Open K4Werri opened 4 years ago
Hello,
Relatively new to MATSim myself. What you have in mind should be possible, but I can't imagine it would be easy.
In one of your last questions you ask about pt vehicles being implemented as agents. As far as I know, that's already how pt is implemented.
I don't calculate / change my plans during a simulation, but before they are run, so I use strategy and routing modules. I imagine that those won't work for you if you want to change an ongoing simulation (unless you would rather do these changes by analyzing previous iterations, as long as the disturbances to the network are the same in each iteration. Then strategy and routing modules is what you should look into).
For adaptive scheduling / changing routes / plans of an ongoing simulation, look at the Within Day Replanning (WDR) examples. That should give you a start on how to change plans during a simulation. However I have no idea if Pt has any particularities that would make it harder to use WDR.
For analysis, there is the Analysis contrib that should give you a start. Vsp also has a congestion analysis thing. Generally for analysis you need event handlers.
Hope that helps!
Hi,
Thanks for your thoughts and answers above.
I'll need to read the PT material again. I missed that PT vehicles are implemented as agents.
I did look through the WDR chapter in the MATSim book and there was material there that looked useful. I would also like to use the BDI agent contribution to provide the decision making to drive schedule adaptation.
The unknown for me, as in your comment above, was whether the PT implementation would allow schedule changes eg have a train skip a station or have a train slow down or wait (or other some other action) based on network change events and other decisions. Or, would I need to build a variant of it myself.
Thanks again for responding.
Kevin.
I've glanced at the bdiintegration contrib, but never used it. I don't know if it can be used to modify Pt vehicles though, but you should be able to modify the Pt vehicles with a WDR. If all else fails maybe use the Carsharing contrib with the bdiintegration? The bushfire example should give you an idea of how to get agents to react to events.
I seem to remember a question asking about changing road capacities during a simulation...
The thing is (as far as I understand), a vehicle isn't just going to slow down on a link ; unless there is something physically blocking it, it's going to go the speed limit (with the default mobsim and agents). I guess you could change the freespeed of the link to avoid having to make a new mobsim and new agents? You could also tell the Pt vehicle to wait on a link or at the stop if that's easier.
In terms of implementation, the API for Pt is a good start https://www.matsim.org/apidocs/core/12.0/. In particular : https://www.matsim.org/apidocs/core/12.0/org/matsim/pt/transitSchedule/api/TransitSchedule.html
There is also an ongoing projet that does research in Pt in MATSim : SMART-PT.
Something else that might be handy: https://www.matsim.org/apidocs/core/12.0/org/matsim/pt/router/TransitScheduleChangedEventHandler.html
Hi,
As well as the BDI integration material in the MATSim book, I've also read some of the papers describing the initial work. It looks quite useful and I think I can make it work for me.
An advantage of being able to use the PT components is the work to import and use extant PT schedules is already there. Otherwise, I would need to build those components. Yes, you can modify the freespeed and, as I recall, you can modify the number of links as well. I would be seeking to do either have the vehicle slow down or stop and wait depending on the situation.
So, for me the key unknown is whether I can, using a BDI agent via the BDI integration contrib, influence the behaviour of the PT simulation by altering schedules or by varying the route of a particular PT vehicle.
I find the api doc ok once you know you need a particular api. I have also spent some time looking at examples to get some clues on what api components I need to use.
More looking through the docs I guess.
Thanks for your thoughts.
K.
Hi @K4Werri, we haven't tried connecting BDI to PT vehicles, but if you did want to investigate that idea and had questions around the BDI-MATSim integration then please get in touch. The framework is still maintained and we use it for bushfire evacuation modelling here in Australia. An example scenario with a link to a video is here.
Hi,
Thanks. I'll do that. Same timezone so easy enough.
Regards.
K.
Hi
Yes, you can modify the freespeed and, as I recall, you can modify the number of links as well. I would be seeking to do either have the vehicle slow down or stop and wait depending on the situation.
The problem with manipulating freespeed on links is that usually multiple lines operate over the same link and for that reason all lines are affected. This can be right if you have a railway network and want to block a certain track and all services passing over it, but then you need to have a network with railway services operating over the same track being mapped to the same link. GTFS has no information on tracks or road networks whatsoever, so you have to figure that out yourself.
So, for me the key unknown is whether I can, using a BDI agent via the BDI integration contrib, influence the behaviour of the PT simulation by altering schedules or by varying the route of a particular PT vehicle.
As far as I know, the schedule is constant during an iteration and cannot be altered in an easy way during the iteration. The TransitScheduleChangedEvent only helps with resetting the router to discard pre-processed schedule data and pre-process again based on the current TransitSchedule. But the vehicles themselves continue to operate to the old schedule they had at the beginning of the iteration. You can already simulate some disruptions despite these limitations (see e.g. https://doi.org/10.1016/j.procs.2020.03.161), but this obviously limits what can be modelled and what not. It's not impossible to model "trains slow down, trains skip stops, trains wait longer at some stations or some trains being cancelled" in matsim, but it would probably need heavy work. The easiest way to go is probably modifying the plans of the pt driver agents (never tried myself). Changing the schedule does not help during the iteration or you have to find a way to re-map existing vehicles and transit drivers of the old schedule to the new schedule which sounds very complicated.
The topic sound very interesting though, so keep us informed ;-)
Hi,
Thanks for your response.
I had, in my reading, come across a similar comment to yours regarding the issues with manipulating freespeed. I concluded that I could do what I wanted but with some extra work on my part.
Thanks for the reference on simulating disruptions. You've also confirmed (thanks) what I thought about altering the schedules, that is, it would not be easy. I did not know that you could modify the pt driver agents. I'll have another look at the documentation. That might get me part of the way. I think I do need to be able to alter schedules though. Some more thought required.
Thanks again.
K.
Hi,
Apologies in advance if the following are naive. New to MATSim and trying to figure out whether it is usable for my problem. I have some questions about simulating public transport. I have read parts of the book and the current user guide but have not found answers to all my questions.
I am focusing on public transport initially considering rail but hoping to add buses as a second stage. I would like to simulate passenger rail services in the presence of disturbances and disruptions with adaptive (re-)scheduling to (gradually) restore services to the original schedule. The rescheduling would consist of any/all of trains slow down, trains skip stops, trains wait longer at some stations or some trains being cancelled. I would want to gather statistics on delay to services and the number of commuters affected.
I would be interested in any thoughts on whether what I've described above is feasible in MATSim?
The adaptive scheduling would be done via BDI agents running outside MATSim but exchanging information through the implementation of some integration components (I see that something like this has been done though with a different problem domain).
I think the disturbances could be specified using the time dependent network features. Is this correct?
However, to do the adaptive scheduling component, it would need to be possible to dynamically change aspects of the transit schedule during the simulation. I cannot determine from the material I've examined thus far at as to whether this is possible or not. There looks to be an api for the transit schedule but I could not work out whether that would allow dynamic changes at runtime.
An alternative may be to implement public transport vehicles eg trains, buses as agents. Is that possible?
Any thoughts or advice would be appreciated.
Thanks in advance.
Kevin.