Skip to content

Commit

Permalink
Fixing bug for MILP solver using IBM CPLEX
Browse files Browse the repository at this point in the history
  • Loading branch information
fplanes committed Nov 16, 2017
1 parent ddca100 commit 9d681c7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/base/solvers/solveCobraMILP.m
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@
else
solStat = -1; % Solution not optimal or solver problem
end

case 'ibm_cplex'
% Free academic licenses for the IBM CPLEX solver can be obtained from
% https://www.ibm.com/developerworks/community/blogs/jfp/entry/CPLEX_Is_Free_For_Students?lang=en

cplexlp = Cplex();
if (~isempty(csense))
b_L(csense == 'E') = b(csense == 'E');
Expand Down Expand Up @@ -432,8 +436,8 @@
end

% Get results
x = Result.x;
f = osense*Result.objval;
try x = Result.x; catch x=zeros(size(cplexlp.Model.ub)); end %return zeros if infeasible
try f = osense*Result.objval; catch f=nan; end %return Nan if infeasible
stat = Result.status;
if (stat == 101 || stat == 102 || stat == 1)
solStat = 1; % Opt integer within tolerance
Expand Down

0 comments on commit 9d681c7

Please sign in to comment.