10 #ifndef IMPKERNEL_MODEL_H
11 #define IMPKERNEL_MODEL_H
13 #include <IMP/kernel/kernel_config.h>
23 #include "internal/AttributeTable.h"
24 #include "internal/attribute_tables.h"
27 #include <boost/unordered_map.hpp>
28 #include <boost/unordered_set.hpp>
30 #include <boost/iterator/transform_iterator.hpp>
31 #include <boost/iterator/filter_iterator.hpp>
35 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_;
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;
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);
188 return get_particle(pi)->get_name();
206 do_remove_score_state(obj));
230 void add_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
233 void remove_attribute(TypeKey attribute_key,
ParticleIndex particle);
235 bool get_has_attribute(TypeKey attribute_key,
ParticleIndex particle)
const;
238 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,
260 void set_is_optimized(TypeKey attribute_key,
ParticleIndex particle,
266 #define IMP_MODEL_ATTRIBUTE_METHODS(Type, Value) \
267 void add_attribute(Type##Key attribute_key, ParticleIndex particle, \
269 void remove_attribute(Type##Key attribute_key, ParticleIndex particle); \
270 bool get_has_attribute(Type##Key attribute_key, \
271 ParticleIndex particle) const; \
272 void set_attribute(Type##Key attribute_key, ParticleIndex particle, \
274 Value get_attribute(Type##Key attribute_key, ParticleIndex particle); \
275 void add_cache_attribute(Type##Key attribute_key, ParticleIndex particle, \
279 IMP_MODEL_ATTRIBUTE_METHODS(
Int,
Int);
280 IMP_MODEL_ATTRIBUTE_METHODS(
Ints,
Ints);
284 IMP_MODEL_ATTRIBUTE_METHODS(Object, Object *);
285 IMP_MODEL_ATTRIBUTE_METHODS(WeakObject, Object *);
326 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
330 typedef boost::filter_iterator<
336 #if !defined(IMP_DOXYGEN)
346 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
347 unsigned
int get_number_of_restraints() const;
349 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
350 Restraint *get_restraint(
unsigned int i) const;
352 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
353 double evaluate(
bool tf,
bool warn = true);
355 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
358 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
359 unsigned int get_number_of_particles() const;
361 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
364 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
367 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
368 double get_maximum_score(
Restraint *r) const;
370 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
371 void set_maximum_score(
Restraint *r,
double s);
373 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
374 void set_maximum_score(
double s);
376 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
377 double get_maximum_score() const;
380 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
381 ParticleIterator particles_begin() const;
383 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
384 ParticleIterator particles_end() const;
386 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
387 operator
Restraint *()
const {
return restraints_.get(); }
391 IMPKERNEL_END_NAMESPACE
IMP::kernel::ModelObject ModelObject
The base class for decorators.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
A nullptr-initialized pointer to an IMP Object.
A smart pointer to a ref-counted Object that is a class memeber.
ParticlesTemp get_particles(kernel::Model *m, const ParticleIndexes &ps)
IMP::base::Vector< IMP::base::WeakPointer< Restraint > > RestraintsTemp
Object used to hold a set of restraints.
A smart pointer to a reference counted object.
kernel::RestraintsTemp get_restraints(const Subset &s, const ParticleStatesTable *pst, const DependencyGraph &dg, kernel::RestraintSet *rs)
ScoreStates maintian invariants in the Model.
ScoringFunction * create_scoring_function(RestraintType *rs, double weight=1.0, double max=NO_MAX, std::string name=std::string())
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
virtual void clear_caches()
Various general useful macros for IMP.
Single variable function.
Abstract base class for all restraints.
Storage of a model, its restraints, constraints and particles.
A restraint is a term in an IMP ScoringFunction.
Used to hold a set of related restraints.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Class to handle individual model particles.
IMP::kernel::DependencyGraph DependencyGraph
Common base class for heavy weight IMP objects.
Classes to handle individual model particles.
double Float
Basic floating-point value (could be float, double...)
virtual void do_destroy()
int Int
Basic integer value.
Macros to define containers of objects.
A shared base class to help in debugging and things.
void add_particle(RMF::FileHandle fh, kernel::Particle *hs)
void add_restraint(RMF::FileHandle fh, kernel::Restraint *hs)
std::string String
Basic string value.
Class for storing model, its restraints, constraints, and particles.
std::string get_particle_name(ParticleIndex pi)
Get the name of a particle.