1 : |
agomez |
1 |
'''
|
2 : |
|
|
Created on 03/01/2012
|
3 : |
|
|
|
4 : |
|
|
@author: R. Valin
|
5 : |
|
|
'''
|
6 : |
|
|
import matplotlib.pyplot as plt
|
7 : |
|
|
import time
|
8 : |
|
|
#import os
|
9 : |
|
|
import random
|
10 : |
|
|
from exp.ea import experiment_type as expt
|
11 : |
|
|
from exp.ea import ea_bonfire as ea
|
12 : |
|
|
|
13 : |
|
|
|
14 : |
|
|
|
15 : |
|
|
"""############################################
|
16 : |
|
|
#Generacion aleatoria de experimentos #
|
17 : |
|
|
##############################################"""
|
18 : |
|
|
#Lectura de datos del histograma de envio
|
19 : |
|
|
#
|
20 : |
|
|
dire='/home/cesga/bonfire/workspace/Bonfire/exp/dis'
|
21 : |
|
|
print (dire + '/submit_time.csv')
|
22 : |
|
|
file1 = open(dire + '/submit_time_norm.csv', 'r')
|
23 : |
|
|
#Leemos ficheros estadisticas
|
24 : |
|
|
sub_prob = file1.readlines()
|
25 : |
|
|
file1.close()
|
26 : |
|
|
#Crea una lista con los valores que lee del fichero
|
27 : |
|
|
submit_prob = []
|
28 : |
|
|
for a in sub_prob:
|
29 : |
|
|
submit_prob.append(float(a.split(',')[1]))
|
30 : |
|
|
#print(submit_prob)
|
31 : |
|
|
|
32 : |
|
|
#Semilla para random si no pones nada en seed coge el tiempo del sistema
|
33 : |
|
|
random.seed()
|
34 : |
|
|
|
35 : |
|
|
print len(sub_prob)
|
36 : |
|
|
#Prueba de que la lectura de datos es correcta
|
37 : |
|
|
#b=0
|
38 : |
|
|
#for a in submit_prob:
|
39 : |
|
|
# b=b+a
|
40 : |
|
|
#print ('Prob total', b)
|
41 : |
|
|
|
42 : |
|
|
|
43 : |
|
|
#Asignacion del numero de trabajos cada media hora
|
44 : |
|
|
jobs = 0
|
45 : |
|
|
i = 0
|
46 : |
|
|
#Inicializa prob
|
47 : |
|
|
prob = 0
|
48 : |
|
|
#Trabajos totales que quieres enviar
|
49 : |
|
|
total_jobs = 100
|
50 : |
|
|
envio = [0 for x in range(len(submit_prob))]
|
51 : |
|
|
for a in range(total_jobs):
|
52 : |
|
|
#Probabilidad de envio en una hora dada
|
53 : |
|
|
prob_envio = random.random()
|
54 : |
|
|
|
55 : |
|
|
#Con este algoritmo determinamos la hora (o el bin del histograma)
|
56 : |
|
|
while (prob < prob_envio and prob_envio > prob + submit_prob[i + 1]):
|
57 : |
|
|
i = i + 1
|
58 : |
|
|
#print (i)
|
59 : |
|
|
prob = prob + submit_prob[i]
|
60 : |
|
|
|
61 : |
|
|
#Vector de trabajos a enviar por hora
|
62 : |
|
|
if (i <= len(submit_prob)):
|
63 : |
|
|
envio[i] = envio[i] + 1
|
64 : |
|
|
else:
|
65 : |
|
|
print('Me paso de indice')
|
66 : |
|
|
#print prob_envio, prob, prob+submit_prob[i+1]
|
67 : |
|
|
#Inicializamos variables para la siguiente iteracion
|
68 : |
|
|
i = 0
|
69 : |
|
|
prob = submit_prob[0]
|
70 : |
|
|
|
71 : |
|
|
#plt.bar(range(1,49), envio, 1)
|
72 : |
|
|
#plt.show()
|
73 : |
|
|
file2=open('sub.csv', 'w')
|
74 : |
|
|
for sub in envio:
|
75 : |
|
|
file2.write(str(sub)+'\n')
|
76 : |
|
|
file2.close()
|
77 : |
|
|
|
78 : |
|
|
"""################################################################
|
79 : |
|
|
# Envio de experimentos #
|
80 : |
|
|
###################################################################"""
|
81 : |
|
|
#Descripcion del trabajo en Json
|
82 : |
|
|
#exp={'description': 'Experiment description',
|
83 : |
|
|
# 'duration': 120,
|
84 : |
|
|
# 'name': 'My Experiment',
|
85 : |
|
|
# 'resources': [{'compute': {'name': 'JSON-COMPUTE-TEST',
|
86 : |
|
|
# 'description': 'A description of the compute.',
|
87 : |
|
|
# 'instanceType': 'small',
|
88 : |
|
|
# 'locations': ['fr-inria'],
|
89 : |
|
|
# 'resources':[{'storage': '@BonFIRE Debian Squeeze v3'},{'network':'@BonFIRE WAN'}]}}]}
|
90 : |
|
|
|
91 : |
|
|
|
92 : |
|
|
|
93 : |
|
|
|
94 : |
|
|
#Indicamos la lista de sites a la que queremos enviar, la duracion de los experimentos
|
95 : |
|
|
# y nos devuelve una lista con stings en json con la definicion del experimento
|
96 : |
|
|
#locations=['be-ibbt','fr-inria','uk-hplabs','uk-uedin']
|
97 : |
|
|
|
98 : |
|
|
#duration = 120
|
99 : |
|
|
#locations = ['uk-uedin']
|
100 : |
|
|
#exp, info_instance, info_storage, info_location = expt.json_exp(locations, duration)
|
101 : |
|
|
#
|
102 : |
|
|
#multi = 10
|
103 : |
|
|
#
|
104 : |
|
|
#for i in exp:
|
105 : |
|
|
# print i
|
106 : |
|
|
# m=str(i)
|
107 : |
|
|
# for j in range(10):
|
108 : |
|
|
# save(locations)
|
109 : |
|
|
# location=info_location[m]
|
110 : |
|
|
# instance=info_instance[m]
|
111 : |
|
|
# store=info_storage[m]
|
112 : |
|
|
# ea.ea_bf(i,instance,store,location)
|
113 : |
|
|
#time.sleep(float(130))
|
114 : |
|
|
|
115 : |
|
|
|
116 : |
|
|
|