-
Notifications
You must be signed in to change notification settings - Fork 1
/
one_ackley_cloud2.py
60 lines (48 loc) · 2.72 KB
/
one_ackley_cloud2.py
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
__author__ = 'mariosky'
from sackley_2 import initialize, work
import time, yaml
import random
config = yaml.load(open("EvoPar2015/code/conf/conf.yaml"))
dict={'NUMBER_OF_WORKERS':config['NUMBER_OF_WORKERS'],'SAMPLE_SIZE':config["SAMPLE_SIZE"],'POPULATION_SIZE':config["POPULATION_SIZE"],'SERVER': 'http://54.164.20.127:5000/evospace','WORKER_TYPE': 'c1','CHROMOSOME_LENGTH': config["CHROMOSOME_LENGTH"],'PEAKS': 512,'WORKER_GENERATIONS': config["WORKER_GENERATIONS"],'MAX_SAMPLES': config["MAX_SAMPLES"],'MUTATION_FLIP_PB': .05,'TOURNAMENT_SIZE': 4,'CXPB':round(random.uniform(0.5,1),2), 'MUTPB':round(random.uniform(0,0.1),3),'RETURN_RATE': 1.00}
experiment = "w%d-%d-p%d" % (dict["NUMBER_OF_WORKERS"], dict["RETURN_RATE"]*100,dict["POPULATION_SIZE"])
experiment_id = experiment + "-%d" % round(time.time(),0)
dic=[]
for i in range(dict["NUMBER_OF_WORKERS"]):
dict1 = {'NUMBER_OF_WORKERS':range(dict["NUMBER_OF_WORKERS"]),'SAMPLE_SIZE':config['SAMPLE_SIZE'],'POPULATION_SIZE':config['POPULATION_SIZE'],'SERVER': 'http://54.164.20.127:5000/evospace','WORKER_TYPE': 'c1','CHROMOSOME_LENGTH': config["CHROMOSOME_LENGTH"],'PEAKS': 512,'WORKER_GENERATIONS': config["WORKER_GENERATIONS"],'MAX_SAMPLES': config["MAX_SAMPLES"],'MUTATION_FLIP_PB': .05,'TOURNAMENT_SIZE': 4,'CXPB':round(random.uniform(0.5,1),2),'MUTPB':round(random.uniform(0,0.1),3),'RETURN_RATE': 1.00}
dic.append(dict1)
datafile = open("EvoPar2015/code/data/one_ackley_n1-"+experiment_id+".dat","a")
conf_out = open("EvoPar2015/code/conf/one_ackley_n1-"+experiment_id+".yaml","w")
yaml.dump(config, conf_out)
conf_out.close()
for i in range(config["NUM_EXP"]):
start = time.time()
init_job = initialize.delay(config=config)
while not init_job.ready():
time.sleep(2)
print "waiting to initialize"
print "EvoSpace Initialized"
tInitialize = time.time()-start
print i, tInitialize
params = [(w, dic[w]) for w in range(dict["NUMBER_OF_WORKERS"])]
jids = map(work.delay, params)
results_list = []
while jids:
#time.sleep(1)
print "Working"
for job in jids:
if job.ready():
if job.status == 'FAILURE':
print job.traceback
#time.sleep(2)
r = job.get()
#print r
results_list.append(r)
jids.remove(job)
#print min(results_list)
tTotal = time.time()-start
totals = "%d,%0.2f,%0.2f" % (i, round(tTotal,2), round(tInitialize,2))
print totals
datafile.write(totals + '\n')
for worker_list in results_list:
for data_list in worker_list:
datafile.write(str(i) +"," + ",".join(map(str,data_list)) + '\n')