Ejemplo n.º 1
0
    def __init__(
        self,
        domain,
        problem,
        benchmarks_dir="",
        domain_file=None,
        problem_file=None,
        properties=None,
    ):
        """
        *domain* and *problem* are the display names of the domain and
        problem, *domain_file* and *problem_file* are paths to the
        respective files on the disk. If the latter are not specified,
        they will be automatically generated according to the following
        naming conventions: both files are searched in the directory
        *benchmarks_dir*/*domain*. The default filename of the problem
        is *problem* and the domain file is searched for under the
        names 'domain.pddl', 'pXX-domain.pddl', or the full problem
        name preceeded by 'domain_'.

        *properties* may be a dictionary of entries that should be
        added to the properties file of each run that uses this
        problem. ::

            suite = [
                Problem('gripper-original', 'prob01.pddl',
                    domain_file='/path/to/original/domain.pddl',
                    problem_file='/path/to/original/problem.pddl',
                    properties={'relaxed': False}),
                Problem('gripper-relaxed', 'prob01.pddl',
                    domain_file='/path/to/relaxed/domain.pddl',
                    problem_file='/path/to/relaxed/problem.pddl',
                    properties={'relaxed': True}),
                Problem('gripper', 'prob01.pddl',
                    benchmarks_dir='/path/to/benchmarks',
            ]
        """
        self.domain = domain
        self.problem = problem

        self.domain_file = domain_file
        if self.domain_file is None:
            domain_basenames = [
                "domain.pddl",
                self.problem[:3] + "-domain.pddl",
                "domain_" + self.problem,
                "domain-" + self.problem,
            ]
            domain_dir = os.path.join(benchmarks_dir, self.domain)
            self.domain_file = tools.find_file(domain_basenames, domain_dir)

        self.problem_file = problem_file or os.path.join(
            benchmarks_dir, self.domain, self.problem)

        self.properties = properties or {}
        self.properties.setdefault("domain", self.domain)
        self.properties.setdefault("problem", self.problem)
Ejemplo n.º 2
0
 def domain_file(self):
     domain_basenames = [
         'domain.pddl',
         self.problem[:4] + 'domain.pddl',
         self.problem[:3] + '-domain.pddl',
         'domain_' + self.problem,
         'domain-' + self.problem,
         self.problem.replace('problem.pddl', 'domain.pddl'),
     ]
     domain_dir = os.path.join(self.benchmarks_dir, self.domain)
     return tools.find_file(domain_basenames, domain_dir)
Ejemplo n.º 3
0
def find_domain_file(benchmarks_dir, domain, problem):
    """
    Search for domain file in the directory *benchmarks_dir*/*domain*.
    Check the following names: 'domain.pddl', 'pXX-domain.pddl', or the
    full problem name preceeded by 'domain_'.
    """
    domain_basenames = [
        "domain.pddl",
        problem[:3] + "-domain.pddl",
        "domain_" + problem,
        "domain-" + problem,
    ]
    domain_dir = os.path.join(benchmarks_dir, domain)
    return tools.find_file(domain_basenames, domain_dir)
Ejemplo n.º 4
0
def find_domain_file(benchmarks_dir, domain, problem):
    """Search for domain file in the directory *benchmarks_dir*/*domain*.

    For a given problem filename "<taskname>.<ext>", check the following
    domain filenames: "domain.pddl", "<taskname>-domain.<ext>",
    "domain_<taskname>.<ext>" and "domain-<taskname>.<ext>", where
    ".<ext>" is optional. Also check "<xyz>-domain.pddl" where <xyz> are
    the first three characters of the task file name, to cover the airport
    and psr-small domains, where problem file names are p01-xxx.pddl and
    domain file names are p01-domain.pddl.
    """
    problem_root, ext = os.path.splitext(problem)
    domain_basenames = [
        "domain.pddl",
        problem_root + "-domain" + ext,
        problem_root[:3] + "-domain.pddl",  # for airport and psr-small
        "domain_" + problem,
        "domain-" + problem,
    ]
    domain_dir = os.path.join(benchmarks_dir, domain)
    return tools.find_file(domain_basenames, domain_dir)