MUQ  0.4.3
ModPiece.h
Go to the documentation of this file.
1 #ifndef MODPIECE_H
2 #define MODPIECE_H
3 
6 
7 #include <Eigen/Core>
8 #include <vector>
9 
10 namespace muq{
11  namespace Modeling{
12 
147  class ModPiece : public WorkPiece
148  {
149 
150  public:
151 
152  ModPiece(std::vector<int> const& inputSizes,
153  std::vector<int> const& outputSizes);
154 
155  ModPiece(Eigen::VectorXi const& inputSizes,
156  Eigen::VectorXi const& outputSizes);
157 
158  virtual ~ModPiece() = default;
159 
160 
169  virtual double GetRunTime(const std::string& method="Evaluate") const override;
170  virtual void ResetCallTime() override;
171 
179  virtual unsigned long int GetNumCalls(const std::string& method = "Evaluate") const override;
180 
188  virtual std::vector<Eigen::VectorXd> const& Evaluate(std::vector<Eigen::VectorXd> const& input);
189  virtual std::vector<Eigen::VectorXd> const& Evaluate(ref_vector<Eigen::VectorXd> const& input);
190  VARIADIC_TO_REFVECTOR(Evaluate, Eigen::VectorXd, std::vector<Eigen::VectorXd> const&);
191 
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);
221 
222  virtual Eigen::VectorXd const& Gradient(unsigned int const outputDimWrt,
223  unsigned int const inputDimWrt,
224  ref_vector<Eigen::VectorXd> const& input,
225  Eigen::VectorXd const& sensitivity);
226 
227  inline Eigen::VectorXd const& Gradient(unsigned int outWrt,
228  unsigned int inWrt,
229  Eigen::VectorXd const& last,
230  Eigen::VectorXd const& sens) {
232  vec.push_back(std::cref(last));
233  return Gradient(outWrt, inWrt, vec, sens);
234  }
235 
236  template<typename... Args>
237  inline Eigen::VectorXd const& Gradient(unsigned int wrtOut,
238  unsigned int wrtIn,
239  Args const&... args) {
241  return GradientRecurse(wrtOut, wrtIn, vec, args...);
242  }
243 
244 
245  inline Eigen::VectorXd const& ApplyHessian(unsigned int outWrt,
246  unsigned int inWrt1,
247  unsigned int inWrt2,
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);
254  }
255 
256  template<typename... Args>
257  inline Eigen::VectorXd const& ApplyHessian(unsigned int wrtOut,
258  unsigned int wrtIn1,
259  unsigned int wrtIn2,
260  Args const&... args) {
262  return ApplyHessianRecurse(wrtOut, wrtIn1, wrtIn2, invec, args...);
263  }
264 
281  virtual Eigen::MatrixXd const& Jacobian(unsigned int const outputDimWrt,
282  unsigned int const inputDimWrt,
283  std::vector<Eigen::VectorXd> const& input);
284 
285  virtual Eigen::MatrixXd const& Jacobian(unsigned int const outputDimWrt,
286  unsigned int const inputDimWrt,
287  ref_vector<Eigen::VectorXd> const& input);
288 
289 
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...);
294  }
295 
296  template<typename... Args>
297  inline Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, Args const&... args) {
299  return JacobianByFD(outWrt, inWrt, vec, args...);
300  }
301 
302  template<typename... Args>
303  inline Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, Args const&... args) {
305  return ApplyJacobianByFD(outWrt, inWrt, vec, args...);
306  }
307 
308 
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);
333 
334  virtual Eigen::VectorXd const& ApplyJacobian(unsigned int const outputDimWrt,
335  unsigned int const inputDimWrt,
336  ref_vector<Eigen::VectorXd> const& input,
337  Eigen::VectorXd const& vec);
338 
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)); \
342  return ApplyJacobian(outWrt, inWrt, vec, sens); \
343  }
344  template<typename... Args>
345  inline Eigen::VectorXd const& ApplyJacobian(unsigned int wrtOut, unsigned int wrtIn, Args const&... args) {
347  return ApplyJacobianRecurse(wrtOut, wrtIn, vec, args...);
348  }
349 
350 
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);
355 
356  virtual Eigen::VectorXd GradientByFD(unsigned int const outputDimWrt,
357  unsigned int const inputDimWrt,
358  ref_vector<Eigen::VectorXd> const& input,
359  Eigen::VectorXd const& sensitivity);
360 
361  virtual Eigen::MatrixXd JacobianByFD(unsigned int const outputDimWrt,
362  unsigned int const inputDimWrt,
363  std::vector<Eigen::VectorXd> const& input);
364 
365  virtual Eigen::MatrixXd JacobianByFD(unsigned int const outputDimWrt,
366  unsigned int const inputDimWrt,
367  ref_vector<Eigen::VectorXd> const& input);
368 
369  virtual Eigen::VectorXd ApplyJacobianByFD(unsigned int const outputDimWrt,
370  unsigned int const inputDimWrt,
371  std::vector<Eigen::VectorXd> const& input,
372  Eigen::VectorXd const& vec);
373 
374  virtual Eigen::VectorXd ApplyJacobianByFD(unsigned int const outputDimWrt,
375  unsigned int const inputDimWrt,
376  ref_vector<Eigen::VectorXd> const& input,
377  Eigen::VectorXd const& vec);
378 
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);
415 
416  virtual Eigen::VectorXd const& ApplyHessian(unsigned int const outWrt,
417  unsigned int const inWrt1,
418  unsigned int const inWrt2,
419  ref_vector<Eigen::VectorXd> const& input,
420  Eigen::VectorXd const& sens,
421  Eigen::VectorXd const& vec);
422 
428  virtual Eigen::VectorXd ApplyHessianByFD(unsigned int const outWrt,
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);
434 
435  virtual Eigen::VectorXd ApplyHessianByFD(unsigned int const outWrt,
436  unsigned int const inWrt1,
437  unsigned int const inWrt2,
438  ref_vector<Eigen::VectorXd> const& input,
439  Eigen::VectorXd const& sens,
440  Eigen::VectorXd const& vec);
441 
459  void EnableCache(){cacheEnabled=true;};
460  void DisableCache(){cacheEnabled=false;};
461  bool CacheStatus() const{return cacheEnabled;};
462 
463 
469  virtual void SetWarnLevel(unsigned int newLevel){fdWarnLevel=newLevel;};
470 
471  const Eigen::VectorXi inputSizes;
472  const Eigen::VectorXi outputSizes;
473 
474  protected:
475 
476  std::vector<Eigen::VectorXd> ToStdVec(ref_vector<Eigen::VectorXd> const& input);
477 
478  // Should one step caching be used?
479  bool cacheEnabled = false;
480  std::vector<Eigen::VectorXd> cacheInput;
481 
483  bool ExistsInCache(ref_vector<Eigen::VectorXd> const& input) const;
484 
485  // The following variables keep track of how many times the Implemented functions, i.e. EvaluateImpl, GradientImpl,
486  // etc... are called.
487  unsigned long int numGradCalls = 0;
488  unsigned long int numJacCalls = 0;
489  unsigned long int numJacActCalls = 0;
490  unsigned long int numHessActCalls = 0;
491  unsigned long int numGradFDCalls = 0;
492  unsigned long int numJacFDCalls = 0;
493  unsigned long int numJacActFDCalls = 0;
494  unsigned long int numHessActFDCalls = 0;
495 
496  // these variables keep track of the total wall-clock time spent in each of the Implemented functions. They are in
497  // units of milliseconds
498  double gradTime = 0;
499  double jacTime = 0;
500  double jacActTime = 0;
501  double hessActTime = 0;
502 
503  std::vector<Eigen::VectorXd> outputs;
504  Eigen::VectorXd gradient;
505  Eigen::VectorXd jacobianAction;
506  Eigen::MatrixXd jacobian;
507  Eigen::VectorXd hessAction;
508 
516  unsigned int fdWarnLevel = 0;
517 
518  void CheckInputs(ref_vector<Eigen::VectorXd> const& input, std::string const& funcName);
519 
520  virtual void EvaluateImpl(ref_vector<boost::any> const& inputs) override;
521 
522  virtual void EvaluateImpl(ref_vector<Eigen::VectorXd> const& input) = 0;
523 
524  virtual void GradientImpl(unsigned int const outputDimWrt,
525  unsigned int const inputDimWrt,
526  ref_vector<Eigen::VectorXd> const& input,
527  Eigen::VectorXd const& sensitivity);
528 
529  virtual void JacobianImpl(unsigned int const outputDimWrt,
530  unsigned int const inputDimWrt,
531  ref_vector<Eigen::VectorXd> const& input);
532 
533  virtual void ApplyJacobianImpl(unsigned int const outputDimWrt,
534  unsigned int const inputDimWrt,
535  ref_vector<Eigen::VectorXd> const& input,
536  Eigen::VectorXd const& vec);
537 
538  virtual void ApplyHessianImpl(unsigned int const outWrt,
539  unsigned int const inWrt1,
540  unsigned int const inWrt2,
541  ref_vector<Eigen::VectorXd> const& input,
542  Eigen::VectorXd const& sens,
543  Eigen::VectorXd const& vec);
544 
545  // virtual void ApplyHessianImpl(int const outputDimWrt,
546  // int const inputDimWrt1,
547  // int const inputDimWrt2,
548  // ref_vector<Eigen::VectorXd> const& input,
549  // Eigen::VectorXd const& sensitivity
550  // Eigen::VectorXd const& vec);
551 
552 
553  // virtual void ApplyHessianByFD(int const outputDimWrt,
554  // int const inputDimWrt1,
555  // int const inputDimWrt2,
556  // ref_vector<Eigen::VectorXd> const& input,
557  // Eigen::VectorXd const& sensitivity
558  // Eigen::VectorXd const& vec);
559 
560  private:
561 
562  template<typename NextType, typename... Args>
563  inline Eigen::VectorXd const& GradientRecurse(unsigned int outWrt,
564  unsigned int inWrt,
566  NextType const& ith,
567  Args const&... args) {
568 
569  static_assert(std::is_same<Eigen::VectorXd,
570  NextType>::value,
571  "In ModPiece::Gradient, cannot cast input to Eigen::VectorXd.");
572 
573  vec.push_back(std::cref((NextType&)ith));
574  return GradientRecurse(outWrt, inWrt, vec, args...);
575 
576  }
577 
578  template<typename NextType>
579  inline Eigen::VectorXd const& GradientRecurse(unsigned int outWrt,
580  unsigned int inWrt,
582  NextType const& last,
583  Eigen::VectorXd const& sens) {
584  static_assert(std::is_same<Eigen::VectorXd, NextType>::value, "In ModPiece::Gradient, cannot cast input to Eigen::VectorXd.");
585  vec.push_back(std::cref((NextType&)last));
586  return Gradient(outWrt, inWrt, vec, sens);
587  }
588 
589  template<typename NextType, typename... Args>
590  inline Eigen::VectorXd const& ApplyHessianRecurse(unsigned int outWrt,
591  unsigned int inWrt1,
592  unsigned int inWrt2,
594  NextType const& ith,
595  Args const&... args) {
596 
597  static_assert(std::is_same<Eigen::VectorXd,
598  NextType>::value,
599  "In ModPiece::ApplyHessian, cannot cast input to Eigen::VectorXd.");
600 
601  invec.push_back(std::cref((NextType&)ith));
602  return ApplyHessianRecurse(outWrt, inWrt1, inWrt2, invec, args...);
603 
604  }
605 
606  template<typename NextType>
607  inline Eigen::VectorXd const& ApplyHessianRecurse(unsigned int outWrt,
608  unsigned int inWrt1,
609  unsigned int inWrt2,
611  NextType const& last,
612  Eigen::VectorXd const& sens,
613  Eigen::VectorXd const& vec) {
614  static_assert(std::is_same<Eigen::VectorXd, NextType>::value, "In ModPiece::ApplyHessian, cannot cast input to Eigen::VectorXd.");
615  invec.push_back(std::cref((NextType&)last));
616  return ApplyHessian(outWrt, inWrt1, inWrt2, invec, sens, vec);
617  }
618 
619 
620  template<typename... Args>
621  inline Eigen::MatrixXd const& Jacobian(unsigned int outWrt, unsigned int inWrt, ref_vector<Eigen::VectorXd>& vec, Eigen::VectorXd const& ith, Args const&... args) { \
622  vec.push_back(std::cref(ith)); \
623  return Jacobian(outWrt, inWrt, vec, args...); \
624  }
625  inline Eigen::MatrixXd const& Jacobian(unsigned int outWrt, unsigned int inWrt, ref_vector<Eigen::VectorXd>& vec, Eigen::VectorXd const& last) {
626  vec.push_back(std::cref(last));
627  return Jacobian(outWrt, inWrt, vec);
628  }
629 
630  template<typename NextType, typename... Args> \
631  inline Eigen::VectorXd const& ApplyJacobianRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector<Eigen::VectorXd>& vec, NextType const& ith, Args const&... args) { \
632  static_assert(std::is_same<Eigen::VectorXd, NextType>::value, "In ModPiece::Gradient, cannot cast input to Eigen::VectorXd."); \
633  vec.push_back(std::cref((NextType&)ith)); \
634  return ApplyJacobianRecurse(outWrt, inWrt, vec, args...); \
635  }
636 
637  template<typename NextType> \
638  inline Eigen::VectorXd const& ApplyJacobianRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector<Eigen::VectorXd>& vec, NextType const& last, Eigen::VectorXd const& sens) { \
639  static_assert(std::is_same<Eigen::VectorXd, NextType>::value, "In ModPiece::Gradient, cannot cast input to Eigen::VectorXd."); \
640  vec.push_back(std::cref((NextType&)last)); \
641  return ApplyJacobian(outWrt, inWrt, vec, sens); \
642  }
643 
644  template<typename... Args> \
645  inline Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector<Eigen::VectorXd>& vec, Eigen::VectorXd const& ith, Args const&... args) { \
646  vec.push_back(std::cref(ith)); \
647  return JacobianByFD(outWrt, inWrt, vec, args...); \
648  }
649  inline Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector<Eigen::VectorXd>& vec, Eigen::VectorXd const& last) {
650  vec.push_back(std::cref(last));
651  return JacobianByFD(outWrt, inWrt, vec);
652  }
653 
654  template<typename NextType, typename... Args>
655  inline Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector<Eigen::VectorXd>& vec, NextType const& ith, Args const&... args) {
656  vec.push_back(std::cref(ith));
657  return ApplyJacobianByFD(outWrt, inWrt, vec, args...);
658  }
659  template<typename NextType>
660  inline Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector<Eigen::VectorXd>& vec, NextType const& last, Eigen::VectorXd const& sens) {
661  vec.push_back(std::cref(last));
662  return ApplyJacobianByFD(outWrt, inWrt, vec, sens);
663  }
664 
665  };
666 
667  }
668 }
669 
670 
671 
672 #endif // #ifndef MODPIECE_H
Provides an abstract interface for defining vector-valued model components.
Definition: ModPiece.h:148
Eigen::MatrixXd jacobian
Definition: ModPiece.h:506
virtual void GradientImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
Definition: ModPiece.cpp:237
virtual void ApplyJacobianImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec)
Definition: ModPiece.cpp:262
Eigen::VectorXd const & ApplyJacobian(unsigned int wrtOut, unsigned int wrtIn, Args const &... args)
Definition: ModPiece.h:345
Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &ith, Args const &... args)
Definition: ModPiece.h:655
virtual Eigen::VectorXd GradientByFD(unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
Definition: ModPiece.cpp:111
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 .
Definition: ModPiece.cpp:83
bool CacheStatus() const
Definition: ModPiece.h:461
unsigned long int numJacActFDCalls
Definition: ModPiece.h:493
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)
Definition: ModPiece.cpp:448
const Eigen::VectorXi inputSizes
Definition: ModPiece.h:469
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.
Definition: ModPiece.cpp:128
Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, Args const &... args)
Definition: ModPiece.h:303
std::vector< Eigen::VectorXd > outputs
Definition: ModPiece.h:503
ModPiece(std::vector< int > const &inputSizes, std::vector< int > const &outputSizes)
Definition: ModPiece.cpp:9
Eigen::VectorXd const & ApplyJacobian(unsigned int outWrt, unsigned int inWrt, Eigen::VectorXd const &last, Eigen::VectorXd const &sens)
Definition: ModPiece.h:339
virtual void EvaluateImpl(ref_vector< boost::any > const &inputs) override
User-implemented function that determines the behavior of this muq::Modeling::WorkPiece.
Definition: ModPiece.cpp:179
Eigen::VectorXd const & GradientRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &last, Eigen::VectorXd const &sens)
Definition: ModPiece.h:579
Eigen::VectorXd gradient
Definition: ModPiece.h:504
Eigen::MatrixXd ApplyJacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &last, Eigen::VectorXd const &sens)
Definition: ModPiece.h:660
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)
Definition: ModPiece.h:621
Eigen::VectorXd const & ApplyHessianRecurse(unsigned int outWrt, unsigned int inWrt1, unsigned int inWrt2, ref_vector< Eigen::VectorXd > &invec, NextType const &ith, Args const &... args)
Definition: ModPiece.h:590
virtual double GetRunTime(const std::string &method="Evaluate") const override
Get the average run time for one of the implemented methods.
Definition: ModPiece.cpp:497
Eigen::VectorXd const & Gradient(unsigned int wrtOut, unsigned int wrtIn, Args const &... args)
Definition: ModPiece.h:237
unsigned long int numJacActCalls
Definition: ModPiece.h:489
unsigned long int numHessActFDCalls
Definition: ModPiece.h:494
virtual void JacobianImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input)
Definition: ModPiece.cpp:245
unsigned long int numJacCalls
Definition: ModPiece.h:488
virtual void SetWarnLevel(unsigned int newLevel)
Definition: ModPiece.h:469
Eigen::VectorXd const & Gradient(unsigned int outWrt, unsigned int inWrt, Eigen::VectorXd const &last, Eigen::VectorXd const &sens)
Definition: ModPiece.h:227
Eigen::VectorXd const & GradientRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &ith, Args const &... args)
Definition: ModPiece.h:563
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.
Definition: ModPiece.cpp:153
unsigned int fdWarnLevel
Definition: ModPiece.h:516
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)
Definition: ModPiece.h:245
unsigned long int numGradFDCalls
Definition: ModPiece.h:491
const Eigen::VectorXi outputSizes
Definition: ModPiece.h:472
Eigen::VectorXd const & ApplyHessian(unsigned int wrtOut, unsigned int wrtIn1, unsigned int wrtIn2, Args const &... args)
Definition: ModPiece.h:257
Eigen::MatrixXd const & Jacobian(unsigned int outWrt, unsigned int inWrt, Args const &... args)
Definition: ModPiece.h:291
void CheckInputs(ref_vector< Eigen::VectorXd > const &input, std::string const &funcName)
Definition: ModPiece.cpp:211
virtual ~ModPiece()=default
Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, Args const &... args)
Definition: ModPiece.h:297
bool ExistsInCache(ref_vector< Eigen::VectorXd > const &input) const
Definition: ModPiece.cpp:27
Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &ith, Args const &... args)
Definition: ModPiece.h:645
unsigned long int numJacFDCalls
Definition: ModPiece.h:492
Eigen::VectorXd const & ApplyJacobianRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &ith, Args const &... args)
Definition: ModPiece.h:631
std::vector< Eigen::VectorXd > ToStdVec(ref_vector< Eigen::VectorXd > const &input)
Definition: ModPiece.cpp:586
std::vector< Eigen::VectorXd > cacheInput
Definition: ModPiece.h:480
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.
Definition: ModPiece.cpp:535
virtual void ResetCallTime() override
Resets the number of call and times.
Definition: ModPiece.cpp:520
unsigned long int numGradCalls
Definition: ModPiece.h:487
Eigen::VectorXd hessAction
Definition: ModPiece.h:507
Eigen::VectorXd const & ApplyJacobianRecurse(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, NextType const &last, Eigen::VectorXd const &sens)
Definition: ModPiece.h:638
Eigen::VectorXd jacobianAction
Definition: ModPiece.h:505
Eigen::MatrixXd const & Jacobian(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &last)
Definition: ModPiece.h:625
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)
Definition: ModPiece.cpp:436
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)
Definition: ModPiece.h:607
unsigned long int numHessActCalls
Definition: ModPiece.h:490
Eigen::MatrixXd JacobianByFD(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &last)
Definition: ModPiece.h:649
Base class for MUQ's modelling envronment.
Definition: WorkPiece.h:40
std::vector< boost::any > const & Evaluate()
Evaluate this muq::Modeling::WorkPiece in the case that there are no inputs.
Definition: WorkPiece.cpp:222
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37
int int FloatType value
Definition: json.h:15223
const char * last
Definition: json.h:15399