9 #ifndef IMPKERNEL_MODEL_H
10 #define IMPKERNEL_MODEL_H
12 #include <IMP/kernel_config.h>
22 #include "internal/AttributeTable.h"
23 #include "internal/attribute_tables.h"
26 #include <boost/unordered_map.hpp>
27 #include <boost/unordered_set.hpp>
29 #include <boost/iterator/transform_iterator.hpp>
30 #include <boost/iterator/filter_iterator.hpp>
34 IMPKERNEL_BEGIN_NAMESPACE
40 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
47 COMPUTING_DEPENDENCIES
73 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
75 public internal::Masks,
78 public internal::FloatAttributeTable,
79 public internal::StringAttributeTable,
80 public internal::IntAttributeTable,
81 public internal::ObjectAttributeTable,
82 public internal::WeakObjectAttributeTable,
83 public internal::IntsAttributeTable,
84 public internal::FloatsAttributeTable,
85 public internal::ObjectsAttributeTable,
86 public internal::ParticleAttributeTable,
87 public internal::ParticlesAttributeTable
95 typedef boost::unordered_map<const ModelObject *, NodeInfo>
DependencyGraph;
96 DependencyGraph dependency_graph_;
97 boost::unordered_set<const ModelObject *> no_dependencies_;
98 boost::unordered_map<const ModelObject *, ScoreStatesTemp>
99 required_score_states_;
102 boost::unordered_map<FloatKey, FloatRange> ranges_;
111 void do_clear_required_score_states(
ModelObject *mo);
112 void do_check_required_score_states(
const ModelObject *mo)
const;
113 void do_check_update_order(
const ScoreState *ss)
const;
114 void do_check_inputs_and_outputs(
const ModelObject *mo)
const;
115 void do_check_readers_and_writers(
const ModelObject *mo)
const;
116 void do_check_not_in_readers_and_writers(
const ModelObject *mo)
const;
118 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
125 internal::Stage cur_stage_;
129 bool do_get_has_dependencies(
const ModelObject *mo)
const {
130 return no_dependencies_.find(mo) == no_dependencies_.end();
132 void do_set_has_dependencies(
const ModelObject *mo,
bool tf);
133 void do_set_has_all_dependencies(
bool tf);
135 void validate_computed_derivatives()
const {}
136 void set_has_all_dependencies(
bool tf);
137 bool get_has_all_dependencies()
const;
138 void check_dependency_invariants()
const;
139 void check_dependency_invariants(
const ModelObject *mo)
const;
146 internal::Stage get_stage()
const {
return cur_stage_; }
148 static void do_remove_score_state(
ScoreState *obj);
151 bool do_get_has_required_score_states(
const ModelObject *mo)
const;
152 void do_set_has_required_score_states(
ModelObject *mo,
bool tf);
156 "Doesn't have score states");
157 return required_score_states_.find(mo)->second;
164 Model(std::string name =
"Model %1%");
167 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
168 IMP_MODEL_IMPORT(internal::FloatAttributeTable);
169 IMP_MODEL_IMPORT(internal::StringAttributeTable);
170 IMP_MODEL_IMPORT(internal::IntAttributeTable);
171 IMP_MODEL_IMPORT(internal::ObjectAttributeTable);
172 IMP_MODEL_IMPORT(internal::WeakObjectAttributeTable);
173 IMP_MODEL_IMPORT(internal::IntsAttributeTable);
174 IMP_MODEL_IMPORT(internal::FloatsAttributeTable);
175 IMP_MODEL_IMPORT(internal::ObjectsAttributeTable);
176 IMP_MODEL_IMPORT(internal::ParticleAttributeTable);
177 IMP_MODEL_IMPORT(internal::ParticlesAttributeTable);
205 do_remove_score_state(obj));
230 void add_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
234 void remove_attribute(TypeKey attribute_key,
ParticleIndex particle);
237 bool get_has_attribute(TypeKey attribute_key,
ParticleIndex particle)
const;
241 void set_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
245 Type get_attribute(TypeKey attribute_key,
ParticleIndex particle);
258 void add_cache_attribute(TypeKey attribute_key,
ParticleIndex particle,
263 void set_is_optimized(TypeKey attribute_key,
ParticleIndex particle,
269 #define IMP_MODEL_ATTRIBUTE_METHODS(Type, Value) \
270 void add_attribute(Type##Key attribute_key, ParticleIndex particle, \
272 void remove_attribute(Type##Key attribute_key, ParticleIndex particle); \
273 bool get_has_attribute(Type##Key attribute_key, \
274 ParticleIndex particle) const; \
275 void set_attribute(Type##Key attribute_key, ParticleIndex particle, \
277 Value get_attribute(Type##Key attribute_key, ParticleIndex particle); \
278 void add_cache_attribute(Type##Key attribute_key, ParticleIndex particle, \
282 IMP_MODEL_ATTRIBUTE_METHODS(
Int,
Int);
284 IMP_MODEL_ATTRIBUTE_METHODS(
Ints,
Ints);
289 IMP_MODEL_ATTRIBUTE_METHODS(WeakObject,
Object *);
298 return particle_index_[p];
303 if (particle_index_.size() <= get_as_unsigned_int(p))
return false;
304 return particle_index_[p];
331 bool get_has_data(
ModelKey mk)
const;
337 #if !defined(IMP_DOXYGEN)
342 IMPKERNEL_END_NAMESPACE
Particle * get_particle(ParticleIndex p) const
Get the particle from an index.
Used to hold a set of related restraints.
boost::graph DependencyGraph
Directed graph on the interactions between the various objects in the model.
The base class for undecorators.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
void add_particle(RMF::FileHandle fh, Particle *hs)
Macros to help in defining tuple classes.
virtual void clear_caches()
bool get_has_particle(ParticleIndex p) const
Check whether a given particle index exists.
Macros to define containers of objects.
Class for storing model, its restraints, constraints, and particles.
Base class for objects in a Model that depend on other objects.
virtual void do_destroy()
Common base class for heavy weight IMP objects.
ParticleIndexes get_particle_indexes(ParticlesTemp const &particles)
ScoreStates maintain invariants in the Model.
Implements a vector tied to a particular index of type Index<Tag>.
Base class for objects in a Model that depend on other objects.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
A nullptr-initialized pointer to an IMP Object.
A shared base class to help in debugging and things.
Represents a scoring function on the model.
double Float
Basic floating-point value (could be float, double...)
Class to handle individual particles of a Model object.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Abstract base class for all restraints.
int Int
Basic integer value.
std::string String
Basic string value.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.