34#include <boost/type_index.hpp>
48template <
typename EndgameT>
50{BOOST_TYPE_INDEX_REGISTER_CLASS
53using BCT =
typename EndgameT::BaseComplexT;
59 if(
auto p =
dynamic_cast<const TimeAdvanced<EmitterT>*
>(&e))
61 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"time advanced " << p->Get().LatestTime();
64 else if (
auto p =
dynamic_cast<const SampleRefined<EmitterT>*
>(&e))
66 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"refined a sample, huzzah";
71 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"advanced around the circle, to " << p->NewSample()<<
" at time " << p->NewTime();
74 else if (
auto p =
dynamic_cast<const ClosedLoop<EmitterT>*
>(&e))
76 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"closed a loop, cycle number " << p->Get().CycleNumber();
78 else if (
auto p =
dynamic_cast<const ApproximatedRoot<EmitterT>*
>(&e))
80 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"approximated the target root. approximation " << p->Get().template FinalApproximation<BCT>() <<
" with error " << p->Get().ApproximateError();
85 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"precision changed from " << p->Previous() <<
" to " << p->Next();
88 else if (
auto p =
dynamic_cast<const InEGOperatingZone<EmitterT>*
>(&e))
90 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"made it to the endgame operating zone at time " << p->Get().LatestTime();
93 else if(
auto p =
dynamic_cast<const Converged<EmitterT>*
>(&e))
95 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"converged at time " << p->Get().LatestTime() <<
" with result " << p->Get().template FinalApproximation<BCT>() <<
" and residual " << p->Get().ApproximateError();
97 else if (
auto p =
dynamic_cast<const Initializing<EmitterT>*
>(&e))
99 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"starting running " << boost::typeindex::type_id<EmitterT>().pretty_name();
103 BOOST_LOG_TRIVIAL(severity_level::debug) <<
"unprogrammed response for event of type " << boost::typeindex::type_id_runtime(e).pretty_name();
124template <
typename EndgameT>
126{BOOST_TYPE_INDEX_REGISTER_CLASS
129using BCT =
typename EndgameT::BaseComplexT;
148 if (
auto p =
dynamic_cast<const TimeAdvanced<EmitterT>*
>(&e))
151 else if (
dynamic_cast<const SampleRefined<EmitterT>*
>(&e))
157 else if (
dynamic_cast<const ClosedLoop<EmitterT>*
>(&e))
160 else if (
auto p =
dynamic_cast<const ApproximatedRoot<EmitterT>*
>(&e))
161 { ++
num_approximated_root; (void)p->Get().template FinalApproximation<BCT>(); (void)p->Get().ApproximateError(); }
163 else if (
dynamic_cast<const InEGOperatingZone<EmitterT>*
>(&e))
166 else if (
auto p =
dynamic_cast<const Converged<EmitterT>*
>(&e))
211template <
typename EndgameT>
213{BOOST_TYPE_INDEX_REGISTER_CLASS
216using BCT =
typename EndgameT::BaseComplexT;
273 else if (
auto p =
dynamic_cast<const ApproximatedRoot<EmitterT>*
>(&e))
275 approximations.push_back(p->Get().template FinalApproximation<BCT>());
281 else if (
auto p =
dynamic_cast<const TimeAdvanced<EmitterT>*
>(&e))
286 else if (
dynamic_cast<const Initializing<EmitterT>*
>(&e))
298 else if (
dynamic_cast<const SamplesRecomputedAtHigherPrecision<EmitterT>*
>(&e))
Strawman Event type, enabling polymorphism.
Definition events.hpp:57
Actual observer type, which you should derive from to extract custom information from observable type...
Definition observer.hpp:117
Advanced around the circle around target time.
Definition events.hpp:157
A new sample point on the path was computed, adding one point to the sequence of the endgame's approa...
Definition events.hpp:118
Event emitted when the endgame's working precision changes.
Definition events.hpp:220
Contains the endgames/events base types.
Logging in Bertini using Boost.Log.
Definition endgames.hpp:44
Definition algorithm_builder.hpp:36
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
ObserveResult
The result an observer returns from Observe(), telling the observable whether to keep sending it even...
Definition observer.hpp:59
@ KeepObserving
Definition observer.hpp:59
Contains the observer base types.
Counts endgame events and captures their payloads, for tests and diagnostics.
Definition observers.hpp:126
unsigned num_precision_changed
Number of precision-changed events observed.
Definition observers.hpp:139
unsigned num_closed_loop
Number of closed-loop events observed.
Definition observers.hpp:135
unsigned num_in_eg_zone
Number of in-endgame-zone events observed.
Definition observers.hpp:137
unsigned num_converged
Number of converged events observed.
Definition observers.hpp:138
BCT last_circle_time
The most-recent circle sample time captured from an event.
Definition observers.hpp:142
unsigned num_sample_refined
Number of SampleRefined events observed.
Definition observers.hpp:133
EndgameT EmitterT
The endgame type emitting the observed events.
Definition observers.hpp:128
unsigned num_events
Total number of events observed.
Definition observers.hpp:131
unsigned num_approximated_root
Number of approximated-root events observed.
Definition observers.hpp:136
typename EndgameT::BaseComplexT BCT
The boundary complex type of the observed endgame.
Definition observers.hpp:129
Vec< BCT > last_circle_point
The most-recent circle sample point captured from an event.
Definition observers.hpp:141
Vec< BCT > converged_point
The converged root point captured from a converged event.
Definition observers.hpp:143
virtual ObserveResult Observe(AnyEvent const &e) override
Observe the observable object being observed.
Definition observers.hpp:145
unsigned num_time_advanced
Number of TimeAdvanced events observed.
Definition observers.hpp:132
unsigned num_circle_advanced
Number of circle-advanced events observed.
Definition observers.hpp:134
Logs the endgame run, with gory detail.
Definition observers.hpp:50
EndgameT EmitterT
The event-emitter type.
Definition observers.hpp:52
virtual ObserveResult Observe(AnyEvent const &e) override
Observe the observable object being observed.
Definition observers.hpp:57
virtual ~GoryDetailLogger()=default
typename EndgameT::BaseComplexT BCT
The complex number type.
Definition observers.hpp:53
Collects an endgame's approach to the root as a time-indexed sequence, for callers that need to watch...
Definition observers.hpp:213
size_t NumRuns() const
Definition observers.hpp:254
std::vector< size_t > run_circle_starts
Index into circle_samples where each run's circle points begin.
Definition observers.hpp:235
std::vector< Vec< BCT > > approximations
Root approximations, from ApproximatedRoot.
Definition observers.hpp:224
std::vector< BCT > path_times
The time at which each path sample was computed.
Definition observers.hpp:219
std::vector< BCT > circle_times
The time of each circle sample.
Definition observers.hpp:222
typename EndgameT::BaseComplexT BCT
The boundary complex type of the observed endgame.
Definition observers.hpp:216
std::vector< BCT > advance_times
Times at which TimeAdvanced fired (that event carries no payload).
Definition observers.hpp:229
EndgameT EmitterT
The endgame type emitting the observed events.
Definition observers.hpp:215
size_t num_precision_increases
How many times the endgame raised its working precision (PrecisionChanged), over every run observed....
Definition observers.hpp:238
std::vector< unsigned > cycle_numbers
The endgame's cycle number at each approximation.
Definition observers.hpp:227
std::vector< Vec< BCT > > path_samples
Points on the path, from ComputedSamplePoint – the sequence.
Definition observers.hpp:218
std::vector< BCT > approximation_times
The endgame's latest time at each approximation.
Definition observers.hpp:225
void Clear()
Forget everything collected so far, so one collector can be reused across paths.
Definition observers.hpp:241
std::vector< NumErrorT > approximation_errors
The endgame's reported error at each approximation.
Definition observers.hpp:226
std::vector< size_t > run_approx_starts
Index into approximations where each run's approximations begin.
Definition observers.hpp:236
virtual ObserveResult Observe(AnyEvent const &e) override
Observe the observable object being observed.
Definition observers.hpp:259
std::vector< Vec< BCT > > circle_samples
Circle-track points, from CircleAdvanced (Cauchy only).
Definition observers.hpp:221
size_t NumSamples() const
Definition observers.hpp:257
std::vector< size_t > run_path_starts
Index into path_samples where each run's samples begin.
Definition observers.hpp:234