# Large scale linear programming (Data imported from .mat file)

I tried to run a large scale linear programming with mathematica. I entered the code below:

Import["A,B.mat", "LabeledData"]
x = LinearProgramming[{0, 0, -1}, A, B, {{-1, 100}, {0, 100}, {0, 100}}];
c.x


where A, B are two large scale matrices. {{-1, 100}, {0, 100}, {0, 100}} are bounds of variabels of linear programming. The code doesn't work and I think there is sth wrong with importing matrices A and B. How can I fix that?

-
Please provide the data file so we can see for ourselves. – Mr.Wizard Jan 28 '14 at 9:43
@Mr.Wizard Sorry. How can I add it to post? It is a .mat file (344 KB) – user2667048 Jan 28 '14 at 11:54
You will need to upload it somewhere accessible. I'm sorry, but StackExchange does not provide that service. Nevertheless without the data I feel that this question is impossible to answer. – Mr.Wizard Jan 28 '14 at 12:12
@Mr.Wizard data file added. – user2667048 Jan 28 '14 at 12:19
@user2667048 you can try imp = Import["A.mat", "LabeledData"]; AA = "A" /. imp ; BB = "B" /. imp ; x = LinearProgramming[{0, 0, -1}, AA, Flatten@BB, {{-1, 100}, {0, 100}, {0, 100}}]; – s.s.o Jan 28 '14 at 12:47

If you carefully check what has been imported, you'll see that it imports matrix labels and the values.

imp = Import["A.mat", "LabeledData"];


{"A" -> {{-1.13043, 1., 1.50927}, {-1.13043, 1., 1.50927},...

(*Get A and B matrix values*)
AA = "A" /. imp ;
BB = "B" /. imp ;


And flatten BB so that it becomes a vector.

x = LinearProgramming[{0, 0, -1}, AA, Flatten@BB,
{{-1, 100}, {0, 100}, {0, 100}}];
c x

-
That's work. It's amazing that definition of inequality constrained in Mathematica and MATLAB are not the same. (I can't vote up! Thanks +1) – user2667048 Jan 28 '14 at 15:00