< = ", N[fitnSum/popSize]]; bitPopNew = {}; Do[ selind1 = propSelection[bitPop, pSelect]; selind2 = propSelection[bitPop, pSelect]; If[Random[] < pco, children = onePointCO[selind1, selind2], children = {selind1, selind2}]; bitPopNew = Append[bitPopNew, children[[1]]]; bitPopNew = Append[bitPopNew, children[[2]]]; , {m, 1, popSize, 2} ]; bitPop = MUTATION[bitPopNew, pm]; If[ gen > genStop, Break[] ] ]; bitPop ) (* ************************************************************************** *) (* ************************************************************************** *) (* Experiment 1 *) simpleGA[8, 6, 50, 0.01] simpleGA[50, 24, 200, 0.001] (* ************************************************************************** *) (* Experiment 2 *) Remove[fitness] Remove[simpleGA] (* insert simpleGA definition here *) fitness[ind_] := ( sLength = Dimensions[ind][[1]]; Sum[ ind[[k]], {k, 1, sLength} ] ) simpleGA[50, 30, 200, 0.001] simpleGA[50, 100, 200, 0.0005]