GEGELATI
|
Class in charge of generating the C code of a TPGGraph. More...
#include <tpgGenerationEngine.h>
Public Member Functions | |
TPGGenerationEngine (const std::string &filename, const TPG::TPGGraph &tpg, const std::string &path="./", const uint64_t &stackSize=8) | |
Main constructor of the class. More... | |
~TPGGenerationEngine () | |
destructor of the class. More... | |
void | generateEdge (const TPG::TPGEdge &edge) |
Method for generating the code for an edge of the graph. More... | |
void | generateTeam (const TPG::TPGTeam &team) |
Method for generating the code for a team of the graph. More... | |
void | generateAction (const TPG::TPGAction &action) |
Method for generating a action of the graph. More... | |
void | setRoot (const TPG::TPGVertex &root) |
define the function pointer root to the vertex given in parameter. More... | |
void | generateTPGGraph () |
function that creates the C files required to execute the TPG without gegelati. More... | |
![]() | |
bool | findProgramID (const Program::Program &prog, uint64_t &id) |
Method for finding the unique identifier associated to a given Program. More... | |
uint64_t | findVertexID (const TPG::TPGVertex &vertex) |
Method for finding the unique identifier associated to a given TPGVertex. More... | |
Protected Member Functions | |
void | initTpgFile () |
function printing generic code in the main file. More... | |
void | initHeaderFile () |
function printing generic code declaration in the main file header. More... | |
![]() | |
TPGAbstractEngine (const TPG::TPGGraph &tpg) | |
Constructor for the abstract engine. More... | |
Protected Attributes | |
std::ofstream | fileMain |
File holding the functions in charge of iterating through the TPG. | |
std::ofstream | fileMainH |
header file for the function that iterates through the TPG. | |
CodeGen::ProgramGenerationEngine | progGenerationEngine |
ProgramGenerationEngine for generating Programs of edges. More... | |
uint64_t | stackSize |
Size of the stack of visited edges. More... | |
![]() | |
const TPG::TPGGraph & | tpg |
Reference to the TPGGraph whose content will be used to fill the maps. | |
std::map< const Program::Program *, uint64_t > | programID |
Map associating pointers to Program to an integer ID. More... | |
uint64_t | nbPrograms = 0 |
Integer number used to associate a unique integer identifier to each new Program. More... | |
std::map< const TPG::TPGVertex *, uint64_t > | vertexID |
Map associating pointers to TPGVertex to an integer ID. More... | |
uint64_t | nbVertex = 0 |
Integer number used during export to associate a unique integer identifier to each new TPGTeam. More... | |
uint64_t | nbActions |
Integer number used during export to associate a unique integer identifier to each TPGAction. More... | |
Static Protected Attributes | |
static const std::string | filenameProg = "program" |
Class in charge of generating the C code of a TPGGraph.
Each program of the TPGGraph is represented by a C function. All the functions are regrouped in a file. Another file holds the required functions to iterate through the TPGGraph.
To use the generated code two code templates are provided in the directory doc/codeGen. One template is for generic learning environment. The other one is dedicated for adversarial learning environment and manages the switch between the players. Both templates can use the inference with the codeGen or the inference with Gegelati.
The repo gegelati apps give some example of the template code completed for TicTacToe, Pendulum and StickGame.
|
inline |
Main constructor of the class.
[in] | filename | : filename of the file holding the main function of the generated program. |
[in] | tpg | Environment in which the Program of the TPGGraph will be executed. |
[in] | path | to the folder in which the file are generated. If the folder does not exist. |
[in] | stackSize | size of call stack for the execution of the TPG graph. |
|
inline |
destructor of the class.
add endif at the end of the header and close both file.
void CodeGen::TPGGenerationEngine::generateAction | ( | const TPG::TPGAction & | action | ) |
Method for generating a action of the graph.
This method generates the C function that represents an action. The generated function return a NULL pointer and write the action in the pointer given as parameter.
[in] | action | const reference of the TPGAction that must be generated. |
void CodeGen::TPGGenerationEngine::generateEdge | ( | const TPG::TPGEdge & | edge | ) |
Method for generating the code for an edge of the graph.
This function generates the code that represents an edge. An edge of a team is represented by a struct with: an integer, a function pointer of type : double (ptr_prog)() for the program of the edge a a function pointer of type : void (ptr_vertex)(int) to represent the destination of the edge
[in] | edge | that must be generated. |
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 - 2021) 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.
void CodeGen::TPGGenerationEngine::generateTeam | ( | const TPG::TPGTeam & | team | ) |
Method for generating the code for a team of the graph.
This method generates the C function that represents a team. Each function representing a team contains a static array of TPGEdge and calls the function executeTeam(Edge*, int).
[in] | team | const reference of the TPGTeam that must be generated. |
void CodeGen::TPGGenerationEngine::generateTPGGraph | ( | ) |
function that creates the C files required to execute the TPG without gegelati.
This function iterates trough the TPGGraph and create the required C code to represent each element of the TPGGraph.
|
protected |
|
protected |
function printing generic code in the main file.
This function prints generic code to execute the TPG and manage the stack of visited edges.
void CodeGen::TPGGenerationEngine::setRoot | ( | const TPG::TPGVertex & | root | ) |
define the function pointer root to the vertex given in parameter.
[in] | root | const reference to the root of the TPG graph. |
|
inlinestaticprotected |
String added at the end of the parameter filename to create the filename of the file with the programs of the TPGGraph.
|
protected |
ProgramGenerationEngine for generating Programs of edges.
Keeping this ProgramGenerationEngine as an attribute avoids wasting time rebuilding a new one for each edge.
|
protected |
Size of the stack of visited edges.
Stack holding the visited edges during the iteration of the TPG. Stop the execution of the program if the callStack is too small to store all the visited edges