IMP  2.1.1
The Integrative Modeling Platform
singleton_predicates.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/singleton_predicates.h
3  * \brief Define some predicates.
4  *
5  * WARNING This file was generated from singleton_predicates.h
6  * in /tmp/nightly-build-61576/imp-2.1.1/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_SINGLETON_PREDICATES_H
13 #define IMPCORE_SINGLETON_PREDICATES_H
14 
15 #include <IMP/core/core_config.h>
16 #include <IMP/SingletonPredicate.h>
17 #include <IMP/singleton_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 ConstantSingletonPredicate : public SingletonPredicate {
26  int v_;
27 
28  public:
30  std::string name = "ConstSingletonPredicate%1%");
31  virtual int get_value_index(kernel::Model *, ParticleIndex ) 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 
47  : public SingletonPredicate {
48  public:
49  UnorderedTypeSingletonPredicate(std::string name =
50  "UnorderedTypeSingletonPredicate%1%");
51  virtual int get_value_index(kernel::Model *m, ParticleIndex 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 singleton of
65  kernel::ParticleTypes (see Typed).
66 */
67 class IMPCOREEXPORT OrderedTypeSingletonPredicate : public SingletonPredicate {
68  public:
69  OrderedTypeSingletonPredicate(std::string name =
70  "OrderedTypeSingletonPredicate%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, ParticleIndex 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 AllSameSingletonPredicate : public SingletonPredicate {
92  public:
93  AllSameSingletonPredicate(std::string name = "AllSameSingletonPredicate%1%");
94  virtual int get_value_index(kernel::Model *m, ParticleIndex 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 CoinFlipSingletonPredicate : public SingletonPredicate {
107  double p_;
108  mutable boost::uniform_real<double> rng_;
109 
110  public:
111  CoinFlipSingletonPredicate(double p, std::string name =
112  "CoinFlipSingletonPredicate%1%");
113  virtual int get_value_index(kernel::Model *, ParticleIndex ) 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_SINGLETON_PREDICATES_H */
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *m, const kernel::ParticleIndexes &pis) const
RandomNumberGenerator random_number_generator
A shared random number generator.
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
ParticlesTemp get_particles(kernel::Model *m, const ParticleIndexes &ps)
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *m, const kernel::ParticleIndexes &pis) const
Import IMP/kernel/singleton_macros.h in the namespace.
virtual int get_value_index(kernel::Model *, ParticleIndex) const
Compute the predicate and the derivative if needed.
Import IMP/kernel/SingletonPredicate.h in the namespace.
virtual int get_value_index(kernel::Model *m, ParticleIndex pi) const
Compute the predicate and the derivative if needed.
virtual int get_value_index(kernel::Model *m, ParticleIndex pi) const
Compute the predicate and the derivative if needed.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
#define IMP_SINGLETON_PREDICATE_METHODS(Name)
Define extra the functions needed for a SingletonPredicate.
virtual int get_value_index(kernel::Model *, ParticleIndex) const
Compute the predicate and the derivative if needed.
Abstract predicate function.
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
virtual int get_value_index(kernel::Model *m, ParticleIndex pi) const
Compute the predicate and the derivative if needed.
virtual int get_value(Particle *vt) const
Class for storing model, its restraints, constraints, and particles.