IMP  2.3.0
The Integrative Modeling Platform
IMP::kernel::Model Class Reference

Class for storing model, its restraints, constraints, and particles. More...

#include "IMP/Model.h"

+ Inheritance diagram for IMP::kernel::Model:

Detailed Description

Class for storing model, its restraints, constraints, and particles.

The Model maintains a standard IMP container for each of Particle, ScoreState and Restraint object types.

Each Float attribute has an associated range which reflects the range of values that it is expected to take on during optimization. The optimizer can use these ranges to make the optimization process more efficient. By default, the range estimates are simply the range of values for that attribute in the various particles, but it can be set to another value. For example, an attribute storing an angle could have the range set to (0,PI).

The ranges are not enforced; they are just guidelines. In order to enforce ranges, see, for example, IMP::example::ExampleSingletonModifier.

Examples:
atom/dope_and_excluded_volume.cpp, and core/simple.cpp.

Definition at line 73 of file kernel/Model.h.

Public Member Functions

 Model (std::string name="Model %1%")
 
ParticleIndex add_particle (std::string name)
 Add particle to the model. More...
 
void add_undecorator (ParticleIndex pi, Undecorator *d)
 
void clear_particle_caches (ParticleIndex pi)
 
double evaluate (bool tf, bool warn=true)
 
bool get_has_particle (ParticleIndex p) const
 
double get_maximum_score (Restraint *r) const
 
double get_maximum_score () const
 
ModelObjectsTemp get_model_objects () const
 
unsigned int get_number_of_particles () const
 
unsigned int get_number_of_restraints () const
 
Particleget_particle (ParticleIndex p) const
 
ParticleIndexes get_particle_indexes ()
 
std::string get_particle_name (ParticleIndex pi)
 Get the name of a particle. More...
 
ParticlesTemp get_particles () const
 
Restraintget_restraint (unsigned int i) const
 
RestraintSetget_root_restraint_set ()
 
virtual std::string get_type_name () const
 
virtual ::IMP::base::VersionInfo get_version_info () const
 Get information about the module and version of the object. More...
 
 operator Restraint * () const
 
ParticleIterator particles_begin () const
 
ParticleIterator particles_end () const
 
void remove_particle (ParticleIndex pi)
 
void remove_particle (Particle *p)
 
void set_maximum_score (Restraint *r, double s)
 
void set_maximum_score (double s)
 
void update ()
 Sometimes it is useful to be able to make sure the model is up to date. More...
 
- Public Member Functions inherited from IMP::base::Object
virtual void clear_caches ()
 
CheckLevel get_check_level () const
 
LogLevel get_log_level () const
 
void set_check_level (CheckLevel l)
 
void set_log_level (LogLevel l)
 Set the logging level used in this object. More...
 
void set_was_used (bool tf) const
 
void show (std::ostream &out=std::cout) const
 
const std::string & get_name () const
 
void set_name (std::string name)
 

States

ScoreStates can be added to the Model in order to keep them alive as long as the model is alive. Being added does affect their ability to perform their required action. See ScoreState for more information.

Note
Familiarity with these methods is not required to use imp.
void remove_score_state (ScoreState *d)
 
void remove_score_states (const ScoreStates &d)
 
void set_score_states (const ScoreStates &ps)
 
void set_score_states_order (const ScoreStates &objs)
 
unsigned int add_score_state (ScoreState *obj)
 
void add_score_states (const ScoreStates &objs)
 
void clear_score_states ()
 
unsigned int get_number_of_score_states () const
 
bool get_has_score_states ()
 
ScoreStateget_score_state (unsigned int i) const
 
ScoreStates get_score_states () const
 
void reserve_score_states (unsigned int sz)
 

Accessing attributes

All the attribute data associated with each Particle is stored in the Model. For each type of attribute, there are the methods detailed below (where, eg, TypeKey is FloatKey or StringKey)

void add_attribute (TypeKey attribute_key, ParticleIndex particle, Type value)
 
void remove_attribute (TypeKey attribute_key, ParticleIndex particle)
 
bool get_has_attribute (TypeKey attribute_key, ParticleIndex particle) const
 
void set_attribute (TypeKey attribute_key, ParticleIndex particle, Type value)
 
Type get_attribute (TypeKey attribute_key, ParticleIndex particle)
 
void add_cache_attribute (TypeKey attribute_key, ParticleIndex particle, Type value)
 
void set_is_optimized (TypeKey attribute_key, ParticleIndex particle, bool true_or_false)
 Optimized attributes are the parameters of the model. More...
 

Storing data in the model

One can store data associated with the model. This is used, for example, to keep a central ScoreState to normalize rigid body rotational variables.

void add_data (kernel::ModelKey mk, base::Object *o)
 
base::Objectget_data (kernel::ModelKey mk) const
 
void remove_data (kernel::ModelKey mk)
 
bool get_has_data (kernel::ModelKey mk) const
 

Additional Inherited Members

- Protected Member Functions inherited from IMP::base::Object
 Object (std::string name)
 Construct an object with the given name. More...
 
virtual void do_destroy ()
 

Constructor & Destructor Documentation

IMP::kernel::Model::Model ( std::string  name = "Model %1%")

Construct an empty model

Member Function Documentation

void IMP::kernel::Model::add_attribute ( TypeKey  attribute_key,
ParticleIndex  particle,
Type  value 
)
Precondition
get_has_attribute(attribute_key, particle) is false
void IMP::kernel::Model::add_cache_attribute ( TypeKey  attribute_key,
ParticleIndex  particle,
Type  value 
)

Cache attributes, unklike normal attributes, can be added during evaluation. They are also cleared by the clear_cache_attributes() method. Cache attributes should be used when one is adding data to a particle to aid scoring (eg cache the rigid body collision acceleration structure).

When some pertinent aspect of the particle changes, the clear method should be called (yes, this is a bit vague). Examples where it should be cleared include changing the set of members of a core::RigidBody or their coordinates, changing the members of an atom::Hierarchy.

void IMP::kernel::Model::add_data ( kernel::ModelKey  mk,
base::Object o 
)

Store a piece of data in the model referenced by the key.

ParticleIndex IMP::kernel::Model::add_particle ( std::string  name)

Add particle to the model.

Examples:
atom/dope_and_excluded_volume.cpp.
void IMP::kernel::Model::add_undecorator ( ParticleIndex  pi,
Undecorator d 
)

Add the passed Undecorator to the particle.

void IMP::kernel::Model::clear_particle_caches ( ParticleIndex  pi)

Clear all the cache attributes of a given particle.

double IMP::kernel::Model::evaluate ( bool  tf,
bool  warn = true 
)
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use a ScoringFunction instead.
Type IMP::kernel::Model::get_attribute ( TypeKey  attribute_key,
ParticleIndex  particle 
)
Precondition
get_has_attribute(attribute_key, particle) is true
base::Object* IMP::kernel::Model::get_data ( kernel::ModelKey  mk) const

Get back some data stored in the model.

bool IMP::kernel::Model::get_has_data ( kernel::ModelKey  mk) const

Check if the model has a certain piece of data attached.

bool IMP::kernel::Model::get_has_particle ( ParticleIndex  p) const

Get the particle from an index.

double IMP::kernel::Model::get_maximum_score ( Restraint r) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Get the maximum directly from the restraint.
double IMP::kernel::Model::get_maximum_score ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. You should use a ScoringFunction or a RestraintSet.
ModelObjectsTemp IMP::kernel::Model::get_model_objects ( ) const

Get all the ModelObjects associated with this Model.

unsigned int IMP::kernel::Model::get_number_of_particles ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use get_particle_indexes().
unsigned int IMP::kernel::Model::get_number_of_restraints ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use a RestraintSet instead.
Particle* IMP::kernel::Model::get_particle ( ParticleIndex  p) const

Get the particle from an index.

ParticleIndexes IMP::kernel::Model::get_particle_indexes ( )

Get all particle indexes

std::string IMP::kernel::Model::get_particle_name ( ParticleIndex  pi)

Get the name of a particle.

ParticlesTemp IMP::kernel::Model::get_particles ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use get_particle_indexes().
Restraint* IMP::kernel::Model::get_restraint ( unsigned int  i) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use a RestraintSet instead.
RestraintSet* IMP::kernel::Model::get_root_restraint_set ( )
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Using a ScoringFunction instead.
virtual ::IMP::base::VersionInfo IMP::kernel::Model::get_version_info ( ) const
virtual

Get information about the module and version of the object.

Reimplemented from IMP::base::Object.

Definition at line 321 of file kernel/Model.h.

IMP::kernel::Model::operator Restraint * ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use a ScoringFunction instead.

Definition at line 386 of file kernel/Model.h.

ParticleIterator IMP::kernel::Model::particles_begin ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use get_particle_indexes().
ParticleIterator IMP::kernel::Model::particles_end ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use get_particle_indexes().
void IMP::kernel::Model::remove_attribute ( TypeKey  attribute_key,
ParticleIndex  particle 
)
Precondition
get_has_attribute(attribute_key, particle) is true
void IMP::kernel::Model::remove_data ( kernel::ModelKey  mk)

Remove data stored in the model.

void IMP::kernel::Model::remove_particle ( ParticleIndex  pi)

Remove a particle from the Model. The particle will then be inactive and cannot be used for anything and all data stored in the particle is lost.

void IMP::kernel::Model::remove_particle ( Particle p)
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use the ParticleIndex version.
void IMP::kernel::Model::set_attribute ( TypeKey  attribute_key,
ParticleIndex  particle,
Type  value 
)
Precondition
get_has_attribute(attribute_key, particle) is true
void IMP::kernel::Model::set_is_optimized ( TypeKey  attribute_key,
ParticleIndex  particle,
bool  true_or_false 
)

Optimized attributes are the parameters of the model.

They will be modified by the samplers and optimizers.

void IMP::kernel::Model::set_maximum_score ( Restraint r,
double  s 
)
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Set get the maximum directly on the restraint.
void IMP::kernel::Model::set_maximum_score ( double  s)
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. You should use a ScoringFunction or a RestraintSet.
void IMP::kernel::Model::update ( )

Sometimes it is useful to be able to make sure the model is up to date.

This method updates all the state but does not necessarily compute the score. Use this to make sure that your containers and rigid bodies are up to date.


The documentation for this class was generated from the following file: