ActivitySim / sandag-abm3-example

BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Error on Ebike access utility #1

Closed jpn-- closed 6 months ago

jpn-- commented 7 months ago

This expression line does not work as it was probably intended.

https://github.com/ActivitySim/sandag-abm3-example/blob/34935f121a85eb74a184455ff5fbb93f51868b12/configs/resident/tour_mode_choice.csv#L368

The + operator has higher precedence than the &, so you get effectively this...

@(microConstant + ~df.ebike_owner)&(microRentTime + df.micro_access_inb + df.micro_access_out))*df.time_factor

The constant is being added to the bool, and that (integer) value is bitwise-anded with the other values, which looks like a mess.

I think what is implied is actually this:

@(microConstant + np.where(df.ebike_owner, 0, microRentTime + df.micro_access_inb + df.micro_access_out))*df.time_factor

@dhensle can you check?

dhensle commented 7 months ago

I suspect you are correct. Tagging @JoeJimFlood and @aletzdy for confirmation that the above fix is the desired behavior.

aletzdy commented 7 months ago

correct. this should be fixed. we can do the fix by replacing & with * as well, I believe. I will push an update to sandag repo after testing.