GEGELATI
Public Member Functions | Protected 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. More...
 
 TPGGraph (const TPGGraph &model)=delete
 delete copy constructor
 
 TPGGraph (TPGGraph &&model) noexcept
 TPGGraph move assignment operator. More...
 
TPGGraphoperator= (TPGGraph model)
 assignement operator for class TPGGraph
 
virtual ~TPGGraph ()
 Destructor for the TPGGraph. More...
 
void clear ()
 Empty the TPGGraph of all its content.
 
const EnvironmentgetEnvironment () const
 Accessor to the Environment of the TPGGraph. More...
 
const TPGFactorygetFactory () const
 Get a reference to the TPGFactory of the TPGGraph. More...
 
const TPGTeamaddNewTeam ()
 Create a new TPGTeam and add it to the vertices of the TPGGraph. More...
 
const TPGActionaddNewAction (uint64_t actionID)
 Create a new TPGAction and add it to the vertices of the TPGGraph. More...
 
size_t getNbVertices () const
 Get the number of TPGVertex contained in the TPGGraph. More...
 
const std::vector< const TPGVertex * > getVertices () const
 Get vector of const pointer to the vertices of the TPGGraph. More...
 
uint64_t getNbRootVertices () const
 Get the number of rootVertices of the TPGGraph. More...
 
const std::vector< const TPGVertex * > getRootVertices () const
 Get vector of const pointer to the root vertices of the TPGGraph. More...
 
bool hasVertex (const TPG::TPGVertex &vertex) const
 Check whether a given vertex exists in the TPGGraph. More...
 
void removeVertex (const TPGVertex &vertex)
 Remove a TPGVertex from the TPGGraph and destroy it. More...
 
const TPGVertexcloneVertex (const TPGVertex &vertex)
 Clone a TPGVertex of the graph and all its outgoing TPGEdge. More...
 
const TPGEdgeaddNewEdge (const TPGVertex &src, const TPGVertex &dest, const std::shared_ptr< Program::Program > prog)
 Add a new TPGEdge to the TPGGraph. More...
 
const std::list< std::unique_ptr< TPGEdge > > & getEdges () const
 Get a const reference to the edges of the TPGGraph. More...
 
void removeEdge (const TPGEdge &edge)
 Remove a TPGEdge from the TPGGraph. More...
 
const TPGEdgecloneEdge (const TPGEdge &edge)
 
bool setEdgeDestination (const TPGEdge &edge, const TPGVertex &newDest)
 Change the destination of the Edge to the given target. More...
 
bool setEdgeSource (const TPGEdge &edge, const TPGVertex &newSrc)
 Change the source of the TPGEdge to the given vertex. More...
 
void clearProgramIntrons ()
 Clear all intron instructions in the Program of the TPGGraph. More...
 

Protected Member Functions

std::list< TPGVertex * >::iterator findVertex (const TPGVertex *vertex)
 Find the non-const iterator to a vertex of the graph from its const pointer. More...
 
std::list< std::unique_ptr< TPGEdge > >::iterator findEdge (const TPGEdge *edge)
 Find the non-const iterator to an edge of the graph from its const pointer. More...
 

Protected Attributes

const Environmentenv
 Environment of the TPGGraph.
 
const std::unique_ptr< TPGFactoryfactory
 TPGFactory of the TPGGraph.
 
std::list< TPGVertex * > vertices
 Set of TPGVertex composing the TPGGraph.
 
std::list< std::unique_ptr< TPGEdge > > edges
 Set of TPGEdge composing the TPGGraph.
 

Friends

void swap (TPGGraph &a, TPGGraph &b)
 Helper function for move constructor. More...
 

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]ethe Environment for the TPGGraph.
[in]fthe TPGFactory used to create the graph elements.

◆ TPGGraph() [2/2]

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

TPGGraph move assignment operator.

Parameters
[in]modelthe 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 - 2021) :

Karol Desnos kdesn.nosp@m.os@i.nosp@m.nsa-r.nosp@m.enne.nosp@m.s.fr (2019 - 2021) Nicolas Sourbier nsour.nosp@m.bie@.nosp@m.insa-.nosp@m.renn.nosp@m.es.fr (2019 - 2020)

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]actionIDthe identifier to associate to the TPGAction.
Returns
a const reference to the newly created TPGAction.

◆ 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]srcthe source TPGVertex of the newly created TPGEdge.
[in]destthe destination TPGVertex of the newly created TPGEdge.
[in]progshared pointer to the Program associated to the newly created TPGEdge.
Returns
a const reference to the created TPGEdge.
Exceptions
std::runtime_errorIn 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]edgea const reference to the TPGedge to duplicate.
Returns
a const reference to the newly created TPGEdge.
Exceptions
std::runtime_errorif 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]vertexthe const reference to the TPGVertex to clone.
Returns
a const reference to the new TPGVertex.
Exceptions
std::runtime_errorif the given vertex does not belong to the TPGGraph.

◆ findEdge()

std::list< std::unique_ptr< TPG::TPGEdge > >::iterator TPG::TPGGraph::findEdge ( const TPGEdge edge)
protected

Find the non-const iterator to an edge of the graph from its const pointer.

Parameters
[in]edgethe const pointer to the TPGEdge.
Returns
the iterator on the edges attribute, at the position of the searched edge pointer. If the given vertex pointer is not in the vertices, then vertices.end() is returned.

◆ findVertex()

std::list< TPG::TPGVertex * >::iterator TPG::TPGGraph::findVertex ( const TPGVertex vertex)
protected

Find the non-const iterator to a vertex of the graph from its const pointer.

Parameters
[in]vertexthe const pointer to the TPGVertex.
Returns
the iterator on the vertices attribute, at the position of the searched vertex pointer. If the given vertex pointer is not in the vertices, then vertices.end() is returned.

◆ getEdges()

const std::list< std::unique_ptr< 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.

◆ 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]vertexthe TPG::TPGVertex whose presence in the TPGGraph is checked.
Returns
true if the vertex exists in the TPGGraph, false otherwise.

◆ 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]edgea const reference to the TPGEdge to remove.
Exceptions
std::runtime_errorIn 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]vertexa const reference to the TPGVertex to remove.

◆ 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]edgea const reference to the modified TPGEdge.
[in]newDesta 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]edgea const reference to the modified TPGEdge.
[in]newSrca 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.

Friends And Related Function 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: