GEGELATI
|
This abstract class is the base class for any program engine (generation and execution) More...
#include <programEngine.h>
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 Line & | getCurrentLine () const |
Get the Program Line corresponding to the current programCounter. More... | |
const Instructions::Instruction & | getCurrentInstruction () 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 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. | |
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.
|
inlineprotected |
Constructor of the class.
The constructor initialize the number of registers accordingly with the Environment given as a parameter.
[in] | env | The Environment in which the Program will be executed. |
|
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.
|
inlineprotected |
Constructor of the class.
The constructor initialize the number of registers accordingly with the Environment of the given Program.
[in] | prog | the const Program that will be executed by the ProgramExecutionEngine. |
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.
[in,out] | operands | std::vector where the fetched operands will be inserted. |
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. |
const Instructions::Instruction & Program::ProgramEngine::getCurrentInstruction | ( | ) | const |
Get the Instruction corresponding to the current programCounter.
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. |
const Program::Line & Program::ProgramEngine::getCurrentLine | ( | ) | const |
const std::vector< std::reference_wrapper< const Data::DataHandler > > & Program::ProgramEngine::getDataSources | ( | ) | const |
Get the DataHandler of the ProgramExecutionEngine.
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.
[in] | idxOp | std::vector where the fetched operands will be inserted. |
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. |
|
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.
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.
|
protectedpure virtual |
operator parenthesis used when iterating through the program with the function iterationThroughtProgram
Implemented in CodeGen::ProgramGenerationEngine, and Program::ProgramExecutionEngine.
|
inline |
Method for changing the dataSources on which the Program will be executed.
[in] | dataSrc | The vector of DataHandler references with which the Program will be executed. |
std::runtime_error | if the Environment references by the Program is incompatible with the given dataSources. |
void Program::ProgramEngine::setProgram | ( | const Program & | prog | ) |
Method for changing the Program executed by a ProgramExecutionEngin.
[in] | prog | the const Program that will be executed by the ProgramExecutionEngine. |
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 - 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.
|
protected |
The program currently executed by the ProgramExecutionEngine instance.