Skip to content

Commit

Permalink
Fixed some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Framba-Luca committed Oct 18, 2023
1 parent b99cec3 commit e1f890a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions unified_planning/engines/compilers/grounder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions up_benchmarks/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions up_benchmarks/test_cases/numeric/simple_linear_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
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))

a1 = InstantaneousAction("a1")
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)))
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion up_benchmarks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -148,6 +148,8 @@ def get_report_parser() -> argparse.ArgumentParser:
)

parser.add_argument(
"-p",
"--prefix",
"--prefixes",
type=str,
nargs="+",
Expand All @@ -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="+",
Expand All @@ -167,6 +170,7 @@ def get_report_parser() -> argparse.ArgumentParser:
default=[],
)
mutually_exclusive.add_argument(
"--pkgs",
"--packages",
type=str,
nargs="+",
Expand All @@ -176,6 +180,7 @@ def get_report_parser() -> argparse.ArgumentParser:
)

parser.add_argument(
"-m",
"--mode",
"--modes",
type=str,
Expand All @@ -187,6 +192,7 @@ def get_report_parser() -> argparse.ArgumentParser:
)

parser.add_argument(
"-t",
"--timeout",
type=float,
dest="timeout",
Expand Down

0 comments on commit e1f890a

Please sign in to comment.