GEGELATI
|
The Program class contains a list of program lines that can be executed within a well defined Environment. More...
#include <program.h>
Public Member Functions | |
Program (const Environment &e) | |
Main constructor of the Program. More... | |
Program (const Program &other) | |
Copy constructor of the Program. More... | |
Program & | operator= (const Program &other)=delete |
~Program () | |
Destructor for the Program class. More... | |
Line & | addNewLine () |
Add a new line to the Program with only 0 bits. More... | |
Line & | addNewLine (const uint64_t idx) |
Add a new line to the Program with only 0 bits. More... | |
void | clearIntrons () |
Clear all intron instructions in the Program. More... | |
void | removeLine (const uint64_t idx) |
Remove a Line from the Program. More... | |
void | swapLines (const uint64_t idx0, const uint64_t idx1) |
Swap two existing lines from the Program. More... | |
const Environment & | getEnvironment () const |
Get the environment associated to the Program at construction. More... | |
size_t | getNbLines () const |
Get the number of lines in the Program. More... | |
const Line & | getLine (uint64_t index) const |
Get a const ref to a Line of the Program. More... | |
Line & | getLine (uint64_t index) |
Get a non-const ref to a Line of the Program. More... | |
bool | isIntron (uint64_t index) const |
Checks whether a Line at the given index is an intron. More... | |
uint64_t | identifyIntrons () |
Scan the Line of the Program to identify introns. More... | |
Data::ConstantHandler & | getConstantHandler () |
get the constantHandler object of the Program More... | |
const Data::ConstantHandler & | cGetConstantHandler () const |
get a const reference to the constantHandler object of the Program More... | |
const Data::Constant | getConstantAt (size_t index) const |
Get the value of a constant at a given index. More... | |
bool | hasIdenticalBehavior (const Program &other) const |
Check if two Program have the same behavior. More... | |
Protected Member Functions | |
Program ()=delete | |
Delete the default constructor. | |
Protected Attributes | |
const Environment & | environment |
Environment within which the Program will be executed. | |
std::vector< std::pair< Line *, bool > > | lines |
Lines of the program and intron property. More... | |
Data::ConstantHandler | constants |
Constants of the Program. More... | |
The Program class contains a list of program lines that can be executed within a well defined Environment.
|
inline |
Main constructor of the Program.
[in] | e | the reference to the Environment that will be referenced in the Program attributes. |
|
inline |
Program::Program::~Program | ( | ) |
Destructor for the Program class.
This destructor deallocates all memory allocated for Program lines (if any).
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 (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.
Program::Line & Program::Program::addNewLine | ( | ) |
Program::Line & Program::Program::addNewLine | ( | const uint64_t | idx | ) |
Add a new line to the Program with only 0 bits.
The new line is inserted at the given position of the program.
[in] | idx | the position at which the line should be inserted. |
std::out_of_range | if the given position is beyond the end of the Program. |
const Data::ConstantHandler & Program::Program::cGetConstantHandler | ( | ) | const |
get a const reference to the constantHandler object of the Program
This method gives a const reference to the constantHandler associated with the program
void Program::Program::clearIntrons | ( | ) |
Clear all intron instructions in the Program.
All introns lines from the Program are removed by this method. The behavior of the Program should not be modified after a call to this function.
Introns should have been identified before calling this methos, as this method does NOT call the identifyIntrons method.
const Data::Constant Program::Program::getConstantAt | ( | size_t | index | ) | const |
Get the value of a constant at a given index.
Although this method is not required as the data is accessible from the constantHandler, it allows a shortcut and add readability.
[in] | index | the position at which we access the constant |
Data::ConstantHandler & Program::Program::getConstantHandler | ( | ) |
get the constantHandler object of the Program
This method gives a reference to the constantHandler associated with the program
const Environment & Program::Program::getEnvironment | ( | ) | const |
Get the environment associated to the Program at construction.
Program::Line & Program::Program::getLine | ( | uint64_t | index | ) |
const Program::Line & Program::Program::getLine | ( | uint64_t | index | ) | const |
size_t Program::Program::getNbLines | ( | ) | const |
bool Program::Program::hasIdenticalBehavior | ( | const Program & | other | ) | const |
Check if two Program have the same behavior.
Two Program have the same behaviour if their sequence of non-intron Lines are strictly identical (i.e. same instructions and operands, in the same order, and used Constant with identical values).
[in] | other | the Program whose behavior is compared. |
uint64_t Program::Program::identifyIntrons | ( | ) |
bool Program::Program::isIntron | ( | uint64_t | index | ) | const |
void Program::Program::removeLine | ( | const uint64_t | idx | ) |
void Program::Program::swapLines | ( | const uint64_t | idx0, |
const uint64_t | idx1 | ||
) |
Swap two existing lines from the Program.
[in] | idx0 | the index of the first line to swap. |
[in] | idx1 | the index of the second line to swap. |
std::out_of_range | if any of the two index is too large. |
|
protected |
Constants of the Program.
A Program contains a set of constants in a dedicated Data::DataHandler
|
protected |
Lines of the program and intron property.
Each element of this vector stores a pointer to a Line, and a boolean value indicating whether this Line is an Intron whithin the program.
Introns are Lines of the program that do not contribute to its final result, stored in the first register. Hence, skipping these lines during a program execution can speed up the Program execution.