How can I write a self scaling function for fmincon ?

조회 수: 1 (최근 30일)
Tim
Tim 2018년 11월 28일
댓글: Matt J 2018년 11월 30일
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!

채택된 답변

Matt J
Matt J 2018년 11월 28일
편집: Matt J 2018년 11월 28일
fun = @(x) -sum(log(x))
  댓글 수: 11
Tim
Tim 2018년 11월 30일
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 2018년 11월 30일
What is "each of the objective values"?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2018년 11월 28일
@(X) -prod(X)
  댓글 수: 2
Matt J
Matt J 2018년 11월 28일
Care is needed here to avoid overflow/underflow.
Tim
Tim 2018년 11월 29일
Thank you for answer! I appreciate that you are so passionate to solve my problem.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by