www.gusucode.com > GAVPai_Book_MathworksCntrlFileEx_May2019 > GAVPai_Book_MathworksCntrlFileEx_May2019/rand_varpt_arith_crossover.m
function [offspring_popln]= rand_varpt_arith_crossover(input_parent_popln, popln_size, genes) crossover_rate = 0.61; rand_arrange = randperm(popln_size); parent_popln = input_parent_popln(rand_arrange,:); for i = 1 : 2: (popln_size-1) parent1 = parent_popln(i,:); parent2 = parent_popln(i+1,:); a = rand; for j = 1: genes if (rand < crossover_rate) % perform cross over temp1 = parent1(j); temp2 = parent2(j); parent1(j)= a * temp1 + (1-a)* temp2; parent2(j)= (1-a)* temp1 + a * temp2; end end offspring_popln(i,:) = parent1; offspring_popln(i+1,:)= parent2; end