Skip to content

Commit

Permalink
Merge pull request #20 from ale-gaudenzi/master
Browse files Browse the repository at this point in the history
Changed Repairer plan_to_file logic to manage TimeTriggeredPlan
  • Loading branch information
serivan authored Nov 7, 2023
2 parents 7319ef0 + 5ba37e1 commit 3f9b262
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 3f9b262

Please sign in to comment.