1、ex1.c文件中,遍历结果基因的代码:
const GAGenome& bestGenome = ga.statistics().bestIndividual();
const GA2DBinaryStringGenome& strGen = (const GA2DBinaryStringGenome&)bestGenome;
vector<vector<int>> vecTmp;
for (unsigned int j = 0; j < strGen.height(); j++) {
vector<int> vec;
for (unsigned int i = 0; i < strGen.width(); i++)
{
vec.push_back(strGen.gene(i, j));
}
vecTmp.push_back(vec);
}
2、案例说明: