Commit c3777c6e authored by Philipp Trunschke's avatar Philipp Trunschke

add version of uq_ra_adf that takes initial values

parent 3596678d
Pipeline #1948 failed with stages
in 11 minutes and 57 seconds
......@@ -50,7 +50,17 @@ namespace xerus { namespace uq {
*/
TTTensor uq_ra_adf(const std::vector<std::vector<Tensor>>& _positions, const std::vector<Tensor>& _solutions, const std::vector<size_t>& _dimensions, const double _targetEps = 1e-8, const size_t _maxItr = 0);
/**
* @brief Rank adaptive ADF to calculate the UQ solution for given measurements.
* @param _x Initial value.
* @param _positions The positions of the measurements.
* @param _solutions The measured solutions corresponding to the @a _positions.
* @param _dimensions The dimensions of the final solution tensor.
* @param _targetEps TODO describe effect
* @param _maxItr Maximal number of iterations to perform.
*/
TTTensor uq_ra_adf(const TTTensor& _x, const std::vector<std::vector<Tensor>>& _positions, const std::vector<Tensor>& _solutions, const std::vector<size_t>& _dimensions, const double _targetEps = 1e-8, const size_t _maxItr = 0);
/**
* @brief Rank adaptive ADF to calculate the UQ solution for given weighted measurements.
* @param _positions The positions of the measurements.
......@@ -63,6 +73,5 @@ namespace xerus { namespace uq {
TTTensor uq_ra_adf(const std::vector<std::vector<Tensor>>& _positions, const std::vector<Tensor>& _solutions, const std::vector<double>& _weights, const std::vector<size_t>& _dimensions, const double _targetEps = 1e-8, const size_t _maxItr = 0);
// TODO How is this different to the inplace variant? Also very confusing that it changes _x inplace AND returns it.
TTTensor uq_ra_adf_iv(TTTensor& _x, const UQMeasurementSet& _measurements, const PolynomBasis _basisType, const double _targetEps = 1e-8, const size_t _maxItr = 0);
TTTensor uq_ra_adf(const TTTensor& _x, const UQMeasurementSet& _measurements, const PolynomBasis _basisType, const double _targetEps = 1e-8, const size_t _maxItr = 0);
}}
......@@ -673,6 +673,17 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
solver.solve();
return x;
}
TTTensor uq_ra_adf(const TTTensor& _x, const std::vector<std::vector<Tensor>>& _positions, const std::vector<Tensor>& _solutions, const std::vector<size_t>& _dimensions, const double _targetEps, const size_t _maxItr) {
REQUIRE(_positions.size() == _solutions.size(), "Invalid measurments");
REQUIRE(_dimensions.front() == _solutions.front().size, "Inconsitent spacial dimension");
TTTensor x(_x);
x.canonicalize_left();
impl_uqRaAdf::InternalSolver<2> solver(x, _positions, _solutions, _maxItr, _targetEps, 1e-1);
solver.solve();
return x;
}
TTTensor uq_ra_adf(const std::vector<std::vector<Tensor>>& _positions, const std::vector<Tensor>& _solutions, const std::vector<double>& _weights, const std::vector<size_t>& _dimensions, const double _targetEps, const size_t _maxItr) {
......@@ -699,7 +710,7 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
}
TTTensor uq_ra_adf(TTTensor& _x, const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const double _targetEps, const size_t _maxItr) {
TTTensor uq_ra_adf(const TTTensor& _x, const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const double _targetEps, const size_t _maxItr) {
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_x.dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
......@@ -712,9 +723,11 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
}
}
}
impl_uqRaAdf::InternalSolver<2> solver(_x, _measurments, _basisType, _maxItr, _targetEps, 1e-1);
TTTensor x(_x);
impl_uqRaAdf::InternalSolver<2> solver(x, _measurments, _basisType, _maxItr, _targetEps, 1e-1);
solver.solve();
return _x;
return x;
}
}} // namespace uq | xerus
......@@ -130,6 +130,11 @@ void expose_recoveryAlgorithms(module& m) {
}, arg("positions"), arg("solutions"), arg("dimensions"), arg("targeteps"), arg("maxitr")
);
m.def("uq_ra_adf", +[](const TTTensor& _x, const std::vector<std::vector<Tensor>>& _positions, const std::vector<Tensor>& _solutions, const std::vector<size_t>& _dimensions, const double _targetEps, const size_t _maxItr){
return uq::uq_ra_adf(_x, _positions, _solutions, _dimensions, _targetEps, _maxItr);
}, arg("x"), arg("positions"), arg("solutions"), arg("dimensions"), arg("targeteps"), arg("maxitr")
);
m.def("uq_ra_adf", +[](const std::vector<std::vector<Tensor>>& _positions, const std::vector<Tensor>& _solutions, const std::vector<double>& _weights, const std::vector<size_t>& _dimensions, const double _targetEps, const size_t _maxItr){
return uq::uq_ra_adf(_positions, _solutions, _weights, _dimensions, _targetEps, _maxItr);
}, arg("positions"), arg("solutions"), arg("weights"), arg("dimensions"), arg("targeteps"), arg("maxitr")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment