Hello,
I have a vrp problem. in this vrp problem there is a constraint that say when vehicle is in node n at time t, in time t+1 it will be in the one of the routes that start from node n.
anybody can help me to code it in gams?
You can create a set of paths that start from each node
set
n /n1*n10/
paths(n, n)
;
Now you can populate paths(n_a,n_b) = yes for all paths that start from node n_a to node n_b.
Alternatively, you can populate a parameter matrix (table) that has 1, 0 values for possible paths.
assign a binary variable v(n, t) which is 1 if vehicle is at node n in time t and 0 otherwise.
alias(n, nn);
You would want all v(nn, t+1) to be 0 if v(n, t) is 1 and paths(n, nn) does not exist the paths don’t start from node n in v(n, t).
con1(n, t).. sum(nn $( not paths(n, nn)), v(nn, t+1)) + v(n, t) =l= 1;
This constraint makes sure that if v(n, t) is 1 then all v(nn, t+1) are 0. It also says that if v(n, t) is 0 then only one of v(nn, t+1) can be 1 (I assume this because vehicle can go only on one path) but you can modify it as needed.
Hope this helps.
- Atharv