IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
GaussianProcessInterpolationRestraint.h
Go to the documentation of this file.
1/**
2 * \file IMP/isd/GaussianProcessInterpolationRestraint.h
3 * \brief Restraint and ScoreState for GaussianProcessInterpolation
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 */
7
8#ifndef IMPISD_GAUSSIAN_PROCESS_INTERPOLATION_RESTRAINT_H
9#define IMPISD_GAUSSIAN_PROCESS_INTERPOLATION_RESTRAINT_H
10
11#include <IMP/isd/isd_config.h>
12#include <IMP/macros.h>
13#include <boost/scoped_ptr.hpp>
14#include <IMP/Restraint.h>
17#include <IMP/Pointer.h>
18#include <Eigen/Dense>
19
20#include <IMP/ScoreState.h>
21
22IMPISD_BEGIN_NAMESPACE
23
24class GaussianProcessInterpolationScoreState;
25
26//! gaussian process restraint
27/* the restraint is a multivariate normal distribution on the vector of
28* observations with mean and standard deviation given by the posterior of the
29* gaussian process.
30*/
32 : public Restraint {
33 private:
34 // checks and makes necessary updates
35 void update_mean_and_covariance();
39 // number of observation points
40 unsigned M_;
41
42 void create_score_state();
43
44 public:
45 /** This is a restraint on other restraints. It first constructs the
46 necessary vectors from GaussianProcessInterpolation, then creates a
47 multivariate normal distribution around it. Upon evaluation, it
48 checks if parameters have changed, reconstructs the matrix if
49 necessary, changes the DA weight and passes it to the functions. */
52
53 /** To call this, you need to update the scorestate before.
54 calling model.evaluate(False) is enough. */
55 double get_probability() const { return mvn_->density(); }
56
57 //! Use conjugate gradients when possible (default false)
58 void set_use_cg(bool use, double tol) { mvn_->set_use_cg(use, tol); }
59
60 //! Get minus log normalization and minus exponent separately
62 double get_minus_exponent() const;
63
64 //! Get hessian of the minus log likelihood
65 Eigen::MatrixXd get_hessian() const;
66
67 //! Get log determinant of hessian
68 double get_logdet_hessian() const;
69
70 //! call this one from Python
71 FloatsList get_hessian(bool unused) const;
72
73 public:
75 override;
78
79 // to allow the scorestate to get the restraint's objects
80 friend class GaussianProcessInterpolationScoreState;
81};
82
83#if !defined(IMP_DOXYGEN) && !defined(SWIG)
84class IMPISDEXPORT GaussianProcessInterpolationScoreState : public ScoreState {
85 private:
87
88 private:
89 GaussianProcessInterpolationScoreState(
91 : ScoreState(gpir->get_model(),
92 "GaussianProcessInterpolationScoreState%1%"),
93 gpir_(gpir) {}
94
95 public:
96 // only the GPIR can create this and add it to the model
97 friend class GaussianProcessInterpolationRestraint;
98 virtual void do_before_evaluate() override;
99 virtual void do_after_evaluate(DerivativeAccumulator *da) override;
100 virtual ModelObjectsTemp do_get_inputs() const override;
101 virtual ModelObjectsTemp do_get_outputs() const override;
102 IMP_OBJECT_METHODS(GaussianProcessInterpolationScoreState);
103};
104#endif
105
106IMPISD_END_NAMESPACE
107
108#endif /* IMPISD_GAUSSIAN_PROCESS_INTERPOLATION_RESTRAINT_H */
Normal distribution of Function.
Normal distribution of Function.
A nullptr-initialized pointer to an IMP Object.
Abstract base class for all restraints.
Shared score state.
Class for adding derivatives from restraints to the model.
Restraint(Model *m, std::string name)
Create a restraint and register it with the model.
ScoreStates maintain invariants in the Model.
Definition ScoreState.h:56
GaussianProcessInterpolationRestraint(Model *m, GaussianProcessInterpolation *gpi)
Eigen::MatrixXd get_hessian() const
Get hessian of the minus log likelihood.
void set_use_cg(bool use, double tol)
Use conjugate gradients when possible (default false).
double get_logdet_hessian() const
Get log determinant of hessian.
double get_minus_log_normalization() const
Get minus log normalization and minus exponent separately.
double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const override
Return the unweighted score for the restraint.
IMP::ModelObjectsTemp do_get_inputs() const override
FloatsList get_hessian(bool unused) const
call this one from Python
Various general useful macros for IMP.
IMP::Vector< Floats > FloatsList
Standard way to pass a bunch of Floats values.
Definition types.h:53
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A smart pointer to a ref-counted Object that is a class member.
Definition Pointer.h:144
Smart pointer to Object-derived classes that does not refcount.
Definition WeakPointer.h:78