Visual c++ 在MFC项目中使用GAlib时未处理的异常
总之,我在VC++MFC项目中使用GAlib,在使用GA初始化函数时遇到未处理的异常:Visual c++ 在MFC项目中使用GAlib时未处理的异常,visual-c++,mfc,genetic-algorithm,genetic-programming,Visual C++,Mfc,Genetic Algorithm,Genetic Programming,总之,我在VC++MFC项目中使用GAlib,在使用GA初始化函数时遇到未处理的异常: Unhandled exception at 0x765b2eec in XMLDOMFromVC.exe: Microsoft C++ exception: _com_error at memory location 0x00f9de10.. 这是我的代码,遵循GAlib中的示例: void CGATrainingDlg::OnBnClickedGaTrainButton() { // TODO: Add
Unhandled exception at 0x765b2eec in XMLDOMFromVC.exe: Microsoft C++ exception: _com_error at memory location 0x00f9de10..
这是我的代码,遵循GAlib中的示例:
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*/
}
我一直在关注一个使用GA initialize的示例ex7.C,但不知道导致此异常的原因,所以知道如何修复此问题吗
干杯你在动态链接GALib吗?您是否尝试过在调试器中运行程序并进入ga.initialize?GASimpleGA在构造和初始化之间必须调用哪些函数?参数是否自动初始化?初始化是否调用ObjectiveTrampoline?在ObjectiveTrampoline中设置断点以查找。这个函数崩溃了吗?您是否正在访问该函数中传递的?