Effacer les filtres
Effacer les filtres

how to plot objective function with variables

3 vues (au cours des 30 derniers jours)
RAHUL KUMAR
RAHUL KUMAR le 20 Août 2019
xo=[0.0011,0.0049,0.3]; % assumptions
%[Q]=heatload1_new(xo)
%nvars=3;
A=[];
b=[];
Aeq=[];
beq=[];
lb=[0.001,0.002,0.01]; %lower bound
ub=[0.01,0.08,0.5]; %upper bound
nonlincon = @(x)constraint_new(x); % calling constraint function
Fitnessfun = @(x)weight_testvariable(x); %calling objective function
options = optimoptions(@fmincon,'Display','iter-detailed','Algorithm','sqp','MaxIterations',1500)
options = optimset('Display','iter','TolFun',1e-5)
[X,fval]=fmincon(Fitnessfun,xo,[],[],[],[],lb,ub,nonlincon,options)

Réponses (1)

Alan Weiss
Alan Weiss le 22 Août 2019
You have two definitions of options, meaning the first definition does nothing:
options = optimoptions(@fmincon,'Display','iter-detailed','Algorithm','sqp','MaxIterations',1500) % gets overwritten
options = optimset('Display','iter','TolFun',1e-5)
If you want to plot the objective function value as the optimization runs, set the PlotFcn argument to 'optimplotfval'. If you also want to plot the current point at the same time, set the PlotFcn argument to a cell array, {@optimplotfval,@optimplotx}.
Alan Weiss
MATLAB mathematical toolbox documentation

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by