MATLAB Why is MATLAB giving me a wrong answer when solving a minimization problem?

AI Thread Summary
MATLAB's fmincon can yield incorrect minimization results based on the choice of initial feasible points, as demonstrated in a specific minimization problem with nonlinear constraints. When starting from the point x0=[-1; -2], the algorithm produced a non-feasible solution, while a different initial point x0=[0.4; 4] led to the correct minimizer of [0.5; 2]. The issue arises from the optimization algorithm's tendency to approach constraint boundaries, which can result in suboptimal solutions if the starting point is poorly chosen. It is recommended to visualize the function and constraints to better inform the selection of initial points for optimization. Understanding the behavior of optimization algorithms is crucial for achieving accurate results in constrained minimization problems.
math8
Messages
143
Reaction score
0
In MATLAB, I am using fmincon to solve a minimization problem with nonlinear constraints. The problem is that, it is giving me a wrong answer, a point that is not a minimizer (not even close), and that is not within the tolerance. I made sure to use a feasible initial point.

However, when I use another initial feasible point, it gives me a correct answer.

Here is the problem:

min f = 100*(x(2)-x(1)^2)^2+(1-x(1))^2;
s.t. constraints= [1-(x(1)*x(2));-x(1)-(x(2))^2;x(1)-0.5] <= 0

The minimizer is [0.5 ; 2] with optimal objective value: 306.5000

However when I use the feasible initial point x0=[-1 ; -2], this gives me the answer: [-0.7921; -1.2624] (which is not feasible and has an f value of 360.3798 !) (to within options.TolCon = 1e-06)

and when I use the initial point x0=[0.4;4], this gives me the correct answer [0.5 ; 2].

Note that my constraints do not require the variables to be non-negative.

Any idea what I am doing wrong here?
 
Physics news on Phys.org
You're not doing anything "wrong" , but you are being given a demonstration of the potential limitations of optimization algorithms and the need to choose the starting point carefully. I don't have Matlab so I've implemented your function in Mathcad and used its Solve Block capability to minimize the function given the constraints.

If you look at the left hand plot in image below you should see black contour lines (the function), two clusters of blue contour lines (the constraint boundaries) and 4 coloured dots (2 initial points and 2 solutions).

You should note that the first 'incorrect' minimum is within the larger constrained area of the x-y plane and the solution has migrated towards the constraint boundary. The right hand plot may show the descent slightly more clearly. What's happened is that the minimization algorithm (Conjugate Gradient) hits the constraint if it tries to move further down the function slope, so it halts with the best value it can find (which has strayed slightly over the boundary).

The 'correct' minimum starts from the second constrained area and follows the same process of descending the slope until it hits the boundary and can't progress any further. It also is just over the boundary. (The algorithms don't necessarily treat constraints as hard conditions but will try to meet them as closely as possible).

A useful technique is to plot your function first to get a feel for where to start - you may even need to calculate it for several points and choose the minimum.

attachment.php?attachmentid=55019&stc=1&d=1359204745.jpg
 

Attachments

  • phys - 13 01 26 optimization 01.jpg
    phys - 13 01 26 optimization 01.jpg
    48.2 KB · Views: 954
Last edited:

Similar threads

Replies
4
Views
1K
Replies
8
Views
2K
Replies
1
Views
2K
Replies
18
Views
4K
Replies
10
Views
3K
Replies
2
Views
2K
Back
Top