Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
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) 2015 - 2021 by 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// individual authors of this file include:
23// silviana amethyst, university of wisconsin eau claire
24
25
26#ifndef BERTINI_AMP_CRITERIA_HPP
27#define BERTINI_AMP_CRITERIA_HPP
28
35
37
38namespace bertini{
39 namespace tracking{
40 namespace amp{
41
42
43
49 inline
50 double CriterionARHS(double const& norm_J, double const& norm_J_inverse, AdaptiveMultiplePrecisionConfig const& AMP_config)
51 {
52 return AMP_config.safety_digits_1 + log10(norm_J_inverse * AMP_config.epsilon * (norm_J + AMP_config.Phi ));
53 }
54
70 template<typename NumT>
71 bool CriterionA(double const& norm_J, double const& norm_J_inverse, AdaptiveMultiplePrecisionConfig const& AMP_config)
72 {
73 return NumTraits<NumT>::NumDigits() > CriterionARHS(norm_J, norm_J_inverse, AMP_config);
74 }
75
76
77
87 inline
88 double D(double const& norm_J, double const& norm_J_inverse, AdaptiveMultiplePrecisionConfig const& AMP_config)
89 {
90 return log10(norm_J_inverse*( (2+AMP_config.epsilon)*norm_J+AMP_config.epsilon*AMP_config.Phi)+1);
91 }
92
107 inline
108 double CriterionBRHS(double const& norm_J, double const& norm_J_inverse, unsigned num_newton_iterations_remaining, double const& tracking_tolerance, double const& norm_of_latest_newton_residual, AdaptiveMultiplePrecisionConfig const& AMP_config)
109 {
110 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);
111 }
112
113
131 template<typename NumT>
132 bool CriterionB(double const& norm_J,
133 double const& norm_J_inverse,
134 unsigned num_newton_iterations_remaining,
135 double const& tracking_tolerance,
136 double const& norm_of_latest_newton_residual,
137 AdaptiveMultiplePrecisionConfig const& AMP_config)
138 {
139 return NumTraits<NumT>::NumDigits() > CriterionBRHS(norm_J, norm_J_inverse, num_newton_iterations_remaining, tracking_tolerance, norm_of_latest_newton_residual, AMP_config);
140 }
141
142
143
144
145
158 inline
159 double CriterionCRHS(double const& norm_J_inverse,
160 double const& norm_z,
161 double const& tracking_tolerance,
162 AdaptiveMultiplePrecisionConfig const& AMP_config)
163 {
164 return AMP_config.safety_digits_2 + -log10(tracking_tolerance) + log10(norm_J_inverse*AMP_config.Psi + norm_z);
165 }
166
167
168
181 template<typename Derived>
182 double CriterionCRHS(double const& norm_J_inverse,
183 const Eigen::MatrixBase<Derived>& z,
184 double tracking_tolerance,
185 AdaptiveMultiplePrecisionConfig const& AMP_config)
186 {
187 return CriterionCRHS(norm_J_inverse, double(z.norm()), tracking_tolerance, AMP_config);
188 }
189
190
205 template<typename NumT, typename Derived>
206 bool CriterionC(double const& norm_J_inverse, const Eigen::MatrixBase<Derived>& z, double tracking_tolerance, AdaptiveMultiplePrecisionConfig const& AMP_config)
207 {
208 return NumTraits<NumT>::NumDigits() > CriterionCRHS(norm_J_inverse, z, tracking_tolerance, AMP_config);
209 }
210 }
211 }
212
213}
214
215
216#endif
217
bool CriterionC(double const &norm_J_inverse, const Eigen::MatrixBase< Derived > &z, double tracking_tolerance, AdaptiveMultiplePrecisionConfig const &AMP_config)
Check AMP Criterion C.
Definition amp_criteria.hpp:206
double CriterionCRHS(double const &norm_J_inverse, double const &norm_z, double const &tracking_tolerance, AdaptiveMultiplePrecisionConfig const &AMP_config)
Evaluate the right hand side of Criterion C.
Definition amp_criteria.hpp:159
double D(double const &norm_J, double const &norm_J_inverse, AdaptiveMultiplePrecisionConfig const &AMP_config)
Compute the expression from the AMP papers amp1, amp2.
Definition amp_criteria.hpp:88
bool CriterionB(double const &norm_J, double const &norm_J_inverse, unsigned num_newton_iterations_remaining, double const &tracking_tolerance, double const &norm_of_latest_newton_residual, AdaptiveMultiplePrecisionConfig const &AMP_config)
Check AMP Criterion B.
Definition amp_criteria.hpp:132
double CriterionBRHS(double const &norm_J, double const &norm_J_inverse, unsigned num_newton_iterations_remaining, double 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:108
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:50
bool CriterionA(double const &norm_J, double const &norm_J_inverse, AdaptiveMultiplePrecisionConfig const &AMP_config)
Check AMP Criterion A.
Definition amp_criteria.hpp:71
Definition trackers/config.hpp:154
int safety_digits_2
User-chosen setting for the number of safety digits used during Criterion C.
Definition trackers/config.hpp:170
int safety_digits_1
User-chosen setting for the number of safety digits used during Criteria A & B.
Definition trackers/config.hpp:169
NumErrorT Phi
Bound on (an error bound). Used for AMP criteria A, B.
Definition trackers/config.hpp:161
NumErrorT Psi
Bound on (an error bound). Used for AMP criterion C.
Definition trackers/config.hpp:165
NumErrorT epsilon
Bound on growth in error from linear solves. This is in amp1, amp2, and is used for AMP criteria A a...
Definition trackers/config.hpp:158
Configs and settings for tracking.