Originally posted by: Didier Vidal
Alex,
I am surprised that you could add a numVar to the solver. In CP Optimizer, the decision variables should be integer. You can have float expressions, and constraints on them, but they have to be derived from discrete decision variables. Here is an example in case it helps.
import ilog.concert.IloException;
import ilog.concert.IloIntVar;
import ilog.cp.IloCP;
public
class MyTest
{
public
static
void main(String[] _args)
throws IloException
{ IloCP cp=
new IloCP(); IloIntVar a = cp.intVar(1, 10); IloIntVar b = cp.intVar(1, 10); ilog.concert.IloNumExpr f=cp.quot(a, b); cp.addLe(f, 0.4); cp.addGe(f, 0.3); cp.add(a);
if (cp.solve())
{ System.out.println(
"f="+cp.getValue(f)); System.out.println(
"a="+cp.getValue(a)); System.out.println(
"b="+cp.getValue(b));
}
}
};
The output I have is the following:
! ---------------------------------------------------------------------------- ! Satisfiability problem - 2 variables, 2 constraints ! Initial process time : 0.00s (0.00s extraction + 0.00s propagation) ! . Log search space : 6.6 (before), 5.0 (after) ! . Memory usage : 315.4 Kb (before), 315.4 Kb (after) ! ---------------------------------------------------------------------------- ! Branches Non-fixed Branch decision * 1 0.00s _int0 = 1 ! ---------------------------------------------------------------------------- ! Solution status : Terminated normally, solution found ! Number of branches : 1 ! Number of fails : 0 ! Total memory usage : 336.0 Kb (331.4 Kb CP Optimizer + 4.5 Kb Concert) ! Time spent in solve : 0.00s (0.00s engine + 0.00s extraction) ! Search speed (br. / s) : 100.0 ! ---------------------------------------------------------------------------- f=0.3333333333333333 a=1.0 b=3.0
Didier.
#CPOptimizer#DecisionOptimization