13 #include "boost/any.hpp"
14 #include "boost/optional.hpp"
16 #include <Eigen/Dense>
22 #if MUQ_HAS_SUNDIALS==1
24 #include <nvector/nvector_serial.h>
25 #include <sundials/sundials_dense.h>
37 using ref_vector = std::vector<std::reference_wrapper<const T>>;
72 WorkPiece(
int const numIns,
int const numOuts);
108 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);
115 WorkPiece(std::vector<std::string>
const& types,
int const num);
122 WorkPiece(
int const num, std::vector<std::string>
const& types);
130 WorkPiece(std::map<unsigned int, std::string>
const& inTypes,
int const numIns,
int const numOuts);
138 WorkPiece(
int const numIns, std::map<unsigned int, std::string>
const& outTypes,
int const numOuts);
145 WorkPiece(std::vector<std::string>
const& inTypes, std::vector<std::string>
const& outTypes);
152 WorkPiece(std::map<unsigned int, std::string>
const& inTypes, std::vector<std::string>
const& outTypes);
160 WorkPiece(std::map<unsigned int, std::string>
const& inTypes,
int const num, std::vector<std::string>
const& outTypes);
167 WorkPiece(std::vector<std::string>
const& inTypes, std::map<unsigned int, std::string>
const& outTypes);
175 WorkPiece(std::vector<std::string>
const& inTypes, std::map<unsigned int, std::string>
const& outTypes,
int const num);
182 WorkPiece(std::map<unsigned int, std::string>
const& inTypes, std::map<unsigned int, std::string>
const& outTypes);
190 WorkPiece(std::map<unsigned int, std::string>
const& inTypes,
int const numIn, std::map<unsigned int, std::string>
const& outTypes);
198 WorkPiece(std::map<unsigned int, std::string>
const& inTypes, std::map<unsigned int, std::string>
const& outTypes,
int const numOut);
207 WorkPiece(std::map<unsigned int, std::string>
const& inTypes,
int const numIn, std::map<unsigned int, std::string>
const& outTypes,
int const numOut);
220 std::vector<boost::any>
const&
Evaluate(std::vector<boost::any>
const& ins);
236 std::vector<boost::any>
const&
Evaluate();
244 template<
typename... Args>
245 std::vector<boost::any>
const&
Evaluate(Args... args) {
435 std::string
const&
Name();
438 void SetName(std::string
const& newName);
450 int InputSize(
unsigned int inputNum)
const;
464 std::map<unsigned int, std::string>
OutputTypes()
const;
467 std::map<unsigned int, std::string>
InputTypes()
const;
473 unsigned int ID()
const;
483 virtual double GetRunTime(
const std::string& method=
"Evaluate")
const;
492 virtual unsigned long int GetNumCalls(
const std::string& method =
"Evaluate")
const;
518 bool CheckInputType(
unsigned int const inputNum, std::string
const& type)
const;
526 bool CheckOutputType(
unsigned int const outputNum, std::string
const& type)
const;
534 std::vector<std::string>
Types(std::vector<boost::any>
const& vec)
const;
546 std::vector<boost::any>
outputs = std::vector<boost::any>(0);
568 std::map<unsigned int, std::string>
Types(std::vector<std::string>
const& typesVec)
const;
580 const unsigned int id;
605 template<
typename ith,
typename... Args>
607 const int inputNum = inputs.size();
616 const boost::any in_any(in);
617 inputs.push_back(std::cref(in_any));
629 template<
typename last>
632 const int inputNum = inputs.size();
641 const boost::any in_any(in);
642 inputs.push_back(std::cref(in_any));
A muq::Modeling::WorkPiece created from a muq::Modeling::WorkGraph.
A graph of connected muq::Modeling::WorkPiece's.
Base class for MUQ's modelling envronment.
void Clear()
Clear muq::Modeling::WorkPiece::outputs when muq::Modeling::Evaluate is called.
std::vector< boost::any > const & EvaluateRecursive(ref_vector< boost::any > &inputs, ith const &in, Args... args)
Creates WorkPiece::inputs when the WorkPiece::Evaluate is called with multiple arguments.
std::string const & Name()
Get the (unique) name of this work piece.
std::map< unsigned int, std::string > outputTypes
The output types.
std::map< unsigned int, int > inputSizes
bool CheckOutputType(unsigned int const outputNum, std::string const &type) const
Check the output type.
std::map< unsigned int, std::string > OutputTypes() const
Get the output types.
bool CheckInputType(unsigned int const inputNum, std::string const &type) const
Check the input type.
std::vector< boost::any > const & EvaluateRecursive(ref_vector< boost::any > &inputs, last const &in)
Creates WorkPiece::inputs when the WorkPiece::Evaluate is called with multiple arguments.
const unsigned int id
A unique ID number assigned by the constructor.
virtual unsigned long int GetNumCalls(const std::string &method="Evaluate") const
get the number of times one of the implemented methods has been called.
std::map< unsigned int, std::string > inputTypes
The input types.
WorkPiece()
Create a muq::Modeling::WorkPiece with no fixed number of inputs and outputs and variable input/outpu...
std::string OutputType(unsigned int outputNum, bool const demangle=true) const
Get the output type (if we know it) for a specific output.
virtual double GetRunTime(const std::string &method="Evaluate") const
Get the average run time for one of the implemented methods.
virtual void EvaluateImpl(ref_vector< boost::any > const &inputs)=0
User-implemented function that determines the behavior of this muq::Modeling::WorkPiece.
unsigned long int numEvalCalls
virtual void ResetCallTime()
Resets the number of call and times.
std::vector< boost::any > const & Evaluate(Args... args)
Evalaute this muq::Modeling::WorkPiece using multiple arguments.
std::map< unsigned int, std::string > InputTypes() const
Get the input types.
std::vector< std::string > Types(std::vector< boost::any > const &vec) const
Get the types from a vector of boost::any's.
static ref_vector< const boost::any > ToRefVector(std::vector< boost::any > const &anyVec)
Create vector of references from a vector of boost::any's.
void SetName(std::string const &newName)
Set the name of this work piece.
std::string InputType(unsigned int inputNum, bool const demangle=true) const
Get the input type (if we know it) for a specific input.
unsigned int ID() const
Get the unique ID number.
bool clearOutputs
Clear outputs every time Evaluate is called.
void DestroyAny(boost::any &obj) const
Destroy a boost any.
int numOutputs
The number of outputs.
void SetInputSize(unsigned int inputNum, int newSize)
Fix
Does the constructor fix the inputs or the outputs?
@ Inputs
The constructor fixes the input number and possibly the types.
@ Outputs
The constructor fixes the output number and possibly the types.
virtual ~WorkPiece()
Default destructor.
virtual std::string CreateName() const
virtual void DestroyAnyImpl(boost::any &obj) const
Destroy a boost any.
std::vector< boost::any > outputs
The outputs.
std::vector< boost::any > const & Evaluate()
Evaluate this muq::Modeling::WorkPiece in the case that there are no inputs.
static unsigned int CreateID()
Creates a unique ID number, must be called by the constructor.
int InputSize(unsigned int inputNum) const
Get the length of a vector valued input with fixed size.
std::string name
A unique name for this WorkPiece. Defaults to <ClassName>_<id>
int numInputs
The number of inputs.
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
std::string demangle(const char *name)