44#include <boost/json.hpp>
56 std::snprintf(buffer,
sizeof(buffer),
"%.17g", v);
63 return std::strtod(s.c_str(),
nullptr);
80 return {z.real().str(0, std::ios::scientific), z.imag().str(0, std::ios::scientific),
81 static_cast<std::int64_t
>(z.precision())};
85template <
typename ComplexT>
100 auto const digits =
static_cast<unsigned>(triple.at(2).as_int64());
102 real_mp(std::string(triple.at(1).as_string()), digits));
108template <
typename ComplexT>
111 boost::json::array out;
112 for (Eigen::Index ii = 0; ii < point.size(); ++ii)
118template <
typename ComplexT>
122 for (std::size_t ii = 0; ii < coords.size(); ++ii)
160 return "UnknownSuccessCode";
191template <
typename ComplexT>
194 boost::json::object out;
206 boost::json::array sv;
209 out[
"singular_values"] = std::move(sv);
215 out[
"cycle_num"] =
static_cast<std::int64_t
>(r.
cycle_num);
236 out[
"crossing_unresolved"] =
true;
241template <
typename ComplexT>
243 std::size_t path_index)
249 static_cast<SuccessCode>(rec.at(
"pre_endgame_success_code").as_int64());
251 if constexpr (std::is_same<RealT, double>::value)
254 r.
boundary_stepsize = RealT(std::string(rec.at(
"boundary_stepsize").as_string()));
255 r.
boundary_precision =
static_cast<unsigned>(rec.at(
"boundary_precision").as_int64());
261 if (
auto const* sv = rec.if_contains(
"singular_values"))
263 auto const& arr = sv->as_array();
265 for (std::size_t i = 0; i < arr.size(); ++i)
274 (rec.if_contains(
"accuracy_estimate_internal_coords")
275 ? rec.at(
"accuracy_estimate_internal_coords")
276 : rec.at(
"accuracy_estimate")).as_string()));
278 DoubleFromText(std::string(rec.at(
"accuracy_estimate_user_coords").as_string()));
279 r.
cycle_num =
static_cast<unsigned>(rec.at(
"cycle_num").as_int64());
280 r.
precision_digits =
static_cast<unsigned>(rec.at(
"precision_digits").as_int64());
281 r.
accuracy_digits =
static_cast<unsigned>(rec.at(
"accuracy_digits").as_int64());
285 r.
max_precision_used =
static_cast<unsigned>(rec.at(
"max_precision_used").as_int64());
288 if (
auto const* v = rec.if_contains(
"num_successful_steps"))
290 if (
auto const* v = rec.if_contains(
"num_failed_steps"))
292 if (
auto const* v = rec.if_contains(
"latest_path_point"))
294 if (
auto const* v = rec.if_contains(
"wall_clock_limit_seconds"))
296 if (
auto const* v = rec.if_contains(
"crossing_unresolved"))
Definition config_encoding.hpp:66
complex_mp DecodeComplexScalar< complex_mp >(boost::json::array const &triple)
Decode a multiprecision complex value at its recorded precision.
Definition solver_recording.hpp:98
boost::json::object EncodeFullPathResult(parallel::FullPathResult< ComplexT > const &r)
Serialize one whole-path result as a b2rec/1 track record body.
Definition solver_recording.hpp:192
complex_dbl DecodeComplexScalar< complex_dbl >(boost::json::array const &triple)
Decode a double-precision complex value.
Definition solver_recording.hpp:90
double DoubleFromText(std::string const &s)
Parse a double written by ExactDoubleText (bit-exact round trip).
Definition solver_recording.hpp:61
Vec< ComplexT > DecodePoint(boost::json::array const &coords)
Decode a point written by EncodePoint.
Definition solver_recording.hpp:119
std::string ExactDoubleText(double v)
A double as full-round-trip decimal text (%.17g: bit-exact per IEEE-754).
Definition solver_recording.hpp:53
std::string CoarsePathStatus(SuccessCode code)
The coarse outcome of a path, from its endgame verdict: "success", "diverged" (the path went to infin...
Definition solver_recording.hpp:175
parallel::FullPathResult< ComplexT > DecodeFullPathResult(boost::json::object const &rec, std::size_t path_index)
Reconstruct a whole-path result from a track record (the recall half).
Definition solver_recording.hpp:242
std::string CanonicalName(tracking::Predictor p)
The fixed canonical name of a predictor choice (never its numeric value).
boost::json::array EncodePoint(Vec< ComplexT > const &point)
Encode a point (vector of complex coordinates) as an array of scalar triples.
Definition solver_recording.hpp:109
boost::json::array EncodeComplexScalar(complex_dbl const &z)
Encode one complex value as ["re", "im", precision] (precision in digits).
Definition solver_recording.hpp:72
std::string EncodeRealScalar(double v)
Encode one real scalar as text: doubles via %.17g; real_mp at full stored precision.
Definition solver_recording.hpp:67
ComplexT DecodeComplexScalar(boost::json::array const &triple)
Decode a complex value written by EncodeComplexScalar, at its recorded precision.
Definition algorithm_builder.hpp:36
constexpr unsigned DoublePrecision()
The number of digits considered "double precision" (16).
Definition num_traits.hpp:152
std::complex< double > complex_dbl
The double-precision complex number type.
Definition double_extensions.hpp:47
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
bmp::number< mpc_complex_backend< 0 >, bmp::et_on > complex_mp
The arbitrary-precision complex number type.
Definition mpfr_complex.hpp:58
SuccessCode
Definition config.hpp:42
@ MinStepSizeReached
Definition config.hpp:60
@ FailedToConverge
Definition config.hpp:55
@ MatrixSolveFailureFirstPartOfPrediction
Definition config.hpp:57
@ FailedToSelectPrecisionAndStepsize
Definition config.hpp:67
@ NeverStarted
No tracking was attempted.
Definition config.hpp:50
@ ExternallyTerminated
Definition config.hpp:63
@ Success
Definition config.hpp:51
@ MaxNumStepsTaken
Definition config.hpp:58
@ GoingToInfinity
Definition config.hpp:54
@ MinTrackTimeReached
Definition config.hpp:64
@ WallClockLimitReached
The tracker's wall-clock deadline passed between steps; the path was abandoned where it was....
Definition config.hpp:68
@ MatrixSolveFailure
Definition config.hpp:56
@ MaxPrecisionReached
Definition config.hpp:59
@ ReduceStepSize
Definition config.hpp:53
@ HigherPrecisionNecessary
Definition config.hpp:52
@ CycleNumTooHigh
Definition config.hpp:66
@ Failure
Definition config.hpp:61
@ SecurityMaxNormReached
Definition config.hpp:65
@ SingularStartPoint
Definition config.hpp:62
boost::multiprecision::number< boost::multiprecision::mpfr_float_backend< 0 >, boost::multiprecision::et_on > real_mp
The arbitrary-precision real number type.
Definition mpfr_extensions.hpp:53
Provides an Eigen-like NumTraits struct for querying traits of a number type.
Result struct used in the manager-worker MPI protocol for ZeroDim.
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
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