Effacer les filtres
Effacer les filtres

Plot function in Non-linear optimization

2 vues (au cours des 30 derniers jours)
Srinivasan Balan
Srinivasan Balan le 26 Nov 2020
%% 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?

Réponses (0)

Catégories

En savoir plus sur Nonlinear Optimization dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by