From 0c49afc693b616a8d1797d0ba1fe7da51e16ffdb Mon Sep 17 00:00:00 2001 From: mkirsz <marcin.kirsz@ed.ac.uk> Date: Wed, 10 Apr 2024 11:02:03 +0100 Subject: [PATCH] Example HPO compile and run basic optimisation without LAMMPS. With LAMMPS throws error. --- CMakeLists.txt | 4 ++-- examples/ex_hpo_1/ex_hpo_1.cpp | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e010ebb..6e448bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,12 +162,12 @@ add_library(tadah $<TARGET_OBJECTS:tadah.mlip.obj> $<TARGET_OBJECTS:config::rc> ) -target_link_libraries (tadah PUBLIC config::rc) +target_link_libraries(tadah PUBLIC config::rc) +target_link_libraries(tadah PUBLIC tadah.hpo) add_executable (ta-dah bin/tadah.cpp) target_link_libraries(ta-dah PRIVATE tadah) -target_link_libraries(ta-dah PRIVATE tadah.hpo) ######################################################################### if(TADAH_MARCH_NATIVE) diff --git a/examples/ex_hpo_1/ex_hpo_1.cpp b/examples/ex_hpo_1/ex_hpo_1.cpp index 7506b62..ead667b 100644 --- a/examples/ex_hpo_1/ex_hpo_1.cpp +++ b/examples/ex_hpo_1/ex_hpo_1.cpp @@ -1,13 +1,11 @@ #include <iostream> -#include <tadah/HPO/hyper_param_opti.h> #include <tadah/HPO/hpo_targets.h> -#include <tadah/HPO/lammps_scores.h> -#include <tadah/config.h> +#include <tadah/HPO/hyper_param_opti.h> +#include <tadah/HPO/glf.h> +#include <tadah/HPO/runners.h> +#include <tadah/CORE/config/config.h> #include <dlib/global_optimization/find_max_global.h> -using T = dlib::matrix<double,0,1>; -using LS = LammpsScores; - /** @file ex_hpo_1.cpp * This example shows how to optimise hyperparameters (HP) * of the model with an external minimiser. The model will be optimised @@ -91,11 +89,15 @@ using LS = LammpsScores; * https://journals.aps.org/prb/abstract/10.1103/PhysRevB.88.134101 */ int main() { + Config config("config.train"); - HPOTargets trg("targets"); +using R = LammpsRunner; +using D = GLF; +using T = dlib::matrix<double,0,1>; - HyperParamOpti<T, LS> hpo(config,trg); + HPOTargets trg("targets"); + HyperParamOpti<T, D, R> hpo(config,trg); const T lowbound = dlib::mat(trg.configmin); const T highbound = dlib::mat(trg.configmax); @@ -107,6 +109,5 @@ int main() { ); std::cout << result1.x << std::endl; std::cout << result1.y << std::endl; - return 0; } -- GitLab