Skip to content

Commit

Permalink
Added extra_engine_info in the result
Browse files Browse the repository at this point in the history
  • Loading branch information
alvalentini committed Nov 7, 2023
1 parent 3d9d2af commit d4bf98a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 27 deletions.
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
"tamer": ["up-tamer==1.0.0.4.dev1"],
"enhsp": ["up-enhsp==0.0.21"],
"fast-downward": ["up-fast-downward==0.3.1"],
"lpg": ["up-lpg==0.0.7"],
"lpg": ["up-lpg==0.0.7.5"],
"fmap": ["up-fmap==0.0.9"],
"aries": ["up-aries>=0.2.0"],
"aries": ["up-aries>=0.2.1"],
"symk": ["up-symk>=1.0.1"],
"engines": [
"tarski[arithmetic]",
"up-pyperplan==1.0.0.4.dev1",
"up-tamer==1.0.0.4.dev1",
"up-enhsp==0.0.21",
"up-fast-downward==0.3.1",
"up-lpg==0.0.7",
"up-lpg==0.0.7.5",
"up-fmap==0.0.9",
"up-aries>=0.2.0",
"up-aries>=0.2.1",
"up-symk>=1.0.1",
],
"plot": [
Expand Down
1 change: 1 addition & 0 deletions unified_planning/engines/oversubscription_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def _solve(
self.name,
metrics=res.metrics,
log_messages=res.log_messages,
extra_engine_info=res.extra_engine_info,
)
elif res.status == PlanGenerationResultStatus.TIMEOUT:
return PlanGenerationResult(
Expand Down
1 change: 1 addition & 0 deletions unified_planning/engines/pddl_anytime_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def _generate_last_result(
solve_result.engine_name,
solve_result.metrics,
solve_result.log_messages,
solve_result.extra_engine_info,
)
return res

Expand Down
12 changes: 8 additions & 4 deletions unified_planning/engines/pddl_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,25 @@ def _solve(
plan = self._plan_from_file(
problem, plan_filename, self._writer.get_item_named
)
metrics = {}
metrics["pddl_planner_subprocess_time"] = str(process_end - process_start)
extra_engine_info = {}
extra_engine_info["internal_time"] = str(process_end - process_start)
if timeout_occurred and retval != 0:
return PlanGenerationResult(
PlanGenerationResultStatus.TIMEOUT,
plan=plan,
engine_name=self.name,
metrics=metrics,
log_messages=logs,
extra_engine_info=extra_engine_info,
)
status: PlanGenerationResultStatus = self._result_status(
problem, plan, retval, logs
)
res = PlanGenerationResult(
status, plan, engine_name=self.name, metrics=metrics, log_messages=logs
status,
plan,
engine_name=self.name,
log_messages=logs,
extra_engine_info=extra_engine_info,
)
problem_kind = problem.kind
if problem_kind.has_continuous_time() or problem_kind.has_discrete_time():
Expand Down
6 changes: 6 additions & 0 deletions unified_planning/engines/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class PlanGenerationResult(Result):
engine_name: str
metrics: Optional[Dict[str, str]] = field(default=None)
log_messages: Optional[List[LogMessage]] = field(default=None)
extra_engine_info: Optional[Dict[str, str]] = field(default=None)

def __post__init(self):
# Checks that plan and status are consistent
Expand Down Expand Up @@ -235,6 +236,7 @@ def correct_plan_generation_result(
result.engine_name,
result.metrics,
result.log_messages,
result.extra_engine_info,
)
elif problem.epsilon is None or (
engine_epsilon is not None and problem.epsilon < engine_epsilon
Expand All @@ -250,6 +252,7 @@ def correct_plan_generation_result(
result.engine_name,
result.metrics,
result.log_messages,
result.extra_engine_info,
)
elif result.status == PlanGenerationResultStatus.SOLVED_OPTIMALLY:
return PlanGenerationResult(
Expand All @@ -258,6 +261,7 @@ def correct_plan_generation_result(
result.engine_name,
result.metrics,
result.log_messages,
result.extra_engine_info,
)
return result

Expand All @@ -274,6 +278,7 @@ class ValidationResult(Result):
)
reason: Optional[FailedValidationReason] = field(default=None)
inapplicable_action: Optional[up.plans.ActionInstance] = field(default=None)
extra_engine_info: Optional[Dict[str, str]] = field(default=None)

def __post_init__(self):
assert (
Expand Down Expand Up @@ -313,6 +318,7 @@ class CompilerResult(Result):
]
engine_name: str
log_messages: Optional[List[LogMessage]] = field(default=None)
extra_engine_info: Optional[Dict[str, str]] = field(default=None)

def _post_init(self):
# Check that compiled problem and map_back_action_instance are consistent with each other
Expand Down
38 changes: 19 additions & 19 deletions up_test_cases/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@ def report_oneshot(
if not outcome.ok():
errors.append((planner_id, name))
total_execution_time = end - start
subprocess_time_str = None
if result.metrics is not None:
subprocess_time_str = result.metrics.get(
"pddl_planner_subprocess_time", None
internal_time_str = None
if result.extra_engine_info is not None:
internal_time_str = result.extra_engine_info.get(
"internal_time", None
)
if subprocess_time_str is not None:
subprocess_time = float(subprocess_time_str)
# overhead_percentage = 1-subprocess_time/total_execution_time
if internal_time_str is not None:
internal_time = float(internal_time_str)
# overhead_percentage = 1-internal_time/total_execution_time
overhead_percentage = (
total_execution_time - subprocess_time
) / subprocess_time
total_execution_time - internal_time
) / internal_time
runtime_report = "{:.3f}s({:.3%})".format(
total_execution_time, overhead_percentage
).ljust(15)
Expand Down Expand Up @@ -394,18 +394,18 @@ def report_anytime(
test_case, metrics_evaluations
)
total_execution_time = end - start
subprocess_time_str = None
if result.metrics is not None:
subprocess_time_str = result.metrics.get(
"pddl_planner_subprocess_time", None
internal_time_str = None
if result.extra_engine_info is not None:
internal_time_str = result.extra_engine_info.get(
"internal_time", None
)
if subprocess_time_str is not None:
subprocess_time = float(subprocess_time_str)
# overhead_percentage = 1-subprocess_time/total_execution_time
if internal_time_str is not None:
internal_time = float(internal_time_str)
# overhead_percentage = 1-internal_time/total_execution_time
overhead_percentage = (
total_execution_time - subprocess_time
) / subprocess_time
runtime_report = "{:.3f}s({:.3%})".format(
total_execution_time - internal_time
) / internal_time
runtime_report = "{:.3f}s({:.0%})".format(
total_execution_time, overhead_percentage
).ljust(15)
else:
Expand Down

0 comments on commit d4bf98a

Please sign in to comment.