matsim-org / matsim-code-examples

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

My agent couldn't find route #629

Closed khzannat closed 2 years ago

khzannat commented 3 years ago

I am implementing a futuristic scenario of BRT network for Dhaka, Bangladesh. While I am running the scenario I am having an error saying that from one node agent could not find the way to my Public transport stop. I assumed the access mode for public transport stop would be default walking which I configured as teleported mode. Could you please help me to find the potential reason of having the error and what can be done to resolve the problem? I also checked in VIA that my PT brt network doesn't have any break. I have added the part of the error.

java.lang.RuntimeException: No route found from node 317601113 to node pt_33 by mode pt. at org.matsim.core.router.NetworkRoutingModule.calcRoute(NetworkRoutingModule.java:97) ~[matsim-13.0.jar:?] at org.matsim.core.router.TripRouter.calcRoute(TripRouter.java:174) ~[matsim-13.0.jar:?] at org.matsim.core.router.PlanRouter.run(PlanRouter.java:94) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.modules.AbstractMultithreadedModule$PlanAlgoThread.run(AbstractMultithreadedModule.java:234) ~[matsim-13.0.jar:?] at java.lang.Thread.run(Thread.java:832) [?:?] 2021-10-18T16:08:15,645 ERROR MatsimRuntimeModifications:75 Getting uncaught Exception in Thread main java.lang.RuntimeException: Some threads crashed, thus not all plans may have been handled. at org.matsim.core.replanning.modules.AbstractMultithreadedModule.finishReplanning(AbstractMultithreadedModule.java:159) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.GenericPlanStrategyImpl.finish(GenericPlanStrategyImpl.java:121) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.GenericStrategyManager.run(GenericStrategyManager.java:223) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.StrategyManager.run(StrategyManager.java:191) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.StrategyManager.run(StrategyManager.java:173) ~[matsim-13.0.jar:?] at org.matsim.core.controler.corelisteners.PlansReplanningImpl.notifyReplanning(PlansReplanningImpl.java:58) ~[matsim-13.0.jar:?] at org.matsim.core.controler.ControlerListenerManagerImpl.fireControlerReplanningEvent(ControlerListenerManagerImpl.java:206) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$3.run(AbstractController.java:149) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:243) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:146) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:121) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:81) ~[matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-13.0.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-13.0.jar:?] at org.matsim.project.RunMatsim2.main(RunMatsim2.java:130) [classes/:?] Caused by: java.lang.RuntimeException: No route found from node 317601113 to node pt_33 by mode pt. at org.matsim.core.router.NetworkRoutingModule.calcRoute(NetworkRoutingModule.java:97) ~[matsim-13.0.jar:?] at org.matsim.core.router.TripRouter.calcRoute(TripRouter.java:174) ~[matsim-13.0.jar:?] at org.matsim.core.router.PlanRouter.run(PlanRouter.java:94) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.modules.AbstractMultithreadedModule$PlanAlgoThread.run(AbstractMultithreadedModule.java:234) ~[matsim-13.0.jar:?] at java.lang.Thread.run(Thread.java:832) ~[?:?] 2021-10-18T16:08:15,646 ERROR MatsimRuntimeModifications:81 ERROR --- This is an unexpected shutdown! 2021-10-18T16:08:15,646 ERROR MatsimRuntimeModifications:84 Shutdown possibly caused by the following Exception: java.lang.RuntimeException: Some threads crashed, thus not all plans may have been handled. at org.matsim.core.replanning.modules.AbstractMultithreadedModule.finishReplanning(AbstractMultithreadedModule.java:159) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.GenericPlanStrategyImpl.finish(GenericPlanStrategyImpl.java:121) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.GenericStrategyManager.run(GenericStrategyManager.java:223) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.StrategyManager.run(StrategyManager.java:191) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.StrategyManager.run(StrategyManager.java:173) ~[matsim-13.0.jar:?] at org.matsim.core.controler.corelisteners.PlansReplanningImpl.notifyReplanning(PlansReplanningImpl.java:58) ~[matsim-13.0.jar:?] at org.matsim.core.controler.ControlerListenerManagerImpl.fireControlerReplanningEvent(ControlerListenerManagerImpl.java:206) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$3.run(AbstractController.java:149) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:243) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:146) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:121) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:81) ~[matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-13.0.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-13.0.jar:?] at org.matsim.project.RunMatsim2.main(RunMatsim2.java:130) [classes/:?] Caused by: java.lang.RuntimeException: No route found from node 317601113 to node pt_33 by mode pt. at org.matsim.core.router.NetworkRoutingModule.calcRoute(NetworkRoutingModule.java:97) ~[matsim-13.0.jar:?] at org.matsim.core.router.TripRouter.calcRoute(TripRouter.java:174) ~[matsim-13.0.jar:?] at org.matsim.core.router.PlanRouter.run(PlanRouter.java:94) ~[matsim-13.0.jar:?] at org.matsim.core.replanning.modules.AbstractMultithreadedModule$PlanAlgoThread.run(AbstractMultithreadedModul

kainagel commented 3 years ago

Could you please attach the full logfile? Thanks ...

khzannat commented 3 years ago

logfileWarningsErrors.log logfile.log I have attached herewith the logfile with error and full logfile.

jalal1 commented 3 years ago

I quickly looked to the logfileWarningsErrors.log and I see the following:

2021-10-18T16:08:15,628 WARN Dijkstra:304 No route was found from node 317601113 to node pt_33. Some possible reasons: 2021-10-18T16:08:15,629 WARN Dijkstra:305 Network is not connected. Run NetworkCleaner(). 2021-10-18T16:08:15,629 WARN Dijkstra:306 Network for considered mode does not even exist. Modes need to be entered for each link in network.xml. 2021-10-18T16:08:15,629 WARN Dijkstra:307 * Network for considered mode is not connected to starting or ending point of route. Setting insertingAccessEgressWalk to true may help.

This means you have some issues in the network.xml. Use NetworkCleaner() first, then you have to manage the modes in the network.xml

I don't remember the exact details, but you may check some examples in GitHub, to see how modes are added to network.xml.

khzannat commented 3 years ago

Thank you very much for your suggestion. I did the network cleanup but it removed my BRT network. I think I couldn't make a connection of BRT with the existing network because all BRT nodes are manually created (as it is a future scenario). I used the following code to create node and then created connection between each node. var startNode = network.getFactory().createNode(Id.createNodeId("pt_start"), new Coord(237243.491728,2656248.34032)); network.addNode(startNode); connections.add(createLink("pt_1L", startNode, stop1))

I could not find a way to start (startNode ) the BRT node from the exiting node without creating a node. As a result, startNode overlapped with the existing node. Instead of creating a new node is it possible to refer to a existing node (example node ID: 317601113) as startNode?

kainagel commented 2 years ago

I have to admit that I don't know the details enough here; it would be good if other people could come to the help how this is typically resolved. Here are some thoughts:

If nothing of this helps, it would be helpful to isolate the plan that is causing the problem. Unfortunately, the corresponding error message does not give the person ID. I will try to add this functionality into the code. Evidently this will not help with 13.0, but since Christian already recommended a newer version ...

khzannat commented 2 years ago

Dear Professor Nagel, Thank you for your detail reply. My existing network (assigned for car and other mode) is not the problem. I developed my base model (existing scenario) with the existing network and it is not causing the problem. The problem appeared after creating a BRT network on the existing network. I have attached herewith the code I used to built the BRT network (I had to code each stoppage manually as appropriate documentation for it wasn't available). With this network the error I attached before is happening. This BRT network is not connected with the other node/link of the existing network. I assumed by default each stoppage will be accessed by teleported mode walking.

NB: Since, I am new to java and matsim my codes are not as clean as you might expect.
CreateBrt.zip

kainagel commented 2 years ago

Hello, if we are talking about code, it would be far easier (and standard within the open source community) to have a pointer to a git repo. Would that be possible?

khzannat commented 2 years ago

Dear Professor, I have attached herewith the github link of my public repository: https://github.com/khzannat/matsim-example-project/blob/master/src/main/java/org/matsim/project/CreateBrt.java Also, my input file are publicly available: https://github.com/khzannat/matsim-example-project/tree/master/scenarios/Dhaka_input

vsp-gleich commented 2 years ago

Hello, I just double checked with the open Berlin model and the car and the pt links are not interconnected and it works there. I don't see any obvious issue while fast reading the CreateBrt code. So IMHO the issue is most likely that someone tries to route to a pt link with a mode that is not pt alhough the pt links should only be used by pt. Have you tried using accessEgressRouting e.g. by adding config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); in your run class (before loading the Scenario)? The default value is AccessEgressType.none most likely for some old tests or backward compatibility.

khzannat commented 2 years ago

Hi Thank you for your suggestion. I have already tried your given suggestion. https://github.com/khzannat/matsim-example-project/blob/master/src/main/java/org/matsim/project/RunMatsim2.java I have added here the link of my runmatsim class where I made the changes to resolve the error. It seems it's not working as well.

vsp-gleich commented 2 years ago

Hello, looking at your Run class I saw https://github.com/khzannat/matsim-example-project/blob/b9e03b47dfe78124e84832db20a224eff991628a/src/main/java/org/matsim/project/RunMatsim2.java#L121-L123 where you add multiple allowed modes to all links. This could cause a routing request from a car link to a "pt_XXXX" link, i.e. between those unconnected networks. Furthermore I see https://github.com/khzannat/matsim-example-project/blob/b9e03b47dfe78124e84832db20a224eff991628a/src/main/java/org/matsim/project/RunMatsim2.java#L117 which adds pt as a qsim main mode, whereas in the open berlin scenario pt is not added there. Could you try without those lines 117 and most of all 121-123?

khzannat commented 2 years ago

Hi, If I remove line 117 and lines 121-123. I encountered a different error (attached bellow). Also, if the setnetworkmode for BRT line is pt, why setMainModes is causing routing request from a car to pt link? Because, I thought using this line config.qsim().setMainModes(CollectionUtils.stringToSet( "car,cng,pt")), I allowed car, cng, pt on the network instead of teleportation and network is a multimodal netwok. java.lang.RuntimeException: Object is null; follow stack trace at org.matsim.core.gbl.Gbl.assertNotNull(Gbl.java:209) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.facilities.FacilitiesUtils.decideOnLink(FacilitiesUtils.java:135) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.router.NetworkRoutingInclAccessEgressModule.calcRoute(NetworkRoutingInclAccessEgressModule.java:132) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.router.TripRouter.calcRoute(TripRouter.java:174) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.router.PlanRouter.run(PlanRouter.java:94) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.population.algorithms.PersonPrepareForSim.run(PersonPrepareForSim.java:220) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils$PersonAlgoThread.run(ParallelPersonAlgorithmUtils.java:145) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at java.lang.Thread.run(Thread.java:832) [?:?] 2021-10-25T20:56:43,568 ERROR MatsimRuntimeModifications:75 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) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.PrepareForSimImpl.run(PrepareForSimImpl.java:172) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.NewControler.prepareForSim(NewControler.java:113) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:80) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.project.RunMatsim2.main(RunMatsim2.java:139) [classes/:?] 2021-10-25T20:56:43,568 ERROR MatsimRuntimeModifications:81 ERROR --- This is an unexpected shutdown! 2021-10-25T20:56:43,568 ERROR MatsimRuntimeModifications:84 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) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.PrepareForSimImpl.run(PrepareForSimImpl.java:172) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.NewControler.prepareForSim(NewControler.java:113) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:80) ~[matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-14.0-2021w15-20210412.124250-1.jar:?] at org.matsim.project.RunMatsim2.main(RunMatsim2.java:139) [classes/:?]

vsp-gleich commented 2 years ago

If you open up all links for mode car, the closest link to the destination activity might fall on a pt link which is not connected to the car network (and does not need to be connected to the car network). That causes exceptions when routing between unconnected parts of the network. The qsim main modes are for the qsim only (the queue simulation that moves vehicles around the network). Here it makes sense to enter all modes for which the passenger is the vehicle's driver. However, pt passenger agents are handled separately because they are not vehicles moving according to the queue model between links but rather passengers hopping on and off pt vehicles which are simulated separately with driver agents. The config default comment says " [comma-separated list] Defines which modes are congested modes. Technically, these are the modes that the departure handler of the netsimengine handles. Effective cell size, effective lane width, flow capacity factor, and storage capacity factor need to be set with diligence. Need to be vehicular modes to make sense." Similar theory is behind the planCalcScore networkModes " All the modes for which the router is supposed to generate network routes (like car) " so https://github.com/khzannat/matsim-example-project/blob/b9e03b47dfe78124e84832db20a224eff991628a/src/main/java/org/matsim/project/RunMatsim2.java#L73 should be deleted, too (unless you want to add mode "cng" as a network mode, but certainly not pt. I do not know what cng is). Besides it seems you forgot to add config.plansCalcRoute().addModeRoutingParams( pars3 ); in line 66). The new error message looks as if there is still some issue with which link has which allowed mode.

khzannat commented 2 years ago

Hello, Thank you for your answer. cng is basically autorickshaw. It can be considered as non-app based ride-hailing service/taxi service but the speed is below car. It's specification is defined in vehicle.xml file. I kept line 74 as I want car and cng as network mode. And, after removing line 122 to 130 I have a new error. java.lang.RuntimeException: Object is null; follow stack trace at org.matsim.core.gbl.Gbl.assertNotNull(Gbl.java:209) ~[matsim-13.0.jar:?] at org.matsim.facilities.FacilitiesUtils.decideOnLink(FacilitiesUtils.java:135) ~[matsim-13.0.jar:?] at org.matsim.core.router.NetworkRoutingInclAccessEgressModule.calcRoute(NetworkRoutingInclAccessEgressModule.java:132) ~[matsim-13.0.jar:?] at org.matsim.core.router.TripRouter.calcRoute(TripRouter.java:174) ~[matsim-13.0.jar:?] at org.matsim.core.router.PlanRouter.run(PlanRouter.java:94) ~[matsim-13.0.jar:?] at org.matsim.core.population.algorithms.PersonPrepareForSim.run(PersonPrepareForSim.java:220) ~[matsim-13.0.jar:?] at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils$PersonAlgoThread.run(ParallelPersonAlgorithmUtils.java:145) ~[matsim-13.0.jar:?] at java.lang.Thread.run(Thread.java:832) [?:?] 2021-11-08T00:12:52,057 ERROR MatsimRuntimeModifications:75 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) ~[matsim-13.0.jar:?] at org.matsim.core.controler.PrepareForSimImpl.run(PrepareForSimImpl.java:172) ~[matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.prepareForSim(NewControler.java:113) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:80) ~[matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-13.0.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-13.0.jar:?] at org.matsim.project.RunMatsim2.main(RunMatsim2.java:140) [classes/:?] 2021-11-08T00:12:52,058 ERROR MatsimRuntimeModifications:81 ERROR --- This is an unexpected shutdown! 2021-11-08T00:12:52,058 ERROR MatsimRuntimeModifications:84 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) ~[matsim-13.0.jar:?] at org.matsim.core.controler.PrepareForSimImpl.run(PrepareForSimImpl.java:172) ~[matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.prepareForSim(NewControler.java:113) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:80) ~[matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-13.0.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-13.0.jar:?] at org.matsim.project.RunMatsim2.main(RunMatsim2.java:140) [classes/:?]

vsp-gleich commented 2 years ago

Hi, I checked out your github repository and tried to investigate. File paths were inconsistent, so I had to guess to make it run, please double check. I changed the activity types in plans2.xml in order to have them consistent with the activity types in your config.xml. For me it gives no errors when running with java openjdk-11. If you give me write access to your repository I can commit this to your repository.

khzannat commented 2 years ago

Hi Can you check with my 1pc sample input? it is added in Dhaka_input2. And, the config I am using for running BRT is also added there. https://github.com/khzannat/matsim-example-project/tree/master/scenarios/Dhaka_input2 The error I mentioned above is still there.

vsp-gleich commented 2 years ago

Sorry, the file paths are inconsistent again. I changed some paths to use Dhaka_input instead of Dhaka_input2 where network-with-pt.xml.gz and the transit schedule and vehicles files are missing, but you also refer to a vehicles.xml file that does not exist. Could you please add a version whose file paths work?

khzannat commented 2 years ago

I am sorry for the inconsistency. You can use all the input from Dhaka_input2 for runmatsim2. Runmatsim1 and Dhaka_input1 were for the base scenario, which did not have any error.

vsp-gleich commented 2 years ago

Thank you! Now I get the following error message: 2021-11-08T17:15:32,496 WARN NetworkUtils:437 [nearestNode not found. Will probably crash eventually. Maybe run NetworkCleaner? Also may mean that network for mode is not defined.]org.matsim.core.network.NetworkImpl@6a1c1d0b[capperiod=3600.0][nof_nodes=0] 2021-11-08T17:15:32,498 ERROR ParallelPersonAlgorithmUtils$ExceptionHandler:164 Thread PersonPrepareForSim.1 died with exception while handling events. java.lang.RuntimeException: Object is null; follow stack trace at org.matsim.core.gbl.Gbl.assertNotNull(Gbl.java:209) ~[matsim-13.0.jar:?] at org.matsim.facilities.FacilitiesUtils.decideOnLink(FacilitiesUtils.java:135) ~[matsim-13.0.jar:?] at org.matsim.core.router.NetworkRoutingInclAccessEgressModule.calcRoute(NetworkRoutingInclAccessEgressModule.java:132) ~[matsim-13.0.jar:?] at org.matsim.core.router.TripRouter.calcRoute(TripRouter.java:174) ~[matsim-13.0.jar:?] at org.matsim.core.router.PlanRouter.run(PlanRouter.java:94) ~[matsim-13.0.jar:?] at org.matsim.core.population.algorithms.PersonPrepareForSim.run(PersonPrepareForSim.java:220) ~[matsim-13.0.jar:?] at org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils$PersonAlgoThread.run(ParallelPersonAlgorithmUtils.java:145) ~[matsim-13.0.jar:?] at java.lang.Thread.run(Thread.java:829) [?:?]

So it is an issue with the network.

vsp-gleich commented 2 years ago

You have defined the modes "car","bus","rickshaw","hh","cng","pt" as available modes for your agents. Which of those modes are supposed to be

khzannat commented 2 years ago

Before implementing the BRT I did the base model with this network and there were no issues with it. Among the modes: Real network mode is car and cng. Bus, hh are public transport but not structured in Dhaka (not possible to manually develop the pt network mode for both of them), therefore I marked them as teleported mode and just want to estimate the travel time as the routed travel time over the network, but without any vehicle actually being simulated in the mobsim. Rickshaw I also marked as teleported mode as rickshaw is restricted for some network. Since brt will be implemented very soon in Dhaka I wanted it as pt network mode not as teleported like bus and hh. As a result I will be able to see BRT's impact after the implementation.

vsp-gleich commented 2 years ago

Hi, I just pushed another branch:

On that branch it works for me. I hope it works for you now, too.

khzannat commented 2 years ago

Hi Thank you very much, I have couple of queries about the way you resolved the issue: 1) Before I set average travel speed as setTeleportedModeSpeed (I assume I set them as teleported modes independent from the network). If I want bus, hh to include as teleported modes independent from the network my previous code would work? Right? But it didn't! What could be potential reason for that? 2) Now you coded as rickshaw, hh or bus will be teleported modes with the travel time as the routed travel time over the network. You included setTeleportedModeFreespeedLimit which was the average speed before. Are they same? What teleported setTeleportedModeFreespeedFactor actually doing? 3) Following your recommendation do you have any code example of setting the allowed modes in the input network file as I have converted the osm network to matsim network?

vsp-gleich commented 2 years ago
1. Before I set average travel speed as setTeleportedModeSpeed (I assume I set them as teleported modes independent from the network). If I want bus, hh to include as teleported modes independent from the network my previous code would work? Right? But it didn't! What could be potential reason for that?

You forgot about mode "cng" which was not contained in the allowed modes of any link (causing the no nearest node found error) but was supposed to be a network mode. In a previous version you added it to all links including pt links, but those were not connected to all other links giving the exception during routing. Now each mode to be routed over the network has at least one link where it is registered as allowed mode and all links allowed to a certain mode are (apparently) interconnected.

2. Now you coded as rickshaw, hh or bus will be teleported modes with the travel time as the routed travel time over the network. You included setTeleportedModeFreespeedLimit  which was the average speed before. Are they same? What teleported setTeleportedModeFreespeedFactor actually doing?

setTeleportedModeFreespeedFactor sets the travel time to a factor of the freespeed of the link. I added setTeleportedModeFreespeedLimit in order to limit to the speed you set before so the resulting travel times should be more similar to what you had before.

3. Following your recommendation do you have any code example of setting the allowed modes in the input network file as I have converted the osm network to matsim network?

There is code to read in networks from osm, but that usually does not set any modes besides car. The modes you added are very specific I doubt anyone has written an example. This is something you have to define dependent on what restrictions you want to model. E.g. if you want to prohibit cng or rickshaw from using fast roads (e.g. motorways) you can try with a for loop over all car links (like the one I implemented) and then if freespeed <= 70 / 3.6 add cng and rickshaw to allowed modes.

khzannat commented 2 years ago

Thank you very much, it resolved the issue :)