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

  • Context: MATLAB 
  • Thread starter Thread starter math8
  • Start date Start date
  • Tags Tags
    Matlab Minimization
Click For Summary
SUMMARY

The discussion centers on the use of MATLAB's fmincon function for solving a nonlinear minimization problem with constraints. Users reported that different feasible initial points yield vastly different results, highlighting the sensitivity of optimization algorithms to starting conditions. Specifically, an initial point of x0=[-1; -2] produced an incorrect minimizer of [-0.7921; -1.2624] with an objective value of 360.3798, while x0=[0.4; 4] led to the correct minimizer of [0.5; 2] with an optimal objective value of 306.5000. This illustrates the importance of selecting appropriate initial points in optimization tasks.

PREREQUISITES
  • Familiarity with MATLAB and its optimization toolbox
  • Understanding of nonlinear programming and constraints
  • Knowledge of the fmincon function and its parameters
  • Basic concepts of optimization algorithms, particularly Conjugate Gradient
NEXT STEPS
  • Explore advanced features of MATLAB's fmincon, including options for constraint handling
  • Learn about visualization techniques for optimization problems in MATLAB
  • Investigate the effects of different initial points on optimization outcomes
  • Study alternative optimization algorithms available in MATLAB, such as genetic algorithms or simulated annealing
USEFUL FOR

This discussion is beneficial for MATLAB users, optimization researchers, and engineers involved in nonlinear programming, particularly those seeking to improve their understanding of constraint handling and initial point selection in optimization 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: 966
Last edited:

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K