getting data to the genome (Re: Objective(GAGenome& g...)
Matthew Wall
mbwall at MIT.EDU
Fri Jun 2 09:00:39 EDT 2000
to get additional information into a genome or objective function,
you should either derive a new genome class that has data members for
the information you are trying to pass, or you should use a
'userData' object with an existing galib genome.
deriving a new genome is described in the 'extensions' portion of the
documentation.
if you do the userData option, then your userData class would be
something like this:
class MyUserData : public GAUserData {
double* Rdata;
int* Rrow;
int* Rcol;
double* Rpki;
public:
MyUserData();
~MyUserData();
MyUserData* clone();
void copy(const GAUserData&);
};
to use it, something like this:
main() {
MyUserData data;
GA1DBinarySringGenome genome(length, ObjectiveFunction, data);
GASimpleGA ga(genome);
ga.evolve();
}
float
ObjectiveFunction(GAGenome& g) {
GA1DBinaryStringGenome& genome = (GA1DBinaryStringGenome&)g;
MyUserData* d = (MyUserData*)(genome.userData());
// objective stuff here
}
MyUserData::clone must be able to generate a new user data instance.
MyUserData::copy must be able to duplicate an existing user data
object.
>Hello galib people,
>
>i need for evaluation of the scoring function to pass other argument
>(double * Rdata, int * Rrow, int * Rcol, double * Rpki)
>from the main part.
>
>Of course when i compile i got :
>
>error C2664: 'GA1DBinaryStringGenome::GA1DBinaryStringGenome(unsigned
>int,float (__cdecl *)(class GAGenome &),void *)' : cannot convert
>parameter 2 from 'float (class GAGenome &,double *,int *,int *,double
>*)' to 'float (__cdecl *)(class GAGenome &)'
>
>Is it possible by modifying the Gagenome.h or Gagenome.C codes
>
>or is there any to pass my arguments elseway
More information about the galib
mailing list