IMP logo
Public Member Functions | Static Public Member Functions | Protected Member Functions
IMP::Restraint Class Reference

Detailed Description

Abstract class for representing restraints.

Restraints should take their score function or UnaryFunction as the first argument. Restraints which act on large numbers of particles should allow the particle list to be skipped in the constructor and should provide methods so that the set of particles can be modified after construction.

A restraint can be added to the model multiple times or to multiple restraint sets in the same model.

Note:
When logging is VERBOSE, restraints should print enough information in evaluate to reproduce the the entire flow of data in evaluate. When logging is TERSE the restraint should print out only a constant number of lines per evaluate call.
Physical restraints should use the units of kcal/mol for restraint values and kcal/mol/A for derivatives.
Restraints will print a warning message if they are destroyed without ever having been added to a model as this is an easy mistake to make. To disable this warning for a particular restraint, call set_was_used(true).
Implementors
Developers who wish to implement a Restraint should inherit from this class and use the IMP_RESTRAINT() macro to help define the needed functions. IMP::example::ExampleRestraint provides an example to start from.

Examples: write a restraint

Inherits IMP::base::Object.

Inherited by IMP::atom::CHARMMStereochemistryRestraint, IMP::container::MinimumPairRestraint, IMP::container::MinimumQuadRestraint, IMP::container::MinimumSingletonRestraint, IMP::container::MinimumTripletRestraint, IMP::container::PairsRestraint, IMP::container::PredicatePairsRestraint, IMP::container::PredicateQuadsRestraint, IMP::container::PredicateSingletonsRestraint, IMP::container::PredicateTripletsRestraint, IMP::container::QuadsRestraint, IMP::container::SingletonsRestraint, IMP::container::TripletsRestraint, IMP::core::ConnectivityRestraint, IMP::core::ConstantRestraint, IMP::core::DiameterRestraint, IMP::core::DihedralRestraint, IMP::core::DistanceRestraint, IMP::core::ExcludedVolumeRestraint, IMP::core::MinimumRestraint, IMP::core::MSConnectivityRestraint, IMP::core::VolumeRestraint, IMP::em2d::DummyRestraint, IMP::em2d::Em2DRestraint, IMP::em2d::Fine2DRegistrationRestraint, IMP::em2d::ParticlesDummyRestraint, IMP::em2d::RigidBodiesImageFitRestraint, IMP::em::DensityFillingRestraint, IMP::em::EnvelopePenetrationRestraint, IMP::em::FitRestraint, IMP::example::ExampleComplexRestraint, IMP::example::ExampleRestraint, IMP::examplesystemlocal::ExampleRestraint, IMP::isd::ISDRestraint, IMP::isd::LogicalORRestraint, IMP::isd::TALOSRestraint, IMP::modeller::ModellerRestraints, IMP::modeller::MultipleBinormalRestraint, IMP::multifit::ComplementarityRestraint, IMP::multifit::RadiusOfGyrationRestraint, IMP::multifit::WeightedExcludedVolumeRestraint, IMP::PairScoreRestraint, IMP::PairsScoreRestraint, IMP::QuadScoreRestraint, IMP::QuadsScoreRestraint, IMP::RestraintSet, IMP::saxs::RadiusOfGyrationRestraint, IMP::saxs::Restraint, IMP::SingletonScoreRestraint, IMP::SingletonsScoreRestraint, IMP::TripletScoreRestraint, and IMP::TripletsScoreRestraint.

List of all members.

Public Member Functions

 Restraint (std::string name="Restraint %1%")
Restraintcreate_current_decomposition () const
 Decompose this restraint into constituent terms for the current conf.
Restraintcreate_decomposition () const
 Decompose this restraint into constituent terms.
Restraintcreate_incremental_decomposition (unsigned int n) const
 Decompose a restraint parts for incremental evaluation.
double evaluate (bool calc_derivs) const
 Return the score for this restraint for the current state of the model.
double evaluate_if_good (bool calc_derivatives) const
 See Model::evaluate_if_good()
bool get_is_part_of_model () const
 Return true if this particle is part of a model.
Modelget_model () const
 Return the model containing this restraint.
virtual void set_model (Model *model)

Static Public Member Functions

static Restraintget_from (Object *o)
 For python, cast a generic Object to this type. Throw a ValueException of object is not the right type.

Interactions

Certain sorts of operations, such as evaluation of restraints in isolation, benefit from being able to determine which containers and particles are needed by which restraints.

virtual ContainersTemp get_input_containers () const =0
virtual ParticlesTemp get_input_particles () const =0

Weights

Each restraint's contribution to the model score is weighted. The total weight for the restraint is the some over all the paths containing it. That is, if a restraint is in a RestraintSet with weight .5 and another with weight 2, and the restaint itself has weight 3, then the total weight of the restraint is $.5 \dot 3 + 2 \dot 3 = 7.5 $.

void set_weight (Float weight)
Float get_weight () const

Filtering

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

Note:
The maximum score for for the unweighted restraint (eg the score that is returned with weight 1).
double get_maximum_score () const
void set_maximum_score (double s)

Protected Member Functions

virtual Restraints do_create_current_decomposition () const
virtual Restraints do_create_decomposition () const
virtual Restraints do_create_incremental_decomposition (unsigned int) const

Member Function Documentation

Restraint* IMP::Restraint::create_current_decomposition ( ) const

Decompose this restraint into constituent terms for the current conf.

Return a decomposition that is value for the current conformation, but will not necessarily be valid if any of the particles are changed. This is the same as create_decomposition() for non-conditional restraints.

The restraints returned have had set_model() called and so can be evaluated.

Restraint* IMP::Restraint::create_decomposition ( ) const

Decompose this restraint into constituent terms.

Given the set of input particles, decompose the restraint into as simple parts as possible. For many restraints, the simplest part is simply the restraint itself.

If a restraint can be decomposed, it should return a RestraintSet so that the maximum score and weight can be passed properly.

The restraints returned have had set_model() called and so can be evaluated.

Restraint* IMP::Restraint::create_incremental_decomposition ( unsigned int  n) const

Decompose a restraint parts for incremental evaluation.

The restraint should be decomposed as efficiently as possible for evaluation when n particles are moved each evaluate call.

virtual Restraints IMP::Restraint::do_create_current_decomposition ( ) const [protected, virtual]

A Restraint should override this if they want to decompose themselves for display and other purposes. The returned restraints will be made in to a RestraintSet, if needed and the weight and maximum score set for the restraint set.

Reimplemented in IMP::core::MSConnectivityRestraint, IMP::core::ConnectivityRestraint, and IMP::core::ExcludedVolumeRestraint.

virtual Restraints IMP::Restraint::do_create_decomposition ( ) const [protected, virtual]

A Restraint should override this if they want to decompose themselves for domino and other purposes. The returned restraints will be made in to a RestraintSet, if needed and the weight and maximum score set for the restraint set.

Reimplemented in IMP::core::ExcludedVolumeRestraint.

virtual Restraints IMP::Restraint::do_create_incremental_decomposition ( unsigned  int) const [protected, virtual]

int should override this if they want to decompose themselves for incremental montecarlo and other purposes. The returned restraints will be made in to a RestraintSet, if needed and the weight and maximum score set for the restraint set.

Reimplemented in IMP::core::ExcludedVolumeRestraint.

double IMP::Restraint::evaluate ( bool  calc_derivs) const

Return the score for this restraint for the current state of the model.

Returns:
Current score.

This method is equivalent to calling:

      model->evaluate(RestraintsTemp(1,this), calc_derivs)
double IMP::Restraint::evaluate_if_good ( bool  calc_derivatives) const
static Restraint* IMP::Restraint::get_from ( Object *  o) [static]

For python, cast a generic Object to this type. Throw a ValueException of object is not the right type.

bool IMP::Restraint::get_is_part_of_model ( ) const

Return true if this particle is part of a model.

Model* IMP::Restraint::get_model ( ) const

Return the model containing this restraint.

virtual void IMP::Restraint::set_model ( Model model) [virtual]

This method is called to register a restrain with a model. Adding the restraint the model (Model::add_restraint()) will call this method but it can be called directly if one wants to use the restraint, just not as part of the normal scoring function.

Reimplemented in IMP::isd::GaussianProcessInterpolationRestraint, IMP::example::ExampleComplexRestraint, and IMP::core::MinimumRestraint.


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

Generated on Fri Feb 10 2012 23:36:21 for IMP by doxygen 1.7.5.1