arup-group/pam

Pam Fix Plans Crop functionality beyond the last leg/activity

Closed this issue · 0 comments

What happened?

Part bug, part clarification.

For the .fix_plans() method, is the intention to check only the last activity and remove the last leg? For example, the below sample test has two activities that extend beyond a day. The .crop() method will only address the last activity, but the day for the second activity will be 1900-01-09 08:20:00. This test will therefore fail against the second assertion.

from pam.activity import Activity, Leg, Plan
from pam.utils import minutes_to_datetime as mtdt
from pam.variables import END_OF_DAY

plan = Plan()
plan.add(Activity(seq=1, act="home", area="A", start_time=mtdt(0), end_time=mtdt(600)))
plan.add(
        Leg(
            seq=2,
            mode="car",
            start_area="A",
            end_area="B",
            start_time=mtdt(600),
            end_time=mtdt(12020),
        )
    )
plan.add(Activity(seq=3, act="work", area="B", start_time=mtdt(12020), end_time=mtdt(12030)))
plan.add(
        Leg(
            seq=2,
            mode="car",
            start_area="B",
            end_area="A",
            start_time=mtdt(12030),
            end_time=mtdt(12050),
        )
    )
plan.add(Activity(seq=1, act="home", area="A", start_time=mtdt(12050), end_time=mtdt(12060)))
plan.crop()
assert plan.day[-1].end_time == END_OF_DAY
assert plan.day[-2].end_time == END_OF_DAY

What this means is that we need to ensure that plans that are created only have a risk of the final activity/leg going beyond one day. Plans that are generated with several activities beyond a day may not be cropped accordingly. This is ok, so long as the user knows that they will need to generate agent plans accordingly.

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

Version

None

Relevant log output

<person id="HGV_68">
  <attributes>
    <attribute class="java.lang.String" name="subpopulation">hgv</attribute>
    <attribute class="java.lang.String" name="CarType">hgv</attribute>
    <attribute class="java.lang.String" name="CarCO2">hgv</attribute>
    <attribute class="java.lang.String" name="hid">HGV_68</attribute>
  </attributes>
  <plan selected="yes">
    <activity type="depot" start_time="00:00:00" end_time="21:47:00" x="422096.42270312115" y="396685.6815914132"/>
    <leg mode="car" trav_time="06:05:00"/>
    <activity type="delivery" start_time="27:52:00" end_time="28:52:00" x="622267.8180467577" y="311424.940147245"/>
    <leg mode="car" trav_time="03:45:00"/>
    <activity type="delivery" start_time="32:37:00" end_time="33:37:00" x="566435.718646235" y="189614.1775535666"/>
    <leg mode="car" trav_time="00:26:00"/>
    <activity type="delivery" start_time="34:03:00" end_time="24:00:00" x="557638.181561101" y="176695.84084380232"/>
  </plan>
</person>

391,HGV_68,HGV_68,,depot,1,1900-01-01 00:00:00,1900-01-01 21:47:00,21:47:00,30003
392,HGV_68,HGV_68,,delivery,2,1900-01-02 03:52:00,1900-01-02 04:52:00,1:00:00,60449
393,HGV_68,HGV_68,,delivery,3,1900-01-02 08:37:00,1900-01-02 09:37:00,1:00:00,60734
394,HGV_68,HGV_68,,delivery,4,1900-01-02 10:03:00,1900-01-02 00:00:00,"-1 day, 13:57:00",69997