MaxOng99 / ECS-Ridesharing

0 stars 0 forks source link

Calculation of Arrival and Waiting Time for newly inserted Tour Node #5

Open MaxOng99 opened 3 years ago

MaxOng99 commented 3 years ago

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 as rider_i, the left and right nodes are left_node and right_node respectively.

The algorithm is described as follows:

  1. Verify left_node and right_node. tour_node_i will be inserted between them.
  2. arrival_time of new tour_node_i is left_node.departure_time + travel_time(left_node.location_id, new_location_id)
  3. waiting_time of tour_node_i is calculated as follows:

    • If tour_node_i is a departure node, compare rider_i.optimal_departure with arrival_time. If arrival_time exceeds rider_i.optimal_departure, this means that the bus is late, and rider_i would not want to wait (waiting_time = 0). Else if rider_i.optimal_departure exceeds arrival_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, compare rider_i.optimal_arrival with arrival_time. If arrival_time exceeds rider_i.optimal_arrival, this means that the bus arrived late, and thus waiting_time = 0. Else if rider_i.optimal_arrival exceeds arrival_time, the bus arrived early. waiting_time of this new node is calculated as rider_i.optimal_arrival - arrival_time.

Although waiting_time is added for arrival nodes, the utility of a rider is still calculated based on departure_node.departure_time and arrival_node.arrival_time. This means that a rider's arrival utility might not be optimal at the start, but waiting_time allows more tour_nodes to be added in the future, possibly reaching the desired rider_i.optimal_arrival value.

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