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 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