matsim-org / matsim-code-examples

A repository containing code examples around MATSim
GNU General Public License v3.0
81 stars 178 forks source link

Problem using NetworkSimplifier #271

Closed zekechan1 closed 4 years ago

zekechan1 commented 4 years ago

Hi,

I am using both NetworkCleaner and NetworkSimplifier to prepare the input network: new NetworkCleaner().run(network); new NetworkSimplifier().run(network); But what I find is that running networkCleaner only is fine, but running both networkCleaner and networkSimplifier will cause a crash (errors shown below). When I look at the output network file, I notice that with networkSimplifier the link_ids are long texts rather than integers, such as: link id="995-246-243-3385-3253" I suspect this could be a source of problem.

Much appreciated if someone can give some insight into why networkSimplifier causes crash, and what is the fix?

Many thanks

Zeke

2020-01-21 11:32:13,143 WARN NetworkUtils:445 org.matsim.core.network.NetworkImpl@3f1d2e23[capperiod=3600.0][nof_nodes=1662][found nearest node that has no incident links. Will probably crash eventually ... Maybe run NetworkCleaner?] 2020-01-21 11:32:13,143 WARN NetworkUtils:462 org.matsim.core.network.NetworkImpl@3f1d2e23[capperiod=3600.0][nof_nodes=1662][nearestLink not found. Will probably crash eventually ... Maybe run NetworkCleaner?] 2020-01-21 11:32:13,144 ERROR ParallelPersonAlgorithmUtils$ExceptionHandler:164 Thread PersonPrepareForSim.0 died with exception while handling events. java.lang.RuntimeException: For person id=5: getNearestLink returned Null! act=[type=home][coord=[x=1799871.3546][y=5816353.2638]][linkId=null][startTime=undefined][endTime=07:29:54][duration=undefined][facilityId=null] at org.matsim.core.population.algorithms.XY2Links.processPlan(XY2Links.java:122) at org.matsim.core.population.algorithms.XY2Links.run(XY2Links.java:73) at org.matsim.core.population.algorithms.PersonPrepareForSim.run(PersonPrepareForSim.java:143) at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils$PersonAlgoThread.run(ParallelPersonAlgorithmUtils.java:145) at java.lang.Thread.run(Unknown Source) 2020-01-21 11:32:13,148 INFO Counter:70 [PersonPrepareForSim] handled person # 4 2020-01-21 11:32:13,148 WARN NetworkUtils:445 org.matsim.core.network.NetworkImpl@3f1d2e23[capperiod=3600.0][nof_nodes=1662][found nearest node that has no incident links. Will probably crash eventually ... Maybe run NetworkCleaner?] 2020-01-21 11:32:13,148 WARN NetworkUtils:462 org.matsim.core.network.NetworkImpl@3f1d2e23[capperiod=3600.0][nof_nodes=1662][nearestLink not found. Will probably crash eventually ... Maybe run NetworkCleaner?] 2020-01-21 11:32:13,148 ERROR ParallelPersonAlgorithmUtils$ExceptionHandler:164 Thread PersonPrepareForSim.1 died with exception while handling events. java.lang.RuntimeException: For person id=6: getNearestLink returned Null! act=[type=home][coord=[x=1798918.8242][y=5818034.9672]][linkId=null][startTime=undefined][endTime=07:29:50][duration=undefined][facilityId=null] at org.matsim.core.population.algorithms.XY2Links.processPlan(XY2Links.java:122) at org.matsim.core.population.algorithms.XY2Links.run(XY2Links.java:73) at org.matsim.core.population.algorithms.PersonPrepareForSim.run(PersonPrepareForSim.java:143) at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils$PersonAlgoThread.run(ParallelPersonAlgorithmUtils.java:145) at java.lang.Thread.run(Unknown Source) 2020-01-21 11:32:13,149 INFO Counter:76 [PersonPrepareForSim] handled person # 4 2020-01-21 11:32:13,149 ERROR MatsimRuntimeModifications:54 Getting uncaught Exception in Thread main java.lang.RuntimeException: Exception while processing persons. Cannot guarantee that all persons have been fully processed. at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils.run(ParallelPersonAlgorithmUtils.java:120) at org.matsim.core.controler.PrepareForSimImpl.run(PrepareForSimImpl.java:119) at org.matsim.core.controler.NewControler.prepareForSim(NewControler.java:115) at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:79) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:48) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:31) at org.matsim.core.controler.AbstractController.run(AbstractController.java:88) at org.matsim.core.controler.NewControler.run(NewControler.java:84) at org.matsim.core.controler.Controler.run(Controler.java:212) at zeke1.RunMatsim.runConfig(RunMatsim.java:315) at zeke1.RunMatsim.main(RunMatsim.java:199) 2020-01-21 11:32:13,149 INFO MatsimRuntimeModifications:58 S H U T D O W N --- start shutdown. 2020-01-21 11:32:13,149 ERROR MatsimRuntimeModifications:60 ERROR --- This is an unexpected shutdown! 2020-01-21 11:32:13,149 ERROR MatsimRuntimeModifications:63 Shutdown possibly caused by the following Exception: java.lang.RuntimeException: Exception while processing persons. Cannot guarantee that all persons have been fully processed. at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils.run(ParallelPersonAlgorithmUtils.java:120) at org.matsim.core.controler.PrepareForSimImpl.run(PrepareForSimImpl.java:119) at org.matsim.core.controler.NewControler.prepareForSim(NewControler.java:115) at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:79) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:48) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:31) at org.matsim.core.controler.AbstractController.run(AbstractController.java:88) at org.matsim.core.controler.NewControler.run(NewControler.java:84) at org.matsim.core.controler.Controler.run(Controler.java:212) at zeke1.RunMatsim.runConfig(RunMatsim.java:315) at zeke1.RunMatsim.main(RunMatsim.java:199) 2020-01-21 11:32:13,150 INFO ControlerListenerManagerImpl:121 calling notifyShutdown on org.matsim.core.controler.corelisteners.EventsHandlingImpl 2020-01-21 11:32:13,150 INFO ControlerListenerManagerImpl:121 calling notifyShutdown on org.matsim.core.controler.corelisteners.DumpDataAtEndImpl 2020-01-21 11:32:13,150 INFO ControlerListenerManagerImpl:126 calling notifyShutdown on org.matsim.analysis.ModeStatsControlerListener 2020-01-21 11:32:13,154 INFO ControlerListenerManagerImpl:126 calling notifyShutdown on org.matsim.analysis.ScoreStatsControlerListener 2020-01-21 11:32:13,159 INFO ControlerListenerManagerImpl:126 calling notifyShutdown on org.matsim.analysis.TravelDistanceStatsControlerListener 2020-01-21 11:32:13,160 INFO ControlerListenerManagerImpl:126 calling notifyShutdown on zeke1.MyControlerListener 2020-01-21 11:32:13,160 INFO MyControlerListener:102 ** We're shutting down! 2020-01-21 11:32:13,160 INFO ControlerListenerManagerImpl:129 all ControlerShutdownListeners called. 2020-01-21 11:32:13,160 ERROR MatsimRuntimeModifications:78 ERROR --- MATSim unexpectedly terminated. Please check the output or the logfile with warnings and errors for hints. 2020-01-21 11:32:13,160 ERROR MatsimRuntimeModifications:79 ERROR --- results should not be used for further analysis. 2020-01-21 11:32:13,160 INFO MatsimRuntimeModifications:81 S H U T D O W N --- shutdown completed. 2020-01-21 11:32:13,160 ERROR MatsimRuntimeModifications:83 ERROR --- This was an unexpected shutdown! See the log file for a possible reason. Exception in thread "main" java.lang.RuntimeException: Exception while processing persons. Cannot guarantee that all persons have been fully processed. at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils.run(ParallelPersonAlgorithmUtils.java:120) at org.matsim.core.controler.PrepareForSimImpl.run(PrepareForSimImpl.java:119) at org.matsim.core.controler.NewControler.prepareForSim(NewControler.java:115) at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:79) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:48) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:31) at org.matsim.core.controler.AbstractController.run(AbstractController.java:88) at org.matsim.core.controler.NewControler.run(NewControler.java:84) at org.matsim.core.controler.Controler.run(Controler.java:212) at zeke1.RunMatsim.runConfig(RunMatsim.java:315) at zeke1.RunMatsim.main(RunMatsim.java:199)

mrieser commented 4 years ago

found nearest node that has no incident links. Will probably crash eventually ... Maybe run NetworkCleaner?

Make sure to run the NetworkCleaner after running the NetworkSimplifier, and not the other way round. NetworkSimplifier leaves back nodes without in- or out-links, which cause problems when trying to look for the nearest link.

Ids in MATSim can be arbitrary strings, they don't have to be integers. NetworkSimplifier just concatenates the original link ids of simplified links, thus the long ids in simplified links.

zekechan1 commented 4 years ago

Hi Marcel

Thanks for the quick reply.

I did try running NetworkCleaner after NetworkSimplifer, as follows: new NetworkSimplifier().run(network); new NetworkCleaner().run(network);

Then it gave me the errors shown below. It mentioned that: java.lang.NumberFormatException: For input string: "2678-2676" etc which leads me to think that LinkId must somehow be number rather than string.

Can you think of the reason for this crash please?

Thanks

Zeke

2020-01-22 09:14:39,730 ERROR SimStepParallelEventsManagerImpl$ExceptionHandler:420 Thread class org.matsim.core.events.SimStepParallelEventsManagerImpl$ProcessEventsRunnable0 died with exception while handling events. java.lang.NumberFormatException: For input string: "2678-2676" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at zeke1.MyControlerEventHandler.handleEvent(MyControlerEventHandler.java:59) at org.matsim.core.events.EventsManagerImpl.callHandlerFast(EventsManagerImpl.java:291) at org.matsim.core.events.EventsManagerImpl.computeEvent(EventsManagerImpl.java:222) at org.matsim.core.events.EventsManagerImpl.processEvent(EventsManagerImpl.java:136) at org.matsim.core.events.SimStepParallelEventsManagerImpl$ProcessEventsRunnable.run(SimStepParallelEventsManagerImpl.java:330) at java.lang.Thread.run(Unknown Source) 2020-01-22 09:14:39,747 ERROR AbstractController:208 Mobsim did not complete normally! afterMobsimListeners will be called anyway. java.lang.RuntimeException: Exception while processing events. Cannot guarantee that all events have been fully processed. at org.matsim.core.events.SimStepParallelEventsManagerImpl.finishProcessing(SimStepParallelEventsManagerImpl.java:212) at org.matsim.core.mobsim.qsim.QSim.cleanupSim(QSim.java:319) at org.matsim.core.mobsim.qsim.QSim.run(QSim.java:244) at org.matsim.core.controler.NewControler.runMobSim(NewControler.java:126) at org.matsim.core.controler.AbstractController$9.run(AbstractController.java:197) at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:229) at org.matsim.core.controler.AbstractController.mobsim(AbstractController.java:193) at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:144) at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:112) at org.matsim.core.controler.AbstractController.access$1(AbstractController.java:110) at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:80) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:48) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:31) at org.matsim.core.controler.AbstractController.run(AbstractController.java:88) at org.matsim.core.controler.NewControler.run(NewControler.java:84) at org.matsim.core.controler.Controler.run(Controler.java:212) at zeke1.RunMatsim.runConfig(RunMatsim.java:315) at zeke1.RunMatsim.main(RunMatsim.java:199) Caused by: java.lang.NumberFormatException: For input string: "2678-2676" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at zeke1.MyControlerEventHandler.handleEvent(MyControlerEventHandler.java:59) at org.matsim.core.events.EventsManagerImpl.callHandlerFast(EventsManagerImpl.java:291) at org.matsim.core.events.EventsManagerImpl.computeEvent(EventsManagerImpl.java:222) at org.matsim.core.events.EventsManagerImpl.processEvent(EventsManagerImpl.java:136) at org.matsim.core.events.SimStepParallelEventsManagerImpl$ProcessEventsRunnable.run(SimStepParallelEventsManagerImpl.java:330) at java.lang.Thread.run(Unknown Source) 2020-01-22 09:14:39,754 INFO AbstractController$6:220 ### ITERATION 0 fires after mobsim event 2020-01-22 09:14:39,754 INFO ControlerListenerManagerImpl:248 calling notifyAfterMobsim on org.matsim.analysis.LegTimesControlerListener 2020-01-22 09:14:39,759 INFO LegTimesControlerListener:50 [0] average trip (probably: leg) duration is: 0 seconds = 00:00:00 2020-01-22 09:14:39,759 INFO ControlerListenerManagerImpl:248 calling notifyAfterMobsim on org.matsim.core.scoring.EventsToActivities$1 2020-01-22 09:14:39,759 INFO ControlerListenerManagerImpl:251 [it.0] all ControlerAfterMobsimListeners called. 2020-01-22 09:14:39,759 ERROR MatsimRuntimeModifications:54 Getting uncaught Exception in Thread main java.lang.RuntimeException: Exception while processing events. Cannot guarantee that all events have been fully processed. at org.matsim.core.events.SimStepParallelEventsManagerImpl.finishProcessing(SimStepParallelEventsManagerImpl.java:212) at org.matsim.core.mobsim.qsim.QSim.cleanupSim(QSim.java:319) at org.matsim.core.mobsim.qsim.QSim.run(QSim.java:244) at org.matsim.core.controler.NewControler.runMobSim(NewControler.java:126) at org.matsim.core.controler.AbstractController$9.run(AbstractController.java:197) at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:229) at org.matsim.core.controler.AbstractController.mobsim(AbstractController.java:193) at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:144) at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:112) at org.matsim.core.controler.AbstractController.access$1(AbstractController.java:110) at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:80) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:48) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:31) at org.matsim.core.controler.AbstractController.run(AbstractController.java:88) at org.matsim.core.controler.NewControler.run(NewControler.java:84) at org.matsim.core.controler.Controler.run(Controler.java:212) at zeke1.RunMatsim.runConfig(RunMatsim.java:315) at zeke1.RunMatsim.main(RunMatsim.java:199) Caused by: java.lang.NumberFormatException: For input string: "2678-2676" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at zeke1.MyControlerEventHandler.handleEvent(MyControlerEventHandler.java:59) at org.matsim.core.events.EventsManagerImpl.callHandlerFast(EventsManagerImpl.java:291) at org.matsim.core.events.EventsManagerImpl.computeEvent(EventsManagerImpl.java:222) at org.matsim.core.events.EventsManagerImpl.processEvent(EventsManagerImpl.java:136) at org.matsim.core.events.SimStepParallelEventsManagerImpl$ProcessEventsRunnable.run(SimStepParallelEventsManagerImpl.java:330) at java.lang.Thread.run(Unknown Source) 2020-01-22 09:14:39,759 INFO MatsimRuntimeModifications:58 S H U T D O W N --- start shutdown. 2020-01-22 09:14:39,760 ERROR MatsimRuntimeModifications:60 ERROR --- This is an unexpected shutdown! 2020-01-22 09:14:39,760 ERROR MatsimRuntimeModifications:63 Shutdown possibly caused by the following Exception: java.lang.RuntimeException: Exception while processing events. Cannot guarantee that all events have been fully processed. at org.matsim.core.events.SimStepParallelEventsManagerImpl.finishProcessing(SimStepParallelEventsManagerImpl.java:212) at org.matsim.core.mobsim.qsim.QSim.cleanupSim(QSim.java:319) at org.matsim.core.mobsim.qsim.QSim.run(QSim.java:244) at org.matsim.core.controler.NewControler.runMobSim(NewControler.java:126) at org.matsim.core.controler.AbstractController$9.run(AbstractController.java:197) at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:229) at org.matsim.core.controler.AbstractController.mobsim(AbstractController.java:193) at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:144) at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:112) at org.matsim.core.controler.AbstractController.access$1(AbstractController.java:110) at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:80) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:48) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:31) at org.matsim.core.controler.AbstractController.run(AbstractController.java:88) at org.matsim.core.controler.NewControler.run(NewControler.java:84) at org.matsim.core.controler.Controler.run(Controler.java:212) at zeke1.RunMatsim.runConfig(RunMatsim.java:315) at zeke1.RunMatsim.main(RunMatsim.java:199) Caused by: java.lang.NumberFormatException: For input string: "2678-2676" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at zeke1.MyControlerEventHandler.handleEvent(MyControlerEventHandler.java:59) at org.matsim.core.events.EventsManagerImpl.callHandlerFast(EventsManagerImpl.java:291) at org.matsim.core.events.EventsManagerImpl.computeEvent(EventsManagerImpl.java:222) at org.matsim.core.events.EventsManagerImpl.processEvent(EventsManagerImpl.java:136) at org.matsim.core.events.SimStepParallelEventsManagerImpl$ProcessEventsRunnable.run(SimStepParallelEventsManagerImpl.java:330) at java.lang.Thread.run(Unknown Source) 2020-01-22 09:14:39,760 INFO ControlerListenerManagerImpl:121 calling notifyShutdown on org.matsim.core.controler.corelisteners.EventsHandlingImpl 2020-01-22 09:14:39,760 INFO ControlerListenerManagerImpl:121 calling notifyShutdown on org.matsim.core.controler.corelisteners.DumpDataAtEndImpl 2020-01-22 09:14:39,760 INFO ControlerListenerManagerImpl:126 calling notifyShutdown on org.matsim.analysis.ModeStatsControlerListener 2020-01-22 09:14:39,765 INFO ControlerListenerManagerImpl:126 calling notifyShutdown on org.matsim.analysis.ScoreStatsControlerListener 2020-01-22 09:14:39,766 INFO ControlerListenerManagerImpl:126 calling notifyShutdown on org.matsim.analysis.TravelDistanceStatsControlerListener 2020-01-22 09:14:39,767 INFO ControlerListenerManagerImpl:126 calling notifyShutdown on zeke1.MyControlerListener 2020-01-22 09:14:39,768 INFO MyControlerListener:102 ** We're shutting down! 2020-01-22 09:14:39,768 INFO ControlerListenerManagerImpl:129 all ControlerShutdownListeners called. 2020-01-22 09:14:39,768 ERROR MatsimRuntimeModifications:78 ERROR --- MATSim unexpectedly terminated. Please check the output or the logfile with warnings and errors for hints. 2020-01-22 09:14:39,768 ERROR MatsimRuntimeModifications:79 ERROR --- results should not be used for further analysis. 2020-01-22 09:14:39,768 INFO MatsimRuntimeModifications:81 S H U T D O W N --- shutdown completed. 2020-01-22 09:14:39,768 ERROR MatsimRuntimeModifications:83 ERROR --- This was an unexpected shutdown! See the log file for a possible reason. Exception in thread "main" java.lang.RuntimeException: Exception while processing events. Cannot guarantee that all events have been fully processed. at org.matsim.core.events.SimStepParallelEventsManagerImpl.finishProcessing(SimStepParallelEventsManagerImpl.java:212) at org.matsim.core.mobsim.qsim.QSim.cleanupSim(QSim.java:319) at org.matsim.core.mobsim.qsim.QSim.run(QSim.java:244) at org.matsim.core.controler.NewControler.runMobSim(NewControler.java:126) at org.matsim.core.controler.AbstractController$9.run(AbstractController.java:197) at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:229) at org.matsim.core.controler.AbstractController.mobsim(AbstractController.java:193) at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:144) at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:112) at org.matsim.core.controler.AbstractController.access$1(AbstractController.java:110) at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:80) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:48) at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:31) at org.matsim.core.controler.AbstractController.run(AbstractController.java:88) at org.matsim.core.controler.NewControler.run(NewControler.java:84) at org.matsim.core.controler.Controler.run(Controler.java:212) at zeke1.RunMatsim.runConfig(RunMatsim.java:315) at zeke1.RunMatsim.main(RunMatsim.java:199) Caused by: java.lang.NumberFormatException: For input string: "2678-2676" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at zeke1.MyControlerEventHandler.handleEvent(MyControlerEventHandler.java:59) at org.matsim.core.events.EventsManagerImpl.callHandlerFast(EventsManagerImpl.java:291) at org.matsim.core.events.EventsManagerImpl.computeEvent(EventsManagerImpl.java:222) at org.matsim.core.events.EventsManagerImpl.processEvent(EventsManagerImpl.java:136) at org.matsim.core.events.SimStepParallelEventsManagerImpl$ProcessEventsRunnable.run(SimStepParallelEventsManagerImpl.java:330) at java.lang.Thread.run(Unknown Source)

zekechan1 commented 4 years ago

Hi Marcel

I also read from your course note:

Network Generation: Best Practice 1.convert from OSM with setKeepPath(true)

  1. run NetworkCleaner
  2. run NetworkSimplifier

I've tried this sequence too but also generated a crash.

Zeke

mrieser commented 4 years ago

Caused by: java.lang.NumberFormatException: For input string: "2678-2676" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at zeke1.MyControlerEventHandler.handleEvent(MyControlerEventHandler.java:59) at org.matsim.core.events.EventsManagerImpl.callHandlerFast(EventsManagerImpl.java:291)

But this error originates in your own event handler: MyControlerEventHandler, which seems to try something like Integer.parseInt(link.getId().toString()). So you, in your code, make the assumption that the ids are numeric, which they are not. If you fix your code, then it should hopefully work.

zekechan1 commented 4 years ago

Hi Marcel, Thank you for the quick reply again. 100% spot on - I made an assumption in my code that LinkIds should be integer, but after NetworkSimplifier, they are strings.

Now you've solved the original problem. Can I ask one more thing? Is there an easy way to change all the link ids so they are integers from 1 to [number of links] for easy and efficient referencing? (I understand the hashcode is a unique integer, but it's number range is quite large. I want to limit maximum to [number of links]).

Zeke

zekechan1 commented 4 years ago

Hi, Answering my own question - we can use NetworkUtils to assign a unique integer as "origId" to each link:

    int count=1;
    for(Link link : network.getLinks().values()) {
        NetworkUtils.setOrigId(link, Integer.toString(count++));
    }

We can now use "origId" as a unique integer identifier. Thank you all and especially Marcel for your input.

Best,

Zeke