Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
endgames/observers.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//endgames/observers.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//endgames/observers.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with endgames/observers.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2015 - 2021 by Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22// individual authors of this file include:
23// silviana amethyst, university of wisconsin eau claire
24
25
31
32#pragma once
33
35#include "bertini2/logging.hpp"
37
38#include <boost/type_index.hpp>
39
40namespace bertini {
41
42 namespace endgame{
43
44
50template <typename EndgameT>
51struct GoryDetailLogger : public Observer<EndgameT>
52{BOOST_TYPE_INDEX_REGISTER_CLASS
53
54using EmitterT = EndgameT;
55using BCT = typename EndgameT::BaseComplexType;
56
57virtual ~GoryDetailLogger() = default;
58
59virtual void Observe(AnyEvent const& e) override
60{
61 if(auto p = dynamic_cast<const TimeAdvanced<EmitterT>*>(&e))
62 {
63 BOOST_LOG_TRIVIAL(severity_level::debug) << "time advanced " << p->Get().LatestTime();
64 }
65
66 else if (auto p = dynamic_cast<const SampleRefined<EmitterT>*>(&e))
67 {
68 BOOST_LOG_TRIVIAL(severity_level::debug) << "refined a sample, huzzah";
69 }
70
71 else if (auto p = dynamic_cast<const CircleAdvanced<EmitterT>*>(&e))
72 {
73 BOOST_LOG_TRIVIAL(severity_level::debug) << "advanced around the circle, to " << p->NewSample()<< " at time " << p->NewTime();
74 }
75
76 else if (auto p = dynamic_cast<const ClosedLoop<EmitterT>*>(&e))
77 {
78 BOOST_LOG_TRIVIAL(severity_level::debug) << "closed a loop, cycle number " << p->Get().CycleNumber();
79 }
80 else if (auto p = dynamic_cast<const ApproximatedRoot<EmitterT>*>(&e))
81 {
82 BOOST_LOG_TRIVIAL(severity_level::debug) << "approximated the target root. approximation " << p->Get().template FinalApproximation<BCT>() << " with error " << p->Get().ApproximateError();
83 }
84
85 else if (auto p = dynamic_cast<const PrecisionChanged<AMPEndgame>*>(&e))
86 {
87 BOOST_LOG_TRIVIAL(severity_level::debug) << "precision changed from " << p->Previous() << " to " << p->Next();
88 }
89
90 else if (auto p = dynamic_cast<const InEGOperatingZone<EmitterT>*>(&e))
91 {
92 BOOST_LOG_TRIVIAL(severity_level::debug) << "made it to the endgame operating zone at time " << p->Get().LatestTime();
93 }
94
95 else if(auto p = dynamic_cast<const Converged<EmitterT>*>(&e))
96 {
97 BOOST_LOG_TRIVIAL(severity_level::debug) << "converged at time " << p->Get().LatestTime() << " with result " << p->Get().template FinalApproximation<BCT>() << " and residual " << p->Get().ApproximateError();
98 }
99 else if (auto p = dynamic_cast<const Initializing<EmitterT>*>(&e))
100 {
101 BOOST_LOG_TRIVIAL(severity_level::debug) << "starting running " << boost::typeindex::type_id<EmitterT>().pretty_name();
102 }
103 else
104 {
105 BOOST_LOG_TRIVIAL(severity_level::debug) << "unprogrammed response for event of type " << boost::typeindex::type_id_runtime(e).pretty_name();
106 }
107}
108
109}; // gory detail
110
111
112 } //re: namespace endgames
113}// re: namespace bertini
Strawman Event type, enabling polymorphism.
Definition detail/events.hpp:47
Actual observer type, which you should derive from to extract custom information from observable type...
Definition observer.hpp:82
Advanced around the circle around target time.
Definition endgames/events.hpp:93
Contains the endgames/events base types.
Logging in Bertini using Boost.Log.
Contains the observer base types.
Logs the endgame run, with gory detail.
Definition endgames/observers.hpp:52
virtual void Observe(AnyEvent const &e) override
Observe the observable object being observed. This is probably in response to NotifyObservers.
Definition endgames/observers.hpp:59