matsim-org / matsim-code-examples

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

Query regarding the 1st Homework Task #1119

Open cnabu opened 1 month ago

cnabu commented 1 month ago

Hello,

My partner and I chose the Düsseldorf scenario for our initial homework project. As a new policy, I decided to restrict the setAllowedModes to bike only for five bridges connecting Düsseldorf to other districts and analyze the impact of this change. I successfully modified the input network file, changing the allowed modes from car, ride, and freight to bike. However, when I ran the simulation, the following error occurred. From my understanding, MATSim should adjust the routes accordingly during the simulation, as the Agent's plan file doesn't specify the exact route to take. Could someone advise why this error is happening and how to fix it?

duesseldorf-1pct-dc_114.logfile.log duesseldorf-1pct-dc_114.logfileWarningsErrors.log error changes-v1.7-network-with-pt.xml.gz

cnabu commented 1 month ago

Following are the names of the bridges and their link IDs:

Fleher bridge: 90115782 500532313 154653058

Joseph-Kardinal-Frings bridge: 159901568 468511901

Rheinknie bridge: 4532363 49010919

Oberkasseler Bridge: 142750745 369744127

Theodor-Heuss Bridge: 4440565 4440598

kainagel commented 1 month ago

A possible (and typical) issue is that matsim still "remembers" material from the situation where those modes were allowed on those links.

I can think of a number of possible approaches, but none of them is completely simple.

@simei94 , how did you solve this for leipzig?

And we need to find a better approach for this.

Janekdererste commented 1 month ago

The particular error indicates that the network for the mode car is not connected anymore. By closing all bridges for cars you have created two separate networks. The routing algorithm does not know how to handle this case. A simple fix would be to add one connection between the two river sides which is open for cars and give it a very low freespeed or capacity. This way, the routing algorithm can still find routes, but if agents try to cross the river by car, their plan will receive a bad score and should eventually be dropped.

simei94 commented 1 month ago

My solution for Leipzig was similar to @cnabu, but in this case the problem is what @Janekdererste is describing. I would say you should put the capacity + freespeed of the bridge links to a very low value, BUT NOT 0. You will see that some agents will still be using the links, as they have activities close to them. You could check the following class (method prepareNetworkBlockedRoad) for an example, we did the exact thing there.

cnabu commented 1 month ago

First of all, I want to express my gratitude to everyone for their advice. I've tried the approach suggested by @simei94 where instead of removing the mode of transport (i.e car and ride) from those links I've changed the free speed & capacity to 0.1 and 10.0, respectively, and it worked like a charm. Thanks

paulheinr commented 1 week ago

I think the issues is not, that the whole network is separated, but that activities take place at links that are not reachable due to the modification (because of a local dead end). Right now, that XY2Links class maps to the nearest link regardless of the allowed mode (org.matsim.core.population.algorithms.XY2Links#processPlan). Assume this link sequence: ---l_0-->(n)---l_1-->(m)---l_2--> Let's say, an activity takes place on link l_1, the access and egress legs have mode car and we restrict l_0 and l_2 and do not allow car. If we want to reach the activity, the end node of a route would be n. The only way to reach n would be via l_0. This is not possible with car. The same situation happens if an agent departs at the activity, because the start node of the next route would be m which can only be left without car.

The question is: Do we want this behaviour? We could also try to detect these local dead ends for one mode and pick another link.