-
Notifications
You must be signed in to change notification settings - Fork 3
/
configs.py
184 lines (149 loc) · 7.53 KB
/
configs.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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
class DataConfig:
def __init__(self, dist='lognormal_laplacian_periodic', block_periodic=True,
num_unknowns=8 ** 2, root_num_blocks=4, splitting='CLJP', add_diag=False,
load_data=True, save_data=False):
self.dist = dist # see function 'generate_A()' for possible distributions
self.block_periodic = block_periodic
self.num_unknowns = num_unknowns
self.root_num_blocks = root_num_blocks
self.splitting = splitting
self.add_diag = add_diag
self.load_data = load_data
self.save_data = save_data
class ModelConfig:
def __init__(self, mp_rounds=3, global_block=False, latent_size=64, mlp_layers=4, concat_encoder=True):
self.mp_rounds = mp_rounds
self.global_block = global_block
self.latent_size = latent_size
self.mlp_layers = mlp_layers
self.concat_encoder = concat_encoder
class RunConfig:
def __init__(self, node_indicators=True, edge_indicators=True, normalize_rows=True, normalize_rows_by_node=False):
self.node_indicators = node_indicators
self.edge_indicators = edge_indicators
self.normalize_rows = normalize_rows
self.normalize_rows_by_node = normalize_rows_by_node
class TestConfig:
def __init__(self, dist='lognormal_laplacian_periodic', splitting='CLJP',
test_sizes=(1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072),
load_data=True, num_runs=100, cycle='W',
max_levels=12, iterations=81, fp_threshold=1e-10, strength=('classical', {'theta': 0.25}),
presmoother=('gauss_seidel', {'sweep': 'forward', 'iterations': 1}),
postsmoother=('gauss_seidel', {'sweep': 'forward', 'iterations': 1}),
coarse_solver='pinv2'):
self.dist = dist
self.splitting = splitting
self.test_sizes = test_sizes
self.load_data = load_data
self.num_runs = num_runs
self.cycle = cycle
self.max_levels = max_levels
self.iterations = iterations
self.fp_threshold = fp_threshold
self.strength = strength
self.presmoother = presmoother
self.postsmoother = postsmoother
self.coarse_solver = coarse_solver
# self.coarse_solver = ('gauss_seidel', {'iterations': 20})
class TrainConfig:
def __init__(self, samples_per_run=256, num_runs=1000, batch_size=32, learning_rate=3e-3, fourier=True,
coarsen=False, checkpoint_dir='./training_dir', tensorboard_dir='./tb_dir', load_model=False):
self.samples_per_run = samples_per_run
self.num_runs = num_runs
self.batch_size = batch_size
self.learning_rate = learning_rate
self.fourier = fourier
self.coarsen = coarsen
self.checkpoint_dir = checkpoint_dir
self.tensorboard_dir = tensorboard_dir
self.load_model = load_model
class Config:
def __init__(self):
self.data_config = DataConfig()
self.model_config = ModelConfig()
self.run_config = RunConfig()
self.test_config = TestConfig()
self.train_config = TrainConfig()
GRAPH_LAPLACIAN_TEST = Config()
COMPLEX_FEM_TEST = Config()
COMPLEX_FEM_TEST.test_config.dist = 'lognormal_complex_fem'
COMPLEX_FEM_TEST.test_config.fp_threshold = 0
GRAPH_LAPLACIAN_RS_TEST = Config()
GRAPH_LAPLACIAN_RS_TEST.test_config.splitting = 'RS'
GRAPH_LAPLACIAN_RS_SECOND_PASS_TEST = Config()
GRAPH_LAPLACIAN_RS_SECOND_PASS_TEST.test_config.splitting = ('RS', {'second_pass': True})
GRAPH_LAPLACIAN_PMIS_TEST = Config()
GRAPH_LAPLACIAN_PMIS_TEST.test_config.splitting = 'PMIS'
GRAPH_LAPLACIAN_PMISc_TEST = Config()
GRAPH_LAPLACIAN_PMISc_TEST.test_config.splitting = 'PMISc'
GRAPH_LAPLACIAN_CLJPc_TEST = Config()
GRAPH_LAPLACIAN_CLJPc_TEST.test_config.splitting = 'CLJPc'
GRAPH_LAPLACIAN_SA_TEST = Config()
GRAPH_LAPLACIAN_SA_TEST.test_config.splitting = 'SA'
GRAPH_LAPLACIAN_ROOTNODE_TEST = Config()
GRAPH_LAPLACIAN_ROOTNODE_TEST.test_config.splitting = 'rootnode'
GRAPH_LAPLACIAN_TRAIN = Config()
GRAPH_LAPLACIAN_TRAIN.data_config.dist = 'lognormal_laplacian_periodic'
GRAPH_LAPLACIAN_ABLATION_MP2 = Config()
GRAPH_LAPLACIAN_ABLATION_MP2.data_config.dist = 'lognormal_laplacian_periodic'
GRAPH_LAPLACIAN_ABLATION_MP2.model_config.mp_rounds = 2
GRAPH_LAPLACIAN_ABLATION_MLP2 = Config()
GRAPH_LAPLACIAN_ABLATION_MLP2.data_config.dist = 'lognormal_laplacian_periodic'
GRAPH_LAPLACIAN_ABLATION_MLP2.model_config.mlp_layers = 2
GRAPH_LAPLACIAN_ABLATION_NO_CONCAT = Config()
GRAPH_LAPLACIAN_ABLATION_NO_CONCAT.data_config.dist = 'lognormal_laplacian_periodic'
GRAPH_LAPLACIAN_ABLATION_NO_CONCAT.model_config.concat_encoder = False
GRAPH_LAPLACIAN_ABLATION_NO_INDICATORS = Config()
GRAPH_LAPLACIAN_ABLATION_NO_INDICATORS.data_config.dist = 'lognormal_laplacian_periodic'
GRAPH_LAPLACIAN_ABLATION_NO_INDICATORS.run_config.node_indicators = False
GRAPH_LAPLACIAN_ABLATION_NO_INDICATORS.run_config.edge_indicators = False
GRAPH_LAPLACIAN_EVAL = Config()
GRAPH_LAPLACIAN_EVAL.data_config.block_periodic = False
GRAPH_LAPLACIAN_EVAL.data_config.num_unknowns = 4096
GRAPH_LAPLACIAN_EVAL.data_config.dist = 'lognormal_laplacian'
GRAPH_LAPLACIAN_EVAL.data_config.load_data = False
GRAPH_LAPLACIAN_EVAL.train_config.fourier = False
SPEC_CLUSTERING_TRAIN = Config()
SPEC_CLUSTERING_TRAIN.data_config.dist = 'spectral_clustering'
SPEC_CLUSTERING_TRAIN.data_config.num_unknowns = 1024
SPEC_CLUSTERING_TRAIN.data_config.block_periodic = False
SPEC_CLUSTERING_TRAIN.data_config.add_diag = True
SPEC_CLUSTERING_TRAIN.train_config.coarsen = False
SPEC_CLUSTERING_TRAIN.train_config.fourier = False
SPEC_CLUSTERING_EVAL = Config()
SPEC_CLUSTERING_EVAL.data_config.dist = 'spectral_clustering'
SPEC_CLUSTERING_EVAL.data_config.num_unknowns = 4096
SPEC_CLUSTERING_EVAL.data_config.block_periodic = False
SPEC_CLUSTERING_EVAL.data_config.add_diag = True
SPEC_CLUSTERING_EVAL.train_config.coarsen = False
SPEC_CLUSTERING_EVAL.train_config.fourier = False
GRAPH_LAPLACIAN_UNIFORM_TEST = Config()
GRAPH_LAPLACIAN_UNIFORM_TEST.data_config.block_periodic = False
GRAPH_LAPLACIAN_UNIFORM_TEST.data_config.dist = 'uniform_laplacian'
FINITE_ELEMENT_TEST = Config()
FINITE_ELEMENT_TEST.data_config.block_periodic = False
FINITE_ELEMENT_TEST.data_config.dist = 'finite_element'
# should replicate results from "Compatible Relaxation and Coarsening in Algebraic Multigrid" (2009)
CR_TEST = Config()
CR_TEST.data_config.splitting = ('CR', {'verbose': True,
'method': 'habituated',
'nu': 2,
'thetacr': 0.5,
'thetacs': [0.3 ** 2, 0.5],
'maxiter': 20})
# CR_TEST.data_config.dist = 'poisson'
# CR_TEST.data_config.dist = 'aniso'
CR_TEST.data_config.dist = 'lognormal_laplacian'
# CR_TEST.data_config.dist = 'example'
CR_TEST.test_config.num_runs = 10
CR_TEST.test_config.test_sizes = (1024, 2048, 4096, 8192,)
# CR_TEST.test_config.test_sizes = ('airfoil', 'bar', 'knot', 'local_disc_galerkin_diffusion',
# 'recirc_flow', 'unit_cube', 'unit_square')
# CR_TEST.test_config.fp_threshold = 0
# CR_TEST.test_config.coarse_solver = ('gauss_seidel', {'iterations': 200})
CR_TEST.test_config.presmoother = ('gauss_seidel', {'sweep': 'forward', 'iterations': 1})
# CR_TEST.test_config.postsmoother = ('gauss_seidel', {'sweep': 'backward', 'iterations': 1})
CR_TEST.test_config.coarse_solver = 'pinv2'
CR_TEST.test_config.cycle = 'V'
CR_TEST.test_config.iterations = 40
CR_TEST.test_config.max_levels = 2