From d002fbe8744a90ee7596e3b3f23305b7933642b6 Mon Sep 17 00:00:00 2001 From: LBer Date: Thu, 13 Jan 2022 15:25:50 +0100 Subject: [PATCH] add assimilation methods to quadratic_model #1 --- example/quadratic_model/CMakeLists.txt | 24 +++++++++++++++++++ .../configuration/perturbation_manager.lua | 18 +++++++++++++- .../ensemble_kalman_filter.cpp | 4 ++-- .../extended_kalman_filter.cpp | 4 ++-- .../extended_minimax_filter.cpp | 4 ++-- example/quadratic_model/forward.cpp | 4 ++-- example/quadratic_model/forward_python.cpp | 4 ++-- example/quadratic_model/hjb.cpp | 4 ++-- example/quadratic_model/monte_carlo.cpp | 4 ++-- example/quadratic_model/nudging.cpp | 4 ++-- .../quadratic_model/optimal_interpolation.cpp | 4 ++-- .../unscented_kalman_filter.cpp | 4 ++-- 12 files changed, 61 insertions(+), 21 deletions(-) diff --git a/example/quadratic_model/CMakeLists.txt b/example/quadratic_model/CMakeLists.txt index 0421877..4e0a0a7 100644 --- a/example/quadratic_model/CMakeLists.txt +++ b/example/quadratic_model/CMakeLists.txt @@ -15,3 +15,27 @@ add_dependencies(quadratic_model quadratic_model_optimal_interpolation) add_executable(quadratic_model_nudging nudging.cpp) target_link_libraries(quadratic_model_nudging verdandi) add_dependencies(quadratic_model quadratic_model_nudging) + +add_executable(quadratic_model_enkf ensemble_kalman_filter.cpp) +target_link_libraries(quadratic_model_enkf verdandi) +add_dependencies(quadratic_model quadratic_model_enkf) + +add_executable(quadratic_model_extkf extended_kalman_filter.cpp) +target_link_libraries(quadratic_model_extkf verdandi) +add_dependencies(quadratic_model quadratic_model_extkf) + +add_executable(quadratic_model_extminmax extended_minimax_filter.cpp) +target_link_libraries(quadratic_model_extminmax verdandi) +add_dependencies(quadratic_model quadratic_model_extminmax) + +add_executable(quadratic_model_mc monte_carlo.cpp) +target_link_libraries(quadratic_model_mc verdandi) +add_dependencies(quadratic_model quadratic_model_mc) + +add_executable(quadratic_model_ukf unscented_kalman_filter.cpp) +target_link_libraries(quadratic_model_ukf verdandi) +add_dependencies(quadratic_model quadratic_model_ukf) + +# add_executable(quadratic_model_hjb hjb.cpp) +# target_link_libraries(quadratic_model_hjb verdandi) +# add_dependencies(quadratic_model quadratic_model_hjb) \ No newline at end of file diff --git a/example/quadratic_model/configuration/perturbation_manager.lua b/example/quadratic_model/configuration/perturbation_manager.lua index bbefb84..ecd2152 100644 --- a/example/quadratic_model/configuration/perturbation_manager.lua +++ b/example/quadratic_model/configuration/perturbation_manager.lua @@ -15,6 +15,22 @@ perturbation_manager = { -- directory. It must end with a slash. -- seed_directory = os.getenv("HOME") .. "/.newran/" + }, + random = { + + -- Choose between + -- * "time" for machine time, + -- * "number" for a fixed seed value between 0 and 1, and + -- * "directory" to use a Newran directory which stores the seeds. + seed_type = "number", + + -- If 'seed_type' is set to "number", choose a number in ]0, 1[. + seed_number = 0.4, + + -- If 'seed_type' is set to "directory", put the path to the Newran + -- directory. It must end with a slash. + -- seed_directory = os.getenv("HOME") .. "/.newran/" + }, output = { @@ -24,4 +40,4 @@ perturbation_manager = { } -} +} \ No newline at end of file diff --git a/example/quadratic_model/ensemble_kalman_filter.cpp b/example/quadratic_model/ensemble_kalman_filter.cpp index 5fdb91e..18b7fca 100644 --- a/example/quadratic_model/ensemble_kalman_filter.cpp +++ b/example/quadratic_model/ensemble_kalman_filter.cpp @@ -32,8 +32,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; } diff --git a/example/quadratic_model/extended_kalman_filter.cpp b/example/quadratic_model/extended_kalman_filter.cpp index 5c3bdec..76dbeac 100644 --- a/example/quadratic_model/extended_kalman_filter.cpp +++ b/example/quadratic_model/extended_kalman_filter.cpp @@ -19,8 +19,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; } diff --git a/example/quadratic_model/extended_minimax_filter.cpp b/example/quadratic_model/extended_minimax_filter.cpp index e30e35a..729de59 100644 --- a/example/quadratic_model/extended_minimax_filter.cpp +++ b/example/quadratic_model/extended_minimax_filter.cpp @@ -19,8 +19,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; } diff --git a/example/quadratic_model/forward.cpp b/example/quadratic_model/forward.cpp index 1e8e036..bd97aad 100644 --- a/example/quadratic_model/forward.cpp +++ b/example/quadratic_model/forward.cpp @@ -18,8 +18,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; } diff --git a/example/quadratic_model/forward_python.cpp b/example/quadratic_model/forward_python.cpp index 0a314c0..add0717 100644 --- a/example/quadratic_model/forward_python.cpp +++ b/example/quadratic_model/forward_python.cpp @@ -16,8 +16,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; } diff --git a/example/quadratic_model/hjb.cpp b/example/quadratic_model/hjb.cpp index 8a84c81..8a231f6 100644 --- a/example/quadratic_model/hjb.cpp +++ b/example/quadratic_model/hjb.cpp @@ -19,8 +19,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; cout << mesg << endl; return 1; } diff --git a/example/quadratic_model/monte_carlo.cpp b/example/quadratic_model/monte_carlo.cpp index dc78f7f..cc45e6a 100644 --- a/example/quadratic_model/monte_carlo.cpp +++ b/example/quadratic_model/monte_carlo.cpp @@ -25,8 +25,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; } diff --git a/example/quadratic_model/nudging.cpp b/example/quadratic_model/nudging.cpp index 47b54f9..507ff61 100644 --- a/example/quadratic_model/nudging.cpp +++ b/example/quadratic_model/nudging.cpp @@ -18,8 +18,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; } diff --git a/example/quadratic_model/optimal_interpolation.cpp b/example/quadratic_model/optimal_interpolation.cpp index 00e25a0..b6cc037 100644 --- a/example/quadratic_model/optimal_interpolation.cpp +++ b/example/quadratic_model/optimal_interpolation.cpp @@ -22,8 +22,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; } diff --git a/example/quadratic_model/unscented_kalman_filter.cpp b/example/quadratic_model/unscented_kalman_filter.cpp index d35cc13..89369fc 100644 --- a/example/quadratic_model/unscented_kalman_filter.cpp +++ b/example/quadratic_model/unscented_kalman_filter.cpp @@ -19,8 +19,8 @@ int main(int argc, char** argv) if (argc != 2) { - string mesg = "Usage:\n"; - mesg += string(" ") + argv[0] + " [configuration file]"; + std::string mesg = "Usage:\n"; + mesg += std::string(" ") + argv[0] + " [configuration file]"; std::cout << mesg << std::endl; return 1; }