MUQ  0.4.3
muq::Modeling::WorkGraphPiece Class Reference

A muq::Modeling::WorkPiece created from a muq::Modeling::WorkGraph. More...

#include <WorkGraphPiece.h>

Inheritance diagram for muq::Modeling::WorkGraphPiece:

Detailed Description

A muq::Modeling::WorkPiece created from a muq::Modeling::WorkGraph.

Definition at line 115 of file WorkGraphPiece.h.

Public Member Functions

 WorkGraphPiece (std::shared_ptr< WorkGraph > wgraph, std::vector< std::shared_ptr< ConstantPiece > > const &constantPieces, std::vector< std::string > const &inputNames, std::map< unsigned int, std::string > const &inTypes, std::shared_ptr< WorkPiece > outputNode)
 Construct a muq::Modeling::WorkGraphPiece. More...
 
virtual ~WorkGraphPiece ()
 Default destructor. More...
 
std::shared_ptr< WorkGraphGetGraph ()
 
- Public Member Functions inherited from muq::Modeling::WorkPiece
 WorkPiece ()
 Create a muq::Modeling::WorkPiece with no fixed number of inputs and outputs and variable input/output types. More...
 
 WorkPiece (int const num, WorkPiece::Fix const fix=WorkPiece::Fix::Inputs)
 Create a muq::Modeling::WorkPiece with either a fixed number of inputs or outputs and variable input/output types. More...
 
 WorkPiece (int const numIns, int const numOuts)
 Create a muq::Modeling::WorkPiece with a fixed number of inputs and outputs but variable input/output types. More...
 
 WorkPiece (std::vector< std::string > const &types, WorkPiece::Fix const fix=WorkPiece::Fix::Inputs)
 Create a muq::Modeling::WorkPiece with either a fixed number of inputs with specified types or a fixed number of outputs with specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &types, WorkPiece::Fix const fix=WorkPiece::Fix::Inputs)
 Create a muq::Modeling::WorkPiece where either some of the inputs have specified types or some of the outputs have specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &types, int const num, WorkPiece::Fix const fixTypes=WorkPiece::Fix::Inputs, WorkPiece::Fix const fixNum=WorkPiece::Fix::Inputs)
 Create a muq::Modeling::WorkPiece where either some of the inputs have specified types or some of the outputs have specified types and either the number of inputs or the number of outputs is fixed. More...
 
 WorkPiece (std::vector< std::string > const &types, int const num)
 Create a muq::Modeling::WorkPiece with a fixed number of inputs with specified types and a fixed number of outputs (of uknown type) More...
 
 WorkPiece (int const num, std::vector< std::string > const &types)
 Create a muq::Modeling::WorkPiece with a fixed number of outputs with specified types and a fixed number of inputs (of uknown type) More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, int const numIns, int const numOuts)
 Create a muq::Modeling::WorkPiece where some of the inputs are known and we know the input and output numbers. More...
 
 WorkPiece (int const numIns, std::map< unsigned int, std::string > const &outTypes, int const numOuts)
 Create a muq::Modeling::WorkPiece where some of the outputs are known and we know the input and output numbers. More...
 
 WorkPiece (std::vector< std::string > const &inTypes, std::vector< std::string > const &outTypes)
 Create a muq::Modeling::WorkPiece with a fixed number of inputs and outputs with specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, std::vector< std::string > const &outTypes)
 Create a muq::Modeling::WorkPiece where some of the inputs are known and all of the outputs have specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, int const num, std::vector< std::string > const &outTypes)
 Create a muq::Modeling::WorkPiece where some of the inputs are known with a known number of inputs and all of the outputs have specified types. More...
 
 WorkPiece (std::vector< std::string > const &inTypes, std::map< unsigned int, std::string > const &outTypes)
 Create a muq::Modeling::WorkPiece where some of the outputs and all of the inputs have specified types. More...
 
 WorkPiece (std::vector< std::string > const &inTypes, std::map< unsigned int, std::string > const &outTypes, int const num)
 Create a muq::Modeling::WorkPiece where some of the outputs with a known number of outputs and all of the inputs have specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, std::map< unsigned int, std::string > const &outTypes)
 Create a muq::Mdoeling::WorkPiece where some of the inputs and some of the outputs have specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, int const numIn, std::map< unsigned int, std::string > const &outTypes)
 Create a muq::Mdoeling::WorkPiece where some of the inputs and some of the outputs have specified types with a fixed number of inputs. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, std::map< unsigned int, std::string > const &outTypes, int const numOut)
 Create a muq::Mdoeling::WorkPiece where some of the inputs and some of the outputs have specified types with a fixed number of outputs. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, int const numIn, std::map< unsigned int, std::string > const &outTypes, int const numOut)
 Create a muq::Mdoeling::WorkPiece where some of the inputs and some of the outputs have specified types with a fixed number of inputs and outputs. More...
 
virtual ~WorkPiece ()
 Default destructor. More...
 
std::vector< boost::any > const & Evaluate (std::vector< boost::any > const &ins)
 Evaluate this muq::Modeling::WorkPiece. More...
 
std::vector< boost::any > const & Evaluate (ref_vector< boost::any > const &ins)
 Evaluate this muq::Modeling::WorkPiece using references to the inputs. More...
 
std::vector< boost::any > const & Evaluate ()
 Evaluate this muq::Modeling::WorkPiece in the case that there are no inputs. More...
 
template<typename... Args>
std::vector< boost::any > const & Evaluate (Args... args)
 Evalaute this muq::Modeling::WorkPiece using multiple arguments. More...
 
std::string const & Name ()
 Get the (unique) name of this work piece. More...
 
void SetName (std::string const &newName)
 Set the name of this work piece. More...
 
std::string InputType (unsigned int inputNum, bool const demangle=true) const
 Get the input type (if we know it) for a specific input. More...
 
int InputSize (unsigned int inputNum) const
 Get the length of a vector valued input with fixed size. More...
 
void SetInputSize (unsigned int inputNum, int newSize)
 
std::string OutputType (unsigned int outputNum, bool const demangle=true) const
 Get the output type (if we know it) for a specific output. More...
 
std::map< unsigned int, std::string > OutputTypes () const
 Get the output types. More...
 
std::map< unsigned int, std::string > InputTypes () const
 Get the input types. More...
 
unsigned int ID () const
 Get the unique ID number. More...
 
virtual double GetRunTime (const std::string &method="Evaluate") const
 Get the average run time for one of the implemented methods. More...
 
virtual unsigned long int GetNumCalls (const std::string &method="Evaluate") const
 get the number of times one of the implemented methods has been called. More...
 
virtual void ResetCallTime ()
 Resets the number of call and times. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from muq::Modeling::WorkPiece
static ref_vector< const boost::any > ToRefVector (std::vector< boost::any > const &anyVec)
 Create vector of references from a vector of boost::any's. More...
 
static ref_vector< const Eigen::VectorXd > ToRefVector (std::vector< Eigen::VectorXd > const &anyVec)
 
- Public Attributes inherited from muq::Modeling::WorkPiece
int numInputs
 The number of inputs. More...
 
int numOutputs
 The number of outputs. More...
 

Constructor & Destructor Documentation

◆ WorkGraphPiece()

WorkGraphPiece::WorkGraphPiece ( std::shared_ptr< WorkGraph wgraph,
std::vector< std::shared_ptr< ConstantPiece > > const &  constantPieces,
std::vector< std::string > const &  inputNames,
std::map< unsigned int, std::string > const &  inTypes,
std::shared_ptr< WorkPiece outputNode 
)

Construct a muq::Modeling::WorkGraphPiece.

Typically muq::Modeling::WorkGraphPiece's are constructed by calling muq::Modeling::WorkGraph::CreateWorkPiece

Parameters
[in]graphFrom inputs to the output-of-interest
[in]constantPiecesPointers to the muq::Modeling::ConstantPiece's that hold the graph's inputs
[in]inputNamesThe names of each node in the graph corresponding to the constantPieces
[in]inTypesThe input types (if known)
[in]outputNodeThe muq::Modeling::WorkPiece that we ultimately want to evaluate
[in]algebraAlgebra to preform basic operations between different types (defaults to base class, which has common types)

Definition at line 75 of file WorkGraphPiece.cpp.

References derivRunOrders, filtered_graphs, muq::Modeling::WorkPiece::numInputs, runOrder, nlohmann::detail::dtoa_impl::v, and wgraph.

◆ ~WorkGraphPiece()

WorkGraphPiece::~WorkGraphPiece ( )
virtual

Default destructor.

Definition at line 110 of file WorkGraphPiece.cpp.

Member Function Documentation

◆ EvaluateImpl()

void WorkGraphPiece::EvaluateImpl ( ref_vector< boost::any > const &  inputs)
overrideprivatevirtual

Evaluate each muq::Modeling::WorkPiece in the graph.

Parameters
[in]inputsInputs to the muq::Modeling::WorkGraphPiece

Implements muq::Modeling::WorkPiece.

Definition at line 112 of file WorkGraphPiece.cpp.

References outputID, OutputMap(), muq::Modeling::WorkPiece::outputs, SetInputs(), and valMap.

◆ GetGraph()

std::shared_ptr<WorkGraph> muq::Modeling::WorkGraphPiece::GetGraph ( )
inline

Definition at line 138 of file WorkGraphPiece.h.

References wgraph.

◆ InputNodes()

std::map< unsigned int, std::vector< std::pair< unsigned int, unsigned int > > > WorkGraphPiece::InputNodes ( boost::graph_traits< Graph >::vertex_descriptor const &  node) const
private

Get a the input nodes for a node.

Parameters
[in]nodeWe want the input nodes for this node
Returns
A map from the input node's ID to the input/output number

Definition at line 312 of file WorkGraphPiece.cpp.

References nlohmann::detail::dtoa_impl::e, muq::Modeling::WorkPiece::id, and wgraph.

Referenced by Inputs().

◆ Inputs()

ref_vector< boost::any > WorkGraphPiece::Inputs ( boost::graph_traits< Graph >::vertex_descriptor  node) const
private

Get the inputs from muq::Modeling::WorkGraphPiece::valMap to a specified node in the graph.

Parameters
[in]idThe ID of the node of interest
Returns
A reference vector of inputs to that node

Definition at line 354 of file WorkGraphPiece.cpp.

References InputNodes(), valMap, and wgraph.

◆ OutputMap()

void WorkGraphPiece::OutputMap ( )
private

Fill the map from each node's muq::Modeling::WorkPiece::ID to its outputs.

Definition at line 339 of file WorkGraphPiece.cpp.

References muq::Modeling::WorkPiece::Inputs, runOrder, muq::Modeling::WorkPiece::ToRefVector(), valMap, and wgraph.

Referenced by EvaluateImpl().

◆ RequiredInputs()

std::vector< std::tuple< unsigned int, unsigned int, unsigned int > > WorkGraphPiece::RequiredInputs ( boost::graph_traits< FilteredGraph >::vertex_descriptor const &  node,
unsigned int const  wrtIn 
) const
private

Get the required inputs for a node in one of the filtered graphs.

Parameters
[in]nodeWe want the inputs of this node
[in]wrtInThe input whose downstream nodes we care about
Returns
The input nodes — tuple: the input WorkPiece ID, the output number, and the input number

Definition at line 408 of file WorkGraphPiece.cpp.

References filtered_graphs, muq::Modeling::WorkPiece::ID(), and wgraph.

◆ RequiredOutputs()

std::vector< std::tuple< unsigned int, unsigned int, unsigned int > > WorkGraphPiece::RequiredOutputs ( boost::graph_traits< FilteredGraph >::vertex_descriptor const &  node,
unsigned int const  wrtIn,
unsigned int  wrtOut 
) const
private

Get the required outputs for a node in one of the filtered graphs.

Parameters
[in]nodeWe want the outputs of this node
[in]wrtInThe input whose downstream nodes we care about
[in]wrtOutThe output we are ultimately trying to differentiate wrt
Returns
The output nodes — tuple: the output WorkPiece ID, the output number, and the input number

Definition at line 376 of file WorkGraphPiece.cpp.

References filtered_graphs, muq::Modeling::WorkPiece::ID(), outputID, and wgraph.

◆ SetInputs()

void WorkGraphPiece::SetInputs ( ref_vector< boost::any > const &  inputs)
private

Set the inputs.

Set the inputs in each the muq::Modeling::ConstantPiece.

Definition at line 304 of file WorkGraphPiece.cpp.

References constantPieces.

Referenced by EvaluateImpl().

Member Data Documentation

◆ constantPieces

std::vector<std::shared_ptr<ConstantPiece> > muq::Modeling::WorkGraphPiece::constantPieces
private

The muq::Modeling::ConstantPiece's that store the inputs.

Definition at line 236 of file WorkGraphPiece.h.

Referenced by SetInputs().

◆ derivRunOrders

std::vector<std::deque<boost::graph_traits<Graph>::vertex_descriptor> > muq::Modeling::WorkGraphPiece::derivRunOrders
private

Like muq::Modeling::WorkGraphPiece::runOrder, but specific to which input node is used (also in output->input order)

Definition at line 221 of file WorkGraphPiece.h.

Referenced by WorkGraphPiece().

◆ filtered_graphs

std::vector<std::shared_ptr<FilteredGraph> > muq::Modeling::WorkGraphPiece::filtered_graphs
private

Definition at line 227 of file WorkGraphPiece.h.

Referenced by RequiredInputs(), RequiredOutputs(), and WorkGraphPiece().

◆ outputID

unsigned int muq::Modeling::WorkGraphPiece::outputID
private

The ID of the WorkPiece corresponding to the output node.

Definition at line 233 of file WorkGraphPiece.h.

Referenced by EvaluateImpl(), and RequiredOutputs().

◆ runOrder

std::deque<boost::graph_traits<Graph>::vertex_descriptor> muq::Modeling::WorkGraphPiece::runOrder
private

Run order computed during construction (input->output order)

Definition at line 215 of file WorkGraphPiece.h.

Referenced by OutputMap(), and WorkGraphPiece().

◆ valMap

std::unordered_map<unsigned int, ref_vector<boost::any> > muq::Modeling::WorkGraphPiece::valMap
private

A the map from each node's muq::Modeling::WorkPiece::ID to its outputs.

Definition at line 230 of file WorkGraphPiece.h.

Referenced by EvaluateImpl(), Inputs(), and OutputMap().

◆ wgraph

std::shared_ptr<WorkGraph> muq::Modeling::WorkGraphPiece::wgraph
private

The WorkGraph associated with this WorkGraphPiece.

Definition at line 225 of file WorkGraphPiece.h.

Referenced by GetGraph(), InputNodes(), Inputs(), OutputMap(), RequiredInputs(), RequiredOutputs(), and WorkGraphPiece().


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