GEGELATI
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 std::vector< std::reference_wrapper< const Data::DataHandler > > &dHandlers, const size_t nbRegs, const size_t nbConst=0)
 Constructor with initialization of all attributes. More...
 
size_t getNbRegisters () const
 Get the size of the number of registers of this Environment. More...
 
size_t getNbConstant () const
 Get the number of constants used by programs. More...
 
size_t getNbInstructions () const
 Get the size of the number of Instruction within the Instructions::Set. More...
 
size_t getMaxNbOperands () const
 Get the size of the maximum number of operands of Instructions::Set. More...
 
size_t getNbDataSources () const
 Get the size of the number of DataHandlers. More...
 
size_t getLargestAddressSpace () const
 Get the size of the largestAddressSpace of DataHandlers. More...
 
const LineSizegetLineSize () const
 Get the size of the line for this environment (in bits). More...
 
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getDataSources () const
 Get the DataHandler of the Environment. More...
 
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getFakeDataSources () const
 
const Instructions::SetgetInstructionSet () const
 Get the Instruction Set of the Environment. More...
 

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. More...
 
static const LineSize computeLineSize (const Environment &env)
 Static method used to compute the size of Program lines based on information from the Enviroment. More...
 
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. More...
 

Protected Attributes

const Instructions::Set instructionSet
 Set of Instruction used by Program running within this Environment.
 
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 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 std::vector< std::reference_wrapper< const Data::DataHandler > > &  dHandlers,
const size_t  nbRegs,
const size_t  nbConst = 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]iSetthe Instructions::Set whose Instruction will be used in this Environment.
[in]dHandlersthe list of DataHandler that will be used in this Environment.
[in]nbRegsthe number of double registers in this Environment.
[in]nbConstthe number of program's constants in this Environment.

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]nbRegistersthe number of registers of the environment.
[in]nbConstantsthe number of program's constants.
[in]dHandlersreference 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 - 2021) :

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) 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]envThe Environment whose information is used.
Returns
the computed line size.
Exceptions
std::domain_errorin 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]iSetthe Instructions::Set to filter.
[in]nbRegistersNumber of registers
[in]nbConstantsNumber of constants of the program
[in]dataSourcesa 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 ( void  ) 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.

◆ getNbConstant()

size_t Environment::getNbConstant ( ) const

Get the number of constants used by programs.

Returns
the value of the nbParameters 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.

◆ getNbRegisters()

size_t Environment::getNbRegisters ( ) const

Get the size of the number of registers of this Environment.

Returns
the value of the nbRegisters attribute.

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