Line data Source code
1 : #pragma once 2 : 3 : #include "L1Norm.h" 4 : #include "WLSProblem.h" 5 : #include "LinearOperator.h" 6 : #include "DataContainer.h" 7 : 8 : namespace elsa 9 : { 10 : /** 11 : * @brief Class representing a Least Absolute Shrinkage and Selection Operator problem 12 : * 13 : * This class represents a LASSO problem i.e. 14 : * 15 : * - @f$ \argmin_x \frac{1}{2} \| Ax - b \|_{W,2}^2 + \lambda \| x \|_1 @f$ 16 : * 17 : * in which @f$ W @f$ is a weighting (scaling) operator, @f$ A @f$ is a linear operator, @f$ 18 : * b @f$ is a data vector and @f$ \lambda @f$ is the regularization parameter. 19 : * 20 : * References: 21 : * - Ryan J. Tibshirani _The Lasso Problem and Uniqueness_ (2013) 22 : * https://www.stat.cmu.edu/~ryantibs/papers/lassounique.pdf 23 : * - Tao, S., Boley, D., Zhang, S. _Local Linear Convergence of ISTA and FISTA on the LASSO 24 : * Problem_ (2015) https://arxiv.org/pdf/1501.02888.pdf 25 : * 26 : * @author Andi Braimllari - initial code 27 : * 28 : * @tparam data_t data type for the domain and range of the problem, defaulting to real_t 29 : */ 30 : template <typename data_t = real_t> 31 : class LASSOProblem : public Problem<data_t> 32 : { 33 : public: 34 : /** 35 : * @brief Constructor for the lasso problem, construction a WLSProblem 36 : * 37 : * @param[in] A a linear operator 38 : * @param[in] b a data vector 39 : * @param[in] regTerm RegularizationTerm 40 : */ 41 : LASSOProblem(const LinearOperator<data_t>& A, const DataContainer<data_t>& b, 42 : real_t lambda = 0.5f); 43 : 44 : /** 45 : * @brief Constructor for the lasso problem, accepting wlsProblem and regTerm 46 : * 47 : * @param[in] wlsProblem WLSProblem 48 : * @param[in] regTerm RegularizationTerm 49 : */ 50 : LASSOProblem(WLSProblem<data_t> wlsProblem, const RegularizationTerm<data_t>& regTerm); 51 : 52 : /** 53 : * @brief Constructor for converting a general optimization problem to a LASSO one 54 : * 55 : * @param[in] problem the problem to be converted 56 : * 57 : * Only problems that consist exclusively of a WLSProblem and a L1Norm regularization term 58 : * can be converted. 59 : * 60 : * Acts as a copy constructor if the supplied optimization problem is a LASSO problem. 61 : */ 62 : explicit LASSOProblem(const Problem<data_t>& problem); 63 : 64 : /// default destructor 65 30 : ~LASSOProblem() override = default; 66 : 67 : protected: 68 : /// implement the polymorphic clone operation 69 : auto cloneImpl() const -> LASSOProblem<data_t>* override; 70 : 71 : /// the getLipschitzConstant method for the optimization problem 72 : auto getLipschitzConstantImpl(index_t nIterations) const -> data_t override; 73 : 74 : private: 75 : WLSProblem<data_t> _wlsProblem; 76 : 77 : /// converts an optimization problem to a WLSProblem 78 : static auto wlsFromProblem(const Problem<data_t>& problem) -> WLSProblem<data_t>; 79 : 80 : /// converts an optimization problem to a RegularizationTerm 81 : static auto regTermFromProblem(const Problem<data_t>& problem) 82 : -> RegularizationTerm<data_t>; 83 : }; 84 : } // namespace elsa