Line data Source code
1 : #pragma once 2 : 3 : #include "Functional.h" 4 : 5 : namespace elsa 6 : { 7 : /** 8 : * @brief Class representing a constraint associated to an optimization problem. 9 : * 10 : * @author Andi Braimllari - initial code 11 : * 12 : * @tparam data_t data type for the domain of the residual of the functional, defaulting to 13 : * real_t 14 : * 15 : * Constraint is expressed in the form 16 : * - @f$ Ax + Bz = c @f$. 17 : * 18 : * All three components must be present during construction. One can interchangeably utilize a 19 : * LinearResidual if either of the LinearOperators A or B is the zero matrix. 20 : */ 21 : template <typename data_t = real_t> 22 : class Constraint : public Cloneable<Constraint<data_t>> 23 : { 24 : public: 25 : /** 26 : * @brief Constructor for the constraint, accepting the two LinearOperators and 27 : * DataContainer 28 : * 29 : * @param[in] A LinearOperator 30 : * @param[in] B LinearOperator 31 : * @param[in] c DataContainer 32 : */ 33 : Constraint(const LinearOperator<data_t>& A, const LinearOperator<data_t>& B, 34 : const DataContainer<data_t>& c); 35 : 36 : /// make copy constructor deletion explicit 37 : Constraint(const Constraint<data_t>&) = delete; 38 : 39 : /// default destructor 40 12 : ~Constraint() = default; 41 : 42 : /// return the operator A 43 : auto getOperatorA() const -> const LinearOperator<data_t>&; 44 : 45 : /// return the operator B 46 : auto getOperatorB() const -> const LinearOperator<data_t>&; 47 : 48 : /// return the data vector c 49 : auto getDataVectorC() const -> const DataContainer<data_t>&; 50 : 51 : protected: 52 : /// implement the clone operation 53 : auto cloneImpl() const -> Constraint<data_t>* override; 54 : 55 : /// overridden comparison method based on the LinearOperators and the DataContainer 56 : auto isEqual(const Constraint<data_t>& other) const -> bool override; 57 : 58 : private: 59 : /// @f$ A @f$ from the problem definition 60 : std::unique_ptr<LinearOperator<data_t>> _A; 61 : 62 : /// @f$ B @f$ from the problem definition 63 : std::unique_ptr<LinearOperator<data_t>> _B; 64 : 65 : /// @f$ c @f$ from the problem definition 66 : DataContainer<data_t> _c; 67 : }; 68 : } // namespace elsa