Skip to content

faq 89260043

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

activity at time

by GregoryM on 2016-10-20 01:42:08


I would like to build a picture of what all my agents are doing at particular and arbitrary time slices. So, for example, I want to know how many are at home, how many are working, and how many are on the road in 15-minute intervals throughout the day.

I have started doing this with an EventsHandler; when an activity begins or ends I can notice it and increment a map counter for any bins that the activity includes. But this seems a little convoluted. Are there any methods for reading output plans or events and saying something like

for(Person person : pop.getPersons().values()){
   Plan plan = person.getSelectedPlan();
   // activity at time 0630
   String activityType = plan.activityatTime(0630).activityType();
 }

This seems like a more natural way for me to think about the problem, but I don't know if the methods I need are available.


Comments: 1


Re: activity at time

by Thibaut Dubernet on 2016-10-20 08:06:03

Dear Greg,

there is, unfortunately, no methods similar to what you describe. The reason is that a plan, as such, has to be "played" in some way to know what the agent would be doing at what time: this means, in a sense, that you need to create events out of the plan.

So those methods would anyway do something as what you describe under the hood: this is not particularly convoluted. I implemented something like this myself, in this package:

https://github.com/matsim-org/matsim/tree/master/playgrounds/ivtExt/src/main/java/playground/ivt/analysis/activityhistogram

ActivityHistogram is the actual event listener. The other classes are related to plotting the results, and adding the requested listeners as a Guice Module. You might want to copy the code in your project an modify it to your needs, as there is no maven artifact for the "playgrounds", and thus no proper way to include this as a dependency.

Clone this wiki locally