I#m trying to model the objective function sum(i in Sites,j in Sites, k in Routings)(c[i][j] * x[i][j][k]*TruckKmCost) in Cplex using java.
IloLinearNumExpr expr = cplex.linearNumExpr();
for (int i = 1; i <= nbFarmer; i++) {
for (int j = 1; j <= nbFarmer; j++) {
for (int k = 1; k <= nbRouting; k++) {
expr.addTerm(truckKmCost, c[i][j],x[i][j][k]);
}
}
}
This was my attempt, but the method addTerm only accepts (double, IloNumVar), and I can't convert c[i][j] to IloNumVar, because I need it as an int so i can add my int values to it.
There must be a pretty easy solution, maybe somebody can help me, I'm a little stumped right now.
Thanks a lot!