fmincon exitflag 2 and different results with different initial points

7 次查看(过去 30 天)
I am solving a nonlinear optimization problem using fmincon, in which I have only 2 decision variables, with the following lower and upper bounds:
lb = [1228.527,837.942]
ub = [1728.527,1337.942]
and the equality constraint: x1 + x2 = 2566.469
my objective function has no closed form solution and calls a program that returns values depending on the values of x1 and x2.
Here is a plot of the values of the objective function for different values of x1 and x2:
However, this picture may be a bit misleading, since the objective function has several small ups and downs when zoomed in:
If I use fmincon default options, the analysis ends at the initial point as a local minimum.
so I have tried using:
options = optimoptions('fmincon','FiniteDifferenceStepSize',1e-3);
The problem I have is that using different initial points, such as:
x0(1) = lb(1) + 0.15*500
x0(2) = lb(2) + 0.85*500
and
x0(1) = lb(1) + 0.85*500
x0(2) = lb(2) + 0.15*500
these result in very different results, such as (1317,1249) and (1653,913)
also, the exitflag I get is 2. I hoped I could get an exitflag of 1 and, at least, similar results with different initial points
Does anyone have any suggestions on how to calibrate fmincon options in this case or which algorithm should I use?
I am running patternsearch now, but I am pretty sure that different initial points will give different results...

回答(1 个)

Matt J
Matt J 2020-8-31
编辑:Matt J 2020-8-31
You should use your equality constraint to eliminate one of the variables, e.g.,
x2 = 2566.469-x1
lb=max( [1228.527, 2566.469-1337.942] ); %lower bound on x1
ub=min( [1728.527, 2566.469-837.942] ); %upper bound on x1
Once you have things in the form of a 1-dimensional problem, you can just evaluate your function on a linspace of x1 values to get the minimum, or at least to get an initial guess very close to the global solution. Once you have a good initial guess, you can refine it using fminbnd. Note that unlike fmincon, fminbnd will handle non-differentiable objective functions, which your objective appears to be.
  3 个评论
Matt J
Matt J 2020-8-31
编辑:Matt J 2020-8-31
If you have a general non-convex, non-differentiable objective in 8 unknowns, my recommendation would be to try ga(). It is clear, in any case, why a local optimizer like fmincon may give you different solutions for different initial guesses - that's what local optimizers do when you initialize too close to local minima. It is also clear that if your function is not differentiable, you may not be able to drive the first order optimality measures to zero, which is what exitflag=1 requires.
Conrado Neto
Conrado Neto 2020-8-31
thanks I will try ga then..
I thought fmincon options could be adjusted for this case

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver 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