GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
ActiveGP.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
// See LICENSE for details.
4
5
#ifndef GPR_POTENTIALS_ACTIVEGP_H_
6
#define GPR_POTENTIALS_ACTIVEGP_H_
7
8
#include <cstdint>
9
#include <functional>
10
#include <memory>
11
#include <mutex>
12
#include <vector>
13
14
#include "
gpr/neb/Session.h
"
15
16
namespace
pot
{
17
40
struct
ActiveGPConfig
{
42
double
sigma_lo_factor
= 1.0;
44
double
sigma_hi_factor
= 20.0;
49
double
certify_below_force
= 0.0;
52
std::uint64_t
refit_training_revisions
= 5;
53
};
54
55
class
ActiveGP
{
56
public
:
59
using
OracleFn
= std::function<int(
long
n_atoms,
const
double
* positions,
60
const
int
* atomic_nrs,
const
double
* box,
61
double
* energy,
double
* forces)>;
62
64
enum class
AcquireReason
{
Variance
,
Certify
,
Batch
,
Reject
};
65
using
AcquireHook
= std::function<void(
AcquireReason
)>;
67
using
ModelUpdateHook
= std::function<void(std::uint64_t
epoch
)>;
68
69
using
Config
=
ActiveGPConfig
;
70
71
ActiveGP
(std::shared_ptr<gpr::neb::ActiveLearningSession> session,
72
OracleFn
oracle,
Config
config =
Config
());
73
76
[[nodiscard]] std::uint64_t
modelState
() const noexcept;
77
79
[[nodiscard]]
long
trainingSize
() const noexcept;
80
82
[[nodiscard]]
long
oracleCalls
() const noexcept
83
{
84
return
oracle_calls_;
85
}
86
87
void
setAcquireHook
(
AcquireHook
hook)
88
{
89
on_acquire_ = std::move(hook);
90
}
91
void
setModelUpdateHook
(
ModelUpdateHook
hook)
92
{
93
on_model_update_ = std::move(hook);
94
}
95
98
int
force
(
long
n_atoms,
const
double
* positions,
const
int
* atomic_nrs,
99
double
* forces,
double
* energy,
double
* variance,
100
const
double
* box);
101
107
int
forceBatch
(
long
n_systems,
long
n_atoms,
const
double
* positions,
108
const
int
* atomic_nrs,
double
* forces,
double
* energies,
109
double
* variances,
const
double
* boxes);
110
112
void
incorporate
();
113
114
private
:
115
std::shared_ptr<gpr::neb::ActiveLearningSession> session_;
116
OracleFn
oracle_;
117
Config
config_;
118
AcquireHook
on_acquire_;
119
ModelUpdateHook
on_model_update_;
120
long
oracle_calls_ = 0;
121
bool
pending_incorporation_ =
false
;
122
mutable
std::mutex mutex_;
123
125
void
predict(
long
n_atoms,
const
double
* positions,
double
* forces,
126
double
* energy,
double
* variance);
127
129
int
acquire(
long
n_atoms,
const
double
* positions,
const
int
* atomic_nrs,
130
const
double
* box,
double
* energy,
double
* forces,
131
AcquireReason
reason,
bool
learn);
132
133
[[nodiscard]]
double
noiseSigma()
const
;
134
};
135
136
}
// namespace pot
137
138
#endif
Session.h
ActiveLearningSession: shared GP + training data across GP-NEB and GP-Dimer phases.
pot::ActiveGP::AcquireReason
AcquireReason
Fired when a point is delegated, before the oracle runs.
Definition
ActiveGP.h:64
pot::ActiveGP::AcquireReason::Batch
@ Batch
Definition
ActiveGP.h:64
pot::ActiveGP::AcquireReason::Variance
@ Variance
Definition
ActiveGP.h:64
pot::ActiveGP::AcquireReason::Certify
@ Certify
Definition
ActiveGP.h:64
pot::ActiveGP::AcquireReason::Reject
@ Reject
Definition
ActiveGP.h:64
pot::ActiveGP::setModelUpdateHook
void setModelUpdateHook(ModelUpdateHook hook)
Definition
ActiveGP.h:91
pot::ActiveGP::modelState
std::uint64_t modelState() const noexcept
Definition
ActiveGP.cpp:22
pot::ActiveGP::ActiveGP
ActiveGP(std::shared_ptr< gpr::neb::ActiveLearningSession > session, OracleFn oracle, Config config=Config())
Definition
ActiveGP.cpp:13
pot::ActiveGP::Config
ActiveGPConfig Config
Definition
ActiveGP.h:69
pot::ActiveGP::incorporate
void incorporate()
Host-requested incorporation boundary (the ABI hint channel).
Definition
ActiveGP.cpp:94
pot::ActiveGP::ModelUpdateHook
std::function< void(std::uint64_t epoch)> ModelUpdateHook
Fired after an incorporation changed the surface.
Definition
ActiveGP.h:67
pot::ActiveGP::forceBatch
int forceBatch(long n_systems, long n_atoms, const double *positions, const int *atomic_nrs, double *forces, double *energies, double *variances, const double *boxes)
Definition
ActiveGP.cpp:181
pot::ActiveGP::OracleFn
std::function< int(long n_atoms, const double *positions, const int *atomic_nrs, const double *box, double *energy, double *forces)> OracleFn
Definition
ActiveGP.h:59
pot::ActiveGP::force
int force(long n_atoms, const double *positions, const int *atomic_nrs, double *forces, double *energy, double *variance, const double *box)
Definition
ActiveGP.cpp:107
pot::ActiveGP::oracleCalls
long oracleCalls() const noexcept
Oracle calls made through this surrogate.
Definition
ActiveGP.h:82
pot::ActiveGP::AcquireHook
std::function< void(AcquireReason)> AcquireHook
Definition
ActiveGP.h:65
pot::ActiveGP::trainingSize
long trainingSize() const noexcept
Training rows currently held.
Definition
ActiveGP.cpp:27
pot::ActiveGP::setAcquireHook
void setAcquireHook(AcquireHook hook)
Definition
ActiveGP.h:87
epoch
uint64_t epoch
Definition
eon_relax_engine.h:225
pot
Potential wrappers and the batched oracle interface.
Definition
ProblemSetUp.h:22
pot::ActiveGPConfig
Definition
ActiveGP.h:40
pot::ActiveGPConfig::sigma_lo_factor
double sigma_lo_factor
Delegate above this multiple of the likelihood noise sigma.
Definition
ActiveGP.h:42
pot::ActiveGPConfig::sigma_hi_factor
double sigma_hi_factor
Above this multiple the geometry is not learned from.
Definition
ActiveGP.h:44
pot::ActiveGPConfig::certify_below_force
double certify_below_force
Definition
ActiveGP.h:49
pot::ActiveGPConfig::refit_training_revisions
std::uint64_t refit_training_revisions
Definition
ActiveGP.h:52
gpr
potentials
ActiveGP.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf