my objective function should be maximized. It has 3 variables that all should be optimized, i.e. the optimization should give 3 optimized variables at the end.

My objective function also has an indicator function that its value depends on one of those 3 variables which has to be optimized. (if that variable is more than something the indicator function is 1 and if the variable is less than something the indicator function is 0). When I write the objective function in Matlab it asks for the variable that the indicator function depends on that. It is unknown yet, so how can I define this kind of objective function in Matlab?

1 commentaire

When I write the objective function in Matlab it asks for the variable that the indicator function depends on that.
Please clarify what you mean by "it asks". Who is "it"? You mean you've written the code so that the indicator function prompts the user for data entry from the keyboard? Then you should rewrite it so that it gets entered as a normal function input argument instead.

Connectez-vous pour commenter.

 Réponse acceptée

Matt J
Matt J le 17 Juin 2017
Modifié(e) : Matt J le 17 Juin 2017
The objective function is always a function of unknown variables. Whichever solver you are using, you need to code the objective as a function of arbitrary values.
However, I recommend that you avoid the indicator function completely, since it introduces discontinuity and non-differentiability into your function. Do the optimization for two cases and take the best result: in one case constraining the indicator variable to be less than the indicator threshold and in the other case by constraining it to be greater. In each case, the indicator reduces to a known value.

4 commentaires

Thanks for your reply Matt. If I avoid the indicator function, my objective function will miss one of its variables that should be optimized, as my indicator function is a function of that variable. So, I asked the question that how I can define the indicator function in Matlab while its variable will be known after optimization.
It will not miss any variables that matter.
If the indicator function is the only thing in your objective that depends on that variable (I'll call it x3), then the optimum is entirely determined by the value of the indicator function. You can get rid of x3 in that case and just replace the indicator function by an unknown binary variable, b. Once you do that, you only need to explore the 2 possible values of b when doing the optimization - hence you can divide the optimization into two cases, as I suggested.
On the other hand, if x3 appears elsewhere in your objective in addition to the indicator function, you can still write the indicator function as b(x3). You then minimize the objective f(x1,x2,x3) over two regions: x3 s.t. b(x3)=0 and x3 s.t. b(x3)=1. This involves doing constrained optimizations, and the solver still iterate non-trivially over x3 (as well as x1 and x2). However, you've gotten rid of the indicator function, just as before.
Thanks for your reply Matt. The indicator function is the only thing in objective that depends on that variable. I did the thing that you advised, but now how should I find the best value for x3?
What value does the indicator function have at the optimum? x3 can be anything that induces that value.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by