public static void runNetworkSimplifier( Network network ) { new NetworkSimplifier().run(network) ; } public static void writeNetwork(Network network, String string) {
@Test public void testRunMergeLinkStats() { Network network = buildNetwork(); NetworkSimplifier nst = new NetworkSimplifier(); nst.setMergeLinkStats(true); nst.run(network, 20.0); assertEquals("Wrong number of links", 2, network.getLinks().size()); assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("AB-BC"))); assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("CD-DE-EF"))); network = buildNetwork(); nst.run(network, 40.0); assertEquals("Wrong number of links", 1, network.getLinks().size()); assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("AB-BC-CD-DE-EF"))); network = buildNetwork(); nst.run(network, 5.0); assertEquals("Wrong number of links", 5, network.getLinks().size()); }
public static void main(String[] args) { final String inNetworkFile = args[ 0 ]; final String outNetworkFile = args[ 1 ]; Set<Integer> nodeTypesToMerge = new TreeSet<>(); nodeTypesToMerge.add(4); nodeTypesToMerge.add(5); Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile( inNetworkFile ); NetworkSimplifier nsimply = new NetworkSimplifier(); nsimply.setNodesToMerge(nodeTypesToMerge); // nsimply.setMergeLinkStats(true); nsimply.run(network, Double.NEGATIVE_INFINITY); new NetworkWriter(network).write( outNetworkFile ); }
if( areLinksMergeable(inLink, outLink) ){ if(this.mergeLinksWithDifferentAttributes){ switch (type) { case BOTH: criteria = bothLinksAreShorterThanThreshold(inLink, outLink, thresholdLength); break; case EITHER: criteria = eitherLinkIsShorterThanThreshold(inLink, outLink, thresholdLength); break; default: network.removeLink(inLink.getId()); network.removeLink(outLink.getId()); collectMergedLinkNodeInfo(inLink, outLink, link.getId()); if(bothLinksHaveSameLinkStats(inLink, outLink)){ switch (type) { case BOTH: isHavingShortLinks = bothLinksAreShorterThanThreshold(inLink, outLink, thresholdLength); break; case EITHER: isHavingShortLinks = eitherLinkIsShorterThanThreshold(inLink, outLink, thresholdLength); break; default: collectMergedLinkNodeInfo(inLink, outLink, newLink.getId());
/** * Merges all qualifying links, ignoring length threshold. * @param network */ public void run(final Network network){ run(network, Double.POSITIVE_INFINITY, ThresholdExceeded.EITHER); }
NetworkSimplifier simplifier = new NetworkSimplifier(); simplifier.setMergeLinkStats(true); simplifier.run(newClusteredIntersectionsRoadNetwork); new NetworkCleaner().run(newClusteredIntersectionsRoadNetwork);
/** * Merges all qualifying links while ensuring no link is shorter than the * given threshold. * <br/> * Comments:<ul> * <li>I would argue against setting the thresholdLength to anything different from POSITIVE_INFINITY, since * the result of the method depends on the sequence in which the algorithm goes through the nodes. </li> * </ul> * @param network * @param thresholdLength */ @Deprecated public void run(final Network network, double thresholdLength){ run(network, thresholdLength, ThresholdExceeded.BOTH); run(network, thresholdLength, ThresholdExceeded.EITHER); }
public static void run(String[] args) { String input = args[0]; String output = args[1]; Network network = NetworkUtils.createNetwork(); new MatsimNetworkReader(network).readFile(input); IntersectionSimplifier ns = new IntersectionSimplifier(30.0, 2); Network newNetwork = ns.simplify(network); NetworkCalcTopoType nct = new NetworkCalcTopoType(); nct.run(newNetwork); LOG.info("Simplifying the network..."); new NetworkSimplifier().run(newNetwork); LOG.info("Cleaning the network..."); new NetworkCleaner().run(newNetwork); IntersectionSimplifier.reportNetworkStatistics(newNetwork); new NetworkWriter(newNetwork).write(output); }
assertEquals("Wrong number of links", 10, network.getLinks().size()); NetworkSimplifier networkSimplifier = new NetworkSimplifier(); networkSimplifier.setMergeLinkStats(false); networkSimplifier.run(network);
@Test public void testRun() { Network network = buildNetwork(); NetworkSimplifier nst = new NetworkSimplifier(); nst.run(network, 20.0); assertEquals("Wrong number of links", 3, network.getLinks().size()); assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("AB-BC"))); assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("CD"))); assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("DE-EF"))); }
new NetworkSimplifier().run(net,500); new NetworkCleaner().run(net); new NetworkWriter(net).write(xmlfile);
NetworkSimplifier ns = new NetworkSimplifier(); ns.run(simpleNetwork); new NetworkCleaner().run(simpleNetwork); new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "network.xml");