-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain-part-2.py
More file actions
63 lines (52 loc) · 1.71 KB
/
main-part-2.py
File metadata and controls
63 lines (52 loc) · 1.71 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
62
63
import os
import time
from core.buscaheuristica import BuscaHeuristica
from probe import Probe
def main():
print('Processo iniciado!')
busca_heuristica = BuscaHeuristica()
instances_path = os.path.abspath('./final-instance/')
busca_heuristica.load_instances(instances_path)
print('Instâncias calculadas')
for instance in busca_heuristica.get_instances():
instance_name = instance['name']
results_file_path = os.path.abspath('./reports/' + instance_name.lower() + '.csv')
busca_heuristica.set_results_file_path(results_file_path)
melhores_configs = [
# Western Sahara
(15, 20, 90),
(80, 20, 5),
(85, 100, 15),
# Djibouti
(80, 20, 85),
( 5, 20, 15),
( 5, 100, 20),
# Qatar
(15, 20, 90),
(15, 10, 80),
(80, 100, 85),
]
for melhor_config in melhores_configs:
(alfa, filhos, mutacao) = melhor_config
timeout_base = time.process_time()
parameters = {
'alfa': alfa,
'mutacao': mutacao / 100,
'filhos': filhos / 100
}
print(f'Processando instância {instance_name}; Alfa={alfa}%; Filhos={filhos}%; Mutação={mutacao}%')
alg = Probe(table=instance['data'], instance_name=instance_name, parameters=parameters)
alg_results = alg.run()
print('Resultado instância:', alg_results)
process_time = time.process_time() - timeout_base
busca_heuristica.append_result({
'name': instance_name,
'q_medio': alg_results['q_medio'],
'q_desvio': alg_results['q_desvio'],
'tempo': process_time,
'alfa': alfa,
'mutacao': mutacao,
'filhos': filhos,
})
if __name__ == '__main__':
main()