[galib] Newbie question: how to pass parameters to the (Paul Smith)
Paul Smith
phhs80 at gmail.com
Wed Jun 30 13:43:11 EDT 2010
Thanks, Guillaume, I have now understood your idea. I like specially
the idea of using the class problem, and I plan to use that.
Paul
2010/6/30 Guillaume Massé <guillaume.masse at polymtl.ca>:
> 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/
>
> _______________________________________________
> galib mailing list
> galib at mit.edu
> http://mailman.mit.edu/mailman/listinfo/galib
>
>
More information about the galib
mailing list