Advertisement
froleyks

experiment.py<pipegrid>

Nov 20th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. import time
  2. from subprocess import getstatusoutput as cmd
  3.  
  4. # from encode import *
  5.  
  6.  
  7. def solve(pathToLevel):
  8.  
  9.     cmd("python encode.py " + pathToLevel + " > problem.pddl")
  10.     start_time = time.time()
  11.     cmd("./M -r 400 -Q domain.pddl problem.pddl > plan")
  12.     execution_time = time.time() - start_time
  13.     cmd("python plan2rotations.py plan")
  14.     res = cmd("python validate_rotations.py " + pathToLevel +
  15.               " plan-rotations")
  16.  
  17.     # print(res[1])
  18.     if execution_time > 399:
  19.         execution_time = -2
  20.     elif "plan is valid" not in res[1]:
  21.         execution_time = -1
  22.  
  23.     return execution_time
  24.  
  25.  
  26. # def is_st_fixed(pathToLevel):
  27. #     level = parseInput(pathToLevel)
  28. #     level = fix(level)
  29. #     flag = printFixed(level)
  30. #     return flag
  31.  
  32.  
  33. def main():
  34.     f = open("instances", "r")
  35.     all = True
  36.     for level in f:
  37.         level = level.strip()
  38.         print("| " + level + " | ", end="")
  39.         print(str(solve(level)) + " |")
  40.  
  41.     #     print()
  42.     #     if is_st_fixed(level):
  43.     #         print("X")
  44.     #     else:
  45.     #         all = False
  46.     #         print("O")
  47.     # if all:
  48.     #     print("jeah")
  49.     # else:
  50.     #     print("neig")
  51.  
  52.  
  53. if __name__ == '__main__':
  54.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement