-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperiments.py
More file actions
87 lines (77 loc) · 2.65 KB
/
experiments.py
File metadata and controls
87 lines (77 loc) · 2.65 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import pandas as pd
import pfevaluator
from pathlib import Path
from glob import glob
from zipfile import ZipFile
from architecturespaceanalyzer import ArchitectureSpaceAnalyzer
DATA = 'zips'
DATA_TMP = 'datasets'
class Experiment:
def __init__(self, name, short_name, length, num_objs):
self.name = name
self.short_name = short_name
self.length = length
self.num_objs = num_objs
self.objectives = self.get_objectives()
self.objectives_df = self.get_objectives_df()
def get_objectives(self):
objectives = ['perfQ', 'reliability', '#changes']
if self.num_objs == 4:
objectives.append('pas')
return objectives
def get_objectives_df(self):
space = ArchitectureSpaceAnalyzer()
space.initialize_dataset(self.name)
space.read_file_batch(1, 31, length=self.length, arguments=2,
option='all', add_source=True)
df = space.objectives_df
df['perfQ'] = -df['perfQ']
df['reliability'] = -df['reliability']
return df
def get_pareto(self, invert=False):
pf_values = pfevaluator.find_reference_front(
self.objectives_df[self.objectives].values)
pf = pd.DataFrame(pf_values, columns=self.objectives)
if invert:
pf['perfQ'] = -pf['perfQ']
pf['reliability'] = -pf['reliability']
return pf
#####
# TTBS
#####
ttbs = [
Experiment('nsgaii-train-ticket-1000-eval',
'reference 1000', 4, 4),
Experiment('nsgaii-train-ticket-sbspe-100-eval-it-0',
'baseline 100', 4, 4),
Experiment('nsgaii-train-ticket-sbspe-50-eval-it-1-l-2-centroid-258',
'2nd step 50 c258', 2, 4),
Experiment('nsgaii-train-ticket-sbspe-50-eval-it-1-l-2-centroid-223',
'2nd step 50 c223', 2, 4),
]
#####
# CoCOME
#####
ccm = [
Experiment('nsgaii-cocome-1000-eval',
'reference 1000', 4, 4),
Experiment('nsgaii-cocome-sbspe-100-eval-it-0',
'baseline 100', 4, 4),
Experiment('nsgaii-cocome-sbspe-50-eval-it-1-l-2-centroid-317',
'2nd step 50 c317', 2, 4),
Experiment('nsgaii-cocome-sbspe-50-eval-it-1-l-2-centroid-358',
'2nd step 50 c358', 2, 4),
]
# Prepare data
zips = Path(DATA)
data_dir = Path(DATA_TMP)
# Extract the archives if necessary
if not data_dir.exists() and \
not data_dir.is_dir() and \
zips.exists() and \
zips.is_dir():
archives = ['{}/{}.zip'.format(DATA, exp.name) for exp in ttbs + ccm]
data_dir.mkdir()
for arc in archives:
with ZipFile(arc, 'r') as zObject:
zObject.extractall(path=DATA_TMP)