Feature: [Linkgraph] Prioritize faster routes for passengers and express cargo #9457
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
Cargodist does not optimize for travel time but for distance, which means passengers sometimes take (for instance) a slow but short bus route instead of a faster train route to their destination. I think it would be more intuitive if cargodist prioritized the fastest paths, at least for passengers and express cargo (goods, food). Since cargo payment depends on travel time, this may also increase income for some networks.
Description
This PR adds a member variable
travel_time_sum
toLinkGraph::Edge
. When a vehicle traverses a link, the product of its travel time and its capacity is added to this variable, so thattravel_time_sum / capacity
gives the average travel time of a cargo unit traversing this edge in a saturated network. Just like capacities, the value is halved every 256 days, so that older travel times weigh less in the average.This average travel time is then used in the MCF solver in place of the distance for cargo of classes
CC_PASSENGERS
andCC_EXPRESS
.Limitations
This change could be hidden behind a default-disabled setting for better backward compatibility.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.