[galib] Newbie question: how to pass parameters to the (Paul Smith)

Guillaume Massé guillaume.masse at polymtl.ca
Wed Jun 30 12:18:19 EDT 2010


I was thinking something like that

C function with global variable

const float PARAM = 10.0;

float fun_objective(GAGenome & c)
{
    return PARAM;
}

int main()
{

   ...Genome genome( ..., fun_objective );
   GA.. ga(genome);
}

OR

C++ Class

class Problem{
public:
   Problem( int p): param( p ) { }
   float objective( GAGenome & c ){ return param; }
private:
   float param;
}

int main()
{
   Problem prob( 10.0 );
   ...Genome genome( ..., prob.objective() );
   GA.. ga(genome);
}


> Thanks, Guillaume. When you write


"Global variables and a function",


do you mean


"Global variables AND a function"


or


"Global variables OR a function" ?


Paul

______________
Guillaume Massé
École polytechnique de Montréal
http://www.info.polymtl.ca/~gumasa/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20100630/b593a00a/attachment.htm


More information about the galib mailing list