GEGELATI

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Archive Class Reference

`#include <archive.h>`

## Public Member Functions
| Archive (size_t size=50, double archivingProbability=1.0, size_t initialSeed=0)
| Main constructor for Archive.
| Archive (const Archive &other)=delete
| ~Archive ()
| Destructor of the class.
const ArchiveRecording & | at (uint64_t n) const
| Access the nth ArchiveRecording within the Archive.
void | setRandomSeed (size_t newSeed)
| Set a new seed for the randomEngine.
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.
bool | hasDataHandlers (const size_t &hash) const
| Check whether the given hash is already in the archive.
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.
size_t | getNbDataHandlers () const
| Get the number of different vector of DataHandler associated to recordings.
const std::map< size_t, std::vector< std::reference_wrapper< const Data::DataHandler > > > & | getDataHandlers () const
| Const accessor to the dataHandlers attribute.
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.

## Protected Attributes
const size_t | maxSize
| Maximum number of recordings held in the Archive.
Mutator::RNG | rng
| Randomness engine for archiving.
std::map< size_t, std::vector< std::reference_wrapper< const Data::DataHandler > > > | dataHandlers
| Storage for DataHandler copies used in recordings.
std::map< const Program::Program *, std::deque< ArchiveRecording > > | recordingsPerProgram
| Map storing the Program pointers referenced in recordings the associated recording.
std::deque< ArchiveRecording > | recordings
| Recordings of the Archive.
const double | archivingProbability
| Probability of adding any program execution to the archive.

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ Archive() [1/2]

Archive::Archive | ( | size_t | size = 50,
|  | double | archivingProbability = 1.0,
|  | size_t | initialSeed = 0 )
| inline

Main constructor for Archive.

Parameters

  [in] | archivingProbability | probability for each call to addRecording to actually lead to a new recodring in the Archive.
  [in] | size | maximum number of recordings kept in the Archive.
  [in] | initialSeed | Seed value for the randomEngine.

## ◆ Archive() [2/2]

Archive::Archive | ( | const Archive & | other | ) |
| delete

Disable Archive copy construction.

Until we see the need for it, there is no reason to enable copy-construction of Archive.

## ◆ ~Archive()

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.

## Member Function Documentation

## ◆ addRecording()

void Archive::addRecording | ( | const Program::Program *const | program,
|  | const std::vector< std::reference_wrapper< const Data::DataHandler > > & | dHandler,
|  | double | result,
|  | bool | forced = false )
| 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.

Parameters

  [in] | program | the Program associated to this recording.
  [in] | dHandler | the set of dataHandler the Program worked on to generate the associated result.
  [in] | result | double value produced by the Program.
  [in] | forced | Boolean for bypassing the stochastic process during insertion.

## ◆ areProgramResultsUnique()

bool Archive::areProgramResultsUnique | ( | const std::map< size_t, double > & | hashesAndResults,
|  | double | tau = 1e-4 ) const
| 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).

## ◆ at()

const ArchiveRecording & Archive::at | ( | uint64_t | n | ) | const

Access the nth ArchiveRecording within the Archive.

Parameters

  [in] | n | The index of the retrieved ArchiveRecording.

Returns
  a const reference to the indexed ArchiveRecording.

Exceptions

  std::out_of_range | if the given index is out of bounds.

## ◆ getCombinedHash()

size_t Archive::getCombinedHash | ( | const std::vector< std::reference_wrapper< const Data::DataHandler > > & | dHandler | ) |
| static

Combien the hash of a set of dataHandlers into a single one.

Hashes of each DataHandler is accessed with the DataHandler::getHash() method.

Returns
  the hash resulting from the combination.

## ◆ getDataHandlers()

const std::map< size_t, std::vector< std::reference_wrapper< const Data::DataHandler > > > & Archive::getDataHandlers | ( |  | ) | const

Const accessor to the dataHandlers attribute.

In order to test the unicity of a Program value, this Program must be executed on all DataHandlers contained in an Archive to assess the uniqueness of the results it produces.

Returns
  a const reference to the dataHandlers attribute.

## ◆ getNbDataHandlers()

size_t Archive::getNbDataHandlers | ( |  | ) | const

Get the number of different vector of DataHandler associated to recordings.

Returns
  the size of the dataHandlers attribute.

## ◆ getNbRecordings()

size_t Archive::getNbRecordings | ( |  | ) | const

Get the number of recordings currently held in the Archive.

Returns
  the size of the recordings attribute.

## ◆ hasDataHandlers()

bool Archive::hasDataHandlers | ( | const size_t & | hash | ) | const

Check whether the given hash is already in the archive.

Parameters

  [in] | hash | the DataHandler hash whose presence will be tested.

Returns
  true if the given hash is already in the Archive, false otherwise.

## ◆ setRandomSeed()

void Archive::setRandomSeed | ( | size_t | newSeed | ) |

Set a new seed for the randomEngine.

Parameters

  [in] | newSeed | Set a new seed for the random engine.

## Member Data Documentation

## ◆ dataHandlers

std::map<size_t, std::vector<std::reference_wrapper<const Data::DataHandler> > > Archive::dataHandlers
| 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.

## ◆ recordingsPerProgram

std::map<const Program::Program*, std::deque<ArchiveRecording> > Archive::recordingsPerProgram
| 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.

## ◆ rng

Mutator::RNG Archive::rng
| 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.

The documentation for this class was generated from the following files:

- D:/a/gegelati/gegelati/gegelatilib/include/archive.h
- D:/a/gegelati/gegelati/gegelatilib/src/archive.cpp