vehicle routing problem

Problems with syntax of GAMS
Post Reply
AmirHo3eiin
User
User
Posts: 6
Joined: 3 years ago

vehicle routing problem

Post by AmirHo3eiin »

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?
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: vehicle routing problem

Post by abhosekar »

You can create a set of paths that start from each node

Code: Select all

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.

Code: Select all

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).

Code: Select all

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
Post Reply