[galib] Help using GALib: customising crossover operator
#SAWHNEY ADITI#
aditi at pmail.ntu.edu.sg
Tue Jul 26 02:38:46 EDT 2005
hey,
I have customised my crossover operator but get the following errors during compiling.
the program:
-----------------------------------------------------------------------------------------------
....
int RouteCrossover(const GAGenome & , const GAGenome &, GAGenome *);
int SwapMutator(GAGenome & c, float );
....
int main(int argc, char *argv[])
{
....
GARealAlleleSet alleles;
....
GARealGenome genome(numCustomer+numVeh, alleles, objective);
genome.initializer(RouteInitializer);
genome.mutator(SwapMutator);
genome.crossover(RouteCrossover);
...}
--------------------------------------------------------------
W:\Latest\sce03-056\main.C(105) : error C2664: 'int (__cdecl *__thiscall GAGenome::crossover(int (__cdecl *)(const class GAGenome &,const class GAGenome &,class GAGenome *,class GAGenome *)))(const class GAGenome &,const class GAGenome &,class GAGen
ome *,class GAGenome *)' : cannot convert parameter 1 from 'int (const class GAGenome &,const class GAGenome &,class GAGenome *)' to 'int (__cdecl *)(const class GAGenome &,const class GAGenome &,class GAGenome *,class GAGenome *)'
None of the functions with this name in scope match the target type
________________________________
From: galib-bounces at mit.edu on behalf of Christophe Philemotte
Sent: Tue 7/19/2005 4:53 PM
To: galib at mit.edu
Subject: Re: [galib] Help using GALib: customising mutation operator
Hi,
Following the typedef int (*GAGenome::Mutator)(GAGenome &, float), you can
write your own mutation operator. To apply to a given genome, you have
just to use the method GAGenome::Mutator mutator(GAGenome::Mutator func).
In your case, that gives something like this:
int swap(GAGenome &g, float pmut) { ... }
int main() {
...
//g is your GARealGenome
g.mutator(swap);
...
}
you can find all these in the galib API:
http://lancet.mit.edu/galib-2.4/API.html
regards
christophe
> hey,
>
> I'm new to galib and c++ so have a basic question to ask.
> I am using real genomes and want to write my own mutation operator
> called "swap". so where do i place the code for this mutation operator
> n how do i set the genome class to use it?
>
> sincerely,
> Aditi
>
> _______________________________________________
> galib mailing list
> galib at mit.edu
> http://mailman.mit.edu/mailman/listinfo/galib
_______________________________________________
galib mailing list
galib at mit.edu
http://mailman.mit.edu/mailman/listinfo/galib
More information about the galib
mailing list