When I'm using the fmincon function to solve an optimization problem,the optimization result is always near the initial value. How to avoid this situation?

4 Ansichten (letzte 30 Tage)
When I'm using the fmincon function to solve an optimization problem,the optimization result is always near the initial value. How to avoid this situation?Is it useful to modify steptolerance?

Antworten (4)

John D'Errico
John D'Errico am 1 Mär. 2022
Bearbeitet: John D'Errico am 1 Mär. 2022
Resetting the step tolerance will probably not help. In fact, that may be a bad idea, or it may be what you need. Before you try to do something like that, you need to know WHY the solver is stalling, or is it stalling at all? What is the returned exit flag?
Far more likely, your problem is ill-posed in some way. Possibly there are hugely many solutinos. Possibly, there are infinitely many solutions, all of which lie along some path through your solution space. Possibly you have done something in the objective that causes a quantization in some form, or perhaps you have some sort of randomization in the objective function. (Yes, people do things like that, and then try to optimize the result.)
But my point is, we cannot know what you have only from your vague description of what happens. We only know that you have a problem that proves difficult to solve. Why? God only knows, at least so far.
If you want better help, then you would need to show a working example of the objective function, that someone can test out. If any data is needed to run it, then provide that. (Do all of this attached to a COMMENT, or to your original question by editing the question, not as an answer, please.) If you do this, then someone can try running the function, and certainly to look at your code. We would want to look at what fmincon returns. What is the exit flag reported?
  7 Kommentare
John D'Errico
John D'Errico am 4 Mär. 2022
And that is exactly what I said would be a problem. That makes your problem not possible to be solved using fmincon. Your function is not continuous, and it certainly is not differentiable.
You might try using GA instead, which can handle such irregular objectives.
Matt J
Matt J am 4 Mär. 2022
It doesn't sound like it's a problem of differentiability if the binary constraints are enforced by a nonlinear constraint function. If the OP has done as below, everything is differentiable, but still problematic.
function [c,ceq]=nlcon(x)
c=[];
ceq=x.*(x-1);
end

Melden Sie sich an, um zu kommentieren.


Matt J
Matt J am 1 Mär. 2022
When I'm using the fmincon function to solve an optimization problem,the optimization result is always near the initial value. How to avoid this situation?
It is not something you should be trying to avoid. The whole idea of the initial guess is that you want to choose it to be as close to the solution as you can.

Alan Weiss
Alan Weiss am 1 Mär. 2022
There is a documentation section about this issue: Final Point Equals Initial Point. There is also the possibility that you are optimizing a simulation or ODE and need to take larger finite differencing steps. See Optimizing a Simulation or Ordinary Differential Equation.
If neither of those sections is relevant, then please give us more information about your problem. What kind of objective function and constraints do you have?
Alan Weiss
MATLAB mathematical toolbox documentation

Matt J
Matt J am 4 Mär. 2022
Bearbeitet: Matt J am 4 Mär. 2022
The initial value sets these variables to 1, and the solution results in these variables are all 1.
If you are rounding your variables to integers, then your objective function will be locally flat in the neighborhood of any initial point x0, similar to the 1D function below. A point that is locally flat is a local minimum, and therefore the solver has no reason to progress beyond x0.
fplot(@(x) round(x),[0,10])

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by