在遗传算法中永远不会达到100%

never reach 100% in Genetic algorithm

本文关键字:100% 遗传算法 永远      更新时间:2023-10-16

我的主要程序,我认为这一切都正确,有人可以告诉我我的错误,我从来没有100%健身

我对此很反感,如果您知道

,请回答我
void mutate(population *parent,int ratio){
for(unsigned int i=0; i<sizeof(parent[0].gen); i++){
    int condition = (rand()%11);
    int temp0 = (int)parent[0].gen[i];
    int temp1 = (int)parent[1].gen[i];
    if(condition < ratio){
        if(temp0+10 <127 ){
            parent[0].gen[i] = char(temp0 + 10);
            //cout<<temp0<<endl;
        }else{
            temp0 = temp0 + 10 - 80;
            parent[0].gen[i] = char(temp0);
           // cout<<(int)parent[0].gen[i]<<endl;
        }
        if(temp1+10 <127 ){
            parent[1].gen[i] = char(temp1 + 10);
            //cout<<temp0<<endl;
        }else{
            temp1 = temp1 + 10 - 80;
            parent[1].gen[i] = char(temp1);
        }
    }
}

这是我用于突变的示例代码,如下图中的图片中的完整程序

genitygorithm_1genitygorithm_1

尚不清楚您要解决的问题,但很可能是NP完整性,如果没有机器学习,其他类型可以更有效地解决。但是您必须了解,NP完整性问题的精确解决方案需要详尽的搜索所有可能的解决方案。机器学习无法避免此问题,因此100%准确性的成就比基于Brutfors的方法更容易。机器学习的目的,特别是遗传算法的目的是在A 中找到可接受的解决方案>可接受的时间