Effacer les filtres
Effacer les filtres

How can I write a self scaling function for fmincon ?

1 vue (au cours des 30 derniers jours)
Tim
Tim le 28 Nov 2018
Commenté : Matt J le 30 Nov 2018
Hey,
I use fmincon and I want to maximize this function =
fun = @(x) -(x(1)*x(2)*x(3))
and now I do not want to change this function everytime I in- or decrease the size of my optimization.
For example:
If I am looking for 6 solutions my function should look like this =
fun = @(x) -(x(1)*x(2)*x(3)*x(4)*x(5)*x(6))
Is there a way to do it automatically ?
Thank you so much!

Réponse acceptée

Matt J
Matt J le 28 Nov 2018
Modifié(e) : Matt J le 28 Nov 2018
fun = @(x) -sum(log(x))
  11 commentaires
Tim
Tim le 30 Nov 2018
Ah okay. I will try this as well. One additional question came to my mind: Is my code a good way to minimize each of the objective values individually or would you suggest something else?
Matt J
Matt J le 30 Nov 2018
What is "each of the objective values"?

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 28 Nov 2018
@(X) -prod(X)
  2 commentaires
Matt J
Matt J le 28 Nov 2018
Care is needed here to avoid overflow/underflow.
Tim
Tim le 29 Nov 2018
Thank you for answer! I appreciate that you are so passionate to solve my problem.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Surrogate Optimization dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by