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::ObjectsAttributeTable,
85 public internal::ParticleAttributeTable,
86 public internal::ParticlesAttributeTable
94 typedef boost::unordered_map<const ModelObject *, NodeInfo>
DependencyGraph;
95 DependencyGraph dependency_graph_;
96 boost::unordered_set<const ModelObject *> no_dependencies_;
97 boost::unordered_map<const ModelObject *, ScoreStatesTemp>
98 required_score_states_;
101 boost::unordered_map<FloatKey, FloatRange> ranges_;
110 void do_clear_required_score_states(
ModelObject *mo);
111 void do_check_required_score_states(
const ModelObject *mo)
const;
112 void do_check_update_order(
const ScoreState *ss)
const;
113 void do_check_inputs_and_outputs(
const ModelObject *mo)
const;
114 void do_check_readers_and_writers(
const ModelObject *mo)
const;
115 void do_check_not_in_readers_and_writers(
const ModelObject *mo)
const;
117 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
124 internal::Stage cur_stage_;
128 bool do_get_has_dependencies(
const ModelObject *mo)
const {
129 return no_dependencies_.find(mo) == no_dependencies_.end();
131 void do_set_has_dependencies(
const ModelObject *mo,
bool tf);
132 void do_set_has_all_dependencies(
bool tf);
134 void validate_computed_derivatives()
const {}
135 void set_has_all_dependencies(
bool tf);
136 bool get_has_all_dependencies()
const;
137 void check_dependency_invariants()
const;
138 void check_dependency_invariants(
const ModelObject *mo)
const;
145 internal::Stage get_stage()
const {
return cur_stage_; }
147 static void do_remove_score_state(
ScoreState *obj);
150 bool do_get_has_required_score_states(
const ModelObject *mo)
const;
151 void do_set_has_required_score_states(
ModelObject *mo,
bool tf);
155 "Doesn't have score states");
156 return required_score_states_.find(mo)->second;
163 Model(std::string name =
"Model %1%");
166 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
167 IMP_MODEL_IMPORT(internal::FloatAttributeTable);
168 IMP_MODEL_IMPORT(internal::StringAttributeTable);
169 IMP_MODEL_IMPORT(internal::IntAttributeTable);
170 IMP_MODEL_IMPORT(internal::ObjectAttributeTable);
171 IMP_MODEL_IMPORT(internal::WeakObjectAttributeTable);
172 IMP_MODEL_IMPORT(internal::IntsAttributeTable);
173 IMP_MODEL_IMPORT(internal::ObjectsAttributeTable);
174 IMP_MODEL_IMPORT(internal::ParticleAttributeTable);
175 IMP_MODEL_IMPORT(internal::ParticlesAttributeTable);
201 do_remove_score_state(obj));
226 void add_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
230 void remove_attribute(TypeKey attribute_key,
ParticleIndex particle);
233 bool get_has_attribute(TypeKey attribute_key,
ParticleIndex particle)
const;
237 void set_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
241 Type get_attribute(TypeKey attribute_key,
ParticleIndex particle);
254 void add_cache_attribute(TypeKey attribute_key,
ParticleIndex particle,
259 void set_is_optimized(TypeKey attribute_key,
ParticleIndex particle,
265 #define IMP_MODEL_ATTRIBUTE_METHODS(Type, Value) \
266 void add_attribute(Type##Key attribute_key, ParticleIndex particle, \
268 void remove_attribute(Type##Key attribute_key, ParticleIndex particle); \
269 bool get_has_attribute(Type##Key attribute_key, \
270 ParticleIndex particle) const; \
271 void set_attribute(Type##Key attribute_key, ParticleIndex particle, \
273 Value get_attribute(Type##Key attribute_key, ParticleIndex particle); \
274 void add_cache_attribute(Type##Key attribute_key, ParticleIndex particle, \
278 IMP_MODEL_ATTRIBUTE_METHODS(
Int,
Int);
279 IMP_MODEL_ATTRIBUTE_METHODS(
Ints,
Ints);
284 IMP_MODEL_ATTRIBUTE_METHODS(WeakObject,
Object *);
293 return particle_index_[p];
298 if (particle_index_.size() <= get_as_unsigned_int(p))
return false;
299 return particle_index_[p];
326 bool get_has_data(
ModelKey mk)
const;
332 #if !defined(IMP_DOXYGEN)
337 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
A directed graph on the interactions between the various objects in the model.
The base class for decorators.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
void add_particle(RMF::FileHandle fh, Particle *hs)
Various general useful macros for IMP.
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.
virtual void do_destroy()
Common base class for heavy weight IMP objects.
ScoreStates maintain invariants in the Model.
Single variable function.
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.