필터 지우기
필터 지우기

why there is a different value between the latest Fval and the Optimal Solution that Fmincon gives me

조회 수: 1 (최근 30일)
The output that Fmincon gives to me are correct absolutely,but when I check the iterations, at the latest iteration ,Fval=3.742029e-12,which is not the optimal function value:x=(1,1),fun=0,the Fval should be 0 instead of 3.742029e-12. How Fincon gets the optimal solution x=(1,1)
here are my codes:
lb=[-5,-5];
ub=[5,5];
fun = @(x)100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
A = [];
b = [];
Aeq = [];
beq = [];
x0 = [0.0,0.0];
nonlcon = [];
options = optimoptions('fmincon','Display','iter','Algorithm','sqp');
x= fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)

채택된 답변

Alan Weiss
Alan Weiss 2021년 11월 22일
The answer is correct to within tolerances. Generally, you cannot expect an answer that is correct down to the last few decimal places. To learn more ablut what you can expect from floating-point calculations, see
Alan Weiss
MATLAB mathematical toolbox documentation

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by