필터 지우기
필터 지우기

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 CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by