|
| 1 | +from jupyddl.automated_planner import AutomatedPlanner |
| 2 | +import argparse |
| 3 | +import os |
| 4 | + |
| 5 | + |
| 6 | +def format_output(str): |
| 7 | + copy = str |
| 8 | + # Remove the [ and ] at both ends |
| 9 | + copy = copy[copy.index("[") + 1 : copy.index("]")] |
| 10 | + ret = "" |
| 11 | + numWords = 0 |
| 12 | + |
| 13 | + # count the number of words |
| 14 | + for i in range(0, len(str)): |
| 15 | + if str[i] == ",": |
| 16 | + numWords = numWords + 1 |
| 17 | + |
| 18 | + # tokenize |
| 19 | + for i in range(1, numWords - 1): |
| 20 | + try: |
| 21 | + new_str = copy[copy.index("<") + 1 : copy.index(">")] |
| 22 | + copy = copy[copy.index(">") + 1 :] |
| 23 | + new_str = new_str[new_str.index(" ") + 1 :] |
| 24 | + ret = ret + new_str + "\n" |
| 25 | + |
| 26 | + except ValueError as e: |
| 27 | + pass |
| 28 | + |
| 29 | + print(ret) |
| 30 | + |
| 31 | + |
| 32 | +def main(): |
| 33 | + args_parser = argparse.ArgumentParser( |
| 34 | + description="Start parsing Domain and Problem files with PDDL.jl using Python" |
| 35 | + ) |
| 36 | + args_parser.add_argument |
| 37 | + args_parser.add_argument("domain", type=str, help="PDDL domain file") |
| 38 | + args_parser.add_argument("problem", type=str, help="PDDL problem file") |
| 39 | + args_parser.add_argument("-v", "--verbose", help="Increases the output's verbosity") |
| 40 | + args = args_parser.parse_args() |
| 41 | + apla_tbx = AutomatedPlanner(args.domain, args.problem) |
| 42 | + apla_tbx.logger.info("Starting the planning script") |
| 43 | + apla_tbx.logger.debug( |
| 44 | + "Available heuristics: " + str(apla_tbx.available_heuristics.keys()) |
| 45 | + ) |
| 46 | + |
| 47 | + path, computation_time = apla_tbx.dijktra_best_first_search(time_it=True) |
| 48 | + apla_tbx.logger.debug(apla_tbx.get_actions_from_path(path)) |
| 49 | + |
| 50 | + apla_tbx.logger.debug("Computation time: %.2f seconds" % computation_time) |
| 51 | + apla_tbx.logger.info("Terminate with grace...") |
| 52 | + |
| 53 | + |
| 54 | +if __name__ == "__main__": |
| 55 | + main() |
0 commit comments