Effacer les filtres
Effacer les filtres

How to use a constraint on the output of a goal function?

6 vues (au cours des 30 derniers jours)
Tworit Dash
Tworit Dash le 12 Oct 2023
Commenté : Tworit Dash le 16 Oct 2023
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.

Réponse acceptée

Torsten
Torsten le 12 Oct 2023
Modifié(e) : Torsten le 12 Oct 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 commentaires
Torsten
Torsten le 12 Oct 2023
Modifié(e) : Torsten le 12 Oct 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.
Tworit Dash
Tworit Dash le 16 Oct 2023
I will try the second way; because I want to compute F inside the Goal function. And I can not try the product, because it is kind of a log-likelihood which in linear form is very low in value.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by