Optimization giving unexpected results

2 ビュー (過去 30 日間)
Gimpy
Gimpy 2014 年 8 月 11 日
コメント済み: Gimpy 2014 年 8 月 11 日
Hi, I'm trying to optimize a function which I know the results but matlab is giving me weird results. Here's what I'm trying to do:
max: f(x)= 1815x1+379x2
subject to: -1475x1-112013x2 >= -700000
x1,,x2<=80
x1,x2>=0
How would you do it?
  3 件のコメント
Yu Jiang
Yu Jiang 2014 年 8 月 11 日
編集済み: Yu Jiang 2014 年 8 月 11 日
Can you share your code? Which built-in function are you using?
Bear in mind that both functions fminsearch and fmincon search for the minimum not the maximum.
-Yu
Gimpy
Gimpy 2014 年 8 月 11 日
f = [1815;379]
A = [-1475 -11203]
b = [-700000]
ub= (ones(1,2)*80)'
lb = zeros(2,1)
x = linprog(f,A,b,[],[],lb,ub)

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

採用された回答

Yu Jiang
Yu Jiang 2014 年 8 月 11 日
編集済み: Yu Jiang 2014 年 8 月 11 日
Hi Gimpy
Since linprog finds the minimum for the function f(x) but the problem you are trying to solve is a maximization problem, I suggest you change f = [1815;379] to f = -[1815;379]. That is to say, you solve the following problem instead
min: f(x)= - 1815x1 -379x2
subject to: -1475x1-112013x2 >= -700000
x1,,x2<=80
x1,x2>=0
There will only be a sign difference on the objective function. The optimal solutions x will be the same.
-Yu
  6 件のコメント
Yu Jiang
Yu Jiang 2014 年 8 月 11 日
Hi Gimpy
The answer seems not correct, since -1475*40 -11203*80 = -955240 <=700000, meaning the first inequality constraint is not satisfied.
Also, linprog treats inequality constraints as "<=" by default, not ">=". So your A and b matrices should be A = [1475 11203] and b = 700000
-Yu
Gimpy
Gimpy 2014 年 8 月 11 日
Yes after a double check I realized it's my model that was mispecification not the matlab function that I don't understand. My understanding was correct. thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver 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