IMP  2.2.0
The Integrative Modeling Platform
score_functor/HarmonicLowerBound.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/HarmonicLowerBound.h
3  * \brief A Score on the distance between a pair of particles.
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H
9 #define IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H
10 
11 #include <IMP/score_functor/score_functor_config.h>
12 #include "Score.h"
13 #include <IMP/algebra/utility.h>
14 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
15 
16 /** A DistanceScore that scores with a harmonic on distances below 0.*/
17 class HarmonicLowerBound : public Score {
18  double k_;
19 
20  public:
21  HarmonicLowerBound(double k) : k_(k) {}
22  template <unsigned int D>
23  double get_score(kernel::Model *,
25  double distance) const {
26  if (distance > 0) return 0;
27  return .5 * k_ * algebra::get_squared(distance);
28  }
29  template <unsigned int D>
30  DerivativePair get_score_and_derivative(
32  double distance) const {
33  if (distance > 0) return DerivativePair(0, 0);
34  return DerivativePair(get_score(m, p, distance), k_ * (distance));
35  }
36  template <unsigned int D>
37  double get_maximum_range(
39  return 0;
40  }
41  template <unsigned int D>
42  bool get_is_trivially_zero(kernel::Model *,
44  double squared_distance) const {
45  return squared_distance > 0;
46  }
47 };
48 
49 IMPSCOREFUNCTOR_END_NAMESPACE
50 
51 #endif /* IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H */
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
Functions to deal with very common math operations.
A Score on the distance between a pair of particles.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: base/types.h:23
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72