Beispiel #1
0
def run_fastdownard(planner, max_time, max_cost, verbose):
    if isinstance(max_time, float):
        max_time = int(max_time)
    if max_cost == INF:
        max_cost = 'infinity'
    elif isinstance(max_cost, float):
        max_cost = int(max_cost)
    safe_remove(SEARCH_OUTPUT)
    run_translate(verbose)
    return run_search(planner, max_time, max_cost, verbose)
Beispiel #2
0
def fast_downward(universe, planner, max_time, max_cost, remove, verbose):
  ensure_dir(TEMP_DIRECTORY)
  #print universe.domain_pddl(True, True)
  #print universe.problem_pddl(True)
  write(DOMAIN_PATH, universe.domain_pddl(True, True))
  write(PROBLEM_PATH, universe.problem_pddl(True))
  #solution = solve_pddl(DOMAIN_PATH, PROBLEM_PATH, planner, max_time, max_cost)
  solution = run_fastdownard(planner, max_time, max_cost, verbose)
  if solution is None:
    return None
  if remove:
    remove_dir(TEMP_DIRECTORY)
    safe_remove(TRANSLATE_OUTPUT)
    safe_remove(SEARCH_OUTPUT)
  return convert_solution(solution, universe)
Beispiel #3
0
def run_search(planner, max_time, max_cost, verbose):
  fd_root = get_fd_root()
  search = os.path.join(fd_root, FD_BIN, SEARCH_COMMAND) + TRANSLATE_OUTPUT #+ ' --search-time-limit %s'%10 # TODO - limit
  planner_config = search_options[planner]%(max_time, max_cost)
  command = search%planner_config

  safe_remove(SEARCH_OUTPUT)
  t0 = time()
  p = os.popen(command) # NOTE - cannot pipe input easily with subprocess
  output = p.read()
  if verbose:
    print
    print output
    print command, time() - t0
  if not os.path.exists(SEARCH_OUTPUT):
    return None
  return read(SEARCH_OUTPUT)
Beispiel #4
0
def lapkt(universe, search, verbose):
    ensure_dir(TEMP_DIRECTORY)
    write(DOMAIN_PATH, universe.domain_pddl(True, False))
    write(PROBLEM_PATH, universe.problem_pddl(True))
    safe_remove(PLANNER_OUTPUT)

    planner_path = os.path.join(get_lapkt_root(), LAPKT_PLANNERS[search])
    command = planner_path + \
        COMMAND % (DOMAIN_PATH, PROBLEM_PATH, PLANNER_OUTPUT)
    if verbose:
        print command
    p = os.popen(command)
    output = p.read()
    if verbose:
        print output

    SUCCESS = 'Plan found'
    if output.find(SUCCESS) == -1:
        return None
    plan = []
    for line in read(PLANNER_OUTPUT).split('\n')[:-1]:
        entries = line.strip('()').lower().split(' ')
        plan.append(lookup_action(universe, entries[0], entries[1:]))
    if not verbose:
        remove_dir(TEMP_DIRECTORY)
        safe_remove(PLANNER_OUTPUT)
        safe_remove(PLANNER_DETAILS)
    return plan