Coverage Report

Created: 2024-12-20 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/builds/MusicScience37Projects/numerical-analysis/numerical-collection-cpp/include/num_collect/opt/optimizer_base.h
Line
Count
Source
1
/*
2
 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
/*!
17
 * \file
18
 * \brief Definition of optimizer_base class.
19
 */
20
#pragma once
21
22
#include "num_collect/base/index_type.h"
23
#include "num_collect/base/iterative_solver_base.h"
24
#include "num_collect/logging/log_tag_view.h"
25
26
namespace num_collect::opt {
27
28
/*!
29
 * \brief Base class of implementations of optimization algorithms.
30
 *
31
 * \tparam Derived Type of derived class.
32
 */
33
template <typename Derived>
34
class optimizer_base
35
    : public num_collect::base::iterative_solver_base<Derived> {
36
protected:
37
    using num_collect::base::iterative_solver_base<Derived>::derived;
38
39
public:
40
    /*!
41
     * \brief Constructor.
42
     *
43
     * \param[in] tag Log tag.
44
     */
45
    explicit optimizer_base(logging::log_tag_view tag)
46
125
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_23function_object_wrapperIFddEZNS_3rbf16rbf_interpolatorIS4_NS5_4rbfs12gaussian_rbfIdEELNS5_18kernel_matrix_typeE0ENS5_18distance_functions27euclidean_distance_functionIdEENS5_28length_parameter_calculators34global_length_parameter_calculatorISD_EEE31optimize_length_parameter_scaleERKNSt3__16vectorIdNSI_9allocatorIdEEEERKN5Eigen6MatrixIdLin1ELi1ELi0ELin1ELi1EEElQL_ZNS6_IFT0_T_ET1_XT2_ET3_T4_E28uses_global_length_parameterEEEUldE_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
30
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_23function_object_wrapperIFddEZNS_3rbf16rbf_interpolatorIS4_NS5_4rbfs25inverse_multi_quadric_rbfIdEELNS5_18kernel_matrix_typeE0ENS5_18distance_functions27euclidean_distance_functionIdEENS5_28length_parameter_calculators34global_length_parameter_calculatorISD_EEE31optimize_length_parameter_scaleERKNSt3__16vectorIdNSI_9allocatorIdEEEERKN5Eigen6MatrixIdLin1ELi1ELi0ELin1ELi1EEElQL_ZNS6_IFT0_T_ET1_XT2_ET3_T4_E28uses_global_length_parameterEEEUldE_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_23function_object_wrapperIFddEZNS_3rbf16rbf_interpolatorIS4_NS5_4rbfs21inverse_quadratic_rbfIdEELNS5_18kernel_matrix_typeE0ENS5_18distance_functions27euclidean_distance_functionIdEENS5_28length_parameter_calculators34global_length_parameter_calculatorISD_EEE31optimize_length_parameter_scaleERKNSt3__16vectorIdNSI_9allocatorIdEEEERKN5Eigen6MatrixIdLin1ELi1ELi0ELin1ELi1EEElQL_ZNS6_IFT0_T_ET1_XT2_ET3_T4_E28uses_global_length_parameterEEEUldE_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_23function_object_wrapperIFddEZNS_3rbf16rbf_interpolatorIS4_NS5_4rbfs8sech_rbfIdEELNS5_18kernel_matrix_typeE0ENS5_18distance_functions27euclidean_distance_functionIdEENS5_28length_parameter_calculators34global_length_parameter_calculatorISD_EEE31optimize_length_parameter_scaleERKNSt3__16vectorIdNSI_9allocatorIdEEEERKN5Eigen6MatrixIdLin1ELi1ELi0ELin1ELi1EEElQL_ZNS6_IFT0_T_ET1_XT2_ET3_T4_E28uses_global_length_parameterEEEUldE_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_24adaptive_diagonal_curvesIN16num_prob_collect3opt24multi_quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
4
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_26annealing_downhill_simplexIN16num_prob_collect3opt24multi_quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_14bfgs_optimizerIN16num_prob_collect3opt24multi_quadratic_functionENS0_26backtracking_line_searcherIS5_EEN5Eigen3LLTINS8_6MatrixIdLin1ELin1ELi0ELin1ELin1EEELi1EEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_28conjugate_gradient_optimizerIN16num_prob_collect3opt24multi_quadratic_functionENS0_26backtracking_line_searcherIS5_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_13dfp_optimizerIN16num_prob_collect3opt24multi_quadratic_functionENS0_26backtracking_line_searcherIS5_EEN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesIN16num_prob_collect3opt24multi_quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
5
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesIN16num_prob_collect3opt27vibrated_quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_16downhill_simplexIN16num_prob_collect3opt24multi_quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
5
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
function_object_wrapper_test.cpp:_ZN11num_collect3opt14optimizer_baseINS0_21golden_section_searchINS0_23function_object_wrapperIFddEZL22CATCH2_INTERNAL_TEST_0vE3$_0EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
function_object_wrapper_test.cpp:_ZN11num_collect3opt14optimizer_baseINS0_16downhill_simplexINS0_23function_object_wrapperIFdN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEEEZL22CATCH2_INTERNAL_TEST_0vE3$_1EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_26gaussian_process_optimizerIN16num_prob_collect3opt27vibrated_quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_22any_objective_functionIFddEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
4
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_26gaussian_process_optimizerIN16num_prob_collect3opt24multi_quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_22any_objective_functionIFdN5Eigen6MatrixIdLin1ELi1ELi0ELin1ELi1EEEEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_23function_object_wrapperIFddEZNS_3rbf16rbf_interpolatorIFdN5Eigen6MatrixIdLin1ELi1ELi0ELin1ELi1EEEENS5_4rbfs12gaussian_rbfIdEELNS5_18kernel_matrix_typeE0ENS5_18distance_functions27euclidean_distance_functionIS9_EENS5_28length_parameter_calculators34global_length_parameter_calculatorISH_EEE31optimize_length_parameter_scaleERKNSt3__16vectorIS9_NSM_9allocatorIS9_EEEERKS9_lQL_ZNS6_IFT0_T_ET1_XT2_ET3_T4_E28uses_global_length_parameterEEEUldE_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
19
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_21golden_section_searchIN16num_prob_collect3opt18quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
5
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_26heuristic_global_optimizerIN16num_prob_collect3opt18quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_18sampling_optimizerIN16num_prob_collect3opt18quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
5
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_26heuristic_global_optimizerIN16num_prob_collect3opt24multi_quadratic_functionEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
2
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_16newton_optimizerIN16num_prob_collect3opt24multi_quadratic_functionENS0_26backtracking_line_searcherIS5_EEN5Eigen3LLTINS8_6MatrixIdLin1ELin1ELi0ELin1ELin1EEELi1EEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
3
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_16steepest_descentIN16num_prob_collect3opt24multi_quadratic_functionENS0_26backtracking_line_searcherIS5_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
4
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_23function_object_wrapperIFddEZNS_3rbf27rbf_polynomial_interpolatorIS4_NS5_4rbfs12gaussian_rbfIdEELl1ELNS5_18kernel_matrix_typeE0ENS5_18distance_functions27euclidean_distance_functionIdEENS5_28length_parameter_calculators34global_length_parameter_calculatorISD_EEE31optimize_length_parameter_scaleERKNSt3__16vectorIdNSI_9allocatorIdEEEERKN5Eigen6MatrixIdLin1ELi1ELi0ELin1ELi1EEElQL_ZNS6_IFT0_T_ET1_XT2_EXT3_ET4_T5_E28uses_global_length_parameterEEEUldE_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_19dividing_rectanglesINS0_23function_object_wrapperIFddEZNS_3rbf27rbf_polynomial_interpolatorIFdN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEEENS5_4rbfs12gaussian_rbfIdEELl1ELNS5_18kernel_matrix_typeE0ENS5_18distance_functions27euclidean_distance_functionIS9_EENS5_28length_parameter_calculators34global_length_parameter_calculatorISH_EEE31optimize_length_parameter_scaleERKNSt3__16vectorIS9_NSM_9allocatorIS9_EEEERKNS8_IdLin1ELi1ELi0ELin1ELi1EEElQL_ZNS6_IFT0_T_ET1_XT2_EXT3_ET4_T5_E28uses_global_length_parameterEEEUldE_EEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_26heuristic_global_optimizerINS0_23function_object_wrapperIFddENS_14regularization31explicit_gcv_objective_functionINS5_8tikhonovIN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEENS9_IdLin1ELi1ELi0ELin1ELi1EEEEEEEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_18sampling_optimizerINS0_23function_object_wrapperIFddENS_14regularization31explicit_gcv_objective_functionINS5_8tikhonovIN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEENS9_IdLin1ELi1ELi0ELin1ELi1EEEEEEEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_21golden_section_searchINS0_23function_object_wrapperIFddENS_14regularization31explicit_gcv_objective_functionINS5_8tikhonovIN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEENS9_IdLin1ELi1ELi0ELin1ELi1EEEEEEEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_26heuristic_global_optimizerINS0_23function_object_wrapperIFddENS_14regularization35explicit_l_curve_objective_functionINS5_8tikhonovIN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEENS9_IdLin1ELi1ELi0ELin1ELi1EEEEEEEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_18sampling_optimizerINS0_23function_object_wrapperIFddENS_14regularization35explicit_l_curve_objective_functionINS5_8tikhonovIN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEENS9_IdLin1ELi1ELi0ELin1ELi1EEEEEEEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_21golden_section_searchINS0_23function_object_wrapperIFddENS_14regularization35explicit_l_curve_objective_functionINS5_8tikhonovIN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEENS9_IdLin1ELi1ELi0ELin1ELi1EEEEEEEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
_ZN11num_collect3opt14optimizer_baseINS0_26gaussian_process_optimizerINS0_22any_objective_functionIFddEEEEEEC2ENS_7logging12log_tag_viewE
Line
Count
Source
46
1
        : num_collect::base::iterative_solver_base<Derived>(tag) {}
47
48
    /*!
49
     * \brief Get current optimal variable.
50
     *
51
     * \return Current optimal variable.
52
     */
53
    [[nodiscard]] auto opt_variable() const { return derived().opt_variable(); }
54
55
    /*!
56
     * \brief Get current optimal value.
57
     *
58
     * \return Current optimal value.
59
     */
60
    [[nodiscard]] auto opt_value() const { return derived().opt_value(); }
61
62
    /*!
63
     * \brief Get the number of iterations.
64
     *
65
     * \return Number of iterations.
66
     */
67
    [[nodiscard]] auto iterations() const noexcept -> index_type {
68
        return derived().iterations();
69
    }
70
71
    /*!
72
     * \brief Get the number of function evaluations.
73
     *
74
     * \return Number of function evaluations.
75
     */
76
    [[nodiscard]] auto evaluations() const noexcept -> index_type {
77
        return derived().evaluations();
78
    }
79
};
80
81
}  // namespace num_collect::opt