Skip to content

Commit

Permalink
fixed processing sequence to avoid non-deterministic behavior
Browse files Browse the repository at this point in the history
if there is more than one route option with the same travel time albeit
different length, the route found depends on the sequence of link
processing. That is, route choice depends on the implementation of the
Network/NetworkReader and/or the sequence of links in the network file.
  • Loading branch information
neuma committed Jan 30, 2024
1 parent 02cab0e commit 4e57a60
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.network.Node;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
* Implements a highly optimized data structure for representing a MATSim network. Optimized to use as little memory as possible, and thus to fit as much memory as possible into CPU caches for high
Expand Down Expand Up @@ -70,7 +73,11 @@ public SpeedyGraph(Network network) {
for (Node node : network.getNodes().values()) {
this.nodes[node.getId().index()] = node;
}
for (Link link : network.getLinks().values()) {

List<Id<Link>> linkIds = new ArrayList<>(network.getLinks().keySet());
Collections.sort(linkIds);
for (Id<Link> linkId : linkIds) {
Link link = network.getLinks().get(linkId);
addLink(link);
}
}
Expand Down

0 comments on commit 4e57a60

Please sign in to comment.