GEGELATI
|
#include <archive.h>
Public Member Functions | |
Archive (size_t size=50, double archivingProbability=1.0, size_t initialSeed=0) | |
Main constructor for Archive. More... | |
Archive (const Archive &other)=delete | |
~Archive () | |
Destructor of the class. More... | |
const ArchiveRecording & | at (uint64_t n) const |
Access the nth ArchiveRecording within the Archive. More... | |
void | setRandomSeed (size_t newSeed) |
Set a new seed for the randomEngine. More... | |
virtual void | addRecording (const Program::Program *const program, const std::vector< std::reference_wrapper< const Data::DataHandler > > &dHandler, double result, bool forced=false) |
Add a new recording to the Archive. More... | |
bool | hasDataHandlers (const size_t &hash) const |
Check whether the given hash is already in the archive. More... | |
virtual bool | areProgramResultsUnique (const std::map< size_t, double > &hashesAndResults, double tau=1e-4) const |
size_t | getNbRecordings () const |
Get the number of recordings currently held in the Archive. More... | |
size_t | getNbDataHandlers () const |
Get the number of different vector of DataHandler associated to recordings. More... | |
const std::map< size_t, std::vector< std::reference_wrapper< const Data::DataHandler > > > & | getDataHandlers () const |
Const accessor to the dataHandlers attribute. More... | |
void | clear () |
Clear all content from the Archive. | |
Static Public Member Functions | |
static size_t | getCombinedHash (const std::vector< std::reference_wrapper< const Data::DataHandler > > &dHandler) |
Combien the hash of a set of dataHandlers into a single one. More... | |
Protected Attributes | |
const size_t | maxSize |
Maximum number of recordings held in the Archive. | |
Mutator::RNG | rng |
Randomness engine for archiving. More... | |
std::map< size_t, std::vector< std::reference_wrapper< const Data::DataHandler > > > | dataHandlers |
Storage for DataHandler copies used in recordings. More... | |
std::map< const Program::Program *, std::deque< ArchiveRecording > > | recordingsPerProgram |
Map storing the Program pointers referenced in recordings the associated recording. More... | |
std::deque< ArchiveRecording > | recordings |
Recordings of the Archive. | |
const double | archivingProbability |
Probability of adding any program execution to the archive. | |
Class use to manage the Archive associating input DataHandler and Program to the results they produced during execution.
This Archive is used when mutating a Program to perform the neutrality test which requires a Mutated program to produce an original result compared to any Program still in the Archive.
|
inline |
|
delete |
Archive::~Archive | ( | ) |
Destructor of the class.
In addition to default behavior, free all the memory associated to the referenced DataHandler in the dataHandlers attribute.
Copyright or © or Copr. IETR/INSA - Rennes (2019 - 2020) :
Karol Desnos kdesn.nosp@m.os@i.nosp@m.nsa-r.nosp@m.enne.nosp@m.s.fr (2019 - 2020)
GEGELATI is an open-source reinforcement learning framework for training artificial intelligence based on Tangled Program Graphs (TPGs).
This software is governed by the CeCILL-C license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security.
The fact that you are presently reading this means that you have had knowledge of the CeCILL-C license and that you accept its terms.
|
virtual |
Add a new recording to the Archive.
A call to this function adds an ArchiveRecording to the archive with the probability specified by the archivingProbability attribute unless it is forced, in which case the recording is added without randomness. If the maximum number of recordings held in the archive is reached, the oldest recording will be removed. If this is the first time this set of DataHandler is stored in the Archive according to its DataHandler::getHash() method, a copy of the dataHandler will be created. If an identical recording is already in the Archive (same hash, same Program), the recording is not added.
|
virtual |
Check if the given hash-results pairs are unique compared to Program in the Archive.
This method will return false is there exist any Program in the Archive for which all recordings with hashes contained in the given map, are associated to results equal to those of the given map (within tau margin).
const ArchiveRecording & Archive::at | ( | uint64_t | n | ) | const |
Access the nth ArchiveRecording within the Archive.
[in] | n | The index of the retrieved ArchiveRecording. |
std::out_of_range | if the given index is out of bounds. |
|
static |
Combien the hash of a set of dataHandlers into a single one.
Hashes of each DataHandler is accessed with the DataHandler::getHash() method.
const std::map< size_t, std::vector< std::reference_wrapper< const Data::DataHandler > > > & Archive::getDataHandlers | ( | ) | const |
size_t Archive::getNbDataHandlers | ( | ) | const |
Get the number of different vector of DataHandler associated to recordings.
size_t Archive::getNbRecordings | ( | ) | const |
Get the number of recordings currently held in the Archive.
bool Archive::hasDataHandlers | ( | const size_t & | hash | ) | const |
Check whether the given hash is already in the archive.
[in] | hash | the DataHandler hash whose presence will be tested. |
void Archive::setRandomSeed | ( | size_t | newSeed | ) |
Set a new seed for the randomEngine.
[in] | newSeed | Set a new seed for the random engine. |
|
protected |
Storage for DataHandler copies used in recordings.
This map associates a hash values with the corresonding copy of the set of DataHandler that produced this value. The hash value is used in recordings to associate each recording to the right copy of the DataHandler.
|
protected |
Map storing the Program pointers referenced in recordings the associated recording.
The Map is filled in the addRecording method, and elements are removed whenever the las ArchiveRecording referencing a Program is removed from the Archive.
The Map is used to speed the unicity tests.
|
protected |
Randomness engine for archiving.
This randomness engine is used to ensure determinism of the archiving process even in parallel execution context. The randomness engine should be reset with a new seed before entering a parallelizable part of the computations (even if these computations are done sequentially). As a more concrete example, if each policy starting from a root TPGVertex in a TPGGraph is evaluated in parallel, the randomEngine should be reset before each root.