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
41 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
48 COMPUTING_DEPENDENCIES
74 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
76 public internal::Masks,
79 public internal::FloatAttributeTable,
80 public internal::StringAttributeTable,
81 public internal::IntAttributeTable,
82 public internal::ObjectAttributeTable,
83 public internal::WeakObjectAttributeTable,
84 public internal::IntsAttributeTable,
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_;
115 void do_check_required_score_states(
const ModelObject *mo)
const;
116 void do_check_update_order(
const ScoreState *ss)
const;
117 void do_check_inputs_and_outputs(
const ModelObject *mo)
const;
118 void do_check_readers_and_writers(
const ModelObject *mo)
const;
119 void do_check_not_in_readers_and_writers(
const ModelObject *mo)
const;
121 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
128 internal::Stage cur_stage_;
132 bool do_get_has_dependencies(
const ModelObject *mo)
const {
133 return no_dependencies_.find(mo) == no_dependencies_.end();
135 void do_set_has_dependencies(
const ModelObject *mo,
bool tf);
136 void do_set_has_all_dependencies(
bool tf);
138 void validate_computed_derivatives()
const {}
139 void set_has_all_dependencies(
bool tf);
140 bool get_has_all_dependencies()
const;
141 void check_dependency_invariants()
const;
142 void check_dependency_invariants(
const ModelObject *mo)
const;
149 internal::Stage get_stage()
const {
return cur_stage_; }
151 static void do_remove_score_state(
ScoreState *obj);
154 bool do_get_has_required_score_states(
const ModelObject *mo)
const;
159 "Doesn't have score states");
160 return required_score_states_.find(mo)->second;
167 Model(std::string name =
"Model %1%");
170 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
171 IMP_MODEL_IMPORT(internal::FloatAttributeTable);
172 IMP_MODEL_IMPORT(internal::StringAttributeTable);
173 IMP_MODEL_IMPORT(internal::IntAttributeTable);
174 IMP_MODEL_IMPORT(internal::ObjectAttributeTable);
175 IMP_MODEL_IMPORT(internal::WeakObjectAttributeTable);
176 IMP_MODEL_IMPORT(internal::IntsAttributeTable);
177 IMP_MODEL_IMPORT(internal::ObjectsAttributeTable);
178 IMP_MODEL_IMPORT(internal::ParticleAttributeTable);
179 IMP_MODEL_IMPORT(internal::ParticlesAttributeTable);
205 do_remove_score_state(obj));
229 void add_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
232 void remove_attribute(TypeKey attribute_key,
ParticleIndex particle);
234 bool get_has_attribute(TypeKey attribute_key,
ParticleIndex particle)
const;
237 void set_attribute(TypeKey attribute_key,
ParticleIndex particle, Type value);
240 Type get_attribute(TypeKey attribute_key,
ParticleIndex particle);
253 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);
283 IMP_MODEL_ATTRIBUTE_METHODS(Object, Object *);
284 IMP_MODEL_ATTRIBUTE_METHODS(WeakObject, Object *);
325 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
329 typedef boost::filter_iterator<
335 #if !defined(IMP_DOXYGEN)
345 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
346 unsigned
int get_number_of_restraints() const;
348 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
349 Restraint *get_restraint(
unsigned int i) const;
351 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
352 double evaluate(
bool tf,
bool warn = true);
354 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
357 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
358 unsigned int get_number_of_particles() const;
360 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
363 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
366 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
367 double get_maximum_score(
Restraint *r) const;
369 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
370 void set_maximum_score(
Restraint *r,
double s);
372 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
373 void set_maximum_score(
double s);
375 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
376 double get_maximum_score() const;
379 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
380 ParticleIterator particles_begin() const;
382 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
383 ParticleIterator particles_end() const;
385 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
386 operator
Restraint *()
const {
return restraints_.get(); }
390 IMPKERNEL_END_NAMESPACE
IMP::kernel::ModelObject ModelObject
The base class for decorators.
A smart pointer to a ref-counted Object that is a class member.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
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)
Various general useful macros for IMP.
Represents a scoring function on the model.
ScoreStates maintain invariants in the Model.
ScoringFunction * create_scoring_function(RestraintType *rs, double weight=1.0, double max=NO_MAX, std::string name=std::string())
virtual void clear_caches()
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.
Class to handle individual model particles.
IMP::kernel::DependencyGraph DependencyGraph
Common base class for heavy weight IMP objects.
Classes to handle individual model particles. (Note that implementation of inline functions in in int...
A nullptr-initialized pointer to an IMP Object.
A shared base class to help in debugging and things.
IMP::kernel::Particle Particle
double Float
Basic floating-point value (could be float, double...)
virtual void do_destroy()
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
int Int
Basic integer value.
Macros to define containers of objects.
void add_particle(RMF::FileHandle fh, kernel::Particle *hs)
void add_restraint(RMF::FileHandle fh, kernel::Restraint *hs)
std::string String
Basic string value.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.