12#ifndef IMPCORE_SINGLETON_PREDICATES_H
13#define IMPCORE_SINGLETON_PREDICATES_H
15#include <IMP/core/core_config.h>
19#include <boost/random.hpp>
20#include "internal/container_helpers.h"
21#include <cereal/access.hpp>
22#include <cereal/types/base_class.hpp>
24IMPCORE_BEGIN_NAMESPACE
27class IMPCOREEXPORT ConstantSingletonPredicate :
public SingletonPredicate {
30 friend class cereal::access;
31 template<
class Archive>
void serialize(Archive &ar) {
32 ar(cereal::base_class<SingletonPredicate>(
this), v_);
37 ConstantSingletonPredicate(
int v,
38 std::string name =
"ConstSingletonPredicate%1%");
40 ConstantSingletonPredicate() {}
59class IMPCOREEXPORT UnorderedTypeSingletonPredicate
60 :
public SingletonPredicate {
61 friend class cereal::access;
62 template<
class Archive>
void serialize(Archive &ar) {
63 ar(cereal::base_class<SingletonPredicate>(
this));
68 UnorderedTypeSingletonPredicate(std::string name =
69 "UnorderedTypeSingletonPredicate%1%");
72 return internal::get_type_hash(m, pi);
89class IMPCOREEXPORT OrderedTypeSingletonPredicate :
public SingletonPredicate {
91 mutable int const* cached_particle_type_ids_table_;
92 mutable int cached_n_particle_types_;
94 OrderedTypeSingletonPredicate(std::string name =
95 "OrderedTypeSingletonPredicate%1%");
98 return internal::get_ordered_type_hash(types);
103 return internal::get_ordered_type_hash(m, pi);
110 cached_particle_type_ids_table_=
111 m->IMP::internal::IntAttributeTable::access_attribute_data(Typed::get_type_key());
121 return internal::get_ordered_type_hash( pi,
122 cached_particle_type_ids_table_,
123 cached_n_particle_types_);
137class IMPCOREEXPORT AllSameSingletonPredicate :
public SingletonPredicate {
138 friend class cereal::access;
139 template<
class Archive>
void serialize(Archive &ar) {
140 ar(cereal::base_class<SingletonPredicate>(
this));
145 AllSameSingletonPredicate(std::string name =
"AllSameSingletonPredicate%1%");
148 return internal::get_all_same(m, pi);
159class IMPCOREEXPORT CoinFlipSingletonPredicate :
public SingletonPredicate {
161 mutable boost::random::uniform_real_distribution<double> rng_;
164 CoinFlipSingletonPredicate(
double p, std::string name =
165 "CoinFlipSingletonPredicate%1%");
Define SingletonPredicate.
A particle with a user-defined type.
static unsigned int get_number_unique()
Class for storing model, its restraints, constraints, and particles.
Return true (1) if all members of the tuple are the same.
virtual ModelObjectsTemp do_get_inputs(Model *, const ParticleIndexes &) const override
Overload this method to specify the inputs.
virtual int get_value_index(Model *m, ParticleIndex pi) const override
Compute the predicate and the derivative if needed.
Return true (1) with a fixed probability.
virtual ModelObjectsTemp do_get_inputs(Model *, const ParticleIndexes &) const override
Overload this method to specify the inputs.
virtual int get_value_index(Model *, ParticleIndex) const override
Compute the predicate and the derivative if needed.
Always return a constant value.
virtual ModelObjectsTemp do_get_inputs(Model *, const ParticleIndexes &) const override
Overload this method to specify the inputs.
virtual int get_value_index(Model *, ParticleIndex) const override
Compute the predicate and the derivative if needed.
Return a unique predicate value for each ordered set of ParticleTypes.
int get_value(const core::ParticleTypes &types)
Compute the predicate for specified types.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the inputs.
virtual void setup_for_get_value_index_in_batch(Model *m) const override
virtual int get_value_index(Model *m, ParticleIndex pi) const override
Compute the predicate for types of specific pi.
virtual int get_value_index_in_batch(Model *m, ParticleIndex pi) const override
Return a unique predicate value for each unordered set of ParticleTypes.
virtual int get_value_index(Model *m, ParticleIndex pi) const override
Compute the predicate and the derivative if needed.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the inputs.
IMP::Vector< ParticleType > ParticleTypes
Index< ParticleIndexTag > ParticleIndex
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
Get the particles from a list of indexes.
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
RandomNumberGenerator random_number_generator
A shared non-GPU random number generator.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Macros for various classes.
#define IMP_SINGLETON_PREDICATE_METHODS(Name)
Define extra the functions needed for a SingletonPredicate.
#define IMP_UNUSED(variable)