Base class for MUQ's modelling envronment. More...
#include <WorkPiece.h>
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 |
|
protected |
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.
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::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.
[in] | num | The number of inputs or outputs (which one depends on the second parameter) |
[in] | fix | WorkPiece::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::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.
[in] | numIns | The number of inputs |
[in] | numOuts | The number of outputs |
Definition at line 26 of file WorkPiece.cpp.
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.
[in] | types | A 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] | fix | WorkPiece::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::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
are valid muq::Modeling::WorkPiece::Evaluate calls but
is not valid.
[in] | types | A map from the input/output number to the input/output type |
[in] | fix | WorkPiece::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::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.
[in] | types | A map from the input/output number to the input/output type |
[in] | num | The number of inputs/outputs |
[in] | fixTypes | WorkPiece::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] | fixNum | WorkPiece::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::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)
[in] | types | A vector of strings, each element is the type of an input (the number of inputs is the size of this vector) |
[in] | num | The number of outputs |
Definition at line 64 of file WorkPiece.cpp.
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)
[in] | num | The number of inputs |
[in] | types | A 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::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.
[in] | inTypes | A map from the input number to the input type |
[in] | numIns | The number of inputs |
[in] | numOuts | The number of outputs |
Definition at line 82 of file WorkPiece.cpp.
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.
[in] | numIns | The number of inputs |
[in] | outTypes | A map from the input number to the input type |
[in] | numOuts | The number of outputs |
Definition at line 91 of file WorkPiece.cpp.
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.
[in] | inTypes | A vector of strings, each element is the type of an input (the number of inputs is the size of this vector) |
[in] | outTypes | A 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::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.
[in] | inTypes | A map from the input number to the input type |
[in] | outTypes | A 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::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.
[in] | inTypes | A map from the input number to the input type |
[in] | num | The number of inputs |
[in] | outTypes | A 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::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.
[in] | inTypes | A vector of strings, each element is the type of an input (the number of inputs is the size of this vector) |
[in] | outTypes | A map from the output number to the output type |
Definition at line 130 of file WorkPiece.cpp.
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.
[in] | inTypes | A vector of strings, each element is the type of an input (the number of inputs is the size of this vector) |
[in] | outTypes | A map from the output number to the output type |
[in] | num | The number of outputs |
Definition at line 140 of file WorkPiece.cpp.
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.
[in] | inTypes | A map from the input number to the input type |
[in] | outTypes | A map from the output number to the output type |
Definition at line 150 of file WorkPiece.cpp.
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.
[in] | inTypes | A map from the input number to the input type |
[in] | numIn | The number of inputs |
[in] | outTypes | A map from the output number to the output type |
Definition at line 160 of file WorkPiece.cpp.
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.
[in] | inTypes | A map from the input number to the input type |
[in] | outTypes | A map from the output number to the output type |
[in] | outNum | The number of outputs |
Definition at line 170 of file WorkPiece.cpp.
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.
[in] | inTypes | A map from the input number to the input type |
[in] | numIn | The number of inputs |
[in] | outTypes | A map from the output number to the output type |
[in] | outNum | The number of outputs |
Definition at line 180 of file WorkPiece.cpp.
|
inlinevirtual |
Default destructor.
Definition at line 210 of file WorkPiece.h.
|
protected |
Check the input type.
[in] | inputNum | The input number — we are check that the type has the same type as this input |
[in] | type | The type of the input |
Definition at line 743 of file WorkPiece.cpp.
References muq::Utilities::demangle(), and inputTypes.
Referenced by Evaluate(), and EvaluateRecursive().
|
protected |
Check the output type.
[in] | outputNum | The output number — we are check that the computed type has the same type as this output |
[in] | type | The type of the output |
Definition at line 756 of file WorkPiece.cpp.
References muq::Utilities::demangle(), and outputTypes.
Referenced by Evaluate().
|
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().
|
staticprivate |
Creates a unique ID number, must be called by the constructor.
Definition at line 217 of file WorkPiece.cpp.
|
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().
|
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().
|
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().
std::vector< boost::any > const & WorkPiece::Evaluate | ( | ) |
Evaluate this muq::Modeling::WorkPiece in the case that there are no inputs.
Definition at line 222 of file WorkPiece.cpp.
References Clear(), EvaluateImpl(), name, numInputs, numOutputs, outputs, and outputTypes.
Referenced by muq::Modeling::ModPiece::ApplyJacobianByFD(), Evaluate(), muq::Modeling::ModPiece::Evaluate(), EvaluateRecursive(), and muq::Modeling::ModPiece::JacobianByFD().
|
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.
[in] | args | The inputs (may be more than one) |
Definition at line 245 of file WorkPiece.h.
References Clear(), EvaluateRecursive(), and numInputs.
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.
[in] | ins | A vector of references to the inputs |
Definition at line 245 of file WorkPiece.cpp.
References CheckOutputType(), Clear(), EvaluateImpl(), name, numInputs, numOutputs, outputs, and nlohmann::to_string().
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)
[in] | ins | A vector of inputs |
Definition at line 269 of file WorkPiece.cpp.
References CheckInputType(), Evaluate(), inputTypes, name, numInputs, and ToRefVector().
|
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().
|
inlineprivate |
Creates WorkPiece::inputs when the WorkPiece::Evaluate is called with multiple arguments.
[in] | inputs | The growing vector of inputs |
[in] | in | The input corresponding to the \(i^{th}\) input |
[in] | args | The remaining (greater than \(i\)) inputs |
Definition at line 606 of file WorkPiece.h.
References CheckInputType(), name, and numInputs.
Referenced by Evaluate().
|
inlineprivate |
Creates WorkPiece::inputs when the WorkPiece::Evaluate is called with multiple arguments.
[in] | inputs | The growing vector of inputs |
[in] | in | The input corresponding to the last input |
Definition at line 630 of file WorkPiece.h.
References CheckInputType(), Evaluate(), name, and numInputs.
|
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.
[in] | method | The implemented function of interest. Possible options are "Evaluate", "Gradient", "Jacobian", "JacobianAction", or "Hessian" |
Reimplemented in muq::Modeling::ModPiece.
Definition at line 598 of file WorkPiece.cpp.
References numEvalCalls.
|
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.
[in] | method | The implemented function of interest. Possible options are "Evaluate", "Gradient", "Jacobian", "JacobianAction", or "Hessian" |
Reimplemented in muq::Modeling::ModPiece.
Definition at line 580 of file WorkPiece.cpp.
References evalTime, and numEvalCalls.
unsigned int WorkPiece::ID | ( | ) | const |
Get the unique ID number.
Definition at line 651 of file WorkPiece.cpp.
References id.
Referenced by muq::Modeling::ModGraphPiece::RequiredInputs(), muq::Modeling::WorkGraphPiece::RequiredInputs(), muq::Modeling::ModGraphPiece::RequiredOutputs(), and muq::Modeling::WorkGraphPiece::RequiredOutputs().
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.
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.
[in] | inputNum | The input we want the name of |
[in] | demangle | true (default): demangle the input so it is human-readable, false: do not demangle the input |
Definition at line 609 of file WorkPiece.cpp.
References muq::Utilities::demangle(), inputTypes, and numInputs.
std::map< unsigned int, std::string > WorkPiece::InputTypes | ( | ) | const |
std::string const & WorkPiece::Name | ( | ) |
Get the (unique) name of this work piece.
Definition at line 538 of file WorkPiece.cpp.
References CreateName(), and name.
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.
[in] | outputNum | The output we want the name of |
[in] | demangle | true (default): demangle the input so it is human-readable, false: do not demangle the input |
Definition at line 630 of file WorkPiece.cpp.
References muq::Utilities::demangle(), numOutputs, and outputTypes.
std::map< unsigned int, std::string > WorkPiece::OutputTypes | ( | ) | const |
|
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.
void WorkPiece::SetInputSize | ( | unsigned int | inputNum, |
int | newSize | ||
) |
Definition at line 780 of file WorkPiece.cpp.
References inputSizes.
void WorkPiece::SetName | ( | std::string const & | newName | ) |
|
static |
Create vector of references from a vector of boost::any's.
Definition at line 675 of file WorkPiece.cpp.
Referenced by muq::Modeling::ModPiece::ApplyHessian(), muq::Modeling::ModPiece::ApplyHessianByFD(), muq::Modeling::ModPiece::ApplyJacobian(), muq::Modeling::ModPiece::ApplyJacobianByFD(), Evaluate(), muq::Modeling::ModPiece::Evaluate(), muq::Modeling::ModGraphPiece::FillOutputMap(), muq::Modeling::ModPiece::Gradient(), muq::Modeling::ModPiece::GradientByFD(), muq::Modeling::ModPiece::Jacobian(), muq::Modeling::ModPiece::JacobianByFD(), and muq::Modeling::WorkGraphPiece::OutputMap().
|
static |
Definition at line 663 of file WorkPiece.cpp.
|
protected |
Get the types from a vector of boost::any's.
[in] | vec | A vector of boost::any's |
Definition at line 201 of file WorkPiece.cpp.
|
protected |
Convert a vector of input types to a map.
The key in the map is the index of the vector.
[in] | typesVec | A vector of input types |
Definition at line 189 of file WorkPiece.cpp.
|
friend |
Definition at line 44 of file WorkPiece.h.
|
friend |
Definition at line 43 of file WorkPiece.h.
|
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().
|
protected |
Definition at line 577 of file WorkPiece.h.
Referenced by muq::Modeling::ModPiece::Evaluate(), GetRunTime(), muq::Modeling::ModPiece::GetRunTime(), ResetCallTime(), and muq::Modeling::ModPiece::ResetCallTime().
|
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().
|
protected |
Definition at line 560 of file WorkPiece.h.
Referenced by muq::Approximation::Regression::PoisednessCost::GradientImpl(), InputSize(), muq::Approximation::Regression::PoisednessConstraint::JacobianImpl(), and SetInputSize().
|
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().
|
protected |
A unique name for this WorkPiece. Defaults to <ClassName>_<id>
Definition at line 583 of file WorkPiece.h.
Referenced by Evaluate(), EvaluateRecursive(), muq::Modeling::FenicsPiece::ExtractInputs(), muq::Approximation::BasisExpansion::FromHDF5(), muq::Approximation::IndexedScalarBasis::IndexedScalarBasis(), muq::Modeling::ModGraphPiece::JacobianGraph(), Name(), muq::Optimization::Optimizer::Optimizer(), muq::Modeling::UMBridgeModPiece::read_input_size(), muq::Modeling::UMBridgeModPiece::read_output_size(), and SetName().
|
protected |
Definition at line 573 of file WorkPiece.h.
Referenced by muq::Modeling::ModPiece::Evaluate(), GetNumCalls(), muq::Modeling::ModPiece::GetNumCalls(), GetRunTime(), muq::Modeling::ModPiece::GetRunTime(), ResetCallTime(), and muq::Modeling::ModPiece::ResetCallTime().
int muq::Modeling::WorkPiece::numInputs |
The number of inputs.
Definition at line 501 of file WorkPiece.h.
Referenced by muq::Modeling::DensityProduct::DensityProduct(), Evaluate(), muq::Modeling::UMBridgeModPiece::EvaluateImpl(), EvaluateRecursive(), muq::Modeling::GradientPiece::GetInputSizes(), muq::Modeling::JacobianPiece::GetInputSizes(), InputType(), muq::Modeling::ModGraphPiece::ModGraphPiece(), muq::Modeling::SumPiece::SumPiece(), and muq::Modeling::WorkGraphPiece::WorkGraphPiece().
int muq::Modeling::WorkPiece::numOutputs |
The number of outputs.
Definition at line 504 of file WorkPiece.h.
Referenced by muq::Modeling::ConstantPiece::ConstantPiece(), Evaluate(), muq::Modeling::UMBridgeModPiece::EvaluateImpl(), OutputType(), and muq::Modeling::UMBridgeModPiece::UMBridgeModPiece().
|
protected |
The outputs.
The outputs of this muq::Modeling::WorkPiece are filled by WorkPiece::EvaluateImpl(). If the number of outputs is specified (i.e., WorkPiece::numOutputs is not -1) then WorkPiece::Evaluate() checks to make sure the size of this vector is equal to WorkPiece::numOutputs after calling WorkPiece::EvaluateImpl(). If the output types are specified (i.e., WorkPiece::outputTypes is not an empty vector) then WorkPiece::Evaluate() checks that the output types match WorkPiece::outputTypes after calling WorkPiece::EvaluateImpl().
Definition at line 546 of file WorkPiece.h.
Referenced by Clear(), muq::Modeling::ConstantPiece::ConstantPiece(), Evaluate(), muq::Approximation::IndexedScalarBasis::EvaluateImpl(), muq::Approximation::Regression::EvaluateImpl(), muq::Modeling::IdentityPiece::EvaluateImpl(), muq::Optimization::Optimizer::EvaluateImpl(), muq::Approximation::Regression::PoisednessConstraint::EvaluateImpl(), muq::Modeling::FenicsPiece::EvaluateImpl(), muq::Modeling::ModPiece::EvaluateImpl(), and muq::Modeling::WorkGraphPiece::EvaluateImpl().
|
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().