Skip to content

Commit

Permalink
add routing test with multiple same options
Browse files Browse the repository at this point in the history
  • Loading branch information
paulheinr committed May 8, 2024
1 parent bdf2182 commit ca38361
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@

import javax.xml.parsers.ParserConfigurationException;

import org.apache.logging.log4j.LogManager;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Identifiable;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
Expand Down Expand Up @@ -92,4 +94,31 @@ void testCalcLeastCostPath_SameFromTo() throws SAXException, ParserConfiguration
assertEquals(network.getNodes().get(Id.create("12", Node.class)), path.nodes.get(0));
}

@Test
void testCalcLeastCostPath_withOptions() throws SAXException, ParserConfigurationException, IOException {
Config config = utils.loadConfig((String)null);
Scenario scenario = ScenarioUtils.createScenario(config);
Network network = scenario.getNetwork();
new MatsimNetworkReader(scenario.getNetwork()).readFile("test/scenarios/equil/network.xml");

//path from 1 to 13 has several options with the same travel time
Node node1 = network.getNodes().get(Id.create("1", Node.class));
Node node13 = network.getNodes().get(Id.create("13", Node.class));

LeastCostPathCalculator routerAlgo = getLeastCostPathCalculator(network);
Path path = routerAlgo.calcLeastCostPath(node1, node13, 8.0*3600, null, null);

assertEquals(5, path.nodes.size(), "number of nodes wrong.");
assertEquals(4, path.links.size(), "number of links wrong.");
assertEquals(network.getNodes().get(Id.create("1", Node.class)), path.nodes.get(0));
assertEquals(network.getNodes().get(Id.create("2", Node.class)), path.nodes.get(1));
assertEquals(network.getNodes().get(Id.create("3", Node.class)), path.nodes.get(2));
assertEquals(network.getNodes().get(Id.create("12", Node.class)), path.nodes.get(3));
assertEquals(network.getNodes().get(Id.create("13", Node.class)), path.nodes.get(4));
assertEquals(network.getLinks().get(Id.create("1", Link.class)), path.links.get(0));
assertEquals(network.getLinks().get(Id.create("2", Link.class)), path.links.get(1));
assertEquals(network.getLinks().get(Id.create("11", Link.class)), path.links.get(2));
assertEquals(network.getLinks().get(Id.create("20", Link.class)), path.links.get(3));
}

}

0 comments on commit ca38361

Please sign in to comment.