Created
June 21, 2020 20:42
-
-
Save samiranberahaldia/86a0d6f0e9df7fd2d22bf5b27fe8ad80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set i Node Indexes /1*5/, | |
r Route Indexes /1*3/; | |
alias(i,j,h); | |
variable cost Objective Function Value; | |
binary variable x(i,j,r) 1 if edge between i to j is active for route r 0 otherwise; | |
positive variable T(j,r) Time at node j in route r; | |
parameter from(r) Source Node /1=1,3=3/, to(r) Destination Node /1=5,3=2/; | |
table c(i,j) Transportation time from node i to j | |
1 2 3 4 5 | |
1 2 3 9 8 20 | |
2 7 3 4 6 18 | |
3 6 15 9 5 6 | |
4 8 7 5 4 9 | |
5 8 5 6 8 7; | |
equations objective_function, same_node(i,j,r), source_node(i,r), destination_node(j,r), flow_constraint(j,r) | |
sub_tour_elimination_source(j,r), sub_tour_elimination_nodes(j,r); | |
objective_function.. cost =e= sum((i,j,r),x(i,j,r)*c(i,j)); | |
same_node(i,j,r)$(ord(i)=ord(j)).. x(i,j,r) =e= 0; | |
source_node(i,r)$(ord(i)=from(r)).. sum(j,x(i,j,r)) =e= 1; | |
destination_node(j,r)$(ord(j)=to(r)).. sum(i,x(i,j,r)) =e= 1; | |
flow_constraint(j,r)$(ord(j)<>from(r) and ord(j)<>to(r)).. sum(i,x(i,j,r)) =e= sum(h,x(j,h,r)); | |
sub_tour_elimination_source(j,r)$(ord(j)=from(r)).. T(j,r) =e= 0; | |
sub_tour_elimination_nodes(j,r)$(ord(j)<>from(r)).. T(j,r) =e= sum(i,x(i,j,r)*(T(i,r) + c(i,j))); | |
model routing /all/; | |
solve routing using minlp minimizing cost; | |
display cost.l,x.l; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment