MUQ  0.4.3
muq::Modeling::WorkPiece Class Referenceabstract

Base class for MUQ's modelling envronment. More...

#include <WorkPiece.h>

Inheritance diagram for muq::Modeling::WorkPiece:

Detailed Description

Base class for MUQ's modelling envronment.

Definition at line 40 of file WorkPiece.h.

Public Member Functions

 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...
 

Static Public Member Functions

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

int numInputs
 The number of inputs. More...
 
int numOutputs
 The number of outputs. More...
 

Friends

class WorkGraphPiece
 
class WorkGraph
 

Member Enumeration Documentation

◆ Fix

Does the constructor fix the inputs or the outputs?

Enumerator
Inputs 

The constructor fixes the input number and possibly the types.

Outputs 

The constructor fixes the output number and possibly the types.

Definition at line 49 of file WorkPiece.h.

Constructor & Destructor Documentation

◆ WorkPiece() [1/19]

WorkPiece::WorkPiece ( )

Create a muq::Modeling::WorkPiece with no fixed number of inputs and outputs and variable input/output types.

Definition at line 10 of file WorkPiece.cpp.

◆ WorkPiece() [2/19]

WorkPiece::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.

Parameters
[in]numThe number of inputs or outputs (which one depends on the second parameter)
[in]fixWorkPiece::Fix::Inputs (default): the first parameter is the number of inputs; WorkPiece::Fix::Outputs: the first parameter is the number of outputs

Definition at line 18 of file WorkPiece.cpp.

◆ WorkPiece() [3/19]

WorkPiece::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.

Parameters
[in]numInsThe number of inputs
[in]numOutsThe number of outputs

Definition at line 26 of file WorkPiece.cpp.

◆ WorkPiece() [4/19]

WorkPiece::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.

If the number and type of the inputs is specified then the number and type of the outputs is variable. The opposite is true if the number and type of the outputs is specified.

Parameters
[in]typesA vector of strings, each element is the type of an input or output (the number of inputs or outputs is the size of this vector)
[in]fixWorkPiece::Fix::Inputs (default): the elements of the first parameter are the types of the inputs; WorkPiece::Fix::Outputs: the elements of the first parameter are the types of the outputs

Definition at line 34 of file WorkPiece.cpp.

◆ WorkPiece() [5/19]

WorkPiece::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.

If the inputs are specified, then the outputs are not (and vice versa). The number of in/outputs is variable but some of them have specified type. For example, if the first input is a string and the third input is a double then

  • Evaluate("string", 1.0, 2.0);
  • Evaluate("string");
  • Evaluate();
  • Evaluate("string", "another string", 5.0, std::shared_ptr<AnObject>);

are valid muq::Modeling::WorkPiece::Evaluate calls but

  • Evaluate(1.0, 2.0, "string");

is not valid.

Parameters
[in]typesA map from the input/output number to the input/output type
[in]fixWorkPiece::Fix::Inputs (default): the elements of the first parameter are the types of the inputs; WorkPiece::Fix::Outputs: the elements of the first parameter are the types of the outputs

Definition at line 44 of file WorkPiece.cpp.

◆ WorkPiece() [6/19]

WorkPiece::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.

Parameters
[in]typesA map from the input/output number to the input/output type
[in]numThe number of inputs/outputs
[in]fixTypesWorkPiece::Fix::Inputs (default): the elements of the first parameter are the types of the inputs; WorkPiece::Fix::Outputs: the elements of the first parameter are the types of the outputs
[in]fixNumWorkPiece::Fix::Inputs (default): the second parameter is the number of inputs; WorkPiece::Fix::Outputs: the second parameter is the number of outputs

Definition at line 54 of file WorkPiece.cpp.

◆ WorkPiece() [7/19]

WorkPiece::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)

Parameters
[in]typesA vector of strings, each element is the type of an input (the number of inputs is the size of this vector)
[in]numThe number of outputs

Definition at line 64 of file WorkPiece.cpp.

◆ WorkPiece() [8/19]

WorkPiece::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)

Parameters
[in]numThe number of inputs
[in]typesA vector of strings, each element is the type of an output (the number of outputs is the size of this vector)

Definition at line 73 of file WorkPiece.cpp.

◆ WorkPiece() [9/19]

WorkPiece::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.

Parameters
[in]inTypesA map from the input number to the input type
[in]numInsThe number of inputs
[in]numOutsThe number of outputs

Definition at line 82 of file WorkPiece.cpp.

◆ WorkPiece() [10/19]

WorkPiece::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.

Parameters
[in]numInsThe number of inputs
[in]outTypesA map from the input number to the input type
[in]numOutsThe number of outputs

Definition at line 91 of file WorkPiece.cpp.

◆ WorkPiece() [11/19]

WorkPiece::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.

Parameters
[in]inTypesA vector of strings, each element is the type of an input (the number of inputs is the size of this vector)
[in]outTypesA vector of strings, each element is the type of an output (the number of outputs is the size of this vector)

Definition at line 100 of file WorkPiece.cpp.

◆ WorkPiece() [12/19]

WorkPiece::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.

Parameters
[in]inTypesA map from the input number to the input type
[in]outTypesA vector of strings, each element is the type of an output (the number of outputs is the size of this vector)

Definition at line 110 of file WorkPiece.cpp.

◆ WorkPiece() [13/19]

WorkPiece::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.

Parameters
[in]inTypesA map from the input number to the input type
[in]numThe number of inputs
[in]outTypesA vector of strings, each element is the type of an output (the number of outputs is the size of this vector)

Definition at line 120 of file WorkPiece.cpp.

◆ WorkPiece() [14/19]

WorkPiece::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.

Parameters
[in]inTypesA vector of strings, each element is the type of an input (the number of inputs is the size of this vector)
[in]outTypesA map from the output number to the output type

Definition at line 130 of file WorkPiece.cpp.

◆ WorkPiece() [15/19]

WorkPiece::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.

Parameters
[in]inTypesA vector of strings, each element is the type of an input (the number of inputs is the size of this vector)
[in]outTypesA map from the output number to the output type
[in]numThe number of outputs

Definition at line 140 of file WorkPiece.cpp.

◆ WorkPiece() [16/19]

WorkPiece::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.

Parameters
[in]inTypesA map from the input number to the input type
[in]outTypesA map from the output number to the output type

Definition at line 150 of file WorkPiece.cpp.

◆ WorkPiece() [17/19]

WorkPiece::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.

Parameters
[in]inTypesA map from the input number to the input type
[in]numInThe number of inputs
[in]outTypesA map from the output number to the output type

Definition at line 160 of file WorkPiece.cpp.

◆ WorkPiece() [18/19]

WorkPiece::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.

Parameters
[in]inTypesA map from the input number to the input type
[in]outTypesA map from the output number to the output type
[in]outNumThe number of outputs

Definition at line 170 of file WorkPiece.cpp.

◆ WorkPiece() [19/19]

WorkPiece::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.

Parameters
[in]inTypesA map from the input number to the input type
[in]numInThe number of inputs
[in]outTypesA map from the output number to the output type
[in]outNumThe number of outputs

Definition at line 180 of file WorkPiece.cpp.

◆ ~WorkPiece()

virtual muq::Modeling::WorkPiece::~WorkPiece ( )
inlinevirtual

Default destructor.

Definition at line 210 of file WorkPiece.h.

Member Function Documentation

◆ CheckInputType()

bool WorkPiece::CheckInputType ( unsigned int const  inputNum,
std::string const &  type 
) const
protected

Check the input type.

Parameters
[in]inputNumThe input number — we are check that the type has the same type as this input
[in]typeThe type of the input
Returns
true: The input matches the specified type or no input type is specified, false: the input type does not match the specified type

Definition at line 743 of file WorkPiece.cpp.

References muq::Utilities::demangle(), and inputTypes.

Referenced by Evaluate(), and EvaluateRecursive().

◆ CheckOutputType()

bool WorkPiece::CheckOutputType ( unsigned int const  outputNum,
std::string const &  type 
) const
protected

Check the output type.

Parameters
[in]outputNumThe output number — we are check that the computed type has the same type as this output
[in]typeThe type of the output
Returns
true: The output matches the specified type or no output type is specified, false: the output type does not match the specified type

Definition at line 756 of file WorkPiece.cpp.

References muq::Utilities::demangle(), and outputTypes.

Referenced by Evaluate().

◆ Clear()

void WorkPiece::Clear ( )
private

Clear muq::Modeling::WorkPiece::outputs when muq::Modeling::Evaluate is called.

Definition at line 730 of file WorkPiece.cpp.

References clearOutputs, DestroyAny(), and outputs.

Referenced by Evaluate().

◆ CreateID()

unsigned int WorkPiece::CreateID ( )
staticprivate

Creates a unique ID number, must be called by the constructor.

Definition at line 217 of file WorkPiece.cpp.

◆ CreateName()

std::string WorkPiece::CreateName ( ) const
protectedvirtual

Reimplemented in muq::Modeling::CwiseUnaryOperator< T1, T2, T3 >.

Definition at line 546 of file WorkPiece.cpp.

References muq::Utilities::demangle(), and id.

Referenced by Name().

◆ DestroyAny()

void WorkPiece::DestroyAny ( boost::any &  obj) const
private

Destroy a boost any.

Destroys the object associated with a boost::any. If the boost::any is not a smart pointer, for example, the function must destory it.

This function knows how to destory commonly used objects (those in muq::Modeling::WorkPiece::types). Overloading muq::Modeling::WorkPiece::DestroyAnyImpl() destroys other types of objects

Definition at line 689 of file WorkPiece.cpp.

References DestroyAnyImpl().

Referenced by Clear().

◆ DestroyAnyImpl()

void WorkPiece::DestroyAnyImpl ( boost::any &  obj) const
privatevirtual

Destroy a boost any.

By default, this function does nothing. It can be overloaded by the user to destroy objects contained within boost::any's

Definition at line 687 of file WorkPiece.cpp.

Referenced by DestroyAny().

◆ Evaluate() [1/4]

std::vector< boost::any > const & WorkPiece::Evaluate ( )

◆ Evaluate() [2/4]

template<typename... Args>
std::vector<boost::any> const& muq::Modeling::WorkPiece::Evaluate ( Args...  args)
inline

Evalaute this muq::Modeling::WorkPiece using multiple arguments.

This function allows the user to call WorkPiece::Evaluate without first creating a vector of inputs. Instead, the user calls WorkPiece::Evaluate with multiple arguments (if specified, the number of arguments must match the number of inputs) and this function creates the input vector.

Parameters
[in]argsThe inputs (may be more than one)
Returns
The outputs of this muq::Modeling::WorkPiece

Definition at line 245 of file WorkPiece.h.

References Clear(), EvaluateRecursive(), and numInputs.

◆ Evaluate() [3/4]

std::vector< boost::any > const & WorkPiece::Evaluate ( ref_vector< boost::any > const &  ins)

Evaluate this muq::Modeling::WorkPiece using references to the inputs.

This function takes the references to the inputs to the muq::Modeling::WorkPiece, which must match WorkPiece::numInputs and WorkPiece::inputTypes if they are specified. It then calls WorkPiece::EvaluateImpl(), which populates WorkPiece::outputs using the input arguments (passed to WorkPiece::EvaluateImpl()). This function then checks WorkPiece::outputs, which much match WorkPiece::numOutputs and WorkPiece::outputTypes if they are specified.

References are used for efficiency in the muq::Modeling::WorkGraph.

Parameters
[in]insA vector of references to the inputs
Returns
The outputs of this muq::Modeling::WorkPiece

Definition at line 245 of file WorkPiece.cpp.

References CheckOutputType(), Clear(), EvaluateImpl(), name, numInputs, numOutputs, outputs, and nlohmann::to_string().

◆ Evaluate() [4/4]

std::vector< boost::any > const & WorkPiece::Evaluate ( std::vector< boost::any > const &  ins)

Evaluate this muq::Modeling::WorkPiece.

This function takes the inputs to the muq::Modeling::WorkPiece, which must match WorkPiece::numInputs and WorkPiece::inputTypes if they are specified. It then calls WorkPiece::EvaluateImpl(), which populates WorkPiece::outputs using the input arguments (passed to WorkPiece::EvaluateImpl()). This function then checks WorkPiece::outputs, which much match WorkPiece::numOutputs and WorkPiece::outputTypes if they are specified.

This function builds a reference vector to the inputs and calls WorkPiece::Evaluate(ref_vector<boost::any> const& ins)

Parameters
[in]insA vector of inputs
Returns
The outputs of this muq::Modeling::WorkPiece

Definition at line 269 of file WorkPiece.cpp.

References CheckInputType(), Evaluate(), inputTypes, name, numInputs, and ToRefVector().

◆ EvaluateImpl()

virtual void muq::Modeling::WorkPiece::EvaluateImpl ( ref_vector< boost::any > const &  inputs)
privatepure virtual

User-implemented function that determines the behavior of this muq::Modeling::WorkPiece.

This function determines how the WorkPiece::inputs determine WorkPiece::outputs. Must be implemented by a child.

WorkPiece::Evaluate() calls this function after checking the inputs and storing them in WorkPiece::inputs. This function populates WorkPiece::outputs, the outputs of this muq::Modeling::WorkPiece. WorkPiece::Evaluate() checks the outputs after calling this function.

Implemented in muq::Modeling::WorkGraphPiece, muq::Modeling::ModPiece, muq::Modeling::FenicsPiece, muq::Optimization::Optimizer, muq::Optimization::NLoptOptimizer, muq::Modeling::IdentityPiece, muq::Approximation::Regression, and muq::Approximation::IndexedScalarBasis.

Referenced by Evaluate().

◆ EvaluateRecursive() [1/2]

template<typename ith , typename... Args>
std::vector<boost::any> const& muq::Modeling::WorkPiece::EvaluateRecursive ( ref_vector< boost::any > &  inputs,
ith const &  in,
Args...  args 
)
inlineprivate

Creates WorkPiece::inputs when the WorkPiece::Evaluate is called with multiple arguments.

Parameters
[in]inputsThe growing vector of inputs
[in]inThe input corresponding to the \(i^{th}\) input
[in]argsThe remaining (greater than \(i\)) inputs
Returns
The outputs of this muq::Modeling::WorkPiece

Definition at line 606 of file WorkPiece.h.

References CheckInputType(), name, and numInputs.

Referenced by Evaluate().

◆ EvaluateRecursive() [2/2]

template<typename last >
std::vector<boost::any> const& muq::Modeling::WorkPiece::EvaluateRecursive ( ref_vector< boost::any > &  inputs,
last const &  in 
)
inlineprivate

Creates WorkPiece::inputs when the WorkPiece::Evaluate is called with multiple arguments.

Parameters
[in]inputsThe growing vector of inputs
[in]inThe input corresponding to the last input
Returns
The outputs of this muq::Modeling::WorkPiece

Definition at line 630 of file WorkPiece.h.

References CheckInputType(), Evaluate(), name, and numInputs.

◆ GetNumCalls()

unsigned long int WorkPiece::GetNumCalls ( const std::string &  method = "Evaluate") const
virtual

get the number of times one of the implemented methods has been called.

This function returns the number of times the EvaluateImpl, GradientImpl, JacobianImpl, JacobianActionImpl, or HessianImp functions have been called.

Parameters
[in]methodThe implemented function of interest. Possible options are "Evaluate", "Gradient", "Jacobian", "JacobianAction", or "Hessian"
Returns
An integer with the number of calls.

Reimplemented in muq::Modeling::ModPiece.

Definition at line 598 of file WorkPiece.cpp.

References numEvalCalls.

◆ GetRunTime()

double WorkPiece::GetRunTime ( const std::string &  method = "Evaluate") const
virtual

Get the average run time for one of the implemented methods.

This function returns the average wall clock time (in milliseconds) for the EvaluateImpl, GradientImpl, JacobianImpl, JacobianActionImpl, or HessianImp functions. If the function was never called, -1 is returned.

Parameters
[in]methodThe implemented function of interest. Possible options are "Evaluate", "Gradient", "Jacobian", "JacobianAction", or "Hessian"
Returns
The average wall clock time in milli-seconds.

Reimplemented in muq::Modeling::ModPiece.

Definition at line 580 of file WorkPiece.cpp.

References evalTime, and numEvalCalls.

◆ ID()

unsigned int WorkPiece::ID ( ) const

◆ InputSize()

int WorkPiece::InputSize ( unsigned int  inputNum) const

Get the length of a vector valued input with fixed size.

Definition at line 770 of file WorkPiece.cpp.

References inputSizes.

◆ InputType()

std::string WorkPiece::InputType ( unsigned int  inputNum,
bool const  demangle = true 
) const

Get the input type (if we know it) for a specific input.

The return input type name is "demangled" so it is more human readable.

Parameters
[in]inputNumThe input we want the name of
[in]demangletrue (default): demangle the input so it is human-readable, false: do not demangle the input
Returns
If we know the input types, the input type name is returned. If we do not know the input types, return ""

Definition at line 609 of file WorkPiece.cpp.

References muq::Utilities::demangle(), inputTypes, and numInputs.

◆ InputTypes()

std::map< unsigned int, std::string > WorkPiece::InputTypes ( ) const

Get the input types.

Definition at line 659 of file WorkPiece.cpp.

References inputTypes.

◆ Name()

std::string const & WorkPiece::Name ( )

Get the (unique) name of this work piece.

Returns
The name of the muq::Modeling::WorkPiece

Definition at line 538 of file WorkPiece.cpp.

References CreateName(), and name.

◆ OutputType()

std::string WorkPiece::OutputType ( unsigned int  outputNum,
bool const  demangle = true 
) const

Get the output type (if we know it) for a specific output.

The return output type name is "demangled" so it is more human readable.

Parameters
[in]outputNumThe output we want the name of
[in]demangletrue (default): demangle the input so it is human-readable, false: do not demangle the input
Returns
If we know the output types, the output type name is returned. If we do not know the output types, return ""

Definition at line 630 of file WorkPiece.cpp.

References muq::Utilities::demangle(), numOutputs, and outputTypes.

◆ OutputTypes()

std::map< unsigned int, std::string > WorkPiece::OutputTypes ( ) const

Get the output types.

Definition at line 655 of file WorkPiece.cpp.

References outputTypes.

◆ ResetCallTime()

void WorkPiece::ResetCallTime ( )
virtual

Resets the number of call and times.

Sets the number of calls to each implemented function to zero and the recorded wall clock times to zero.

Reimplemented in muq::Modeling::ModPiece.

Definition at line 592 of file WorkPiece.cpp.

References evalTime, and numEvalCalls.

◆ SetInputSize()

void WorkPiece::SetInputSize ( unsigned int  inputNum,
int  newSize 
)

Definition at line 780 of file WorkPiece.cpp.

References inputSizes.

◆ SetName()

void WorkPiece::SetName ( std::string const &  newName)

Set the name of this work piece.

Definition at line 575 of file WorkPiece.cpp.

References name.

◆ ToRefVector() [1/2]

◆ ToRefVector() [2/2]

ref_vector< const Eigen::VectorXd > WorkPiece::ToRefVector ( std::vector< Eigen::VectorXd > const &  anyVec)
static

Definition at line 663 of file WorkPiece.cpp.

◆ Types() [1/2]

std::vector< std::string > WorkPiece::Types ( std::vector< boost::any > const &  vec) const
protected

Get the types from a vector of boost::any's.

Parameters
[in]vecA vector of boost::any's
Returns
A vector of the types of the boost::any's

Definition at line 201 of file WorkPiece.cpp.

◆ Types() [2/2]

std::map< unsigned int, std::string > WorkPiece::Types ( std::vector< std::string > const &  typesVec) const
protected

Convert a vector of input types to a map.

The key in the map is the index of the vector.

Parameters
[in]typesVecA vector of input types
Returns
A map of input types

Definition at line 189 of file WorkPiece.cpp.

Friends And Related Function Documentation

◆ WorkGraph

friend class WorkGraph
friend

Definition at line 44 of file WorkPiece.h.

◆ WorkGraphPiece

friend class WorkGraphPiece
friend

Definition at line 43 of file WorkPiece.h.

Member Data Documentation

◆ clearOutputs

bool muq::Modeling::WorkPiece::clearOutputs = true
protected

Clear outputs every time Evaluate is called.

If true, muq::Modeling::WorkPiece::outputs is cleared everytime muq::Modeling::WorkPiece::Evaluate is called. If false, the outputs are not cleared. Defaults to true.

Definition at line 540 of file WorkPiece.h.

Referenced by Clear(), and muq::Modeling::ConstantPiece::ConstantPiece().

◆ evalTime

double muq::Modeling::WorkPiece::evalTime = 0
protected

◆ id

const unsigned int muq::Modeling::WorkPiece::id
protected

A unique ID number assigned by the constructor.

Definition at line 580 of file WorkPiece.h.

Referenced by CreateName(), ID(), muq::Modeling::ModGraphPiece::InputNodes(), and muq::Modeling::WorkGraphPiece::InputNodes().

◆ inputSizes

std::map<unsigned int, int> muq::Modeling::WorkPiece::inputSizes
protected

◆ inputTypes

std::map<unsigned int, std::string> muq::Modeling::WorkPiece::inputTypes
protected

The input types.

Each element specifies the type of the corresponding input. This vector must have the same number of elements as WorkPiece::numInputs or it is empty (default), which indicates that the input types are variable.

Definition at line 552 of file WorkPiece.h.

Referenced by CheckInputType(), Evaluate(), InputType(), and InputTypes().

◆ name

◆ numEvalCalls

◆ numInputs

◆ numOutputs

int muq::Modeling::WorkPiece::numOutputs

◆ outputs

std::vector<boost::any> muq::Modeling::WorkPiece::outputs = std::vector<boost::any>(0)
protected

◆ outputTypes

std::map<unsigned int, std::string> muq::Modeling::WorkPiece::outputTypes
protected

The output types.

Each element specifies the type of the corresponding output. This vector must have the same number of elements as WorkPiece::numOutputs or it is empty (default), which indicates that the output types are variable.

Definition at line 558 of file WorkPiece.h.

Referenced by CheckOutputType(), Evaluate(), OutputType(), and OutputTypes().


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