How to use a constraint on the output of a goal function?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have an optimization problem where I have 5 variables to optimize. I am using fmincon now wih sqp approach, but in future I may use some other methods as well. The issue is that for some specific combinations of my variables, the goal becomes a complex number, which is not desriable. I was wondering how to avoid these combinations.
For example, if F is my goal I want to set some check to see if F is a real number (and then accept it as a candidate). How can I do it? I have checked the documentation and I have just found setting up a constraint function that works as F <= 0, however I can't think of a clever way to tune this to my complex number problem.
0 Commenti
Risposta accettata
Torsten
il 12 Ott 2023
Modificato: Torsten
il 12 Ott 2023
You must ask yourself: How could the objective function become complex-valued ? Maybe you have a log(x) expression in it and the x became negative ? Or you have an x^a expression in it and the x became negative ?
Once you found the reason, you might be able to set a constraint - either as a lower or upper bound on parameters or in the function "nonlcon" - to avoid this.
3 Commenti
Torsten
il 12 Ott 2023
Modificato: Torsten
il 12 Ott 2023
The first thing I would try is to define the product of the F_n as objective function.
The second thing I would try is to check in your objective function whether all F_n are > 0. If not, return -Inf or NaN (assuming you want to maximize).
The third thing I would try is to define F_n >= 0 for all n in "nonlcon" as constraints.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!