Skip to content

Commit

Permalink
Merge pull request #6 from aiplan4eu/add-solving-time
Browse files Browse the repository at this point in the history
Add internal time info
  • Loading branch information
Alee08 authored Nov 9, 2023
2 parents 98a837f + f755560 commit a61205f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion up_fmap/fmap_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Callable, Dict, IO, List, Optional, Set, Union, cast # type: ignore
from unified_planning.io.ma_pddl_writer import MAPDDLWriter # type: ignore
import tempfile
import time
import os
import subprocess
import sys
Expand Down Expand Up @@ -136,6 +137,7 @@ def _solve(
w.write_ma_domain(domain_filename)
w.write_ma_problem(problem_filename)
cmd = self._get_cmd_ma(problem, domain_filename, problem_filename)
start = time.time()
if output_stream is None:
# If we do not have an output stream to write to, we simply call
# a subprocess and retrieve the final output and error with communicate
Expand Down Expand Up @@ -177,6 +179,7 @@ def _solve(
cmd, output_stream=output_stream, timeout=timeout
)
timeout_occurred, (proc_out, proc_err), retval = exec_res
solving_time = time.time() - start

f = open(plan_filename, "a+")
pattern = re.compile(r"[Ee]rror|[Ee]xception")
Expand Down Expand Up @@ -207,14 +210,15 @@ def _solve(
return PlanGenerationResult(
PlanGenerationResultStatus.TIMEOUT,
plan=plan,
metrics={"engine_internal_time": str(solving_time)},
log_messages=logs,
engine_name=self.name,
)
status: PlanGenerationResultStatus = self._result_status(
problem, plan, retval, logs
)
return PlanGenerationResult(
status, plan, log_messages=logs, engine_name=self.name
status, plan, log_messages=logs, engine_name=self.name, metrics={"engine_internal_time": str(solving_time)}
)

def _plan_from_file(
Expand Down

0 comments on commit a61205f

Please sign in to comment.