From 58171a536577655c0996f2ca84e392cf3c70c470 Mon Sep 17 00:00:00 2001 From: Luca Framba Date: Mon, 23 Oct 2023 11:52:10 +0200 Subject: [PATCH 1/2] Fix(command-line): Now when using just the up command it's equal to up -h (instead of NotImplementedError); Added-check(ActionInstance): Added check where the actual parameters of an ActionInstance must be constants --- unified_planning/cmd/up.py | 2 +- unified_planning/plans/plan.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/unified_planning/cmd/up.py b/unified_planning/cmd/up.py index 0f9bb6f1a..c1b92dc18 100644 --- a/unified_planning/cmd/up.py +++ b/unified_planning/cmd/up.py @@ -48,7 +48,7 @@ def main(args=None): show_supported_kind=parsed_args.show_kind, ) else: - raise NotImplementedError + parser.print_help() def oneshot_planning( diff --git a/unified_planning/plans/plan.py b/unified_planning/plans/plan.py index 03263aa97..bc2226771 100644 --- a/unified_planning/plans/plan.py +++ b/unified_planning/plans/plan.py @@ -49,13 +49,17 @@ def __init__( ), "Typing not respected" self._agent = agent self._action = action - self._params = tuple(auto_promote(params)) + self._params: Tuple["up.model.FNode", ...] = tuple(auto_promote(params)) assert len(action.parameters) == len(self._params) for param, assigned_value in zip(action.parameters, self._params): if not param.type.is_compatible(assigned_value.type): raise UPTypeError( f"Incompatible parameter type assignment. {assigned_value} can't be assigned to: {param}" ) + if not assigned_value.is_constant(): + raise UPTypeError( + f"An ActionInstance parameter must be a constant: {assigned_value} is not." + ) assert motion_paths is None or isinstance( motion_paths, dict ), "Typing not respected" From ef69564e7146f95c6446231cde04a5dbbf790f26 Mon Sep 17 00:00:00 2001 From: Luca Framba Date: Mon, 23 Oct 2023 15:57:45 +0200 Subject: [PATCH 2/2] Fixed PDDLWriter on PlanLength --- unified_planning/io/pddl_writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified_planning/io/pddl_writer.py b/unified_planning/io/pddl_writer.py index ddce37993..cee54b97d 100644 --- a/unified_planning/io/pddl_writer.py +++ b/unified_planning/io/pddl_writer.py @@ -685,7 +685,7 @@ def _write_problem(self, out: IO[str]): pass else: out.write(f" (= {converter.convert(f)} {converter.convert(v)})") - if self.problem.kind.has_actions_cost(): + if self.problem.kind.has_actions_cost() or self.problem.kind.has_plan_length(): out.write(f" (= (total-cost) 0)") out.write(")\n") goals_str: List[str] = []