フィルターのクリア

Fmincon finds no solution with break Points

2 ビュー (過去 30 日間)
Daniela Würmseer
Daniela Würmseer 2022 年 8 月 29 日
コメント済み: Daniela Würmseer 2022 年 8 月 29 日
Hello, i want to solve the following Problem. I have the Problem that sometimes i get a solution to the Problem and sometimes not (for example if i set a breakpoint by cneq = f1(x)-z(1)-eps). If the Problem is not finding a solution then exitflag = -5 (does someone knows what -5 means?)
Does someone has an idea why sometimes i get a solution and sometimes not?
f1 =@(x) 10*(x(1)-2)^4+10*(x(1)-2)^3+10*(x(2)-2)^4+10*(x(2)-2)^3 + 10;
f2 =@(x) (x(1)-3)^2+(x(2)-3)^2 + 10;
Aneq = [-1 -1;
1 0;
0 1;
-1 0;
0 -1];
bneq = [-0.1; 10; 10; 0; 0];
x0 = [2.0595,2.0595];
z = [8.5913,14.6933];
eps = 1.4129;
[x,fval] = test(f1,f2,Aneq,bneq,x0,z,eps);
function [x,fval] = test(f1,f2,Aneq,bneq,x0,z,eps)
f = @(x) f2(x);
nonlincon = @constr;
function [cneq,cq] = constr(x)
cneq = f1(x)-z(1)-eps;
cq = [];
end
opts = optimoptions(@fmincon,'Algorithm','sqp', 'MaxFunctionEvaluations',3000,'FunctionTolerance', 1e-10,'ConstraintTolerance',1e-10);
problem = createOptimProblem('fmincon','objective',f,'x0',x0,'Aineq',Aneq,'bineq',bneq,'nonlcon',nonlincon,'options',opts);
gs = GlobalSearch;
gs.MaxTime = 1;
[x,fval,exitflag,output] = run(gs,problem);
if output.localSolverSuccess == 0
return;
end
end
Thank you.
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 8 月 29 日
https://www.mathworks.com/help/gads/globalsearch.run.html#d123e65923
-5 is time limit exceeded.

サインインしてコメントする。

回答 (1 件)

Torsten
Torsten 2022 年 8 月 29 日
The code below works. Do you have an example where it fails ?
f1 =@(x) 10*(x(1)-2)^4+10*(x(1)-2)^3+10*(x(2)-2)^4+10*(x(2)-2)^3 + 10;
f2 =@(x) (x(1)-3)^2+(x(2)-3)^2 + 10;
lb = [0 0];
ub = [10 10];
Aneq = [-1 -1];
bneq = [-0.1];
x0 = [2.0595,2.0595];
z = [8.5913,14.6933];
eps = 1.4129;
[x,fval] = test(f1,f2,Aneq,bneq,lb,ub,x0,z,eps)
GlobalSearch stopped because it analyzed all the trial points. All 13 local solver runs converged with a positive local solver exit flag.
x = 1×2
2.0583 2.0583
fval = 11.7735
exitflag = 1
output = struct with fields:
funcCount: 2692 localSolverTotal: 13 localSolverSuccess: 13 localSolverIncomplete: 0 localSolverNoSolution: 0 message: 'GlobalSearch stopped because it analyzed all the trial points.↵↵All 13 local solver runs converged with a positive local solver exit flag.'
x = 1×2
2.0583 2.0583
fval = 11.7735
function [x,fval] = test(f1,f2,Aneq,bneq,lb,ub,x0,z,eps)
f = @(x) f2(x);
nonlincon = @constr;
function [cneq,cq] = constr(x)
cneq = f1(x)-z(1)-eps;
cq = [];
end
opts = optimoptions(@fmincon,'Algorithm','sqp', 'MaxFunctionEvaluations',3000,'FunctionTolerance', 1e-10,'ConstraintTolerance',1e-10);
problem = createOptimProblem('fmincon','objective',f,'x0',x0,'Aineq',Aneq,'bineq',bneq,'lb',lb,'ub',ub,'nonlcon',nonlincon,'options',opts);
gs = GlobalSearch;
gs.MaxTime = 1;
[x,fval,exitflag,output] = run(gs,problem)
if output.localSolverSuccess == 0
return;
end
end
  3 件のコメント
Torsten
Torsten 2022 年 8 月 29 日
編集済み: Torsten 2022 年 8 月 29 日
Walter answered this as "Time limit exceeded".
And better put bounds on the variables in lb and ub instead of Aineq and bineq.
Daniela Würmseer
Daniela Würmseer 2022 年 8 月 29 日
Thank you I tried to put bounds in my Alg where i could have. But as my Algorithmus should work for different kind of Problems i cannot put bounds here.
I even already tried with gs.MaxTime = 10 but it changes nothing.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSolver 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