Incorrect solution for symmetric problems in fmincon

3 ビュー (過去 30 日間)
Sargondjani
Sargondjani 2019 年 4 月 22 日
コメント済み: Sargondjani 2021 年 12 月 18 日
If I maximize XX(1)^2+XX(2)^2 subject to x1 + x2 <=1 and use starting value X0=[0.5,0.5] I get as solution X=[0.5,0.5], although the two optima are X=[1,0] and X=[0,1].
Any clue how to prevent this from happening? (Other than using an asymmetric starting value). I already tried changing algorithm to sqp but that doesn't help.
See code:
function [XX,VAL] = test_con_opt()
clc;
close all;
dbstop if error;
sum_x = 1;
AA = [1,1];
bb = sum_x; %Inequality constraint: x1 + x2 <= sum_x
lb = [0,0];
pwr = 2;
%X0 = [0.25,0.75];
%X0 = [0.75,0.025];
X0 = [0.5,0.5];
[XX,mVAL] = fmincon(@(XX)obj_fun(pwr,XX(1),XX(2)),X0,AA,bb,[],[],lb);
VAL = - mVAL;
end
function [mVAL] = obj_fun(pwr,x1,x2)
mVAL = - (x1^pwr + x2^pwr);
end

採用された回答

Alan Weiss
Alan Weiss 2019 年 4 月 22 日
fmincon is a gradient-based algorithm. When your initial point is [0.5,0.5], the gradient is zero, and fmincon stops, since it is at a stationary point.
In general, you can take random initial points, which are unlikely to be exact stationary points (assuming that stationary points are isolated).
Alan Weiss
MATLAB mathematical toolbox documentation
  3 件のコメント
Matt J
Matt J 2021 年 12 月 18 日
編集済み: Matt J 2021 年 12 月 18 日
It seems to me that it could conclude that from a comparison of the gradient of objective & linear constraint.
On the contrary, the gradient of the objective at your initial point is grad=[-1,-1]. Therefore in both feasible directions u= [1,-1] and u=[-1,1], the directional derivative is zero. So, the algorithm cannot see a feasible direction of increase or decrease.
Sargondjani
Sargondjani 2021 年 12 月 18 日
Thanks Matt. I understand now it's really a second order thing.

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

その他の回答 (0 件)

カテゴリ

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