Originally posted by: SystemAdmin
As in other flavors (C++, Java) of Concert you create this kind of constraint using the IfThen, Or and And member functions of class Cplex.
Unfortunately, it seems that IfThen is not documented in the reference documentation (but And and Or are).
However, IfThen works exactly like in the other Concert APIs, so you may check there. For your first constraint the code would look like this
using ILOG.Concert;
using ILOG.CPLEX;
public class Indicator {
public static void Main(string[] args) {
try {
Cplex cplex = new Cplex();
INumVar alph10 = cplex.NumVar(0, 1, "alph10");
INumVar d5 = cplex.NumVar(0, 1, "d5");
INumVar d8 = cplex.NumVar(0, 1, "d8");
INumVar OP = cplex.NumVar(0, 1, "OP");
cplex.Add(cplex.IfThen(cplex.Eq(alph10, 1.0),
cplex.Le(cplex.Sum(cplex.Diff(d8, d5), OP), 3)));
cplex.ExportModel("indicator.lp");
cplex.End();
}
catch (ILOG.Concert.Exception e) {
System.Console.WriteLine("Concert exception caught '" + e + "' caught");
}
}
}
#CPLEXOptimizers#DecisionOptimization