matsim-org / matsim-code-examples

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

Problem with introducing a new routed mode #1142

Open ArezHK opened 4 months ago

ArezHK commented 4 months ago

Hi,

I tried adding a new travel mode, named Bicycle, which is routed on the network. To explain further: I introduced a new mode called Bicycle, defined a new vehicle type for it, and added this mode to the allowed modes for some of my network links. I also implemented a strategy to allow agents to change modes.

However, I am encountering an issue. Although some agents choose Bicycle, they seem to get stuck and do not move. There is also no walking involved. Should I manually add the walking mode to the allowed modes so agents can walk to nearest link with alowed mode for Bicycle?

Could you please help me with this issue?

Thank you.

kainagel commented 4 months ago

There should be something like accessEgressType=accessEgressModeToLink in the routing config. That inserts automatic walk links between activity locations and the network. Could you please try and report back?

You also need to make sure that your Bicycle network is connected (i.e. there are no dead ends, and there are no two disconnected clusters). Running NetworkCleaner helps.

ArezHK commented 4 months ago

Dear Prof. @kainagel ,

Thank you for your response. Indeed, it helped me solve the issue. Now I have other issues:

  1. Some agents just jump onto the link (near the origin) and jump off the link (near the destination) within almost 1 second, which is not realistic!
  2. Some agents jump onto the link and travel in the opposite direction of the destination but then appear at the other end of the link and walk to the destination!

I have attached an image of my network here. (I added a two-directional, triangle-shaped network (blue-colored) which is only allowed for bicycles (as a newly defined routed mode).)

image

Link attributes are almost like below:

    <link id="1000001010" from="100162699" to="7437807472" length="4000" freespeed="10" capacity="600.0" permlanes="1.0" oneway="1" modes="bicycle" >
        <attributes>
            <attribute name="osm:way:highway" class="java.lang.String">residential</attribute>
            <attribute name="osm:way:name" class="java.lang.String">BicycleToNorth</attribute>
        </attributes>
    </link> 
kainagel commented 4 months ago

Hello, next time could you please open a new issue with a new question? From what you write, this is probably expected behavior:

JWJoubert commented 4 months ago

A contributing factor can also be that the two links of a road (one in either direction) are seen as equally far away from the point. So, which one is the agent supposed to pick? Well, you and I have real intelligence and figure that out. But in artificial intelligence, you have to come up with your own heuristic or, as is the case in MATSim (I may be wrong, but that's my understanding), live with its implementation: pick one at random. That might be why you see an agent taking off in the opposite direction.

ArezHK commented 4 months ago

Dear Prof. @kainagel @JWJoubert ,

Thank you for your responses.

Indeed, I used the previously existing nodes for creating my new links. To illustrate the situation more clearly, I have included an image below: At first, the agent jumps to the nearest link (1), disappears, and then reappears at the end of the link, moving in the opposite direction (2 & 3). Finally, it pops up again at the other end of the link and proceeds to work (4).

@kainagel , sorry for any confusion. I will make sure to follow your advice next time!

image

Output events + network: output_events.xml.gz output_network.xml.gz

jingjunL commented 1 month ago

Hi @ArezHK , I am also trying to add bicycle mode into my network and encountered this issue. Have you figured out how to add a new bicycle link? I think adding new bicycle link manually will be time consuming and I am also trying to simulate bicycle movement (instead of classic teleportation) in MATSim :)

ArezHK commented 1 month ago

Hi @jingjunL instead of adding links manually, another possible approach is adjusting the OSM network file and then convert that to MATsim network.