Open MaxOng99 opened 3 years ago
good - this way the only case when a rider suggests non-zero waiting time is when the bus is early.
I think the final point ("Although waiting_time is added for arrival nodes ...") should not make an issue because after the waiting time ends, each rider caululates their utility based on the new time-stamp (i.e., as if the bus just arrived).
https://github.com/MaxOng99/ECS-Ridesharing/blob/3ff9e16688a86dde56b803a732fe7a14b9325400/src/algorithms/greedy_insert.py#L233-L273
Note that the new tour node to be inserted is denoted as
tour_node_i
, the new rider asrider_i
, the left and right nodes areleft_node
andright_node
respectively.The algorithm is described as follows:
left_node
andright_node
.tour_node_i
will be inserted between them.arrival_time
of newtour_node_i
isleft_node.departure_time + travel_time(left_node.location_id, new_location_id)
waiting_time
oftour_node_i
is calculated as follows:If
tour_node_i
is a departure node, comparerider_i.optimal_departure
witharrival_time
. Ifarrival_time
exceedsrider_i.optimal_departure
, this means that the bus is late, andrider_i
would not want to wait (waiting_time = 0
). Else ifrider_i.optimal_departure
exceedsarrival_time
, this means that the bus arrived earlier and thus, the rider waits until his/her optimal departure time (waiting_time = rider_i.optimal_departure - arrival_time
).If
tour_node_i
is an arrival node, comparerider_i.optimal_arrival
witharrival_time
. Ifarrival_time
exceedsrider_i.optimal_arrival
, this means that the bus arrived late, and thuswaiting_time = 0
. Else ifrider_i.optimal_arrival
exceedsarrival_time
, the bus arrived early.waiting_time
of this new node is calculated asrider_i.optimal_arrival - arrival_time
.Although
waiting_time
is added for arrival nodes, the utility of a rider is still calculated based ondeparture_node.departure_time
andarrival_node.arrival_time
. This means that a rider's arrival utility might not be optimal at the start, butwaiting_time
allows more tour_nodes to be added in the future, possibly reaching the desiredrider_i.optimal_arrival
value.