def task_from_domain_problem(domain, problem, add_identical=True): # TODO: prune evaluation that aren't needed in actions #domain_name, domain_requirements, types, type_dict, constants, \ # predicates, predicate_dict, functions, actions, axioms = domain task_name, task_domain_name, task_requirements, objects, init, goal, use_metric, problem_pddl = problem assert domain.name == task_domain_name requirements = pddl.Requirements( sorted( set(domain.requirements.requirements + task_requirements.requirements))) objects = domain.constants + objects check_for_duplicates( [o.name for o in objects], errmsg="error: duplicate object %r", finalmsg="please check :constants and :objects definitions") init.extend(pddl.Atom(EQ, (obj.name, obj.name)) for obj in objects) if add_identical: init.extend(get_identical_atoms(objects)) #print('{} objects and {} atoms'.format(len(objects), len(init))) task = pddl.Task(domain.name, task_name, requirements, domain.types, objects, domain.predicates, domain.functions, init, goal, domain.actions, domain.axioms, use_metric) normalize.normalize(task) # task.add_axiom return task
def task_from_domain_problem(domain, problem): # TODO: prune evaluation that aren't needed in actions #domain_name, domain_requirements, types, type_dict, constants, \ # predicates, predicate_dict, functions, actions, axioms = domain task_name, task_domain_name, task_requirements, objects, init, goal, use_metric, problem_pddl = problem assert domain.name == task_domain_name requirements = pddl.Requirements( sorted( set(domain.requirements.requirements + task_requirements.requirements))) objects = domain.constants + objects check_for_duplicates( [o.name for o in objects], errmsg="error: duplicate object %r", finalmsg="please check :constants and :objects definitions") init.extend(pddl.Atom(EQ, (obj.name, obj.name)) for obj in objects) # TODO: optimistically evaluate (not (= ?o1 ?o2)) for fd_obj in objects: obj = obj_from_pddl(fd_obj.name) if obj.is_unique(): init.append(pddl.Atom(IDENTICAL, (fd_obj.name, fd_obj.name))) else: assert obj.is_shared() task = pddl.Task(domain.name, task_name, requirements, domain.types, objects, domain.predicates, domain.functions, init, goal, domain.actions, domain.axioms, use_metric) normalize.normalize(task) # task.add_axiom return task
def task_from_domain_problem(domain, problem): # TODO: prune eval domain_name, domain_requirements, types, type_dict, constants, \ predicates, predicate_dict, functions, actions, axioms = domain task_name, task_domain_name, task_requirements, objects, init, goal, use_metric = problem assert domain_name == task_domain_name requirements = pddl.Requirements(sorted(set(domain_requirements.requirements + task_requirements.requirements))) objects = constants + objects check_for_duplicates([o.name for o in objects], errmsg="error: duplicate object %r", finalmsg="please check :constants and :objects definitions") init.extend(pddl.Atom(EQ, (obj.name, obj.name)) for obj in objects) task = pddl.Task(domain_name, task_name, requirements, types, objects, predicates, functions, init, goal, actions, axioms, use_metric) normalize.normalize(task) return task