コード例 #1
0
def get_problem(evaluations, goal_exp, domain, unit_costs=False):
    objects = objects_from_evaluations(evaluations)
    typed_objects = list(
        {make_object(pddl_from_object(obj))
         for obj in objects} - set(domain.constants))
    # TODO: this doesn't include =
    init = [
        fd_from_evaluation(e) for e in evaluations if not is_negated_atom(e)
    ]
    goal = pddl.Truth() if goal_exp is None else parse_goal(goal_exp, domain)
    problem_pddl = None
    if USE_FORBID:
        problem_pddl = get_problem_pddl(evaluations,
                                        goal_exp,
                                        domain.pddl,
                                        temporal=False)
    write_pddl(domain.pddl, problem_pddl)
    return Problem(task_name=domain.name,
                   task_domain_name=domain.name,
                   objects=sorted(typed_objects, key=lambda o: o.name),
                   task_requirements=pddl.tasks.Requirements([]),
                   init=init,
                   goal=goal,
                   use_metric=not unit_costs,
                   pddl=problem_pddl)
コード例 #2
0
def get_problem(init_evaluations, goal_expression, domain, unit_costs=False):
    objects = objects_from_evaluations(init_evaluations)
    typed_objects = list({pddl.TypedObject(pddl_from_object(obj), OBJECT) for obj in objects} - set(domain.constants))
    # TODO: this doesn't include =
    init = [fd_from_evaluation(e) for e in init_evaluations if not is_negated_atom(e)]
    goal = parse_goal(goal_expression, domain)
    return Problem(task_name=domain.name, task_domain_name=domain.name, objects=sorted(typed_objects, key=lambda o: o.name),
                   task_requirements=pddl.tasks.Requirements([]), init=init, goal=goal, use_metric=not unit_costs)
コード例 #3
0
def get_problem(init_evaluations, goal_expression, domain, unit_costs):
    objects = map(pddl_from_object, objects_from_evaluations(init_evaluations))
    typed_objects = list({pddl.TypedObject(obj, OBJECT)
                          for obj in objects} - set(domain.constants))
    init = get_init(init_evaluations)
    goal = parse_condition(pddl_list_from_expression(goal_expression),
                           domain.type_dict, domain.predicate_dict)
    return Problem(task_name=domain.name,
                   task_domain_name=domain.name,
                   objects=typed_objects,
                   task_requirements=pddl.tasks.Requirements([]),
                   init=init,
                   goal=goal,
                   use_metric=not unit_costs)
コード例 #4
0
def pddl_problem(problem,
                 domain,
                 evaluations,
                 goal_expression,
                 objective=None):
    objects = objects_from_evaluations(evaluations)
    s = '(define (problem {})\n' \
           '\t(:domain {})\n' \
           '\t(:objects {})\n' \
           '\t(:init \n\t\t{})\n' \
           '\t(:goal {})'.format(
        problem, domain,
        ' '.join(sorted(map(pddl_from_object, objects))), # map(pddl_parameter,
        '\n\t\t'.join(sorted(filter(lambda p: p is not None,
                                    map(pddl_from_evaluation, evaluations)))),
        pddl_from_expression(goal_expression))
    if objective is not None:
        s += '\n\t(:metric minimize ({}))'.format(objective)
    return s + ')\n'