GEGELATI

Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Friends | List of all members
TPG::TPGGraph Class Reference

Class for storing a Tangled-Program-Graph. More...

`#include <tpgGraph.h>`

## Public Member Functions
| TPGGraph (const Environment &e, std::unique_ptr< TPGFactory > f=std::make_unique< TPGFactory >())
| Main TPGGraph constructor.
| TPGGraph (const TPGGraph &model)=delete
| delete copy constructor
| TPGGraph (TPGGraph &&model) noexcept
| TPGGraph move assignment operator.
TPGGraph & | operator= (TPGGraph model)
| assignement operator for class TPGGraph
virtual | ~TPGGraph ()
| Destructor for the TPGGraph.
void | clear ()
| Empty the TPGGraph of all its content.
const Environment & | getEnvironment () const
| Accessor to the Environment of the TPGGraph.
const TPGFactory & | getFactory () const
| Get a reference to the TPGFactory of the TPGGraph.
const TPGTeam & | addNewTeam ()
| Create a new TPGTeam and add it to the vertices of the TPGGraph.
const TPGAction & | addNewAction (uint64_t actionID)
| Create a new TPGAction and add it to the vertices of the TPGGraph.
size_t | getNbVertices () const
| Get the number of TPGVertex contained in the TPGGraph.
const std::vector< const TPGVertex * > | getVertices () const
| Get vector of const pointer to the vertices of the TPGGraph.
uint64_t | getNbRootVertices () const
| Get the number of rootVertices of the TPGGraph.
const std::vector< const TPGAction * > | getRootActions () const
| Get vector of const pointer to the root actions of the TPGGraph.
const std::vector< const TPGTeam * > | getRootTeams () const
| Get vector of const pointer to the root teams of the TPGGraph.
const std::vector< const TPGVertex * > | getRootVertices () const
| Get vector of const pointer to the root vertices of the TPGGraph.
bool | hasVertex (const TPG::TPGVertex &vertex) const
| Check whether a given vertex exists in the TPGGraph.
void | removeVertex (const TPGVertex &vertex)
| Remove a TPGVertex from the TPGGraph and destroy it.
const TPGVertex & | cloneVertex (const TPGVertex &vertex)
| Clone a TPGVertex of the graph and all its outgoing TPGEdge.
const TPGEdge & | addNewEdge (const TPGVertex &src, const TPGVertex &dest, const std::shared_ptr< Program::Program > prog)
| Add a new TPGEdge to the TPGGraph.
const TPGEdge & | addNewActionEdge (const TPGVertex &src, const std::shared_ptr< Program::Program > prog, uint64_t actionClass)
| Add a new TPGActionEdge to the TPGGraph.
const std::set< std::unique_ptr< TPG::TPGEdge >, UniqueLess< TPG::TPGEdge > > & | getEdges () const
| Get a const reference to the edges of the TPGGraph.
void | removeEdge (const TPGEdge &edge)
| Remove a TPGEdge from the TPGGraph.
void | removeActionEdge (const TPGEdge &edge)
| Remove a TPGActionEdge from the TPGGraph.
const TPGEdge & | cloneEdge (const TPGEdge &edge)
bool | setEdgeDestination (const TPGEdge &edge, const TPGVertex &newDest)
| Change the destination of the Edge to the given target.
bool | setEdgeSource (const TPGEdge &edge, const TPGVertex &newSrc)
| Change the source of the TPGEdge to the given vertex.
void | clearProgramIntrons ()
| Clear all intron instructions in the Program of the TPGGraph.
void | setActionClassEdge (const TPGEdge *edge, uint64_t newActionClass)
| set a new action class to a TPGActionEdge
void | updateAssessedActions (const TPG::TPGVertex *vertex)
void | updateAllAssessedActions ()
void | orderActionEdges (const TPG::TPGAction *action)
void | setNewVertexID (const TPG::TPGVertex &vertex, uint64_t newID)
| Set a new ID to a vertex.
void | setNewEdgeID (const TPG::TPGEdge &edge, uint64_t newID)
| Set a new ID to an edge.

## Protected Attributes
const Environment & | env
| Environment of the TPGGraph.
const std::unique_ptr< TPGFactory > | factory
| TPGFactory of the TPGGraph.
std::set< std::unique_ptr< TPGEdge >, UniqueLess< TPGEdge > > | edges
| Set of all edges currently used in the graph.
std::set< std::unique_ptr< TPGVertex >, UniqueLess< TPGVertex > > | vertices
| Set of all vertices currently used in the graph.

## Friends
void | swap (TPGGraph &a, TPGGraph &b)
| Helper function for move constructor.

## Detailed Description

Class for storing a Tangled-Program-Graph.

## Constructor & Destructor Documentation

## ◆ TPGGraph() [1/2]

TPG::TPGGraph::TPGGraph | ( | const Environment & | e,
|  | std::unique_ptr< TPGFactory > | f = std::make_unique<TPGFactory>() )
| inline

Main TPGGraph constructor.

Parameters

  [in] | e | the Environment for the TPGGraph.
  [in] | f | the TPGFactory used to create the graph elements.

## ◆ TPGGraph() [2/2]

TPG::TPGGraph::TPGGraph | ( | TPGGraph && | model | ) |
| inlinenoexcept

TPGGraph move assignment operator.

Parameters

  [in] | model | the TPGGraph to copy

## ◆ ~TPGGraph()

TPG::TPGGraph::~TPGGraph | ( |  | ) |
| virtual

Destructor for the TPGGraph.

Free the memory allocated for TPGVertices.

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 (2019 - 2023) 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 (2024 - 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.

## Member Function Documentation

## ◆ addNewAction()

const TPG::TPGAction & TPG::TPGGraph::addNewAction | ( | uint64_t | actionID | ) |

Create a new TPGAction and add it to the vertices of the TPGGraph.

The new TPGAction is added to the back of the vertices list. The TPGAction is created using the TPGFactory of the TPGGraph.

Parameters

  [in] | actionID | the identifier to associate to the TPGAction.

Returns
  a const reference to the newly created TPGAction.

## ◆ addNewActionEdge()

const TPG::TPGEdge & TPG::TPGGraph::addNewActionEdge | ( | const TPGVertex & | src,
|  | const std::shared_ptr< Program::Program > | prog,
|  | uint64_t | actionClass )

Add a new TPGActionEdge to the TPGGraph.

Add a new TPGActionEdge to the TPGGraph, between the give vertex is associated the given Program. The newly created TPGEdge is inserted in the outgoing edges list of the connected TPGVertex. The TPGActionEdge is created using the TPGFactory of the TPGGraph.

Parameters

  [in] | src | the source TPGVertex of the newly created TPGEdge.
  [in] | prog | shared pointer to the Program associated to the newly created TPGEdge.
  [in] | actionClass | of the actionEdge

Returns
  a const reference to the created TPGEdge.

Exceptions

  std::runtime_error | In case the TPGVertex does not exist in the TPGGraph, or if the source is a TPGTeam.

## ◆ addNewEdge()

const TPG::TPGEdge & TPG::TPGGraph::addNewEdge | ( | const TPGVertex & | src,
|  | const TPGVertex & | dest,
|  | const std::shared_ptr< Program::Program > | prog )

Add a new TPGEdge to the TPGGraph.

Add a new TPGEdge to the TPGGraph, between the two given TPGVertex and associated with the given Program. The newly created TPGEdge is inserted in the incoming and outgoing edges lists of the connected TPGVertex. The TPGEdge is created using the TPGFactory of the TPGGraph.

Parameters

  [in] | src | the source TPGVertex of the newly created TPGEdge.
  [in] | dest | the destination TPGVertex of the newly created TPGEdge.
  [in] | prog | shared pointer to the Program associated to the newly created TPGEdge.

Returns
  a const reference to the created TPGEdge.

Exceptions

  std::runtime_error | In case one of the TPGVertex does not exist in the TPGGraph, or if the destination is a TPGAction.

## ◆ addNewTeam()

const TPG::TPGTeam & TPG::TPGGraph::addNewTeam | ( |  | ) |

Create a new TPGTeam and add it to the vertices of the TPGGraph.

The new TPGTeam is added to the back of the vertices list. The TPGTeam is created using the TPGFactory of the TPGGraph.

Returns
  a const reference to the newly created TPGTeam.

## ◆ clearProgramIntrons()

void TPG::TPGGraph::clearProgramIntrons | ( |  | ) |

Clear all intron instructions in the Program of the TPGGraph.

This method scans all the Programs associated to the TPGEdge of the TPGGraph and removes all intron instructions from them.

## ◆ cloneEdge()

const TPG::TPGEdge & TPG::TPGGraph::cloneEdge | ( | const TPGEdge & | edge | ) |

Duplicate a TPGEdge from the TPGGraph.

This method creates a perfect copy of the given TPGEdge, that is a TPGEdge with the same source, destination and program shared pointer.

Parameters

  [in] | edge | a const reference to the TPGedge to duplicate.

Returns
  a const reference to the newly created TPGEdge.

Exceptions

  std::runtime_error | if the given TPGEdge does not belong to the TPGGraph.

## ◆ cloneVertex()

const TPG::TPGVertex & TPG::TPGGraph::cloneVertex | ( | const TPGVertex & | vertex | ) |

Clone a TPGVertex of the graph and all its outgoing TPGEdge.

Parameters

  [in] | vertex | the const reference to the TPGVertex to clone.

Returns
  a const reference to the new TPGVertex.

Exceptions

  std::runtime_error | if the given vertex does not belong to the TPGGraph.

## ◆ getEdges()

const std::set< std::unique_ptr< TPG::TPGEdge >, UniqueLess< TPG::TPGEdge > > & TPG::TPGGraph::getEdges | ( |  | ) | const

Get a const reference to the edges of the TPGGraph.

Returns
  a const reference to the edges attribute.

## ◆ getEnvironment()

const Environment & TPG::TPGGraph::getEnvironment | ( |  | ) | const

Accessor to the Environment of the TPGGraph.

Returns
  the const reference to the env attribute.

## ◆ getFactory()

const TPG::TPGFactory & TPG::TPGGraph::getFactory | ( |  | ) | const

Get a reference to the TPGFactory of the TPGGraph.

Returns
  a reference to the TPGFactory.

## ◆ getNbRootVertices()

uint64_t TPG::TPGGraph::getNbRootVertices | ( |  | ) | const

Get the number of rootVertices of the TPGGraph.

Returns
  the number of TPGVertex in the graph with no incomingEdge.

## ◆ getNbVertices()

size_t TPG::TPGGraph::getNbVertices | ( |  | ) | const

Get the number of TPGVertex contained in the TPGGraph.

Returns
  the size of the vertices attribute.

## ◆ getRootActions()

const std::vector< const TPG::TPGAction * > TPG::TPGGraph::getRootActions | ( |  | ) | const

Get vector of const pointer to the root actions of the TPGGraph.

Content of the retrieved vector is valid only as long as no non-const method is called on the TPG. The returned vector is the current set of actions.

Returns
  a vector containing pointers to the root actions of the graph.

## ◆ getRootTeams()

const std::vector< const TPG::TPGTeam * > TPG::TPGGraph::getRootTeams | ( |  | ) | const

Get vector of const pointer to the root teams of the TPGGraph.

Content of the retrieved vector is valid only as long as no non-const method is called on the TPG. The returned vector is the current set of teams.

Returns
  a vector containing pointers to the root teams of the graph.

## ◆ getRootVertices()

const std::vector< const TPG::TPGVertex * > TPG::TPGGraph::getRootVertices | ( |  | ) | const

Get vector of const pointer to the root vertices of the TPGGraph.

Content of the retrieved vector is valid only as long as no non-const method is called on the TPG. The returned vector is a copy of the current set of vertices.

Returns
  a vector containing pointers to the root vertices of the graph.

## ◆ getVertices()

const std::vector< const TPG::TPGVertex * > TPG::TPGGraph::getVertices | ( |  | ) | const

Get vector of const pointer to the vertices of the TPGGraph.

Content of the retrieved vector is valid only as long as no non-const method is called on the TPG. The returned vector is a copy of the current set of vertices.

Returns
  a vector containing pointers to the vertices of the graph.

## ◆ hasVertex()

bool TPG::TPGGraph::hasVertex | ( | const TPG::TPGVertex & | vertex | ) | const

Check whether a given vertex exists in the TPGGraph.

Parameters

  [in] | vertex | the TPG::TPGVertex whose presence in the TPGGraph is checked.

Returns
  true if the vertex exists in the TPGGraph, false otherwise.

## ◆ orderActionEdges()

void TPG::TPGGraph::orderActionEdges | ( | const TPG::TPGAction * | action | ) |

Order the ActionEdge of the given action

Parameters

  [in] | action | TPGAction to order

## ◆ removeActionEdge()

void TPG::TPGGraph::removeActionEdge | ( | const TPGEdge & | edge | ) |

Remove a TPGActionEdge from the TPGGraph.

If the edge is connected to TPGVertex within the graph, they are updated.

Parameters

  [in] | edge | a const reference to the TPGActionEdge to remove.

Exceptions

  std::runtime_error | In case one of the TPGEdges does not exist in the TPGGraph.

## ◆ removeEdge()

void TPG::TPGGraph::removeEdge | ( | const TPGEdge & | edge | ) |

Remove a TPGEdge from the TPGGraph.

If the edge is connected to TPGVertex within the graph, they are updated.

Parameters

  [in] | edge | a const reference to the TPGEdge to remove.

Exceptions

  std::runtime_error | In case one of the TPGEdges does not exist in the TPGGraph.

## ◆ removeVertex()

void TPG::TPGGraph::removeVertex | ( | const TPGVertex & | vertex | ) |

Remove a TPGVertex from the TPGGraph and destroy it.

If the edge is connected to TPGEdges within the graph, they are also removed and destroyed.

Parameters

  [in] | vertex | a const reference to the TPGVertex to remove.

## ◆ setActionClassEdge()

void TPG::TPGGraph::setActionClassEdge | ( | const TPGEdge * | edge,
|  | uint64_t | newActionClass )

set a new action class to a TPGActionEdge

Parameters

  [in] | edge | TPGActionEdge changed
  [in] | newActionClass | new action class

## ◆ setEdgeDestination()

bool TPG::TPGGraph::setEdgeDestination | ( | const TPGEdge & | edge,
|  | const TPGVertex & | newDest )

Change the destination of the Edge to the given target.

Change the destination TPGVertex of a TPGEdge to a given TPGVertex. This function updates the TPGEdge attributes as well as those of all impacted TPGVertex.

Parameters

  [in] | edge | a const reference to the modified TPGEdge.
  [in] | newDest | a const reference to the destination TPGVertex.

Returns
  true if the given edge and vertex are part of the graph, and the operation was successful, false otherwise.

## ◆ setEdgeSource()

bool TPG::TPGGraph::setEdgeSource | ( | const TPGEdge & | edge,
|  | const TPGVertex & | newSrc )

Change the source of the TPGEdge to the given vertex.

Change the source TPGVertex of a TPGEdge to a given TPGVertex. This function updates the TPGEdge attributes as well as those of all impacted TPGVertex.

Parameters

  [in] | edge | a const reference to the modified TPGEdge.
  [in] | newSrc | a const reference to the new source TPGVertex.

Returns
  true if the given edge and vertex are part of the graph, and the operation was successful, false otherwise.

## ◆ setNewEdgeID()

void TPG::TPGGraph::setNewEdgeID | ( | const TPG::TPGEdge & | edge,
|  | uint64_t | newID )

Set a new ID to an edge.

An error is thrown if the edge does not belong to the graph An error is thrown if the newID is already used

Parameters

  [in] | edge | the edge to change ID
  [in] | newID | the new ID to set

## ◆ setNewVertexID()

void TPG::TPGGraph::setNewVertexID | ( | const TPG::TPGVertex & | vertex,
|  | uint64_t | newID )

Set a new ID to a vertex.

An error is thrown if the vertex does not belong to the graph An error is thrown if the newID is already used

Parameters

  [in] | vertex | the vertex to change ID
  [in] | newID | the new ID to set

## ◆ updateAllAssessedActions()

void TPG::TPGGraph::updateAllAssessedActions | ( |  | ) |

Update the assessed actions of the all graph.

This is to be use only at the initialisation, the complexity could be really high after

This method basically execute "updateAssessedActions" for all the TPGActions in the graph

## ◆ updateAssessedActions()

void TPG::TPGGraph::updateAssessedActions | ( | const TPG::TPGVertex * | vertex | ) |

Update the assessed actions of the current vertex, and all the incomming edges

Used only for continuous cases with multi-action program per TPGAction.

Assessed actions represent the set of action class used by the vertex.

Parameters

  [in] | vertex | TPGVertex to order

## Friends And Related Symbol Documentation

## ◆ swap

void swap | ( | TPGGraph & | a,
|  | TPGGraph & | b )
| friend

Helper function for move constructor.

Swaps the TPGGraphs objects.

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

- D:/a/gegelati/gegelati/gegelatilib/include/tpg/tpgGraph.h
- D:/a/gegelati/gegelati/gegelatilib/src/tpg/tpgGraph.cpp