## Equation Definition in a Loop Whose Index Maped With Binary Variable

Problems with modeling
EmreA
User
Posts: 4
Joined: 9 months ago

### Equation Definition in a Loop Whose Index Maped With Binary Variable

I need to write equation in such a loop to calculate arrival time for each vehicle on its route waypoints.
For example my model desides the cheapest way with the route Route(1,A,C),Route(1,C,B),Route(1,B,F)all is 1.
So I have to calculate the arrival time of vehicle1 to waypoints C,B,and F in such a loop;
Since the vehicle 1 routed as A-C-B-F
-ArrivalTime(1,C)= TravelDuration(1,A,C)
-ArrivalTime(1,B)= ArrivalTime(1,C)+TravelDuration(1,C,B)
-ArrivalTime(1,F)= ArrivalTime(1,B)+TravelDuration(1,B,F)

The problem is that I have to use binary variable Route resutls to calculate the correct arrival time. How ever I can not assign any value to Route variable since the model decide that values.
Also I can not use the ArrivalTime equations in a loop to calculate correct time for correct node.
How can I do that please give me a solution method.

sets i "Vehichels"/1*10/
m "waypoint names"/A*F/
;
alias (m,n);
binary variable Route(i,m,n);
positive variable ArrivalTime(i,m);

table RouteMap(m,n)"Possible route connections"
A B C D E F
A 0 0 1 1 0 0
B 0 0 0 0 1 1
C 0 1 0 1 0 0
D 0 0 0 0 1 0
E 0 0 0 0 0 1
F 0 0 0 0 0 0

;

table TravelDuration(m,n)"Travel duration between each nodes"
A B C D E F
A 0 0 5 6 0 0
B 0 0 0 0 2 3
C 0 4 0 3 0 0
D 0 0 0 0 7 0
E 0 0 0 0 0 6
F 0 0 0 0 0 0

;