Generic Grouping Heuristic class. More...
#include <rgroupingheuristic.h>
Public Member Functions | |
RGroupingHeuristic (const RString &n, RRandom &r, RCursor< cObj > objs, RDebug *debug=0) | |
const RString | GetName (void) const |
virtual void | Init (cGroups *groups) |
virtual void | BuildOrder (void) |
virtual cGroup * | FindGroup (cObj *obj)=0 |
void | Run (cGroups *groups) |
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 | ~RGroupingHeuristic (void) |
Protected Attributes | |
RString | Name |
RRandom & | Random |
RCursor< cObj > | Objs |
size_t | NbObjs |
size_t | NbObjsOk |
cGroups * | Groups |
cObj ** | Order |
RDebug * | Debug |
Detailed Description
template<class cGroup, class cObj, class cGroups>
class R::RGroupingHeuristic< cGroup, cObj, cGroups >
Generic Grouping Heuristic class.
The RGroupingHeuristic class provides an abstract class for grouping heuristics.
Constructor & Destructor Documentation
RGroupingHeuristic | ( | const RString & | n, |
RRandom & | r, | ||
RCursor< cObj > | objs, | ||
RDebug * | debug = 0 |
||
) |
Construct the grouping 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
-
groups Pointer to the groups.
Reimplemented in RHeuristicNN< cGroup, cObj, cGroups >, and RHeuristicSG< cGroup, cObj, cGroups >.
|
virtual |
Build the order in which the objects that are not assigned must be grouped. By default, the methods treats them in random order.
The array Order must be filled with the pointer to the objects to treat in the correct order and the variable NbObjs must be set with the correct number of objects to treat.
|
pure virtual |
Find a group for the next object.
- Parameters
-
obj Object.
Implemented in RHeuristicNN< cGroup, cObj, cGroups >, RHeuristicSG< cGroup, cObj, cGroups >, and RFirstFitHeuristic< cGroup, cObj, cGroups >.
void Run | ( | cGroups * | groups | ) |
Run the heuristic.
- Parameters
-
groups Pointer to the groups.
|
virtual |
Do some operations after the run.
Reimplemented in RHeuristicNN< cGroup, cObj, cGroups >, and RHeuristicSG< cGroup, cObj, cGroups >.
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 be grouped.
|
protected |
Number of objects already grouped.
|
protected |
Groups.
|
protected |
Order in which the objects are to be treated.
|
protected |
Pointer to a "debugger" holding information about the GA when it is running.