IMP logo
Public Member Functions

IMP::Model Class Reference


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.

Note:
Think carefully about using the iterators over the entire set of Particles or Restraints. Most operations should be done using a user-passed set of Particles or Restraints instead.
Inheritance diagram for IMP::Model:

Public Member Functions

 Model (std::string name="The Model")
void remove_particle (Particle *p)
 Remove the particle from this model.
void restore_particle (Particle *p)
 Sometimes it is useful to put a particle back into a model.
Filtering

We are typically only interested in "good" conformations of the model. These are described by specifying maximum scores per restraint (Restraint::set_maximum_score()) and for the whole model. Samplers, optimizers etc are free to ignore configurations they encounter which go outside these bounds.

void set_maximum_score (double s)
double get_maximum_score () const
bool get_has_good_score () const
 Return true if thelast evaluate satisfied the thresholds.
Methods to debug particles

It is sometimes useful to inspect the list of all particles when debugging. These methods allow you to do that.

Note:
Only use this if you really know what you are doing as Particles can be added to the object from many different places.

The value type for the iterators is a Particle*.

unsigned int get_number_of_particles () const
ParticleIterator particles_begin ()
ParticleIterator particles_end ()
ParticleConstIterator particles_begin () const
ParticleConstIterator particles_end () const
Float Attribute Ranges

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.

FloatRange get_range (FloatKey k) const
void set_range (FloatKey k, FloatRange range)
Evaluation

Evaluation proceeds as follows:

  • ScoreState::before_evaluate() is called on all ScoreStates
  • Restraint::evaluate() is called on all Restraints
  • ScoreState::after_evaluate() is called on all ScoreStates The sum of the Restraint::evaluate() return values is returned.

All evaluate calls throw a ModelException if a Particle attribute value becomes invalid (NaN, infinite etc.)

virtual double evaluate (bool calc_derivs)
 Evaluate all of the restraints in the model and return the score.
void update ()
 Sometimes it is useful to be able to make sure the model is up to date.
Incremental Updates

Control whether incremental updates are being used. See the incremental updates page for a more detailed description.

void set_is_incremental (bool tf)
bool get_is_incremental () const
Statistics

The Model can gather various statistics about the restraints and score states used. To use this feature, first turn on statistics gather and then run your optimization (or just call evaluate).

Note:
Telling the model not to gather statistics does not clear existing statistics.
void clear_all_statistics ()
void set_gather_statistics (bool tf)
void show_all_statistics (std::ostream &out=std::cout) const
void show_restraint_time_statistics (std::ostream &out=std::cout) const
void show_restraint_score_statistics (std::ostream &out=std::cout) const
void show_score_state_time_statistics (std::ostream &out=std::cout) const

States

The Model stores a list of ScoreStates which are given an opportunity to update the stored Particles and their internal state before and after the restraints are evaluated. Use the methods below to manipulate the list of ScoreState objects.The value type for the iterators is a ScoreState*.
Note:
The order of addition of ScoreState objects does not matter.
Familiarity with these methods is not required to use imp.

void remove_score_state (ScoreState *d)
template<class F >
void remove_score_states_if (const F &f)
void remove_score_states (const ScoreStates &d)
void set_score_states (const ScoreStates &ps)
void set_score_states_order (const ScoreStates &ps)
unsigned int add_score_state (ScoreState *obj)
void add_score_states (const ScoreStates &obj)
void clear_score_states ()
unsigned int get_number_of_score_states () const
bool get_has_score_states () const
ScoreStateget_score_state (unsigned int i) const
void reserve_score_states (unsigned int sz)
ScoreStateIterator score_states_begin ()
ScoreStateIterator score_states_end ()
ScoreStateConstIterator score_states_begin () const
ScoreStateConstIterator score_states_end () const

Restraints

The Model scores the current configuration using the stored Restraint objects. Use the methods below to manipulate the list.The value type for the iterators is a Restraint*.
typedef
RestraintSet::RestraintIterator 
RestraintIterator
typedef
RestraintSet::RestraintConstIterator 
RestraintConstIterator
void add_restraint (Restraint *r)
void remove_restraint (Restraint *r)
unsigned int get_number_of_restraints () const
Restraintget_restraint (unsigned int i) const
RestraintIterator restraints_begin ()
RestraintIterator restraints_end ()
RestraintConstIterator restraints_begin () const
RestraintConstIterator restraints_end () const
double get_weight (Restraint *r) const
RestraintSetget_root_restraint_set () const

Constructor & Destructor Documentation

IMP::Model::Model ( std::string  name = "The Model")

Construct an empty model


Member Function Documentation

virtual double IMP::Model::evaluate ( bool  calc_derivs) [virtual]

Evaluate all of the restraints in the model and return the score.

Parameters:
[in]calc_derivsIf true, also evaluate the first derivatives.
Returns:
The score.
bool IMP::Model::get_has_good_score ( ) const

Return true if thelast evaluate satisfied the thresholds.

Currently this ignores maximum scores on restraint sets. Sorry.

void IMP::Model::remove_particle ( Particle p)

Remove the particle from this model.

Since particles are ref counted the object will still be valid until all references are removed, however attributes of removed particles cannot be changed or inspected.

Note:
It is an error to remove particles from the model during Restraint evaluation or ScoreState evaluation. It is OK to remove them during OptimizerState updates, although not all optimizers support this yet.
void IMP::Model::restore_particle ( Particle p)

Sometimes it is useful to put a particle back into a model.

When restoring the state of a Model, it is useful to be able to restore a particle back to the model it used to be part of.

void IMP::Model::set_is_incremental ( bool  tf)

Turn on or off incremental evaluation.

void IMP::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.


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

Generated on Thu Mar 24 2011 02:01:44 for IMP by doxygen 1.7.3