GEGELATI

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
CodeGen::TPGSwitchGenerationEngine Class Reference

Class in charge of generating the C code of a TPGGraph. More...

`#include <tpgSwitchGenerationEngine.h>`

Inheritance diagram for CodeGen::TPGSwitchGenerationEngine:

## Public Member Functions
| TPGSwitchGenerationEngine (const std::string &filename, const TPG::TPGGraph &tpg, const std::string &path="./")
| Main constructor of the class.
virtual void | generateTPGGraph ()
| destructor of the class.
Public Member Functions inherited from CodeGen::TPGGenerationEngine
| TPGGenerationEngine (const std::string &filename, const TPG::TPGGraph &tpg, const std::string &path="./")
| Main constructor of the class.
virtual | ~TPGGenerationEngine ()
| destructor of the class.
Public Member Functions inherited from TPG::TPGAbstractEngine
bool | programIDIsNew (const uint64_t &progID)
| Method to find if the given Program is already in the programID set.

## Protected Member Functions
virtual void | initTpgFile ()
| function printing generic code in the main file.
virtual void | initHeaderFile ()
| function printing generic code declaration in the main file header.
virtual void | initActivationFunction ()
| function printing activation function code in the C files.
virtual void | generateEdge (const TPG::TPGEdge &edge)
| Method for generating the code for an edge of the graph.
virtual void | generateTeam (const TPG::TPGTeam &team)
| Method for generating the code for a team of the graph.
virtual void | generateAction (const TPG::TPGAction &action)
| Method for generating a action of the graph.
std::string | vertexName (const TPG::TPGVertex &v)
| Generate function name depending on the vertex type.
Protected Member Functions inherited from TPG::TPGAbstractEngine
| TPGAbstractEngine (const TPG::TPGGraph &tpg)
| Constructor for the abstract engine.

## Additional Inherited Members
Protected Attributes inherited from CodeGen::TPGGenerationEngine
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.
Protected Attributes inherited from TPG::TPGAbstractEngine
const TPG::TPGGraph & | tpg
| Reference to the TPGGraph whose content will be used to fill the maps.
std::set< uint64_t > | programID
| Set of all program ID.
uint64_t | nbActions
| Integer number used during export to associate a unique integer identifier to each TPGAction.
Static Protected Attributes inherited from CodeGen::TPGGenerationEngine
static const std::string | filenameProg = "program"

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ TPGSwitchGenerationEngine()

CodeGen::TPGSwitchGenerationEngine::TPGSwitchGenerationEngine | ( | const std::string & | filename,
|  | const TPG::TPGGraph & | tpg,
|  | const std::string & | path = "./" )
| inline

Main constructor of the class.

Parameters

  [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.

## Member Function Documentation

## ◆ generateAction()

void CodeGen::TPGSwitchGenerationEngine::generateAction | ( | const TPG::TPGAction & | action | ) |
| protectedvirtual

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.

Parameters

  [in] | action | const reference of the TPGAction that must be generated.

Implements CodeGen::TPGGenerationEngine.

## ◆ generateEdge()

void CodeGen::TPGSwitchGenerationEngine::generateEdge | ( | const TPG::TPGEdge & | edge | ) |
| protectedvirtual

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

Parameters

  [in] | edge | that must be generated.

Copyright or © or Copr. IETR/INSA - Rennes (2022 - 2025) :

Elinor Montmasson elino.nosp@m.r.mo.nosp@m.ntmas.nosp@m.son@.nosp@m.gmail.nosp@m..com (2022) Karol Desnos kdesn.nosp@m.os@i.nosp@m.nsa-r.nosp@m.enne.nosp@m.s.fr (2022 - 2025) Mickaël Dardaillon mdard.nosp@m.ail@.nosp@m.insa-.nosp@m.renn.nosp@m.es.fr (2022) Quentin Vacher qvach.nosp@m.er@i.nosp@m.nsa-r.nosp@m.enne.nosp@m.s.fr (2025)

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.

Implements CodeGen::TPGGenerationEngine.

## ◆ generateTeam()

void CodeGen::TPGSwitchGenerationEngine::generateTeam | ( | const TPG::TPGTeam & | team | ) |
| protectedvirtual

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).

Parameters

  [in] | team | const reference of the TPGTeam that must be generated.

Implements CodeGen::TPGGenerationEngine.

## ◆ generateTPGGraph()

void CodeGen::TPGSwitchGenerationEngine::generateTPGGraph | ( |  | ) |
| virtual

destructor of the class.

add endif at the end of the header and close both file.

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.

Implements CodeGen::TPGGenerationEngine.

## ◆ initActivationFunction()

void CodeGen::TPGSwitchGenerationEngine::initActivationFunction | ( |  | ) |
| protectedvirtual

function printing activation function code in the C files.

This function print the activation function in the param file of the Environment instance.

## ◆ initHeaderFile()

void CodeGen::TPGSwitchGenerationEngine::initHeaderFile | ( |  | ) |
| protectedvirtual

function printing generic code declaration in the main file header.

This function print the the struct required to represent the TPG and the prototypes of the function to execute the TPG and manage the stack of visited edges.

Implements CodeGen::TPGGenerationEngine.

## ◆ initTpgFile()

void CodeGen::TPGSwitchGenerationEngine::initTpgFile | ( |  | ) |
| protectedvirtual

function printing generic code in the main file.

This function prints generic code to execute the TPG and manage the stack of visited edges.

Implements CodeGen::TPGGenerationEngine.

## ◆ vertexName()

std::string CodeGen::TPGSwitchGenerationEngine::vertexName | ( | const TPG::TPGVertex & | v | ) |
| protected

Generate function name depending on the vertex type.

Parameters

  v | vertex to be named.

Returns
  std::string name of the vertex.

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

- D:/a/gegelati/gegelati/gegelatilib/include/codeGen/tpgSwitchGenerationEngine.h
- D:/a/gegelati/gegelati/gegelatilib/src/codeGen/tpgSwitchGenerationEngine.cpp