-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlaunch_jobs.py
More file actions
61 lines (56 loc) · 2.31 KB
/
Copy pathlaunch_jobs.py
File metadata and controls
61 lines (56 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
File to lunch examples/*.py experiments on a HEC cluster
"""
# Importing the necessary packages
from os.path import isdir
import subprocess
import time
# Defining supportive methods
def python_cmd(env,method,exp_type,id=0,mode='default'):
if id != 'random':
return "python examples/"+env+"_"+exp_type+".py"+\
" --atype "+method+\
" --exp_num "+str(i)+\
" --id "+str(id)+\
" --mode "+str(mode)
else:
return "python examples/"+env+"_"+exp_type+".py"+\
" --atype "+method+\
" --exp_num "+str(i)+\
" --id "+str(id)+\
" --mode "+str(mode)+\
" --display False"+\
" --nagents 5"+\
" --ntasks 30"
# Checking AdLeap-MAS folder integrity
if not isdir("results"):
subprocess.run(["mkdir","results"])
if not isdir("serror"):
subprocess.run(["mkdir","serror"])
if not isdir("soutput"):
subprocess.run(["mkdir","soutput"])
if not isdir("tmp"):
subprocess.run(["mkdir","tmp"])
# Setting experiments configuration
exp_type = 'smalltest'
env = "levelforaging"
methods = ['ibpomcp']
nexperiments = 50
scenario_id = [5, 6, 7, 8, 9, 10, 11, 12, 13]
mode_list = ['default']
# Lunching experiments
for i in range(0,nexperiments):
for method in methods:
for mode in mode_list:
for id in scenario_id:
with open('run.sh','w') as runfile:
runfile.write("#!/bin/bash\n\n")
runfile.write("#SBATCH -J "+method+"_"+mode+'_'+env+str(id)+"_"+str(i)+"\n")
runfile.write("#SBATCH -e serror/"+method+"_"+mode+'_'+env+str(id)+"_"+str(i)+"%j.err\n")
runfile.write("#SBATCH -o soutput/"+method+"_"+mode+'_'+env+str(id)+"_"+str(i)+"%j.out\n")
runfile.write("#SBATCH --mem=3G\n")
runfile.write("#SBATCH --time=03:00:00\n")
runfile.write("source /etc/profile\n")
runfile.write(python_cmd(env,method,exp_type,id,mode))
subprocess.run(["sbatch","run.sh"])
time.sleep(0.1)