I am solving a Linear Programming using CPLEX in Java. I have a binary decision variable defined as
IloNumVar[] xd = new IloNumVar[Tend];
where Tend is the time. The decision variable is subject to the constraint that the sum over time of xd must be equal a given integer C_d, which was implemented as:
cplex.addEq(cplex.sum(xd), C_d);
So far everything was working.
The problem I am having is that now I am trying to generalize the number of decision variables using a multidimensional array:
IloNumVar[][] xd = new IloNumVar[Tend][count_d];
but I still need to impose the constraint that the sum of each decision variable over time must be equal to a constant. I tried with this:
IloNumVar[] Sum_d = new IloNumVar[Tend];
IloNumVar[] Sum_D = new IloNumVar[1];
for(int j=0;j<count_d;j++){
for (int i = 1; i<Tend; i++){
cplex.addEq(Sum_d[i],cplex.sum(Sum_d[i-1],xd[i][j]));
}
cplex.addEq(Sum_d[Tend],Sum_D);
cplex.addEq(Sum_D,C_d);
}
but I get the following errors: Multiple markers at this line
- The method addEq(IloNumExpr, double) in the type IloCplexModeler is not applicable for the arguments (IloNumVar, IloNumVar[])
- The method addEq(IloNumExpr, double) in the type IloCplexModeler is not applicable for the arguments (IloNumVar[], int)
I am not quite sure what is the proper way to include the equivalent constraint in the problem definition.
Any suggestion would be much appreciated.