matsim-org/pt2matsim

Adding bicycles to multimodal network

miilljana opened this issue · 5 comments

Hi, I am trying to add bicycle specific paths to the multimodal network along with cars and pt. For that purpose, I added the following in OsmConverterConfig class and I've defined the bicycleSingleton before:

defaultConfig.addParameterSet(new OsmWayParams(Osm.Key.HIGHWAY, Osm.Value.CYCLEWAY,1, 30.0/3.6, 1.0,300,false,bicycleSingleton));
		defaultConfig.addParameterSet(new OsmWayParams(Osm.Key.HIGHWAY, Osm.Value.TRACK,1, 30.0/3.6, 1.0,300,false,bicycleSingleton));
		defaultConfig.addParameterSet(new OsmWayParams(Osm.Key.HIGHWAY, Osm.Value.STEPS,1, 1.0/3.6, 1.0,300,false,bicycleSingleton));
		defaultConfig.addParameterSet(new OsmWayParams(Osm.Key.HIGHWAY, Osm.Value.PEDESTRIAN,1, 30.0/3.6, 1.0,300,false,bicycleSingleton));
		defaultConfig.addParameterSet(new OsmWayParams(Osm.Key.HIGHWAY, Osm.Value.PATH,1, 20.0/3.6, 1.0,300,false,bicycleSingleton));
		defaultConfig.addParameterSet(new OsmWayParams(Osm.Key.HIGHWAY, Osm.Value.FOOT_WAY,1, 30.0/3.6, 1.0,300,false,bicycleSingleton));
		defaultConfig.addParameterSet(new OsmWayParams(Osm.Key.HIGHWAY, Osm.Value.SERVICE,1, 30.0/3.6, 1.0,300,false,bicycleSingleton));

defaultConfig.addParameterSet(new RoutableSubnetworkParams("car", carSingleton));
defaultConfig.addParameterSet(new RoutableSubnetworkParams("bicycle", bicycleSingleton));
defaultConfig.addParameterSet(new RoutableSubnetworkParams("car", new HashSet<>(Arrays.asList("car", "bicycle"))));
defaultConfig.addParameterSet(new RoutableSubnetworkParams("bus", new HashSet<>(Arrays.asList("car", "bus"))));

Here is the network:

ptmatsim_issue

purple- cycleway
blue-footway
yellow-pedestrian
At the end the allowed mode on these links is car, and not bicycle as I have defined before. Any help on this?

Could you provide a reproducible example (code you used to convert the file and an example extent of the osm network)? It's hard to tell what's going on because on your screenshot the selected link is purple so I'm a bit confused.

defaultConfig.addParameterSet(new RoutableSubnetworkParams("car", new HashSet<>(Arrays.asList("car", "bicycle"))));

Why do you use car and bicycle as a subnetwork for cars?

I used the PT2MATSimExample example to convert the network and previously I made changes regarding the required input files.
As pt2matsim doesn't extract bicycle specific paths I made changes to OsmConverterConfigGroup and added only the the lines mentioned in previous comment.

What I want to do is to have a network where cars, bicycles and pt are allowed. I am pretty new to this and I am little bit confused regarding the subnetworks.

defaultConfig.addParameterSet(new RoutableSubnetworkParams("car", carSingleton)); defaultConfig.addParameterSet(new RoutableSubnetworkParams("bicycle", bicycleSingleton)); defaultConfig.addParameterSet(new RoutableSubnetworkParams("car", new HashSet<>(Arrays.asList("car", "bicycle")))); defaultConfig.addParameterSet(new RoutableSubnetworkParams("bus", new HashSet<>(Arrays.asList("car", "bus"))));

Only with this combination of parameters all the relevant paths are extracted from the network.zip file, otherwise the foot way, pedestrian, track, steps, service ways are missed out and not included in the final network.xml
. Also since there is little number of

key:highway value:bicycle

paths, the cyclist need to use the car network otherwise the router cannot find path for them to reach the destination, that's why I created new subnetwork where cars and bicycles are included. I don't know if this makes sense. Any help is welcomed.

It's indeed a bit hard to wrap your head around those subnetworks and modes, I'll try to explain.

There's two steps in converting a network: First, create MATSim links from OSM ways with OsmWayParams. You define for an osm way with a given key value pair (e.g. highway and primary) which values the converted MATSim link should have (lanes, freespeed, ... and allowedTransport modes). The parametersets you provided look ok to create a separate bicicle network. After this step we have separate networks for car, rails, bikes (in your case) and bus/public transit. The bus network is created from OSM data with bus-only lanes and so on.

The RoutableSubnetwork step now cleans those networks and creates a separate routable network for each subnetworkMode. #80 describes the method, I'll also point you to matsim-code-examples#397 where @sebhoerl lines out what's happening there.

The parameter allowedTransportModes defines which links the subnetworkMode can use. For bus the default looks like this:

defaultConfig.addParameterSet(new RoutableSubnetworkParams("bus", new HashSet<>(Arrays.asList("car", "bus"))));

which means that busses can use links with car and bus transportModes.

the cyclist need to use the car network otherwise the router cannot find path for them to reach the destination

This means your code should look something like this

defaultConfig.addParameterSet(new RoutableSubnetworkParams("bicycle", new HashSet<>(Arrays.asList("bicycle", "car"))));

However, that way biciycles can use all car links, including motorways. If that's an issue for you you could add more osm ways to your OsmWayParams list (I'd guess primary and below). However (again), with this method you create a separate network for bikes with no interaction with cars. So it might be easier to use a script after all this is done and remove bicycle as an allowedTransportMode from motorways.

Thank you Flavio for your detailed answer! I have one more doubt to make it clear.
After adding
defaultConfig.addParameterSet(new RoutableSubnetworkParams("bicycle", new HashSet<>(Arrays.asList("car", "bicycle"))));
and
config.getModesToKeepOnCleanUp().add("car,bicycle");
I got the network I needed. And that's fine.

To sum up:

  1. First I created separate subnetworks, and then all are merged into one network (please correct me if I am wrong).
    DefaultConfig.addParameterSet(new RoutableSubnetworkParams("car", carSingleton)); defaultConfig.addParameterSet(new RoutableSubnetworkParams("bicycle", bicycleSingleton)); defaultConfig.addParameterSet(new RoutableSubnetworkParams("bicycle", new HashSet<>(Arrays.asList("car", "bicycle")))); defaultConfig.addParameterSet(new RoutableSubnetworkParams("bus", new HashSet<>(Arrays.asList("car", "bus"))));

  2. When cleaning the network I specified the bicycle to be kept
    config.getModesToKeepOnCleanUp().add("car,bicycle");

As you said:

However (again), with this method you create a separate network for bikes with no interaction with cars.

Does this mean that the bikes are not interacting with cars, even though they use the car subnetowrk which is separate from the subnetowrk the cars are using? And if this is correct, is there a possibility of their interraciton?

Does this mean that the bikes are not interacting with cars, even though they use the car subnetowrk which is separate from the subnetowrk the cars are using? And if this is correct, is there a possibility of their interraciton?

No, I worded this a bit confusing. If you use RoutableSubnetworks (where bikes can use car links as well) there is interaction between cars and bikes on links that they both use. So your approach gives you the intended result (just consider that bikes can also use motorways).

I was just pointing out at the end that it's also possible to create a bike network completely separate from cars by adding more OsmWayParams.