architecture code and speed up Objective function ?

nicolas baurin nicolas.baurin at
Wed Jan 31 13:58:15 EST 2001

Hello to all galib people,

i'm using basically the galib for the moment by just  modifying the
Objective function as followying with userData. I'd like to know if i
will gain speed by incorporating
all the calculation made within myfunc by deriving a new genome class
(or equivalent) that will incorporate the same calculation or else?

(the genome is used to create a sub-matrix from an original
matrix=userdata, the genome says which columns from the original matrix
are to treated to calculate the score):

typedef vector < vector <double > >
v2f;                                                    //for
manipulation of double matrix
float myfunc (v2f &
//a function treating the matrix corresponding to a genome and returning
the score

//within Objective
void main (

float  Objective(GAGenome& g) {
   GA1DBinaryStringGenome & genome = (GA1DBinaryStringGenome &)g;
   int height = 15;
   int width = 5;
   double **pattern = (double
**)genome.userData();                                      //get my
original data matrix of size 15*5 (height*width)

//get the number of genes present in the genome
   for( int i=0; i<genome.length(); i++)    sum += genome.gene(i);

//create a local double matrix of size 15*sum
  for (int j=0;j<deschr.size();j++) {deschr[j].resize(sum);}

// fill my local matrix from the original matrix (columns selected by
the genome
  for (j=0;j<genome.length();j++)
{                                                                //such
as genome.length=width)
   if (genome.gene(j)==1) {
    for (int k=0;k<height;k++) {deschr[k][p]=pattern[k][j];}

float = score myfunc
// treat my local matrix within myfunc to calculate the score

return score;

Nicolas Baurin

Laboratoire de Chimiométrie - Modélisation Moléculaire
Institut de Chimie Organique et Analytique, UMR 6005
Université d'Orléans, BP 6759
45067 ORLEANS Cedex 2, France
Tel: (33+) 2 38 49 45 77

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the galib mailing list