----------------------------- ' SQR((A_opt-A_value)^2 + (B_opt-B_value)^2) AB_child_dist_sum = AB_child_dist_sum + AB_dist 'for getting the average IF AB_dist > AB_child_dist_max THEN AB_child_dist_max = AB_dist ELSEIF AB_dist < AB_child_dist_min THEN AB_child_dist_min = AB_dist END IF ' calculate distance (selection) effect on number of copies per individual ' measure is 0 at average distance, 1 at least distance, -1 at max. distance ' -- add 1 to make it 0 at max distance, 1 at avg. and 2 at min ' -- so it could function as pop_offspring_count that is neutral on population growth ' pop_offspring_rate_AB_dist: limit the impact of the distance measure ' -- so it only affects some percentage of the reproduction rate AB_dist = aPop_2gen(2,pop_count) ' parent's distance from optimum ' IF AB_dist < AB_child_dist_avg THEN '--lower pop_offspring_up ' closer to AB_dist_min gets a larger positive effect, higher % of pop_offspring_count=2 ' (avg is neutral), further gets higher % of pop_offspring_count=0 AB_dist_sel = (AB_dist - AB_dist_min) / (AB_dist_max - AB_dist_min) pop_offspring_up1 = pop_offspring_up - (1.0 - AB_dist_sel) * pop_offspring_rate_AB_dist / 100 pop_offspring_low1 = pop_offspring_low + (AB_dist_sel * pop_offspring_rate_AB_dist / 100) ' ELSE ' AB_dist_sel = (AB_dist - AB_child_dist_avg) / (AB_dist_max - AB_dist_min) ' pop_offspring_low1 = pop_offspring_low + (1.0 - AB_dist_sel) * pop_offspring_rate_AB_dist / 100 ' pop_offspring_up1 = pop_offspring_up - (AB_dist_sel * pop_offspring_rate_AB_dist / 100) ' END IF aPop_2gen(2,pop_count) = AB_dist_sel aPop_2gen(3,pop_count) = pop_offspring_count