Minimizing an objective function

4 ビュー (過去 30 日間)
Eraldo
Eraldo 2014 年 12 月 11 日
コメント済み: Eraldo 2014 年 12 月 16 日
Hi everyone,
I am quite new to Matlab. I want to minimize my objective function, but I have not done it before and I do not know how to minimize the objective function in matlab. Here is a simplified version of the function I need to minimize:
f=3*w(1) +5*w(2) +7*w(3)
st. w(1)+w(2)+w(3)=1
Any code, illustration would help tremendously.
Thanks.

採用された回答

Roger Stafford
Roger Stafford 2014 年 12 月 11 日
編集済み: Roger Stafford 2014 年 12 月 11 日
Unless you place some further constraints on W values, there is no limit to how much 'f' can be reduced. The right answer would be minus infinity. For example, let W(1) = 1, w(2) = +2^50, w(3) = -2^50. Then the sum of the w's is 1 and f is -2^51+3 which is a huge negative number. If you restrict W to non-negative values, then the obvious answer is 3 without the necessity of using matlab.
To learn how to accomplish such a minimization in a general situation, read the documentation for 'fmincon' at:
http://www.mathworks.com/help/optim/ug/fmincon.html
  1 件のコメント
Eraldo
Eraldo 2014 年 12 月 16 日
Thanks for your reply Roger.
Actually, the bounds are zero and one. So, it's a weighted average.
I finished it, BUT I am having difficulties with the for loop inside the function. Instead of the numbers above I need to use my estimates for each period and it just doesn't recognize my estimate. Do you think it might be because of the for loop?
Many thanks in advance.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by