IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
UniformPrior.h
Go to the documentation of this file.
1/**
2 * \file IMP/isd/UniformPrior.h
3 * \brief A restraint on a scale parameter.
4 *
5 * Copyright 2007-2026 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPISD_UNIFORM_PRIOR_H
10#define IMPISD_UNIFORM_PRIOR_H
11
12#include <IMP/isd/isd_config.h>
13#include <IMP/SingletonScore.h>
14#include <IMP/Restraint.h>
15#include <cereal/access.hpp>
16#include <cereal/types/base_class.hpp>
17
18IMPISD_BEGIN_NAMESPACE
19
20//! Uniform distribution with harmonic boundaries
21
22class IMPISDEXPORT UniformPrior : public Restraint
23{
24 ParticleIndex pi_;
25 double upperb_;
26 double lowerb_;
27 double k_;
28
29 friend class cereal::access;
30 template<class Archive> void serialize(Archive &ar) {
31 ar(cereal::base_class<Restraint>(this), pi_, upperb_, lowerb_, k_);
32 }
34
35public:
36 //! Create the restraint.
37 UniformPrior(IMP::Model* m, Particle *p, double k, double upperb,
38 double lowerb, std::string name="UniformPrior%1%");
39
40 UniformPrior() {}
41
42 virtual double
44 const override;
45 virtual IMP::ModelObjectsTemp do_get_inputs() const override;
47
48 /* call for probability */
49 virtual double get_probability() const
50 {
51 return exp(-unprotected_evaluate(nullptr));
52 }
53
54 //! Return the lower and upper bounds
55 FloatRange get_range() const { return FloatRange(lowerb_, upperb_); }
56
57 //! Return the force constant
58 double get_k() const { return k_; }
59
60 //! Return the particle that this prior acts on
61 ParticleIndex get_index() const { return pi_; }
62
63 //! \return Information for writing to RMF files
64 RestraintInfo *get_static_info() const override;
65
66 //! \return Information for writing to RMF files
68
69};
70
71IMPISD_END_NAMESPACE
72
73#endif /* IMPISD_UNIFORM_PRIOR_H */
Abstract base class for all restraints.
Define SingletonScore.
Class for adding derivatives from restraints to the model.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
Report key:value information on restraints.
Restraint(Model *m, std::string name)
Create a restraint and register it with the model.
virtual double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const override
Return the unweighted score for the restraint.
RestraintInfo * get_static_info() const override
RestraintInfo * get_dynamic_info() const override
UniformPrior(IMP::Model *m, Particle *p, double k, double upperb, double lowerb, std::string name="UniformPrior%1%")
Create the restraint.
virtual IMP::ModelObjectsTemp do_get_inputs() const override
ParticleIndex get_index() const
Return the particle that this prior acts on.
FloatRange get_range() const
Return the lower and upper bounds.
double get_k() const
Return the force constant.
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
std::pair< Float, Float > FloatRange
A pair representing the allowed range for a Float attribute.
Definition types.h:30
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.