+ added faster evaluation function
[qpalma.git] / scripts / ModelSelection.py
1 #!/usr/bin/env python
2 # -*- coding:latin-1 -*-
3
4 import cPickle
5 import os
6 import os.path
7 import time
8 import subprocess
9
10 from qpalma_main import QPalma
11 import Experiment as Exp
12
13 class Model:
14
15 allInstances = []
16
17 def __init__(self):
18 pass
19
20 def createInstances(self):
21
22 allRuns = Exp.createRuns()
23
24 for currentRun in allRuns[0:1]:
25
26 currentInstance = QPalma(currentRun)
27
28 #print 'instance created, starting to pickle configuration...'
29 name = currentRun['name']
30 instance_fn = '%s.pickle'%name
31 fh = open(instance_fn,'w+')
32 cPickle.dump(currentInstance,fh)
33 fh.close()
34
35 self.allInstances.append(instance_fn)
36
37
38 def doSelection(self):
39 for instance in self.allInstances:
40 time.sleep(2)
41 cmd = 'echo ./resurrect %s | qsub -l h_vmem=5.0G -cwd -j y -N \"%s.log\"'%(instance,instance)
42 #print cmd
43 os.system(cmd)
44
45 #os.system('echo "./resurrect %s >out_%s.log 2>err_%s.log &"'%(instance,instance,instance))
46
47
48 def doPrediction(self):
49 current_dir = '/fml/ag-raetsch/home/fabio/tmp/QPalma_single_run'
50
51 for instance in self.allInstances:
52 time.sleep(2)
53 cmd = '/fml/ag-raetsch/home/fabio/svn/projects/QPalma/scripts/doPrediction.sh %s 1>_%s.log 2>%s.log & '%(instance,instance,instance)
54 #cmd = 'echo /fml/ag-raetsch/home/fabio/svn/projects/QPalma/scripts/doPrediction.sh %s |\
55 #qsub -l h_vmem=12.0G -cwd -j y -N \"%s.log\"'%(instance,instance)
56 #os.system(cmd)
57 obj = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
58 #out,err = obj.communicate()
59 #print out,err
60
61
62
63 if __name__ == '__main__':
64 m = Model()
65 m.createInstances()
66 #m.doSelection()
67 m.doPrediction()