def solve_finite(evaluations, goal_exp, domain, unit_costs=False, debug=False, **search_args): problem = get_problem(evaluations, goal_exp, domain, unit_costs) task = task_from_domain_problem(domain, problem) sas_task = sas_from_pddl(task, debug=debug) pddl_plan, cost = abstrips_solve_from_task(sas_task, debug=debug, **search_args) plan = obj_from_pddl_plan(pddl_plan) return plan, cost
def solve_finite(evaluations, goal_expression, domain, unit_costs=None, debug=False, **kwargs): if unit_costs is None: unit_costs = not has_costs(domain) problem = get_problem(evaluations, goal_expression, domain, unit_costs) task = task_from_domain_problem(domain, problem) sas_task = sas_from_pddl(task, debug=debug) plan_pddl, cost = abstrips_solve_from_task(sas_task, debug=debug, **kwargs) return obj_from_pddl_plan(plan_pddl), cost
def solve_sequential(evaluations, goal_exp, domain, unit_costs=False, debug=False, **search_args): problem = get_problem(evaluations, goal_exp, domain, unit_costs) task = task_from_domain_problem(domain, problem) if has_attachments(domain): with Verbose(debug): instantiated = instantiate_task(task) return solve_pyplanners(instantiated, **search_args) sas_task = sas_from_pddl(task, debug=debug) return abstrips_solve_from_task(sas_task, debug=debug, **search_args)
def solve_finite(evaluations, goal_exp, domain, unit_costs=False, debug=False, **search_args): if isinstance(domain, SimplifiedDomain): problem = get_problem_pddl(evaluations, goal_exp, domain.pddl) pddl_plan, cost = solve_tfd(domain.pddl, problem, debug=debug) else: problem = get_problem(evaluations, goal_exp, domain, unit_costs) task = task_from_domain_problem(domain, problem) if has_attachments(domain): with Verbose(debug): instantiated = instantiate_task(task) pddl_plan, cost = solve_pyplanners(instantiated, **search_args) else: sas_task = sas_from_pddl(task, debug=debug) pddl_plan, cost = abstrips_solve_from_task(sas_task, debug=debug, **search_args) plan = obj_from_pddl_plan(pddl_plan) return plan, cost
def solve_finite(evaluations, goal_exp, domain, unit_costs=False, debug=False, **search_args): if isinstance(domain, SimplifiedDomain): problem = get_problem_pddl(evaluations, goal_exp, domain.pddl) pddl_plan, cost = solve_tfd(domain.pddl, problem, debug=debug) else: task = task_from_domain_problem( domain, get_problem(evaluations, goal_exp, domain, unit_costs)) sas_task = sas_from_pddl(task, debug=debug) pddl_plan, cost = abstrips_solve_from_task(sas_task, debug=debug, **search_args) plan = obj_from_pddl_plan(pddl_plan) return plan, cost
def relaxed_stream_plan(evaluations, goal_expression, domain, stream_results, negative, unit_costs, unit_efforts, effort_weight, debug=False, **kwargs): # TODO: alternatively could translate with stream actions on real opt_state and just discard them # TODO: only consider axioms that have stream conditions? applied_results, deferred_results = partition_results(evaluations, stream_results, apply_now=lambda r: not r.external.info.simultaneous) stream_domain, result_from_name = add_stream_actions(domain, deferred_results) node_from_atom = get_achieving_streams(evaluations, applied_results) opt_evaluations = apply_streams(evaluations, applied_results) # if n.effort < INF if any(map(is_optimizer_result, stream_results)): goal_expression = augment_goal(stream_domain, goal_expression) problem = get_problem(opt_evaluations, goal_expression, stream_domain, unit_costs) # begin_metric with Verbose(debug): instantiated = instantiate_task(task_from_domain_problem(stream_domain, problem)) if instantiated is None: return None, INF if (effort_weight is not None) or any(map(is_optimizer_result, applied_results)): add_stream_costs(node_from_atom, instantiated, unit_efforts, effort_weight) add_optimizer_axioms(stream_results, instantiated) with Verbose(debug): sas_task = sas_from_instantiated(instantiated) sas_task.metric = True #sas_task = sas_from_pddl(task) #action_plan, _ = serialized_solve_from_task(sas_task, debug=debug, **kwargs) action_plan, _ = abstrips_solve_from_task(sas_task, debug=debug, **kwargs) #action_plan, _ = abstrips_solve_from_task_sequential(sas_task, debug=debug, **kwargs) if action_plan is None: return None, INF applied_plan, function_plan = partition_external_plan(recover_stream_plan( evaluations, goal_expression, stream_domain, applied_results, action_plan, negative, unit_costs)) deferred_plan, action_plan = partition_plan(action_plan, result_from_name) stream_plan = applied_plan + deferred_plan + function_plan action_plan = obj_from_pddl_plan(action_plan) cost = get_plan_cost(opt_evaluations, action_plan, domain, unit_costs) combined_plan = stream_plan + action_plan return combined_plan, cost
def sequential_stream_plan(evaluations, goal_expression, domain, stream_results, negated, effort_weight, unit_costs=True, debug=False, **kwargs): # Intuitively, actions have infinitely more weight than streams if negated: raise NotImplementedError(negated) for result in stream_results: if isinstance(result.external, Stream) and result.external.is_fluent(): raise NotImplementedError('Fluents are not supported') # TODO: compute preimage and make that the goal instead opt_evaluations = evaluations_from_stream_plan(evaluations, stream_results) opt_task = task_from_domain_problem(domain, get_problem(opt_evaluations, goal_expression, domain, unit_costs)) action_plan, action_cost = abstrips_solve_from_task(sas_from_pddl(opt_task, debug=debug), debug=debug, **kwargs) if action_plan is None: return None, action_cost actions = domain.actions[:] domain.actions[:] = [] stream_domain, stream_result_from_name = add_stream_actions(domain, stream_results) # TODO: effort_weight domain.actions.extend(actions) stream_task = task_from_domain_problem(stream_domain, get_problem(evaluations, goal_expression, stream_domain, unit_costs)) action_from_name, function_plan = simplify_actions(opt_evaluations, action_plan, stream_task, actions, unit_costs) # TODO: lmcut? combined_plan, _ = solve_from_task(sas_from_pddl(opt_task, debug=debug), planner=kwargs.get('planner', 'ff-astar'), debug=debug, **kwargs) if combined_plan is None: return None, INF stream_plan, action_plan = [], [] for name, args in combined_plan: if name in stream_result_from_name: stream_plan.append(stream_result_from_name[name]) else: action_plan.append(action_from_name[name]) combined_plan = stream_plan + function_plan + action_plan return combined_plan, action_cost