Search code examples
matlabmathematical-optimizationlinear-programming

MATLAB linprog max iterations reached


I had written the following matlab code to optimize the following LP

  max b'x
  s.t A'x <= 0;
      x <= d;

Also d is

 d = {1,2..m}

and A is defined in the code. I am getting the error:

Maximum number of iterations exceeded; increase options.MaxIter.

Upon googling, someone said it is not very good that the error is occuring. and the problem has to reformulated. Any idea how to reformulate it.

The solution is very simple as A > 0, b> 0 and d>0 therefore x = 0

m   = 10;

d = [1:1:m];

for j = 1:m,
    for i = 1:m,
        A(i,j) = 1/(i+j-1);
    end
end
for i = 1:m,
    b(i)=0;
end
for i = 1:m
    lb(i) = -inf;
end
b;
lb = lb';

f = A*d';
[x,fval,exitflag,output] = linprog(-f,A,b,[],[],lb,d); %minimzation problem. Hence -f, A = A'

Solution

  • I'd used the optimist = ('MaxIter', 10000). To stop that error message.