IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
ConstantRestraint.h
Go to the documentation of this file.
1/**
2 * \file IMP/core/ConstantRestraint.h \brief Constant restraint.
3 *
4 * Just return a constant.
5 *
6 * Copyright 2007-2022 IMP Inventors. All rights reserved.
7 *
8 */
9
10#ifndef IMPCORE_CONSTANT_RESTRAINT_H
11#define IMPCORE_CONSTANT_RESTRAINT_H
12
13#include <IMP/core/core_config.h>
14
15#include <IMP/Restraint.h>
16#include <IMP/PairScore.h>
17#include <cereal/access.hpp>
18#include <cereal/types/base_class.hpp>
19#include <cereal/types/polymorphic.hpp>
20
21IMPCORE_BEGIN_NAMESPACE
22
23//! Return a constant value.
24/** This restraint is mostly for testing, but can also be used to make
25 the total score look nicer.
26 */
27class IMPCOREEXPORT ConstantRestraint : public Restraint {
28 Float v_;
29
30 friend class cereal::access;
31
32 template<class Archive> void serialize(Archive &ar) {
33 ar(cereal::base_class<Restraint>(this), v_);
34 }
36
37 public:
38 //! Add v to the total score.
41
43 const override;
44 virtual IMP::ModelObjectsTemp do_get_inputs() const override;
46};
47
48IMPCORE_END_NAMESPACE
49
50#endif /* IMPCORE_CONSTANT_RESTRAINT_H */
Define PairScore.
Abstract base class for all restraints.
Class for adding derivatives from restraints to the model.
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.
ConstantRestraint(Model *m, Float v)
Add v to the total score.
virtual IMP::ModelObjectsTemp do_get_inputs() const override
double Float
Basic floating-point value (could be float, double...).
Definition types.h:19
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#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.