architecture code and speed up Objective function ?
nicolas baurin
nicolas.baurin at univ-orleans.fr
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 &
matrix);
//a function treating the matrix corresponding to a genome and returning
the score
//within Objective
void main (
...
//classical
)
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)
sum=0;
//get the number of genes present in the genome
for( int i=0; i<genome.length(); i++) sum += genome.gene(i);
v2f
deschr;
//create a local double matrix of size 15*sum
deschr.resize(height);
for (int j=0;j<deschr.size();j++) {deschr[j].resize(sum);}
p=0;
// 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];}
p++;
}
}
float = score myfunc
(deschr);
// treat my local matrix within myfunc to calculate the score
return score;
}
--
Nicolas Baurin
Doctorant
Laboratoire de Chimiométrie - Modélisation Moléculaire
Institut de Chimie Organique et Analytique, UMR 6005
http://www.univ-orleans.fr/SCIENCES/ICOA/
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...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20010131/5507b972/attachment.htm
More information about the galib
mailing list