0

此函数接收另一个值(生成参数)。我的目标是在 cloneGene 变量中返回 onde 数组,尽管它看起来像 NaN,我不知道为什么。

function SampleWithReposition(generation, newGeneration) {
   newGeneration = [];
   generation = Starting_generation; 
   var randomGeneration = Math.floor(Math.random() * pop_size) + 0;

     for(i=0;i<pop_size;i++){
           newGeneration = generation[i] = generation[randomGeneration];

        }

       return newGeneration;
       GenerationStep(newGeneration);
       //document.write(newGeneration + ' <br />' + ' <br />');

    }


//Mutation and recombination rate
 function GenerationStep (mutation_rate, recombination_rate, generation, cloneGene) {
//var generation = [1, 2, 1, 54, 1, 1, 1];
generation = SampleWithReposition();
mutation_rate = recombination_rate = 0.1;

for(var i=0; i<pop_size; i++){
    for(var j=0;j<gene_size; j++){
        random_number = random();
        var max_individual = Math.max.apply(Math, generation);

            //mutation_rate
            if(random_number < mutation_rate){
                var cloneGene = 1;
                cloneGene=generation[i][j]=generation[max_individual][j]+1;

                    document.write(cloneGene);


            }

   }

}

4

0 回答 0