169 virtual double GetRunTime(
const std::string& method=
"Evaluate")
const override;
179 virtual unsigned long int GetNumCalls(
const std::string& method =
"Evaluate")
const override;
188 virtual std::vector<Eigen::VectorXd>
const&
Evaluate(std::vector<Eigen::VectorXd>
const& input);
217 virtual Eigen::VectorXd
const&
Gradient(
unsigned int const outputDimWrt,
218 unsigned int const inputDimWrt,
219 std::vector<Eigen::VectorXd>
const& input,
220 Eigen::VectorXd
const& sensitivity);
222 virtual Eigen::VectorXd
const&
Gradient(
unsigned int const outputDimWrt,
223 unsigned int const inputDimWrt,
225 Eigen::VectorXd
const& sensitivity);
227 inline Eigen::VectorXd
const&
Gradient(
unsigned int outWrt,
229 Eigen::VectorXd
const&
last,
230 Eigen::VectorXd
const& sens) {
232 vec.push_back(std::cref(
last));
233 return Gradient(outWrt, inWrt, vec, sens);
236 template<
typename... Args>
237 inline Eigen::VectorXd
const&
Gradient(
unsigned int wrtOut,
239 Args
const&... args) {
248 Eigen::VectorXd
const&
last,
249 Eigen::VectorXd
const& sens,
250 Eigen::VectorXd
const& vec) {
252 invec.push_back(std::cref(
last));
253 return ApplyHessian(outWrt, inWrt1, inWrt2, invec, sens, vec);
256 template<
typename... Args>
260 Args
const&... args) {
281 virtual Eigen::MatrixXd
const&
Jacobian(
unsigned int const outputDimWrt,
282 unsigned int const inputDimWrt,
283 std::vector<Eigen::VectorXd>
const& input);
285 virtual Eigen::MatrixXd
const&
Jacobian(
unsigned int const outputDimWrt,
286 unsigned int const inputDimWrt,
290 template<
typename... Args>
291 inline Eigen::MatrixXd
const&
Jacobian(
unsigned int outWrt,
unsigned int inWrt, Args
const&... args) {
293 return Jacobian(outWrt, inWrt, vec, args...);
296 template<
typename... Args>
297 inline Eigen::MatrixXd
JacobianByFD(
unsigned int outWrt,
unsigned int inWrt, Args
const&... args) {
302 template<
typename... Args>
303 inline Eigen::MatrixXd
ApplyJacobianByFD(
unsigned int outWrt,
unsigned int inWrt, Args
const&... args) {
329 virtual Eigen::VectorXd
const&
ApplyJacobian(
unsigned int const outputDimWrt,
330 unsigned int const inputDimWrt,
331 std::vector<Eigen::VectorXd>
const& input,
332 Eigen::VectorXd
const& vec);
334 virtual Eigen::VectorXd
const&
ApplyJacobian(
unsigned int const outputDimWrt,
335 unsigned int const inputDimWrt,
337 Eigen::VectorXd
const& vec);
339 inline Eigen::VectorXd
const&
ApplyJacobian(
unsigned int outWrt,
unsigned int inWrt, Eigen::VectorXd
const&
last, Eigen::VectorXd
const& sens) { \
340 ref_vector<Eigen::VectorXd> vec;
341 vec.push_back(std::cref(
last)); \
344 template<
typename... Args>
345 inline Eigen::VectorXd
const&
ApplyJacobian(
unsigned int wrtOut,
unsigned int wrtIn, Args
const&... args) {
351 virtual Eigen::VectorXd
GradientByFD(
unsigned int const outputDimWrt,
352 unsigned int const inputDimWrt,
353 std::vector<Eigen::VectorXd>
const& input,
354 Eigen::VectorXd
const& sensitivity);
356 virtual Eigen::VectorXd
GradientByFD(
unsigned int const outputDimWrt,
357 unsigned int const inputDimWrt,
359 Eigen::VectorXd
const& sensitivity);
361 virtual Eigen::MatrixXd
JacobianByFD(
unsigned int const outputDimWrt,
362 unsigned int const inputDimWrt,
363 std::vector<Eigen::VectorXd>
const& input);
365 virtual Eigen::MatrixXd
JacobianByFD(
unsigned int const outputDimWrt,
366 unsigned int const inputDimWrt,
370 unsigned int const inputDimWrt,
371 std::vector<Eigen::VectorXd>
const& input,
372 Eigen::VectorXd
const& vec);
375 unsigned int const inputDimWrt,
377 Eigen::VectorXd
const& vec);
409 virtual Eigen::VectorXd
const&
ApplyHessian(
unsigned int const outWrt,
410 unsigned int const inWrt1,
411 unsigned int const inWrt2,
412 std::vector<Eigen::VectorXd>
const& input,
413 Eigen::VectorXd
const& sens,
414 Eigen::VectorXd
const& vec);
416 virtual Eigen::VectorXd
const&
ApplyHessian(
unsigned int const outWrt,
417 unsigned int const inWrt1,
418 unsigned int const inWrt2,
420 Eigen::VectorXd
const& sens,
421 Eigen::VectorXd
const& vec);
429 unsigned int const inWrt1,
430 unsigned int const inWrt2,
431 std::vector<Eigen::VectorXd>
const& input,
432 Eigen::VectorXd
const& sens,
433 Eigen::VectorXd
const& vec);
436 unsigned int const inWrt1,
437 unsigned int const inWrt2,
439 Eigen::VectorXd
const& sens,
440 Eigen::VectorXd
const& vec);
524 virtual void GradientImpl(
unsigned int const outputDimWrt,
525 unsigned int const inputDimWrt,
527 Eigen::VectorXd
const& sensitivity);
529 virtual void JacobianImpl(
unsigned int const outputDimWrt,
530 unsigned int const inputDimWrt,
534 unsigned int const inputDimWrt,
536 Eigen::VectorXd
const& vec);
539 unsigned int const inWrt1,
540 unsigned int const inWrt2,
542 Eigen::VectorXd
const& sens,
543 Eigen::VectorXd
const& vec);
562 template<
typename NextType,
typename... Args>
567 Args
const&... args) {
569 static_assert(std::is_same<Eigen::VectorXd,
571 "In ModPiece::Gradient, cannot cast input to Eigen::VectorXd.");
573 vec.push_back(std::cref((NextType&)ith));
578 template<
typename NextType>
582 NextType
const&
last,
583 Eigen::VectorXd
const& sens) {
585 vec.push_back(std::cref((NextType&)
last));
586 return Gradient(outWrt, inWrt, vec, sens);
589 template<
typename NextType,
typename... Args>
595 Args
const&... args) {
597 static_assert(std::is_same<Eigen::VectorXd,
599 "In ModPiece::ApplyHessian, cannot cast input to Eigen::VectorXd.");
601 invec.push_back(std::cref((NextType&)ith));
606 template<
typename NextType>
611 NextType
const&
last,
612 Eigen::VectorXd
const& sens,
613 Eigen::VectorXd
const& vec) {
615 invec.push_back(std::cref((NextType&)
last));
616 return ApplyHessian(outWrt, inWrt1, inWrt2, invec, sens, vec);
620 template<
typename... Args>
622 vec.push_back(std::cref(ith)); \
623 return
Jacobian(outWrt, inWrt, vec, args...); \
626 vec.push_back(std::cref(
last));
627 return Jacobian(outWrt, inWrt, vec);
630 template<
typename NextType,
typename... Args> \
633 vec.push_back(std::cref((NextType&)ith)); \
637 template<
typename NextType> \
640 vec.push_back(std::cref((NextType&)
last)); \
644 template<
typename... Args> \
646 vec.push_back(std::cref(ith)); \
650 vec.push_back(std::cref(
last));
654 template<
typename NextType,
typename... Args>
656 vec.push_back(std::cref(ith));
659 template<
typename NextType>
661 vec.push_back(std::cref(
last));
Provides an abstract interface for defining vector-valued model components.
virtual void GradientImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
virtual void ApplyJacobianImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec)
Eigen::VectorXd const & ApplyJacobian(unsigned int wrtOut, unsigned int wrtIn, Args const &... args)
Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &ith, Args const &... args)
virtual Eigen::VectorXd GradientByFD(unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
virtual Eigen::VectorXd const & Gradient(unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
Compute the Gradient .
unsigned long int numJacActFDCalls
virtual void EvaluateImpl(ref_vector< Eigen::VectorXd > const &input)=0
virtual Eigen::VectorXd ApplyHessianByFD(unsigned int const outWrt, unsigned int const inWrt1, unsigned int const inWrt2, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
const Eigen::VectorXi inputSizes
virtual Eigen::MatrixXd const & Jacobian(unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input)
Compute the Jacobian of this ModPiece.
Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, Args const &... args)
std::vector< Eigen::VectorXd > outputs
ModPiece(std::vector< int > const &inputSizes, std::vector< int > const &outputSizes)
Eigen::VectorXd const & ApplyJacobian(unsigned int outWrt, unsigned int inWrt, Eigen::VectorXd const &last, Eigen::VectorXd const &sens)
virtual void EvaluateImpl(ref_vector< boost::any > const &inputs) override
User-implemented function that determines the behavior of this muq::Modeling::WorkPiece.
Eigen::VectorXd const & GradientRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &last, Eigen::VectorXd const &sens)
Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &last, Eigen::VectorXd const &sens)
VARIADIC_TO_REFVECTOR(Evaluate, Eigen::VectorXd, std::vector< Eigen::VectorXd > const &)
Eigen::MatrixXd const & Jacobian(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &ith, Args const &... args)
Eigen::VectorXd const & ApplyHessianRecurse(unsigned int outWrt, unsigned int inWrt1, unsigned int inWrt2, ref_vector< Eigen::VectorXd > &invec, NextType const &ith, Args const &... args)
virtual double GetRunTime(const std::string &method="Evaluate") const override
Get the average run time for one of the implemented methods.
Eigen::VectorXd const & Gradient(unsigned int wrtOut, unsigned int wrtIn, Args const &... args)
unsigned long int numJacActCalls
unsigned long int numHessActFDCalls
virtual void JacobianImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input)
unsigned long int numJacCalls
virtual void SetWarnLevel(unsigned int newLevel)
Eigen::VectorXd const & Gradient(unsigned int outWrt, unsigned int inWrt, Eigen::VectorXd const &last, Eigen::VectorXd const &sens)
Eigen::VectorXd const & GradientRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &ith, Args const &... args)
virtual Eigen::VectorXd const & ApplyJacobian(unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec)
Apply the Jacobian of this ModPiece to a vector.
Eigen::VectorXd const & ApplyHessian(unsigned int outWrt, unsigned int inWrt1, unsigned int inWrt2, Eigen::VectorXd const &last, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
unsigned long int numGradFDCalls
const Eigen::VectorXi outputSizes
Eigen::VectorXd const & ApplyHessian(unsigned int wrtOut, unsigned int wrtIn1, unsigned int wrtIn2, Args const &... args)
Eigen::MatrixXd const & Jacobian(unsigned int outWrt, unsigned int inWrt, Args const &... args)
void CheckInputs(ref_vector< Eigen::VectorXd > const &input, std::string const &funcName)
virtual ~ModPiece()=default
Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, Args const &... args)
bool ExistsInCache(ref_vector< Eigen::VectorXd > const &input) const
Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &ith, Args const &... args)
unsigned long int numJacFDCalls
Eigen::VectorXd const & ApplyJacobianRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &ith, Args const &... args)
std::vector< Eigen::VectorXd > ToStdVec(ref_vector< Eigen::VectorXd > const &input)
std::vector< Eigen::VectorXd > cacheInput
virtual unsigned long int GetNumCalls(const std::string &method="Evaluate") const override
get the number of times one of the implemented methods has been called.
virtual void ResetCallTime() override
Resets the number of call and times.
unsigned long int numGradCalls
Eigen::VectorXd hessAction
Eigen::VectorXd const & ApplyJacobianRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &last, Eigen::VectorXd const &sens)
Eigen::VectorXd jacobianAction
Eigen::MatrixXd const & Jacobian(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &last)
virtual void ApplyHessianImpl(unsigned int const outWrt, unsigned int const inWrt1, unsigned int const inWrt2, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
Eigen::VectorXd const & ApplyHessianRecurse(unsigned int outWrt, unsigned int inWrt1, unsigned int inWrt2, ref_vector< Eigen::VectorXd > &invec, NextType const &last, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
unsigned long int numHessActCalls
Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &last)
Base class for MUQ's modelling envronment.
std::vector< boost::any > const & Evaluate()
Evaluate this muq::Modeling::WorkPiece in the case that there are no inputs.
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...