Re: [IMP-dev] add_attribute vs. add_cache_attribute
To: List for IMP development <>
Subject: Re: [IMP-dev] add_attribute vs. add_cache_attribute
From: Daniel Russel <>
Date: Fri, 18 May 2012 13:58:22 -0700
Reply-to: List for IMP development <>
Restraints are not allowed to add/remove/change attributes during restraint evaluation. The reason for this is that the order of evaluation of restraints is not defined and if restraints could change attributes, the score could depend on what order they were evaluated in. However, in certain cases it makes sense to cache computations in the particle so as to avoid having to recompute it next time (or in a different restraint). The (undocumented) method add_cache_attribute() provides a means to do that. The assumptions made are that
- any restraint that writes it should write an equivalent value - it should get cleared if anything "significant" (a still vague concept) in the particle changes.
One usage of it currently is for the collision detection hierarchies used with rigid bodies. This hierarchy is computed on demand (for example when trying to evaluate a distance pair score on a pair of rigid bodies). Any time the rigid body is changed (eg the internal coordinates of a member are changed), the hierarchy gets cleared out and must be recomputed the next time.