GGA Chromosome. More...

#include <rgga.h>

Inheritance diagram for RChromoG< cInst, cChromo, cFit, cThreadData, cGroup, cObj >:
[legend]
Collaboration diagram for RChromoG< cInst, cChromo, cFit, cThreadData, cGroup, cObj >:
[legend]

Public Member Functions

 RChromoG (cInst *inst, size_t id)
 
virtual void Init (cThreadData *thData)
 
virtual void Clear (void)
 
virtual void RandomConstruct (void)
 
virtual void Crossover (cChromo *parent1, cChromo *parent2)
 
virtual void Mutation (void)
 
virtual void Inversion (void)
 
virtual void LocalOptimisation (void)
 
virtual void Optimisation (void)
 
virtual void Modify (void)
 
virtual void Verify (void)
 
virtual void Copy (const cChromo &chromo)
 
virtual ~RChromoG (void)
 
- Public Member Functions inherited from RChromo< cInst, cChromo, cFit, cThreadData >
 RChromo (cInst *inst, size_t id)
 
virtual void Evaluate (void)
 
virtual void StrongMutation (void)
 
virtual void Print (void)
 
virtual ~RChromo (void)
 
- Public Member Functions inherited from RGroups< cGroup, cObj, cChromo >
 RGroups (RCursor< cObj > objs, const size_t max)
 
void Init (void)
 
void ClearGroups (void)
 
cGroup * ReserveGroup (size_t id=cNoRef)
 
void ReleaseGroup (cGroup *group)
 
void InsertObj (cGroup *to, cObj *obj)
 
void InsertObjs (const cGroup *from, cGroup *to)
 
void DeleteObj (cGroup *from, cObj *obj)
 
void DeleteObjs (cGroup *grp)
 
cGroup * GetGroup (size_t id) const
 
cGroup * GetGroup (const cObj *obj) const
 
cObj * GetObj (size_t idx) const
 
RCursor< cObj > GetObjs (const RGroup< cGroup, cObj, cChromo > &grp) const
 
void CopyGrouping (const RGroups &grps)
 
void ComputeOrd (void)
 
bool SameGroupment (const RGroups *grps) const
 
RCursor< cObj > GetObjsCursor (void) const
 
RCursor< cGroup > GetUsedGroups (void) const
 
double ComputeAdjustedRandIndex (const cChromo &groups) const
 
virtual ~RGroups (void)
 
- Public Member Functions inherited from RContainer< cGroup, true, false >
 RContainer (size_t m, size_t i=0)
 
 RContainer (const RContainer< cGroup, true, false > &src)
 
 RContainer (const RContainer< cGroup, false, false > &src)
 
int Compare (const RContainer< cGroup, true, false > &) const
 
size_t GetNb (void) const
 
size_t GetMaxPos (void) const
 
size_t GetMaxNb (void) const
 
size_t GetIncNb (void) const
 
bool VerifyIndex (size_t idx) const
 
void VerifyTab (size_t max=0)
 
void Clear (size_t m=0, size_t i=0, bool force=false)
 
void ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max)
 
void ReOrder (int sortOrder(const void *, const void *))
 
void ReOrder (void)
 
void Exchange (size_t pos1, size_t pos2)
 
void Shift (size_t idx, bool reverse)
 
void Transfer (RContainer< cGroup, a, o > &src)
 
RContaineroperator= (const RContainer< cGroup, true, false > &src)
 
RContaineroperator= (const RContainer< cGroup, false, false > &src)
 
void Copy (const RContainer< cGroup, a, false > &src)
 
RContaineroperator+= (const RContainer< cGroup, a, o > &src)
 
size_t GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const
 
bool IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
bool IsIn (const TUse &tag, size_t min=0, size_t max=0) const
 
const cGroup * operator[] (size_t idx) const
 
cGroup * operator[] (size_t idx)
 
const cGroup * GetPtrAt (size_t idx) const
 
cGroup * GetPtrAt (size_t idx)
 
cGroup * GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
cGroup * GetPtr (const TUse &tag, size_t min=0, size_t max=0) const
 
cGroup * GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
cGroup * GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0)
 
cGroup * GetInsertPtrAt (const TUse &tag, size_t pos)
 
RContainer< cGroup, false,
false > * 
GetPtrs (const TUse &tag, size_t min=0, size_t max=0) const
 
size_t GetTab (const void **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (void **tab, size_t min=0, size_t max=0)
 
size_t GetTab (const cGroup **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (cGroup **tab, size_t min=0, size_t max=0)
 
void InsertPtrAt (cGroup *ins, size_t pos, bool del)
 
void InsertPtrAt (cGroup *ins, size_t pos)
 
void InsertPtr (cGroup *ins, bool del=false, size_t min=0, size_t max=0)
 
void DeletePtrAt (size_t pos, bool shift, bool del)
 
void DeletePtrAt (size_t pos, bool shift)
 
void DeletePtrAt (size_t pos)
 
void DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0)
 
void DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
void DeletePtr (const TUse &tag, size_t min=0, size_t max=0)
 
void Inter (const iRContainer< cGroup > &src1, const iRContainer< cGroup > &src2)
 
void Union (const iRContainer< cGroup > &src1, const iRContainer< cGroup > &src2)
 
virtual ~RContainer (void)
 
- Public Member Functions inherited from iRContainer< C >
size_t GetNb (void) const
 
size_t GetMaxPos (void) const
 
size_t GetMaxNb (void) const
 
size_t GetIncNb (void) const
 
bool VerifyIndex (size_t idx) const
 
void VerifyTab (size_t max=0)
 
void Clear (size_t m=0, size_t i=0, bool force=false)
 
void ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max)
 
void ReOrder (int sortOrder(const void *, const void *))
 
void ReOrder (void)
 
void Exchange (size_t pos1, size_t pos2)
 
void Shift (size_t idx, bool reverse)
 
void Transfer (iRContainer< C > &src)
 
iRContaineroperator= (const iRContainer< C > &src)
 
void Copy (const iRContainer< C > &src)
 
iRContaineroperator+= (const iRContainer< C > &src)
 
size_t GetIndex (bool order, const TUse &tag, bool &find, size_t min=0, size_t max=0) const
 
size_t GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const
 
bool IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
bool IsIn (const TUse &tag, size_t min=0, size_t max=0) const
 
const C * operator[] (size_t idx) const
 
C * operator[] (size_t idx)
 
const C * GetPtrAt (size_t idx) const
 
C * GetPtrAt (size_t idx)
 
C * GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
C * GetPtr (const TUse &tag, size_t min=0, size_t max=0) const
 
C * GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
C * GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0)
 
C * GetInsertPtrAt (const TUse &tag, size_t pos)
 
size_t GetTab (const void **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (void **tab, size_t min=0, size_t max=0)
 
size_t GetTab (const C **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (C **tab, size_t min=0, size_t max=0)
 
void InsertPtrAt (C *ins, size_t pos, bool del)
 
void InsertPtrAt (C *ins, size_t pos)
 
void InsertPtr (C *ins, bool del=false, size_t min=0, size_t max=0)
 
void DeletePtrAt (size_t pos, bool shift, bool del)
 
void DeletePtrAt (size_t pos, bool shift)
 
void DeletePtrAt (size_t pos)
 
void DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0)
 
void DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
void DeletePtr (const TUse &tag, size_t min=0, size_t max=0)
 
void Inter (const iRContainer< C > &src1, const iRContainer< C > &src2)
 
void Union (const iRContainer< C > &src1, const iRContainer< C > &src2)
 
virtual ~iRContainer (void)
 

Protected Attributes

RGroupingHeuristic< cGroup,
cObj, cChromo > * 
Heuristic
 
- Protected Attributes inherited from RGroups< cGroup, cObj, cChromo >
RCursor< cObj > Objs
 
size_t MaxObjId
 
size_t * ObjectsAss
 
RContainer< cObj, false, false > ObjsAss
 
RContainer< cObj, false, false > ObjsNoAss
 
size_t * OrdObjectsAss
 
size_t * NewUsedId
 
- Protected Attributes inherited from iRContainer< C >
C ** Tab
 
size_t NbPtr
 
size_t MaxPtr
 
size_t LastPtr
 
size_t IncPtr
 

Private Member Functions

void CopyGroups (cChromo *parent1, cChromo *parent2, size_t pos1, size_t begin, size_t end, size_t pos2, size_t nb2)
 

Additional Inherited Members

- Static Public Member Functions inherited from RContainer< cGroup, true, false >
static int SortOrder (const void *a, const void *b)
 
- Static Public Member Functions inherited from iRContainer< C >
static int SortOrder (const void *a, const void *b)
 
- Public Attributes inherited from RChromo< cInst, cChromo, cFit, cThreadData >
cInst * Instance
 
size_t Id
 
cFit * Fitness
 
bool ToEval
 
- Public Attributes inherited from RGroups< cGroup, cObj, cChromo >
RContainer< cGroup, false, false > Used
 
- Protected Member Functions inherited from iRContainer< C >
void Create (const iRContainer< C > &src)
 
iRContainerNormalCopy (const iRContainer< C > &src)
 
void DeepCopy (const iRContainer< C > &src)
 
iRContainerAdd (const iRContainer< C > &src)
 

Detailed Description

template<class cInst, class cChromo, class cFit, class cThreadData, class cGroup, class cObj>
singleton R::RChromoG< cInst, cChromo, cFit, cThreadData, cGroup, cObj >

GGA Chromosome.

The RChromoG class provides a representation for a chromosome for the GGA.

Constructor & Destructor Documentation

RChromoG ( cInst *  inst,
size_t  id 
)

Construct the chromosome.

Parameters
instThe instance.
idIdentifier of the chromosome.
virtual ~RChromoG ( void  )
virtual

Destruct the chromosome.

Member Function Documentation

virtual void Init ( cThreadData *  thData)
virtual

Initialization of the chromosome.

Parameters
thDataPointer to the "thread-dependent" data of the chromosome.

Reimplemented from RChromo< cInst, cChromo, cFit, cThreadData >.

Reimplemented in RChromoSG< cInst, cChromo, cThreadData, cGroup, cObj >, and RChromoNN< cInst, cChromo, cThreadData, cGroup, cObj >.

virtual void Clear ( void  )
virtual

Clear all the information of the chromosome.

virtual void RandomConstruct ( void  )
virtual

Construct a valid solution.

Returns
The function must return true if a solution has been constructed.

Reimplemented from RChromo< cInst, cChromo, cFit, cThreadData >.

void CopyGroups ( cChromo *  parent1,
cChromo *  parent2,
size_t  pos1,
size_t  begin,
size_t  end,
size_t  pos2,
size_t  nb2 
)
private

This method simply copies nb2 groups of parent2 beginning at pos2 and verifies if some objects are in one of the nb1 groups of parent1 beginning at pos1.

In regards of the parameter of the instance, the groups of parent2 containing objects of parent1 are copied (and the common objects not) or not.

Parameters
parent1Parent 1.
parent2Parent 2.
pos1Position in parent 1.
beginNumber of "first" groups of parent 1 to verify.
endNumber of groups after pos1 of parent 1 to verify.
pos2Position in parent 2.
nb2Number of groups of parent2 of copy.
virtual void Crossover ( cChromo *  parent1,
cChromo *  parent2 
)
virtual

Do a crossover by using the chromosome as child. The crossover implemented is the BPX (bin packing crossover). The groups of parent1 containing objects that are inserted from parent2 are removed. Also, if a group of parent1 is not compatible (IsCompatible) with one of the groups inserted from parent2 it is also removed.

Parameters
parent1First parent used.
parent2Second parent used.

Reimplemented from RChromo< cInst, cChromo, cFit, cThreadData >.

virtual void Mutation ( void  )
virtual

Do a mutation of the chromosome, by choosing randomly groups and destroy them.

Reimplemented from RChromo< cInst, cChromo, cFit, cThreadData >.

virtual void Inversion ( void  )
virtual

Do a inversion of the chromosome, by exchanging two groups in list representing all the used one.

Reimplemented from RChromo< cInst, cChromo, cFit, cThreadData >.

virtual void LocalOptimisation ( void  )
virtual

Perform a local optimization. This function is called by the crossover and the mutation operators just before the use of the heuristic to find a group for the objects not yet assigned.

Reimplemented in RChromoSG< cInst, cChromo, cThreadData, cGroup, cObj >.

virtual void Optimisation ( void  )
virtual

Perform an optimization. This function is called at the end of the crossover and the mutation operators.

Reimplemented from RChromo< cInst, cChromo, cFit, cThreadData >.

Reimplemented in RChromoSG< cInst, cChromo, cThreadData, cGroup, cObj >.

virtual void Modify ( void  )
virtual

Modify a given chromosome when it is identical to another one. By default, the mutation operator of the chromosome is called.

virtual void Verify ( void  )
virtual

Verify the validity of the chromosome.

Reimplemented from RChromo< cInst, cChromo, cFit, cThreadData >.

virtual void Copy ( const cChromo &  chromo)
virtual

The assignment operator.

Parameters
chromoThe chromosome used as source.

Reimplemented from RChromo< cInst, cChromo, cFit, cThreadData >.

Reimplemented in RChromoSG< cInst, cChromo, cThreadData, cGroup, cObj >, and RChromoNN< cInst, cChromo, cThreadData, cGroup, cObj >.

Member Data Documentation

RGroupingHeuristic<cGroup,cObj,cChromo>* Heuristic
protected

Heuristic used for the clustering.