IMP logo
IMP Reference Guide  2.8.0
The Integrative Modeling Platform
pair_predicates.h
Go to the documentation of this file.
1 // Autogenerated by ../../../../tmp/nightly-build-97111/imp-2.8.0/tools/build/make_containers.py
2 // from ../../../../tmp/nightly-build-97111/imp-2.8.0/tools/build/container_templates/core/classname_predicates.h
3 // Do not edit - any changes will be lost!
4 
5 /**
6  * \file IMP/core/pair_predicates.h
7  * \brief Define some predicates.
8  *
9  * Copyright 2007-2017 IMP Inventors. All rights reserved.
10  */
11 
12 #ifndef IMPCORE_PAIR_PREDICATES_H
13 #define IMPCORE_PAIR_PREDICATES_H
14 
15 #include <IMP/core/core_config.h>
16 #include <IMP/PairPredicate.h>
17 #include <IMP/pair_macros.h>
18 #include <boost/random.hpp>
19 #include "internal/container_helpers.h"
20 
21 IMPCORE_BEGIN_NAMESPACE
22 
23 /** Always return a constant value.
24  */
25 class IMPCOREEXPORT ConstantPairPredicate : public PairPredicate {
26  int v_;
27 
28  public:
30  std::string name = "ConstPairPredicate%1%");
31  virtual int get_value_index(Model *, const ParticleIndexPair&) const
32  IMP_OVERRIDE {
33  return v_;
34  }
36  Model *, const ParticleIndexes &) const IMP_OVERRIDE {
37  return ModelObjectsTemp();
38  }
41 };
42 
43 /** Return a unique predicate value for each unordered set of
44  ParticleTypes
45  (see Typed).
46 */
47 
48 class IMPCOREEXPORT UnorderedTypePairPredicate
49  : public PairPredicate {
50  public:
51  UnorderedTypePairPredicate(std::string name =
52  "UnorderedTypePairPredicate%1%");
53  virtual int get_value_index(Model *m, const ParticleIndexPair& pi) const
54  IMP_OVERRIDE {
55  return internal::get_type_hash(m, pi);
56  }
58  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE {
59  ModelObjectsTemp ret;
60  ret += IMP::get_particles(m, pis);
61  return ret;
62  }
65 };
66 
67 /** Return a unique predicate value for each ordered pair of
68  ParticleTypes (see Typed).
69 */
70 class IMPCOREEXPORT OrderedTypePairPredicate : public PairPredicate {
71  public:
72  OrderedTypePairPredicate(std::string name =
73  "OrderedTypePairPredicate%1%");
74 #ifndef SWIG
76 #endif
77  int get_value(const core::ParticleTypes &types) {
78  return internal::get_ordered_type_hash(types);
79  }
80  virtual int get_value_index(Model *m, const ParticleIndexPair& pi) const
81  IMP_OVERRIDE {
82  return internal::get_ordered_type_hash(m, pi);
83  }
85  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE {
86  ModelObjectsTemp ret;
87  ret += IMP::get_particles(m, pis);
88  return ret;
89  }
92 };
93 
94 /** Return true if all members of the tuple are the same. */
95 class IMPCOREEXPORT AllSamePairPredicate : public PairPredicate {
96  public:
97  AllSamePairPredicate(std::string name = "AllSamePairPredicate%1%");
98  virtual int get_value_index(Model *m, const ParticleIndexPair& pi) const
99  IMP_OVERRIDE {
100  return internal::get_all_same(m, pi);
101  }
103  Model *, const ParticleIndexes &) const IMP_OVERRIDE {
104  return ModelObjectsTemp();
105  }
108 };
109 
110 /** Return true with a fixed probability. */
111 class IMPCOREEXPORT CoinFlipPairPredicate : public PairPredicate {
112  double p_;
113  mutable boost::uniform_real<double> rng_;
114 
115  public:
116  CoinFlipPairPredicate(double p, std::string name =
117  "CoinFlipPairPredicate%1%");
118  virtual int get_value_index(Model *, const ParticleIndexPair&) const
119  IMP_OVERRIDE {
120  if (rng_(random_number_generator) < p_)
121  return 1;
122  else
123  return 0;
124  }
126  Model *, const ParticleIndexes &) const IMP_OVERRIDE {
127  return ModelObjectsTemp();
128  }
131 };
132 
133 IMPCORE_END_NAMESPACE
134 
135 #endif /* IMPCORE_PAIR_PREDICATES_H */
virtual ModelObjectsTemp do_get_inputs(Model *, const ParticleIndexes &) const
Overload this method to specify the inputs.
virtual int get_value_index(Model *m, const ParticleIndexPair &pi) const
Compute the predicate and the derivative if needed.
virtual ModelObjectsTemp do_get_inputs(Model *, const ParticleIndexes &) const
Overload this method to specify the inputs.
Macros for various classes.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
A more IMP-like version of the std::vector.
Definition: Vector.h:39
virtual int get_value_index(Model *m, const ParticleIndexPair &pi) const
Compute the predicate and the derivative if needed.
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition: base_types.h:82
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
virtual int get_value_index(Model *, const ParticleIndexPair &) const
Compute the predicate and the derivative if needed.
Define PairPredicate.
Abstract predicate function.
Definition: PairPredicate.h:31
virtual int get_value_index(Model *m, const ParticleIndexPair &pi) const
Compute the predicate and the derivative if needed.
virtual ModelObjectsTemp do_get_inputs(Model *, const ParticleIndexes &) const
Overload this method to specify the inputs.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const
Overload this method to specify the inputs.
virtual int get_value(const ParticlePair &vt) const
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
RandomNumberGenerator random_number_generator
A shared non-GPU random number generator.
virtual int get_value_index(Model *, const ParticleIndexPair &) const
Compute the predicate and the derivative if needed.
#define IMP_PAIR_PREDICATE_METHODS(Name)
Define extra the functions needed for a PairPredicate.
Definition: pair_macros.h:47
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const
Overload this method to specify the inputs.