Originally posted by: John Cui
You can use "cplex.addIndicators" method to add logic constraints in MATLAB.
addpath('/opt/CPLEX_Studio/cplex/matlab');
cplex=Cplex();
cplex.addCols([1;2]);
cplex.Model.ctype = 'BB';
cplex.addIndicators(1,1,[0,1]','E',0);
cplex.addIndicators(1,0,[0,1]','E',0);
cplex.writeModel('test.lp') ;
The matlab code with addIndicators:
\ENCODING=ISO-8859-1
\Problem name: CPLEX
Minimize
obj: x1 + 2 x2
Subject To
i1: x1 = 0 -> x2 = 0
i2: x1 = 1 -> x2 = 0
Bounds
0 <= x1 <= Inf
0 <= x2 <= Inf
Binaries
x1 x2
End
John Cui
#CPLEXOptimizers#DecisionOptimization