Skip to content

Commit

Permalink
Changed Repairer plan_to_file logic to manage TimeTriggeredPlan
Browse files Browse the repository at this point in the history
  • Loading branch information
ale-gaudenzi committed Nov 7, 2023
1 parent 8fdcfc0 commit 5ba37e1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions up_lpg/lpg_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,20 @@ def _repair(self, problem: AbstractProblem, plan: Plan) -> PlanGenerationResult:

def plan_to_file(self, plan: Plan, out: IO[str]):
with open(out, "w") as f:
for i, act in enumerate(plan.actions):
parameters = str(act.actual_parameters).replace('(','').replace(')','').replace(',','')
for i, act in enumerate(plan._actions):
if(plan.kind == PlanKind.TIME_TRIGGERED_PLAN):
start = act[0]
duration = act[2]
action = act[1].action.name
else:
start = i
duration = 1
action = act.action.name
parameters = str(action).replace('(','').replace(')','').replace(',','')
if parameters == '':
f.write(f'{i}: ({act.action.name}) [1]\n')
f.write(f'{start}: ({action}) [{duration}]\n')
else:
f.write(f'{i}: ({act.action.name} {parameters}) [1]\n')
f.write(f'{start}: ({action} {parameters}) [{duration}]\n')

@staticmethod
def supports_plan(plan_kind: "up.plans.PlanKind") -> bool:
Expand Down

0 comments on commit 5ba37e1

Please sign in to comment.