Why did I get two different results in nonlinear programing problems
2 ビュー (過去 30 日間)
古いコメントを表示
clear,clc
A = [1 4 5
4 2 6
5 6 3];
prob = optimproblem;
x = optimvar('x',3);
con = sum(x.^2) == 1;
prob.Constraints.con = con;
prob.Objective = x'*A*x;
x0.x = zeros(3,1);
% x0.x = rand(3,1);
show(prob)
[sol,fval,flag,out] = solve(prob,x0)
sol.x
when the initial point is zeres(0),fval is 0,sol.x is [0;0;0].
but when it is rand(3,1),fval is -3.66.
I can't understand this reason
0 件のコメント
回答 (2 件)
Torsten
2024 年 7 月 22 日
移動済み: Steven Lord
2024 年 7 月 22 日
As you can see from the solver message, with x0 = [0 0 0], fmincon converged to an infeasible point. So you didn't get a solution, but "fmincon" failed.
0 件のコメント
John D'Errico
2024 年 7 月 22 日
編集済み: John D'Errico
2024 年 7 月 22 日
You have a nonlinear problem. You need to understand that given any set of starting values, an optimizer will sometimes find a solution though it need not always find the same solution since nonlinear problems will often have multiple solutions, sometimes it will get stuck at a non-solution but unable to find someplae better to look from that point, and thirdly, sometimes it will fail to go anywhere, being unable to even find a feasible point to begin iterations.
When you started the solver at all zeros, it got stuck, in the last mode. I might point out that all zeros is often the worst possible place to start a nonlinear solver.
Remember that nonlinear solvers are not some god-like computational beings, always able to solve any problem. They are far closer to my oft used example of a blind person placed on the earth at some point, and then asked to find the point of lowest elevation. The only gear this person is given is a cane to determine a direction to look next, and an altimeter to learn the current elevation. (Ok, some scuba gear might be nice too.) But clearly this individual will often fail to find a viable point, and unless your initial point is a good one, they will often fail to find the globally best location, in the depths of the Pacific Ocean.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Biological and Health Sciences についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!