Where I am mistaking?

1 回表示 (過去 30 日間)
Bogdan
Bogdan 2014 年 3 月 8 日
コメント済み: Bogdan 2014 年 3 月 10 日
Hello;
I am trying to make a simple linear programming optimization. I came up with this code:
clear;
y=1663;
f=[100; 100; 100; 100; 100; 100; 100; 100];
A=[1/867.2 1/704.7 1/619.2 1/679 1/770.3 1/658.5 1/749 1/783.1
-105.2 -74.4 -94.3 -88.2 -108.9 999 -112.7 -91.4
-94.1 -71.2 -87.6 -87.8 -99.4 999 -100 -81.2
0.5 0.6 4.5 3 28 15 4.5 12.5
0.78 2.11 0.01 0.01 0.56 0.09 0.02 0.9
93.63 16.3 0.01 0.01 1.44 0.09 0.03 37.64
0.82 3.23 0.03 0.36 3.13 29.97 0.04 16.16];
b=[y/0.775; -95*y; -85*y; 10*y; 1*y; 35*y; 18*y];
Aeq=[1; 1; 1; 1; 1; 1; 1; 1];
beq=y;
lb=zeros(8,1);
hb=[550; 250; 50; 200; 50; 350; 400, 700];
linprog(f, A, b, Aeq, beq, lb, hb);
When I try to run it, it says that The number of rows in A must be the same as the number of elements of b.
A has 7 rows and b has 7 elements, as it can be seen. I cannot see the mistake. Where is it?

採用された回答

Alan Weiss
Alan Weiss 2014 年 3 月 10 日
I believe that your Aeq matrix should be a row vector, not a column vector.
Is your A matrix a vector or a matrix? I mean, don't you need some semicolons to separate the rows?
Alan Weiss
MATLAB mathematical toolbox documentation
  1 件のコメント
Bogdan
Bogdan 2014 年 3 月 10 日
Yes, that was the problem. Aeq should have been a row vector. I gotta love Matlab: it shows the error in a line, but the error is in another line :))
A is a matrix and this time I don't need semicolons, because Matlab interprets it as a matrix in the form that is written. In this case, semicolons are not needed.
Thank you for your help.

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

その他の回答 (1 件)

Dishant Arora
Dishant Arora 2014 年 3 月 8 日
Read the manual properly.
doc linprog
You are missing some input argument while calling.
  3 件のコメント
Dishant Arora
Dishant Arora 2014 年 3 月 8 日
you getting some error??
Bogdan
Bogdan 2014 年 3 月 10 日
Same error, yes :)

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

カテゴリ

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