28#ifndef BERTINI_BASE_TRACKER_HPP
29#define BERTINI_BASE_TRACKER_HPP
163 typename TrackerTraits< D >::NeededConfigs
170 using ComplexT = BaseComplexT;
171 using RealT = BaseRealT;
230 NumErrorT const& path_truncation_threshold,
234 Setup(new_predictor_choice, tracking_tolerance, stepping, newton);
253 if (tracking_tolerance <= 0)
254 throw std::runtime_error(
"tracking tolerance must be strictly positive");
257 settings.tracking_tolerance = tracking_tolerance;
267 throw std::runtime_error(
"truncation threshold must be strictly positive");
270 settings.path_truncation_threshold = tol;
305 ComplexT
const& start_time, ComplexT
const& endtime,
310 throw std::runtime_error(
"start point size must match the number of variables in the system to be tracked");
315 SuccessCode initialization_code = TrackerLoopInitialization(start_time, endtime, start_point);
319 return initialization_code;
349 SuccessCode pre_iteration_code = PreIterationCheck();
353 return pre_iteration_code;
389 CopySolution(solution_at_endtime);
410 Vec<C> const& start_point, C
const& current_time)
const
414 return this->AsDerived().RefineImpl(new_space, start_point, current_time);
435 Vec<C> const& start_point, C
const& current_time,
NumErrorT const& tolerance,
unsigned max_iterations)
const
439 return this->AsDerived().RefineImpl(new_space, start_point, current_time, tolerance, max_iterations);
453 settings.predictor = new_predictor_choice;
571 template <
typename Rep,
typename Period>
574 using clock = std::chrono::steady_clock;
636 const D& AsDerived()
const
638 return static_cast<const D&
>(*this);
649 SuccessCode TrackerLoopInitialization(ComplexT
const& start_time, ComplexT
const& end_time,
Vec<ComplexT> const& start_point)
const = 0;
674 void CopySolution(
Vec<ComplexT> & solution_at_endtime)
const = 0;
697 template <
typename ComplexT>
839 using TupOfVec =
typename NeededTypes::ToTupleOfVec;
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
The fundamental polynomial system class for Bertini2.
Definition system.hpp:106
size_t NumVariables() const
Get the total number of variables in this system, including homogenizing variables.
void ReinitializeInitialStepSize(bool should_reinitialize_stepsize)
Switch resetting of initial step size to that of the stepping settings.
Definition base_tracker.hpp:606
predict::ExplicitRKPredictor predictor_
Definition base_tracker.hpp:815
unsigned num_successful_steps_cumulative_
Definition base_tracker.hpp:801
ComplexT delta_t_
Definition base_tracker.hpp:826
unsigned predictor_order_
Definition base_tracker.hpp:816
typename NeededTypes::ToTupleOfVec TupOfVec
Definition base_tracker.hpp:839
Tracker(System const &sys)
Construct a tracker associated to a system to be tracked.
Definition base_tracker.hpp:181
bool infinite_path_truncation_
Definition base_tracker.hpp:789
SteppingConfig Stepping
Definition base_tracker.hpp:176
Predictor GetPredictor() const
Query the currently set predictor.
Definition base_tracker.hpp:462
void Setup(Predictor new_predictor_choice, NumErrorT const &tracking_tolerance, SteppingConfig const &stepping, NewtonConfig const &newton)
Get the tracker set up for tracking.
Definition base_tracker.hpp:196
auto DeltaT() const
Get the current time-step increment (delta t).
Definition base_tracker.hpp:903
auto InfiniteTruncation()
Query whether the going-to-infinity path truncation check is enabled.
Definition base_tracker.hpp:885
void SetInfiniteTruncationTolerance(NumErrorT const &tol)
Set the threshold beyond which a path is judged to be going to infinity (and truncated).
Definition base_tracker.hpp:264
virtual void PostTrackCleanup() const
Function to be called before exiting the tracker loop.
Definition base_tracker.hpp:712
const System & GetSystem() const
Definition base_tracker.hpp:507
unsigned num_successful_steps_since_stepsize_increase_
Definition base_tracker.hpp:837
virtual Vec< ComplexT > CurrentPoint() const =0
Get the current space point of the track (in the derived tracker's working type).
const T & Get() const
Bring the configuration getter into scope, for querying config settings.
Definition configured.hpp:94
void SetSystem(const System &new_sys)
get a const reference to the system.
Definition base_tracker.hpp:497
SuccessCode Refine(Vec< C > &new_space, Vec< C > const &start_point, C const ¤t_time, NumErrorT const &tolerance, unsigned max_iterations) const
Refine a point to a given tolerance.
Definition base_tracker.hpp:434
void SetPredictor(Predictor new_predictor_choice)
Change tracker to use a predictor.
Definition base_tracker.hpp:450
virtual void OnInfiniteTruncation() const =0
Hook invoked when a path is truncated for going to infinity; derived types react here.
unsigned digits_final_
Definition base_tracker.hpp:822
unsigned num_consecutive_successful_steps_
Definition base_tracker.hpp:798
void SetInfiniteTruncation(bool b)
Turn the going-to-infinity path truncation check on or off.
Definition base_tracker.hpp:879
correct::NewtonCorrector corrector_
Definition base_tracker.hpp:818
auto CurrentTime() const
Get the current time value of the track.
Definition base_tracker.hpp:897
void SyncSettings() const
Bring state derived from the settings in line with the settings.
Definition base_tracker.hpp:484
ComplexT endtime_
Definition base_tracker.hpp:824
NumErrorT LatestNormOfStep() const
Get the norm of the Newton step from the most recent predict/correct step.
Definition base_tracker.hpp:873
std::optional< std::chrono::steady_clock::time_point > MaxWallClockTime() const
The wall-clock deadline in force, if any.
Definition base_tracker.hpp:585
unsigned CumulativeFailedSteps() const
Failed steps since the last ResetCumulativeStepCounts, across every TrackPath call in between.
Definition base_tracker.hpp:544
NewtonConfig Newton
Definition base_tracker.hpp:177
virtual unsigned CurrentPrecision() const =0
Get the current working precision of the tracker.
unsigned NumTotalStepsTaken() const
See how many steps have been taken.
Definition base_tracker.hpp:517
virtual void OnStepFail() const =0
Hook invoked after a failed tracker iteration; derived types update their own state here.
virtual void ResetCounters() const =0
Reset counters used during tracking.
NumErrorT LatestErrorEstimate() const
Get the error estimate from the most recent predict/correct step.
Definition base_tracker.hpp:866
TupOfVec current_space_
Definition base_tracker.hpp:842
SuccessCode step_success_code_
Definition base_tracker.hpp:832
unsigned CumulativeSuccessfulSteps() const
Successful steps since the last ResetCumulativeStepCounts, across every TrackPath call in between.
Definition base_tracker.hpp:538
unsigned num_failed_steps_taken_
Definition base_tracker.hpp:800
RealT current_stepsize_
Definition base_tracker.hpp:827
auto InfiniteTruncationTolerance() const
Get the currently set infinite-truncation (path) threshold.
Definition base_tracker.hpp:628
virtual void OnStepSuccess() const =0
Hook invoked after a successful tracker iteration; derived types update their own state here.
typename TrackerTraits< AMPTracker >::PrecisionConfig PrecConf
Definition base_tracker.hpp:178
void ClearMaxWallClockTime() const
Remove the wall-clock deadline; tracking is unlimited again.
Definition base_tracker.hpp:579
unsigned num_steps_since_last_condition_number_computation_
Definition base_tracker.hpp:836
void Setup(Predictor new_predictor_choice, NumErrorT const &tracking_tolerance, NumErrorT const &path_truncation_threshold, SteppingConfig const &stepping, NewtonConfig const &newton)
Get the tracker set up for tracking, and set its truncation threshold too.
Definition base_tracker.hpp:228
bool reinitialize_stepsize_
Definition base_tracker.hpp:790
TupOfVec temporary_space_
Definition base_tracker.hpp:844
unsigned num_failed_steps_cumulative_
Definition base_tracker.hpp:802
void SetMaxWallClockTime(std::chrono::steady_clock::time_point deadline) const
Give the tracker a wall-clock deadline: a point in time after which any track in progress is abandone...
Definition base_tracker.hpp:561
void IncrementBaseCountersFail() const
Increment and reset counters after a failed TrackerIteration().
Definition base_tracker.hpp:761
typename NeededTypes::ToTupleOfReal TupOfReal
Definition base_tracker.hpp:840
void ResetCumulativeStepCounts() const
Zero the cumulative step counts.
Definition base_tracker.hpp:531
unsigned num_successful_steps_taken_
Definition base_tracker.hpp:797
TupOfVec tentative_space_
Definition base_tracker.hpp:843
auto TrackingTolerance() const
Get the currently set tracking tolerance.
Definition base_tracker.hpp:614
void RefreshConditionDirection()
(Re)draw the random probe direction used for condition-number estimation.
Definition base_tracker.hpp:284
virtual ~Tracker()=default
RealT next_stepsize_
Definition base_tracker.hpp:831
virtual SuccessCode CheckGoingToInfinity() const =0
Check whether the path is going to infinity, as it tracks.
unsigned NumVariables() const
Get the number of variables in the system being tracked.
Definition base_tracker.hpp:891
std::reference_wrapper< const System > tracked_system_
Definition base_tracker.hpp:787
StepMetadata last_step_
Definition base_tracker.hpp:850
void SetTrackingTolerance(NumErrorT const &tracking_tolerance)
Set how tightly to track the path.
Definition base_tracker.hpp:251
unsigned num_consecutive_failed_steps_
Definition base_tracker.hpp:799
detail::Configured< typename TrackerTraits< AMPTracker >::NeededConfigs > Config
Definition base_tracker.hpp:175
SuccessCode TrackPath(Vec< ComplexT > &solution_at_endtime, ComplexT const &start_time, ComplexT const &endtime, Vec< ComplexT > const &start_point) const
Track a start point through time, from a start time to a target time.
Definition base_tracker.hpp:304
SuccessCode Refine(Vec< C > &new_space, Vec< C > const &start_point, C const ¤t_time) const
Refine a point to tolerance implicitly internally set.
Definition base_tracker.hpp:409
void ResetCountersBase() const
Reset the base-class step counters (successes, failures, consecutive runs, total) to zero.
Definition base_tracker.hpp:727
void SetStepSize(RealT const &new_stepsize) const
Set how large the stepsize should be.
Definition base_tracker.hpp:595
void SetMaxWallClockDuration(std::chrono::duration< Rep, Period > duration) const
Give the tracker a wall-clock budget counted from now: SetMaxWallClockTime(now + duration).
Definition base_tracker.hpp:572
unsigned DigitsTrackingTolerance() const
The number of digits tracking to the current tolerance demands, condition number notwithstanding.
Definition base_tracker.hpp:622
std::optional< std::chrono::steady_clock::time_point > wall_clock_deadline_
Definition base_tracker.hpp:803
NumErrorT LatestConditionNumber() const
Get the condition-number estimate from the most recent predict/correct step.
Definition base_tracker.hpp:859
void IncrementBaseCountersSuccess() const
Increment and reset counters after a successful TrackerIteration().
Definition base_tracker.hpp:742
auto CurrentStepsize() const
Get the current step size.
Definition base_tracker.hpp:909
ComplexT current_time_
Definition base_tracker.hpp:825
SuccessCode CheckGoingToInfinity() const
Check, at a given complex type, whether the current space value exceeds the truncation threshold.
Definition base_tracker.hpp:698
/class NewtonCorrector
Definition newton_corrector.hpp:46
A class which stores all the explicit single-step multi-stage ODE predictor methods.
Definition explicit_predictors.hpp:178
Contains the detail/is_template_parameter helper, for checking whether a type is a template parameter...
Logging in Bertini using Boost.Log.
Definition configIni_parse.hpp:78
Definition explicit_predictors.hpp:48
Predictor DefaultPredictor()
Get the Bertini2 default predictor.
Definition explicit_predictors.hpp:70
Definition adaptive_precision_utilities.hpp:35
Predictor
The predictor (ODE integration) method used during path tracking.
Definition config.hpp:55
bool StepFailureIsTerminal(SuccessCode c)
Whether a failed step leaves the tracker with no corrective action taken.
Definition base_tracker.hpp:72
Definition algorithm_builder.hpp:36
bool IsSymmRelDiffSmall(T const &a, T const &b, typename Eigen::NumTraits< T >::Real const &e)
Check whether two values are very close to each other.
Definition eigen_extensions.hpp:425
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
double NumErrorT
The numeric type used to hold error/tolerance magnitudes throughout Bertini2 – tracking tolerances,...
Definition num_traits.hpp:48
SuccessCode
Definition config.hpp:42
@ FailedToSelectPrecisionAndStepsize
Definition config.hpp:67
@ 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
bool StopRequested()
Has somebody asked this process to stop?
Contains the observable base types.
Includes for the suite of ODE predictors.
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
static constexpr bool value
Whether the queried type appears in the pack (base case: no).
Definition is_template_parameter.hpp:43
Settings governing the Newton corrector's iteration bounds.
Definition config.hpp:119
Settings governing step-size adjustment during tracking.
Definition config.hpp:96
mpq_rational initial_step_size
The length of the first time step when calling TrackPath. StepInitSize.
Definition config.hpp:100
Trait lookup mapping a tracker type to its numeric types, event-emitter type, precision config,...
Definition config.hpp:387
Contains the tracker/events base types.