`AgentTollsPaid` handler should parse `personMoney` events
mfitz opened this issue · 5 comments
We have an existing AgentTollsPaid
handler to summarise tolls paid by agents. This handler essentially recapitulates MATSim's own tolling logic by taking a road pricing file, output plans file, and person attributes file as input, iterating over each selected
agent plan, stepping through the links in each leg of the plan, and checking whether or not each link should incur a toll according to the road pricing file.
We run the risk of our logic differing somehow from MATSim's, hence giving us incorrect results. Furthermore, the results from this handler will definitely be wrong whenever our model uses a TollFactor
class, for example for differential road pricing, or capped road pricing, because the handler has no view of the factor being applied, only the "default" un-factored toll defined in the road pricing file.
An alternative approach is for the handler (or possibly a new handler) to rely only on person money events in MATSim's events output file. These events fire when a toll is paid by an agent, hence the amount charged will always have taken into account any applicable toll factor. Person money events for toll charges look like this - note the amounts are negative, representing money being taken from the agent:
<event time="202.0" type="personMoney" person="LGV_45110" amount="-0.07131634459841994" purpose="toll" />
<event time="210.0" type="personMoney" person="LGV_33658" amount="-0.11977075573916363" purpose="toll" />
<event time="210.0" type="personMoney" person="LGV_2763" amount="-0.004715995520649573" purpose="toll" />
<event time="214.0" type="personMoney" person="LGV_45110" amount="-0.02986826262367614" purpose="toll" />
<event time="214.0" type="personMoney" person="LGV_26973" amount="-0.3055779751027617" purpose="toll" />
<event time="216.0" type="personMoney" person="LGV_79004" amount="-0.16695628514069902" purpose="toll" />
<event time="223.0" type="personMoney" person="LGV_45110" amount="-0.1563088745151321" purpose="toll" />
<event time="226.0" type="personMoney" person="LGV_29299" amount="-0.07131634459841994" purpose="toll" />
Great idea @mfitz. I will move this from plan handling to event handling. I'd expect your toll capping logic would then result in many events with -0.0 toll amounts -- i.e.:
<event time="226.0" type="personMoney" person="agent_101" amount="-0.0" purpose="toll" />
Is that right?
Great idea @mfitz. I will move this from plan handling to event handling.
Thinking about it, maybe we should keep the existing handler but add a new one that handles the money events? So keep the plan handler but add a new event handler?
I'd expect your toll capping logic would then result in many events with -0.0 toll amounts -- i.e.:
<event time="226.0" type="personMoney" person="agent_101" amount="-0.0" purpose="toll" />
Is that right?
No, when the toll is not paid, for example because the agent has hit the daily cap according to the TollFactor
, no personMoney
event fires. Only when the agent actually pays (or receives) money do you see these events.
Gotcha -- in practice, it doesn't matter whether there is no event or a $0 event; more of an academic question.
What's your thinking about keeping both handlers? To me, doubling up on handler functionality seems likely to confuse users. Especially when two handlers purport to calculate the same thing in different ways, but may have divergent answers depending on config and controler specs.
Gotcha -- in practice, it doesn't matter whether there is no event or a $0 event; more of an academic question.
What's your thinking about keeping both handlers? To me, doubling up on handler functionality seems likely to confuse users. Especially when two handlers purport to calculate the same thing in different ways, but may have divergent answers depending on config and controler specs.
Speaking selfishly, I could use the existing handler in order to compare tolls that would be due without any factoring with tolls that were actually paid when using factoring for differential pricing and/or capping.
However, I take your point about confusion - we would have to be careful. Renaming the existing AgentTollsPaid
to something to do with plans and unfactored tolls or suchlike could be the way to go. And if we have any existing documentation for that handler, amend and hide it, replacing it with docs for the new, more accurate handler.
Although perhaps we could even roll the with/without factoring reporting in to a single new handler, in which case the old one can be killed. What do you think?