[galib] Unhandled exception

Daiyue Weng dweng01 at qub.ac.uk
Mon Feb 10 06:40:45 EST 2014


Hi,all, I am using GAlib in my Visual Studio MFC project and encountered a Unhandled exception when using GA initialize() :



Unhandled exception at 0x765b2eec in XMLDOMFromVC.exe: Microsoft C++ exception: _com_error at memory location 0x00f9de10..



My code is as follows:



void CGATrainingDlg::OnBnClickedGaTrainButton()
{
// TODO: Add your control notification handler code here
GARealAlleleSetArray alleles2a;
for(int i=0; i<m_nAlleleSetArrayLen; i++)
alleles2a.add(0, 1, GAAllele::EXCLUSIVE, GAAllele::INCLUSIVE);

GARealGenome genome2a(alleles2a, ObjectiveTrampoline, this);
genome2a.mutator(GARealIncrementalMutator);
genome2a.crossover(GARealOnePointCrossover);

// Now do a genetic algorithm for each one of the genomes that we created.
GASimpleGA ga(genome2a);

// Now that we have the genomes, create a parameter list that will be used for
// all of the genetic algorithms.
GAParameterList params;
GASimpleGA::registerDefaultParameters(params);
params.set(gaNpCrossover, m_dPCross);
params.set(gaNpMutation, m_dPMut);

if(BST_CHECKED == IsDlgButtonChecked(IDC_GA_CONVERGENCE_RADIO))
{
params.set(gaNpConvergence, m_fPconv);
params.set(gaNnConvergence, m_nConv);
ga.terminator(GAGeneticAlgorithm::TerminateUponConvergence);
}else{
params.set(gaNnGenerations, m_nGAGen);
}

params.set(gaNpopulationSize, m_nGAPopSize);
params.set(gaNscoreFrequency, m_nScoreFreq);
params.set(gaNflushFrequency, m_nFlushFreq);
params.set(gaNselectScores, (int)GAStatistics::AllScores);

if((m_fPconv == 0 || m_nConv == 0) && m_nGAGen == 0)
{
AfxMessageBox(_T("You need to specify parameters for GA Terminator"));
exit(EXIT_FAILURE);
}

ga.parameters(params);
// the following line is where the exception happened
ga.initialize();
/* some other code*/
}



I have been followed an example (ex7.C) that use `initialize()`, but do not know why I encountered this runtime exception, can anyone suggest me what to do?



cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20140210/353cd917/attachment.htm


More information about the galib mailing list