Feature: [Linkgraph] Prioritize faster routes for passengers, mail and express cargo
Passengers usually prefer fast paths to short paths.
Average travel times of links are updated in real-time for use in Dijkstra's algorithm,
and newer travel times weigh more, just like capacities.
(cherry picked from commit 977604ef08
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
1518c2fa1e
commit
a43a1902bb
@@ -70,6 +70,7 @@ public:
|
||||
struct BaseEdge {
|
||||
uint capacity; ///< Capacity of the link.
|
||||
uint usage; ///< Usage of the link.
|
||||
uint64 travel_time_sum; ///< Sum of the travel times of the link, in ticks.
|
||||
Date last_unrestricted_update; ///< When the unrestricted part of the link was last updated.
|
||||
Date last_restricted_update; ///< When the restricted part of the link was last updated.
|
||||
Date last_aircraft_update; ///< When aircraft capacity of the link was last updated.
|
||||
@@ -106,6 +107,12 @@ public:
|
||||
*/
|
||||
uint Usage() const { return this->edge.usage; }
|
||||
|
||||
/**
|
||||
* Get edge's average travel time.
|
||||
* @return Travel time, in ticks.
|
||||
*/
|
||||
uint32 TravelTime() const { return this->edge.travel_time_sum / this->edge.capacity; }
|
||||
|
||||
/**
|
||||
* Get the date of the last update to the edge's unrestricted capacity.
|
||||
* @return Last update.
|
||||
@@ -311,7 +318,7 @@ public:
|
||||
* @param edge Edge to be wrapped.
|
||||
*/
|
||||
Edge(BaseEdge &edge) : EdgeWrapper<BaseEdge>(edge) {}
|
||||
void Update(uint capacity, uint usage, EdgeUpdateMode mode);
|
||||
void Update(uint capacity, uint usage, uint32 time, EdgeUpdateMode mode);
|
||||
void Restrict() { this->edge.last_unrestricted_update = INVALID_DATE; }
|
||||
void Release() { this->edge.last_restricted_update = INVALID_DATE; }
|
||||
void ClearAircraft() { this->edge.last_aircraft_update = INVALID_DATE; }
|
||||
@@ -445,8 +452,8 @@ public:
|
||||
this->node.demand = demand;
|
||||
}
|
||||
|
||||
void AddEdge(NodeID to, uint capacity, uint usage, EdgeUpdateMode mode);
|
||||
void UpdateEdge(NodeID to, uint capacity, uint usage, EdgeUpdateMode mode);
|
||||
void AddEdge(NodeID to, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode);
|
||||
void UpdateEdge(NodeID to, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode);
|
||||
void RemoveEdge(NodeID to);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user