-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmulti_task.py
More file actions
155 lines (141 loc) · 4.18 KB
/
multi_task.py
File metadata and controls
155 lines (141 loc) · 4.18 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import neat
import os
exec_times = 3
base_pth = "./all_data3"
local_dir = os.path.dirname(__file__)
config_path = os.path.join(local_dir, "config.ini")
tasks_parameters = [
# {
# "name": "sym2_task",
# "pcdtype": "sym2",
# "times": exec_times,
# "out_path": f"{base_pth}/sym2",
# "tradeoff": [
# "Max:E-Min:nu",
# "Max:E-Max:nu",
# ],
# },
# {
# "name": "sym2_tensor_task",
# "pcdtype": "sym2",
# "times": 1,
# "out_path": f"{base_pth}/sym2",
# "tradeoff": [
# "tensor1up",
# "tensor1down",
# "tensor2up",
# "tensor2down",
# "tensor3up",
# "tensor3down",
# ],
# },
{
"name": "sym4_task",
"pcdtype": "sym4",
"times": exec_times,
"out_path": f"{base_pth}/sym4",
"tradeoff": ["Max:E-Min:nu", "Max:E-Max:nu"],
},
{
"name": "rotate_task",
"pcdtype": "rotate",
"times": exec_times,
"out_path": f"{base_pth}/rotate",
"tradeoff": ["Max:E-Min:nu", "Max:E-Max:nu"],
},
{
"name": "parallel_task",
"pcdtype": "parallel",
"times": exec_times,
"out_path": f"{base_pth}/parallel",
"tradeoff": ["Max:E-Min:nu", "Max:E-Max:nu"],
},
# {
# "name": "nosym_task",
# "pcdtype": "nosym",
# "times": exec_times,
# "out_path": f"{base_pth}/nosym",
# "tradeoff": ["shear_normal", "shear_bulk"],
# },
]
# tasks_parameters = [
# {
# "name": "sym2_tensor_task",
# "pcdtype": "sym2",
# "times": 1,
# "out_path": f"{base_pth}/sym2",
# "tradeoff": [
# "tensor1up",
# "tensor2leftdown",
# "tensor3leftup",
# "tensor3leftdown",
# ],
# },
# ]
class exc_all(object):
def __init__(self, para_dict, experiment) -> None:
self.para_dict = para_dict
self.tasks = []
self.experiment = experiment
self.define_tasks()
def define_tasks(self):
for params in self.para_dict:
# initiate et
config = neat.Config(
neat.DefaultGenome,
neat.DefaultReproduction,
neat.DefaultSpeciesSet,
neat.DefaultStagnation,
config_path,
)
config.pcdtype = params["pcdtype"]
et = executor_tasks(
config=config,
name=params["name"],
times=params["times"],
out_path=params["out_path"],
tradeoff=params["tradeoff"],
)
# append into tasks
self.tasks.append(et)
def re_init(self):
pass
def run_all(self):
# 每一个案例的每一个tradeoff 算 n次
for et in self.tasks:
for tf in et.tradeoff:
for t in range(et.times):
et.run(t, tf, self.experiment)
print("======================Finish all======================")
class executor_tasks(object):
def __init__(self, config, name, times, out_path, tradeoff) -> None:
self.config = config
self.name = name
self.times = times
self.out_path = out_path
self.tradeoff = tradeoff
def run(self, t, cur_tradeoff, experiment):
print(
"Current Task Details:\n"
f" Name : {self.name}\n"
f" CurTimes : {t}\n"
f" PointCloud Type: {self.config.pcdtype}\n"
f" Current Trade off: {cur_tradeoff}\n"
)
# 执行程序
experiment(
config=self.config,
task_name=self.name + "_" + cur_tradeoff,
cur_tradeoff=cur_tradeoff,
out_path=self.out_path,
cur_times=t,
n_generations=100,
)
def __str__(self) -> str:
return (
"Task Details:\n"
f" Name : {self.name}\n"
f" Times : {self.times}\n"
f" PointCloud Type: {self.config.pcdtype}\n"
f" Trade off: {self.tradeoff}\n"
)