GEGELATI
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:
CodeGen::ProgramGenerationEngine Program::ProgramExecutionEngine

Public Member Functions

void setProgram (const Program &prog)
 Method for changing the Program executed by a ProgramExecutionEngin. More...
 
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. More...
 
const std::vector< std::reference_wrapper< const Data::DataHandler > > & getDataSources () const
 Get the DataHandler of the ProgramExecutionEngine. More...
 
const bool next ()
 Increments the programCounter and checks for the end of the Program. More...
 
const LinegetCurrentLine () const
 Get the Program Line corresponding to the current programCounter. More...
 
const Instructions::InstructiongetCurrentInstruction () const
 Get the Instruction corresponding to the current programCounter. More...
 
const void fetchCurrentOperands (std::vector< Data::UntypedSharedPtr > &operands) const
 Get the operands for the current Instruction. More...
 
uint64_t getOperandLocation (uint64_t idxOp) const
 Get the location for the current Instruction. More...
 
virtual void iterateThroughtProgram (const bool ignoreException)
 Function that iterates through the lines of the program and execute the function processLine(). More...
 

Protected Member Functions

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

Protected Attributes

const Programprogram
 
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)
inlineprotected

Constructor of the class.

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

Parameters
[in]envThe 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 
)
inlineprotected

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]progthe const Program that will be executed or generated.
[in]dataSrcThe DataHandler with which the Program will be executed.

◆ ProgramEngine() [3/3]

Program::ProgramEngine::ProgramEngine ( const Program prog)
inlineprotected

Constructor of the class.

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

Parameters
[in]progthe 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]operandsstd::vector where the fetched operands will be inserted.
Exceptions
std::invalid_argumentif the data type of the current Instruction is not provided by the indexed DataHandler.
std::out_of_rangeif 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_rangeif 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_rangeif 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]idxOpstd::vector where the fetched operands will be inserted.
Exceptions
std::invalid_argumentif the data type of the current Instruction is not provided by the indexed DataHandler.
std::out_of_rangeif the given address is invalid for the indexed DataHandler, with the given data type, or if the indexed DataHandler does not exist.

◆ 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 ( )
protectedpure 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]dataSrcThe vector of DataHandler references with which the Program will be executed.
Exceptions
std::runtime_errorif 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]progthe const Program that will be executed by the ProgramExecutionEngine.
Exceptions
std::runtime_errorif the Environment references by the Program is incompatible with the dataSources of the ProgramExecutionEngine.

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 (2019 - 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.

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: