From 94ad95b927660f94427660ac5b0d0c4dd7539d6d Mon Sep 17 00:00:00 2001 From: "T.Aoyama" Date: Thu, 29 Aug 2024 18:19:40 +0900 Subject: [PATCH] add tests for resume/continue --- tests/bayes_continue/MeshData.txt | 121 +++++++++++++++++++++++++++ tests/bayes_continue/do.sh | 28 +++++++ tests/bayes_continue/input1a.toml | 21 +++++ tests/bayes_continue/input1b.toml | 21 +++++ tests/bayes_continue/input2.toml | 21 +++++ tests/exchange_continue/do.sh | 30 +++++++ tests/exchange_continue/input1a.toml | 24 ++++++ tests/exchange_continue/input1b.toml | 24 ++++++ tests/exchange_continue/input2.toml | 24 ++++++ tests/mapper_resume/MeshData.txt | 121 +++++++++++++++++++++++++++ tests/mapper_resume/do.sh | 30 +++++++ tests/mapper_resume/input1.toml | 20 +++++ tests/mapper_resume/input2.toml | 17 ++++ tests/pamc_continue/do.sh | 30 +++++++ tests/pamc_continue/input1a.toml | 29 +++++++ tests/pamc_continue/input1b.toml | 29 +++++++ tests/pamc_continue/input2.toml | 29 +++++++ 17 files changed, 619 insertions(+) create mode 100644 tests/bayes_continue/MeshData.txt create mode 100644 tests/bayes_continue/do.sh create mode 100644 tests/bayes_continue/input1a.toml create mode 100644 tests/bayes_continue/input1b.toml create mode 100644 tests/bayes_continue/input2.toml create mode 100644 tests/exchange_continue/do.sh create mode 100644 tests/exchange_continue/input1a.toml create mode 100644 tests/exchange_continue/input1b.toml create mode 100644 tests/exchange_continue/input2.toml create mode 100644 tests/mapper_resume/MeshData.txt create mode 100644 tests/mapper_resume/do.sh create mode 100644 tests/mapper_resume/input1.toml create mode 100644 tests/mapper_resume/input2.toml create mode 100644 tests/pamc_continue/do.sh create mode 100644 tests/pamc_continue/input1a.toml create mode 100644 tests/pamc_continue/input1b.toml create mode 100644 tests/pamc_continue/input2.toml diff --git a/tests/bayes_continue/MeshData.txt b/tests/bayes_continue/MeshData.txt new file mode 100644 index 00000000..28a32434 --- /dev/null +++ b/tests/bayes_continue/MeshData.txt @@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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 diff --git a/tests/bayes_continue/do.sh b/tests/bayes_continue/do.sh new file mode 100644 index 00000000..e9c8aa74 --- /dev/null +++ b/tests/bayes_continue/do.sh @@ -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 + diff --git a/tests/bayes_continue/input1a.toml b/tests/bayes_continue/input1a.toml new file mode 100644 index 00000000..012097f2 --- /dev/null +++ b/tests/bayes_continue/input1a.toml @@ -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 diff --git a/tests/bayes_continue/input1b.toml b/tests/bayes_continue/input1b.toml new file mode 100644 index 00000000..2e9e9c76 --- /dev/null +++ b/tests/bayes_continue/input1b.toml @@ -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 diff --git a/tests/bayes_continue/input2.toml b/tests/bayes_continue/input2.toml new file mode 100644 index 00000000..4b3e444d --- /dev/null +++ b/tests/bayes_continue/input2.toml @@ -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 diff --git a/tests/exchange_continue/do.sh b/tests/exchange_continue/do.sh new file mode 100644 index 00000000..93e0dccc --- /dev/null +++ b/tests/exchange_continue/do.sh @@ -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 + diff --git a/tests/exchange_continue/input1a.toml b/tests/exchange_continue/input1a.toml new file mode 100644 index 00000000..a20d4149 --- /dev/null +++ b/tests/exchange_continue/input1a.toml @@ -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" diff --git a/tests/exchange_continue/input1b.toml b/tests/exchange_continue/input1b.toml new file mode 100644 index 00000000..5ea43e2c --- /dev/null +++ b/tests/exchange_continue/input1b.toml @@ -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" diff --git a/tests/exchange_continue/input2.toml b/tests/exchange_continue/input2.toml new file mode 100644 index 00000000..56e246e8 --- /dev/null +++ b/tests/exchange_continue/input2.toml @@ -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" diff --git a/tests/mapper_resume/MeshData.txt b/tests/mapper_resume/MeshData.txt new file mode 100644 index 00000000..28a32434 --- /dev/null +++ b/tests/mapper_resume/MeshData.txt @@ -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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 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 diff --git a/tests/mapper_resume/do.sh b/tests/mapper_resume/do.sh new file mode 100644 index 00000000..d00ddb00 --- /dev/null +++ b/tests/mapper_resume/do.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +CMD="python3 -u ../../src/py2dmat_main.py" +#CMD="mpiexec -np 2 python3 -u ../../src/py2dmat_main.py" + +rm -rf output1 + +time timeout 12s $CMD input1.toml + +time $CMD --resume input1.toml + +rm -rf output2 + +time $CMD input2.toml + + +resfile=output1/ColorMap.txt +reffile=output2/ColorMap.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 + diff --git a/tests/mapper_resume/input1.toml b/tests/mapper_resume/input1.toml new file mode 100644 index 00000000..1773e3c4 --- /dev/null +++ b/tests/mapper_resume/input1.toml @@ -0,0 +1,20 @@ +[base] +dimension = 2 +output_dir = "output1" + +[solver] +name = "analytical" +function_name = "rosenbrock" +delay = 0.2 + +[algorithm] +name = "mapper" +label_list = ["z1", "z2"] +seed = 1 +checkpoint = true +checkpoint_steps = 40 + +[algorithm.param] +min_list = [-5.0, -5.0] +max_list = [5.0, 5.0] +num_list = [11, 11] diff --git a/tests/mapper_resume/input2.toml b/tests/mapper_resume/input2.toml new file mode 100644 index 00000000..65bb9123 --- /dev/null +++ b/tests/mapper_resume/input2.toml @@ -0,0 +1,17 @@ +[base] +dimension = 2 +output_dir = "output2" + +[solver] +name = "analytical" +function_name = "rosenbrock" + +[algorithm] +name = "mapper" +label_list = ["z1", "z2"] +seed = 1 + +[algorithm.param] +min_list = [-5.0, -5.0] +max_list = [5.0, 5.0] +num_list = [11, 11] diff --git a/tests/pamc_continue/do.sh b/tests/pamc_continue/do.sh new file mode 100644 index 00000000..74a8c343 --- /dev/null +++ b/tests/pamc_continue/do.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +CMD="mpiexec -np 2 python3 -u ../../src/py2dmat_main.py" + +rm -rf output1 + +time $CMD input1a.toml 2>&1 | tee run.log.1a +time $CMD --cont input1b.toml 2>&1 | tee run.log.1b + +rm -rf output2 + +time $CMD input2.toml 2>&1 | tee run.log.2 + + +#resfile=output1/best_result.txt +#reffile=output2/best_result.txt +resfile=output1/fx.txt +reffile=output2/fx.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 + diff --git a/tests/pamc_continue/input1a.toml b/tests/pamc_continue/input1a.toml new file mode 100644 index 00000000..002b8cea --- /dev/null +++ b/tests/pamc_continue/input1a.toml @@ -0,0 +1,29 @@ +[base] +dimension = 1 +output_dir = "output1" + +[algorithm] +name = "pamc" +seed = 12345 +checkpoint = true +checkpoint_steps = 1000 + +[algorithm.param] +min_list = [-10.0] +max_list = [10.0] +unit_list = [0.25] + +[algorithm.pamc] +# numsteps = 100 +numsteps_annealing = 100 +Tnum = 11 +bmin = 0.0 +bmax = 10.0 +Tlogspace = false +nreplica_per_proc = 100 +fix_num_walkers = false +resampling_interval = 3 + +[solver] +name = "analytical" +function_name = "quadratics" diff --git a/tests/pamc_continue/input1b.toml b/tests/pamc_continue/input1b.toml new file mode 100644 index 00000000..79933037 --- /dev/null +++ b/tests/pamc_continue/input1b.toml @@ -0,0 +1,29 @@ +[base] +dimension = 1 +output_dir = "output1" + +[algorithm] +name = "pamc" +seed = 12345 +checkpoint = true +checkpoint_steps = 1000 + +[algorithm.param] +min_list = [-10.0] +max_list = [10.0] +unit_list = [0.25] + +[algorithm.pamc] +# numsteps = 100 +numsteps_annealing = 100 +Tnum = 11 +bmin = 10.0 +bmax = 20.0 +Tlogspace = false +nreplica_per_proc = 100 +fix_num_walkers = false +resampling_interval = 3 + +[solver] +name = "analytical" +function_name = "quadratics" diff --git a/tests/pamc_continue/input2.toml b/tests/pamc_continue/input2.toml new file mode 100644 index 00000000..1a796359 --- /dev/null +++ b/tests/pamc_continue/input2.toml @@ -0,0 +1,29 @@ +[base] +dimension = 1 +output_dir = "output2" + +[algorithm] +name = "pamc" +seed = 12345 +checkpoint = true +checkpoint_steps = 1000 + +[algorithm.param] +min_list = [-10.0] +max_list = [10.0] +unit_list = [0.25] + +[algorithm.pamc] +# numsteps = 100 +numsteps_annealing = 100 +Tnum = 21 +bmin = 0.0 +bmax = 20.0 +Tlogspace = false +nreplica_per_proc = 100 +fix_num_walkers = false +resampling_interval = 3 + +[solver] +name = "analytical" +function_name = "quadratics"