9 #ifndef IMPKERNEL_SCORING_FUNCTION_H
10 #define IMPKERNEL_SCORING_FUNCTION_H
12 #include <IMP/kernel_config.h>
17 #include "internal/moved_particles_cache.h"
20 #include <cereal/access.hpp>
21 #include <cereal/types/base_class.hpp>
24 IMPKERNEL_BEGIN_NAMESPACE
46 internal::MovedParticlesScoreStateCache moved_particles_cache_;
48 unsigned moved_particles_cache_age_;
50 friend class cereal::access;
52 template<
class Archive>
void serialize(Archive &ar) {
53 ar(cereal::base_class<ModelObject>(
this), es_);
55 if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
56 moved_particles_cache_.clear();
57 moved_particles_cache_age_ = 0;
67 typedef std::pair<double, bool> ScoreIsGoodPair;
85 do_add_score_and_derivatives(sa, ss);
91 ScoreAccumulator get_score_accumulator_if_good(
bool deriv) {
92 return ScoreAccumulator(&es_, 1.0, deriv,
NO_MAX,
NO_MAX,
true);
94 ScoreAccumulator get_score_accumulator(
bool deriv) {
95 return ScoreAccumulator(&es_, 1.0, deriv,
NO_MAX,
NO_MAX,
false);
99 ScoringFunction(Model *m, std::string name);
112 double evaluate(
bool derivatives);
114 double evaluate_if_good(
bool derivatives);
116 double evaluate_if_below(
bool derivatives,
double max);
137 double evaluate_moved(
bool derivatives,
const ParticleIndexes &moved_pis,
140 double evaluate_moved_if_below(
144 double evaluate_moved_if_good(
170 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
196 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
211 std::ostream &out = std::cout);
213 IMPKERNEL_END_NAMESPACE
IMP::Vector< IMP::Pointer< ScoringFunction > > ScoringFunctions
const double NO_MAX
Use this value when you want to turn off maximum for restraint evaluation.
virtual void do_add_score_and_derivatives_moved(ScoreAccumulator sa, const ParticleIndexes &moved_pis, const ParticleIndexes &reset_pis, const ScoreStatesTemp &ss)
Score when only some particles have moved.
A more IMP-like version of the std::vector.
ScoringFunctions create_decomposition(ScoringFunction *sf)
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Base class for objects in a Model that depend on other objects.
#define IMP_UNUSED(variable)
A smart pointer to a ref-counted Object that is a class member.
Class for adding up scores during ScoringFunction evaluation.
double get_last_score() const
returns the score that was calculated in the last evaluate call
Base class for objects in a Model that depend on other objects.
A nullptr-initialized pointer to an IMP Object.
Represents a scoring function on the model.
void show_restraint_hierarchy(ScoringFunctionAdaptor rs, std::ostream &out=std::cout)
Print the hierarchy of restraints.
Restraints create_restraints(RMF::FileConstHandle fh, Model *m)
Abstract base class for all restraints.
virtual ModelObjectsTemp do_get_outputs() const override
Build dependency graphs on models.
bool get_had_good_score() const
A restraint is a term in an IMP ScoringFunction.