1#ifndef XPED_IMAG_OPTS_H_
2#define XPED_IMAG_OPTS_H_
6#include "yas/serialize.hpp"
7#include "yas/std_types.hpp"
12#include <boost/describe.hpp>
24 std::vector<double>
dts;
29BOOST_DEFINE_ENUM_CLASS(Update, SIMPLE, FULL, CLUSTER)
33 std::vector<std::size_t> Ds = {2ul, 3ul, 4ul};
34 std::vector<std::vector<std::size_t>> chis = {{20ul}, {30ul}, {40ul}};
36 std::vector<std::size_t> t_steps = {100ul, 100ul, 100ul, 100ul, 100ul, 100ul, 100ul, 100ul, 100ul};
37 std::vector<double> dts = {0.1, 0.05, 0.01, 0.005, 0.001, 0.0005, 0.0001, 0.00005, 0.00001};
39 Update update = Update::SIMPLE;
41 std::size_t max_steps = 50;
42 std::size_t min_steps = 0;
48 std::string load =
"";
49 LoadFormat load_format = LoadFormat::NATIVE;
52 std::size_t seed = 0ul;
56 Verbosity verbosity = Verbosity::ON_ENTRY;
58 std::filesystem::path working_directory = std::filesystem::current_path();
59 std::filesystem::path logging_directory =
"logs";
60 std::string log_format =
".log";
62 std::filesystem::path obs_directory =
"obs";
63 bool display_obs =
true;
65 bool multi_init =
false;
66 std::vector<std::size_t> init_seeds = {0, 1, 2};
67 std::vector<std::size_t> init_Ds = {2ul, 3ul, 2ul};
68 std::vector<std::size_t> init_t_steps = {40ul, 40ul, 40ul};
69 std::vector<double> init_dts = {0.1, 0.01, 0.001};
70 std::size_t init_chi = 28;
72 template <
typename Ar>
75 ar& YAS_OBJECT_NVP(
"ImagOpts",
80 (
"max_steps", max_steps),
81 (
"min_steps", min_steps),
84 (
"verbosity", verbosity),
85 (
"working_directory", working_directory),
86 (
"logging_directory", logging_directory),
87 (
"log_format", log_format),
88 (
"obs_directory", obs_directory),
90 (
"load format", load_format),
93 (
"display_obs", display_obs),
94 (
"qn_scale", qn_scale),
95 (
"multi_init", multi_init),
96 (
"init_t_steps", init_t_steps),
97 (
"init_dts", init_dts),
98 (
"init_seeds", init_seeds),
100 (
"init_chi", init_chi));
101 assert(Ds.size() == chis.size());
102 assert(dts.size() == t_steps.size());
108 fmt::format_to(std::back_inserter(res),
"{}:\n", fmt::styled(
"Imaginary time-evolution options", fmt::emphasis::bold));
109 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• Ds:", Ds);
110 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• chis:", chis);
111 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• t_steps:", t_steps);
112 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• dts:", dts);
113 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• update:", fmt::streamed(update));
114 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• maximum time steps:", max_steps);
115 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• minimum time steps:", min_steps);
116 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• tolerance:", tol);
117 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• resume:", resume);
118 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• log format:", log_format);
119 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• working directory:", working_directory.string());
120 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• logging directory:", logging_directory.string());
121 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• obs directory:", obs_directory.string());
122 if(load.size() > 0) { fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• load from:", load); }
123 if(load.size() > 0) { fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• scale loaded qn by:", qn_scale); }
124 if(load.size() > 0) { fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• load format:", fmt::streamed(load_format)); }
125 if(load.size() == 0) { fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• seed:", seed); }
126 fmt::format_to(std::back_inserter(res),
" {:<30} {}\n",
"• id:",
id);
127 fmt::format_to(std::back_inserter(res),
" {:<30} {}",
"• verbosity:", fmt::streamed(verbosity));
135 res.
Ds = t.contains(
"Ds") ? toml::find<std::vector<std::size_t>>(t,
"Ds") : res.Ds;
136 res.chis = t.contains(
"chis") ? toml::find<std::vector<std::vector<std::size_t>>>(t,
"chis") : res.chis;
137 if(t.contains(
"update")) { res.update = util::enum_from_toml<Update>(t.at(
"update")); }
138 res.max_steps = t.contains(
"max_steps") ? t.at(
"max_steps").as_integer() : res.max_steps;
139 res.min_steps = t.contains(
"min_steps") ? t.at(
"min_steps").as_integer() : res.min_steps;
140 res.dts = t.contains(
"dts") ? toml::find<std::vector<double>>(t,
"dts") : res.dts;
142 t.contains(
"t_steps") ? toml::find<std::vector<std::size_t>>(t,
"t_steps") : std::vector<std::size_t>(res.dts.size(), res.max_steps);
144 res.tol = t.contains(
"tol") ? t.at(
"tol").as_floating() : res.tol;
145 res.resume = t.contains(
"resume") ? t.at(
"resume").as_boolean() : res.resume;
146 if(t.contains(
"verbosity")) { res.verbosity = util::enum_from_toml<Verbosity>(t.at(
"verbosity")); }
147 res.log_format = t.contains(
"log_format") ?
static_cast<std::string
>(t.at(
"log_format").as_string()) : res.log_format;
148 if(t.contains(
"working_directory")) {
149 std::filesystem::path tmp_wd(
static_cast<std::string
>(t.at(
"working_directory").as_string()));
150 if(tmp_wd.is_relative()) {
151 res.working_directory = std::filesystem::current_path() / tmp_wd;
153 res.working_directory = tmp_wd;
156 if(t.contains(
"logging_directory")) {
157 res.logging_directory = std::filesystem::path(
static_cast<std::string
>(t.at(
"logging_directory").as_string()));
159 if(t.contains(
"obs_directory")) { res.obs_directory = std::filesystem::path(
static_cast<std::string
>(t.at(
"obs_directory").as_string())); }
160 res.display_obs = t.contains(
"display_obs") ? t.at(
"display_obs").as_boolean() : res.display_obs;
161 res.load = t.contains(
"load") ?
static_cast<std::string
>(t.at(
"load").as_string()) : res.load;
162 if(t.contains(
"load_format")) { res.load_format = util::enum_from_toml<LoadFormat>(t.at(
"load_format")); }
163 res.qn_scale = t.contains(
"qn_scale") ? (t.at(
"qn_scale").as_integer()) : res.qn_scale;
164 res.seed = t.contains(
"seed") ? (t.at(
"seed").as_integer()) : res.seed;
165 res.id = t.contains(
"id") ? (t.at(
"id").as_integer()) : res.id;
166 res.multi_init = t.contains(
"multi_init") ? (t.at(
"multi_init").as_boolean()) : res.multi_init;
167 if(res.multi_init) { res.init_dts = t.contains(
"init_dts") ? toml::find<std::vector<double>>(t,
"init_dts") : res.init_dts; }
168 if(res.multi_init) { res.init_t_steps = t.contains(
"init_t_steps") ? toml::find<std::vector<std::size_t>>(t,
"init_t_steps") : res.init_t_steps; }
169 if(res.multi_init) { res.init_seeds = t.contains(
"init_seeds") ? toml::find<std::vector<std::size_t>>(t,
"init_seeds") : res.init_seeds; }
170 if(res.multi_init) { res.init_chi = t.contains(
"init_chi") ? t.at(
"init_chi").as_integer() : res.init_chi; }
171 if(res.multi_init) { res.init_Ds = t.contains(
"init_Ds") ? toml::find<std::vector<std::size_t>>(t,
"init_Ds") : res.init_Ds; }
173 VERIFY(res.Ds.size() == res.chis.size());
174 VERIFY(res.dts.size() == res.t_steps.size());
175 VERIFY(res.init_dts.size() == res.init_t_steps.size());
Imag imag_from_toml(const toml::value &t)
Definition: ImagOpts.hpp:132
Definition: ImagOpts.hpp:32
auto info()
Definition: ImagOpts.hpp:105
void serialize(Ar &ar)
Definition: ImagOpts.hpp:73
std::vector< std::size_t > Ds
Definition: ImagOpts.hpp:33
Definition: ImagOpts.hpp:22
std::vector< double > dts
Definition: ImagOpts.hpp:24
std::vector< std::size_t > t_steps
Definition: ImagOpts.hpp:23