173template <
typename Coeff,
typename DerivativeMatrix,
180 tgv2_admm<Coeff, DerivativeMatrix, Data>, Data> {
221 const DerivativeMatrix& first_derivative_matrix,
222 const DerivativeMatrix& second_derivative_matrix,
const Data& data) {
235 "Coefficient matrix is not set.");
237 this->
logger(),
"First order derivative matrix is not set.");
239 this->
logger(),
"Second order derivative matrix is not set.");
241 data_ !=
nullptr, this->
logger(),
"Data vector is not set.");
245 "Coefficient matrix and data vector must have the same number of "
249 "The number of columns in the coefficient matrix must match the "
250 "number of rows in solution vector.");
253 "Data and solution must have the same number of columns.");
256 "The number of columns in the first order derivative matrix must "
257 "match the number of rows in solution vector.");
261 "The number of columns in the second order derivative matrix must "
262 "match the number of rows in the first order derivative matrix.");
268 s_ = (*first_derivative_matrix_) * solution;
285 residual_ = (*coeff_) * solution - (*data_);
286 update_rate_ = std::numeric_limits<scalar_type>::infinity();
288 const scalar_type conjugate_gradient_tolerance_rate =
291 conjugate_gradient_tolerance_rate);
311 const data_type& solution)
const ->
bool {
321 iteration_logger.template append<index_type>(
323 iteration_logger.template append<scalar_type>(
325 iteration_logger.template append<scalar_type>(
332 return ((*
coeff_) * solution - (*
data_)).squaredNorm();
346 data = (*coeff_) * solution;
362 this->
logger(),
"approx_order_of_param={}", approx_order_of_param);
363 constexpr auto tol_update_coeff_multiplier =
365 return {approx_order_of_param *
416 "Maximum number of iterations must be a positive integer.");
438 "Tolerance of update rate of the solution must be a positive "
456 static_cast<scalar_type>(2) * (*coeff_).transpose() * (*data_);
458 (*first_derivative_matrix_).transpose() *
temp_z_;
465 temp_z_.noalias() = (*first_derivative_matrix_) * target;
467 (*first_derivative_matrix_).transpose() *
temp_z_;
471 (solution.norm() + std::numeric_limits<scalar_type>::epsilon());
472 residual_.noalias() = (*coeff_) * solution;
486 temp_z_.noalias() -= (*second_derivative_matrix_).transpose() *
u_;
496 temp_t_.noalias() = (*second_derivative_matrix_) * target;
498 (*second_derivative_matrix_).transpose() *
temp_t_;
502 (
z_.norm() + std::numeric_limits<scalar_type>::epsilon());
513 s_.noalias() = (*first_derivative_matrix_) * solution;
517 (
s_.norm() + std::numeric_limits<scalar_type>::epsilon());
530 t_.noalias() = (*second_derivative_matrix_) *
z_;
535 (
t_.norm() + std::numeric_limits<scalar_type>::epsilon());
552 (
p_.norm() + std::numeric_limits<scalar_type>::epsilon());
570 (
u_.norm() + std::numeric_limits<scalar_type>::epsilon());
Definition of apply_shrinkage_operator function.
Definition of max_eigen_aat function.
Class to perform conjugate gradient (CG) method golub2013 for linear operators.
Class to write logs of iterations.
Class of tags of logs without memory management.
void configure_child_algorithm_logger_if_exists(Child &child)
Configure a logger of a child algorithm if exists.
auto logger() const noexcept -> const num_collect::logging::logger &
Access to the logger.
iterative_regularized_solver_base(logging::log_tag_view tag)
typename Eigen::NumTraits< typename data_type::Scalar >::Real scalar_type
Type of scalars.
Data data_type
Type of data.
linear::impl::operator_conjugate_gradient< data_type > conjugate_gradient_solution_
Conjugate gradient solver for update of the solution.
void update_solution(const scalar_type ¶m, data_type &solution)
Update the solution.
scalar_type tol_update_rate_
Tolerance of update rate of the solution.
data_type previous_solution_
Previous solution.
void init(const scalar_type ¶m, data_type &solution)
Initialize.
void change_data(const data_type &data)
Change data.
index_type iterations_
Number of iterations.
auto is_stop_criteria_satisfied(const data_type &solution) const -> bool
Determine if stopping criteria of the algorithm are satisfied.
void update_p(const scalar_type ¶m, const data_type &solution)
Update p_.
static constexpr auto default_constraint_coeff
Default coefficient of the constraint for the derivative.
auto regularization_term(const data_type &solution) const -> scalar_type
Calculate the regularization term.
static constexpr auto default_second_derivative_ratio
Default ratio of regularization term for the 2nd order derivative.
auto param_search_region() const -> std::pair< scalar_type, scalar_type >
Get the default region to search for the optimal regularization parameter.
void update_z(const scalar_type ¶m, const data_type &solution)
Update z_.
data_type u_update_
Update of u_.
static constexpr index_type default_max_iterations
Default maximum number of iterations.
data_type p_
Lagrange multiplier for the 1st order derivative constraint.
data_type previous_t_
Previous value of t_.
data_type residual_
Residual vector.
void compute(const Coeff &coeff, const DerivativeMatrix &first_derivative_matrix, const DerivativeMatrix &second_derivative_matrix, const Data &data)
Compute internal parameters.
auto residual_norm_rate() const -> scalar_type
Get the rate of the last residual norm.
data_type previous_z_
Previous value of z_.
const derivative_matrix_type * second_derivative_matrix_
Matrix to compute the second order derivative.
auto update_rate() const noexcept -> scalar_type
Get the rate of the norm of the update of the solution in the last iteration.
scalar_type constraint_coeff_
Coefficient of the constraint for the derivative.
scalar_type rate_of_cg_tol_rate_to_tol_update_rate_
Rate of the ratio of the rate of tolerance in CG method to the tolerance of update rate of the soluti...
auto max_iterations(index_type value) -> this_type &
Set the maximum number of iterations.
void configure_iteration_logger(logging::iterations::iteration_logger< this_type > &iteration_logger) const
Configure an iteration logger.
void update_u(const scalar_type ¶m, const data_type &solution)
Update u_.
auto data_size() const -> index_type
Get the size of data.
data_type s_
Component of the 1st order derivative for regularization.
data_type temp_solution_
Temporary vector for the update of the solution.
auto residual_norm(const data_type &solution) const -> scalar_type
Calculate the squared norm of the residual.
void update_t(const scalar_type ¶m, const data_type &solution)
Update t_.
index_type max_iterations_
Maximum number of iterations.
auto tol_update_rate(scalar_type value) -> this_type &
Set the tolerance of update rate of the solution.
data_type temp_z_
Temporary vector for the update of the 1st order derivative.
Coeff coeff_type
Type of coefficient matrices.
data_type p_update_
Update of p_.
void update_s(const scalar_type ¶m, const data_type &solution)
Update s_.
static constexpr auto default_rate_of_cg_tol_rate_to_tol_update_rate
Default value of the ratio of the rate of tolerance in CG method to the tolerance of update rate of t...
const data_type * data_
Data vector.
data_type z_
Component of the 1st order derivative.
const derivative_matrix_type * first_derivative_matrix_
Matrix to compute the first order derivative.
data_type temp_data_
Temporary vector with the size of data.
data_type t_
2nd order derivative of the solution.
data_type previous_s_
Previous value of s_.
void calculate_data_for(const data_type &solution, data_type &data) const
Calculate data for a solution.
scalar_type update_rate_
Rate of norm of the update of the variables in the last iteration.
data_type temp_t_
Temporary vector for the update of the 2nd order derivative.
auto max_iterations() const -> index_type
Get the maximum number of iterations.
DerivativeMatrix derivative_matrix_type
Type of matrices to compute derivatives.
const coeff_type * coeff_
Coefficient matrix to compute data vector.
tgv2_admm< Coeff, DerivativeMatrix, Data > this_type
This type.
data_type u_
Lagrange multiplier for the 2nd order derivative constraint.
auto iterations() const noexcept -> index_type
Get the number of iterations.
auto tol_update_rate() const -> scalar_type
Get the tolerance of update rate of the solution.
scalar_type second_derivative_ratio_
Ratio of regularization term for the 2nd order derivative.
static constexpr auto default_tol_update_rate
Default tolerance of update rate of the solution.
void iterate(const scalar_type ¶m, data_type &solution)
Iterate the algorithm once.
linear::impl::operator_conjugate_gradient< data_type > conjugate_gradient_z_
Conjugate gradient solver for update of the 1st order derivative.
iterative_regularized_solver_base< this_type, Data > base_type
Type of the base class.
Concept of Eigen's dense matrices.
Concept of Eigen's dense vectors.
Concept of sparse matrices.
Definition of dense_matrix concept.
Definition of dense_vector concept.
Definition of index_type type.
Definition of iterative_regularized_solver_base class.
Definition of log_tag_view class.
Definition of macros for logging.
#define NUM_COLLECT_LOG_TRACE(LOGGER,...)
Write a trace log.
std::ptrdiff_t index_type
Type of indices in this library.
auto norm(const Matrix &matrix)
Calculate norm of a matrix.
constexpr auto weak_coeff_min_param
Coefficient (minimum parameter to be searched) / (maximum singular value or eigen value).
auto approximate_max_eigen_aat(const Matrix &matrix) -> typename Matrix::Scalar
Approximate the maximum eigenvalue of for a matrix .
void apply_shrinkage_operator(Vector &target, typename Vector::Scalar threshold)
Apply shrinkage operator to a vector.
constexpr auto weak_coeff_max_param
Coefficient (maximum parameter to be searched) / (maximum singular value or eigen value).
Namespace of regularization algorithms.
constexpr auto tgv2_admm_tag
Tag of tgv2_admm.
Definition of operator_conjugate_gradient class.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.
Definition of sparse_matrix concept.
Definition of coefficients for regularization parameters.