38#ifndef PARALLEL_LEARNING_AGENT
39#define PARALLEL_LEARNING_AGENT
45#include "instructions/set.h"
46#include "tpg/tpgExecutionEngine.h"
48#include "learn/evaluationResult.h"
50#include "learn/learningAgent.h"
51#include "learn/learningEnvironment.h"
52#include "learn/learningParameters.h"
82 std::multimap<std::shared_ptr<EvaluationResult>,
101 std::map<uint64_t, std::pair<std::shared_ptr<EvaluationResult>,
102 std::shared_ptr<Job>>>&
104 std::map<uint64_t, Archive*>& archiveMap);
122 std::map<uint64_t, std::pair<std::shared_ptr<EvaluationResult>,
123 std::shared_ptr<Job>>>&
125 std::multimap<std::shared_ptr<EvaluationResult>,
127 std::map<uint64_t, Archive*>& archiveMap);
151 std::queue<std::shared_ptr<Learn::Job>>& jobsToProcess,
152 std::mutex& rootsToProcessMutex,
153 std::map<uint64_t, std::pair<std::shared_ptr<EvaluationResult>,
154 std::shared_ptr<Job>>>&
156 std::mutex& resultsPerRootMapMutex,
157 std::map<uint64_t, Archive*>& archiveMap,
158 std::mutex& archiveMapMutex,
bool useMainEnvironment);
213 std::multimap<std::shared_ptr<EvaluationResult>,
const TPG::TPGVertex*>
Class for storing a set of Instruction.
Definition: set.h:53
Class used to control the learning steps of a TPGGraph within a given LearningEnvironment.
Definition: learningAgent.h:63
uint64_t maxNbThreads
Control the maximum number of threads when running in parallel.
Definition: learningAgent.h:105
Interface for creating a Learning Environment.
Definition: learningEnvironment.h:80
Class used to control the learning steps of a TPGGraph within a given LearningEnvironment,...
Definition: parallelLearningAgent.h:66
void slaveEvalJobThread(uint64_t generationNumber, LearningMode mode, std::queue< std::shared_ptr< Learn::Job > > &jobsToProcess, std::mutex &rootsToProcessMutex, std::map< uint64_t, std::pair< std::shared_ptr< EvaluationResult >, std::shared_ptr< Job > > > &resultsPerRootMap, std::mutex &resultsPerRootMapMutex, std::map< uint64_t, Archive * > &archiveMap, std::mutex &archiveMapMutex, bool useMainEnvironment)
Function implementing the behavior of slave threads during parallel evaluation of roots.
Definition: parallelLearningAgent.cpp:86
virtual void evaluateAllRootsInParallelExecute(uint64_t generationNumber, LearningMode mode, std::map< uint64_t, std::pair< std::shared_ptr< EvaluationResult >, std::shared_ptr< Job > > > &resultsPerJobMap, std::map< uint64_t, Archive * > &archiveMap)
Subfunction of evaluateAllRootsInParallel which handles the creation of threads, their execution and ...
Definition: parallelLearningAgent.cpp:232
virtual void evaluateAllRootsInParallelCompileResults(std::map< uint64_t, std::pair< std::shared_ptr< EvaluationResult >, std::shared_ptr< Job > > > &resultsPerJobMap, std::multimap< std::shared_ptr< EvaluationResult >, const TPG::TPGVertex * > &results, std::map< uint64_t, Archive * > &archiveMap)
Subfunction of evaluateAllRootsInParallel which handles the gathering of results and the merge of the...
Definition: parallelLearningAgent.cpp:270
std::multimap< std::shared_ptr< EvaluationResult >, const TPG::TPGVertex * > evaluateAllRoots(uint64_t generationNumber, LearningMode mode) override
Evaluate all root TPGVertex of the TPGGraph.
Definition: parallelLearningAgent.cpp:52
virtual void evaluateAllRootsInParallel(uint64_t generationNumber, LearningMode mode, std::multimap< std::shared_ptr< EvaluationResult >, const TPG::TPGVertex * > &results)
Method for evaluating all roots with parallelism.
Definition: parallelLearningAgent.cpp:214
void mergeArchiveMap(std::map< uint64_t, Archive * > &archiveMap)
Method to merge several Archive created in parallel threads.
Definition: parallelLearningAgent.cpp:164
ParallelLearningAgent(LearningEnvironment &le, const Instructions::Set &iSet, const LearningParameters &p, const TPG::TPGFactory &factory=TPG::TPGFactory())
Constructor for ParallelLearningAgent.
Definition: parallelLearningAgent.h:186
Factory for creating all elements constituting a TPG.
Definition: tpgFactory.h:34
Abstract class representing the vertices of a TPGGraph.
Definition: tpgVertex.h:49
Definition: adversarialEvaluationResult.h:45
LearningMode
Different modes in which the LearningEnvironment can be reset.
Definition: learningEnvironment.h:58
Structure for simplifying the transmission of LearningParameters to functions.
Definition: learningParameters.h:53
size_t nbThreads
Number of threads (ParallelLearningAgent only)
Definition: learningParameters.h:189