IMP  2.1.0
The Integrative Modeling Platform
triplet_predicates.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/triplet_predicates.h
3  * \brief Define some predicates.
4  *
5  * WARNING This file was generated from triplet_predicates.h
6  * in /tmp/nightly-build-90783/imp-2.1.0/tools/build/container_templates/core
7  * by tools/maintenance/setup_containers.py.
8  *
9  * Copyright 2007-2013 IMP Inventors. All rights reserved.
10  */
11 
12 #ifndef IMPCORE_TRIPLET_PREDICATES_H
13 #define IMPCORE_TRIPLET_PREDICATES_H
14 
15 #include <IMP/core/core_config.h>
16 #include <IMP/TripletPredicate.h>
17 #include <IMP/triplet_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 ConstantTripletPredicate : public TripletPredicate {
26  int v_;
27 
28  public:
30  std::string name = "ConstTripletPredicate%1%");
31  virtual int get_value_index(kernel::Model *, const ParticleIndexTriplet& ) const IMP_OVERRIDE {
32  return v_;
33  }
35  const IMP_OVERRIDE {
36  return kernel::ModelObjectsTemp();
37  }
40 };
41 
42 /** Return a unique predicate value for each unordered set of kernel::ParticleTypes
43  (see Typed).
44 */
45 
46 class IMPCOREEXPORT UnorderedTypeTripletPredicate
47  : public TripletPredicate {
48  public:
49  UnorderedTypeTripletPredicate(std::string name =
50  "UnorderedTypeTripletPredicate%1%");
51  virtual int get_value_index(kernel::Model *m, const ParticleIndexTriplet& pi) const IMP_OVERRIDE {
52  return internal::get_type_hash(m, pi);
53  }
55  const IMP_OVERRIDE {
57  ret += IMP::get_particles(m, pis);
58  return ret;
59  }
62 };
63 
64 /** Return a unique predicate value for each ordered triplet of
65  kernel::ParticleTypes (see Typed).
66 */
67 class IMPCOREEXPORT OrderedTypeTripletPredicate : public TripletPredicate {
68  public:
69  OrderedTypeTripletPredicate(std::string name =
70  "OrderedTypeTripletPredicate%1%");
71 #ifndef SWIG
73 #endif
74  int get_value(const core::ParticleTypes& types) {
75  return internal::get_ordered_type_hash(types);
76  }
77  virtual int get_value_index(kernel::Model *m, const ParticleIndexTriplet& pi) const IMP_OVERRIDE {
78  return internal::get_ordered_type_hash(m, pi);
79  }
81  const IMP_OVERRIDE {
83  ret += IMP::get_particles(m, pis);
84  return ret;
85  }
88 };
89 
90 /** Return true if all members of the tuple are the same. */
91 class IMPCOREEXPORT AllSameTripletPredicate : public TripletPredicate {
92  public:
93  AllSameTripletPredicate(std::string name = "AllSameTripletPredicate%1%");
94  virtual int get_value_index(kernel::Model *m, const ParticleIndexTriplet& pi) const IMP_OVERRIDE {
95  return internal::get_all_same(m, pi);
96  }
98  const IMP_OVERRIDE {
99  return kernel::ModelObjectsTemp();
100  }
103 };
104 
105 /** Return true with a fixed probability. */
106 class IMPCOREEXPORT CoinFlipTripletPredicate : public TripletPredicate {
107  double p_;
108  mutable boost::uniform_real<double> rng_;
109 
110  public:
111  CoinFlipTripletPredicate(double p, std::string name =
112  "CoinFlipTripletPredicate%1%");
113  virtual int get_value_index(kernel::Model *, const ParticleIndexTriplet& ) const IMP_OVERRIDE {
114  if (rng_(base::random_number_generator) < p_)
115  return 1;
116  else
117  return 0;
118  }
120  const IMP_OVERRIDE {
121  return kernel::ModelObjectsTemp();
122  }
125 };
126 
127 IMPCORE_END_NAMESPACE
128 
129 #endif /* IMPCORE_TRIPLET_PREDICATES_H */
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *m, const kernel::ParticleIndexes &pis) const
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *m, const kernel::ParticleIndexes &pis) const
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
RandomNumberGenerator random_number_generator
A shared random number generator.
Import IMP/kernel/triplet_macros.h in the namespace.
Import IMP/kernel/TripletPredicate.h in the namespace.
ParticlesTemp get_particles(kernel::Model *m, const ParticleIndexes &ps)
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
virtual int get_value_index(kernel::Model *m, const ParticleIndexTriplet &vt) const
Compute the predicate and the derivative if needed.
Abstract predicate function.
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
#define IMP_TRIPLET_PREDICATE_METHODS(Name)
Define extra the functions needed for a TripletPredicate.
virtual int get_value(const ParticleTriplet &vt) const
Class for storing model, its restraints, constraints, and particles.