Can I use GlobalSearch in a for loop to optimize for a parameter range?
Show older comments
Hi all,
I am using GlobalSearch to find the optimal solution for a model with 6 input parameters (v, it models the best tree traits in a certain climate), with the following code:
v = [0.35,0.4,0.6,0.5,0.4,200]; %starting values of input parameters
A = [];
b = [];
Aeq = [];
beq = [];
LB = [0.01,0.01,0.01,0.1,0.01,0]; %lower bounds
UB = [0.9,0.9,0.7,0.7,5,270]; %upper bounds
nonlcon = [];
gs = GlobalSearch('Display','iter'); %solver object
options = optimoptions(@fmincon,'Algorithm','interior-point'); %options
objfun = @LLS_EVDEC; %function to solve (very big vegetation model with Carbon biomass of tree as output to maximize)
problem = createOptimProblem('fmincon','x0',v,'objective',objfun,'lb',LB,'ub',UB,'options',options); %problem structure
[v,fval,eflag,output] = fmincon(problem);
[xming,fming,flagg,outptg,manyminsg] = run(gs,problem);
This optimization runs fine and return the 6 input parameters (v) which I want to know. Now I would like to run this over a range of temperatures. In the @LLS_EVDEC is a temperature array (T, 1x366 array), which I want to increase of decrease with 1-5 degree(s) and run the optimization for.
Is it possible to make a for loop that changes this parameter in the model, and runs the above optimization for every one of these array (so T-5, T-4, ..., T+5), and how would this be implemented in the optimization problem? Can I make a for loop like below and add it to the object function in the problem? Will this make me able to read the iterator into the object function and use it there? like so:
for tt = -5:5
gs = GlobalSearch('Display','iter'); %solver object
options = optimoptions(@fmincon,'Algorithm','interior-point'); %options
objfun = @LLS_EVDEC; %function to solve (very big vegetation model with Carbon biomass of tree as output to maximize)
problem = createOptimProblem('fmincon','x0',v,'objective',objfun(tt),'lb',LB,'ub',UB,'options',options); %problem structure
[v,fval,eflag,output] = fmincon(problem);
[xming,fming,flagg,outptg,manyminsg] = run(gs,problem);
%write away solution into file
end
% In the @LLS_EVDEC function
T = Tstandard + tt;
This is my first time posting a question on the MATLAB forum, so if you need more information that I did not supply, please don't be shy to ask.
Cheers, Anne
1 Comment
infinity
on 2 Aug 2019
Hello,
To solve your problem, the important point is your objective function.
You said that "In the @LLS_EVDEC is a temperature array (T, 1x366 array), which I want to increase of decrease with 1-5 degree(s) and run the optimization for". It is not easy for us to understand what exactly your fitness function. It may help if you can show the code of "LLS_EVDEC".
Answers (0)
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!