Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
amp_criteria.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//amp_criteria.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//amp_criteria.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with amp_criteria.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22#ifndef BERTINI_AMP_CRITERIA_HPP
23#define BERTINI_AMP_CRITERIA_HPP
24
31
33
34namespace bertini{
35 namespace tracking{
36 namespace amp{
37
38
39
45 inline
46 double CriterionARHS(double const& norm_J, double const& norm_J_inverse, AdaptiveMultiplePrecisionConfig const& AMP_config)
47 {
48 return AMP_config.safety_digits_1 + log10(norm_J_inverse * AMP_config.linear_solve_error_bound * (norm_J + AMP_config.jacobian_eval_error_bound ));
49 }
50
66 template<typename NumT>
67 bool CriterionA(double const& norm_J, double const& norm_J_inverse, AdaptiveMultiplePrecisionConfig const& AMP_config)
68 {
69 return NumTraits<NumT>::NumDigits() > CriterionARHS(norm_J, norm_J_inverse, AMP_config);
70 }
71
72
73
83 inline
84 double D(double const& norm_J, double const& norm_J_inverse, AdaptiveMultiplePrecisionConfig const& AMP_config)
85 {
86 return log10(norm_J_inverse*( (2+AMP_config.linear_solve_error_bound)*norm_J+AMP_config.linear_solve_error_bound*AMP_config.jacobian_eval_error_bound)+1);
87 }
88
103 inline
104 double CriterionBRHS(double const& norm_J, double const& norm_J_inverse, unsigned num_newton_iterations_remaining, NumErrorT const& tracking_tolerance, double const& norm_of_latest_newton_residual, AdaptiveMultiplePrecisionConfig const& AMP_config)
105 {
106 return AMP_config.safety_digits_1 + D(norm_J, norm_J_inverse, AMP_config) + (-log10(tracking_tolerance) + log10(norm_of_latest_newton_residual)) / (num_newton_iterations_remaining);
107 }
108
109
127 template<typename NumT>
128 bool CriterionB(double const& norm_J,
129 double const& norm_J_inverse,
130 unsigned num_newton_iterations_remaining,
131 NumErrorT const& tracking_tolerance,
132 double const& norm_of_latest_newton_residual,
133 AdaptiveMultiplePrecisionConfig const& AMP_config)
134 {
135 return NumTraits<NumT>::NumDigits() > CriterionBRHS(norm_J, norm_J_inverse, num_newton_iterations_remaining, tracking_tolerance, norm_of_latest_newton_residual, AMP_config);
136 }
137
138
139
140
141
154 inline
155 double CriterionCRHS(double const& norm_J_inverse,
156 double const& norm_z,
157 NumErrorT const& tracking_tolerance,
158 AdaptiveMultiplePrecisionConfig const& AMP_config)
159 {
160 return AMP_config.safety_digits_2 + -log10(tracking_tolerance) + log10(norm_J_inverse*AMP_config.function_eval_error_bound + norm_z);
161 }
162
163
164
177 template<typename Derived>
178 double CriterionCRHS(double const& norm_J_inverse,
179 const Eigen::MatrixBase<Derived>& z,
180 NumErrorT tracking_tolerance,
181 AdaptiveMultiplePrecisionConfig const& AMP_config)
182 {
183 return CriterionCRHS(norm_J_inverse, double(z.norm()), tracking_tolerance, AMP_config);
184 }
185
186
201 template<typename NumT, typename Derived>
202 bool CriterionC(double const& norm_J_inverse, const Eigen::MatrixBase<Derived>& z, NumErrorT tracking_tolerance, AdaptiveMultiplePrecisionConfig const& AMP_config)
203 {
204 return NumTraits<NumT>::NumDigits() > CriterionCRHS(norm_J_inverse, z, tracking_tolerance, AMP_config);
205 }
206 }
207 }
208
209}
210
211
212#endif
Definition amp_criteria.hpp:36
bool CriterionB(double const &norm_J, double const &norm_J_inverse, unsigned num_newton_iterations_remaining, NumErrorT const &tracking_tolerance, double const &norm_of_latest_newton_residual, AdaptiveMultiplePrecisionConfig const &AMP_config)
Check AMP Criterion B.
Definition amp_criteria.hpp:128
double D(double const &norm_J, double const &norm_J_inverse, AdaptiveMultiplePrecisionConfig const &AMP_config)
Compute the expression from the AMP papers amp1, amp2, amp3.
Definition amp_criteria.hpp:84
double CriterionCRHS(double const &norm_J_inverse, double const &norm_z, NumErrorT const &tracking_tolerance, AdaptiveMultiplePrecisionConfig const &AMP_config)
Evaluate the right hand side of Criterion C.
Definition amp_criteria.hpp:155
double CriterionBRHS(double const &norm_J, double const &norm_J_inverse, unsigned num_newton_iterations_remaining, NumErrorT const &tracking_tolerance, double const &norm_of_latest_newton_residual, AdaptiveMultiplePrecisionConfig const &AMP_config)
Evaluate the right hand side of the inequality of Criterion B.
Definition amp_criteria.hpp:104
double CriterionARHS(double const &norm_J, double const &norm_J_inverse, AdaptiveMultiplePrecisionConfig const &AMP_config)
The right hand side of Criterion A, from amp1, amp2.
Definition amp_criteria.hpp:46
bool CriterionA(double const &norm_J, double const &norm_J_inverse, AdaptiveMultiplePrecisionConfig const &AMP_config)
Check AMP Criterion A.
Definition amp_criteria.hpp:67
bool CriterionC(double const &norm_J_inverse, const Eigen::MatrixBase< Derived > &z, NumErrorT tracking_tolerance, AdaptiveMultiplePrecisionConfig const &AMP_config)
Check AMP Criterion C.
Definition amp_criteria.hpp:202
Definition adaptive_precision_utilities.hpp:35
Definition algorithm_builder.hpp:36
double NumErrorT
The numeric type used to hold error/tolerance magnitudes throughout Bertini2 – tracking tolerances,...
Definition num_traits.hpp:48
Numeric traits for a bertini number type: digit counts, conversions, and companion types.
Definition num_traits.hpp:57
Holds the program parameters with respect to Adaptive Multiple Precision.
Definition config.hpp:214
NumErrorT function_eval_error_bound
Bound on the error of evaluating the functions, divided by the unit roundoff error.
Definition config.hpp:240
int safety_digits_2
User-chosen setting for the number of safety digits used during Criterion C.
Definition config.hpp:243
int safety_digits_1
User-chosen setting for the number of safety digits used during Criteria A & B.
Definition config.hpp:242
NumErrorT jacobian_eval_error_bound
Bound on the error of evaluating the Jacobian, divided by the unit roundoff error .
Definition config.hpp:233
NumErrorT linear_solve_error_bound
Bound on the growth in error from a linear solve.
Definition config.hpp:222
Configs and settings for tracking.