9 #ifndef IMPKERNEL_RESTRAINT_H
10 #define IMPKERNEL_RESTRAINT_H
12 #include <IMP/kernel_config.h>
21 #include <type_traits>
22 #include <cereal/access.hpp>
23 #include <cereal/types/base_class.hpp>
25 IMPKERNEL_BEGIN_NAMESPACE
26 class DerivativeAccumulator;
67 double get_score()
const;
76 double evaluate(
bool calc_derivs)
const;
79 double evaluate_moved(
bool calc_derivs,
84 double evaluate_moved_if_below(
bool calc_derivatives,
89 double evaluate_moved_if_good(
bool calc_derivatives,
94 double evaluate_if_good(
bool calc_derivatives)
const;
97 double evaluate_if_below(
bool calc_derivatives,
double max)
const;
134 return unprotected_evaluate(da);
142 return unprotected_evaluate(da);
149 return unprotected_evaluate(da);
152 virtual double unprotected_evaluate_moved_if_below(
156 return unprotected_evaluate_moved(da, moved_pis, reset_pis);
159 virtual double unprotected_evaluate_moved_if_good(
160 DerivativeAccumulator *da,
const ParticleIndexes &moved_pis,
161 const ParticleIndexes &reset_pis,
double max)
const {
163 return unprotected_evaluate_moved(da, moved_pis, reset_pis);
202 void add_score_and_derivatives_moved(
230 Restraint *create_current_decomposition()
const;
240 void set_weight(
Float weight);
241 Float get_weight()
const {
return weight_; }
255 double get_maximum_score()
const {
return max_; }
256 void set_maximum_score(
double s);
269 double max =
NO_MAX)
const;
270 #if !defined(IMP_DOXYGEN)
271 void set_last_score(
double s)
const {
272 last_last_score_ = last_score_;
275 void set_last_last_score(
double s)
const { last_last_score_ = s; }
306 return Restraints(1, const_cast<Restraint *>(
this));
316 return do_create_decomposition();
321 virtual void do_add_score_and_derivatives_moved(
338 mutable double last_score_;
339 mutable double last_last_score_;
343 friend class cereal::access;
345 template<
class Archive>
void serialize(Archive &ar) {
346 ar(cereal::base_class<ModelObject>(
this));
349 if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
350 last_score_ = last_last_score_ =
BAD_SCORE;
351 cached_internal_scoring_function_ =
nullptr;
363 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
387 IMPKERNEL_END_NAMESPACE
Control display of deprecation information.
const double NO_MAX
Use this value when you want to turn off maximum for restraint evaluation.
IMP::Vector< IMP::Pointer< Restraint > > Restraints
Class for adding scores from restraints to the model.
virtual RestraintInfo * get_static_info() const
Various useful constants.
virtual RestraintInfo * get_dynamic_info() const
Class for adding derivatives from restraints to the model.
virtual Restraints do_create_decomposition() const
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
Set up destructor for a ref counted object.
A smart pointer to a reference counted object.
ScoringFunction * create_scoring_function(RestraintType *rs, double weight=1.0, double max=NO_MAX, std::string name=std::string())
Create a ScoringFunction on a single restraint.
double get_last_last_score() const
Get the unweighted score from the last-but-one time it was evaluated.
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Class for storing model, its restraints, constraints, and particles.
virtual double unprotected_evaluate_if_below(DerivativeAccumulator *da, double max) const
The function calling this will treat any score >= max as bad.
Base class for objects in a Model that depend on other objects.
virtual Restraints do_create_current_decomposition() const
virtual double unprotected_evaluate_if_good(DerivativeAccumulator *da, double max) const
#define IMP_UNUSED(variable)
Provide a consistent interface for things that take Restraints as arguments.
Class for adding up scores during ScoringFunction evaluation.
Restraints create_decomposition(const RestraintsTemp &rs)
Return the decomposition of a list of restraints.
Report key:value information on restraints.
Base class for objects in a Model that depend on other objects.
virtual double get_last_score() const
bool get_is_aggregate() const
Return whether this restraint wraps a number of other restraints.
ModelObjectsTemp do_get_outputs() const override
bool get_was_good() const
Represents a scoring function on the model.
Report key:value information on restraints.
double Float
Basic floating-point value (could be float, double...)
virtual double unprotected_evaluate_moved(DerivativeAccumulator *da, const ParticleIndexes &moved_pis, const ParticleIndexes &reset_pis) const
Return the unweighted score, taking moving particles into account.
Class for adding derivatives from restraints to the model.
A restraint is a term in an IMP ScoringFunction.