IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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 harmonic score on the negative directed distance between
4 * a pair of particles. The score equals zero for
5 * non-negative directed distances.
6 *
7 * Copyright 2007-2022 IMP Inventors. All rights reserved.
8 */
9
10#ifndef IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H
11#define IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H
12
13#include <IMP/score_functor/score_functor_config.h>
14#include "Score.h"
15#include <IMP/algebra/utility.h>
16#include <cereal/access.hpp>
17
18IMPSCOREFUNCTOR_BEGIN_NAMESPACE
19
20/** A harmonic score on the negative directed distance between
21 a pair of particles. The score equals zero for
22 non-negative directed distances.
23*/
24class HarmonicLowerBound : public Score {
25 double k_;
26
27 friend class cereal::access;
28 template<class Archive> void serialize(Archive &ar) {
29 ar(k_);
30 }
31
32 public:
33 HarmonicLowerBound(double k) : k_(k) {}
34 HarmonicLowerBound() {}
35
36 double get_k() const { return k_; }
37
38 template <unsigned int D>
39 double get_score(Model *,
41 double distance) const {
42 if (distance > 0) return 0;
43 return .5 * k_ * algebra::get_squared(distance);
44 }
45 template <unsigned int D>
46 DerivativePair get_score_and_derivative(
47 Model *m, const Array<D, ParticleIndex> &p,
48 double distance) const {
49 if (distance > 0) return DerivativePair(0, 0);
50 return DerivativePair(get_score(m, p, distance), k_ * (distance));
51 }
52 template <unsigned int D>
53 double get_maximum_range(
54 Model *, const Array<D, ParticleIndex> &) const {
55 return 0;
56 }
57 template <unsigned int D>
58 bool get_is_trivially_zero(Model *,
60 double squared_distance) const {
61 return squared_distance > 0;
62 }
63};
64
65IMPSCOREFUNCTOR_END_NAMESPACE
66
67#endif /* IMPSCORE_FUNCTOR_HARMONIC_LOWER_BOUND_H */
A Score on the distance between a pair of particles.
Functions to deal with very common math operations.
A class to store a fixed array of same-typed values.
Definition Array.h:40
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition types.h:22