GEGELATI

Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
File::TPGGraphDotImporter Class Reference

Class used to import a TPG graph from a dot file. It should be able to import a whole Learning agent object. More...

`#include <tpgGraphDotImporter.h>`

## Public Member Functions
| TPGGraphDotImporter (const char *filePath, Environment environment, TPG::TPGGraph &tpgref)
| Constructor for the importer.
| ~TPGGraphDotImporter ()
void | setNewFilePath (const char *newFilePath)
| Set a new file for the importer.
void | importGraph ()
| Creates a TPG Graph from its description in a .dot file.

## Static Public Attributes
static const int | supportedMajorVersion = 2
| The major version supported by the importer.
static const int | supportedMinorVersion = 0
| The minor version supported by the importer.
static const int | supportedPatchVersion = 0
| The patch version supported by the importer.
static const unsigned int | MAX_READ_SIZE = 131072
| Maximum number of characters that can be read in a single line.

## Protected Member Functions
void | readOperands (std::string &str, Program::Line &line)
| Reads the content of the operands and puts it in the line passed in parameter.
void | readLine (std::smatch &matches)
| Reads the content of a line and puts it in the line passed in parameter.
void | readProgram (std::smatch &matches)
| Create a program from its dot content and import its constants.
bool | getExportedVersion (int &major, int &minor, int &patch)
| reads the version of the dot file and returns it in the parameters.
void | dumpTPGGraphHeader ()
| dumps the header of the dot file
void | readTeam (std::smatch &matches)
| reads and creates a TPGTeam.
void | readAction (std::smatch &matches)
| reads and creates a TPGAction.
void | readLinkTeamProgramAction (std::smatch &matches)
| reads a link declaration and creates a team to action edge
void | readLinkActionProgram (std::smatch &matches)
| reads a link declaration and creates a action edge
void | readLinkTeamProgramTeam (std::smatch &matches)
| reads a link declaration and creates a team to team edge
void | readLinkTeamProgram (std::smatch &matches)
| reads a link declaration and creates a team to program's destination edge.
bool | readLineFromFile ()

## Protected Attributes
std::ifstream | pFile
| File in which the dot content is read during import.
std::string | lastLine
| last Line read from file
Environment | env
| The environment in which the TPGGRAPH will be built.
TPG::TPGGraph & | tpg
| TPGGraph imported from dot file.
std::map< uint64_t, const TPG::TPGVertex * > | vertexID
| Map associating pointers to TPGVertex to an integer ID.
std::map< const TPG::TPGAction *, std::vector< uint64_t > > | actionClasses
| Map associating pointers to TPGAction to a vector of integer action class.
std::map< uint64_t, std::shared_ptr< Program::Program > > | programID
| Map associating pointers to Program to an integer ID.
std::map< uint64_t, const TPG::TPGAction * > | actionID
| Map associating pointers to TPGVertex representing actions to the corresponding action.

## Static Protected Attributes
static const std::string | lineSeparator
| string used to spot the end of a line in the program description.
static const std::string | teamRegex
| Contains the regex to identify a team declaration.
static const std::string | programRegex
| Contains the regex to identify a program declaration.
static const std::string | instructionRegex
| contains the regex to identify an instruction declaration
static const std::string | actionRegex
| contains the regex to identify an action declaration
static const std::string | linkProgramInstructionRegex
| contains the regex to identify a Program -> Instruction Link
static const std::string | linkProgramActionRegex
| contains the regex to identify a Team -> Program -> Action Link
static const std::string | linkProgramTeamRegex
| contains the regex to identify a Team -> Program -> Team Link
static const std::string | linkActionProgramRegex
| contains the regex to identify a Team -> Program -> Action Link
static const std::string | addLinkProgramRegex
| contains the regex to identify a Team -> Program Link the outgoing program vertex must already have been linked

## Detailed Description

Class used to import a TPG graph from a dot file. It should be able to import a whole Learning agent object.

## Constructor & Destructor Documentation

## ◆ TPGGraphDotImporter()

File::TPGGraphDotImporter::TPGGraphDotImporter | ( | const char * | filePath,
|  | Environment | environment,
|  | TPG::TPGGraph & | tpgref )
| inline

Constructor for the importer.

Parameters

  [in] | filePath | initial path to the file where the dot content will be written.
  [in] | environment | the environment in which the tpg Graph should be built
  [in] | tpgref | a Reference to the TPGGraph to build from the .dot file

Exceptions

  std::runtime_error | in case no file could be opened at the given filePath.

## ◆ ~TPGGraphDotImporter()

File::TPGGraphDotImporter::~TPGGraphDotImporter | ( |  | ) |
| inline

Destructor for the importer.

Closes the file.

## Member Function Documentation

## ◆ dumpTPGGraphHeader()

void File::TPGGraphDotImporter::dumpTPGGraphHeader | ( |  | ) |
| protected

dumps the header of the dot file

The header of the dot file contains no relevant informations to build the model

## ◆ getExportedVersion()

bool File::TPGGraphDotImporter::getExportedVersion | ( | int & | major,
|  | int & | minor,
|  | int & | patch )
| protected

reads the version of the dot file and returns it in the parameters.

Parameters

  [out] | major | the major version of the dot file
  [out] | minor | the minor version of the dot file
  [out] | patch | the patch version of the dot file

Returns
  true if the version was found, false otherwise.

## ◆ readLineFromFile()

bool File::TPGGraphDotImporter::readLineFromFile | ( |  | ) |
| protected

    \brief reads a single line of the file

    \return true if the line read matched any of the line

characteristics specified as regexs.

## ◆ readOperands()

void File::TPGGraphDotImporter::readOperands | ( | std::string & | str,
|  | Program::Line & | line )
| protected

Reads the content of the operands and puts it in the line passed in parameter.

Parameters

  [in] | str | the string to parse
  [in] | line | the line to fill with the parsed informations

## ◆ setNewFilePath()

void File::TPGGraphDotImporter::setNewFilePath | ( | const char * | newFilePath | ) |

Set a new file for the importer.

Parameters

  [in] | newFilePath | new path to the file where the dot content will be written.

Exceptions

  std::runtime_error | in case no file could be opened at the given newFilePath.

## Member Data Documentation

## ◆ actionID

std::map<uint64_t, const TPG::TPGAction*> File::TPGGraphDotImporter::actionID
| protected

Map associating pointers to TPGVertex representing actions to the corresponding action.

This map is used to ensure that identical actions are not created more than once.

## ◆ actionRegex

const std::string File::TPGGraphDotImporter::actionRegex
| staticprotected

contains the regex to identify an action declaration

this regex values "A([0-9]+)\\x20\\x5B.*=\"([0-9]+)\"\\x5D"

Explanation :

A([0-9]+) looks for a A followed by a number. the number will be stored in a group \x20\x5B looks for a succession of a whitespace and an opening bracket ('[') .*=" the following can be any sequence of character ending with =" ([0-9]+) looks for a number and stores it into the next group \"\\x5D the end of the sequence is made of "]

Example: A0 [shape=box style=invis] Should pass P0 [fillcolor="#22cccc" shape=point] Should not pass

## ◆ addLinkProgramRegex

const std::string File::TPGGraphDotImporter::addLinkProgramRegex
| staticprotected

contains the regex to identify a Team -> Program Link the outgoing program vertex must already have been linked

this regex values "T([0-9]+)\\x20->\\x20P([0-9]+)"

Explanation :

T[0-9]+ looks for a T followed by a number. the number will be stored in a group \x20 looks for a whitespace -> looxs for the sequence '->' \x20 looks for a whitespace P[0-9]+ looks for a P followed by a number. the number will be stored in a group

Example: P22 -> I22[style=invis] Should not pass T0 -> P22 -> T11 Should pass

## ◆ instructionRegex

const std::string File::TPGGraphDotImporter::instructionRegex
| staticprotected

contains the regex to identify an instruction declaration

this regex values "I([0-9]+)\\x20\\x5B.*label=\"(.*)\"\\x5D"

Explanation :

I([0-9]+) looks for a I followed by a number. the number will be stored in a group \x20\x5B looks for a succession of a whitespace and an opening bracket ('[') .* the following can be any sequence of character label=" looks for the label declaration sequence. (.*)"\x5D stores the content of the label in a group and look for the ending sequence : "] Example: I0 [shape=box style=invis] Should pass P0 [fillcolor="#22cccc" shape=point] Should not pass

## ◆ lastLine

std::string File::TPGGraphDotImporter::lastLine
| protected

last Line read from file

helps to pass a line that didn't match any regex to another function

## ◆ lineSeparator

const std::string File::TPGGraphDotImporter::lineSeparator
| staticprotected

string used to spot the end of a line in the program description.

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

Karol Desnos kdesn.nosp@m.os@i.nosp@m.nsa-r.nosp@m.enne.nosp@m.s.fr (2020 - 2022) Nicolas Sourbier nsour.nosp@m.bie@.nosp@m.insa-.nosp@m.renn.nosp@m.es.fr (2019 - 2020) 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.

## ◆ linkActionProgramRegex

const std::string File::TPGGraphDotImporter::linkActionProgramRegex
| staticprotected

contains the regex to identify a Team -> Program -> Action Link

this regex values "A([0-9]+)\\x20->\\x20P([0-9]+).*"

Explanation :

A[0-9]+ looks for a A followed by a number. the number will be stored in a group \x20 looks for a whitespace -> looks for the sequence '->' \x20 looks for a whitespace P[0-9]+ looks for a P followed by a number. the number will be stored in a group .* the following can be any sequence of character

Example: A22 -> I22[style=invis] Should not pass A0 -> P22 Should pass

## ◆ linkProgramActionRegex

const std::string File::TPGGraphDotImporter::linkProgramActionRegex
| staticprotected

contains the regex to identify a Team -> Program -> Action Link

this regex values "T([0-9]+)\\x20->\\x20P([0-9]+)\\x20->\\x20A([0-9]+).*"

Explanation :

T[0-9]+ looks for a T followed by a number. the number will be stored in a group \x20 looks for a whitespace -> looxs for the sequence '->' \x20 looks for a whitespace P[0-9]+ looks for a P followed by a number. the number will be stored in a group \x20 looks for a whitespace -> looxs for the sequence '->' \x20 looks for a whitespace A[0-9]+ looks for a A followed by a number. the number will be stored in a group .* the following can be any sequence of character

Example: P22 -> I22[style=invis] Should not pass T0 -> P22 -> A11 Should pass

## ◆ linkProgramInstructionRegex

const std::string File::TPGGraphDotImporter::linkProgramInstructionRegex
| staticprotected

contains the regex to identify a Program -> Instruction Link

this regex values "P([0-9]+)\\x20->\\x20I([0-9]+).*"

Explanation :

P[0-9]+ looks for a P followed by a number. the number will be stored in a group \x20 looks for a whitespace -> looxs for the sequence '->' \x20 looks for a whitespace I[0-9]+ looks for a I followed by a number. the number will be stored in a group .* the following can be any sequence of character

Example: P22 -> I22[style=invis] Should pass T0 -> P22 -> A11 Should not pass

## ◆ linkProgramTeamRegex

const std::string File::TPGGraphDotImporter::linkProgramTeamRegex
| staticprotected

contains the regex to identify a Team -> Program -> Team Link

this regex values "T([0-9]+)\\x20->\\x20P([0-9]+)\\x20->\\x20T([0-9]+).*"

Explanation :

T[0-9]+ looks for a T followed by a number. the number will be stored in a group \x20 looks for a whitespace -> looxs for the sequence '->' \x20 looks for a whitespace P[0-9]+ looks for a P followed by a number. the number will be stored in a group \x20 looks for a whitespace -> looxs for the sequence '->' \x20 looks for a whitespace T[0-9]+ looks for a T followed by a number. the number will be stored in a group * the following can be any sequence of character

Example: P22 -> I22[style=invis] Should not pass T0 -> P22 -> T11 Should pass

## ◆ programID

std::map<uint64_t, std::shared_ptr<Program::Program> > File::TPGGraphDotImporter::programID
| protected

Map associating pointers to Program to an integer ID.

This map is used to associate an unique id to a tpg program and to keep track of the pointers while restoring the TPGGraph described in a dot file

## ◆ programRegex

const std::string File::TPGGraphDotImporter::programRegex
| staticprotected

Contains the regex to identify a program declaration.

this regex values "P([0-9]+)\\x20\\x5B.*\\x5D"

Explanation :

P([0-9]+) looks for a P followed by a number. the number will be stored in a group \x20\x5B looks for a succession of a whitespace and an opening bracket ('[') .*\x5D the following can be any sequence of character terminated by ]

Example: P0 [fillcolor="#22cccc" shape=point] Should pass T10 [fillcolor="#1199bb"] Should not pass

## ◆ teamRegex

const std::string File::TPGGraphDotImporter::teamRegex
| staticprotected

Contains the regex to identify a team declaration.

this regex values "T([0-9]+)\\x20\\x5B.*\\x5D"

Explanation :

T([0-9]+) looks for a T followed by a number. the number will be stored in a group \x20\x5B looks for a succession of a whitespace and an opening bracket ('[') .*\x5D the following can be any sequence of character terminated by ]

Example: T10 [fillcolor="#1199bb"] Should pass P0 [fillcolor="#22cccc" shape=point] Should not pass

## ◆ vertexID

std::map<uint64_t, const TPG::TPGVertex*> File::TPGGraphDotImporter::vertexID
| protected

Map associating pointers to TPGVertex to an integer ID.

This map is used to associate an unique id to a tpg vertex and to keep track of the pointers while restoring the TPGGraph described in a dot file

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

- D:/a/gegelati/gegelati/gegelatilib/include/file/tpgGraphDotImporter.h
- D:/a/gegelati/gegelati/gegelatilib/src/file/tpgGraphDotImporter.cpp