1 #ifndef SMOLYAKESTIMATOR_H
2 #define SMOLYAKESTIMATOR_H
10 #include <boost/property_tree/ptree.hpp>
13 namespace Approximation {
15 template<
typename EstimateType>
26 virtual EstimateType
Compute(std::shared_ptr<muq::Utilities::MultiIndexSet>
const& fixedSet,
27 boost::property_tree::ptree options = boost::property_tree::ptree());
33 virtual EstimateType
Adapt(boost::property_tree::ptree options);
58 virtual std::vector<std::vector<Eigen::VectorXd>>
PointHistory()
const;
61 virtual std::vector<std::vector<std::shared_ptr<muq::Utilities::MultiIndex>>>
TermHistory()
const{
return termHistory;};
67 virtual void AddTerms(std::shared_ptr<muq::Utilities::MultiIndexSet>
const& fixedSet);
69 virtual void AddTerms(std::vector<std::shared_ptr<muq::Utilities::MultiIndex>>
const& fixedSet);
83 virtual void EvaluatePoints(std::set<unsigned int>
const& ptsToEval);
95 virtual std::vector<Eigen::VectorXd>
OneTermPoints(std::shared_ptr<muq::Utilities::MultiIndex>
const& multi) = 0;
104 virtual EstimateType
ComputeOneTerm(std::shared_ptr<muq::Utilities::MultiIndex>
const& multi,
105 std::vector<std::reference_wrapper<const Eigen::VectorXd>>
const& modEvals) = 0;
112 virtual EstimateType
AddEstimates(
double w1, EstimateType
const& part1,
double w2, EstimateType
const& part2)
const = 0;
117 std::shared_ptr<muq::Modeling::ModPiece>
model;
135 std::vector<std::vector<std::shared_ptr<muq::Utilities::MultiIndex>>>
termHistory;
141 int InCache(Eigen::VectorXd
const& input)
const;
146 const double cacheTol = 10.0*std::numeric_limits<double>::epsilon();
149 double timeTol = std::numeric_limits<double>::infinity();
155 unsigned int maxNumEvals = std::numeric_limits<unsigned int>::max();
197 const double nzTol = 10.0*std::numeric_limits<double>::epsilon();
std::vector< double > timeHistory
Holds the history of how. Each component corresponds to an adaptation iteration.
virtual void AddTerms(std::vector< std::shared_ptr< muq::Utilities::MultiIndex >> const &fixedSet)
virtual double Error() const
unsigned int numEvals
The number of model evaluations that have been performed.
virtual std::vector< std::vector< Eigen::VectorXd > > PointHistory() const
int AddToCache(Eigen::VectorXd const &newPt)
SmolyakEstimator(std::shared_ptr< muq::Modeling::ModPiece > const &modelIn)
virtual std::vector< int > EvalHistory() const
virtual unsigned int NumEvals() const
std::vector< int > evalHistory
Holds the history of how many model evaluations have occured. Each component corresponds to an adapta...
virtual EstimateType AddEstimates(double w1, EstimateType const &part1, double w2, EstimateType const &part2) const =0
virtual void EvaluatePoints(std::set< unsigned int > const &ptsToEval)
unsigned int maxNumEvals
Tolerance on the maximum number of evaluations.
virtual ~SmolyakEstimator()=default
std::vector< double > errorHistory
Holds the history of the error. Each component corresponds to an iteration.
std::shared_ptr< muq::Utilities::MultiIndexSet > termMultis
Multiindices defining each tensor product term in the Smolyak approximation.
virtual void UpdateErrors()
virtual EstimateType ComputeOneTerm(std::shared_ptr< muq::Utilities::MultiIndex > const &multi, std::vector< std::reference_wrapper< const Eigen::VectorXd >> const &modEvals)=0
double errorTol
Tolerance on the global error indicator to continue adapting.
std::vector< std::set< unsigned int > > pointHistory
Indices in the cache for the points that were evaluated during each adaptation iteration.
std::shared_ptr< muq::Modeling::ModPiece > model
The model used to construct the approximations.
double timeTol
Tolerance on the time (in seconds) allowed to continue adapting.
virtual std::vector< Eigen::VectorXd > OneTermPoints(std::shared_ptr< muq::Utilities::MultiIndex > const &multi)=0
virtual EstimateType Compute(std::shared_ptr< muq::Utilities::MultiIndexSet > const &fixedSet, boost::property_tree::ptree options=boost::property_tree::ptree())
virtual void AddTerms(std::shared_ptr< muq::Utilities::MultiIndexSet > const &fixedSet)
virtual EstimateType ComputeWeightedSum() const
int InCache(Eigen::VectorXd const &input) const
virtual std::vector< double > ErrorHistory() const
virtual std::vector< double > TimeHistory() const
Eigen::VectorXd const & GetFromCache(unsigned int index) const
virtual std::vector< std::vector< std::shared_ptr< muq::Utilities::MultiIndex > > > TermHistory() const
virtual double ComputeMagnitude(EstimateType const &estimate) const =0
std::vector< SmolyTerm > terms
std::vector< std::vector< std::shared_ptr< muq::Utilities::MultiIndex > > > termHistory
The terms that are added during each refinement.
std::vector< Eigen::VectorXd > evalCache
virtual EstimateType Adapt(boost::property_tree::ptree options)
muq::Modeling::DynamicKDTreeAdaptor pointCache
A cache of model evaluations.
Eigen::VectorXd diffWeights
std::vector< unsigned int > evalInds
std::deque< Eigen::VectorXd > m_data
The kd-tree index for the user to call its methods as usual with any other FLANN index.