[galib] GaLib: RealGenome boundaries

Jörg Mennicke mail at joerg-mennicke.de
Fri Jul 14 10:27:51 EDT 2006


Dear all,

 

I am using galib with GASimpleGA and GARealGenome:

 

This is the short version of the code that I am using to call the algorithm:

 

      //First the Alleles

      GARealAlleleSetArray alleles;

      //For all the parameters which are to be optimized 


      for(int i=0;i<m_params->GetNumberOptParams();i++){

//
add them to the alleles array (passed params were of course defined and
filled before)

alleles.add(m_fMinValue[i], m_fMaxValue[i], m_fStepSize[i], bMinbound[i],
bMaxbound[i]);

      }

 

      ParamOptimization* target = this;

 

      //Then the Genome

      GARealGenome genome(alleles, EvalGenome,(void *)target);

      //and the algorithm

      ga(genome);

      //Set Parameters for the algorithm


GAParameterList gaparams;

      GASimpleGA::registerDefaultParameters(gaparams);

 

      gaparams.set(gaNnGenerations, m_params->m_iNOGenerations); //#of
generations

      gaparams.set(gaNnBestGenomes, m_params->m_iNOBestGenomes); //#of best
genomes carried over to the next generation

      gaparams.set(gaNpopulationSize, m_params->m_iPopulationSize);
//size of the population in each generation

      gaparams.set(gaNscoreFrequency, m_params->m_iScoreFrequency);    //How
often to save the scores

      gaparams.set(gaNflushFrequency, m_params->m_iFlushFrequency);    //How
often to flush the scores to drive

      gaparams.set(gaNselectScores, (int)GAStatistics::AllScores);
//Save all scores

      gaparams.set(gaNpConvergence, m_params->m_fConvergencePercentage);
//termination condition: convergence percentage 

                                                           //Ratio of the
Nth previous best-of-generation score to the current best-of-generation
score 

      gaparams.set(gaNnConvergence, m_params->m_iNConvergence);  //N for the
convergence stopping criterion

      gaparams.set(gaNpCrossover, m_params->m_fCrossoverPercentage);
//Percentage of crossovermutations in each generation

      gaparams.set(gaNpMutation, m_params->m_fMutationPercentage);
//Percentage of mutations in each generation                               

      gaparams.set(gaNnPopulations, m_params->m_iNOPopulations); //# of
populations in each generation

      std::string outputname = m_params->m_sOutpDir + "/" +
m_params->m_sOutpFilestem + ".gascores";

      gaparams.set(gaNscoreFilename, outputname.c_str());  //Filename where
to save the scores to

      if(m_params->m_bElitism) { 

            gaparams.set(gaNelitism, gaTrue);              //Elitism on ->
Best individual is carried over to the next generation

      } else { 

            gaparams.set(gaNelitism, gaFalse); 

      }

      ga.parameters(gaparams);

 

      //Set Minimize or Maximize and evolve

      if(m_params->m_bMinimize) { 

            ga.minimize(); //Objective Function (e.g. Error) is minimized

      } else { 

            ga.maximize(); //Objective Function (e.g. Accuracy) is minimized

      }

      ga.evolve();

 

In the objective function after some valid parameterconfigurations I receive
a parameterconfiguration

Which has only values of ‘0’, although ‘0’ was not in the valid interval
specified in the initialisation of ‘alleles’!

The following is a short version of the code I am using for the objective
function:

 

      GARealGenome& genome = (GARealGenome&)g;

      ParamOptimization *OptEnv = (ParamOptimization *)g.userData();

      

      for(int i=0; i<genome.length(); i++){

            OptEnv->m_pCurrentParamConfig[i].m_fValue = genome.gene(i);

      }

      return OptEnv->EvaluateParamConfig(OptEnv->m_pCurrentParamConfig);

      //Get GAGenome bestIndividual 

 

Hope anybody can help me out and tell me why this happens.

 

Thanks for your time and replies,

Jörg Mennicke

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20060714/2084ce48/attachment.htm


More information about the galib mailing list