arup-group / elara

Command line utility for processing MATSim events output files.
MIT License
14 stars 4 forks source link

Mode share handling by activity #119

Closed elizabethc-arup closed 3 years ago

elizabethc-arup commented 3 years ago

The NZ mode share benchmark only consists of Journey2Work data however Elara currently computes the global mode share from all plans. As a result it would be very ideal if there is a way to filter the mode share by activity (e.g. work) so that we can compare the census journey2work mode share to the simulation journey2work mode share.

fredshone commented 3 years ago

Option 1: We add a new mode share plan handler that considers the destination (and origin?) activity type as a filter.

Option 2: We add the above functionality to the existing mode share plan handler.

Option 3: Similar to option 1 but using a post process handler. the post processor could use the trips log output.

I am strongly in favour of option 1. Suggest we call it ActivityModeShare and that the config will be as follows:

activity_mode_share = {activities = ["work"]}

elizabethc-arup commented 3 years ago

I think Option 1 looks really good! Would it be ok if I had a crack at implementing this?

fredshone commented 3 years ago

great! - I will have a go at 118

fredshone commented 3 years ago

... so I discovered the existing modeshare handler already provides a breakdown ("groupby") by destination activity here.

I would still like to see a dedicated handler that does a filter rather than groupby. Both for clarity and speed. But the code is somewhat reusable.

fredshone commented 3 years ago

review of the current status of handler configurations:

fredshone commented 3 years ago

Thinking about avoiding future confusion, in the current setup:

handler = {modes = ["car, bus"], optional_arg = "./tests/test_outputs/trip_duration_breakdown_all.csv"}

modes is special because it is a list that causes elara to spin up unique handlers, eg a link_counter for both cars and buses.

modes also has a handy shortcut syntax: handler = ["car, bus"]

If we allow any other options as lists the assumption should be that these do not (i) cause unique handlers for each value and (ii) have no shortcut syntax in config.

For example: activity_mode_share = {activities = ["work", "business"]}

...would run a single handler that would filter for both "work" and "business" activities (not two seperate handlers doing each).

This would also not be possible: activity_mode_share = ["work", "business"] because it would be interpretted as modes.

We might be able to fix the latter case in future.

Also to be pedantic i think this will not be possible:

activity_mode_share = {activities = ["work", "business"]}
activity_mode_share = {activities = ["home"]}

...the latter will overwrite the former.

elizabethc-arup commented 3 years ago

Would it make sense with the current structure of Elara to create a wrapper / parent function which essentially loops through each activity provided to the activity_mode_share handler, filters the activity based on that and apply the mode share handling to it?

fredshone commented 3 years ago

my preference is the new handler be stand-alone. There will be duplication of code - but also clearer structure. Commonly used methods (such as identify trip mode) could be moved to the parent PlanHandlerTool parent.

But ultimately I'd be pleased to see someone elses take on how it can fit in.

andkay commented 3 years ago

This is now addressed by the new mode_share_comparison benchmark.