82template<
typename TrackerType,
typename EndgameType,
typename SystemType>
89template<
typename TrackerType,
typename EndgameType,
typename SystemType>
99template<
typename TrackerType,
typename EndgameType,
typename SystemType>
150 std::string
const& = {}) {
return {}; }
177template<
typename ComplexT>
278 && this->is_real == other.
is_real
287 && (this->singular_values.size() == 0
288 || (this->singular_values.array() == other.
singular_values.array()).all())
290 && (this->latest_path_point.size() == 0
299template<
typename NumT>
301 out <<
"path_index = " << meta.
path_index << std::endl;
311 out <<
"latest_path_point = " << meta.
latest_path_point.transpose() << std::endl;
316 out <<
"singular_values = " << meta.
singular_values.transpose() << std::endl;
323 out <<
"cycle_num = " << meta.
cycle_num << std::endl;
328 out <<
"multiplicity = " << meta.
multiplicity << std::endl;
330 out <<
"is_real = " << meta.
is_real << std::endl;
331 out <<
"is_finite = " << meta.
is_finite << std::endl;
332 out <<
"is_singular = " << meta.
is_singular << std::endl;
341template<
typename ComplexT>
382template<
typename NumT>
384 out <<
"path_point = " << meta.
path_point << std::endl;
385 out <<
"success_code = " << meta.
success_code << std::endl;
387 out <<
"precision = " << meta.
precision << std::endl;
414 out <<
"passed = " << std::boolalpha << r.
passed << std::endl;
417 out <<
"crossed_path_indices = [";
420 out <<
"]" << std::endl;
456template<
typename ComplexT>
463 double finite_distinct = 0;
464 for (
auto const& m : metadata)
478 if (m.is_nonsolution)
480 else if (m.is_finite)
483 finite_distinct += 1.0 / m.multiplicity;
520 out << (first ?
"" :
", ") << kv.second <<
" x " << kv.first;
525 out <<
" singular solutions " << r.
num_singular <<
"\n";
526 out <<
" real solutions " << r.
num_real <<
"\n";
528 out <<
" nonsolutions " << r.
num_nonsolutions <<
" (finite, but not solutions of the target)\n";
530 << (r.
midpath.
passed ?
" (resolved)" :
" (UNRESOLVED)") <<
"\n";
541 template<
typename TrackerType,
typename EndgameType,
typename SystemType>
545 typename AlgoTraits< HomotopySolver<TrackerType, EndgameType, SystemType>>::NeededConfigs>
615#ifdef BERTINI2_HAVE_MPI
619 virtual void DistributeSystems(MPI_Comm ) {}
698#ifdef BERTINI2_HAVE_MPI
701 RunParallel(parallel::WorldComm());
708#ifdef BERTINI2_HAVE_MPI
721 void RunParallel(MPI_Comm comm)
726 ScopedSessionState
const session_state_guard{};
744 MPI_Bcast(&seed, 1, MPI_UNSIGNED_LONG, 0, comm);
751 DistributeSystems(comm);
762 const int n_threads =
static_cast<int>(
775 start_points[ii] = ComputeStartPoint(
static_cast<SolnIndT>(ii));
777 auto run_round = [&](std::queue<Task>& q)
779 parallel::RunManagerLoop<Task, Result>(comm, q,
786 std::vector<SolnIndT> indices_to_run;
788 indices_to_run.push_back(
static_cast<SolnIndT>(ii));
795 std::queue<Task> queue;
796 for (
auto idx : indices_to_run)
797 queue.push(Task{ idx, start_points[idx] });
806 for (
auto const& v :
midpath_.GetCrossedPaths())
811 const auto max_attempts = this->
template Get<ZeroDimConf>().max_num_crossed_path_resolve_attempts;
812 unsigned num_resolve_attempts = 0;
815 int keep_going = (!passed && num_resolve_attempts < max_attempts) ? 1 : 0;
816 MPI_Bcast(&keep_going, 1, MPI_INT, 0, comm);
820 std::queue<Task> redo;
821 for (
auto const& v :
midpath_.GetCrossedPaths())
824 auto idx =
static_cast<SolnIndT>(v.index());
825 redo.push(Task{ idx, start_points[idx] });
830 ++num_resolve_attempts;
834 FlagUnresolvedCrossings(passed);
835 RecordMidpathOutcome();
838 <<
" path crossing(s) detected at the endgame boundary remained unresolved "
839 <<
"after " << num_resolve_attempts <<
" re-track attempt(s); "
840 <<
"the affected solutions may be wrong. Consider a higher-order predictor "
841 <<
"or a tighter tracking tolerance. See EndgameBoundaryMetadata()." << std::endl;
849 auto run_worker_round = [&]()
855 parallel::RunWorkerLoop<Task, Result>(comm,
856 [
this](Task
const& task){ ExecuteOnePath(MemberDuringEGContext(),
static_cast<SolnIndT>(task.path_index), task.start_point); },
865 auto state_factory = [
this]() -> std::unique_ptr<PathThreadState>
870 std::unique_ptr<PathThreadState> s(
873 s->tracker.SetSystem(s->sys);
874 s->endgame.SetTracker(s->tracker);
879 auto track_fn = [
this](std::unique_ptr<PathThreadState>& state, Task
const& task) -> Result
881 auto idx =
static_cast<SolnIndT>(task.path_index);
882 ExecuteOnePath(state->Context(), idx, task.start_point);
886 parallel::RunWorkerLoopThreaded<Task, Result>(
887 comm, state_factory, track_fn, n_threads);
896 MPI_Bcast(&keep_going, 1, MPI_INT, 0, comm);
904 EscalateRetrackSettings();
1115 template<
typename T>
1122 template<
typename T>
1158 ScopedSessionState
const session_state_guard{};
1168 if (
auto const limit = this->
template Get<ZeroDimConf>().max_solve_wall_clock_duration; limit > 0)
1170 + std::chrono::duration_cast<std::chrono::steady_clock::duration>(std::chrono::duration<double>(limit));
1187 auto idx =
static_cast<SolnIndT>(ii);
1188 start_points[ii] = ComputeStartPoint(idx);
1189 all_indices[ii] = idx;
1195 std::vector<SolnIndT> indices_to_run = all_indices;
1206 const unsigned n_threads =
1211 for (
auto idx : indices_to_run)
1215 ExecuteOnePath(MemberDuringEGContext(), idx, start_points[idx]);
1223 RunPathsThreaded(indices_to_run, start_points, n_threads);
1237 RunMidpathResolution([
this, &start_points](
SolnIndT idx){
1238 ExecuteOnePath(MemberDuringEGContext(), idx, start_points[idx]);
1308 template<
typename Pred>
1310 bool merge_multiplicities =
false)
const
1315 for (
size_t i = 0; i < md.size() && i < sols.size(); ++i)
1320 if (merge_multiplicities && !md[i].multiplicity_representative)
1323 out.push_back(sols[i]);
1337 return m.endgame_success_code ==
SuccessCode::Success && m.is_finite && !m.is_nonsolution; }, user_coords, merge_multiplicities);
1344 return m.endgame_success_code ==
SuccessCode::Success && m.is_finite && !m.is_nonsolution && m.is_real; }, user_coords, merge_multiplicities);
1351 return m.endgame_success_code ==
SuccessCode::Success && m.is_finite && !m.is_nonsolution && !m.is_singular; }, user_coords, merge_multiplicities);
1358 return m.endgame_success_code ==
SuccessCode::Success && m.is_finite && !m.is_nonsolution && m.is_singular; }, user_coords, merge_multiplicities);
1386 return SolutionsWhere([](
auto const& m){
return !m.is_finite; }, user_coords);
1452 bool user_coords =
true,
bool representatives_only =
true)
const
1457 std::vector<size_t> matches;
1458 for (
size_t i = 0; i < md.size() && i < sols.size(); ++i)
1460 if (representatives_only && !md[i].multiplicity_representative)
1463 matches.push_back(i);
1466 if (matches.empty())
1467 throw std::runtime_error(
"metadata_for: no solution matches the given point within tol");
1473 std::vector<size_t> reps;
1474 for (
auto i : matches)
1475 if (md[i].multiplicity_representative)
1477 if (reps.size() > 1)
1478 throw std::runtime_error(
"metadata_for: the point matches more than one distinct solution cluster; reduce tol");
1479 if (reps.size() == 1)
1480 return md[reps.front()];
1484 return md[matches.front()];
1510 size_t rep = md.size();
1511 NumErrorT best = std::numeric_limits<NumErrorT>::infinity();
1512 for (
size_t i = 0; i < md.size() && i < sols.size(); ++i)
1514 if (!md[i].multiplicity_representative)
1516 NumErrorT d =
static_cast<NumErrorT>((sols[i] - point).template lpNorm<Eigen::Infinity>());
1517 if (d <= tol && d < best) { best = d; rep = i; }
1519 if (rep == md.size())
1520 throw std::runtime_error(
"metadata_for: no solution matches the given point within tol");
1525 std::vector<SolutionMetaDataT> out;
1526 for (
size_t i = 0; i < md.size() && i < sols.size(); ++i)
1528 out.push_back(md[i]);
1568 void PreSolveChecks()
const
1571 throw std::runtime_error(
"start system has more solutions than container for results. I refuse to continue until this has been addressed.");
1575 void PreSolveSetup()
1593 if constexpr (!std::is_same<BaseComplexT, complex_dbl>::value)
1594 if (fp.precision != 0)
1597 zdc.initial_ambient_precision = fp.precision;
1623 struct BeforeEGContext
1625 TrackerType& tracker;
1626 tracking::PathPrecisionRecorder<TrackerType>& path_prec;
1628 struct DuringEGContext
1633 SystemType
const& target_sys;
1634 TrackerType& tracker;
1635 EndgameType& endgame;
1636 tracking::PathPrecisionRecorder<TrackerType>& path_prec;
1639 BeforeEGContext MemberBeforeEGContext()
1643 DuringEGContext MemberDuringEGContext()
1649 static void HarvestPathPrecision(SolutionMetaData<BaseComplexT>& smd,
1650 tracking::PathPrecisionRecorder<TrackerType>
const& rec)
1652 if (rec.DidPrecisionIncrease() && !smd.precision_changed)
1654 smd.precision_changed =
true;
1655 smd.time_of_first_prec_increase = rec.TimeOfIncrease();
1658 smd.max_precision_used =
max(smd.max_precision_used, rec.MaxPrecision());
1674 static std::mutex start_point_mutex;
1675 std::lock_guard<std::mutex> lock(start_point_mutex);
1676 return StartSystem().template StartPoint<BaseComplexT>(soln_ind);
1692 smd.path_index = soln_ind;
1693 smd.solution_index = soln_ind;
1697 ctx.tracker.ResetCumulativeStepCounts();
1702 auto const wall_clock_limit = this->
template Get<ZeroDimConf>().max_path_wall_clock_duration;
1703 smd.wall_clock_limit_seconds = wall_clock_limit;
1704 ctx.tracker.ClearMaxWallClockTime();
1705 if (wall_clock_limit > 0)
1706 ctx.tracker.SetMaxWallClockDuration(std::chrono::duration<double>(wall_clock_limit));
1711 auto initial_prec = this->
template Get<ZeroDimConf>().initial_ambient_precision;
1722 ctx.tracker.RefreshConditionDirection();
1740 ctx.tracker.ReinitializeInitialStepSize(
true);
1749 if constexpr (tracking::TrackerTraits<TrackerType>::IsAdaptivePrec)
1753 auto tracking_success = ctx.tracker.TrackPath(result, t_start, t_endgame_boundary, start_point);
1756 EGBoundaryMetaDataT({ result, tracking_success, ctx.tracker.CurrentStepsize(), ctx.tracker.CurrentPrecision() });
1760 if constexpr (tracking::TrackerTraits<TrackerType>::IsAdaptivePrec)
1761 ctx.tracker.SetStartPrecision(std::nullopt);
1763 smd.pre_endgame_success_code = tracking_success;
1765 if (tracking::TrackerTraits<TrackerType>::IsAdaptivePrec)
1766 HarvestPathPrecision(smd, ctx.path_prec);
1768 StampWhereThePathGotTo(smd, ctx.tracker, tracking_success, ctx.tracker.CurrentTime());
1787 void StampWhereThePathGotTo(SolutionMetaData<BaseComplexT>& smd, TrackerType
const& tracker,
1791 smd.final_time_used = time_reached;
1792 smd.num_successful_steps = tracker.CumulativeSuccessfulSteps();
1793 smd.num_failed_steps = tracker.CumulativeFailedSteps();
1794 smd.max_precision_used =
max(smd.max_precision_used,
1795 static_cast<decltype(smd.max_precision_used)
>(tracker.CurrentPrecision()));
1797 smd.latest_path_point.resize(0);
1799 smd.latest_path_point = tracker.CurrentPoint();
1810 struct PathThreadState
1814 TrackerType tracker;
1815 EndgameType endgame;
1816 tracking::PathPrecisionRecorder<TrackerType> path_prec;
1818 DuringEGContext Context()
1820 return DuringEGContext{ target_sys, tracker, endgame, path_prec };
1835 auto MakeThreadStateFactory()
1837 return [
this]() -> std::unique_ptr<PathThreadState>
1841 std::unique_ptr<PathThreadState> s(
1844 s->tracker.SetSystem(s->sys);
1845 s->endgame.SetTracker(s->tracker);
1859 auto MakeThreadTrackFn()
1861 return [
this](std::unique_ptr<PathThreadState>& state,
1862 parallel::StartPointTask<BaseComplexT>
const& task)
1863 -> parallel::FullPathResult<BaseComplexT>
1865 auto idx =
static_cast<SolnIndT>(task.path_index);
1866 ExecuteOnePath(state->Context(), idx, task.start_point);
1879 void RunPathsThreaded(std::vector<SolnIndT>
const& indices,
1883 using Task = parallel::StartPointTask<BaseComplexT>;
1884 using Result = parallel::FullPathResult<BaseComplexT>;
1886 auto state_factory = MakeThreadStateFactory();
1887 auto track_fn = MakeThreadTrackFn();
1889 parallel::WorkerThreadPool<Task, Result,
decltype(state_factory),
decltype(track_fn)>
1890 pool(
static_cast<int>(n_threads), state_factory, track_fn);
1892 for (
auto idx : indices)
1893 pool.submit(Task{
static_cast<std::size_t
>(idx), start_points[idx] });
1895 for (std::size_t k = 0; k < indices.size(); ++k)
1917 void EscalateRetrackSettings()
1925 GetTracker().SetPredictor(default_predictor);
1945 Observable const* exec_tracker = &ctx.tracker;
1957 auto const path_start_clock = std::chrono::steady_clock::now();
1958 auto stamp_path_time = [&]{
1960 std::chrono::duration<double>(std::chrono::steady_clock::now() - path_start_clock).count();
1963 this->
NotifyObservers(PathStarted<AnyZeroDim>(*
this,
static_cast<std::size_t
>(soln_ind), exec_tracker));
1967 constexpr bool adaptive = tracking::TrackerTraits<TrackerType>::IsAdaptivePrec;
1970 ctx.path_prec.Reset();
1971 ctx.tracker.AddObserver(ctx.path_prec);
1975 ExecuteBeforeEG(BeforeEGContext{ ctx.tracker, ctx.path_prec }, soln_ind, start_point);
1981 ctx.tracker.RemoveObserver(ctx.path_prec);
1982 ctx.tracker.ClearMaxWallClockTime();
1984 this->
NotifyObservers(PathComplete<AnyZeroDim>(*
this,
static_cast<std::size_t
>(soln_ind), exec_tracker,
1989 ctx.tracker.SetTrackingTolerance(this->
template Get<Tolerances>().newton_during_endgame);
1990 ExecuteDuringEG(ctx, soln_ind);
1992 ctx.tracker.RemoveObserver(ctx.path_prec);
1995 ctx.tracker.ClearMaxWallClockTime();
1997 this->
NotifyObservers(PathComplete<AnyZeroDim>(*
this,
static_cast<std::size_t
>(soln_ind), exec_tracker,
2011 template<
typename RedoOne>
2012 void RunMidpathResolution(RedoOne&& redo_one)
2018 for (
auto const& v :
midpath_.GetCrossedPaths())
2023 const auto max_attempts = this->
template Get<ZeroDimConf>().max_num_crossed_path_resolve_attempts;
2024 unsigned num_resolve_attempts = 0;
2025 while (!passed && num_resolve_attempts < max_attempts)
2027 EscalateRetrackSettings();
2028 for (
auto const& v :
midpath_.GetCrossedPaths())
2030 redo_one(
static_cast<SolnIndT>(v.index()));
2032 ++num_resolve_attempts;
2037 FlagUnresolvedCrossings(passed);
2038 RecordMidpathOutcome();
2042 <<
" path crossing(s) detected at the endgame boundary remained unresolved "
2043 <<
"after " << num_resolve_attempts <<
" re-track attempt(s); "
2044 <<
"the affected solutions may be wrong. Consider a higher-order predictor "
2045 <<
"or a tighter tracking tolerance. See EndgameBoundaryMetadata()." << std::endl;
2065 void FlagUnresolvedCrossings(
bool passed)
2068 smd.crossing_unresolved =
false;
2071 for (
auto const& v :
midpath_.GetCrossedPaths())
2094 void RecordMidpathOutcome()
2099 boost::json::array crossed;
2101 crossed.push_back(boost::json::value(
static_cast<std::int64_t
>(i)));
2103 {{
"kind",
"midpath"},
2106 {
"num_crossings_detected",
2108 {
"num_resolve_attempts",
2110 {
"crossed_path_indices", std::move(crossed)}});
2125 void ExecuteDuringEG(DuringEGContext ctx,
SolnIndT soln_ind)
2134 ctx.tracker.ReinitializeInitialStepSize(
false);
2145 auto eg_success = ctx.endgame.Run(bdry_point);
2156 smd.endgame_success_code = eg_success;
2157 StampWhereThePathGotTo(smd, ctx.tracker, eg_success,
2159 : ctx.tracker.CurrentTime());
2165 if (tracking::TrackerTraits<TrackerType>::IsAdaptivePrec)
2166 HarvestPathPrecision(smd, ctx.path_prec);
2172 if (tracking::TrackerTraits<TrackerType>::IsAdaptivePrec)
2182 smd.newton_residual = ctx.tracker.LatestNormOfStep();
2184 smd.accuracy_estimate_internal_coords = ctx.endgame.ApproximateError();
2185 smd.accuracy_estimate_user_coords =
2187 ctx.target_sys.DehomogenizePoint(ctx.endgame.template PreviousApproximation<BaseComplexT>())).template lpNorm<Eigen::Infinity>() );
2188 smd.cycle_num = ctx.endgame.CycleNumber();
2197 using std::log10;
using std::floor;
using std::min;
using std::max;
2198 double err =
static_cast<double>(smd.accuracy_estimate_internal_coords);
2199 unsigned acc = (err > 0.0)
2200 ?
static_cast<unsigned>(
max(0.0, floor(-log10(err))))
2201 : smd.precision_digits;
2202 smd.accuracy_digits = min(acc, smd.precision_digits);
2255 smd.is_finite =
false;
2264 post.endpoint_finite_threshold);
2267 post.real_threshold);
2300 if (!eligible[ii])
continue;
2303 if (!eligible[jj])
continue;
2304 if (
static_cast<NumErrorT>((user_pts[ii] - user_pts[jj]).
template lpNorm<Eigen::Infinity>()) < same_tol )
2334 smd.is_singular = (smd.multiplicity > 1) || (smd.condition_number > cond_threshold);
2380 const auto J = sys.Jacobian(endpoint);
2381 const auto sv = Eigen::JacobiSVD<Mat<BaseComplexT>>(J).singularValues();
2383 for (Eigen::Index i = 0; i < sv.size(); ++i)
2399 if (singular_values.size() == 0)
2400 return std::numeric_limits<NumErrorT>::infinity();
2401 const NumErrorT smallest = singular_values(singular_values.size()-1);
2403 return std::numeric_limits<NumErrorT>::infinity();
2404 return singular_values(0) / smallest;
2471 smd.path_index = idx;
2472 smd.solution_index = idx;
2515 void RecordTo(std::shared_ptr<records::OutputDirectory> directory)
2547 records_->Append(boost::json::parse(record_json).as_object());
2553 std::string
const& kind,
2554 std::string
const& label = {})
override
2556 return records_ ?
records_->PutDefinition(content, kind, std::nullopt, label)
2569 boost::json::array points;
2572 points.push_back(boost::json::object{
2574 {
"index",
static_cast<std::int64_t
>(smd.path_index)}});
2575 boost::json::object result;
2576 result[
"kind"] =
"result";
2579 result[
"description"] =
"auto-declared by the solver after post-processing";
2580 result[
"points"] = points;
2653 std::string start_identity)
2681 std::ostringstream text;
2710 boost::json::object ask;
2711 ask[
"op"] =
"zerodim";
2718 ask[
"homotopy"] =
Homotopy().ContentDigest().Hex();
2733 template <
typename... EGConfTs>
2754 {{
"kind",
"results_header"},
2760 for (
auto const& rec :
records_->Scan())
2761 if (
auto const* k = rec.if_contains(
"kind");
2762 k && k->is_string() && k->get_string() ==
"run"
2763 && rec.if_contains(
"run") && rec.at(
"run").is_string()
2785 "systems", target_digest_hex);
2791 auto const homotopy_digest_hex =
Homotopy().ContentDigest().Hex();
2794 homotopy_digest_hex,
2796 "systems", homotopy_digest_hex);
2802 std::string(ask.at(
"config").as_string()));
2803 boost::json::object header;
2804 header[
"kind"] =
"run";
2808 header[
"op"] =
"zerodim";
2812 header[
"ask"] = ask;
2815 header[
"target_digest"] = target_digest_hex;
2820 boost::json::array variable_names, user_variable_names;
2821 auto const& homogenizers =
TargetSystem().HomogenizingVariables();
2824 variable_names.push_back(boost::json::value(v->name()));
2825 bool const is_homogenizer = std::find(homogenizers.begin(),
2826 homogenizers.end(), v) != homogenizers.end();
2827 if (!is_homogenizer)
2828 user_variable_names.push_back(boost::json::value(v->name()));
2830 header[
"variables"] = variable_names;
2833 header[
"variables_user"] = user_variable_names;
2878 std::map<std::size_t, boost::json::object> recorded;
2881 auto const* k = rec.if_contains(
"kind");
2882 if (!k || !k->is_string() || k->get_string() !=
"path")
2884 if (
auto const* idx = rec.if_contains(
"index"); idx && idx->is_int64())
2885 recorded[
static_cast<std::size_t
>(idx->as_int64())] = rec;
2889 auto const current_limit = this->
template Get<ZeroDimConf>().max_path_wall_clock_duration;
2893 std::vector<SolnIndT> missing;
2894 for (
auto const idx : all_indices)
2896 auto const found = recorded.find(
static_cast<std::size_t
>(idx));
2899 missing.push_back(idx);
2921 missing.push_back(idx);
2935 records_->Append({{
"kind",
"recall"},
2939 {
"num_computed",
static_cast<std::int64_t
>(missing.size())},
2956 bool abandoned_any =
false;
2958 for (
auto idx : dispatched)
2964 abandoned_any =
true;
2968 abandoned_any =
true;
2996 record[
"kind"] =
"path";
2998 record[
"index"] =
static_cast<std::int64_t
>(r.
path_index);
3011 : boost::json::object{{
"kind",
"start_label"},
3012 {
"index",
static_cast<std::int64_t
>(r.
path_index)}};
3060 auto const path_limit = this->
template Get<ZeroDimConf>().max_path_wall_clock_duration;
3063 auto const path_deadline = path_start
3064 + std::chrono::duration_cast<std::chrono::steady_clock::duration>(std::chrono::duration<double>(path_limit));
3116 template<
typename SystemType>
3170 throw std::runtime_error(
"unable to perform zero dim solve on target system -- has path variable, use a HomotopySolver instead.");
3179 throw std::runtime_error(
"unable to perform zero dim solve on target system -- it is under-determined (fewer equations than variables), so its solution set is positive-dimensional, not zero-dimensional. ZeroDimSolver computes isolated solutions only; add equations, or use a positive-dimensional method.");
3182 throw std::runtime_error(
"unable to perform zero dim solve on target system -- system is non-polynomial, use a HomotopySolver instead.");
3216 auto const n =
static_cast<Eigen::Index
>(
owned_target_.NumVariables());
3217 if (
static_cast<Eigen::Index
>(
owned_target_.NumTotalFunctions()) != n || n == 0)
3224 Eigen::FullPivLU<Mat<complex_dbl>> lu(J);
3225 lu.setThreshold(1e-10);
3227 throw std::runtime_error(
"unable to perform zero dim solve on target system -- the Jacobian is rank-deficient at a generic point, so the solution set is positive-dimensional, not zero-dimensional. ZeroDimSolver computes isolated solutions only.");
3234 target.Homogenize();
3251 template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3303 const double threshold =
3306 for (
decltype(this->num_start_points_) ii{0}; ii < this->num_start_points_; ++ii)
3308 auto& smd = this->solution_final_metadata_[ii];
3318 for (Eigen::Index k = 0; k < user_pt.size(); ++k)
3322 smd.function_residual = residual;
3323 if (
static_cast<double>(residual) > threshold)
3324 smd.is_nonsolution =
true;
3328#ifdef BERTINI2_HAVE_MPI
3331 void DistributeSystems(MPI_Comm comm)
override
3333 parallel::mpi_broadcast_serialized(comm, this->
owned_target_, 0);
3336 parallel::mpi_broadcast_serialized(comm, this->
owned_start_, 0);
3354namespace algorithm {
3356template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3363template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3370template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3377template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3384template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3391template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3398template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3414namespace algorithm {
3423template<
typename Target,
typename... Ts>
3425 (target.template Set<Ts>(std::get<Ts>(t)), ...);
3428template<
typename TrackerType,
typename EndgameType,
typename SystemType>
3430HomotopySolver<TrackerType,EndgameType,SystemType>
3431 ::ApplyParsedConfigs(std::string
const& config_str)
3437 auto zd = ConfigParser<ZDConfs>::Parse(config_str);
3447 auto const effective_path_variable_name =
3450 ||
Homotopy().GetPathVariable()->name() != effective_path_variable_name)
3461 auto tk = ConfigParser<TkConfs>::Parse(config_str);
3464 std::get<tracking::TrackerConfig>(tk).predictor,
3466 std::get<tracking::SteppingConfig>(tk),
3467 std::get<tracking::NewtonConfig>(tk));
3475 auto eg = ConfigParser<EGConfs>::Parse(config_str);
3479 SetMidpath(ConfigParser<MidPathConfig>::Parse(config_str));
3493namespace bertini{
namespace algorithm{
3495extern template struct ZeroDimSolver<tracking::DoublePrecisionTracker, typename endgame::EndgameSelector<tracking::DoublePrecisionTracker>::PSEG, System>;
3496extern template struct ZeroDimSolver<tracking::DoublePrecisionTracker, typename endgame::EndgameSelector<tracking::DoublePrecisionTracker>::Cauchy, System>;
3497extern template struct ZeroDimSolver<tracking::MultiplePrecisionTracker, typename endgame::EndgameSelector<tracking::MultiplePrecisionTracker>::PSEG, System>;
3498extern template struct ZeroDimSolver<tracking::MultiplePrecisionTracker, typename endgame::EndgameSelector<tracking::MultiplePrecisionTracker>::Cauchy, System>;
3499extern template struct ZeroDimSolver<tracking::AMPTracker, typename endgame::EndgameSelector<tracking::AMPTracker>::PSEG, System>;
3500extern template struct ZeroDimSolver<tracking::AMPTracker, typename endgame::EndgameSelector<tracking::AMPTracker>::Cauchy, System>;
3503extern template struct HomotopySolver<tracking::DoublePrecisionTracker, typename endgame::EndgameSelector<tracking::DoublePrecisionTracker>::PSEG, System>;
3504extern template struct HomotopySolver<tracking::DoublePrecisionTracker, typename endgame::EndgameSelector<tracking::DoublePrecisionTracker>::Cauchy, System>;
3505extern template struct HomotopySolver<tracking::MultiplePrecisionTracker, typename endgame::EndgameSelector<tracking::MultiplePrecisionTracker>::PSEG, System>;
3506extern template struct HomotopySolver<tracking::MultiplePrecisionTracker, typename endgame::EndgameSelector<tracking::MultiplePrecisionTracker>::Cauchy, System>;
3507extern template struct HomotopySolver<tracking::AMPTracker, typename endgame::EndgameSelector<tracking::AMPTracker>::PSEG, System>;
3508extern template struct HomotopySolver<tracking::AMPTracker, typename endgame::EndgameSelector<tracking::AMPTracker>::Cauchy, System>;
provides a common base type for algorithms to inherit from, for the abstraction layer above for calli...
virtual bool ObservableIsA(std::type_index t) const
Whether this observable may be observed as the given type.
Definition observable.hpp:166
void NotifyObservers(AnyEvent const &e) const
Sends an event to observers that subscribed to its exact dynamic type, then to all catch-all (untyped...
Definition observable.hpp:185
A deterministic, fully-specified random stream (SHA-256 counter mode).
Definition derive.hpp:78
static std::shared_ptr< OutputDirectory > Shared(std::filesystem::path const &root)
The process-shared OutputDirectory at root: one instance – hence one session history file – per direc...
Abstract base class for other start systems.
Definition start_base.hpp:83
virtual unsigned long long NumStartPoints() const =0
Get the number of start points (an upper bound on the number of target solutions).
Roots-of-unity start system for 1-homogeneous polynomial systems.
Definition total_degree_binomial.hpp:50
Observer that records the precision a whole path used, across every call to TrackPath that tracks it:...
Definition observers.hpp:244
Emit a System (and, with a config, a whole solve) as a Bertini 1 classic input file.
Canonical exact encoding + persistent digests for configuration structs (ADR-0043; the structured-out...
Bertini extensions of the Eigen linear algebra library.
Collects the various header files which define the Bertini2 endgames.
Provides the generators for bertini2.
Render a System's structure as JSON: named fields for its parts.
Provides methods for checking for path crossings.
Events emitted by the higher-level algorithms (e.g.
Definition zero_dim_solve.hpp:3105
Definition algorithm_base.hpp:34
typename SolnCont< complex_dbl >::size_type SolnIndT
Index type for solutions/paths (over a double-precision solution container).
Definition zero_dim_solve.hpp:158
std::ostream & operator<<(std::ostream &out, const SolutionMetaData< NumT > &meta)
Stream insertion: write the metadata fields one per line (used by the Python bindings).
Definition zero_dim_solve.hpp:300
SolveReport SummarizeSolve(std::vector< SolutionMetaData< ComplexT > > const &metadata, MidpathCheckReport const &midpath)
Build a SolveReport from the per-endpoint final metadata and the midpath-crossing report.
Definition zero_dim_solve.hpp:457
void InjectParsedTuple(Target &target, std::tuple< Ts... > const &t)
Inject every element of a tuple of config structs into a Configured-derived target via Set<T>.
Definition zero_dim_solve.hpp:3424
std::vector< T > SolnCont
Definition config.hpp:32
@ Completed
The default. Reuse completed paths; re-track abandoned ones – except one cut off by a wall-clock limi...
Definition config.hpp:184
@ Nothing
Track every path fresh, even when recorded (observers, benchmarking, re-verification)....
Definition config.hpp:183
unsigned DefaultInitialAmbientPrecision()
The default ambient precision for a ZeroDimConfig, by complex type.
Definition config.hpp:162
Digest256 Sha256(std::string_view data)
SHA-256 (FIPS 180-4) of a byte string.
boost::json::object SystemPartsJson(System const &sys)
A System's structure as a JSON object with fields for its parts.
Definition json_writer.hpp:65
unsigned EffectiveThreadCount(unsigned configured=0)
Resolve a configured thread count to the number of worker threads to actually spawn.
Definition thread_pool.hpp:122
int Size()
Get the number of ranks (1 in serial builds).
bool IsManager()
Query whether this rank is the manager (rank 0).
Definition classic_utilities.hpp:41
Definition visitable.hpp:36
Definition config_encoding.hpp:66
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
boost::json::object ProducerInfo()
The producer object recorded in every run header.
std::string TimeStampNow()
The record timestamp, now: YYYY-MM-DD HH:MM local time – the one clock format every record kind uses ...
std::string CanonicalEncoding(tracking::SteppingConfig const &c)
Canonical encoding of stepping settings.
std::string ConfigTextAsJson(std::string const &canonical_text, std::string const &digest_hex)
Render one or more canonical config encodings as pretty JSON, for archiving in a structured output di...
DrawStream & ThreadDrawStream()
This thread's pinned draw stream — the source of every identity-relevant random draw in bertini2.
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
std::string SystemEncodingAsJson(std::string const &encoding_text, std::string const &digest_hex, boost::json::object const &parts)
The archived form of a system definition: a machine-parseable JSON document {"schema",...
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
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
constexpr char ConfigEncodingVersion[]
The version tag baked into every config digest; bump on any encoding change.
Definition config_encoding.hpp:69
std::optional< std::string > AmbientRecordsPath()
Resolve the ambient records directory from the environment – the ONE place the BERTINI_RECORDS_DIR se...
constexpr char RecordSchemaVersion[]
The record-format version tag written on run headers; see docs/records/b2rec-1.md.
Definition output_directory.hpp:62
Definition configIni_parse.hpp:78
Definition zero_dim_solve.hpp:68
StartSystemFactory< SystemType > MakeStartFactory()
Build a StartSystemFactory that mints a concrete start system from the target.
Definition start_base.hpp:68
std::function< std::shared_ptr< StartSystem >(SystemType const &)> StartSystemFactory
A factory that builds a start system from a (prepared) target system.
Definition start_base.hpp:54
Predictor DefaultPredictor()
Get the Bertini2 default predictor.
Definition explicit_predictors.hpp:70
unsigned Order(Predictor predictor_choice)
The order of the predictor.
Definition explicit_predictors.hpp:85
Definition algorithm_builder.hpp:36
System Clone(System const &sys)
Do a deep clone of the system.
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
void SetGlobalSeed(unsigned long seed)
Set the global RNG seed.
std::mt19937 & ThreadEngine()
Returns this thread's canonical mt19937 engine.
unsigned long GetGlobalSeed()
Returns the effective global seed.
void ReseedThisThread(uint64_t stream_key)
Reseed this thread's engine deterministically from the global seed mixed with stream_key.
void SetThreadPrecision(unsigned prec)
Set the precision (digits) for the current thread only (does not touch the global default).
Definition mpfr_complex.hpp:176
Eigen::Matrix< NumT, Eigen::Dynamic, Eigen::Dynamic > Mat
A dynamically-sized matrix of NumT.
Definition eigen_extensions.hpp:298
double NumErrorT
The numeric type used to hold error/tolerance magnitudes throughout Bertini2 – tracking tolerances,...
Definition num_traits.hpp:48
auto DefaultPrecision()
Get the global default precision (digits) for multiprecision numbers.
Definition mpfr_complex.hpp:135
SuccessCode
Definition config.hpp:42
@ NeverStarted
No tracking was attempted.
Definition config.hpp:50
@ ExternallyTerminated
Definition config.hpp:63
@ Success
Definition config.hpp:51
@ GoingToInfinity
Definition config.hpp:54
@ WallClockLimitReached
The tracker's wall-clock deadline passed between steps; the path was abandoned where it was....
Definition config.hpp:68
@ SecurityMaxNormReached
Definition config.hpp:65
bool IsDistinct(Eigen::MatrixBase< DerivedA > const &a, Eigen::MatrixBase< DerivedB > const &b, NumErrorT tol)
True if two points differ by more than tol in the infinity norm (the negation of :func:IsSamePoint).
Definition eigen_extensions.hpp:665
unsigned Precision(Eigen::MatrixBase< Derived > const &v)
Get the precision of an Eigen object.
Definition eigen_extensions.hpp:339
T max(T const &a, T const &b, T const &c)
Three-argument form of max.
Definition mpfr_extensions.hpp:96
System MakeHomotopy(System const &target, System const &start, std::string const &path_variable_name="", std::shared_ptr< node::Node > const &gamma=nullptr)
Form the gamma-trick straight-line homotopy H = (1-t)*target + gamma*t*start.
bool StopRequested()
Has somebody asked this process to stop?
std::string UniquePathVariableName(System const &target, std::string base="t")
Produce a path-variable name guaranteed not to collide with any variable in target.
Provides an Eigen-like NumTraits struct for querying traits of a number type.
Contains the observable base types.
Provides some outputting classes for printing results of running algorithms.
The structured output directory: durable, self-documenting records of computations (b2rec/1; ADR-0045...
Collective include file for parallelism in Bertini2.
Which software produced a record: name, version, and source commit, for the producer field of run hea...
Provides the parsers for settings in bertini2.
FullPathResult <-> track-record serialization (b2rec/1; the arc's rung 4).
Defines generic start system type.
Aggregate include for the various start systems in Bertini2.
Asking a long computation to stop, from outside it.
Numeric traits for a bertini number type: digit counts, conversions, and companion types.
Definition num_traits.hpp:57
detail::TypeList< TolerancesConfig, PostProcessingConfig, ZeroDimConfig, AutoRetrackConfig, RecordsConfig, MidPathConfig > NeededConfigs
The config types this algorithm reads (drives the reusable Python config interface).
Definition zero_dim_solve.hpp:106
typename tracking::TrackerTraits< TrackerType >::BaseComplexT BaseComplexT
The complex number type of the tracker.
Definition zero_dim_solve.hpp:103
typename tracking::TrackerTraits< TrackerType >::BaseRealT BaseRealT
The real number type of the tracker.
Definition zero_dim_solve.hpp:102
Definition config.hpp:271
Type-erased base for all nag algorithms, exposing a single Run() entry point.
Definition algorithm_base.hpp:46
Type-erased base for a zero-dimensional solve, exposing output and config entry points.
Definition zero_dim_solve.hpp:119
virtual void WriteRawSolutions(std::ostream &out) const =0
Write the raw solutions (Bertini 1.7 format) to out.
virtual void WriteSingularSolutions(std::ostream &out) const =0
Write the singular solutions (Bertini 1.7 format) to out.
virtual void WriteNonsingularSolutions(std::ostream &out) const =0
Write the nonsingular solutions (Bertini 1.7 format) to out.
virtual void ApplyParsedConfigs(std::string const &config_str)=0
Apply configuration settings parsed from a classic-input config string.
virtual void WriteRawData(std::ostream &out) const =0
Write the raw-data report to out.
virtual void WriteRealFiniteSolutions(std::ostream &out) const =0
Write the real finite solutions (Bertini 1.7 format) to out.
virtual void RecordToPath(std::string const &)
Attach a structured output directory at path (records + resume; ADR-0046).
Definition zero_dim_solve.hpp:139
virtual std::string RecordsRunIdentity() const
This solve's run id in the records (empty when not recording).
Definition zero_dim_solve.hpp:141
virtual void AppendRecordJson(std::string const &)
Append one raw record (a JSON object as text) to the attached directory; no-op when not recording.
Definition zero_dim_solve.hpp:144
virtual std::string PutRecordsDefinition(std::string const &, std::string const &, std::string const &={})
Store content as a definition of the given kind ("systems"/"configs"/ "givens"), optionally labeled b...
Definition zero_dim_solve.hpp:148
virtual ~AnyZeroDim()=default
virtual void WriteFiniteSolutions(std::ostream &out) const =0
Write the finite solutions (Bertini 1.7 format) to out.
virtual void WriteMainData(std::ostream &out) const =0
Write the human-readable main-data report to out.
Configuration for auto-retracking paths flagged as crossed.
Definition config.hpp:90
unsigned precision_
The ambient default precision at solve entry.
Definition zero_dim_solve.hpp:668
~ScopedSessionState()
Restore it, whatever the solve did in between.
Definition zero_dim_solve.hpp:679
ScopedSessionState(ScopedSessionState const &)=delete
Non-copyable.
ScopedSessionState & operator=(ScopedSessionState const &)=delete
Non-assignable.
ScopedSessionState()
Capture the ambient session state.
Definition zero_dim_solve.hpp:673
records::DrawStream stream_
The calling thread's pinned draw stream at entry.
Definition zero_dim_solve.hpp:670
std::mt19937 engine_
The calling thread's legacy engine state at entry.
Definition zero_dim_solve.hpp:669
The continuation primitive: given a homotopy + a source of start points, track each path through the ...
Definition zero_dim_solve.hpp:546
SolnCont< Vec< BaseComplexT > > RealSolutions(bool user_coords=true, bool merge_multiplicities=false) const
The real finite solutions (is_real applies the configured tolerance).
Definition zero_dim_solve.hpp:1341
const auto & EndgameBoundarySolutions() const
Get the solutions as computed at the endgame boundary.
Definition zero_dim_solve.hpp:1535
C SystemT
Definition zero_dim_solve.hpp:550
NumErrorT DefaultPointMatchTolerance() const
The default point-match tolerance for MetadataForPoint / CoincidentMetadataForPoint.
Definition zero_dim_solve.hpp:1411
void TallyStoppedSolve(std::vector< SolnIndT > const &dispatched)
After dispatching paths, work out whether this solve was cut short, and say so.
Definition zero_dim_solve.hpp:2953
const auto & MidpathRetrackTol() const
Definition zero_dim_solve.hpp:979
void ClassifyFiniteAndReal()
Classify each successful endpoint as finite/infinite, and (when finite) real.
Definition zero_dim_solve.hpp:2244
detail::Configured< typename AlgoTraits< HomotopySolver< A, B, C > >::NeededConfigs > Config
Definition zero_dim_solve.hpp:576
SolutionMetaData< BaseComplexT > SolutionMetaDataT
Definition zero_dim_solve.hpp:589
std::vector< boost::json::object > records_start_refs_
Definition zero_dim_solve.hpp:3027
void ComputePostTrackMetadata()
Populates the result_ member, with the post-processed results of the zero dim solve.
Definition zero_dim_solve.hpp:2226
const auto & SolutionsInternalCoords() const
Get the computed solutions in the solver's internal coordinates: homogenized, and lying on the target...
Definition zero_dim_solve.hpp:1296
bool stopped_early_
Definition zero_dim_solve.hpp:3033
void SetMidpath(MidPathConfig const &mp)
Apply a configuration to the midpath (path-crossing) checker.
Definition zero_dim_solve.hpp:1019
SolnCont< Vec< BaseComplexT > > SolutionsWhere(Pred pred, bool user_coords=true, bool merge_multiplicities=false) const
Select the solution points whose parallel metadata satisfies a predicate.
Definition zero_dim_solve.hpp:1309
std::string PutRecordsDefinition(std::string const &content, std::string const &kind, std::string const &label={}) override
Store a definition of the given kind (optional role label in the filename) in the attached directory ...
Definition zero_dim_solve.hpp:2552
void MaybeAttachAmbientRecords()
Attach the ambient output directory (manager rank only; workers never touch the records).
Definition zero_dim_solve.hpp:2626
void SetToEndgame(T const &t)
Set a configuration struct of type T on the endgame.
Definition zero_dim_solve.hpp:1123
bool records_run_resumed_
Definition zero_dim_solve.hpp:3030
SolnCont< EGBoundaryMetaDataT > solutions_at_endgame_boundary_
computed data
Definition zero_dim_solve.hpp:3092
PostProcessingConfig PostProcessing
Definition zero_dim_solve.hpp:583
const T & Get() const
Retrieve a stored configuration struct by type (inherited from Configured).
Definition configured.hpp:94
static Vec< NumErrorT > EndpointSingularValues(SystemType const &sys, Vec< BaseComplexT > const &endpoint)
The singular values of the system's Jacobian at an endpoint, largest first.
Definition zero_dim_solve.hpp:2378
unsigned long long NumPathsNeverStarted() const
How many paths the last Solve() never began, because it was stopped.
Definition zero_dim_solve.hpp:2610
NumErrorT midpath_retrack_tolerance_
Definition zero_dim_solve.hpp:3073
std::shared_ptr< records::OutputDirectory > records_
The attached output directory (null = not recording).
Definition zero_dim_solve.hpp:3025
void DeclareFiniteSolutionsResult()
Auto-declare this run's finite solutions as a result record and render the derived views – "what were...
Definition zero_dim_solve.hpp:2565
const TrackerType & GetTracker() const
Gets the tracker.
Definition zero_dim_solve.hpp:1064
B endgame_
Definition zero_dim_solve.hpp:3086
unsigned long long num_recalled_
Definition zero_dim_solve.hpp:3031
AutoRetrackConfig AutoRetrack
Definition zero_dim_solve.hpp:585
std::reference_wrapper< const C > homotopy_
Definition zero_dim_solve.hpp:603
std::string const & RecordsRunId() const
This solve's run id in the records (empty when not recording).
Definition zero_dim_solve.hpp:2613
void StoreFullPathResult(parallel::FullPathResult< BaseComplexT > const &r)
Install a whole-path result (from PackFullPathResult) into the shared result arrays.
Definition zero_dim_solve.hpp:2463
SolnCont< Vec< BaseComplexT > > NonsingularSolutions(bool user_coords=true, bool merge_multiplicities=false) const
The nonsingular finite solutions (simple, well-conditioned roots).
Definition zero_dim_solve.hpp:1348
const EndgameType & GetEndgame() const
Gets the endgame.
Definition zero_dim_solve.hpp:1098
static NumErrorT SpectralConditionNumberOf(Vec< NumErrorT > const &singular_values)
The spectral condition number from a spectrum: largest over smallest singular value.
Definition zero_dim_solve.hpp:2397
SolutionMetaDataT MetadataForPoint(Vec< BaseComplexT > const &point, NumErrorT tol, bool user_coords=true, bool representatives_only=true) const
The metadata of the solution matching point – the cluster REPRESENTATIVE (issue #302).
Definition zero_dim_solve.hpp:1451
EGBoundaryMetaData< BaseComplexT > EGBoundaryMetaDataT
Definition zero_dim_solve.hpp:588
SolnCont< SolutionMetaDataT > solution_final_metadata_
Definition zero_dim_solve.hpp:3096
static NumErrorT EndpointSpectralConditionNumber(SystemType const &sys, Vec< BaseComplexT > const &endpoint)
The spectral-norm condition number of the system's Jacobian at an endpoint.
Definition zero_dim_solve.hpp:2362
const SystemType & TargetSystem() const
Definition zero_dim_solve.hpp:624
SolnCont< Vec< BaseComplexT > > InfiniteSolutions(bool user_coords=true) const
The solutions at infinity: endpoints not classified finite (is_finite is false) – the complement of F...
Definition zero_dim_solve.hpp:1384
void DefaultSetup()
setup functions
Definition zero_dim_solve.hpp:927
std::reference_wrapper< const StartSystemBaseT > start_system_
Definition zero_dim_solve.hpp:602
void ReadSolveTimeoutAsAnInterrupt(SuccessCode &code, std::chrono::steady_clock::time_point path_start) const
A path the WHOLE-SOLVE budget cut off reads as interrupted, not as over its own budget.
Definition zero_dim_solve.hpp:3056
virtual SystemType const & RecordsTargetSystem() const
The system the records name as this solve's TARGET: what the user asked about.
Definition zero_dim_solve.hpp:2541
unsigned long long NumPathsRecalled() const
How many paths the last Solve() recalled from records instead of computing.
Definition zero_dim_solve.hpp:2595
std::vector< SolnIndT > RecallRecordedPaths(std::vector< SolnIndT > const &all_indices)
Recall recorded paths into the solver's state and return the indices still to compute.
Definition zero_dim_solve.hpp:2876
void ResetSystems(SystemType const &hom, StartSystemBaseT const &start, SystemType const &target)
Re-seat the system references (used after an MPI broadcast re-materializes the owned systems).
Definition zero_dim_solve.hpp:608
const T & GetFromEndgame() const
Get a configuration struct of type T from the endgame.
Definition zero_dim_solve.hpp:1116
void DefaultTrackerSetup()
Takes the default action to set up the zero dim algorithm with the default constructed tracker.
Definition zero_dim_solve.hpp:1030
std::shared_ptr< records::OutputDirectory > const & Records() const
The attached output directory (null when not recording).
Definition zero_dim_solve.hpp:2586
void ComputeMultiplicities()
Cluster identical endpoints to compute multiplicities.
Definition zero_dim_solve.hpp:2282
MidpathChecker< BaseRealT, BaseComplexT, EGBoundaryMetaData< BaseComplexT > > MidpathType
Definition zero_dim_solve.hpp:594
unsigned long long num_start_points_
Number of start points the start system produces.
Definition zero_dim_solve.hpp:3072
void ApplyParsedConfigs(std::string const &config_str) override
Apply configuration settings parsed from a classic-input config string.
Definition zero_dim_solve.hpp:3431
std::string records_start_identity_
Definition zero_dim_solve.hpp:3028
void RecordCompletedPath(parallel::FullPathResult< BaseComplexT > const &r)
Emit the path record for one completed path into the run's results file (called from StoreFullPathRes...
Definition zero_dim_solve.hpp:2982
void SetStartPointPrecision(unsigned p)
Set the precision at which start points are computed.
Definition zero_dim_solve.hpp:990
SolnCont< Vec< BaseComplexT > > solutions_user_coords_
Definition zero_dim_solve.hpp:3094
void AppendEndgameConfigEncodings(std::ostringstream &text, detail::TypeList< EGConfTs... >) const
Append the canonical encodings of the endgame's configs (its AlgoTraits::NeededConfigs,...
Definition zero_dim_solve.hpp:2734
TrackerType & GetTracker()
Gets the tracker.
Definition zero_dim_solve.hpp:1074
void EnsureRunRecorded()
Ensure this solve's run header is on record (appending it if absent) and set the run id.
Definition zero_dim_solve.hpp:2745
void DefaultSettingsSetup()
Fills the tolerances and retrack settings from default values.
Definition zero_dim_solve.hpp:953
bertini::start_system::StartSystem StartSystemBaseT
Definition zero_dim_solve.hpp:553
unsigned start_point_precision_
Definition zero_dim_solve.hpp:3075
void SetMidpathRetrackTol(NumErrorT const &rt)
Set the tolerance used when re-tracking paths flagged by the midpath check.
Definition zero_dim_solve.hpp:973
ZeroDimConfig ZeroDimConf
Definition zero_dim_solve.hpp:584
virtual ~HomotopySolver()=default
bool WasStoppedEarly() const
Was the last Solve() stopped before it finished?
Definition zero_dim_solve.hpp:2607
void AppendRecordJson(std::string const &record_json) override
Append a raw JSON record to the attached directory (no-op if none).
Definition zero_dim_solve.hpp:2544
NumErrorT SamePointTolerance() const
The same-point (clustering) tolerance: final_tolerance * same_point_tolerance_multiplier.
Definition zero_dim_solve.hpp:1425
void DefaultSystemSetup()
Read off the number of start points the (already-built) start system will produce.
Definition zero_dim_solve.hpp:941
MidpathCheckReport midpath_report_
populated by EGBoundaryAction; exposed via EndgameBoundaryMetadata()
Definition zero_dim_solve.hpp:3074
void SetRecordedStartProvenance(std::vector< boost::json::object > refs, std::string start_identity)
Declare where this solve's start points came from, for the records (chains and givens).
Definition zero_dim_solve.hpp:2652
void RecordToPath(std::string const &path) override
Attach an output directory by path (the AnyZeroDim polymorphic hook).
Definition zero_dim_solve.hpp:2523
SolveReport Report() const
A concise summary of the solve: how every path ended, by category, and whether any path was lost.
Definition zero_dim_solve.hpp:1558
typename tracking::TrackerTraits< A >::BaseComplexT BaseComplexT
Definition zero_dim_solve.hpp:567
const MidpathCheckReport & EndgameBoundaryMetadata() const
Get the report from the midpath (path-crossing) check performed at the endgame boundary: how many cro...
Definition zero_dim_solve.hpp:1547
bool recalling_
True while replaying recorded paths (suppresses re-emission).
Definition zero_dim_solve.hpp:3029
typename tracking::TrackerTraits< A >::BaseRealT BaseRealT
Definition zero_dim_solve.hpp:568
void WriteRawSolutions(std::ostream &out) const override
Write the raw solutions (Bertini 1.7 format) to out.
Definition zero_dim_solve.hpp:3400
TolerancesConfig Tolerances
Definition zero_dim_solve.hpp:582
const SystemType & Homotopy() const
Definition zero_dim_solve.hpp:628
bool SolveDeadlinePassed() const
Whether the whole-solve wall-clock budget has run out.
Definition zero_dim_solve.hpp:3037
bool ObservableIsA(std::type_index t) const override
Whether this observable may be observed as the given type.
Definition zero_dim_solve.hpp:558
void SetEndgame(EndgameType const &new_endgame)
endgame specific stuff
Definition zero_dim_solve.hpp:1088
const StartSystemBaseT & StartSystem() const
Definition zero_dim_solve.hpp:626
tracking::PathPrecisionRecorder< TrackerType > path_prec_
observers used during tracking
Definition zero_dim_solve.hpp:3081
void WriteFiniteSolutions(std::ostream &out) const override
Write the finite solutions (Bertini 1.7 format) to out.
Definition zero_dim_solve.hpp:3372
void WriteSingularSolutions(std::ostream &out) const override
Write the singular solutions (Bertini 1.7 format) to out.
Definition zero_dim_solve.hpp:3393
B EndgameT
Definition zero_dim_solve.hpp:549
unsigned long long NumPaths() const
How many paths there are to answer: the start system's start point count.
Definition zero_dim_solve.hpp:2592
std::string RecordsRunIdentity() const override
This solve's run id (the AnyZeroDim polymorphic hook).
Definition zero_dim_solve.hpp:2529
unsigned StartPointPrecision() const
Definition zero_dim_solve.hpp:997
typename tracking::TrackerTraits< A >::PrecisionConfig PrecisionConfig
Definition zero_dim_solve.hpp:570
A TrackerT
Definition zero_dim_solve.hpp:548
void Solve()
the main functions
Definition zero_dim_solve.hpp:1145
void WriteNonsingularSolutions(std::ostream &out) const override
Write the nonsingular solutions (Bertini 1.7 format) to out.
Definition zero_dim_solve.hpp:3386
HomotopySolver(SystemType const &target, StartSystemBaseT const &start, SystemType const &homotopy)
constructors
Definition zero_dim_solve.hpp:644
void WriteRawData(std::ostream &out) const override
Write the raw-data report to out.
Definition zero_dim_solve.hpp:3365
const auto & SolutionsUserCoords() const
Get the computed solutions, in the coordinates of the user's original variables.
Definition zero_dim_solve.hpp:1263
A tracker_
Definition zero_dim_solve.hpp:3085
bool start_point_precision_set_by_user_
Definition zero_dim_solve.hpp:3076
void DefaultMidpathSetup()
call this after setting up the tolerances, etc.
Definition zero_dim_solve.hpp:1006
std::string records_run_id_
This solve's run id in the records (ask hash prefix).
Definition zero_dim_solve.hpp:3026
void RecordTo(std::shared_ptr< records::OutputDirectory > directory)
Attach a structured output directory: this solve records to (and memoizes/resumes from) it.
Definition zero_dim_solve.hpp:2515
bool solutions_user_coords_fresh_
Whether the user-coordinate cache is up to date.
Definition zero_dim_solve.hpp:3095
boost::json::object RecordsAsk() const
The ask identity of this solve: op + tracker/endgame kind (stable record names, never typeid) + targe...
Definition zero_dim_solve.hpp:2707
SolnCont< Vec< BaseComplexT > > FiniteSolutions(bool user_coords=true, bool merge_multiplicities=false) const
The finite solutions: successful, finite endpoints that ARE solutions of the target (is_finite applie...
Definition zero_dim_solve.hpp:1334
typename SolnCont< BaseComplexT >::size_type SolnIndT
Definition zero_dim_solve.hpp:572
EndgameType & GetEndgame()
Gets the endgame.
Definition zero_dim_solve.hpp:1108
void SetTracker(TrackerType const &new_tracker)
Sets the tracker to one you supply to this function.
Definition zero_dim_solve.hpp:1053
parallel::FullPathResult< BaseComplexT > PackFullPathResult(SolnIndT idx) const
Pack everything computed for one whole path into a single result value (thread/MPI handoff).
Definition zero_dim_solve.hpp:2421
void Run() override
Main Run() function provided for calling from the blackbox mode.
Definition zero_dim_solve.hpp:692
std::vector< SolutionMetaDataT > CoincidentMetadataForPoint(Vec< BaseComplexT > const &point, NumErrorT tol, bool user_coords=true) const
All metadata records for the paths coincident with point (issue #302).
Definition zero_dim_solve.hpp:1503
void WriteMainData(std::ostream &out) const override
Write the human-readable main-data report to out.
Definition zero_dim_solve.hpp:3358
static bool AbandonmentIsReusable(parallel::FullPathResult< BaseComplexT > const &r, double current_limit)
Under RecallPolicy::Completed, may this recorded path stand in for tracking it?
Definition zero_dim_solve.hpp:2856
std::string CanonicalSettingsText() const
The canonical text of this solver's FULL settings: the algorithm-level configs, then the tracker's ow...
Definition zero_dim_solve.hpp:2679
std::reference_wrapper< const C > target_system_
Definition zero_dim_solve.hpp:601
bertini::start_system::StartSystem StartSystemT
Definition zero_dim_solve.hpp:552
SolnCont< Vec< BaseComplexT > > Nonsolutions(bool user_coords=true) const
The NONSOLUTIONS: finite, successful endpoints that are NOT solutions of the target system – the extr...
Definition zero_dim_solve.hpp:1367
unsigned long long num_never_started_
Definition zero_dim_solve.hpp:3070
void ClassifySingular()
Classify each successful endpoint as singular or not.
Definition zero_dim_solve.hpp:2326
std::optional< std::chrono::steady_clock::time_point > solve_deadline_
Definition zero_dim_solve.hpp:3034
const auto & SolutionMetadata() const
Get the metadat associated with the final computed solutions.
Definition zero_dim_solve.hpp:1392
void WriteRealFiniteSolutions(std::ostream &out) const override
Write the real finite solutions (Bertini 1.7 format) to out.
Definition zero_dim_solve.hpp:3379
SolnCont< Vec< BaseComplexT > > SingularSolutions(bool user_coords=true, bool merge_multiplicities=false) const
The singular finite solutions (multiple or ill-conditioned roots).
Definition zero_dim_solve.hpp:1355
SolnCont< Vec< BaseComplexT > > solutions_post_endgame_
Definition zero_dim_solve.hpp:3093
MidpathType midpath_
The midpath (path-crossing) checker.
Definition zero_dim_solve.hpp:3087
virtual void PostEGAction()
Action taken after the endgame: compute post-track metadata (ZeroDimSolver overrides to also filter e...
Definition zero_dim_solve.hpp:2214
Configuration for the midpath (path-crossing) check.
Definition config.hpp:80
Summary of what the midpath (path-crossing) check found at the endgame boundary, and what the algorit...
Definition zero_dim_solve.hpp:404
unsigned num_resolve_attempts
How many re-track attempts were actually performed.
Definition zero_dim_solve.hpp:407
bool passed
Did the final midpath check pass (no crossings remained)?
Definition zero_dim_solve.hpp:405
std::vector< unsigned long long > crossed_path_indices
Indices of the paths flagged as crossed on the first check.
Definition zero_dim_solve.hpp:408
unsigned num_crossings_detected
Number of crossed paths found on the first check, before any re-tracking.
Definition zero_dim_solve.hpp:406
Detects whether any solution paths crossed during tracking, before the endgame.
Definition midpath_check.hpp:52
Configuration for post-processing solutions (reality/finiteness/singularity classification).
Definition config.hpp:140
How a recording algorithm uses the records it finds: not what to compute, but what already-recorded w...
Definition config.hpp:197
A concise, human-readable summary of a zero-dimensional solve: how every path ended up,...
Definition zero_dim_solve.hpp:436
unsigned long long num_singular
finite solutions flagged singular (multiple / ill-conditioned)
Definition zero_dim_solve.hpp:442
unsigned max_precision_used
highest working precision any path needed (digits)
Definition zero_dim_solve.hpp:447
unsigned long long num_finite_solutions
DISTINCT finite solutions (round of sum 1/multiplicity).
Definition zero_dim_solve.hpp:438
MidpathCheckReport midpath
the path-crossing check outcome
Definition zero_dim_solve.hpp:448
unsigned long long num_diverged
paths ending at infinity (Success & !finite, GoingToInfinity, or SecurityMaxNormReached truncation)
Definition zero_dim_solve.hpp:440
unsigned long long num_real
finite solutions flagged real
Definition zero_dim_solve.hpp:443
bool all_paths_resolved
num_failed==0 AND no unresolved crossings: the solve is trustworthy
Definition zero_dim_solve.hpp:449
std::map< SuccessCode, unsigned long long > failures_by_reason
histogram of the failed paths' SuccessCodes
Definition zero_dim_solve.hpp:445
double max_condition_number
largest condition number among finite solutions
Definition zero_dim_solve.hpp:446
unsigned long long num_failed
paths the tracker could not resolve (no solution, no clean divergence)
Definition zero_dim_solve.hpp:441
unsigned long long num_finite_endpoints
raw count of finite, successful endpoints
Definition zero_dim_solve.hpp:439
unsigned long long num_nonsolutions
finite endpoints that are NOT solutions of the target (nonsolutions of an over-determined,...
Definition zero_dim_solve.hpp:444
unsigned long long num_paths_tracked
total paths tracked (the Bezout / start count)
Definition zero_dim_solve.hpp:437
Newton and path-tracking tolerances.
Definition config.hpp:69
Top-level configuration for a zero-dimensional solve (times, precision, threading).
Definition config.hpp:212
unsigned initial_ambient_precision
Initial ambient (working) precision for the solve.
Definition config.hpp:215
zero_dim_detail::OwnedHomotopy< SystemType > OwnedT
The system-owning base.
Definition zero_dim_solve.hpp:3256
void PostEGAction() override
After the engine classifies the endpoints, discard the extraneous solutions that squaring an over-det...
Definition zero_dim_solve.hpp:3294
HomotopySolver< TrackerType, EndgameType, SystemType > EngineT
The continuation-engine base.
Definition zero_dim_solve.hpp:3257
Mat< complex_mp > const & RandomizationMatrix() const
The randomization matrix used to square up (empty if the system was already square).
Definition zero_dim_solve.hpp:3279
typename OwnedT::FactoryT FactoryT
The start-system factory type.
Definition zero_dim_solve.hpp:3258
ZeroDimSolver(SystemType const &target, FactoryT factory=bertini::start_system::MakeStartFactory< bertini::start_system::TotalDegreeBinomial, SystemType >())
Build the start system + homotopy from target, then construct the engine over them.
Definition zero_dim_solve.hpp:3266
bool WasRandomized() const
Whether the supplied system was over-determined and squared-up by randomization.
Definition zero_dim_solve.hpp:3277
SystemType const & RecordsTargetSystem() const override
The records name the PRISTINE user-supplied system as this solve's target (see HomotopySolver::Record...
Definition zero_dim_solve.hpp:3274
Owns and builds the target / start system / homotopy for a zero-dim solve.
Definition zero_dim_solve.hpp:3118
OwnedHomotopy(SystemType const &target, FactoryT factory, std::string const &path_variable_name)
Build and own the target, start system, and homotopy from a target system and factory.
Definition zero_dim_solve.hpp:3123
SystemType const & BuiltTarget() const
Definition zero_dim_solve.hpp:3138
FactoryT owned_factory_
The start-system factory used to build the start system.
Definition zero_dim_solve.hpp:3154
SystemType const & UserTarget() const
Definition zero_dim_solve.hpp:3143
SystemType owned_target_
The owned (cloned, prepared) target system.
Definition zero_dim_solve.hpp:3151
bertini::start_system::StartSystem StartSystemBaseT
The start-system base type.
Definition zero_dim_solve.hpp:3119
static void PrepareTarget(SystemType &target)
Homogenize and auto-patch the (already square) target system in place.
Definition zero_dim_solve.hpp:3232
Mat< complex_mp > randomization_matrix_
The exact coefficient matrix used to square up the system.
Definition zero_dim_solve.hpp:3162
void ConsistencyCheck() const
Reject targets that cannot have isolated solutions for structural reasons.
Definition zero_dim_solve.hpp:3167
std::shared_ptr< StartSystemBaseT > owned_start_
The owned start system.
Definition zero_dim_solve.hpp:3152
void RankCheck() const
Reject a square target whose solution set is still positive-dimensional.
Definition zero_dim_solve.hpp:3212
StartSystemBaseT const & BuiltStart() const
Definition zero_dim_solve.hpp:3145
void SquareUp()
If the target is over-determined (more equations than the affine dimension), replace it with n generi...
Definition zero_dim_solve.hpp:3191
SystemType original_natural_target_
The original (natural, un-homogenized) target, kept to discard extraneous solutions.
Definition zero_dim_solve.hpp:3161
bool was_randomized_
Whether an over-determined target was squared up by randomization.
Definition zero_dim_solve.hpp:3160
SystemType user_target_
The target exactly as supplied (pristine; the records' target identity).
Definition zero_dim_solve.hpp:3150
bertini::start_system::StartSystemFactory< SystemType > FactoryT
The start-system factory type.
Definition zero_dim_solve.hpp:3120
SystemType owned_homotopy_
The owned homotopy.
Definition zero_dim_solve.hpp:3153
SystemType const & BuiltHomotopy() const
Definition zero_dim_solve.hpp:3147
std::string Hex() const
The digest as 64 lowercase hex characters (the cross-session interchange form).
A basic typelist, in the style of Modern C++ Design, but using variadic templates.
Definition typelist.hpp:42
Definition config.hpp:176
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
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
Work item for the speculative-full-path model: a path index plus its start point.
Definition path_result.hpp:62
Settings governing the Newton corrector's iteration bounds.
Definition config.hpp:119
Settings governing step-size adjustment during tracking.
Definition config.hpp:96
The thresholds a tracker judges a path against: close enough, and too big.
Definition config.hpp:142
Trait lookup mapping a tracker type to its numeric types, event-emitter type, precision config,...
Definition config.hpp:387
Includes all files for tracking in Bertini2.
Contains the visitable base types.