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?

2 ビュー (過去 30 日間)
jessie sun 2022 年 3 月 1 日
コメント済み: Matt J 2022 年 3 月 4 日
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？

サインインしてコメントする。

回答 (4 件)

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 件のコメント表示非表示 6 件の古いコメント
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 件のコメント表示非表示 -1 件の古いコメント

サインインしてコメントする。

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.
Alan Weiss
MATLAB mathematical toolbox documentation
0 件のコメント表示非表示 -1 件の古いコメント

サインインしてコメントする。

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])

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by