39#ifndef LEARNING_AGENT_H
40#define LEARNING_AGENT_H
46#include "environment.h"
47#include "instructions/set.h"
48#include "log/laLogger.h"
49#include "mutator/mutationParameters.h"
50#include "tpg/tpgExecutionEngine.h"
51#include "tpg/tpgGraph.h"
53#include "learn/classificationLearningEnvironment.h"
54#include "learn/evaluationResult.h"
56#include "learn/learningEnvironment.h"
57#include "learn/learningParameters.h"
59#include "selector/selectorFactory.h"
82 std::shared_ptr<TPG::TPGGraph>
tpg;
100 std::vector<std::reference_wrapper<Log::LALogger>>
loggers;
117 env(iSet, p, le.getDataSources(),
118 (le.isDiscrete()) ? 0 : le.getNbActions()),
120 tpg(factory.createTPGGraph(
env)),
201 virtual std::shared_ptr<EvaluationResult>
evaluateJob(
223 std::shared_ptr<Learn::EvaluationResult>& previousResult)
const;
237 virtual std::multimap<std::shared_ptr<EvaluationResult>,
278 bool doPopulate =
true);
294 virtual uint64_t
train(
volatile bool& altTraining,
295 bool printProgressBar);
310 virtual std::shared_ptr<Learn::Job>
makeJob(
325 virtual std::queue<std::shared_ptr<Learn::Job>>
makeJobs(
337 virtual void init(uint64_t seed = 0);
The Environment class contains all information needed to execute a Program.
Definition environment.h:86
Class for storing a set of Instruction.
Definition set.h:55
This class embeds roots for the simulations.
Definition job.h:53
Class used to control the learning steps of a TPGGraph within a given LearningEnvironment.
Definition learningAgent.h:67
void addLogger(Log::LALogger &logger)
Adds a LALogger to the loggers vector.
Definition learningAgent.cpp:100
std::shared_ptr< TPG::TPGGraph > getTPGGraph()
Getter for the TPGGraph built by the LearningAgent.
Definition learningAgent.cpp:53
uint64_t maxNbThreads
Control the maximum number of threads when running in parallel.
Definition learningAgent.h:91
const Archive & getArchive() const
Getter for the Archive filled by the LearningAgent.
Definition learningAgent.cpp:63
std::shared_ptr< Selector::Selector > selector
Selector used for the selection process.
Definition learningAgent.h:85
virtual std::multimap< std::shared_ptr< EvaluationResult >, const TPG::TPGVertex * > evaluateAllRoots(uint64_t generationNumber, LearningMode mode)
Evaluate all root TPGVertex of the TPGGraph.
Definition learningAgent.cpp:254
LearningParameters params
Parameters for the learning process.
Definition learningAgent.h:79
LearningAgent(LearningEnvironment &le, const Instructions::Set &iSet, const LearningParameters &p, const TPG::TPGFactory &factory=TPG::TPGFactory())
Constructor for LearningAgent.
Definition learningAgent.h:113
Archive archive
Archive used during the training process.
Definition learningAgent.h:76
virtual void init(uint64_t seed=0)
Initialize the LearningAgent.
Definition learningAgent.cpp:78
virtual std::queue< std::shared_ptr< Learn::Job > > makeJobs(Learn::LearningMode mode, TPG::TPGGraph *tpgGraph=nullptr)
Puts all roots into jobs to be able to use them in simulation later.
Definition learningAgent.cpp:430
virtual std::shared_ptr< EvaluationResult > evaluateOneRoot(uint64_t generationNumber, LearningMode mode, const TPG::TPGVertex *root)
Evaluate one root TPGVertex of the TPGGraph.
Definition learningAgent.cpp:279
Mutator::RNG rng
Random Number Generator for this Learning Agent.
Definition learningAgent.h:88
LearningEnvironment & learningEnvironment
LearningEnvironment with which the LearningAgent will interact.
Definition learningAgent.h:70
virtual uint64_t train(volatile bool &altTraining, bool printProgressBar)
Train the TPGGraph for a given number of generation.
Definition learningAgent.cpp:364
std::vector< std::reference_wrapper< Log::LALogger > > loggers
Set of LALogger called throughout the training process.
Definition learningAgent.h:100
virtual void trainOneGeneration(uint64_t generationNumber, bool doPopulate=true)
Train the TPGGraph for one generation.
Definition learningAgent.cpp:309
bool isRootEvalSkipped(const TPG::TPGVertex &root, std::shared_ptr< Learn::EvaluationResult > &previousResult) const
Method detecting whether a root should be evaluated again.
Definition learningAgent.cpp:109
virtual ~LearningAgent()=default
Default destructor for polymorphism.
Mutator::RNG & getRNG()
Getter for the RNG used by the LearningAgent.
Definition learningAgent.cpp:73
std::shared_ptr< TPG::TPGGraph > tpg
TPGGraph built during the learning process.
Definition learningAgent.h:82
std::shared_ptr< Selector::Selector > getSelector()
Getter for the Selector built by the LearningAgent.
Definition learningAgent.cpp:58
Environment env
Environment for executing Program of the LearningAgent.
Definition learningAgent.h:73
virtual std::shared_ptr< EvaluationResult > evaluateJob(TPG::TPGExecutionEngine &tee, const Job &job, uint64_t generationNumber, LearningMode mode, LearningEnvironment &le) const
Evaluates policy starting from the given root.
Definition learningAgent.cpp:128
virtual std::shared_ptr< Learn::Job > makeJob(const TPG::TPGVertex *vertex, Learn::LearningMode mode, int idx=0, TPG::TPGGraph *tpgGraph=nullptr)
Takes a given TPGVertex and creates a job containing it.
Definition learningAgent.cpp:409
const Environment & getEnvironment() const
Accessor to the Environment of the TPGGraph.
Definition learningAgent.cpp:68
Interface for creating a Learning Environment.
Definition learningEnvironment.h:81
Learning Agent logger class that will be called during LearningAgent executions.
Definition laLogger.h:66
Definition tpgExecutionEngine.h:57
Factory for creating all elements constituting a TPG.
Definition tpgFactory.h:71
Class for storing a Tangled-Program-Graph.
Definition tpgGraph.h:58
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
Definition classificationLearningEnvironment.h:44
LearningMode
Different modes in which the LearningEnvironment can be reset.
Definition learningEnvironment.h:59
Definition mapElitesArchiveLogger.h:45
Structure for simplifying the transmission of LearningParameters to functions.
Definition learningParameters.h:56