IMP  2.0.1
The Integrative Modeling Platform
kernel/dependency_graph.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/dependency_graph.h
3  * \brief Build dependency graphs on models.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_DEPENDENCY_GRAPH_H
10 #define IMPKERNEL_DEPENDENCY_GRAPH_H
11 
12 #include <IMP/kernel/kernel_config.h>
13 #include "base_types.h"
14 #include <IMP/base/base_macros.h>
15 #include <boost/graph/adjacency_list.hpp>
16 
17 IMPKERNEL_BEGIN_NAMESPACE
18 
19 /*
20  Implementations in Model_dependency.cpp
21  */
22 
23 /** \brief A directed graph on the interactions between the various objects in
24  the model.
25 
26  The vertices are named by the associated Object*. There
27  is an edge from a to b, if a is an input to b. For example, there
28  is an edge from a particle to a restraint if the restraint directly
29  reads the particle.
30 
31  See
32  \ref dependencies "Dependencies" for more information about dependencies.
33 */
34 IMP_GRAPH(DependencyGraph, bidirectional, ModelObject*, int);
35 
36 class Model;
37 
38 /** The dependency graph captures the interactions between Restraint,
39  ScoreState and Particle objects. The graph has a directed edge if the source
40  of the edge is an input for the target of the edge or the target
41  of the edge is an output for the source. eg, there
42  is an edge connecting a Container to the Restraint which gets
43  its particles from the Container.
44  \see get_pruned_dependency_graph()
45 */
46 IMPKERNELEXPORT DependencyGraph
48 
49 
50 /** The pruned dependency graph merges all particles which have the
51  same dependencies to produce a simpler graph.
52 */
53 IMPKERNELEXPORT DependencyGraph
55 
56 
57 /** \name Getting required values
58 
59  These functions use the dependency graph to determine all the objects
60  of a given type that are needed by a particular object. An object is said
61  to be needed by another if there is a path from the object to the dependent
62  object through the dependency graph (see get_dependency_graph()) not passing
63  through a node in all.
64 
65  @{
66  */
67 IMPKERNELEXPORT ParticlesTemp
68 get_required_particles(ModelObject *p,
69  const ModelObjectsTemp &all,
70  const DependencyGraph &dg,
71  const DependencyGraphVertexIndex &index);
72 
73 /** Return all the score states that depend on p as an input, even indirectly.
74  */
75 IMPKERNELEXPORT ScoreStatesTemp
77  const ModelObjectsTemp &all,
78  const DependencyGraph &dg,
79  const DependencyGraphVertexIndex &index);
80 /** @} */
81 
82 /** \name Getting dependent values
83 
84  These functions use the dependency graph to determine all the objects
85  of a given type that depend on a particular object. An object is said
86  to depend on another if there is a path from the object to the dependent
87  object through the reversed dependency graph (see get_dependency_graph()).
88 
89  @{
90  */
91 IMPKERNELEXPORT ParticlesTemp
92 get_dependent_particles(ModelObject *p,
93  const ModelObjectsTemp &all,
94  const DependencyGraph &dg,
95  const DependencyGraphVertexIndex &index);
96 
97 
98 /** Return all the restraints that depend on p as an input, even indirectly.
99  */
100 IMPKERNELEXPORT RestraintsTemp
102  const ModelObjectsTemp &all,
103  const DependencyGraph &dg,
104  const DependencyGraphVertexIndex &index);
105 
106 /** Return all the score states that depend on p as an input, even indirectly.
107  */
108 IMPKERNELEXPORT ScoreStatesTemp
110  const ModelObjectsTemp &all,
111  const DependencyGraph &dg,
112  const DependencyGraphVertexIndex &index);
113 /** @} */
114 
115 
116 
117 
118 /** Return the required score states for the restraints ordered in
119  a valid evaluation order. Make sure you include any score states
120  that are simply needed to update optimized particles.
121 */
122 IMPKERNELEXPORT
124  const DependencyGraph &dg,
125  const DependencyGraphVertexIndex &index);
126 
127 
128 /** Assign an order to the score states in the dependency graph in which
129  they can safetly be updated.*/
130 IMPKERNELEXPORT void set_score_state_update_order(const DependencyGraph& dg,
131  const DependencyGraphVertexIndex &index);
132 
133 
134 IMPKERNEL_END_NAMESPACE
135 
136 #endif /* IMPKERNEL_DEPENDENCY_GRAPH_H */