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 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (4개)
John D'Errico
2022년 3월 1일
편집: John D'Errico
2022년 3월 1일
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
John D'Errico
2022년 3월 4일
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
2022년 3월 4일
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
Matt J
2022년 3월 1일
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.
댓글 수: 0
Alan Weiss
2022년 3월 1일
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
댓글 수: 0
Matt J
2022년 3월 4일
편집: Matt J
2022년 3월 4일
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])
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!