diff --git a/unified_planning/engines/compilers/grounder.py b/unified_planning/engines/compilers/grounder.py index 9f860c371..df807fab6 100644 --- a/unified_planning/engines/compilers/grounder.py +++ b/unified_planning/engines/compilers/grounder.py @@ -76,6 +76,12 @@ def __init__( assert isinstance(problem, Problem) self._problem = problem self._grounding_actions_map = grounding_actions_map + if grounding_actions_map is not None: + for action, params_list in grounding_actions_map.items(): + for params in params_list: + assert len(action.parameters) == len( + params + ), f"Action {action.name} has {len(action.parameters)} parameters but {len(params)} are given in the map.\n{action.parameters}\n{params}" # grounded_actions is a map from an Action of the original problem and it's parameters # to the grounded instance of the Action with the given parameters. # When the grounded instance of the Action is None, it means that the resulting grounding diff --git a/up_benchmarks/report.py b/up_benchmarks/report.py index cd4eacf31..36d8db393 100644 --- a/up_benchmarks/report.py +++ b/up_benchmarks/report.py @@ -148,10 +148,12 @@ def check_result( PlanGenerationResultStatus.MEMOUT, PlanGenerationResultStatus.UNSUPPORTED_PROBLEM, PlanGenerationResultStatus.UNSOLVABLE_INCOMPLETELY, + PlanGenerationResultStatus.INTERMEDIATE, + PlanGenerationResultStatus.UNSOLVABLE_PROVEN, ), - "invalid status", + f"error status: {result.status.name}", ) - output += Warn(f"Unsolved ({result.status.name})") + output += Warn(f"Solvable problem, returned {result.status.name}") else: output += verify( result.status @@ -435,8 +437,12 @@ def applicable_validators(pb, plan): print() print(f"{name} invalid[{i}]".ljust(40), end="\n") print("| ", validator.name.ljust(40), end="") + start = time.time() result = validator.validate(test_case.problem, invalid_plan) + end = time.time() print(str(result.status.name).ljust(25), end=" ") + runtime = "{:.3f}s".format(end - start).ljust(10) + print(runtime, end="") if result.status == ValidationResultStatus.INVALID: print(Ok("Invalid")) else: @@ -446,7 +452,7 @@ def applicable_validators(pb, plan): problems_skipped.append(f"{name} invalid[{i}]") if problems_skipped: - print("\n\Validation test cases skipped:") + print("\n\nValidation test cases skipped:") print(" ", "\n ".join(problems_skipped)) return errors diff --git a/up_benchmarks/test_cases/numeric/simple_linear_conditions.py b/up_benchmarks/test_cases/numeric/simple_linear_conditions.py index 1b95418bd..db34f7ea0 100644 --- a/up_benchmarks/test_cases/numeric/simple_linear_conditions.py +++ b/up_benchmarks/test_cases/numeric/simple_linear_conditions.py @@ -7,8 +7,8 @@ def get_test_cases(): res = {} - x = Fluent("x", RealType()) problem = Problem("GT_linear_conditions") + x = problem.add_fluent("x", RealType()) problem.set_initial_value(x, Fraction(51, 10)) problem.add_goal(GT(x, 10)) @@ -16,7 +16,6 @@ def get_test_cases(): a1.add_precondition(GT(x, Fraction(505, 100))) a1.add_effect(x, Plus(x, Fraction(509, 100))) - problem.add_fluent(x) problem.add_action(a1) # TODO add plans diff --git a/up_benchmarks/test_cases/numeric/simple_nonlinear_conditions.py b/up_benchmarks/test_cases/numeric/simple_nonlinear_conditions.py index 24279ec71..5a74e1ed8 100644 --- a/up_benchmarks/test_cases/numeric/simple_nonlinear_conditions.py +++ b/up_benchmarks/test_cases/numeric/simple_nonlinear_conditions.py @@ -7,9 +7,9 @@ def get_test_cases(): res = {} - x = Fluent("x", IntType()) - y = Fluent("y", IntType()) problem = Problem("simple_non_linear_GT_equality_conditions") + x = problem.add_fluent("x", IntType()) + y = problem.add_fluent("y", IntType()) problem.set_initial_value(x, 3) problem.set_initial_value(y, 2) problem.add_goal(Equals(Times(x, y), 24)) @@ -19,13 +19,14 @@ def get_test_cases(): a1.add_effect(x, 6) a1.add_effect(y, 4) - problem.add_fluent(x) problem.add_action(a1) # TODO add plans res[problem.name] = TestCase(problem=problem, solvable=True) problem = Problem("simple_non_linear_LE_Negative_conditions") + problem.add_fluent(x) + problem.add_fluent(y) problem.set_initial_value(x, 3) problem.set_initial_value(y, 2) problem.add_goal(Not(Equals(Times(x, y), 24))) @@ -36,7 +37,6 @@ def get_test_cases(): a1.add_effect(x, Plus(x, 3)) a1.add_effect(y, Plus(y, 2)) - problem.add_fluent(x) problem.add_action(a1) # TODO add plans diff --git a/up_benchmarks/utils.py b/up_benchmarks/utils.py index ebb6bf231..9ea1b2c7e 100644 --- a/up_benchmarks/utils.py +++ b/up_benchmarks/utils.py @@ -10,7 +10,7 @@ # Define the default timeout for anytime and oneshot -DEFAULT_TIMEOUT = 3 +DEFAULT_TIMEOUT = 3.0 def _get_test_cases(package_name: str) -> Dict[str, TestCase]: @@ -148,6 +148,8 @@ def get_report_parser() -> argparse.ArgumentParser: ) parser.add_argument( + "-p", + "--prefix", "--prefixes", type=str, nargs="+", @@ -159,6 +161,7 @@ def get_report_parser() -> argparse.ArgumentParser: mutually_exclusive = parser.add_mutually_exclusive_group() mutually_exclusive.add_argument( + "--e-pkgs", "--extra-packages", type=str, nargs="+", @@ -167,6 +170,7 @@ def get_report_parser() -> argparse.ArgumentParser: default=[], ) mutually_exclusive.add_argument( + "--pkgs", "--packages", type=str, nargs="+", @@ -176,6 +180,7 @@ def get_report_parser() -> argparse.ArgumentParser: ) parser.add_argument( + "-m", "--mode", "--modes", type=str, @@ -187,6 +192,7 @@ def get_report_parser() -> argparse.ArgumentParser: ) parser.add_argument( + "-t", "--timeout", type=float, dest="timeout",