matsim-org / matsim-libs

Multi-Agent Transport Simulation
www.matsim.org
482 stars 446 forks source link

Inconsistent behavior with transit only simulation #1216

Closed nkuehnel closed 3 years ago

nkuehnel commented 3 years ago

Dear all,

we wanted to run a "pt only" simulation without cars. However, in the person prepare for sim, each activity has to be assigned to a link: https://github.com/matsim-org/matsim-libs/blob/55f9aa4444c3a22bdc5d255768bb39d278406dd0/matsim/src/main/java/org/matsim/core/population/algorithms/PersonPrepareForSim.java#L173-L187

This then runs the XY2Links algorithm, which is basically checking for the nearest link: https://github.com/matsim-org/matsim-libs/blob/81c09a2847b68b828bef59276cc6745a23fb2c0e/matsim/src/main/java/org/matsim/core/population/algorithms/XY2Links.java#L121

Now we get two different behaviors, depending on whether we set all links to a single "pt" mode or differentiated by individual pt modes such as "tram" "rail" etc.

  1. if we have links with individual pt modes, the network is considered "multimodal" in the PersonPrepareForSim. In this case the network will be filtered to "car" only links, which will then fail since we only have pt links: https://github.com/matsim-org/matsim-libs/blob/55f9aa4444c3a22bdc5d255768bb39d278406dd0/matsim/src/main/java/org/matsim/core/population/algorithms/PersonPrepareForSim.java#L87-L94
  2. if we set all links to "pt", the network is not considered as "Multimodal" and is thus not filtered for car links. In this case, the simulation runs through just fine.

It feels a bit wrong to me that the simulation fails in one case bot nut the other. I would think that MATSim should be able to run without a car network, regardless of whether the network is "multimodal" if all agents can only choose "pt" and no mode choice is enabled? Or should we just stick to have all links set to "pt" without any differentiation by actual pt mode? I appreciate any help/feedback/comment

Best Nico

kainagel commented 3 years ago

Well. Long-standing problem. Since the connection of facilities to car links was so deeply embedded into the code, I eventually decided that each facility needs to have a postal address. Which needs to be reachable by car.

So, in theory, it should be possible to do the following:

???


The fact that PrepareForSim fails with one execution path and not with the other is that the non-multimodal execution path is still there for backwards compatibility, but it was never upgraded to the new data model. Maybe we should completely get rid of it. (And maybe we should get rid of the execution path without access/egress.)

???

nkuehnel commented 3 years ago

I see; thanks for the swift reply. We will go with the single-car link then. I want to point out that maybe it should also fail in the case where there is only one pt mode case (i.e. all links set to mode "pt") to be consistent with the "postal address" idea.