GEGELATI

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

The Environment class contains all information needed to execute a Program. More...

`#include <environment.h>`

## Public Member Functions
| Environment (const Instructions::Set &iSet, const Learn::LearningParameters &p, const std::vector< std::reference_wrapper< const Data::DataHandler > > &dHandlers, size_t nbContinuousAct=0)
| Constructor with initialization of all attributes.
const Learn::LearningParameters & | getParams () const
| Get the instance of parameters used.
size_t | getNbContinuousActions () const
| Get the number of continuous actions.
size_t | getNbInstructions () const
| Get the size of the number of Instruction within the Instructions::Set.
size_t | getMaxNbOperands () const
| Get the size of the maximum number of operands of Instructions::Set.
size_t | getNbDataSources () const
| Get the size of the number of DataHandlers.
size_t | getLargestAddressSpace () const
| Get the size of the largestAddressSpace of DataHandlers.
const LineSize & | getLineSize () const
| Get the size of the line for this environment (in bits).
const std::vector< std::reference_wrapper< const Data::DataHandler > > & | getDataSources () const
| Get the DataHandler of the Environment.
const std::vector< std::reference_wrapper< const Data::DataHandler > > & | getFakeDataSources () const
const Instructions::Set & | getInstructionSet () const
| Get the Instruction Set of the Environment.

## Static Protected Member Functions
static size_t | computeLargestAddressSpace (const size_t nbRegisters, const size_t nbConstants, const std::vector< std::reference_wrapper< const Data::DataHandler > > &dHandlers)
| Static method used when constructing a new Environment to compute the largest AddressSpace of a set of DataHandler.
static const LineSize | computeLineSize (const Environment &env)
| Static method used to compute the size of Program lines based on information from the Enviroment.
static Instructions::Set | filterInstructionSet (const Instructions::Set &iSet, const size_t nbRegisters, const size_t nbConstants, const std::vector< std::reference_wrapper< const Data::DataHandler > > &dataSources)
| Filter an InstructionSet to keep only Instruction with operand types provided by the given DataHandler.

## Protected Attributes
const Instructions::Set | instructionSet
| Set of Instruction used by Program running within this Environment.
const Learn::LearningParameters | params
| Parameters for the learning process.
const std::vector< std::reference_wrapper< const Data::DataHandler > > | dataSources
| List of DataHandler that can be accessed within this Environment.
const size_t | nbRegisters
| Number of registers.
const size_t | nbConstants
| Number of constants.
std::vector< std::reference_wrapper< const Data::DataHandler > > | fakeDataSources
| Vector of DataHandlers containing the environment's dataSources.
const Data::PrimitiveTypeArray< double > | fakeRegisters
| DataHandler whost type corresponds to registers.
const Data::ConstantHandler | fakeConstants
| DataHandler whost type corresponds to the programs constants.
const size_t | nbContinuousActions
| Number of continuous actions.
const size_t | nbInstructions
| Number of Instruction in the Instructions::Set.
const size_t | maxNbOperands
| Maxmimum number of operands of the Instructions::Set.
const size_t | nbDataSources
| Number of DataHandler from which data can be accessed.
const size_t | largestAddressSpace
| Size of the largestAddressSpace of DataHandlers.
const LineSize | lineSize
| Size of lines within this Environment.

## Detailed Description

The Environment class contains all information needed to execute a Program.

To execute a Program, and size adequately its ProgramLine, a fixed Instruction Set, a list of available input DataHandler, and the number of available registers is needed.

To ensure viability of Program based on a given Environment, all attributes of an Environment are copied in const attributes at construction time.

## Constructor & Destructor Documentation

## ◆ Environment()

Environment::Environment | ( | const Instructions::Set & | iSet,
|  | const Learn::LearningParameters & | p,
|  | const std::vector< std::reference_wrapper< const Data::DataHandler > > & | dHandlers,
|  | size_t | nbContinuousAct = 0 )
| inline

Constructor with initialization of all attributes.

To ensure viability of Program based on a given Environment, all attributes of an Environment are copied in const attributes at construction time.

Parameters

  [in] | iSet | the Instructions::Set whose Instruction will be used in this Environment.
  [in] | p | the LearningParameter used, storing all metaparameters.
  [in] | dHandlers | the list of DataHandler that will be used in this Environment.
  [in] | nbContinuousAct | number of continuous actions in the LearningEnvironment, default value is 0.

## Member Function Documentation

## ◆ computeLargestAddressSpace()

size_t Environment::computeLargestAddressSpace | ( | const size_t | nbRegisters,
|  | const size_t | nbConstants,
|  | const std::vector< std::reference_wrapper< const Data::DataHandler > > & | dHandlers )
| staticprotected

Static method used when constructing a new Environment to compute the largest AddressSpace of a set of DataHandler.

Parameters

  [in] | nbRegisters | the number of registers of the environment.
  [in] | nbConstants | the number of program's constants.
  [in] | dHandlers | reference to the set of DataHandler whose largest largestAddressSpace is searched.

Returns
  the found value, or 0 default value if the given std::vector was empty.

Copyright or © or Copr. IETR/INSA - Rennes (2019 - 2025) :

Karol Desnos kdesn.nosp@m.os@i.nosp@m.nsa-r.nosp@m.enne.nosp@m.s.fr (2019 - 2020) Nicolas Sourbier nsour.nosp@m.bie@.nosp@m.insa-.nosp@m.renn.nosp@m.es.fr (2020) Quentin Vacher qvach.nosp@m.er@i.nosp@m.nsa-r.nosp@m.enne.nosp@m.s.fr (2025) Thomas Bourgoin tbour.nosp@m.goi@.nosp@m.insa-.nosp@m.renn.nosp@m.es.fr (2021)

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.

## ◆ computeLineSize()

const LineSize Environment::computeLineSize | ( | const Environment & | env | ) |
| staticprotected

Static method used to compute the size of Program lines based on information from the Enviroment.

The Program line size, expressed in bits, is computed with the following formula: $ ceil(log2(i)) + ceil(log2(n))+ m*(ceil(log2(nb_{src}))+ceil(log2(largestAddressSpace)) + p*32$ With bits organised (theoretically) in the same order as in the equation | Instruction | destination | operands See PROJECT/doc/instructions.md for more details.

Parameters

  [in] | env | The Environment whose information is used.

Returns
  the computed line size.

Exceptions

  std::domain_error | in cases where the given Environment is parameterized with no registers, contains no Instruction, Instruction with no operands, no DataHandler or DataHandler with no addressable Space.

## ◆ filterInstructionSet()

Instructions::Set Environment::filterInstructionSet | ( | const Instructions::Set & | iSet,
|  | const size_t | nbRegisters,
|  | const size_t | nbConstants,
|  | const std::vector< std::reference_wrapper< const Data::DataHandler > > & | dataSources )
| staticprotected

Filter an InstructionSet to keep only Instruction with operand types provided by the given DataHandler.

Parameters

  [in] | iSet | the Instructions::Set to filter.
  [in] | nbRegisters | Number of registers
  [in] | nbConstants | Number of constants of the program
  [in] | dataSources | a set of DataHandler providing data.

Returns
  a new Instructions:Set where only Instruction whose operands can be provided by at least one DataHandler are kept.

## ◆ getDataSources()

const std::vector< std::reference_wrapper< const Data::DataHandler > > & Environment::getDataSources | ( |  | ) | const

Get the DataHandler of the Environment.

Returns
  a const reference to the dataSources attribute of this Environment.

## ◆ getFakeDataSources()

const std::vector< std::reference_wrapper< const Data::DataHandler > > & Environment::getFakeDataSources | ( |  | ) | const

Get the datasource identical to the one used by programs

Getting the data sources identical to the one used by programs when executing a Program can be useful, notably when mutating a Program::Line and assessing whether a data type can be provided by the registers.

## ◆ getInstructionSet()

const Instructions::Set & Environment::getInstructionSet | ( |  | ) | const

Get the Instruction Set of the Environment.

Returns
  a const reference to the instructionSet attribute of this Environment.

## ◆ getLargestAddressSpace()

size_t Environment::getLargestAddressSpace | ( |  | ) | const

Get the size of the largestAddressSpace of DataHandlers.

Returns
  the value of the LargestAddressSpace attribute.

## ◆ getLineSize()

const LineSize & Environment::getLineSize | ( |  | ) | const

Get the size of the line for this environment (in bits).

Returns
  the value of the lineSize attribute.

## ◆ getMaxNbOperands()

size_t Environment::getMaxNbOperands | ( |  | ) | const

Get the size of the maximum number of operands of Instructions::Set.

Returns
  the value of the maxNbOperands attribute.

## ◆ getNbContinuousActions()

size_t Environment::getNbContinuousActions | ( |  | ) | const

Get the number of continuous actions.

Returns
  the value of the nbContinuousActions attribute.

## ◆ getNbDataSources()

size_t Environment::getNbDataSources | ( |  | ) | const

Get the size of the number of DataHandlers.

Returns
  the value of the nbDataSources attribute.

## ◆ getNbInstructions()

size_t Environment::getNbInstructions | ( |  | ) | const

Get the size of the number of Instruction within the Instructions::Set.

Returns
  the value of the nbInstructions attribute.

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

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