Skip to content

Commit

Permalink
add tests for resume/continue
Browse files Browse the repository at this point in the history
  • Loading branch information
aoymt committed Aug 29, 2024
1 parent 2d5bec5 commit 94ad95b
Show file tree
Hide file tree
Showing 17 changed files with 619 additions and 0 deletions.
121 changes: 121 additions & 0 deletions tests/bayes_continue/MeshData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
0 -5.0 -5.0
1 -5.0 -4.0
2 -5.0 -3.0
3 -5.0 -2.0
4 -5.0 -1.0
5 -5.0 0.0
6 -5.0 1.0
7 -5.0 2.0
8 -5.0 3.0
9 -5.0 4.0
10 -5.0 5.0
11 -4.0 -5.0
12 -4.0 -4.0
13 -4.0 -3.0
14 -4.0 -2.0
15 -4.0 -1.0
16 -4.0 0.0
17 -4.0 1.0
18 -4.0 2.0
19 -4.0 3.0
20 -4.0 4.0
21 -4.0 5.0
22 -3.0 -5.0
23 -3.0 -4.0
24 -3.0 -3.0
25 -3.0 -2.0
26 -3.0 -1.0
27 -3.0 0.0
28 -3.0 1.0
29 -3.0 2.0
30 -3.0 3.0
31 -3.0 4.0
32 -3.0 5.0
33 -2.0 -5.0
34 -2.0 -4.0
35 -2.0 -3.0
36 -2.0 -2.0
37 -2.0 -1.0
38 -2.0 0.0
39 -2.0 1.0
40 -2.0 2.0
41 -2.0 3.0
42 -2.0 4.0
43 -2.0 5.0
44 -1.0 -5.0
45 -1.0 -4.0
46 -1.0 -3.0
47 -1.0 -2.0
48 -1.0 -1.0
49 -1.0 0.0
50 -1.0 1.0
51 -1.0 2.0
52 -1.0 3.0
53 -1.0 4.0
54 -1.0 5.0
55 0.0 -5.0
56 0.0 -4.0
57 0.0 -3.0
58 0.0 -2.0
59 0.0 -1.0
60 0.0 0.0
61 0.0 1.0
62 0.0 2.0
63 0.0 3.0
64 0.0 4.0
65 0.0 5.0
66 1.0 -5.0
67 1.0 -4.0
68 1.0 -3.0
69 1.0 -2.0
70 1.0 -1.0
71 1.0 0.0
72 1.0 1.0
73 1.0 2.0
74 1.0 3.0
75 1.0 4.0
76 1.0 5.0
77 2.0 -5.0
78 2.0 -4.0
79 2.0 -3.0
80 2.0 -2.0
81 2.0 -1.0
82 2.0 0.0
83 2.0 1.0
84 2.0 2.0
85 2.0 3.0
86 2.0 4.0
87 2.0 5.0
88 3.0 -5.0
89 3.0 -4.0
90 3.0 -3.0
91 3.0 -2.0
92 3.0 -1.0
93 3.0 0.0
94 3.0 1.0
95 3.0 2.0
96 3.0 3.0
97 3.0 4.0
98 3.0 5.0
99 4.0 -5.0
100 4.0 -4.0
101 4.0 -3.0
102 4.0 -2.0
103 4.0 -1.0
104 4.0 0.0
105 4.0 1.0
106 4.0 2.0
107 4.0 3.0
108 4.0 4.0
109 4.0 5.0
110 5.0 -5.0
111 5.0 -4.0
112 5.0 -3.0
113 5.0 -2.0
114 5.0 -1.0
115 5.0 0.0
116 5.0 1.0
117 5.0 2.0
118 5.0 3.0
119 5.0 4.0
120 5.0 5.0
28 changes: 28 additions & 0 deletions tests/bayes_continue/do.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

CMD="python3 -u ../../src/py2dmat_main.py"

rm -rf output1

time $CMD input1a.toml
time $CMD --cont input1b.toml

rm -rf output2

time $CMD input2.toml


resfile=output1/BayesData.txt
reffile=output2/BayesData.txt

echo diff $resfile $reffile
res=0
diff $resfile $reffile || res=$?
if [ $res -eq 0 ]; then
echo TEST PASS
true
else
echo TEST FAILED: $resfile and $reffile differ
false
fi

21 changes: 21 additions & 0 deletions tests/bayes_continue/input1a.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[base]
dimension = 2
output_dir = "output1"

[solver]
name = "analytical"
function_name = "rosenbrock"

[algorithm]
name = "bayes"
label_list = ["z1", "z2"]
seed = 1
checkpoint = true
checkpoint_steps = 8

[algorithm.param]
mesh_path = "MeshData.txt"

[algorithm.bayes]
random_max_num_probes = 5
bayes_max_num_probes = 20
21 changes: 21 additions & 0 deletions tests/bayes_continue/input1b.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[base]
dimension = 2
output_dir = "output1"

[solver]
name = "analytical"
function_name = "rosenbrock"

[algorithm]
name = "bayes"
label_list = ["z1", "z2"]
seed = 1
checkpoint = true
checkpoint_steps = 8

[algorithm.param]
mesh_path = "MeshData.txt"

[algorithm.bayes]
random_max_num_probes = 5
bayes_max_num_probes = 30
21 changes: 21 additions & 0 deletions tests/bayes_continue/input2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[base]
dimension = 2
output_dir = "output2"

[solver]
name = "analytical"
function_name = "rosenbrock"

[algorithm]
name = "bayes"
label_list = ["z1", "z2"]
seed = 1
checkpoint = true
checkpoint_steps = 8

[algorithm.param]
mesh_path = "MeshData.txt"

[algorithm.bayes]
random_max_num_probes = 5
bayes_max_num_probes = 30
30 changes: 30 additions & 0 deletions tests/exchange_continue/do.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

CMD="mpiexec -np 4 python3 -u ../../src/py2dmat_main.py"

rm -rf output1

time $CMD input1a.toml
time $CMD --cont input1b.toml

rm -rf output2

time $CMD input2.toml


#resfile=output1/best_result.txt
#reffile=output2/best_result.txt
resfile=output1/result_T0.txt
reffile=output2/result_T0.txt

echo diff $resfile $reffile
res=0
diff $resfile $reffile || res=$?
if [ $res -eq 0 ]; then
echo TEST PASS
true
else
echo TEST FAILED: $resfile and $reffile differ
false
fi

24 changes: 24 additions & 0 deletions tests/exchange_continue/input1a.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[base]
dimension = 2
output_dir = "output1"

[algorithm]
name = "exchange"
seed = 12345
checkpoint = true
checkpoint_steps = 1000

[algorithm.param]
min_list = [-5.0, -5.0]
max_list = [5.0, 5.0]

[algorithm.exchange]
numsteps = 10000
numsteps_exchange = 20
Tmin = 0.1
Tmax = 1.0
Tlogspace = false

[solver]
name = "analytical"
function_name = "rosenbrock"
24 changes: 24 additions & 0 deletions tests/exchange_continue/input1b.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[base]
dimension = 2
output_dir = "output1"

[algorithm]
name = "exchange"
seed = 12345
checkpoint = true
checkpoint_steps = 5000

[algorithm.param]
min_list = [-5.0, -5.0]
max_list = [5.0, 5.0]

[algorithm.exchange]
numsteps = 20000
numsteps_exchange = 20
Tmin = 0.1
Tmax = 1.0
Tlogspace = false

[solver]
name = "analytical"
function_name = "rosenbrock"
24 changes: 24 additions & 0 deletions tests/exchange_continue/input2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[base]
dimension = 2
output_dir = "output2"

[algorithm]
name = "exchange"
seed = 12345
checkpoint = true
checkpoint_steps = 1000

[algorithm.param]
min_list = [-5.0, -5.0]
max_list = [5.0, 5.0]

[algorithm.exchange]
numsteps = 20000
numsteps_exchange = 20
Tmin = 0.1
Tmax = 1.0
Tlogspace = false

[solver]
name = "analytical"
function_name = "rosenbrock"
Loading

0 comments on commit 94ad95b

Please sign in to comment.