Hello,
I am currently migrating the optimization model from CPLEX OPL to CPLEX Concert Technology + Java.
In Java, I would like to define the decision variables based on tuple structure. Would you please help me how to define it?
For example, I have a decision variable in OPL as below.
tuple INDEX{ int employeeID; int offeringID;}{INDEX} indexes {<e, o> | e in employees, o in offerings}
dvar int+ schedule [indexes] in 0..1;In order to define the decision variable (
X) in Java, I first defined class data structure.
class INDEX{
int employeeID;
int offeringID;
}
List<INDEX> indexes = new ArrayList<INDEX>();
IloNumVar[] schedule = cplex.numVarArray(indexes.size(), 0, 1, IloNumVarType.Int);
I would like to have the constraint (
cplex.addEQ(cplex.sum(schedule[indexes]), 1) ), sum of schedule over indexes has to be equal to 1.
The above cplex.addEQ function does not work. Would you please help me how to defined tuple-based decision variables and constraints in Java?
Thank you for your help!
------------------------------
Sung Hwang
------------------------------
#DecisionOptimization