IMP  2.2.1
The Integrative Modeling Platform
quad_predicates.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/quad_predicates.h
3  * \brief Define some predicates.
4  *
5  * WARNING This file was generated from quad_predicates.h
6  * in /tmp/nightly-build-90828/imp-2.2.1/tools/build/container_templates/core
7  * by tools/maintenance/setup_containers.py.
8  *
9  * Copyright 2007-2014 IMP Inventors. All rights reserved.
10  */
11 
12 #ifndef IMPCORE_QUAD_PREDICATES_H
13 #define IMPCORE_QUAD_PREDICATES_H
14 
15 #include <IMP/core/core_config.h>
16 #include <IMP/QuadPredicate.h>
17 #include <IMP/quad_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 ConstantQuadPredicate : public QuadPredicate {
26  int v_;
27 
28  public:
30  std::string name = "ConstQuadPredicate%1%");
32  IMP_OVERRIDE {
33  return v_;
34  }
36  kernel::Model *, const kernel::ParticleIndexes &) const IMP_OVERRIDE {
37  return kernel::ModelObjectsTemp();
38  }
41 };
42 
43 /** Return a unique predicate value for each unordered set of
44  kernel::ParticleTypes
45  (see Typed).
46 */
47 
48 class IMPCOREEXPORT UnorderedTypeQuadPredicate
49  : public QuadPredicate {
50  public:
51  UnorderedTypeQuadPredicate(std::string name =
52  "UnorderedTypeQuadPredicate%1%");
53  virtual int get_value_index(kernel::Model *m, const kernel::ParticleIndexQuad& pi) const
54  IMP_OVERRIDE {
55  return internal::get_type_hash(m, pi);
56  }
58  kernel::Model *m, const kernel::ParticleIndexes &pis) const IMP_OVERRIDE {
60  ret += IMP::get_particles(m, pis);
61  return ret;
62  }
65 };
66 
67 /** Return a unique predicate value for each ordered quad of
68  kernel::ParticleTypes (see Typed).
69 */
70 class IMPCOREEXPORT OrderedTypeQuadPredicate : public QuadPredicate {
71  public:
72  OrderedTypeQuadPredicate(std::string name =
73  "OrderedTypeQuadPredicate%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(kernel::Model *m, const kernel::ParticleIndexQuad& pi) const
81  IMP_OVERRIDE {
82  return internal::get_ordered_type_hash(m, pi);
83  }
85  kernel::Model *m, const kernel::ParticleIndexes &pis) const IMP_OVERRIDE {
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 AllSameQuadPredicate : public QuadPredicate {
96  public:
97  AllSameQuadPredicate(std::string name = "AllSameQuadPredicate%1%");
98  virtual int get_value_index(kernel::Model *m, const kernel::ParticleIndexQuad& pi) const
99  IMP_OVERRIDE {
100  return internal::get_all_same(m, pi);
101  }
103  kernel::Model *, const kernel::ParticleIndexes &) const IMP_OVERRIDE {
104  return kernel::ModelObjectsTemp();
105  }
108 };
109 
110 /** Return true with a fixed probability. */
111 class IMPCOREEXPORT CoinFlipQuadPredicate : public QuadPredicate {
112  double p_;
113  mutable boost::uniform_real<double> rng_;
114 
115  public:
116  CoinFlipQuadPredicate(double p, std::string name =
117  "CoinFlipQuadPredicate%1%");
119  IMP_OVERRIDE {
120  if (rng_(base::random_number_generator) < p_)
121  return 1;
122  else
123  return 0;
124  }
126  kernel::Model *, const kernel::ParticleIndexes &) const IMP_OVERRIDE {
127  return kernel::ModelObjectsTemp();
128  }
131 };
132 
133 IMPCORE_END_NAMESPACE
134 
135 #endif /* IMPCORE_QUAD_PREDICATES_H */
Import IMP/kernel/QuadPredicate.h in the namespace.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
RandomNumberGenerator random_number_generator
A shared random number generator.
ParticlesTemp get_particles(kernel::Model *m, const ParticleIndexes &ps)
Import IMP/kernel/quad_macros.h in the namespace.
Abstract predicate function.
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
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
virtual int get_value_index(kernel::Model *m, const kernel::ParticleIndexQuad &pi) const
Compute the predicate and the derivative if needed.
virtual int get_value_index(kernel::Model *, const kernel::ParticleIndexQuad &) const
Compute the predicate and the derivative if needed.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
#define IMP_QUAD_PREDICATE_METHODS(Name)
Define extra the functions needed for a QuadPredicate.
virtual int get_value_index(kernel::Model *m, const kernel::ParticleIndexQuad &pi) const
Compute the predicate and the derivative if needed.
virtual int get_value_index(kernel::Model *, const kernel::ParticleIndexQuad &) const
Compute the predicate and the derivative if needed.
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *, const kernel::ParticleIndexes &) const
virtual int get_value_index(kernel::Model *m, const kernel::ParticleIndexQuad &pi) const
Compute the predicate and the derivative if needed.
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *m, const kernel::ParticleIndexes &pis) const
virtual int get_value(const kernel::ParticleQuad &vt) const
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72