1 #ifndef WORKGRAPHPIECE_H_
2 #define WORKGRAPHPIECE_H_
4 #include <boost/graph/adjacency_list.hpp>
5 #include <boost/graph/filtered_graph.hpp>
24 bool operator()(
const boost::graph_traits<Graph>::vertex_descriptor& node)
const;
28 std::vector<boost::graph_traits<Graph>::vertex_descriptor>
doesDepend;
34 void UpstreamNodes(
const boost::graph_traits<Graph>::vertex_descriptor& baseNode,
Graph const& graph);
44 bool operator()(
const boost::graph_traits<Graph>::edge_descriptor& edge)
const;
72 bool operator()(
const boost::graph_traits<Graph>::vertex_descriptor& node)
const;
76 std::vector<boost::graph_traits<Graph>::vertex_descriptor>
doesDepend;
82 void DownstreamNodes(
const boost::graph_traits<Graph>::vertex_descriptor& baseNode,
Graph const& graph);
101 bool operator()(
const boost::graph_traits<Graph>::edge_descriptor& edge)
const;
112 typedef boost::filtered_graph<Graph, DependentEdgePredicate, DependentPredicate>
FilteredGraph;
129 std::vector<std::shared_ptr<ConstantPiece> >
const&
constantPieces,
130 std::vector<std::string>
const& inputNames,
131 std::map<unsigned int, std::string>
const& inTypes,
132 std::shared_ptr<WorkPiece> outputNode);
181 std::vector<std::tuple<unsigned int, unsigned int, unsigned int> >
RequiredOutputs(boost::graph_traits<FilteredGraph>::vertex_descriptor
const& node,
unsigned int const wrtIn,
unsigned int wrtOut)
const;
189 std::vector<std::tuple<unsigned int, unsigned int, unsigned int> >
RequiredInputs(boost::graph_traits<FilteredGraph>::vertex_descriptor
const& node,
unsigned int const wrtIn)
const;
212 std::map<unsigned int, std::vector<std::pair<unsigned int, unsigned int> > >
InputNodes(boost::graph_traits<Graph>::vertex_descriptor
const& node)
const;
215 std::deque<boost::graph_traits<Graph>::vertex_descriptor>
runOrder;
221 std::vector<std::deque<boost::graph_traits<Graph>::vertex_descriptor> >
derivRunOrders;
230 std::unordered_map<unsigned int, ref_vector<boost::any> >
valMap;
Determine if the source of an edge is downstream of an input.
bool operator()(const boost::graph_traits< Graph >::edge_descriptor &edge) const
DependentPredicate nodePred
The nodes that are downstream of the input.
DependentEdgePredicate()
Required default constructor.
const Graph * graph
The graph holding all the nodes.
This class keeps track of which nodes are downstream of a specified input.
bool operator()(const boost::graph_traits< Graph >::vertex_descriptor &node) const
DependentPredicate()
Required default constructor.
void DownstreamNodes(const boost::graph_traits< Graph >::vertex_descriptor &baseNode, Graph const &graph)
std::vector< boost::graph_traits< Graph >::vertex_descriptor > doesDepend
A vector of all the nodes downstream of the input node.
UpstreamPredicate nodePred
The nodes that are downstream of the input.
UpstreamEdgePredicate(UpstreamPredicate nodePred, Graph const &graph)
const Graph * graph
The graph holding all the nodes.
bool operator()(const boost::graph_traits< Graph >::edge_descriptor &edge) const
This class keeps track of which nodes are upstream (needed to evaluate) a given node.
bool operator()(const boost::graph_traits< Graph >::vertex_descriptor &node) const
std::vector< boost::graph_traits< Graph >::vertex_descriptor > doesDepend
A vector of all the nodes downstream of the input node.
void UpstreamNodes(const boost::graph_traits< Graph >::vertex_descriptor &baseNode, Graph const &graph)
A muq::Modeling::WorkPiece created from a muq::Modeling::WorkGraph.
std::vector< std::tuple< unsigned int, unsigned int, unsigned int > > RequiredOutputs(boost::graph_traits< FilteredGraph >::vertex_descriptor const &node, unsigned int const wrtIn, unsigned int wrtOut) const
Get the required outputs for a node in one of the filtered graphs.
std::map< unsigned int, std::vector< std::pair< unsigned int, unsigned int > > > InputNodes(boost::graph_traits< Graph >::vertex_descriptor const &node) const
Get a the input nodes for a node.
void SetInputs(ref_vector< boost::any > const &inputs)
Set the inputs.
virtual void EvaluateImpl(ref_vector< boost::any > const &inputs) override
Evaluate each muq::Modeling::WorkPiece in the graph.
void OutputMap()
Fill the map from each node's muq::Modeling::WorkPiece::ID to its outputs.
virtual ~WorkGraphPiece()
Default destructor.
unsigned int outputID
The ID of the WorkPiece corresponding to the output node.
std::vector< std::shared_ptr< FilteredGraph > > filtered_graphs
std::vector< std::tuple< unsigned int, unsigned int, unsigned int > > RequiredInputs(boost::graph_traits< FilteredGraph >::vertex_descriptor const &node, unsigned int const wrtIn) const
Get the required inputs for a node in one of the filtered graphs.
std::unordered_map< unsigned int, ref_vector< boost::any > > valMap
A the map from each node's muq::Modeling::WorkPiece::ID to its outputs.
std::shared_ptr< WorkGraph > wgraph
The WorkGraph associated with this WorkGraphPiece.
std::deque< boost::graph_traits< Graph >::vertex_descriptor > runOrder
Run order computed during construction (input->output order)
std::shared_ptr< WorkGraph > GetGraph()
std::vector< std::shared_ptr< ConstantPiece > > constantPieces
The muq::Modeling::ConstantPiece's that store the inputs.
std::vector< std::deque< boost::graph_traits< Graph >::vertex_descriptor > > derivRunOrders
Base class for MUQ's modelling envronment.
friend class WorkGraphPiece
@ Inputs
The constructor fixes the input number and possibly the types.
boost::filtered_graph< Graph, DependentEdgePredicate, DependentPredicate > FilteredGraph
A filtered graph that only has nodes downstream of a specified input.
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, std::shared_ptr< WorkGraphNode >, std::shared_ptr< WorkGraphEdge > > Graph
Define a directed graph type.