0

I am using a function in Matlab based on lp_solve. In my case, lp_solve is structured as follows:

 A = rand (13336,3); %A is made of real numbers between 0 and 1. For this mwe, I thought 'rand' was fine
 W = [0; 0; 1];
 C = A(:,3);
 B = 1E+09;
 e = -1;
 m= 13336;
 xint = linspace(1,13336,13336);
 xint = xint';
 obj = lp_solve(A*W,C,B,e,zeros(m,1),ones(m,1),xint)

But when I run it, I get this error:

Error using mxlpsolve
invalid vector.

Error in lp_solve (line 46)
mxlpsolve('set_rh_vec', lp, b);

Error in mylpsolvefunction (line 32) %This is my function that uses lp_solve 
    obj = lp_solve(A*W,C,B,e,zeros(m,1),ones(m,1),xint);

I looked in the documentation, and it say, under the chapter "Matrices" that:

[...] if a dense matrix is provided, the dimension must exactly match the dimension that is expected by mxlpsolve. Matrices with too few or too much elements gives an 'invalid vector.' error. Sparse matrices can off course provide less elements (the non provided elements are seen as zero). However if too many elements are provided or an element with a too large index, again an 'invalid vector.' error is raised.

I did not understand what they mean when they say that the dimension "must exactly match the dimensions that is expected by mxlpsolve". Anyway, since they say that the error my also occur "if too many elements are provided", I tried to "cut" my inputs from 13336 elements to 50 (I am sure it works with 58 and I am quite sure it does also with 2000), but also this way I receive the same error. What may the problem be?

Patapunfate
  • 297
  • 1
  • 4
  • 12
  • What is `m`? And your `linspace` call gives an error. Please provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – nirvana-msu May 29 '16 at 18:37
  • `m` is equal to 13336, too. I modified my example (introduced m and corrected the `linspace`) now it replicates my problem. – Patapunfate May 30 '16 at 06:48

0 Answers0