Inverse of a function gives different results than the negative function with fmincon

조회 수: 3 (최근 30일)
Hello,
I have a function f(x) which I am trying to maximize. Following the suggestions on: Maximizing an Objective - MATLAB & Simulink (mathworks.com), I can define the function to minimize on fmincon as -f(x). This works as well since my boundaries indicate that x needs to be in the positive regime, and my function is actually one of the two variables x itself, specfically f(x)=-x(1).
However, I previously used to define my variable as the inverse of itself in case I wanted to maximize it, so f(x)=1/(x(1)). Now oddly enough, fmincon gives me different results if I define my function this way... I would love to share my files but I cannot for confidentiality. Assuming that the boundaries are not the problem, is this expected behavior with the fmincon solver? Or am I making a mistake somewhere else?
Thanks.
  댓글 수: 2
Mario Malic
Mario Malic 2020년 12월 21일
If you want to minimise, then it's f(x), if you want to maximise then it's -f(x).
Alessandro Maria Laspina
Alessandro Maria Laspina 2020년 12월 22일
Why not 1/f(x)? If the bounds are positive, and the objective function is the optimization variable itself, this should also minimize the function when f(x) gets larger.

댓글을 달려면 로그인하십시오.

채택된 답변

Alan Weiss
Alan Weiss 2020년 12월 22일
The problem could be related to a few things, such as numerical stability and the presence of multiple local minima.
For numerical stability, you didn't tell us the typical ranges of your variables. But for very large or small values, 1/x and -x behave very differently. I expect that your solution might be a large or small number.
For multiple local minima, the fmincon algorithm can take different paths dependinig on many problem inputs, and both results can be true local minima and yet differ.
Without more information, these general optimization characteristics are the best I can offer.
Alan Weiss
MATLAB mathematical toolbox documentation

추가 답변 (2개)

Bruno Luong
Bruno Luong 2020년 12월 22일
If you apply a non-llinear transformation of your decision variables, I would expect the solver behave differently.
The solver is not a miracle blackbox that you can twist in any direction and expect it to be robust.
I relies on the fact that the minimum is on the attraction basin, that the Hessian is more or less change not so quickly, etc....
Transform x -> 1/x will be a major change.

Matt J
Matt J 2020년 12월 22일
편집: Matt J 2020년 12월 22일
With f(x)=-x1, the norm of the gradient of f is always 1. However, with f(x)=1/x1, the norm of the gradient will fall off quadratically as x1 gets larger. It therefore becomes possible that the OptimalityTolerance threshold and/or the FunctionTolerance threshold will be reached sooner than it otherwise would and cause the iterations to stop prematurely. You can try reducing these thresholds to see if there is a helpful effect. However, f(x)=-x1 is probably ythe better way to go, for reasons that others have already mentioned.

카테고리

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