9 #ifndef IMPKERNEL_MODEL_H
10 #define IMPKERNEL_MODEL_H
12 #include <IMP/kernel_config.h>
18 #include "container_macros.h"
19 #include "base_types.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_;
113 void do_clear_required_score_states(
ModelObject *mo);
114 void do_check_required_score_states(
const ModelObject *mo)
const;
115 void do_check_update_order(
const ScoreState *ss)
const;
116 void do_check_inputs_and_outputs(
const ModelObject *mo)
const;
117 void do_check_readers_and_writers(
const ModelObject *mo)
const;
118 void do_check_not_in_readers_and_writers(
const ModelObject *mo)
const;
120 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
127 internal::Stage cur_stage_;
131 bool do_get_has_dependencies(
const ModelObject *mo)
const {
132 return no_dependencies_.find(mo) == no_dependencies_.end();
134 void do_set_has_dependencies(
const ModelObject *mo,
bool tf);
135 void do_set_has_all_dependencies(
bool tf);
137 void validate_computed_derivatives()
const {}
138 void set_has_all_dependencies(
bool tf);
139 bool get_has_all_dependencies()
const;
140 void check_dependency_invariants()
const;
141 void check_dependency_invariants(
const ModelObject *mo)
const;
148 internal::Stage get_stage()
const {
return cur_stage_; }
150 static void do_remove_score_state(
ScoreState *obj);
153 bool do_get_has_required_score_states(
const ModelObject *mo)
const;
154 void do_set_has_required_score_states(
ModelObject *mo,
bool tf);
158 "Doesn't have score states");
159 return required_score_states_.find(mo)->second;
166 Model(std::string name =
"Model %1%");
169 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
170 IMP_MODEL_IMPORT(internal::FloatAttributeTable);
171 IMP_MODEL_IMPORT(internal::StringAttributeTable);
172 IMP_MODEL_IMPORT(internal::IntAttributeTable);
173 IMP_MODEL_IMPORT(internal::ObjectAttributeTable);
174 IMP_MODEL_IMPORT(internal::WeakObjectAttributeTable);
175 IMP_MODEL_IMPORT(internal::IntsAttributeTable);
176 IMP_MODEL_IMPORT(internal::ObjectsAttributeTable);
177 IMP_MODEL_IMPORT(internal::ParticleAttributeTable);
178 IMP_MODEL_IMPORT(internal::ParticlesAttributeTable);
204 do_remove_score_state(obj));
228 void add_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
231 void remove_attribute(TypeKey attribute_key,
ParticleIndex particle);
233 bool get_has_attribute(TypeKey attribute_key,
ParticleIndex particle)
const;
236 void set_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
239 Type get_attribute(TypeKey attribute_key,
ParticleIndex particle);
252 void add_cache_attribute(TypeKey attribute_key,
ParticleIndex particle,
258 void set_is_optimized(TypeKey attribute_key,
ParticleIndex particle,
264 #define IMP_MODEL_ATTRIBUTE_METHODS(Type, Value) \
265 void add_attribute(Type##Key attribute_key, ParticleIndex particle, \
267 void remove_attribute(Type##Key attribute_key, ParticleIndex particle); \
268 bool get_has_attribute(Type##Key attribute_key, \
269 ParticleIndex particle) const; \
270 void set_attribute(Type##Key attribute_key, ParticleIndex particle, \
272 Value get_attribute(Type##Key attribute_key, ParticleIndex particle); \
273 void add_cache_attribute(Type##Key attribute_key, ParticleIndex particle, \
277 IMP_MODEL_ATTRIBUTE_METHODS(
Int,
Int);
278 IMP_MODEL_ATTRIBUTE_METHODS(
Ints,
Ints);
283 IMP_MODEL_ATTRIBUTE_METHODS(WeakObject,
Object *);
319 bool get_has_data(
ModelKey mk)
const;
326 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
330 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
333 #if !defined(IMP_DOXYGEN)
338 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
339 double evaluate(
bool tf,
bool warn = true);
341 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
345 IMPKERNEL_END_NAMESPACE
350 #include "IMP/Particle.h"
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()
Object used to hold a set of restraints.
Class for storing model, its restraints, constraints, and particles.
void add_restraint(RMF::FileHandle fh, Restraint *hs)
virtual void do_destroy()
Common base class for heavy weight IMP objects.
ScoreStates maintain invariants in the Model.
A smart pointer to a ref-counted Object that is a class member.
Single variable function.
A nullptr-initialized pointer to an IMP Object.
Represents a scoring function on the model.
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 model particles.
#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.
A restraint is a term in an IMP ScoringFunction.