GEGELATI
Public Member Functions | Public Attributes | Friends | List of all members
TPG::PolicyStats Class Reference

#include <policyStats.h>

Public Member Functions

 PolicyStats ()=default
 Default constructor.
 
void clear ()
 
void setEnvironment (const Environment &env)
 Set Environement used during analyses. More...
 
void analyzeLine (const Program::Line *line)
 Analyze the given Line. More...
 
void analyzeProgram (const Program::Program *prog)
 Analyze the given Program. More...
 
void analyzeTPGTeam (const TPG::TPGTeam *team)
 
void analyzeTPGAction (const TPG::TPGAction *action)
 
void analyzePolicy (const TPG::TPGVertex *vertex)
 

Public Attributes

std::map< const Program::Program *, size_t > nbUsePerProgram
 Number of time a Program was analyzed. More...
 
std::map< const TPGTeam *, size_t > nbUsePerTPGTeam
 Number of time a TPGTeam was analyzed. More...
 
std::map< const TPGAction *, size_t > nbUsePerTPGAction
 Number of time a TPGAction was analyzed. More...
 
std::vector< size_t > nbLinesPerProgram
 Number of lines of analyzed Program.
 
std::vector< size_t > nbIntronPerProgram
 Number of intron lines of analyzed Program.
 
std::map< size_t, size_t > nbUsagePerInstruction
 
std::map< std::pair< size_t, size_t >, size_t > nbUsagePerDataLocation
 
std::vector< size_t > nbOutgoingEdgesPerTeam
 Number of outgoing TPGEdge of per TPGTeam of the TPGGraph.
 
std::map< size_t, size_t > nbUsagePerActionID
 
size_t maxPolicyDepth = 0
 Depth of the analyzed policy.
 
std::map< size_t, size_t > nbTPGVertexPerDepthLevel
 
size_t nbDistinctTeams = 0
 Number of distinct TPGTeams per policy.
 

Friends

std::ostream & operator<< (std::ostream &os, const PolicyStats &policyStats)
 Overload of the stream output operator for the PolicyStats class.
 

Detailed Description

Utility class for extracting statistics from a policy within a TPGGraph.

The entry point for using this class is the analyzePolicy() method which updates all attribute for a "tree" starting from a given root TPGVertex.

To analyze different policies with a single PolicyStats instance, the clear() method should be called between calls to analyzePolicy().

For access simplicity, all attributes filled during the analysis are public. Tampering with them will just make the result of the analysis useless.

Member Function Documentation

◆ analyzeLine()

void TPG::PolicyStats::analyzeLine ( const Program::Line line)

Analyze the given Line.

The method updates the following stats:

  • Total number of usage of each Instruction.
  • Total number of access for each location.

◆ analyzePolicy()

void TPG::PolicyStats::analyzePolicy ( const TPG::TPGVertex vertex)

Analyze the policy starting from the given TPGVertex.

This method explores the TPGGraph starting from the given TPGVertex, and analyzes all TPGTeam, TPGAction and Program encountered along the way.

The method updates the following stats:

  • Depth of the policy.
  • Number of TPGTeam per depth level.

◆ analyzeProgram()

void TPG::PolicyStats::analyzeProgram ( const Program::Program prog)

Analyze the given Program.

The method updates the following stats:

For each non-intron line, the analyzeLine() method will be called.

If a Program was already analyzed, it will not be analyzed again and only the number of use per program will be updated.

Parameters
[in]progthe analyzed Program.
Exceptions
std::runtime_errorif the given Program has incorrect lines accessing for example non existing instructions.

◆ analyzeTPGAction()

void TPG::PolicyStats::analyzeTPGAction ( const TPG::TPGAction action)

Analyze the given TPGAction.

The method updates the following stats:

  • Number of use per TPGAction.
  • Total number of usage per action.

If a TPGAction was already analyzed, it will not be analyzed again and only the number of use per TPGAction will be updated.

◆ analyzeTPGTeam()

void TPG::PolicyStats::analyzeTPGTeam ( const TPG::TPGTeam team)

Analyze the given TPGTeam.

The method updates the following stats:

If a TPGTeam was already analyzed, it will not be analyzed again and only the number of use per TPGTeam will be updated.

◆ clear()

void TPG::PolicyStats::clear ( )

Clear all stats stored in the class attributes.

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

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

◆ setEnvironment()

void TPG::PolicyStats::setEnvironment ( const Environment env)

Set Environement used during analyses.

From the given Environment, this method sets class attributes used during the analyses of the Program and Line of the policy. If the given Environment does not correspond to the one known to the Program exceptions may be thrown during analyses.

Member Data Documentation

◆ nbTPGVertexPerDepthLevel

std::map<size_t, size_t> TPG::PolicyStats::nbTPGVertexPerDepthLevel

Each entry of this map represents a level deepth of the policy tree and the number of TPGTeam that "first" appeared within this level.

A TPGTeam may appear several time in a single policy, but only its "lowest" level is counted here.

◆ nbUsagePerActionID

std::map<size_t, size_t> TPG::PolicyStats::nbUsagePerActionID

Each entry of this map associates an action ID to the number of time it was present in the analyzed policy.

◆ nbUsagePerDataLocation

std::map<std::pair<size_t, size_t>, size_t> TPG::PolicyStats::nbUsagePerDataLocation

Each entry of this map associates a data location with the total number of times it was accessed by non-intron lines of analyzed Programs. Each data location is itself represented with a pair consisting of the data source index, and the location within this data source.

◆ nbUsagePerInstruction

std::map<size_t, size_t> TPG::PolicyStats::nbUsagePerInstruction

Each entry of this map associates an Instruction identifier from an instruction set with the total number of times it was used in analyzed Programs.

◆ nbUsePerProgram

std::map<const Program::Program*, size_t> TPG::PolicyStats::nbUsePerProgram

Number of time a Program was analyzed.

When analyzing a policy, this number corresponds to the number of TPGEdge referencing a Program.

◆ nbUsePerTPGAction

std::map<const TPGAction*, size_t> TPG::PolicyStats::nbUsePerTPGAction

Number of time a TPGAction was analyzed.

When analyzing a policy, this number corresponds to the number of times this TPGAction is the destination of a TPGEdge.

◆ nbUsePerTPGTeam

std::map<const TPGTeam*, size_t> TPG::PolicyStats::nbUsePerTPGTeam

Number of time a TPGTeam was analyzed.

When analyzing a policy, this number corresponds to the number of times this TPGTeam is the destination of a TPGEdge.


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