Square root in objective function must appear as nonlinear constraints for optimization?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
The title already described my question. Let me give a specific example:
If I have
in my objective function for fmincon to optimize. During the iterations,
may be smaller than 0.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207162/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207163/image.png)
Therefore, do I need to write
as nonlinear constraints or does Matlab already take account of the problem?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207164/image.png)
Thank you very much!
0 comentarios
Respuestas (4)
Matt J
el 6 de Mzo. de 2019
Editada: Matt J
el 6 de Mzo. de 2019
You should omit square roots, because they introduce both unneccesary additional computation and non-differentiability into the cost function, which breaks the theoretical assumptions of fmincon. In your example, the problem could be equivalently posed without square roots as
min x^2
s.t. x^2>=100
6 comentarios
Matt J
el 6 de Mzo. de 2019
Editada: Matt J
el 6 de Mzo. de 2019
Lastly, Matt, could you please kindly tell me what is the non-differentiability issue? I can differentiate my objective function and nonlinear constraints easily.
The function sqrt(z) has no derivative at z=0. In your case, the function f and hence also t(f) is non-differentiable wherever -x^3+2*x+99=0. So, if the optimal solution lies near such a point, fmincon will not be able to use gradients to find its way there.
What is |t(f)-data|? Is it a least squares objective or is it the L1 norm error between t(f) and |data|? The L1 norm also has differentiability issues.
Matt J
el 7 de Mzo. de 2019
Editada: Matt J
el 7 de Mzo. de 2019
One general way to get rid of sqrt expressions in the objective is to replace them with an additional nonlinearly constrained variable, e.g., instead of
f=a+b^2+sqrt(-x^3+2*x+99)
have instead,
f=a+b^2+c
s.t. c^2=-x^3+2*x+99
c>=0;
All of the above expressions, both in the objective and the constraints, are now differentiable everywhere.
1 comentario
SandeepKumar R
el 6 de Mzo. de 2019
Yes, you need to specify that constraint as ignoring this will lead infeasibilty. This is true for any optimizer
0 comentarios
Walter Roberson
el 6 de Mzo. de 2019
if you have fractional power of a polynomial (not a multinomial) then manually solve for the bounds and express them as bounds constraints . Bounds constraints are respected in most situations .
You might end up with discontinuous ranges. If so it can often be more efficient to run the ranges as separate problems and take the best solution afterwards . Nonlinear constraints are much less efficient to deal with .
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!