batch_runner.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from runner import run_round
  2. # TODO - make multiple parameter values, for batch running
  3. # & build batch runner functionality
  4. # rounds_per_run =[]
  5. num_runs_per_condition = 2
  6. num_agents = [3,5]
  7. world_size = [5, 9]
  8. #TODO - variabalize this
  9. total_runs = num_runs_per_condition*len(num_agents)*len(world_size)
  10. current_run_num = 1
  11. print("Running ", total_runs, " rounds")
  12. # initial header setup
  13. with open ("data/data_test.txt", "w") as f:
  14. f.write("RunNumTot, RunNumOfCond, NumRoundsToCompletion, NumAgents,\
  15. InitResoCnt, HarvestedResos \n")
  16. # run a single iteration of the sim
  17. # TODO - make these nested for loops cleaner
  18. for w_size in world_size:
  19. for n_agents in num_agents:
  20. for run_num_in_cond in range(num_runs_per_condition):
  21. print("Run: ", current_run_num, " of", total_runs, " total runs")
  22. num_rounds_to_completion, raw_resos, harv_resos =\
  23. run_round(n_agents, w_size)
  24. with open ("data/data_test.txt", "a") as f:
  25. f.write("{}, {}, {}, {}, {}, {} \n".format( \
  26. current_run_num, \
  27. run_num_in_cond + 1, \
  28. num_rounds_to_completion, \
  29. n_agents, \
  30. raw_resos,\
  31. harv_resos))
  32. current_run_num += 1
  33. with open ("data/data_test.txt", "r") as f:
  34. #print(f.read(), end="")
  35. pass