Why did I get two different results in nonlinear programing problems
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Torsten
el 22 de Jul. de 2024
Movida: Steven Lord
el 22 de Jul. de 2024
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 comentarios
John D'Errico
el 22 de Jul. de 2024
Editada: John D'Errico
el 22 de Jul. de 2024
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 comentarios
Ver también
Categorías
Más información sobre Biological and Health Sciences en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!