Skip to content

faq 88440954

Billy Charlton edited this page Sep 5, 2018 · 2 revisions

Changing the leg modes

by Rolando Armas on 2016-10-13 06:27:04


Hi, MATSim friends,

I want to test several scenarios changing the proportion of agents that use public transportation and private cars. The initial plan has a ratio of 3:1. We want to test several scenarios changing that ratio by modifying the initial plans.  Is there a proper way to modify the initial leg modes?

I wonder if  I can use changeLegMode module to change a specific number of agents from car to pt leg modes or vice verse? Is it feasible?

How can I do?


Thanks.


Comments: 3


Re: Changing the leg modes

by Johan W. Joubert on 2016-10-13 07:18:24

Rolando, I am not sure I understand exactly what you want to do. If, as I understand it, you only want to change the ratio of the pt legs in the initial plans, then I suggest you simply iterate through the population, before or at the start of the simulation run, get their initial plans and (randomly) set the mode using leg.setMode("pt").

The ChangeLegMode class is a replanning module, which means agents will change their mode from one iteration to the next. This does not seem to be what you want to achieve, right?


Re: Changing the leg modes

by Rolando Armas on 2016-10-13 08:06:39

Hi, Johan.

Yes, I want to change the leg modes of some agents, changing the proportion between car and pt leg modes.

I was wondering if ChangeLegMode provide an aditional functionality to do that, I mean, checking some constraints in order to create more "coherent" plans.

But, if it is only necessary to change the agents leg modes from the initial plans, it is that I need.

So, how can I do it?


Thanks.


Re: Changing the leg modes

by Johan W. Joubert on 2016-10-13 12:28:08

Working with the leg:

for(Person p : sc.getPopulation().getPersons().values()){
    for(PlanElement pe : p.getSelectedPlan().getPlanElements()){
       if(pe instanceof Leg){
          Leg leg = (Leg)pe;
			
          /* Change the leg mode... */
       }
    }
 }

Hope that helps.

Clone this wiki locally