IMP logo
Public Member Functions | Static Public Member Functions
IMP::container::AllPairContainer Class Reference

Detailed Description

Return all unordered pairs of particles taken from the SingletonContainer.

Here is an example using this container to restrain all particles in a set to be within a a certain distance of one another.

import IMP
import IMP.core
import IMP.container

# This example restraints the diameter of a set of particles to be smaller than 10

diameter=10
m= IMP.Model()
lc= IMP.container.ListSingletonContainer(IMP.core.create_xyzr_particles(m, 50, 1.0))
h=IMP.core.HarmonicUpperBound(0,1)
r=IMP.core.DiameterRestraint(h, lc, diameter)
m.add_restraint(r)

# Set up optimizer
o= IMP.core.ConjugateGradients()
o.set_model(m)

max=0
for p0 in lc.get_particles():
    for p1 in lc.get_particles():
        d=IMP.core.get_distance(IMP.core.XYZ(p0),
                            IMP.core.XYZ(p1))
        if d > max: max=d
print "The maximim distance is "+str(max)

IMP.set_log_level(IMP.SILENT)
o.optimize(100)

max=0
for p0 in lc.get_particles():
    for p1 in lc.get_particles():
        d=IMP.core.get_distance(IMP.core.XYZ(p0),
                            IMP.core.XYZ(p1))
        if d > max: max=d
print "Afterwards, the maximim distance is "+str(max)
Note:
Sequential access is much more efficient than random access which is suicidally slow for now. Complain if you want fast(er) random access. We might listen.
The maintenance of the invariant is done by an associated IMP::Constraint. As a result, the state is only guaranteed to be correct either during model evaluation, or immediately following model evaluation before any particles have been changed.
+ Inheritance diagram for IMP::container::AllPairContainer:

List of all members.

Public Member Functions

 AllPairContainer (SingletonContainer *c, std::string name="AllPairContainer%1%")
 Get the individual particles from the passed SingletonContainer.
 IMP_IMPLEMENT_PAIR_CONTAINER (AllPairContainer)

Static Public Member Functions

static AllPairContainercreate_untracked_container (SingletonContainer *c)

Constructor & Destructor Documentation

IMP::container::AllPairContainer::AllPairContainer ( SingletonContainer c,
std::string  name = "AllPairContainer%1%" 
)

Get the individual particles from the passed SingletonContainer.


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

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