I'm having hard time regarding how to model a constraint. I'm trying to solve a transportation problem and one of the constraints is as follows:
t[s[i]] >= t[i] + travelTime (i, s[i])
which t is the time at which node i is visited and s is the successor variable of node i ( t and s are variables).
I also have a travel time matrix :
int time = travelTime(int origin, int destination)
which defines the travel time between pair of nodes. I have defined the constraint as below:
for (int i : set){
IloIntExpr expr = model.linearIntExpr();
expr = model.sum(model.element(t, s[i]), model.prod(t[i], -1));
IloIntExpr next = model.element(range(0, nbNodes), s[i]);
model.addGe(expr, travelTime(i, next));
}
***range function generates [0,1, ... ,nbNodes]
and [size(s) = size(t) = nbNodes]
now the problem is that next
is returning IloIntExpr
and I want it to be int
to pass it to travelTime(int, int)
, and also IloIntExpr
is not castable to int
.
What can be the possible solution for my problem.
I really appreciate any help in this regard.