Loading...
Searching...
No Matches
GPSurrogateJob.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
14#include "HelperFunctions.h"
15#include "Job.h"
16#include "Parameters.h"
17
18#ifdef WITH_CATLEARN
20#endif
21#include "PyGuard.h"
22#include <format>
23#include <pybind11/eigen.h>
24
25#include "NudgedElasticBand.h"
26
27namespace eonc {
28
29class GPSurrogateJob : public Job {
30public:
31 GPSurrogateJob(std::unique_ptr<Parameters> parameters)
32 : Job(std::move(parameters)) {
34#ifndef NDEBUG
35 py::module_ sys_mod = py::module_::import("sys");
36 py::module_ ipdb_mod = py::module_::import("ipdb");
37 sys_mod.attr("breakpointhook") = ipdb_mod.attr("set_trace");
38#endif // NDEBUG
39 }
40 GPSurrogateJob(std::shared_ptr<Potential> potPassed,
41 const Parameters &parameters)
42 : Job(potPassed, parameters) {
44#ifndef NDEBUG
45 py::module_ sys_mod = py::module_::import("sys");
46 py::module_ ipdb_mod = py::module_::import("ipdb");
47 sys_mod.attr("breakpointhook") = ipdb_mod.attr("set_trace");
48#endif // NDEBUG
49 }
50 ~GPSurrogateJob() = default;
51 std::vector<std::string> run() override;
53 std::shared_ptr<NudgedElasticBand>
54 runFromMatter(std::shared_ptr<Matter> initial,
55 std::shared_ptr<Matter> final_state);
56
57private:
59 std::unique_ptr<NudgedElasticBand> neb);
60 std::vector<std::string> returnFiles;
61};
62
63namespace helpers::surrogate {
64MatrixXd get_features(const std::vector<Matter> &matobjs);
65MatrixXd get_features(const std::vector<std::shared_ptr<Matter>> &matobjs);
66MatrixXd get_targets(std::vector<std::shared_ptr<Matter>> &matobjs,
67 std::shared_ptr<Potential> true_pot);
68MatrixXd get_targets(std::vector<Matter> &matobjs,
69 std::shared_ptr<Potential> true_pot);
70Eigen::VectorXd make_target(Matter &m1, std::shared_ptr<Potential> true_pot);
71std::pair<Eigen::VectorXd, Eigen::VectorXd>
72getNewDataPoint(const std::vector<std::shared_ptr<Matter>> &matobjs,
73 std::shared_ptr<Potential> true_pot);
74std::vector<Matter> getMidSlice(const std::vector<Matter> &matobjs);
75bool accuratePES(std::vector<std::shared_ptr<Matter>> &matobjs,
76 std::shared_ptr<Potential> true_pot);
77std::pair<double, Eigen::VectorXd::Index>
78getMaxUncertainty(const std::vector<std::shared_ptr<Matter>> &matobjs);
79} // namespace helpers::surrogate
80
81namespace helpers::eigen {
82MatrixXd vertCat(const MatrixXd &m1, const MatrixXd &m2);
83void addVectorRow(MatrixXd &data, const Eigen::VectorXd &newrow);
84// Modifies data
85} // namespace helpers::eigen
86
87} // namespace eonc
88
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, eOnStorageOrder > MatrixXd
Definition Eigen.h:33
The job class is used to serve as an abstract class for all jobs, as well as to call a job at runtime...
std::shared_ptr< NudgedElasticBand > runFromMatter(std::shared_ptr< Matter > initial, std::shared_ptr< Matter > final_state)
Matter-first NEB surrogate path (endpoints as Matter).
void saveData(NudgedElasticBand::NEBStatus status, std::unique_ptr< NudgedElasticBand > neb)
GPSurrogateJob(std::unique_ptr< Parameters > parameters)
GPSurrogateJob(std::shared_ptr< Potential > potPassed, const Parameters &parameters)
std::vector< std::string > returnFiles
std::vector< std::string > run() override
Virtual run; used solely for dynamic dispatch.
~GPSurrogateJob()=default
Job(std::unique_ptr< Parameters > parameters)
Definition Job.h:58
MatrixXd vertCat(const MatrixXd &m1, const MatrixXd &m2)
void addVectorRow(MatrixXd &data, const Eigen::VectorXd &newrow)
MatrixXd get_targets(std::vector< Matter > &matobjs, std::shared_ptr< Potential > true_pot)
MatrixXd get_features(const std::vector< Matter > &matobjs)
bool accuratePES(std::vector< std::shared_ptr< Matter > > &matobjs, std::shared_ptr< Potential > true_pot)
std::pair< double, Eigen::VectorXd::Index > getMaxUncertainty(const std::vector< std::shared_ptr< Matter > > &matobjs)
std::vector< Matter > getMidSlice(const std::vector< Matter > &matobjs)
std::pair< Eigen::VectorXd, Eigen::VectorXd > getNewDataPoint(const std::vector< std::shared_ptr< Matter > > &matobjs, std::shared_ptr< Potential > true_pot)
Eigen::VectorXd make_target(Matter &m1, std::shared_ptr< Potential > true_pot)
RAII resource manager for the ARTn C library with global synchronization.
void ensure_interpreter()
Definition NbGuard.h:21