fmincon with nonlcon does not converge to optimum value

1 次查看(过去 30 天)
function [c ceq] = test_simple(x)
c=[];
ceq=x(1)*x(2);
end
clear;
clc;
fun = @(x) -x(1)^2-x(2)^2
lb = [0;0.2;];
ub = [0.5;0.8];
A = [];
b = [];
Aeq = [];
beq = [];
x0 = [0;0.1];
nonlcon=@test_simple;
options = optimset('MaxFunEvals',Inf,'MaxIter',5000,...
'Algorithm','interior-point','Display','iter');
[x1, fval1] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,optimset)
optimum value is 0 0.8 but, matlab execution value is
x1 =
0.0000
0.7153
how do i fix it?
  1 个评论
Torsten
Torsten 2017-9-27
You don't have to pass "optimset" to "fmincon", but "options":
[x1, fval1] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)
Best wishes
Torsten.

请先登录,再进行评论。

采纳的回答

Alan Weiss
Alan Weiss 2017-9-27
The 'interior-point' algorithm cannot allow for points that are right on a boundary, yet your nonlinear constraint attempts to force the points to the boundary. I suggest that you do one of the following:
  • Change the lower bound on x(1) to a negative number such as lb = [-0.1;0.2]
  • Use the 'sqp' algorithm
  • In any case, use a feasible initial point, such as [1e-8;0.3]
Also, after fmincon finishes, try running it again from the final point if the answer isn't reliable (exit flag not equal to 1).
Alan Weiss
MATLAB mathematical toolbox documentation

更多回答(1 个)

Walter Roberson
Walter Roberson 2017-9-27
fmincon is not a global optimizer. You need one of the tools from the Global Optimization Toolbox, such as ga or particleswarm or bounded simulated annealing or patternsearch. (Note: none of those can promise to find the global minima either -- but fmincon doesn't even try.)

类别

Help CenterFile Exchange 中查找有关 솔버 출력값과 반복 과정 표시 的更多信息

Community Treasure Hunt

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

Start Hunting!