Plot function in Non-linear optimization
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
%% Introduction to Constrained non-linear minimization
%Objective
fcn=@(x,y) log(1+3*(y-(x.^3-x)).^2+(x-4/3).^2);
%% plot
fsurf(fcn,[-2.5 2.5],'ShowContours','on')
view(127,38)
%% Create optimization
prob=optimproblem;
%% define variables
x=optimvar('x','LowerBound',-2.5,'UpperBound',2.5);
y=optimvar('y','LowerBound',-2.5,'UpperBound',2.5);
%% Define objective
prob.Objective = log(1+3*(y-(x.^3-x)).^2+(x-4/3).^2);
%% set optimization options
initialpt.x=-1;
initialpt.y=2;
options=optimoptions(prob,'Display','iter','OutputFcn',@plotUpdate);
%% solve the problem
[sol,fval,exitflag,output] = solve(prob,initialpt,'Options',options);
I am unable to get the @plotUpdate command working and thus, I do not get the contour plot with optimal x path. Could someone help me?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Nonlinear Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!