GEGELATI

Loading...
Searching...
No Matches
laLogger.h
1
38#ifndef LA_LOGGER_H
39#define LA_LOGGER_H
40
41#include <chrono>
42#include <map>
43#include <ostream>
44
45#include "learn/evaluationResult.h"
46#include "log/logger.h"
47#include "tpg/tpgGraph.h"
48
49namespace Learn {
50 class LearningAgent;
51}
52
53namespace Log {
54
64 class LALogger : public Logger
65 {
66 protected:
71 std::shared_ptr<std::chrono::time_point<
72 std::chrono::system_clock, std::chrono::nanoseconds>> const start;
73
78 std::shared_ptr<std::chrono::time_point<std::chrono::system_clock,
79 std::chrono::nanoseconds>>
80 checkpoint;
81
86 double mutationTime = 0;
87
92 double evalTime = 0;
93
98 double validTime = 0;
99
104 double decimationTime = 0;
105
107 Learn::LearningAgent& learningAgent;
108
115 double getDurationFrom(
116 const std::chrono::time_point<std::chrono::system_clock,
117 std::chrono::nanoseconds>& begin)
118 const;
119
125 std::chrono::time_point<std::chrono::system_clock,
126 std::chrono::nanoseconds>
127 getTime() const;
128
129 public:
133 bool doValidation = false;
134
139 bool useUtility = false;
140
153 explicit LALogger(Learn::LearningAgent& la,
154 std::ostream& out = std::cout);
155
159 void chronoFromNow();
160
164 virtual void logHeader() {
165 /* Empty because sub-class does not need to inherrit from it.*/
166 };
167
175 virtual void logNewGeneration(uint64_t& generationNumber) {
176 /* Empty because sub-class does not need to inherrit from it.*/
177 };
178
184 virtual void logAfterPopulateTPG() {
185 /* Empty because sub-class does not need to inherrit from it.*/
186 };
187
195 virtual void logAfterEvaluate(
196 std::multimap<std::shared_ptr<Learn::EvaluationResult>,
197 const TPG::TPGVertex*>& results) {
198 /* Empty because sub-class does not need to inherrit from it.*/
199 };
200
205 virtual void logAfterDecimate() {
206 /* Empty because sub-class does not need to inherrit from it.*/
207 };
208
215 virtual void logAfterValidate(
216 std::multimap<std::shared_ptr<Learn::EvaluationResult>,
217 const TPG::TPGVertex*>& results) {
218 /* Empty because sub-class does not need to inherrit from it.*/
219 };
220
224 virtual void logEndOfTraining() {
225 /* Empty because sub-class does not need to inherrit from it.*/
226 };
227 };
228} // namespace Log
229
230#endif
Learn::LearningAgent
Class used to control the learning steps of a TPGGraph within a given LearningEnvironment.
Definition learningAgent.h:67
Log::LALogger
Learning Agent logger class that will be called during LearningAgent executions.
Definition laLogger.h:65
Log::LALogger::mutationTime
double mutationTime
Definition laLogger.h:86
Log::LALogger::getTime
std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > getTime() const
Gets the current time value, for example to set checkpoint.
Definition laLogger.cpp:48
Log::LALogger::useUtility
bool useUtility
Definition laLogger.h:139
Log::LALogger::logAfterPopulateTPG
virtual void logAfterPopulateTPG()
Method called by the Learning Agent right after PopulateTPG is done.
Definition laLogger.h:184
Log::LALogger::chronoFromNow
void chronoFromNow()
Updates checkpoint to now.
Definition laLogger.cpp:63
Log::LALogger::validTime
double validTime
Definition laLogger.h:98
Log::LALogger::logEndOfTraining
virtual void logEndOfTraining()
Method called by the Learning Agent when the training is done.
Definition laLogger.h:224
Log::LALogger::learningAgent
Learn::LearningAgent & learningAgent
LearningAgent logged by the LALogger.
Definition laLogger.h:107
Log::LALogger::logNewGeneration
virtual void logNewGeneration(uint64_t &generationNumber)
Method called by the LearningAgent at the start of a generation.
Definition laLogger.h:175
Log::LALogger::logAfterEvaluate
virtual void logAfterEvaluate(std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > &results)
Method called by the Learning Agent right after the evaluation is done.
Definition laLogger.h:195
Log::LALogger::logAfterDecimate
virtual void logAfterDecimate()
Method called by the Learning Agent right after the decimation is done.
Definition laLogger.h:205
Log::LALogger::LALogger
LALogger(Learn::LearningAgent &la, std::ostream &out=std::cout)
Constructor defining a given output and setting start and checkpoint as now. Default output is cout.
Definition laLogger.cpp:53
Log::LALogger::getDurationFrom
double getDurationFrom(const std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > &begin) const
Computes the duration from a given time to now.
Definition laLogger.cpp:40
Log::LALogger::logAfterValidate
virtual void logAfterValidate(std::multimap< std::shared_ptr< Learn::EvaluationResult >, const TPG::TPGVertex * > &results)
Method called by the Learning Agent right after the validation is done.
Definition laLogger.h:215
Log::LALogger::decimationTime
double decimationTime
Definition laLogger.h:104
Log::LALogger::start
std::shared_ptr< std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > > const start
Definition laLogger.h:72
Log::LALogger::checkpoint
std::shared_ptr< std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > > checkpoint
Definition laLogger.h:80
Log::LALogger::doValidation
bool doValidation
Definition laLogger.h:133
Log::LALogger::evalTime
double evalTime
Definition laLogger.h:92
Log::LALogger::logHeader
virtual void logHeader()
Logs the header (e.g. column names) of this logger.
Definition laLogger.h:164
Log::Logger
Definition logger.h:48
TPG::TPGVertex
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
Learn
Definition classificationLearningEnvironment.h:44
Log
Definition cycleDetectionLALogger.h:38