Loading...
Searching...
No Matches
Structures.h
Go to the documentation of this file.
1/*
2 * Structures.h
3 *
4 * Created on: 17 Jun 2020
5 * Author: Maxim Masterov
6 * Company: SURFSara
7 */
8
9#ifndef STRUCTURES_STRUCTURES_H_
10#define STRUCTURES_STRUCTURES_H_
11
12#include <Eigen/Dense>
13#include <algorithm>
14#include <functional>
15#include <limits>
16#include <memory>
17#include <string>
18
19#include "../data_types/Coord.h"
20#include "../data_types/Field.h"
21#include "../gpr/Enums.h"
24
25namespace dimer {
26class SphereRotation;
27}
28
29namespace gpr {
30
34template <typename T>
36 std::string key;
38};
39
43template <typename T>
44struct Pair {
47};
48
52template <typename T>
53struct Triplet {
57};
58
62template <typename T>
64 T D1;
65 T D2;
66 T D12;
67};
68
72struct Indices2D {
73 Eigen::Index i;
74 Eigen::Index j;
75};
76
83
84 void setZero()
85 {
86 outer = inner = 0;
87 }
88};
89
90[[nodiscard]] constexpr bool iterationAllowedByLimit(
91 Index_t iteration, Index_t configured_limit) noexcept
92{
93 return configured_limit <= 0 || iteration < configured_limit;
94}
95
100enum class MapPriorWeightMode : uint8_t { Annealed = 0, Full = 1 };
101
105struct GPRSetup {
106 double sigma2;
108 double tol_fun;
109 double tol_X;
111 // Two-sided log-Gaussian length-scale prior centred on the per-pairtype
112 // chemistry scale (Decompose-time hierarchical prior). Was env
113 // GPR_LS_PRIOR.
115 // Marchildon-Zingg principled diagonal nugget on the (dual) kernel before
116 // factorization, bounding cond(K_tilde + eta I) <= kappa_max. Was env
117 // GPR_PRINCIPLED_NUGGET.
119 // Condition-number cap for the principled nugget. 0 (or <=1) means use
120 // detail::principledKappaMaxDefault(). Was env GPR_KAPPA_MAX.
121 double kappa_max;
122 // MAP hyperparameter prior weight mode (annealed default; full = weight 1).
123 // Applied to ScgOptimizationSettings when setParameters(GPRSetup) runs.
125 // When true, MAP optimizers use PriorSqrtt/PriorT|Gaussian params from
126 // setPriorParameters* instead of the hard-coded weakly-informative
127 // defaults. Default false so existing fits stay bit-identical.
129
131 {
132 clear();
133 }
134
135 void clear()
136 {
137 sigma2 = 0.;
138 jitter_sigma2 = 0.;
139 tol_fun = 0.;
140 tol_X = 0.;
142 ls_prior = false;
143 principled_nugget = false;
144 kappa_max = 0.;
147 }
148};
149
166
177enum class UncertaintyMode {
178 MAP = 0,
179 BMA = 1,
181 EB = 3,
182 SVGD = 4,
184};
185
201enum class GPModelProfile : uint8_t { CHEMGP = 0, GPRD_ZBL = 1, EXTENDED = 2 };
202
206[[nodiscard]] inline bool usesClassicJointEnergyForcePrior(
207 GPModelProfile profile) noexcept
208{
209 return profile == GPModelProfile::CHEMGP ||
210 profile == GPModelProfile::GPRD_ZBL;
211}
212
224 std::function<bool()> stop_requested;
225
230
232 {
233 check_derivative = false;
234 report_level = 1;
235 max_iter = 400;
236 tolerance_func = 1e-4;
237 tolerance_sol = 1e-4;
238 stop_requested = {};
239 }
240};
241
249 double lambda;
280 std::vector<bool> active_parameters;
281
286
309};
310
318 double beta1;
319 double beta2;
320 double epsilon;
323
328
330 {
331 common.setDefault();
332 // NOTE(rg): Generally a high learning rate here is fine, just need to
333 // reach a low value, fast
334 learning_rate = 1e-1; // from PyTorch
335 learning_rate_decay = 0.99;
336 beta1 = 0.9;
337 beta2 = 0.999;
338 epsilon = 1.0e-8;
339 weight_decay = 0.1;
340 amsgrad = true;
341 }
342};
343
355
360 double& energy;
361 Eigen::VectorXd& gradient;
362 EnergyAndGradient(double& e, Eigen::VectorXd& g)
363 : energy(e), gradient(g) { }
364};
365
371 KeyValuePair<int> i_dist = {"i_dist", 0};
372 KeyValuePair<int> i_run = {"i_run", 0};
373
374 KeyValuePair<double[4]> dist_sp = {"dist_sp", {0., 0., 0., 0.}};
375
379 KeyValuePair<double> actdist_fro = {"actdist_fro", 5.0};
380 KeyValuePair<int> evict_frozen = {"evict_frozen", 0};
381 KeyValuePair<int> nn_frozen = {"nn_frozen", 0};
382 KeyValuePair<int> nn_auto = {"nn_auto", 1};
383
387 KeyValuePair<double*> R_all_init = {"R_all_init", nullptr};
388
392 KeyValuePair<double*> E_all_init = {"E_all_init", nullptr};
393
397 KeyValuePair<double*> G_all_init = {"G_all_init", nullptr};
398
402 KeyValuePair<double[3]> R_init = {"R_init", {0., 0., 0.}};
403
408 KeyValuePair<double> E_init = {"E_init", 0.};
409
414 KeyValuePair<double[3]> G_init = {"G_init", {0., 0., 0.}};
415
419 KeyValuePair<double[3]> orient_init = {"orient_init", {0., 0., 0.}};
420
425 KeyValuePair<double> dimer_sep = {"dimer_sep", 0.};
426
430 KeyValuePair<std::string> method_rot = {"method_rot", "none"};
431
435 KeyValuePair<std::string> method_trans = {"method_trans", "none"};
436
440 KeyValuePair<double[2]> param_trans = {"param_trans", {0., 0.}};
441
446 KeyValuePair<int> eval_image1 = {"eval_image1", 0};
447
453 KeyValuePair<double> T_dimer = {"T_dimer", 0.};
454
461 KeyValuePair<int> convergence_force_norm = {"convergence_force_norm", 0};
462
467 KeyValuePair<int> initrot_nogp = {"initrot_nogp", 0};
468
474 KeyValuePair<double> T_anglerot_init = {"T_anglerot_init", 0.};
475
479 KeyValuePair<int> num_iter_initrot = {"num_iter_initrot", 0};
480
484 KeyValuePair<double> T_anglerot_gp = {"T_anglerot_gp", 0.};
485
490 KeyValuePair<int> num_iter_rot_gp = {"num_iter_rot_gp", 0};
491
498 KeyValuePair<int> divisor_T_dimer_gp = {"divisor_T_dimer_gp", 0};
499
505 KeyValuePair<double> disp_max = {"disp_max", 0.};
506
512 KeyValuePair<double> ratio_at_limit = {"ratio_at_limit", 0.};
513
519 KeyValuePair<int> num_bigiter_initloc = {"num_bigiter_initloc", 0};
520
527 KeyValuePair<int> num_bigiter_initparam = {"num_bigiter_initparam", 0};
528
532 KeyValuePair<int> num_bigiter = {"num_bigiter", 0};
533
537 KeyValuePair<int> num_iter = {"num_iter", 0};
538
544 KeyValuePair<int> islarge_num_iter = {"islarge_num_iter", 0};
545
550 KeyValuePair<std::string> load_file = {"load_file", "none"};
551
556 KeyValuePair<std::string> save_file = {"save_file", "none"};
557
558 /* * --- FOR PRUNE * */
559 /*
560 * Activation
561 */
562 KeyValuePair<bool> use_prune = {"use_prune", false};
563
566 KeyValuePair<bool> use_precision = {"use_precision", false};
567
571 KeyValuePair<int> start_prune_at = {"start_prune_at", 10};
572
576 KeyValuePair<int> nprune_vals = {"nprune_vals", 3};
577
581 KeyValuePair<double> prune_threshold = {"prune_threshold", 0.5};
582
583 /* * --- FOR DEBUGGING * */
584 KeyValuePair<std::string> debug_output_dir = {"debug_output_dir", "output"};
586 "position"};
588 "energy"};
590 "gradient"};
592 "debug_output_file_extension", "dat"};
594 "debug_offset_from_mid_point", 3.};
595 KeyValuePair<double> debug_dy = {"debug_dy", 0.1};
596 KeyValuePair<double> debug_dz = {"debug_dz", 0.1};
597 KeyValuePair<int> debug_level = {"debug_level", 0};
598
599 KeyValuePair<std::string> pot_general = {"pot_general", "none"};
600 KeyValuePair<std::string*> conf_info = {"conf_info", nullptr};
602 nullptr};
603 KeyValuePair<int> gp_nonperiodic = {"gp_nonperiodic", 0};
604
606 "cell_dimensions", {0., 0., 0., 0., 0., 0., 0., 0., 0.}};
607
610 KeyValuePair<int[3]> cell_periodic = {"cell_periodic", {1, 1, 1}};
611
612 KeyValuePair<double> gp_sigma2 = {"gp_sigma2", 0.};
613 KeyValuePair<double> jitter_sigma2 = {"jitter_sigma2", 0.};
615 "SCG_opt"};
616 KeyValuePair<double> sigma2 = {"sigma2", 0.};
617 KeyValuePair<double> magnSigma2 = {"magnSigma2", 0.};
618 KeyValuePair<double> constSigma2 = {"constSigma2", 0.};
619 KeyValuePair<bool> use_alpha_k_predict_mean = {"use_alpha_k_predict_mean",
620 true};
621 KeyValuePair<bool> use_alpha_k_laplace_mean = {"use_alpha_k_laplace_mean",
622 true};
624 "laplace_skip_scg_threshold", 0.0};
626 "use_training_geometry_handle", true};
627 KeyValuePair<bool> use_rigid_null_deflation = {"use_rigid_null_deflation",
628 false};
629 KeyValuePair<bool> profile_predict_mean = {"profile_predict_mean", false};
630 KeyValuePair<bool> profile_energy_split = {"profile_energy_split", false};
631 KeyValuePair<bool> profile_gradient_split = {"profile_gradient_split",
632 false};
633 KeyValuePair<bool> profile_dimer_times = {"profile_dimer_times", false};
634 KeyValuePair<bool> log_training_geometry = {"log_training_geometry", false};
635 KeyValuePair<bool> log_rank_block_cholesky = {"log_rank_block_cholesky",
636 false};
637 KeyValuePair<int> scalapack_block_size = {"scalapack_block_size", 0};
638 KeyValuePair<int> scalapack_nprow = {"scalapack_nprow", 0};
639 KeyValuePair<std::string> cutlass_plugin_path = {"cutlass_plugin_path", ""};
640
641 // Zero is not a sentinel. PriorSqrtt and PriorT divide by nu and s2,
642 // and initialize rejects a non-positive value. initialize() copies this
643 // (prior_mu, prior_nu, prior_s2) triple onto the Student-t magnitude,
644 // Gaussian length-scale, and log-normal priors as their initial
645 // parameters; data-bearing setHyperparameters() then overwrites
646 // Student-t s2 with target_variance and Gaussian s2 with
647 // seed_length_scale_^2 rather than keeping a single shared scale.
648 KeyValuePair<double> prior_mu = {"prior_mu", 0.};
649 KeyValuePair<double> prior_nu = {"prior_nu", 20.};
650 KeyValuePair<double> prior_s2 = {"prior_s2", 1.};
651
654 KeyValuePair<double> es_threshold = {"es_threshold", 1.2};
655 KeyValuePair<bool> es_use_adaptive_threshold = {"es_use_adaptive_threshold",
656 false};
657 KeyValuePair<double> es_adaptive_A = {"es_adaptive_A", 1.3};
658 KeyValuePair<double> es_adaptive_floor = {"es_adaptive_floor", 0.25};
659 KeyValuePair<double> es_t_min = {"es_t_min", 0.15};
660 KeyValuePair<double> es_delta_explore = {"es_delta_explore", 0.35};
661 KeyValuePair<int> es_half_life = {"es_half_life", 50};
662
665 KeyValuePair<int> fps_history = {"fps_history", 5};
666
668 "rotation_removal_projection_threshold",
669 std::numeric_limits<double>::infinity()};
670 KeyValuePair<std::string> rot_opt = {"rot_opt", "lbfgs"};
671
672 KeyValuePair<std::string> check_derivative = {"check_derivative", "false"};
673 KeyValuePair<int> report_level = {"report_level", 1};
674 KeyValuePair<int> max_iter = {"max_iter", 400};
675 KeyValuePair<double> tolerance_func = {"tolerance_func", 1e-4};
676 KeyValuePair<double> tolerance_sol = {"tolerance_sol", 1e-4};
677 KeyValuePair<double> lambda_limit = {"lambda_limit", 1e20};
678 KeyValuePair<double> lambda = {"lambda", 10.};
679 KeyValuePair<std::string> curvature_mode = {"curvature_mode", "exact"};
680 KeyValuePair<double> learning_rate = {"learning_rate", 0.8};
681 KeyValuePair<double> learning_rate_decay = {"learning_rate_decay", 0.999};
682 KeyValuePair<double> beta1 = {"beta1", 0.9};
683 KeyValuePair<double> beta2 = {"beta2", 0.99};
684 KeyValuePair<double> epsilon = {"epsilon", 1.0e-8};
685 KeyValuePair<double> weight_decay = {"weight_decay", 0.0};
686 KeyValuePair<bool> amsgrad = {"amsgrad", true};
687
688 void print()
689 {
690 io::LogManager log_man;
691
692 log_man << i_dist.key << " : " << i_dist.value << "\n";
693 log_man << i_run.key << " : " << i_run.value << "\n";
694 log_man << dist_sp.key << " : " << dist_sp.value[0] << " "
695 << dist_sp.value[1] << " " << dist_sp.value[2] << " "
696 << dist_sp.value[3] << "\n";
697 log_man << actdist_fro.key << " : " << actdist_fro.value << "\n";
698 log_man << dimer_sep.key << " : " << dimer_sep.value << "\n";
699 log_man << method_rot.key << " : " << method_rot.value << "\n";
700 log_man << method_trans.key << " : " << method_trans.value << "\n";
701 log_man << param_trans.key << " : " << param_trans.value[0] << " "
702 << param_trans.value[1] << "\n";
703 log_man << eval_image1.key << " : " << eval_image1.value << "\n";
704 log_man << T_dimer.key << " : " << T_dimer.value << "\n";
705 log_man << initrot_nogp.key << " : " << initrot_nogp.value << "\n";
706 log_man << T_anglerot_init.key << " : " << T_anglerot_init.value
707 << "\n";
708 log_man << num_iter_initrot.key << " : " << num_iter_initrot.value
709 << "\n";
710 log_man << T_anglerot_gp.key << " : " << T_anglerot_gp.value << "\n";
711 log_man << num_iter_rot_gp.key << " : " << num_iter_rot_gp.value
712 << "\n";
713 log_man << divisor_T_dimer_gp.key << " : " << divisor_T_dimer_gp.value
714 << "\n";
715 log_man << disp_max.key << " : " << disp_max.value << "\n";
716 log_man << ratio_at_limit.key << " : " << ratio_at_limit.value << "\n";
717 log_man << num_bigiter.key << " : " << num_bigiter.value << "\n";
718 log_man << num_iter.key << " : " << num_iter.value << "\n";
719 log_man << islarge_num_iter.key << " : " << islarge_num_iter.value
720 << "\n";
721 log_man << load_file.key << " : " << load_file.value << "\n";
722 log_man << save_file.key << " : " << save_file.value << "\n";
723
724 log_man << debug_output_dir.key << " : " << debug_output_dir.value
725 << "\n";
726 log_man << debug_output_file_R.key << " : " << debug_output_file_R.value
727 << "\n";
728 log_man << debug_output_file_E.key << " : " << debug_output_file_E.value
729 << "\n";
730 log_man << debug_output_file_G.key << " : " << debug_output_file_G.value
731 << "\n";
732 log_man << debug_output_file_extension.key << " : "
733 << debug_output_file_extension.value << "\n";
734 log_man << debug_offset_from_mid_point.key << " : "
735 << debug_offset_from_mid_point.value << "\n";
736 log_man << debug_dy.key << " : " << debug_dy.value << "\n";
737 log_man << debug_dz.key << " : " << debug_dz.value << "\n";
738 log_man << debug_level.key << " : " << (int)debug_level.value << "\n";
739
740 log_man << cell_dimensions.key << " : " << cell_dimensions.value[0]
741 << " " << cell_dimensions.value[1] << " "
742 << cell_dimensions.value[2] << " " << cell_dimensions.value[3]
743 << " " << cell_dimensions.value[4] << " "
744 << cell_dimensions.value[5] << " " << cell_dimensions.value[6]
745 << " " << cell_dimensions.value[7] << " "
746 << cell_dimensions.value[8] << "\n";
747
748 log_man << use_precision.key << " : " << use_precision.value << "\n";
749 log_man << gp_sigma2.key << " : " << gp_sigma2.value << "\n";
750 log_man << jitter_sigma2.key << " : " << jitter_sigma2.value << "\n";
751 log_man << optimization_alg.key << " : " << optimization_alg.value
752 << "\n";
753
754 log_man << sigma2.key << " : " << sigma2.value << "\n";
755 log_man << magnSigma2.key << " : " << magnSigma2.value << "\n";
756 log_man << constSigma2.key << " : " << constSigma2.value << "\n";
757 log_man << use_alpha_k_predict_mean.key << " : "
758 << use_alpha_k_predict_mean.value << "\n";
759 log_man << use_alpha_k_laplace_mean.key << " : "
760 << use_alpha_k_laplace_mean.value << "\n";
761 log_man << laplace_skip_scg_threshold.key << " : "
762 << laplace_skip_scg_threshold.value << "\n";
763 log_man << use_training_geometry_handle.key << " : "
764 << use_training_geometry_handle.value << "\n";
765 log_man << profile_predict_mean.key << " : "
766 << profile_predict_mean.value << "\n";
767 log_man << profile_energy_split.key << " : "
768 << profile_energy_split.value << "\n";
769 log_man << profile_gradient_split.key << " : "
770 << profile_gradient_split.value << "\n";
771 log_man << profile_dimer_times.key << " : " << profile_dimer_times.value
772 << "\n";
773 log_man << log_training_geometry.key << " : "
774 << log_training_geometry.value << "\n";
775 log_man << log_rank_block_cholesky.key << " : "
776 << log_rank_block_cholesky.value << "\n";
777 log_man << scalapack_block_size.key << " : "
778 << scalapack_block_size.value << "\n";
779 log_man << scalapack_nprow.key << " : " << scalapack_nprow.value
780 << "\n";
781 log_man << cutlass_plugin_path.key << " : " << cutlass_plugin_path.value
782 << "\n";
783
784 log_man << prior_mu.key << " : " << prior_mu.value << "\n";
785 log_man << prior_nu.key << " : " << prior_nu.value << "\n";
786 log_man << prior_s2.key << " : " << prior_s2.value << "\n";
787
788 log_man << check_derivative.key << " : " << check_derivative.value
789 << "\n";
790 log_man << report_level.key << " : " << report_level.value << "\n";
791 log_man << max_iter.key << " : " << max_iter.value << "\n";
792 log_man << tolerance_func.key << " : " << tolerance_func.value << "\n";
793 log_man << tolerance_sol.key << " : " << tolerance_sol.value << "\n";
794 log_man << lambda_limit.key << " : " << lambda_limit.value << "\n";
795 log_man << lambda.key << " : " << lambda.value << "\n";
796 log_man << curvature_mode.key << " : " << curvature_mode.value << "\n";
797
798 log_man << start_prune_at.key << " : " << start_prune_at.value << "\n";
799 log_man << nprune_vals.key << " : " << nprune_vals.value << "\n";
800 log_man << prune_threshold.key << " : " << prune_threshold.value
801 << "\n";
802 log_man << use_rigid_null_deflation.key << " : "
803 << use_rigid_null_deflation.value << "\n";
804 }
805};
806
813
814 void resize(const Index_t num_atoms)
815 {
816 positions.resize(1, num_atoms * 3);
817 positions.setZero();
818 type.resize(1, num_atoms);
819 type.setZero();
820 }
821
822 void clear()
823 {
824 positions.resize(0, 0);
825 type.resize(0, 0);
826 }
827};
828
837 Eigen::VectorXd
840
845
854 std::vector<Index_t> pair_type_parent;
856
861 double cell[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.};
862
865 double pair_cutoff = 0.0;
866 double pair_cutoff_width = 0.0;
867
873 bool evict_frozen = false;
881 bool nn_auto = true;
882
891 {
892 if (nn_auto && nn_frozen == 0 && !evict_frozen) {
893 const Index_t n =
894 static_cast<Index_t>(atoms_froz_active.positions.cols() / 3);
895 if (n > 0) nn_frozen = n;
896 }
897 }
898
903 {
904#ifndef NDEBUG
905 assertMsg(field.size() != 0, "The reference field cannot be empty!");
906 assertMsg(field.cols() >= 5,
907 "The reference field should have 5 or more columns!");
908#endif
909
910 Index_t counter = 0;
911
912 positions.resize(1, 3 * field.rows());
913 positions.setZero();
914 is_frozen.resize(1, field.rows());
915 is_frozen.setZero();
916 id.resize(1, field.rows());
917 id.setZero();
918
919 for (Eigen::Index i = 0; i < field.rows(); ++i) {
920 for (Eigen::Index j = 0; j < 3; ++j) {
921 *(positions.data() + counter++) = field(i, j);
922 }
923 if (field(i, 3) == 0)
924 *(is_frozen.data() + i) = MOVING_ATOM;
925 else
926 *(is_frozen.data() + i) = FROZEN_ATOM;
927 *(id.data() + i) = static_cast<Index_t>(field(i, 4));
928 }
929 }
930
931 void clear()
932 {
933 positions.resize(0, 0);
934 is_frozen.resize(0, 0);
935 id.resize(0, 0);
936 atomicNrs.resize(0, 0);
937 atomic_masses.resize(0);
938 type.resize(0, 0);
939 atoms_froz_active.clear();
940 atoms_froz_inactive.clear();
941 atoms_mov.clear();
942 pairtype.resize(0, 0);
943 n_pt = 0;
944 for (int i = 0; i < 9; ++i)
945 cell[i] = 0.0;
946 pair_cutoff = 0.0;
947 pair_cutoff_width = 0.0;
948 }
949
951 {
952 atoms_froz_active.clear();
953 atoms_froz_inactive.clear();
954 atoms_mov.clear();
955 pairtype.resize(0, 0);
956 n_pt = 0;
957 }
958
959 void copy(const AtomsConfiguration& other)
960 {
961 *this = other;
962 }
963
965 {
966 Index_t count = 0;
967 for (Eigen::Index i = 0; i < is_frozen.size(); ++i) {
968 if (*(is_frozen.data() + i) == MOVING_ATOM) ++count;
969 }
970 return count;
971 }
972};
973
977struct LBFGSInfo {
979 std::shared_ptr<dimer::SphereRotation> sphere_rotation;
980
986
987 void clear()
988 {
989 sphere_rotation.reset();
990 num_cg_iter = 0;
991 num_lbfgs_iter = 0;
992 }
993
994 // For debugging
995 void print()
996 {
997 io::LogManager log_man;
998
999 log_man << "num_cg_iter: " << num_cg_iter << "\n";
1000 log_man << "num_lbfgs_iter: " << num_lbfgs_iter << "\n";
1001 }
1002};
1003
1012
1017 double force = 0.;
1018 double angle_rotation = 0.;
1019
1020 void clear()
1021 {
1022 force = angle_rotation = 0.;
1023 }
1024};
1025
1033
1034 void clear()
1035 {
1036 R.resize(0, 0);
1037 E.resize(0, 0);
1038 G.resize(0, 0);
1039 }
1040
1041 void append(const Observation& other)
1042 {
1043 gpr::field::appendRows(R, other.R);
1044 gpr::field::appendRows(E, other.E);
1045 gpr::field::appendRows(G, other.G);
1046 }
1047
1048 void resizeToMatch(const Observation& other, const Index_t num_rows)
1049 {
1050 R.resize(num_rows, other.R.cols());
1051 R.setZero();
1052 E.resize(num_rows, other.E.cols());
1053 E.setZero();
1054 G.resize(num_rows, other.G.cols());
1055 G.setZero();
1056 }
1057
1058 void copyRow(const Index_t dest_row_idx, const Observation& other,
1059 const Index_t src_row_idx)
1060 {
1061 R.row(dest_row_idx) = other.R.row(src_row_idx);
1062 E.row(dest_row_idx) = other.E.row(src_row_idx);
1063 G.row(dest_row_idx) = other.G.row(src_row_idx);
1064 }
1065
1066 // for debugging
1068 {
1069 io::LogManager log_man;
1070
1071 log_man << "R size: " << R.size() << "\n";
1072 log_man << "R (rows, cols): " << R.rows() << " " << R.cols() << "\n\n";
1073
1074 log_man << "E size: " << E.size() << "\n";
1075 log_man << "E (rows, cols): " << E.rows() << " " << E.cols() << "\n\n";
1076
1077 log_man << "G size: " << G.size() << "\n";
1078 log_man << "G (rows, cols): " << G.rows() << " " << G.cols() << "\n\n";
1079 }
1080};
1081
1087 std::string out_dir = "output";
1088 std::string file_name_R = "position";
1089 std::string file_name_E = "energy";
1090 std::string file_name_G = "gradient";
1091 std::string file_extension = "dat";
1092 double offset = 3.;
1093 double dy = 0.1;
1094 double dz = 0.1;
1096};
1097
1098} /* namespace gpr */
1099
1100#endif /* STRUCTURES_STRUCTURES_H_ */
@ DEBUG_L0
Definition Enums.h:40
@ FROZEN_ATOM
Definition Enums.h:36
@ MOVING_ATOM
Definition Enums.h:35
#define assertMsg(expression, msg)
Responsible for logging.
Definition LogManager.h:28
void appendRows(Eigen::PlainObjectBase< Derived > &mat, const Eigen::PlainObjectBase< Derived > &other)
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16
ScgCurvatureMode
Selects how SCG computes the directional curvature term.
Definition Structures.h:161
MapPriorWeightMode
Definition Structures.h:100
Eigen::Matrix< int, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixi
Definition Macros.h:27
Eigen::Matrix< Index_t, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixIdx
Definition Macros.h:29
FieldMatrixd Coord
Definition Macros.h:35
bool usesClassicJointEnergyForcePrior(GPModelProfile profile) noexcept
Definition Structures.h:206
uint32_t Index_t
Definition Macros.h:17
constexpr bool iterationAllowedByLimit(Index_t iteration, Index_t configured_limit) noexcept
Definition Structures.h:90
Eigen::Matrix< uint8_t, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixU8
Definition Macros.h:31
GPModelProfile
Definition Structures.h:201
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
Definition Macros.h:25
UncertaintyMode
Definition Structures.h:177
OptimizerCommonSettings common
Definition Structures.h:315
Stores configurations of all atoms in the system.
Definition Structures.h:832
std::vector< Index_t > pair_type_parent
Definition Structures.h:854
void seedNearestNeighbourFromActive()
Seed the fixed-N nearest-neighbour set from the current active (radius-activated) frozen count....
Definition Structures.h:890
FieldMatrixi atomicNrs
Atomic Number of each atom.
Definition Structures.h:836
AtomsPositionAndType atoms_froz_inactive
Info on inactive frozen atoms.
Definition Structures.h:843
FieldMatrixU8 is_frozen
Indicates whether atom is frozen or not.
Definition Structures.h:834
void assignFromField(const FieldMatrixd &field)
Extract data from a 5-column field.
Definition Structures.h:902
FieldMatrixIdx id
ID of each atom (we do not use it).
Definition Structures.h:835
AtomsPositionAndType atoms_froz_active
Info on active frozen atoms.
Definition Structures.h:841
Index_t n_base_pt
Number of base pair types (0: none).
Definition Structures.h:855
AtomsPositionAndType atoms_mov
Info on moving atoms.
Definition Structures.h:844
void copy(const AtomsConfiguration &other)
Definition Structures.h:959
FieldMatrixIdx type
Type of each atom.
Definition Structures.h:839
Coord positions
Positions of all atoms in the system.
Definition Structures.h:833
Eigen::VectorXd atomic_masses
Per-atom input masses; empty selects unit masses.
Definition Structures.h:838
Structure of atoms positions and types.
Definition Structures.h:810
void resize(const Index_t num_atoms)
Definition Structures.h:814
OptimizerCommonSettings common
Definition Structures.h:348
Structure of directional derivatives.
Definition Structures.h:63
EnergyAndGradient(double &e, Eigen::VectorXd &g)
Definition Structures.h:362
Eigen::VectorXd & gradient
Definition Structures.h:361
A structure with information used to write the energy surface to a file.
uint8_t optimization_alg
Definition Structures.h:110
bool map_use_configured_priors
Definition Structures.h:128
double kappa_max
Definition Structures.h:121
bool principled_nugget
Definition Structures.h:118
double jitter_sigma2
Definition Structures.h:107
MapPriorWeightMode map_prior_weight_mode
Definition Structures.h:124
Structure of pair of indices.
Definition Structures.h:72
Eigen::Index j
Definition Structures.h:74
Eigen::Index i
Definition Structures.h:73
Structure of the input parameters. All input parameters are pairs of string names and values.
Definition Structures.h:370
KeyValuePair< double[2]> param_trans
Definition Structures.h:440
KeyValuePair< bool > log_rank_block_cholesky
Definition Structures.h:635
KeyValuePair< double * > E_all_init
Definition Structures.h:392
KeyValuePair< double > T_anglerot_gp
Definition Structures.h:484
KeyValuePair< double > prior_s2
Definition Structures.h:650
KeyValuePair< double > es_t_min
Definition Structures.h:659
KeyValuePair< double > laplace_skip_scg_threshold
Definition Structures.h:623
KeyValuePair< std::string > pot_general
Definition Structures.h:599
KeyValuePair< std::string > debug_output_file_G
Definition Structures.h:589
KeyValuePair< int > max_iter
Definition Structures.h:674
KeyValuePair< int > i_dist
Definition Structures.h:371
KeyValuePair< std::string * > conf_info_inactive
Definition Structures.h:601
KeyValuePair< int > initrot_nogp
Definition Structures.h:467
KeyValuePair< DistanceMetricType > es_dist_metric
Definition Structures.h:652
KeyValuePair< bool > use_rigid_null_deflation
Definition Structures.h:627
KeyValuePair< std::string > optimization_alg
Definition Structures.h:614
KeyValuePair< bool > es_use_adaptive_threshold
Definition Structures.h:655
KeyValuePair< double[9]> cell_dimensions
Definition Structures.h:605
KeyValuePair< double > dimer_sep
Definition Structures.h:425
KeyValuePair< int > start_prune_at
Definition Structures.h:571
KeyValuePair< int > islarge_num_iter
Definition Structures.h:544
KeyValuePair< double > lambda
Definition Structures.h:678
KeyValuePair< double[3]> G_init
Definition Structures.h:414
KeyValuePair< int > fps_history
Definition Structures.h:665
KeyValuePair< double > prior_nu
Definition Structures.h:649
KeyValuePair< int > report_level
Definition Structures.h:673
KeyValuePair< double > rotation_removal_projection_threshold
Definition Structures.h:667
KeyValuePair< int > nn_frozen
Definition Structures.h:381
KeyValuePair< double > T_anglerot_init
Definition Structures.h:474
KeyValuePair< double > learning_rate_decay
Definition Structures.h:681
KeyValuePair< int > scalapack_nprow
Definition Structures.h:638
KeyValuePair< double > jitter_sigma2
Definition Structures.h:613
KeyValuePair< std::string > debug_output_dir
Definition Structures.h:584
KeyValuePair< int > scalapack_block_size
Definition Structures.h:637
KeyValuePair< double > ratio_at_limit
Definition Structures.h:512
KeyValuePair< double > E_init
Definition Structures.h:408
KeyValuePair< int > debug_level
Definition Structures.h:597
KeyValuePair< std::string > method_trans
Definition Structures.h:435
KeyValuePair< double > weight_decay
Definition Structures.h:685
KeyValuePair< double > beta2
Definition Structures.h:683
KeyValuePair< double > debug_dz
Definition Structures.h:596
KeyValuePair< int > gp_nonperiodic
Definition Structures.h:603
KeyValuePair< std::string > rot_opt
Definition Structures.h:670
KeyValuePair< double > prune_threshold
Definition Structures.h:581
KeyValuePair< double[3]> R_init
Definition Structures.h:402
KeyValuePair< DistanceMetricType > fps_metric
Definition Structures.h:663
KeyValuePair< double > beta1
Definition Structures.h:682
KeyValuePair< double > es_delta_explore
Definition Structures.h:660
KeyValuePair< int > nprune_vals
Definition Structures.h:576
KeyValuePair< int > num_bigiter_initloc
Definition Structures.h:519
KeyValuePair< int > nn_auto
Definition Structures.h:382
KeyValuePair< int > convergence_force_norm
Definition Structures.h:461
KeyValuePair< bool > use_training_geometry_handle
Definition Structures.h:625
KeyValuePair< bool > profile_gradient_split
Definition Structures.h:631
KeyValuePair< double > actdist_fro
Definition Structures.h:379
KeyValuePair< double > epsilon
Definition Structures.h:684
KeyValuePair< int > num_bigiter_initparam
Definition Structures.h:527
KeyValuePair< std::string > method_rot
Definition Structures.h:430
KeyValuePair< double > constSigma2
Definition Structures.h:618
KeyValuePair< bool > use_prune
Definition Structures.h:562
KeyValuePair< int > divisor_T_dimer_gp
Definition Structures.h:498
KeyValuePair< double > learning_rate
Definition Structures.h:680
KeyValuePair< int > num_iter
Definition Structures.h:537
KeyValuePair< int > num_iter_initrot
Definition Structures.h:479
KeyValuePair< int > eval_image1
Definition Structures.h:446
KeyValuePair< double > lambda_limit
Definition Structures.h:677
KeyValuePair< double > debug_offset_from_mid_point
Definition Structures.h:593
KeyValuePair< double > disp_max
Definition Structures.h:505
KeyValuePair< double > tolerance_func
Definition Structures.h:675
KeyValuePair< bool > use_precision
Definition Structures.h:566
KeyValuePair< std::string > check_derivative
Definition Structures.h:672
KeyValuePair< bool > profile_dimer_times
Definition Structures.h:633
KeyValuePair< std::string > cutlass_plugin_path
Definition Structures.h:639
KeyValuePair< std::string > debug_output_file_E
Definition Structures.h:587
KeyValuePair< double[4]> dist_sp
Definition Structures.h:374
KeyValuePair< double > es_adaptive_A
Definition Structures.h:657
KeyValuePair< bool > profile_energy_split
Definition Structures.h:630
KeyValuePair< int > es_half_life
Definition Structures.h:661
KeyValuePair< std::string > load_file
Definition Structures.h:550
KeyValuePair< double * > R_all_init
Definition Structures.h:387
KeyValuePair< bool > log_training_geometry
Definition Structures.h:634
KeyValuePair< bool > use_alpha_k_laplace_mean
Definition Structures.h:621
KeyValuePair< bool > use_alpha_k_predict_mean
Definition Structures.h:619
KeyValuePair< std::string > debug_output_file_extension
Definition Structures.h:591
KeyValuePair< double * > G_all_init
Definition Structures.h:397
KeyValuePair< double > tolerance_sol
Definition Structures.h:676
KeyValuePair< double > prior_mu
Definition Structures.h:648
KeyValuePair< int > num_bigiter
Definition Structures.h:532
KeyValuePair< double > sigma2
Definition Structures.h:616
KeyValuePair< std::string > curvature_mode
Definition Structures.h:679
KeyValuePair< std::string * > conf_info
Definition Structures.h:600
KeyValuePair< bool > profile_predict_mean
Definition Structures.h:629
KeyValuePair< int > i_run
Definition Structures.h:372
KeyValuePair< int[3]> cell_periodic
Definition Structures.h:610
KeyValuePair< double > magnSigma2
Definition Structures.h:617
KeyValuePair< bool > amsgrad
Definition Structures.h:686
KeyValuePair< double > es_threshold
Definition Structures.h:654
KeyValuePair< double > debug_dy
Definition Structures.h:595
KeyValuePair< std::string > debug_output_file_R
Definition Structures.h:585
KeyValuePair< double > gp_sigma2
Definition Structures.h:612
KeyValuePair< double > es_adaptive_floor
Definition Structures.h:658
KeyValuePair< double > T_dimer
Definition Structures.h:453
KeyValuePair< int > num_iter_rot_gp
Definition Structures.h:490
KeyValuePair< double[3]> orient_init
Definition Structures.h:419
KeyValuePair< int > evict_frozen
Definition Structures.h:380
KeyValuePair< std::string > save_file
Definition Structures.h:556
Structure of limits for iterational loops.
Definition Structures.h:80
Structure of a string key and template value.
Definition Structures.h:35
std::string key
Definition Structures.h:36
Structure with information for the LBFGS method.
Definition Structures.h:977
Index_t num_cg_iter
Definition Structures.h:981
Index_t num_lbfgs_iter
Definition Structures.h:984
std::shared_ptr< dimer::SphereRotation > sphere_rotation
A copied history starts an independent sphere solve when written.
Definition Structures.h:979
Observation data: energy, gradient and positions.
void resizeToMatch(const Observation &other, const Index_t num_rows)
FieldMatrixd E
void append(const Observation &other)
void copyRow(const Index_t dest_row_idx, const Observation &other, const Index_t src_row_idx)
Settings shared by every hyperparameter optimizer.
Definition Structures.h:216
std::function< bool()> stop_requested
Definition Structures.h:224
A simple pair with identical datatypes.
Definition Structures.h:44
MapPriorWeightMode map_prior_weight_mode
Annealed (default) or full prior weight; see MapPriorWeightMode.
Definition Structures.h:255
OptimizerCommonSettings common
Definition Structures.h:247
ScgCurvatureMode curvature_mode
Definition Structures.h:252
std::vector< bool > active_parameters
Definition Structures.h:280
Stores stop criteria for dimer method (e.g. LBFGS).
Structure of translation parameters.
A simple triplet with identical datatypes.
Definition Structures.h:53