フィルターのクリア

Plot function in Non-linear optimization

2 ビュー (過去 30 日間)
Srinivasan Balan
Srinivasan Balan 2020 年 11 月 26 日
%% 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 件)

カテゴリ

Help Center および File ExchangeNonlinear Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by