how to write or constrains optimization

my problem in how to write the syntx of equality constrains in optimization for thatcase
x(1) =50 OR x(1) =20

Respuestas (1)

John D'Errico
John D'Errico el 3 de Feb. de 2020

0 votos

For which optimization tool? fmincon? You can't.
This essentially reduces to a discrete optimization problem. You can think of it as essentially a binary integer programming problem. Tools like fmincon cannot handle discrete variables. Period. fmincon assumes a continuously differentiable objective function of the parameters.
You can use the GA optimizer however. It allows discrete variables as an alternative.
And, of course, if you have only one variable that takes on just two possible levels, then you can make it even simpler - just run the optimization twice, setting x(1) in each case to 20 and then to 50. Take the better of the two solutions, and you have the optimal solution.

La pregunta está cerrada.

Preguntada:

el 3 de Feb. de 2020

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by