Xped
Loading...
Searching...
No Matches
CeresSolve.hpp
Go to the documentation of this file.
1#include <filesystem>
2#include <fstream>
3#include <memory>
4
5#include "fmt/color.h"
6#include "fmt/core.h"
7
8#include "ceres/first_order_function.h"
9#include "ceres/gradient_problem.h"
10#include "ceres/gradient_problem_solver.h"
11
12#include "highfive/H5File.hpp"
13
15#include "Xped/PEPS/CTMOpts.hpp"
16
18
19namespace Xped {
20
21template <typename Scalar, typename Symmetry, Opts::CTMCheckpoint CPOpts, std::size_t TRank = 2>
22class Energy final : public ceres::FirstOrderFunction
23{
24 template <typename Sym>
26
27public:
30 std::shared_ptr<iPEPS<Scalar, Symmetry, false>> Psi)
31 : impl(std::move(solver))
32 , op(op)
33 , Psi(Psi)
34
35 {}
36
37 ~Energy() override {}
38
39 bool Evaluate(const double* parameters, double* cost, double* gradient) const override
40 {
41 if constexpr(ScalarTraits<Scalar>::IS_COMPLEX()) {
42 const std::complex<double>* params_compl = reinterpret_cast<const std::complex<double>*>(parameters);
43 Psi->set_data(params_compl);
44 std::complex<double>* gradient_compl = reinterpret_cast<std::complex<double>*>(gradient);
45 cost[0] = impl->template solve<Scalar, true>(Psi, gradient_compl, op);
46 } else {
47 Psi->set_data(parameters);
48 cost[0] = impl->template solve<Scalar, true>(Psi, gradient, op);
49 }
50 return true;
51 }
52 std::unique_ptr<CTMSolver<Scalar, Symmetry, CPOpts, TRank>> impl;
54 std::shared_ptr<iPEPS<Scalar, Symmetry, false>> Psi;
55 int NumParameters() const override { return ScalarTraits<Scalar>::IS_COMPLEX() ? 2 * Psi->plainSize() : Psi->plainSize(); }
56};
57
58template <typename Scalar, typename Symmetry, Opts::CTMCheckpoint CPOpts = Opts::CTMCheckpoint{}, std::size_t TRank = 2>
60{
61 template <typename Sym>
64
65 iPEPSSolverAD() = delete;
66
69 , H(H_in)
70 , Psi(Psi_in)
71 {
72 std::filesystem::create_directories(optim_opts.working_directory);
73 if(optim_opts.resume) {
74 constexpr std::size_t flags = yas::file /*IO type*/ | yas::binary; /*IO format*/
75 try {
76 yas::load<flags>((optim_opts.working_directory.string() + "/" + this->H.file_name() +
77 fmt::format("_D={}_chi={}_seed={}_id={}.ad", Psi->D, ctm_opts.chi, optim_opts.seed, optim_opts.id) + ".ad")
78 .c_str(),
79 *this);
80 } catch(const std::exception& e) {
81 fmt::print("Error while loading file ({}) for resuming simulation.\n",
82 optim_opts.working_directory.string() + "/" + this->H.file_name() +
83 fmt::format("_D={}_chi={}_seed={}_id={}.ad", Psi->D, ctm_opts.chi, optim_opts.seed, optim_opts.id));
84 std::cout << std::flush;
85 throw;
86 }
87 } else {
88 if(optim_opts.load != "") {
89 std::filesystem::path load_p(optim_opts.load);
90 if(load_p.is_relative()) { load_p = optim_opts.working_directory / load_p; }
91 switch(optim_opts.load_format) {
92 case Opts::LoadFormat::MATLAB: {
93 Psi->loadFromMatlab(load_p, "cpp", optim_opts.qn_scale);
94 break;
95 }
96 case Opts::LoadFormat::NATIVE: {
97 constexpr std::size_t flags = yas::file /*IO type*/ | yas::binary; /*IO format*/
99 try {
100 yas::load<flags>(load_p.string().c_str(), tmp_Psi);
101 } catch(const yas::serialization_exception& se) {
102 fmt::print(
103 "Error while deserializing file ({}) with initial wavefunction.\nThis might be because of incompatible symmetries between this simulation and the loaded wavefunction.",
104 load_p.string());
105 std::cout << std::flush;
106 throw;
107 } catch(const yas::io_exception& ie) {
108 fmt::print("Error while loading file ({}) with initial wavefunction.\n", load_p.string());
109 std::cout << std::flush;
110 throw;
111 } catch(const std::exception& e) {
112 fmt::print("Unknown error while loading file ({}) with initial wavefunction.\n", load_p.string());
113 std::cout << std::flush;
114 throw;
115 }
116 Psi = std::make_shared<iPEPS<Scalar, Symmetry>>(std::move(tmp_Psi));
117 break;
118 }
119 }
120 assert(Psi->cell().pattern == H.data_h.pat);
121 } else {
122 Psi->setRandom(optim_opts.seed);
123 }
124 problem = std::make_unique<ceres::GradientProblem>(
125 new EnergyFunctor(std::move(std::make_unique<CTMSolver<Scalar, Symmetry, CPOpts, TRank>>(ctm_opts)), H, Psi));
126 std::filesystem::create_directories(optim_opts.working_directory / optim_opts.logging_directory);
127 if(optim_opts.log_format == ".h5") {
128 try {
129 HighFive::File file((optim_opts.working_directory / optim_opts.logging_directory).string() + "/" + this->H.file_name() +
130 fmt::format("_D={}_chi={}_seed={}_id={}.h5", Psi->D, ctm_opts.chi, optim_opts.seed, optim_opts.id),
131 optim_opts.resume ? HighFive::File::ReadWrite : HighFive::File::Excl);
132 HighFive::DataSpace dataspace = HighFive::DataSpace({0}, {HighFive::DataSpace::UNLIMITED});
133
134 // // Use chunking
135 HighFive::DataSetCreateProps props;
136 props.add(HighFive::Chunking(std::vector<hsize_t>{10}));
137
138 // Create the dataset
139 if(not file.exist("/iteration")) {
140 HighFive::DataSet dataset_i = file.createDataSet("/iteration", dataspace, HighFive::create_datatype<int>(), props);
141 }
142 if(not file.exist("/cost")) {
143 HighFive::DataSet dataset_c = file.createDataSet("/cost", dataspace, HighFive::create_datatype<double>(), props);
144 }
145 if(not file.exist("/grad_norm")) {
146 HighFive::DataSet dataset_g = file.createDataSet("/grad_norm", dataspace, HighFive::create_datatype<double>(), props);
147 }
148 } catch(const std::exception& e) {
149 fmt::print(fg(fmt::color::red),
150 "There already exists a log file for this simulation:{}.\n",
151 (optim_opts.working_directory / optim_opts.logging_directory).string() + "/" + this->H.file_name() +
152 fmt::format("_D={}_chi={}_seed={}_id={}.h5", Psi->D, ctm_opts.chi, optim_opts.seed, optim_opts.id));
153 std::cout << std::flush;
154 throw;
155 }
156 }
157 if(not optim_opts.obs_directory.empty()) {
158 std::filesystem::create_directories(optim_opts.working_directory / optim_opts.obs_directory);
159 if(std::filesystem::exists(
161 std::filesystem::path(this->H.file_name() + fmt::format("_seed={}_id={}.h5", optim_opts.seed, optim_opts.id)))) {
162 HighFive::File file((optim_opts.working_directory / optim_opts.obs_directory).string() + "/" + this->H.file_name() +
163 fmt::format("_seed={}_id={}.h5", optim_opts.seed, optim_opts.id),
164 optim_opts.resume ? HighFive::File::ReadWrite : HighFive::File::ReadOnly);
165 if(file.exist(fmt::format("/{}/{}", Psi->D, ctm_opts.chi))) {
166 fmt::print(fg(fmt::color::red),
167 "There already exists data in observable file for D={}, chi={}.\n Filename:{}.\n",
168 Psi->D,
169 ctm_opts.chi,
170 (optim_opts.working_directory / optim_opts.obs_directory).string() + "/" + this->H.file_name() +
171 fmt::format("_seed={}_id={}.h5", optim_opts.seed, optim_opts.id));
172 std::cout << std::flush;
173 throw;
174 }
175 } else {
176 try {
177 HighFive::File file((optim_opts.working_directory / optim_opts.obs_directory).string() + "/" + this->H.file_name() +
178 fmt::format("_seed={}_id={}.h5", optim_opts.seed, optim_opts.id),
179 optim_opts.resume ? HighFive::File::ReadWrite : HighFive::File::Excl);
180 } catch(const std::exception& e) {
181 fmt::print(fg(fmt::color::red),
182 "Error while creating the observable file for this simulation:{}.\n",
183 (optim_opts.working_directory / optim_opts.obs_directory).string() + "/" + this->H.file_name() +
184 fmt::format("_seed={}_id={}.h5", optim_opts.seed, optim_opts.id));
185 std::cout << std::flush;
186 throw;
187 }
188 }
189 }
190 }
191 }
192
193 template <typename HamScalar>
194 void solve()
195 {
197 "{}: Model={}(Bonds: V:{}, H:{}, D1: {}, D2: {})",
198 fmt::styled("iPEPSSolverAD", fmt::emphasis::bold),
199 H.format(),
200 (H.bond & Opts::Bond::V) == Opts::Bond::V,
201 (H.bond & Opts::Bond::H) == Opts::Bond::H,
202 (H.bond & Opts::Bond::D1) == Opts::Bond::D1,
203 (H.bond & Opts::Bond::D2) == Opts::Bond::D2);
205 Log::on_entry(optim_opts.verbosity, "{}", getCTMSolver()->opts.info());
206 Log::on_entry(optim_opts.verbosity, "{}", CPOpts.info());
207
208 // auto Dwain = std::make_unique<CTMSolver<Scalar, Symmetry, CPOpts, TRank>>(ctm_opts);
209 // ceres::GradientProblem problem(new Energy<Scalar, Symmetry, CPOpts, TRank>(std::move(Dwain), H, Psi));
210 // problem = ceres::GradientProblem(new EnergyFunctor(std::move(Dwain), H, Psi));
211 std::vector<Scalar> parameters = Psi->data();
212
213 // options.line_search_direction_type = ceres::NONLINEAR_CONJUGATE_GRADIENT;
214 // options.line_search_direction_type = ceres::STEEPEST_DESCENT;
215 switch(optim_opts.alg) {
216 case Opts::Algorithm::L_BFGS: options.line_search_direction_type = ceres::LBFGS; break;
217 case Opts::Algorithm::CONJUGATE_GRADIENT: options.line_search_direction_type = ceres::NONLINEAR_CONJUGATE_GRADIENT; break;
218 case Opts::Algorithm::NELDER_MEAD: throw std::invalid_argument("Nelder-Mead optimization is not in ceres.");
219 }
220
221 switch(optim_opts.ls) {
222 case Opts::Linesearch::WOLFE: options.line_search_type = ceres::WOLFE; break;
223 case Opts::Linesearch::ARMIJO: options.line_search_type = ceres::ARMIJO; break;
224 }
225 options.logging_type = ceres::SILENT;
226 options.minimizer_progress_to_stdout = true;
227 options.use_approximate_eigenvalue_bfgs_scaling = optim_opts.bfgs_scaling;
228 // options.line_search_interpolation_type = ceres::BISECTION;
229 options.max_num_iterations = optim_opts.max_steps;
230 options.function_tolerance = optim_opts.cost_tol;
231 options.parameter_tolerance = optim_opts.step_tol;
232 options.gradient_tolerance = optim_opts.grad_tol;
233 options.update_state_every_iteration = true;
234 GetStateCallback get_state_c(this->state);
235 options.callbacks.push_back(&get_state_c);
236 LoggingCallback logging_c(*this);
237 options.callbacks.push_back(&logging_c);
238 ObsCallback obs_c(*this);
239 options.callbacks.push_back(&obs_c);
240 CustomCallback custom_c(*this, getCTMSolver()->getCTM());
241 options.callbacks.push_back(&custom_c);
242 SaveCallback save_c(*this);
243 if(optim_opts.save_period > 0) { options.callbacks.push_back(&save_c); }
244 ceres::GradientProblemSolver::Summary summary;
245 if constexpr(ScalarTraits<Scalar>::IS_COMPLEX()) {
246 typename ScalarTraits<Scalar>::Real* params_real = reinterpret_cast<double*>(parameters.data());
247 ceres::Solve(options, *problem, params_real, &summary);
248 } else {
249 ceres::Solve(options, *problem, parameters.data(), &summary);
250 }
251 custom_c((summary.iterations.size() > 0) ? summary.iterations.back() : ceres::IterationSummary{});
252 obs_c((summary.iterations.size() > 0) ? summary.iterations.back() : ceres::IterationSummary{});
253 Log::on_exit(optim_opts.verbosity, "{}", summary.FullReport());
254 }
255
257 {
258 std::size_t current_iter = 0;
259 double grad_norm;
260 double cost;
261 double step_norm;
262 template <typename Ar>
263 void serialize(Ar& ar)
264 {
265 ar& YAS_OBJECT_NVP("SolverState", ("current_iter", current_iter), ("grad_norm", grad_norm), ("cost", cost), ("step_norm", step_norm));
266 }
267 };
268
269 CTMSolver<Scalar, Symmetry, CPOpts, TRank>* getCTMSolver() { return dynamic_cast<const EnergyFunctor*>(problem->function())->impl.get(); }
271 {
272 return dynamic_cast<const EnergyFunctor*>(problem->function())->impl.get();
273 }
274
276 std::function<void(XPED_CONST CTM<Scalar, Symmetry, TRank>& ctm, std::size_t)> callback = [](XPED_CONST CTM<Scalar, Symmetry, TRank>&,
277 std::size_t) {};
279
280 ceres::GradientProblemSolver::Options options;
282 std::shared_ptr<iPEPS<Scalar, Symmetry>> Psi;
283 std::unique_ptr<ceres::GradientProblem> problem;
284
285 template <typename Ar>
286 void serialize(Ar& ar) const
287 {
288 ar& YAS_OBJECT_NVP("iPEPSSolverAD",
289 ("CTMSolver", *dynamic_cast<const EnergyFunctor*>(problem->function())->impl),
290 ("Psi", *Psi),
291 ("optim_opts", optim_opts),
292 ("state", state));
293 }
294
295 template <typename Ar>
296 void serialize(Ar& ar)
297 {
300 ar& YAS_OBJECT_NVP("iPEPSSolverAD", ("CTMSolver", tmp_CTMSolver), ("Psi", tmp_Psi), ("optim_opts", optim_opts), ("state", state));
301 // optim_opts.max_steps = optim_opts.max_steps > state.current_iter ? optim_opts.max_steps - state.current_iter : 1;
302 Psi = std::make_shared<iPEPS<Scalar, Symmetry>>(std::move(tmp_Psi));
303 auto Dwain = std::make_unique<CTMSolver<Scalar, Symmetry, CPOpts, TRank>>(std::move(tmp_CTMSolver));
304 problem = std::make_unique<ceres::GradientProblem>(new EnergyFunctor(std::move(Dwain), H, Psi));
305 }
306
307 struct CustomCallback : public ceres::IterationCallback
308 {
310 : s(s)
311 , c(c)
312 {}
313
314 ceres::CallbackReturnType operator()(const ceres::IterationSummary& summary)
315 {
316 s.callback(c, summary.iteration);
317 return ceres::SOLVER_CONTINUE;
318 }
319
322 };
323
324 struct GetStateCallback : public ceres::IterationCallback
325 {
327 : state(state_in)
328 {}
329
330 ceres::CallbackReturnType operator()(const ceres::IterationSummary& summary)
331 {
332 state.current_iter = summary.iteration;
333 state.grad_norm = summary.gradient_norm;
334 state.cost = summary.cost;
335 state.step_norm = summary.step_norm;
336 return ceres::SOLVER_CONTINUE;
337 }
339 };
340
341 struct LoggingCallback : public ceres::IterationCallback
342 {
344 : solver(solver_in)
345 {}
346
347 ceres::CallbackReturnType operator()(const ceres::IterationSummary& summary)
348 {
350 "{}{:^4d}: E={:+.8f}, ΔE={:.1e}, |∇|={:.1e}, step time={}, total time={}",
351 fmt::styled("Iteration=", fmt::emphasis::bold),
352 fmt::styled(summary.iteration, fmt::emphasis::bold),
353 summary.cost,
354 summary.cost_change,
355 summary.gradient_norm,
356 util::format_secs(std::chrono::duration<double, std::ratio<1, 1>>(summary.iteration_time_in_seconds)),
357 util::format_secs(std::chrono::duration<double, std::ratio<1, 1>>(summary.cumulative_time_in_seconds)));
358 if(solver.optim_opts.log_format == ".h5") {
359 HighFive::File file((solver.optim_opts.working_directory / solver.optim_opts.logging_directory).string() + "/" +
360 solver.H.file_name() +
361 fmt::format("_D={}_chi={}_seed={}_id={}.h5",
362 solver.Psi->D,
363 solver.getCTMSolver()->opts.chi,
366 HighFive::File::OpenOrCreate);
367 auto insert_elem = [&file](const std::string& name, auto elem) {
368 auto d = file.getDataSet(name);
369 std::size_t curr_size = d.getElementCount();
370 d.resize({curr_size + 1});
371 decltype(elem) elem_a[1] = {elem};
372 d.select({curr_size}, {1}).write(elem_a);
373 };
374 insert_elem("/iteration", summary.iteration);
375 insert_elem("/cost", summary.cost);
376 insert_elem("/grad_norm", summary.gradient_norm);
377 } else {
378 std::ofstream ofs((solver.optim_opts.working_directory / solver.optim_opts.logging_directory).string() + "/" + solver.H.file_name() +
379 fmt::format("_D={}_chi={}_seed={}_id={}{}",
380 solver.Psi->D,
381 solver.getCTMSolver()->opts.chi,
385 std::ios::app);
386 ofs << summary.iteration << '\t' << summary.cost << '\t' << summary.gradient_norm << std::endl;
387 ofs.close();
388 }
389 return ceres::SOLVER_CONTINUE;
390 }
392 };
393
394 struct ObsCallback : public ceres::IterationCallback
395 {
397 : solver(solver_in)
398 {}
399
400 ceres::CallbackReturnType operator()(const ceres::IterationSummary& summary)
401 {
402 if(solver.optim_opts.display_obs or not solver.optim_opts.obs_directory.empty()) { solver.H.computeObs(solver.getCTMSolver()->getCTM()); }
404 Log::per_iteration(solver.optim_opts.verbosity, " Observables:\n{}", solver.H.getObsString(" "));
405 }
406 if(not solver.optim_opts.obs_directory.empty()) {
407 HighFive::File file((solver.optim_opts.working_directory / solver.optim_opts.obs_directory).string() + "/" + solver.H.file_name() +
408 fmt::format("_seed={}_id={}.h5", solver.optim_opts.seed, solver.optim_opts.id),
409 HighFive::File::OpenOrCreate);
410 std::string e_name = fmt::format("/{}/{}/energy", solver.Psi->D, solver.getCTMSolver()->getCTM().chi());
411 if(not file.exist(e_name)) {
412 HighFive::DataSpace dataspace = HighFive::DataSpace({0, 0}, {HighFive::DataSpace::UNLIMITED, HighFive::DataSpace::UNLIMITED});
413
414 // Use chunking
415 HighFive::DataSetCreateProps props;
416 props.add(HighFive::Chunking(std::vector<hsize_t>{2, 2}));
417
418 // Create the dataset
419 HighFive::DataSet dataset = file.createDataSet(e_name, dataspace, HighFive::create_datatype<double>(), props);
420 }
421 {
422 auto d = file.getDataSet(e_name);
423 std::vector<std::vector<double>> data;
424 data.push_back(std::vector<double>(1, summary.cost));
425 std::size_t curr_size = d.getDimensions()[0];
426 d.resize({curr_size + 1, data[0].size()});
427 d.select({curr_size, 0}, {1, data[0].size()}).write(data);
428 }
429 std::string g_name = fmt::format("/{}/{}/grad", solver.Psi->D, solver.getCTMSolver()->getCTM().chi());
430 if(not file.exist(g_name)) {
431 HighFive::DataSpace dataspace = HighFive::DataSpace({0, 0}, {HighFive::DataSpace::UNLIMITED, HighFive::DataSpace::UNLIMITED});
432
433 // Use chunking
434 HighFive::DataSetCreateProps props;
435 props.add(HighFive::Chunking(std::vector<hsize_t>{2, 2}));
436
437 // Create the dataset
438 HighFive::DataSet dataset = file.createDataSet(g_name, dataspace, HighFive::create_datatype<double>(), props);
439 }
440 {
441 auto d = file.getDataSet(g_name);
442 std::vector<std::vector<double>> data;
443 data.push_back(std::vector<double>(1, summary.gradient_norm));
444 std::size_t curr_size = d.getDimensions()[0];
445 d.resize({curr_size + 1, data[0].size()});
446 d.select({curr_size, 0}, {1, data[0].size()}).write(data);
447 }
448 solver.H.obsToFile(file, fmt::format("/{}/{}/", solver.Psi->D, solver.getCTMSolver()->getCTM().chi()));
449 }
450 return ceres::SOLVER_CONTINUE;
451 }
453 };
454
455 struct SaveCallback : public ceres::IterationCallback
456 {
457 SaveCallback(const iPEPSSolverAD& solver_in)
458 : solver(solver_in)
459 {}
460
461 ceres::CallbackReturnType operator()(const ceres::IterationSummary& summary)
462 {
463 assert(solver.optim_opts.save_period > 0);
464 if(summary.iteration == 0) { return ceres::SOLVER_CONTINUE; }
465 if(summary.iteration % solver.optim_opts.save_period == 0) {
466 constexpr std::size_t flags = yas::file /*IO type*/ | yas::binary; /*IO format*/
467 yas::file_ostream ofs_ad((solver.optim_opts.working_directory.string() + "/" + solver.H.file_name() +
468 fmt::format("_D={}_chi={}_seed={}_id={}.ad",
469 solver.Psi->D,
470 solver.getCTMSolver()->opts.chi,
473 .c_str(),
474 /*trunc*/ 1);
475 yas::save<flags>(ofs_ad, solver);
476 yas::file_ostream ofs_psi((solver.optim_opts.working_directory.string() + "/" + solver.H.file_name() +
477 fmt::format("_D={}_chi={}_seed={}_id={}.psi",
478 solver.Psi->D,
479 solver.getCTMSolver()->opts.chi,
482 .c_str(),
483 /*trunc*/ 1);
484 yas::save<flags>(ofs_psi, *solver.Psi);
485 }
486 return ceres::SOLVER_CONTINUE;
487 }
489 };
490};
491
492} // namespace Xped
Definition: CTMSolver.hpp:18
Definition: CTM.hpp:62
Definition: CeresSolve.hpp:23
bool Evaluate(const double *parameters, double *cost, double *gradient) const override
Definition: CeresSolve.hpp:39
int NumParameters() const override
Definition: CeresSolve.hpp:55
~Energy() override
Definition: CeresSolve.hpp:37
Hamiltonian< Symmetry > & op
Definition: CeresSolve.hpp:53
std::unique_ptr< CTMSolver< Scalar, Symmetry, CPOpts, TRank > > impl
Definition: CeresSolve.hpp:52
std::shared_ptr< iPEPS< Scalar, Symmetry, false > > Psi
Definition: CeresSolve.hpp:54
Energy(std::unique_ptr< CTMSolver< Scalar, Symmetry, CPOpts, TRank > > solver, Hamiltonian< Symmetry > &op, std::shared_ptr< iPEPS< Scalar, Symmetry, false > > Psi)
Definition: CeresSolve.hpp:28
Definition: iPEPS.hpp:39
constexpr void on_exit(Verbosity policy, Args &&... args)
Definition: Logging.hpp:102
constexpr void on_entry(Verbosity policy, Args &&... args)
Definition: Logging.hpp:108
constexpr void per_iteration(Verbosity policy, Args &&... args)
Definition: Logging.hpp:114
std::string format_secs(std::chrono::duration< double, std::ratio< 1, 1 > > dts)
Definition: Stopwatch.hpp:25
Definition: bench.cpp:62
Definition: CTMOpts.hpp:28
std::size_t chi
Definition: CTMOpts.hpp:29
Definition: OptimOpts.hpp:25
Linesearch ls
Definition: OptimOpts.hpp:28
std::size_t seed
Definition: OptimOpts.hpp:46
bool resume
Definition: OptimOpts.hpp:40
Algorithm alg
Definition: OptimOpts.hpp:26
LoadFormat load_format
Definition: OptimOpts.hpp:42
std::filesystem::path logging_directory
Definition: OptimOpts.hpp:55
bool display_obs
Definition: OptimOpts.hpp:58
double grad_tol
Definition: OptimOpts.hpp:33
std::size_t id
Definition: OptimOpts.hpp:48
auto info()
Definition: OptimOpts.hpp:88
bool bfgs_scaling
Definition: OptimOpts.hpp:31
Verbosity verbosity
Definition: OptimOpts.hpp:60
std::size_t max_steps
Definition: OptimOpts.hpp:37
std::string log_format
Definition: OptimOpts.hpp:52
int qn_scale
Definition: OptimOpts.hpp:44
std::string load
Definition: OptimOpts.hpp:43
std::size_t save_period
Definition: OptimOpts.hpp:50
std::filesystem::path working_directory
Definition: OptimOpts.hpp:54
std::filesystem::path obs_directory
Definition: OptimOpts.hpp:57
double step_tol
Definition: OptimOpts.hpp:34
double cost_tol
Definition: OptimOpts.hpp:35
Definition: ScalarTraits.hpp:10
Definition: TwoSiteObservable.hpp:22
Definition: CeresSolve.hpp:308
ceres::CallbackReturnType operator()(const ceres::IterationSummary &summary)
Definition: CeresSolve.hpp:314
XPED_CONST CTM< Scalar, Symmetry, TRank > & c
Definition: CeresSolve.hpp:321
CustomCallback(const iPEPSSolverAD &s, XPED_CONST CTM< Scalar, Symmetry, TRank > &c)
Definition: CeresSolve.hpp:309
const iPEPSSolverAD & s
Definition: CeresSolve.hpp:320
Definition: CeresSolve.hpp:325
SolverState & state
Definition: CeresSolve.hpp:338
ceres::CallbackReturnType operator()(const ceres::IterationSummary &summary)
Definition: CeresSolve.hpp:330
GetStateCallback(SolverState &state_in)
Definition: CeresSolve.hpp:326
Definition: CeresSolve.hpp:342
LoggingCallback(const iPEPSSolverAD &solver_in)
Definition: CeresSolve.hpp:343
ceres::CallbackReturnType operator()(const ceres::IterationSummary &summary)
Definition: CeresSolve.hpp:347
const iPEPSSolverAD & solver
Definition: CeresSolve.hpp:391
Definition: CeresSolve.hpp:395
ceres::CallbackReturnType operator()(const ceres::IterationSummary &summary)
Definition: CeresSolve.hpp:400
iPEPSSolverAD & solver
Definition: CeresSolve.hpp:452
ObsCallback(iPEPSSolverAD &solver_in)
Definition: CeresSolve.hpp:396
Definition: CeresSolve.hpp:456
const iPEPSSolverAD & solver
Definition: CeresSolve.hpp:488
ceres::CallbackReturnType operator()(const ceres::IterationSummary &summary)
Definition: CeresSolve.hpp:461
SaveCallback(const iPEPSSolverAD &solver_in)
Definition: CeresSolve.hpp:457
Definition: CeresSolve.hpp:257
double cost
Definition: CeresSolve.hpp:260
double grad_norm
Definition: CeresSolve.hpp:259
std::size_t current_iter
Definition: CeresSolve.hpp:258
void serialize(Ar &ar)
Definition: CeresSolve.hpp:263
double step_norm
Definition: CeresSolve.hpp:261
Definition: CeresSolve.hpp:60
Hamiltonian< Symmetry > & H
Definition: CeresSolve.hpp:281
CTMSolver< Scalar, Symmetry, CPOpts, TRank > * getCTMSolver()
Definition: CeresSolve.hpp:269
SolverState state
Definition: CeresSolve.hpp:278
void serialize(Ar &ar) const
Definition: CeresSolve.hpp:286
std::unique_ptr< ceres::GradientProblem > problem
Definition: CeresSolve.hpp:283
ceres::GradientProblemSolver::Options options
Definition: CeresSolve.hpp:280
void solve()
Definition: CeresSolve.hpp:194
iPEPSSolverAD(Opts::Optim optim_opts, Opts::CTM ctm_opts, std::shared_ptr< iPEPS< Scalar, Symmetry > > Psi_in, Hamiltonian< Symmetry > &H_in)
Definition: CeresSolve.hpp:67
std::shared_ptr< iPEPS< Scalar, Symmetry > > Psi
Definition: CeresSolve.hpp:282
std::function< void(XPED_CONST CTM< Scalar, Symmetry, TRank > &ctm, std::size_t)> callback
Definition: CeresSolve.hpp:276
Opts::Optim optim_opts
Definition: CeresSolve.hpp:275
void serialize(Ar &ar)
Definition: CeresSolve.hpp:296
Energy< Scalar, Symmetry, CPOpts, TRank > EnergyFunctor
Definition: CeresSolve.hpp:63
const CTMSolver< Scalar, Symmetry, CPOpts, TRank > * getCTMSolver() const
Definition: CeresSolve.hpp:270