IMP logo
IMP Reference Guide  2.9.0
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-2018 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 
23  public:
24  LinearLowerBound(double k) : k_(k) {}
25  // depend on get_is_trivially_zero
26  template <unsigned int D>
27  double get_score(Model *,
29  double distance) const {
30  if (distance >= 0) return 0;
31  return -k_ * distance;
32  }
33  template <unsigned int D>
34  DerivativePair get_score_and_derivative(
35  Model *, const Array<D, ParticleIndex> &,
36  double distance) const {
37  if (distance >= 0) return DerivativePair(0, 0);
38  return DerivativePair(-k_ * distance, -k_);
39  }
40  template <unsigned int D>
41  double get_maximum_range(
42  Model *, const Array<D, ParticleIndex> &) const {
43  return 0;
44  }
45  template <unsigned int D>
46  bool get_is_trivially_zero(Model *,
48  double squared_distance) const {
49  return squared_distance > 0;
50  }
51 
52  float get_k() const{
53  return k_;
54  }
55 };
56 
57 IMPSCOREFUNCTOR_END_NAMESPACE
58 
59 #endif /* IMPSCORE_FUNCTOR_LINEAR_LOWER_BOUND_H */
A class to store an fixed array of same-typed values.
Definition: Array.h:33
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
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: types.h:23
A functor for computing a distance based score for two particles.
Definition: Score.h:20