Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

SIGEL_Program::SIG_Program Class Reference

This class represents a complete program that is evolved in an evolutionary process by a Genetic Programming System. More...

#include <SIG_Program.h>

List of all members.

Public Methods

SIGEL_Program::SIG_Program& operator= (SIGEL_Program::SIG_Program& prg)
 This operator copies a complete program. More...

 SIG_Program ()
 This constructor creates an empty program (that contains no program lines). More...

 SIG_Program (SIGEL_GP::SIG_GPParameter &param, SIGEL_Robot::SIG_LanguageParameters &languageP, SIGEL_Tools::SIG_Randomizer& random)
 This constructor creates a program. More...

virtual ~SIG_Program ()
 This destructor deletes all program lines and all data that belongs to the current program. More...

vector< SIGEL_Program::SIG_ProgramLine* >& getPrgLines ()
 This function returns the list of programlines. More...

void writeToFile (QTextStream &file)
 This functions write a complete program to a text stream. More...

void readFromFile (QTextStream &file)
 This function reads a program out of a given text stream. More...

void printToString (QString &str)
 This function transfers a complete program into a QString. More...

void clear ()
 This function deletes a complete program. More...

void print ()
 This function has only been implemented for test purposes. More...

long getProgramLength ()
 This function returns the length of the current program. More...

SIGEL_Program::SIG_ProgramLinegetLine (long no)
 This functions returns a program line. More...

void deleteLine (long no)
 This function deletes the line with the index no. More...

void appendLine (SIGEL_Program::SIG_ProgramLine *l)
 This function appends a line to program. More...

void insertLine (long no, SIGEL_Program::SIG_ProgramLine *l)
 This function inserts a program line at position no. More...

 SIG_Program (int length, int nop, SIGEL_Tools::SIG_Randomizer &r)
 This constructor creates a program that contains randomly generated program lines. More...

void generateRandomProgram (SIGEL_GP::SIG_GPParameter &param, SIGEL_Robot::SIG_LanguageParameters &languageP, SIGEL_Tools::SIG_Randomizer& random)
 This function generates a random program using the language and GP definitions. More...

void importProgram ( QString& filename )
 This function imports a complete program from an existing file. More...

void exportProgram ( QString& filename )
 This function exports a complete program to a file. More...

void checkLength ( long minimum, long maximum, SIGEL_Tools::SIG_Randomizer &r, SIGEL_Robot::SIG_LanguageParameters &languageP, QArray< int > &prob, int &historyInfo )
 This function checks if the current program length is too long or too short. More...


Protected Attributes

vector< SIG_ProgramLine* > lines


Detailed Description

This class represents a complete program that is evolved in an evolutionary process by a Genetic Programming System.

A program consists of program lines that contain the data of the correponding program instructions. The program lines are saved in a (Q)list, so the program supports all neccessary functions to work with such a list (of program lines). All program lines can be accessed with an index. The first line has the index 0.

Definition at line 48 of file SIG_Program.h.


Constructor & Destructor Documentation

SIGEL_Program::SIG_Program::SIG_Program ( )
 

This constructor creates an empty program (that contains no program lines).

Postcondition:
An empty program will be created and is ready to work with, e.g. for appending program lines etc.

Definition at line 233 of file SIG_Program.cpp.

SIGEL_Program::SIG_Program::SIG_Program ( SIGEL_GP::SIG_GPParameter & param,
SIGEL_Robot::SIG_LanguageParameters & languageP,
SIGEL_Tools::SIG_Randomizer & random )
 

This constructor creates a program.

Its properties are dependend on the language and GP parameters.

Precondition:
The language and GP parameters must exist.
Postcondition:
A program, which properties are defined by the mentioned parameters, is created.

Definition at line 329 of file SIG_Program.cpp.

SIGEL_Program::SIG_Program::~SIG_Program ( ) [virtual]
 

This destructor deletes all program lines and all data that belongs to the current program.

Postcondition:
All data will be deleted.

Definition at line 357 of file SIG_Program.cpp.

SIGEL_Program::SIG_Program::SIG_Program ( int length,
int nop,
SIGEL_Tools::SIG_Randomizer & r )
 

This constructor creates a program that contains randomly generated program lines.

This constructor needs a randomizer because a program does not have an own randomizer. All parameters are simulated by fixed values, e.g. the length is always set to 15. This constructor should only be used for test purposes.

Precondition:
A randomizer must exist and must be initialized.
Postcondition:
A randomly generated program will exist.


Member Function Documentation

void SIGEL_Program::SIG_Program::appendLine ( SIGEL_Program::SIG_ProgramLine * l )
 

This function appends a line to program.

It can also be the first program line.

Precondition:
The program line to append has to be created (with new) before.
Postcondition:
The program line will be appended at the end of the program. The program length will be increased, The new line can now be accessed with an index.

Definition at line 172 of file SIG_Program.cpp.

Referenced by checkLength(), SIGEL_GP::SIG_GPOperations::crossOver(), generateRandomProgram(), operator=(), and readFromFile().

void SIGEL_Program::SIG_Program::checkLength ( long minimumLength,
long maximumLength,
SIGEL_Tools::SIG_Randomizer & r,
SIGEL_Robot::SIG_LanguageParameters & languageP,
QArray< int >& prob,
int & historyInfo )
 

This function checks if the current program length is too long or too short.

In case of a too long program, the obsolete program lines (>maximum) will be deleted. In case of a too short program, the number of program lines will be increased to mininum.

Definition at line 248 of file SIG_Program.cpp.

Referenced by SIGEL_GP::SIG_GPOperations::crossOver(), SIGEL_GP::SIG_GPOperations::mutation(), and SIGEL_GP::SIG_GPOperations::reproduction().

void SIGEL_Program::SIG_Program::clear ( )
 

This function deletes a complete program.

Postcondition:
The program is deleted and contains no program lines.

Definition at line 90 of file SIG_Program.cpp.

Referenced by generateRandomProgram(), importProgram(), operator=(), readFromFile(), SIGEL_GP::SIG_GPIndividual::readFromFile(), and ~SIG_Program().

void SIGEL_Program::SIG_Program::deleteLine ( long no )
 

This function deletes the line with the index no.

Precondition:
A program (with program lines) must exist.
Postcondition:
The line (with index no) will be deleted. The following lines will get a new index (oldindex - 1),.

Definition at line 158 of file SIG_Program.cpp.

Referenced by checkLength(), SIGEL_GP::SIG_GPOperations::crossOver(), and SIGEL_GP::SIG_GPOperations::mutation().

void SIGEL_Program::SIG_Program::exportProgram ( QString & filename )
 

This function exports a complete program to a file.

Definition at line 216 of file SIG_Program.cpp.

Referenced by SIGEL_GP::SIG_GPIndividual::exportProgram().

void SIGEL_Program::SIG_Program::generateRandomProgram ( SIGEL_GP::SIG_GPParameter & param,
SIGEL_Robot::SIG_LanguageParameters & languageP,
SIGEL_Tools::SIG_Randomizer & random )
 

This function generates a random program using the language and GP definitions.

WARNING: An old program will be deleted.

Postcondition:
A new randomly generated program will exist.

Definition at line 337 of file SIG_Program.cpp.

Referenced by SIG_Program().

SIGEL_Program::SIG_ProgramLine * SIGEL_Program::SIG_Program::getLine ( long no )
 

This functions returns a program line.

Precondition:
A program (with program lines) must exist.
Returns:
A pointer to the corresponding program line will be returned. If this line is not existing, the functions returns 0.

Definition at line 143 of file SIG_Program.cpp.

Referenced by SIGEL_GP::SIG_GPOperations::crossOver(), SIGEL_GP::SIG_GPOperations::mutation(), and operator=().

vector< SIGEL_Program::SIG_ProgramLine *>& SIGEL_Program::SIG_Program::getPrgLines ( )
 

This function returns the list of programlines.

Definition at line 57 of file SIG_Program.cpp.

long SIGEL_Program::SIG_Program::getProgramLength ( )
 

This function returns the length of the current program.

Returns:
The returned long is the current program length.

Definition at line 52 of file SIG_Program.cpp.

Referenced by appendLine(), checkLength(), SIGEL_GP::SIG_GPOperations::crossOver(), insertLine(), SIGEL_GP::SIG_GPOperations::mutation(), operator=(), readFromFile(), and writeToFile().

void SIGEL_Program::SIG_Program::importProgram ( QString & filename )
 

This function imports a complete program from an existing file.

Definition at line 198 of file SIG_Program.cpp.

Referenced by SIGEL_GP::SIG_GPIndividual::importProgram().

void SIGEL_Program::SIG_Program::insertLine ( long no,
SIGEL_Program::SIG_ProgramLine * l )
 

This function inserts a program line at position no.

Precondition:
The program line to insert has to be created (with new) before.
Postcondition:
The program line will be inserted at position no. The program length will be increased. The new line can now be accessed with an index,

Definition at line 187 of file SIG_Program.cpp.

Referenced by SIGEL_GP::SIG_GPOperations::mutation().

SIGEL_Program::SIG_Program & SIGEL_Program::SIG_Program::operator= ( SIGEL_Program::SIG_Program & prg )
 

This operator copies a complete program.

Definition at line 12 of file SIG_Program.cpp.

void SIGEL_Program::SIG_Program::print ( )
 

This function has only been implemented for test purposes.

It is obsolete.

Postcondition:
The program will be printed to stdout.

Definition at line 74 of file SIG_Program.cpp.

Referenced by SIGEL_GP::SIG_GPIndividual::print().

void SIGEL_Program::SIG_Program::printToString ( QString & str )
 

This function transfers a complete program into a QString.

The string can displayed, e.g. with cout.

Postcondition:
The QString contains the complete program.

Definition at line 62 of file SIG_Program.cpp.

Referenced by SIGEL_MasterGUI::SIG_AllIndividualsView::slotSelectionChanged(), and SIGEL_SlaveGUI::SIG_SimulationWidget::visualizeThis().

void SIGEL_Program::SIG_Program::readFromFile ( QTextStream & file )
 

This function reads a program out of a given text stream.

Precondition:
The QTextStream file must exist, and it has to contain a complete program. Either this text stream has been created by writeToFile, or the stream has been edited by the user. The stream has to have a defined format, which is described more in detail in the corresponding specification.
Postcondition:
The program, which is described in the text stream, has been transfered (and translated) into (new created) program lines. All neccessary data is prepared. WARNING: An existing program will be deleted by calling this function.

Definition at line 96 of file SIG_Program.cpp.

Referenced by importProgram(), and SIGEL_GP::SIG_GPIndividual::readFromFile().

void SIGEL_Program::SIG_Program::writeToFile ( QTextStream & file )
 

This functions write a complete program to a text stream.

Precondition:
The QTextStream file must exist.
Postcondition:
The current program will be attached to the given text stream.

Definition at line 81 of file SIG_Program.cpp.

Referenced by exportProgram(), SIGEL_GP::SIG_GPPVMData::savePVMDataTransfer(), and SIGEL_GP::SIG_GPIndividual::writeToFile().


Member Data Documentation

vector< SIG_ProgramLine * > SIGEL_Program::SIG_Program::lines [protected]
 

Definition at line 52 of file SIG_Program.h.


The documentation for this class was generated from the following files:
Generated at Mon Sep 3 01:32:52 2001 for PG 368 - SIGEL by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000