GEGELATI
Public Member Functions | Protected Member Functions | List of all members
Program::ProgramExecutionEngine Class Reference

Class in charge of executing a Program within its Environment. More...

#include <programExecutionEngine.h>

Inheritance diagram for Program::ProgramExecutionEngine:
Program::ProgramEngine

Public Member Functions

 ProgramExecutionEngine (const Environment &env)
 Constructor of the class. More...
 
template<class T >
 ProgramExecutionEngine (const Program &prog, const std::vector< std::reference_wrapper< T > > &dataSrc)
 Constructor of the class. More...
 
 ProgramExecutionEngine (const Program &prog)
 Constructor of the class. More...
 
void executeCurrentLine ()
 Execute the current line of the program. More...
 
double executeProgram (const bool ignoreException=false)
 Execute the program completely and returns the content of register 0. More...
 
virtual void processLine () override
 inherited from Program::ProgramEngine More...
 
- Public Member Functions inherited from Program::ProgramEngine
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

 ProgramExecutionEngine ()=delete
 Default constructor is deleted.
 
- Protected Member Functions inherited from Program::ProgramEngine
 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...
 

Additional Inherited Members

- Protected Attributes inherited from Program::ProgramEngine
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

Class in charge of executing a Program within its Environment.

Constructor & Destructor Documentation

◆ ProgramExecutionEngine() [1/3]

Program::ProgramExecutionEngine::ProgramExecutionEngine ( const Environment env)
inline

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.

◆ ProgramExecutionEngine() [2/3]

template<class T >
Program::ProgramExecutionEngine::ProgramExecutionEngine ( const Program prog,
const std::vector< std::reference_wrapper< T > > &  dataSrc 
)
inline

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 by the ProgramExecutionEngine.
[in]dataSrcThe DataHandler with which the Program will be executed.

◆ ProgramExecutionEngine() [3/3]

Program::ProgramExecutionEngine::ProgramExecutionEngine ( const Program prog)
inline

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

◆ executeCurrentLine()

void Program::ProgramExecutionEngine::executeCurrentLine ( )

Execute the current line of the program.

Exceptions
seefetchCurrentOperands, getCurrentInstruction.

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.

◆ executeProgram()

double Program::ProgramExecutionEngine::executeProgram ( const bool  ignoreException = false)

Execute the program completely and returns the content of register 0.

Parameters
[in]ignoreExceptionWhen true, all exceptions thrown when fetching current instructions, operands are caught and the current program Line is simply ignored. When true, all lines of the Program are assumed to be correct by construction, and any exception is re-thrown for higher-level handling, thus stopping the program. Exception thrown by getCurrentLine are never ignored.
Returns
the double value contained in the 0-indexed register at the end of the program execution.

◆ processLine()

void Program::ProgramExecutionEngine::processLine ( )
overridevirtual

inherited from Program::ProgramEngine

Implements Program::ProgramEngine.


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