IMP  2.1.1
The Integrative Modeling Platform
Score.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/Score.h
3  * \brief A Score on the distance between a pair of particles.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPSCORE_FUNCTOR_SCORE_H
9 #define IMPSCORE_FUNCTOR_SCORE_H
10 
11 #include <IMP/score_functor/score_functor_config.h>
12 #include <IMP/base_types.h>
13 #include <IMP/particle_index.h>
15 #include <limits>
16 
17 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
18 /** A functor for computing a distance based score for two particles.
19  */
20 struct Score {
21  // swig gets confused otherwise
22  Score() {}
23 #ifdef IMP_DOXYGEN
24  /** Return the score at the passed feature size (eg distance). The involved
25  particle indexes are passed along.
26 
27  \pre get_is_trivially_zero() or get_maximum_range() has been called
28  and get_is_trivially_zero() is false. This allows things to be cached
29  across those calls.
30  */
31  template <unsigned int D>
32  double get_score(kernel::Model *m, const kernel::ParticleIndexTuple<D> &p,
33  double distance) const;
34  /** Return the score and derivative at the passed feature size (eg distance).
35  The derivative is for the feature decreasing.
36 
37  \pre get_is_trivially_zero() or get_maximum_range() has been called
38  and get_is_trivially_zero() is false. This allows things to be cached
39  across those calls.
40  */
41  template <unsigned int D>
42  DerivativePair get_score_and_derivative(
43  kernel::Model *m, const kernel::ParticleIndexTuple<D> &p,
44  double distance) const;
45 #endif
46  /** Return true if the function can be easily determined to be zero at the
47  passed squared distance. The default implementation provided here
48  returns false.
49 
50  \note That it is squared distance, not distance.
51  */
52  template <unsigned int D>
55  double squared_distance) const {
56  IMP_UNUSED(m);
57  IMP_UNUSED(p);
58  IMP_UNUSED(squared_distance);
59  return false;
60  }
61  /** Return an upper bound on the distance at which the score can be
62  non-zero. The default implementation provided here returns infinity.*/
63  template <unsigned int D>
66  IMP_UNUSED(m);
67  IMP_UNUSED(p);
68  return std::numeric_limits<double>::infinity();
69  }
70  /** Return the set of particles read when particle p is part of the passed
71  tuples. The default implementation provided here just returns the list
72  containing p.*/
74  kernel::Model *m, const kernel::ParticleIndexes &pis) const {
75  return IMP::get_particles(m, pis);
76  }
77  void show(std::ostream &) const {}
78 };
79 
80 IMPSCOREFUNCTOR_END_NAMESPACE
81 
82 #endif /* IMPSCORE_FUNCTOR_SCORE_H */
Import IMP/kernel/base_types.h in the namespace.
Import IMP/kernel/particle_index.h in the namespace.
ParticlesTemp get_particles(kernel::Model *m, const ParticleIndexes &ps)
bool get_is_trivially_zero(kernel::Model *m, const base::Array< D, kernel::ParticleIndex > &p, double squared_distance) const
Definition: Score.h:53
#define IMP_UNUSED(variable)
kernel::ModelObjectsTemp get_inputs(kernel::Model *m, const kernel::ParticleIndexes &pis) const
Definition: Score.h:73
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
Various general useful macros for IMP.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: base/types.h:23
double get_maximum_range(kernel::Model *m, const base::Array< D, kernel::ParticleIndex > &p) const
Definition: Score.h:64
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
Class for storing model, its restraints, constraints, and particles.