GEGELATI

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Program::ProgramEngine Class Referenceabstract

This abstract class is the base class for any program engine (generation and execution) More...

`#include <programEngine.h>`

Inheritance diagram for Program::ProgramEngine:

## Public Member Functions
void | setProgram (const Program &prog)
| Method for changing the Program executed by a ProgramExecutionEngin.
template<class T >
void | setDataSources (const std::vector< std::reference_wrapper< T > > &dataSrc)
| Method for changing the dataSources on which the Program will be executed.
const std::vector< std::reference_wrapper< const Data::DataHandler > > & | getDataSources () const
| Get the DataHandler of the ProgramExecutionEngine.
const bool | next ()
| Increments the programCounter and checks for the end of the Program.
const Line & | getCurrentLine () const
| Get the Program Line corresponding to the current programCounter.
const Instructions::Instruction & | getCurrentInstruction () const
| Get the Instruction corresponding to the current programCounter.
const void | fetchCurrentOperands (std::vector< Data::UntypedSharedPtr > &operands) const
| Get the operands for the current Instruction.
uint64_t | getOperandLocation (uint64_t idxOp) const
| Get the location for the current Instruction.
virtual void | iterateThroughtProgram (const bool ignoreException)
| Function that iterates through the lines of the program and execute the function processLine().
virtual std::vector< double > | getRegisterValues (uint64_t nbRegisters)
| Return the current registers value of the program indicated.

## Protected Member Functions
| ProgramEngine ()=delete
| Default constructor is deleted.
| ProgramEngine (const Environment &env)
| Constructor of the class.
template<class T >
| ProgramEngine (const Program &prog, const std::vector< std::reference_wrapper< T > > &dataSrc)
| Constructor of the class.
| ProgramEngine (const Program &prog)
| Constructor of the class.
virtual void | processLine ()=0
| operator parenthesis used when iterating through the program with the function iterationThroughtProgram

## Protected Attributes
const Program * | program
Data::PrimitiveTypeArray< double > | registers
| Registers used for the Program execution.
std::vector< std::reference_wrapper< const Data::DataHandler > > | dataSources
| Data sources from the environment used for archiving a program.
std::vector< std::reference_wrapper< const Data::DataHandler > > | dataScsConstsAndRegs
| Data sources (including registers) used in the Program.
uint64_t | programCounter
| Program counter of the execution engine.

## Detailed Description

This abstract class is the base class for any program engine (generation and execution)

This class holds the common algortithms and members required to generate or execute a program for a given Environment.

## Constructor & Destructor Documentation

## ◆ ProgramEngine() [1/3]

Program::ProgramEngine::ProgramEngine | ( | const Environment & | env | ) |
| inline protected

Constructor of the class.

The constructor initialize the number of registers accordingly with the Environment given as a parameter.

Parameters

  [in] | env | The Environment in which the Program will be executed.

## ◆ ProgramEngine() [2/3]

template<class T >

Program::ProgramEngine::ProgramEngine | ( | const Program & | prog,
|  | const std::vector< std::reference_wrapper< T > > & | dataSrc )
| inline protected

Constructor of the class.

The constructor initialize the number of registers accordingly with the Environment given as a parameter instead of that of the Program or its Environment.

This constructor is useful for testing a Program on a different Environment than its own.

Parameters

  [in] | prog | the const Program that will be executed or generated.
  [in] | dataSrc | The DataHandler with which the Program will be executed.

## ◆ ProgramEngine() [3/3]

Program::ProgramEngine::ProgramEngine | ( | const Program & | prog | ) |
| inline protected

Constructor of the class.

The constructor initialize the number of registers accordingly with the Environment of the given Program.

Parameters

  [in] | prog | the const Program that will be executed by the ProgramExecutionEngine.

## Member Function Documentation

## ◆ fetchCurrentOperands()

const void Program::ProgramEngine::fetchCurrentOperands | ( | std::vector< Data::UntypedSharedPtr > & | operands | ) | const

Get the operands for the current Instruction.

This method fetches from the dataSourcesAndRegisters the operands indexed in the current Line of the Program. To get the correct data, the method Uses the data types of the current Instruction of the program.

Parameters

  [in,out] | operands | std::vector where the fetched operands will be inserted.

Exceptions

  std::invalid_argument | if the data type of the current Instruction is not provided by the indexed DataHandler.
  std::out_of_range | if the given address is invalid for the indexed DataHandler, with the given data type, or if the indexed DataHandler does not exist.

## ◆ getCurrentInstruction()

const Instructions::Instruction & Program::ProgramEngine::getCurrentInstruction | ( |  | ) | const

Get the Instruction corresponding to the current programCounter.

Returns
  the Instruction from the Environment Instruction::Set for the Line of the Program indexed by the current programCounter.

Exceptions

  std::out_of_range | if the programCounter exceeds the number of lines of the program or if the instruction index contained in the current Line exceeds the number of Instruction in the Environment Instructions::Set.

## ◆ getCurrentLine()

const Program::Line & Program::ProgramEngine::getCurrentLine | ( |  | ) | const

Get the Program Line corresponding to the current programCounter.

Returns
  a const ref to the Line from the Program indexed by the current programCounter.

Exceptions

  std::out_of_range | if the programCounter exceeds the number of lines of the program.

## ◆ getDataSources()

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

Get the DataHandler of the ProgramExecutionEngine.

Returns
  a vector containing references to the dataHandlers of the dataSourses attribute (i.e. without the registers)

## ◆ getOperandLocation()

uint64_t Program::ProgramEngine::getOperandLocation | ( | uint64_t | idxOp | ) | const

Get the location for the current Instruction.

This method fetches from the dataSourcesAndRegisters the operands indexed in the current Line of the Program. To get the correct data, the method Uses the data types of the current Instruction of the program.

Parameters

  [in] | idxOp | std::vector where the fetched operands will be inserted.

Exceptions

  std::invalid_argument | if the data type of the current Instruction is not provided by the indexed DataHandler.
  std::out_of_range | if the given address is invalid for the indexed DataHandler, with the given data type, or if the indexed DataHandler does not exist.

## ◆ getRegisterValues()

std::vector< double > Program::ProgramEngine::getRegisterValues | ( | uint64_t | nbRegisters | ) |
| virtual

Return the current registers value of the program indicated.

Parameters

  nbRegisters | The number of register values that are taken (starting from the register 0)

Returns
  a vector containing the different value of the registers.

## ◆ iterateThroughtProgram()

void Program::ProgramEngine::iterateThroughtProgram | ( | const bool | ignoreException | ) |
| virtual

Function that iterates through the lines of the program and execute the function processLine().

For each line that is not an intron, this function calls processLine(). This function can be overloaded for example to execute or to generate the non introns lines.

## ◆ next()

const bool Program::ProgramEngine::next | ( |  | ) |

Increments the programCounter and checks for the end of the Program.

This method will automatically skip intron lines of the Program when searching for the next Line to execute.

Returns
  true if the Program of the ProgramExecutionEngine has a Line for the new programCounter value, and false otherwise.

## ◆ processLine()

virtual void Program::ProgramEngine::processLine | ( |  | ) |
| protected pure virtual

operator parenthesis used when iterating through the program with the function iterationThroughtProgram

Implemented in CodeGen::ProgramGenerationEngine, and Program::ProgramExecutionEngine.

## ◆ setDataSources()

template<class T >

void Program::ProgramEngine::setDataSources | ( | const std::vector< std::reference_wrapper< T > > & | dataSrc | ) |
| inline

Method for changing the dataSources on which the Program will be executed.

Parameters

  [in] | dataSrc | The vector of DataHandler references with which the Program will be executed.

Exceptions

  std::runtime_error | if the Environment references by the Program is incompatible with the given dataSources.

## ◆ setProgram()

void Program::ProgramEngine::setProgram | ( | const Program & | prog | ) |

Method for changing the Program executed by a ProgramExecutionEngin.

Parameters

  [in] | prog | the const Program that will be executed by the ProgramExecutionEngine.

Exceptions

  std::runtime_error | if the Environment references by the Program is incompatible with the dataSources of the ProgramExecutionEngine.

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 - 2023) Nicolas Sourbier nsour.nosp@m.bie@.nosp@m.insa-.nosp@m.renn.nosp@m.es.fr (2019 - 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.

## Member Data Documentation

## ◆ program

const Program* Program::ProgramEngine::program
| protected

The program currently executed by the ProgramExecutionEngine instance.

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

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