IMP  2.0.1
The Integrative Modeling Platform
LinearLowerBound.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/LinearLowerBound.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_LINEAR_LOWER_BOUND_H
9 #define IMPSCORE_FUNCTOR_LINEAR_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 linear function on distances below 0.
17 
18  \note a positive k results in repulsion
19 */
20 class LinearLowerBound: public Score {
21  const double k_;
22 public:
23  LinearLowerBound(double k): k_(k){}
24  // depend on get_is_trivially_zero
25  template <unsigned int D>
26  double get_score(Model *, const base::Array<D, ParticleIndex>&,
27  double distance) const {
28  IMP_USAGE_CHECK(distance <= 0,
29  "It is trivially 0.");
30  return -k_*distance;
31  }
32  template <unsigned int D>
33  DerivativePair get_score_and_derivative(Model *,
35  double distance) const {
36  return DerivativePair(-k_*distance, -k_);
37  }
38  template <unsigned int D>
39  double get_maximum_range(Model *,
40  const base::Array<D, ParticleIndex>& ) const {
41  return 0;
42  }
43  template <unsigned int D>
44  bool get_is_trivially_zero(Model *, const base::Array<D, ParticleIndex>& ,
45  double squared_distance) const {
46  return squared_distance > 0;
47  }
48 };
49 
50 IMPSCOREFUNCTOR_END_NAMESPACE
51 
52 #endif /* IMPSCORE_FUNCTOR_LINEAR_LOWER_BOUND_H */