Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
path_result.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/parallel/path_result.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//bertini2/parallel/path_result.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 bertini2/parallel/path_result.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17
31
32#pragma once
33
34#include <deque>
35#include <limits>
36
38#include "bertini2/eigen_extensions.hpp" // defines Vec<T> and sets up Eigen serialization plugin
39#include "bertini2/mpfr_extensions.hpp" // Boost.Serialization for real_mp, mpc_complex
40#include "bertini2/common/config.hpp" // SuccessCode (needs Vec<T> and <deque> first)
41
42#include <boost/serialization/vector.hpp>
43
44namespace bertini {
45namespace parallel {
46
47constexpr int TAG_WORK_ITEM = 1;
48constexpr int TAG_RESULT = 2;
49constexpr int TAG_CAPACITY = 3;
50
51
52
60template<typename ComplexT>
62{
63 using SolnIndT = std::size_t;
64
65 SolnIndT path_index = std::numeric_limits<SolnIndT>::max();
67
69 bool is_sentinel() const
70 {
71 return path_index == std::numeric_limits<SolnIndT>::max();
72 }
73
76 {
77 return StartPointTask{}; // default path_index == max
78 }
79
81 template<class Archive>
82 void serialize(Archive& ar, unsigned const)
83 {
84 ar & path_index;
85 ar & start_point;
86 }
88};
89
90
99template<typename ComplexT>
101{
102 using SolnIndT = std::size_t;
104
106
107 // boundary (pre-endgame) data
112
113 // endgame data
116 double function_residual = 0;
117 double condition_number = 0;
119 double newton_residual = 0;
123 unsigned cycle_num = 0;
124 unsigned precision_digits = 0;
125 unsigned accuracy_digits = 0;
126
127 // precision metadata (spans the whole path)
128 bool precision_changed = false;
130 unsigned max_precision_used = 0;
131
132 // wall-clock time to execute the whole path (pre-endgame + endgame), in seconds
133 double path_time_seconds = 0;
134
135 // where the path got to (the stamp every path carries; the point only when it did not succeed)
136 unsigned num_successful_steps = 0;
137 unsigned num_failed_steps = 0;
140
141 // the endgame-boundary crossing verdict. Unlike everything above it, this is not known when
142 // the path finishes -- whether a path crossed another is only decidable once every path has
143 // reached the boundary -- so the manager writes it afterwards and the path is reported again.
144 bool crossing_unresolved = false;
145
147 template<class Archive>
148 void serialize(Archive& ar, unsigned const)
149 {
150 ar & path_index;
152 ar & boundary_point;
156 ar & solution;
158 ar & condition_number;
159 ar & singular_values;
160 ar & newton_residual;
161 ar & final_time_used;
164 ar & cycle_num;
165 ar & precision_digits;
166 ar & accuracy_digits;
172 ar & num_failed_steps;
176 }
178};
179
180namespace detail {
181
182// Sentinel detection and factory for the work-item type. The work item is a StartPointTask whose
183// max path_index marks "no more work". (The plain-size_t overloads remain for any other caller.)
184
186inline bool is_sentinel(std::size_t v)
187{
188 return v == std::numeric_limits<std::size_t>::max();
189}
190
192inline std::size_t make_sentinel(std::size_t)
193{
194 return std::numeric_limits<std::size_t>::max();
195}
196
198template<typename ComplexT>
200{
201 return t.is_sentinel();
202}
203
205template<typename ComplexT>
210
211} // namespace detail
212
213} // namespace parallel
214} // namespace bertini
Bertini extensions of the Eigen linear algebra library.
Extensions to the Boost.Multiprecision library.
Definition path_result.hpp:180
bool is_sentinel(std::size_t v)
Query whether a plain index value is the sentinel.
Definition path_result.hpp:186
std::size_t make_sentinel(std::size_t)
Make the sentinel index value.
Definition path_result.hpp:192
Definition initialize_finalize.hpp:43
constexpr int TAG_CAPACITY
MPI message tag: worker -> manager, max tasks in flight on that rank.
Definition path_result.hpp:49
constexpr int TAG_RESULT
MPI message tag: worker -> manager result.
Definition path_result.hpp:48
constexpr int TAG_WORK_ITEM
MPI message tag: manager -> worker work item.
Definition path_result.hpp:47
Definition algorithm_builder.hpp:36
constexpr unsigned DoublePrecision()
The number of digits considered "double precision" (16).
Definition num_traits.hpp:152
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
SuccessCode
Definition config.hpp:42
@ NeverStarted
No tracking was attempted.
Definition config.hpp:50
Provides an Eigen-like NumTraits struct for querying traits of a number type.
Numeric traits for a bertini number type: digit counts, conversions, and companion types.
Definition num_traits.hpp:57
Result of executing one WHOLE path: start -> endgame boundary -> target.
Definition path_result.hpp:101
unsigned max_precision_used
The highest precision used over the whole path.
Definition path_result.hpp:130
unsigned num_successful_steps
Successful predictor-corrector steps over the whole path.
Definition path_result.hpp:136
bool precision_changed
Whether precision changed during the path.
Definition path_result.hpp:128
unsigned cycle_num
The estimated cycle number at the endpoint.
Definition path_result.hpp:123
SuccessCode pre_endgame_success_code
Outcome of pre-endgame tracking to the boundary.
Definition path_result.hpp:108
double accuracy_estimate_user_coords
Estimated accuracy in the user's coordinates.
Definition path_result.hpp:122
bool crossing_unresolved
Whether a crossing involving this path was detected at the endgame boundary and never resolved,...
Definition path_result.hpp:144
unsigned num_failed_steps
Failed predictor-corrector steps over the whole path.
Definition path_result.hpp:137
ComplexT final_time_used
The time value the endgame finished at.
Definition path_result.hpp:120
typename NumTraits< ComplexT >::Real RealT
The real companion of the complex type.
Definition path_result.hpp:103
Vec< ComplexT > solution
The solution point (final endpoint of the path).
Definition path_result.hpp:115
SolnIndT path_index
The index of the path this result is for.
Definition path_result.hpp:105
double function_residual
Residual of the system at the final solution.
Definition path_result.hpp:116
double wall_clock_limit_seconds
The per-path wall-clock budget in force when the path ran, seconds; 0 = none.
Definition path_result.hpp:139
double newton_residual
Final Newton residual.
Definition path_result.hpp:119
unsigned precision_digits
Digits the endgame finished in (= solution point's precision).
Definition path_result.hpp:124
std::size_t SolnIndT
The path-index type.
Definition path_result.hpp:102
SuccessCode endgame_success_code
Outcome of the endgame.
Definition path_result.hpp:114
double condition_number
Condition-number estimate at the final solution.
Definition path_result.hpp:117
unsigned boundary_precision
The precision at the endgame boundary.
Definition path_result.hpp:111
ComplexT time_of_first_prec_increase
The time of the first precision increase (if any).
Definition path_result.hpp:129
Vec< ComplexT > latest_path_point
The last point the tracker reached on a path that did not succeed; empty otherwise.
Definition path_result.hpp:138
double path_time_seconds
Wall-clock seconds to execute the whole path.
Definition path_result.hpp:133
unsigned accuracy_digits
Trustworthy digit count, from the convergence agreement.
Definition path_result.hpp:125
RealT boundary_stepsize
The step size at the endgame boundary.
Definition path_result.hpp:110
double accuracy_estimate_internal_coords
Estimated accuracy in the solver's internal coordinates (homogenized, on the patch).
Definition path_result.hpp:121
Vec< ComplexT > boundary_point
The space point at the endgame boundary.
Definition path_result.hpp:109
Vec< double > singular_values
Singular values of the target Jacobian at the final solution, largest first (the spectrum behind cond...
Definition path_result.hpp:118
Work item for the speculative-full-path model: a path index plus its start point.
Definition path_result.hpp:62
bool is_sentinel() const
Query whether this is the sentinel "no more work" task.
Definition path_result.hpp:69
std::size_t SolnIndT
The path-index type.
Definition path_result.hpp:63
static StartPointTask sentinel()
Make the sentinel "no more work" task.
Definition path_result.hpp:75
SolnIndT path_index
The path index (max value marks a sentinel).
Definition path_result.hpp:65
Vec< ComplexT > start_point
The authoritative start point for this path.
Definition path_result.hpp:66