def pddl_from_expression(expression): if isinstance(expression, Object) or isinstance(expression, OptimisticObject): return pddl_from_object(expression) if isinstance(expression, str): return expression return '({})'.format(' '.join(map(pddl_from_expression, expression)))
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)
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)
def enforce_single_binding(result, preconditions, effects): binding_facts = [(BOUND_PREDICATE, pddl_from_object(out)) for out in result.output_objects] preconditions.extend(Not(fact) for fact in binding_facts) effects.extend(fact for fact in binding_facts)