<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hello to all galib people,
<p>i'm using basically the galib for the moment by just modifying
the Objective function as followying with userData. <u>I'd like to know
if i will gain speed by incorporating</u>
<br><u>all the calculation made within myfunc by deriving a new genome
class (or equivalent) that will incorporate the same calculation or else?</u>
<p>(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):
<p>typedef vector < vector <double > > v2f;
//for manipulation of double matrix
<br>float myfunc (v2f & matrix);
//a function treating the matrix corresponding to a genome and returning
the score
<br>
//within Objective
<br>void main (
<br>...
//classical
<br>)
<p>float Objective(GAGenome& g) {
<br> GA1DBinaryStringGenome & genome = (GA1DBinaryStringGenome
&)g;
<br> int height = 15;
<br> int width = 5;
<br> double **pattern = (double **)genome.userData();
//get my original data matrix of size 15*5 (height*width)
<p> sum=0;
//get the number of genes present in the genome
<br> for( int i=0; i<genome.length(); i++)
sum += genome.gene(i);
<br>
<br> v2f deschr;
//create a local double matrix of size 15*sum
<br> deschr.resize(height);
<br> for (int j=0;j<deschr.size();j++) {deschr[j].resize(sum);}
<br>
<br> p=0;
// fill my local matrix from the original matrix (columns selected by the
genome
<br> for (j=0;j<genome.length();j++) {
//such as genome.length=width)
<br> if (genome.gene(j)==1) {
<br> for (int k=0;k<height;k++) {deschr[k][p]=pattern[k][j];}
<br> p++;
<br> }
<br> }
<p>float = score myfunc (deschr);
// treat my local matrix within myfunc to calculate the score
<p>return score;
<br>}
<br>
<br>
<br>
<br>
<p>--
<br>Nicolas Baurin
<p>Doctorant
<br>Laboratoire de Chimiométrie - Modélisation Moléculaire
<br>Institut de Chimie Organique et Analytique, UMR 6005
<br><A HREF="http://www.univ-orleans.fr/SCIENCES/ICOA/">http://www.univ-orleans.fr/SCIENCES/ICOA/</A>
<br>Université d'Orléans, BP 6759
<br>45067 ORLEANS Cedex 2, France
<br>Tel: (33+) 2 38 49 45 77
<br> </html>