HGA Heuristic. More...
#include <rtreeheuristic.h>
Public Member Functions | |
RTreeHeuristic (const RString &n, RRandom &r, RCursor< cObj > objs, RDebug *debug=0) | |
const RString | GetName (void) const |
virtual void | Init (cNodes *nodes) |
void | BuildFile (const RString &name, cObj *obj) |
virtual void | SelectNextObject (void) |
cObj * | GetNextObject (void) |
cNode * | GetNode (void) |
virtual cNode * | FindNode (void)=0 |
void | PutNextObject (void) |
void | Run (cNodes *nodes) |
virtual void | PostRun (void) |
bool | IsEnd (void) |
size_t | GetNbObjsOk (void) |
long | RRand (long max) |
template<class T > | |
void | RandOrder (T *arr, size_t size) |
virtual | ~RTreeHeuristic (void) |
Protected Attributes | |
RString | Name |
RRandom & | Random |
RCursor< cObj > | Objs |
size_t | NbObjs |
size_t | NbObjsOk |
cNodes * | Nodes |
cObj ** | Order |
cObj * | CurObj |
cNode * | CurNode |
RDebug * | Debug |
Detailed Description
template<class cNode, class cObj, class cNodes>
class R::RTreeHeuristic< cNode, cObj, cNodes >
HGA Heuristic.
The RTreeHeuristic class proposes a generic heuristic for a Hierarchical Genetic Algorithm (HGA).
Constructor & Destructor Documentation
RTreeHeuristic | ( | const RString & | n, |
RRandom & | r, | ||
RCursor< cObj > | objs, | ||
RDebug * | debug = 0 |
||
) |
Construct the tree heuristic.
- Parameters
-
n Name of the heuristic. r The random generator to use. objs Pointer to the objects. debug Debugger.
|
virtual |
Destruct the grouping heuristic.
Member Function Documentation
const RString GetName | ( | void | ) | const |
Get the name of the heuristic.
- Returns
- Pointer to a C String.
|
virtual |
Initialize the heuristic.
- Parameters
-
nodes Pointer to the nodes.
Reimplemented in RFirstNodeHeuristic< cNode, cObj, cNodes >.
void BuildFile | ( | const RString & | name, |
cObj * | obj | ||
) |
Build a file with a tree.
- Parameters
-
name Name of the file. obj Eventually, the attributes of an object are printed too.
|
virtual |
Select the next object to place. The CurObj must pointed to object to place.
cObj* GetNextObject | ( | void | ) |
Return the current object to attach.
cNode* GetNode | ( | void | ) |
Return the current node.
|
pure virtual |
Find a node for the next object.
Implemented in RFirstNodeHeuristic< cNode, cObj, cNodes >.
void PutNextObject | ( | void | ) |
Put the next object into a node.
void Run | ( | cNodes * | nodes | ) |
Run the heuristic.
- Parameters
-
nodes Pointer to the nodes.
|
virtual |
Do some operations after the run.
bool IsEnd | ( | void | ) |
Return true if all the objects are grouped.
size_t GetNbObjsOk | ( | void | ) |
Return the number of objects grouped.
long RRand | ( | long | max | ) |
Return a number in the interval [0,max[ using the current random generator.
- Parameters
-
max Variable used to calculate the number.
void RandOrder | ( | T * | arr, |
size_t | size | ||
) |
Random the position of elements of a vector using the current random generator.
- Parameters
-
arr A pointer to the array representing the vector. size The size of the vector.
Member Data Documentation
|
protected |
Name of the heuristic.
|
protected |
The random number generator to use.
|
protected |
Objects to be grouped.
|
protected |
Number of objects to attach.
|
protected |
Number of objects already attached.
|
protected |
Nodes.
|
protected |
Order in which the objects are to be treated.
|
protected |
Current object to place.
|
protected |
Current node manipulated.
|
protected |
Pointer to a "debugger" holding information about the GA when it is running.