func naturalSelection(pool []Organism, population []Organism) []Organism {
	next := make([]Organism, len(population))
	for i := 0; i < len(population); i++ {
		r1, r2 := rand.Intn(len(pool)), rand.Intn(len(pool))
		a := pool[r1]
		b := pool[r2]

		child := crossover(a, b)
		child.mutate()

		if !child.isValid() {
			child = createOrganism(cost_matrix, flow_matrix, alpha, no_hubs)
		}

		child.calcFitness()

		next[i] = child
	}
	return next
}
// perform natural selection to create the next generation
perform natural selection to create the next generation
// perform natural selection to create the next generation
func naturalSelection(pool []Organism, population []Organism) []Organism {
	next := make([]Organism, len(population))
	for i := 0; i < len(population); i++ {
		r1, r2 := rand.Intn(len(pool)), rand.Intn(len(pool))
		a := pool[r1]
		b := pool[r2]
		child := crossover(a, b)
		child.mutate()
		if !child.isValid() {
			child = createOrganism(cost_matrix, flow_matrix, alpha, no_hubs)
		}
		child.calcFitness()
		next[i] = child
	}
	return next
}
func naturalSelection ( pool [ ] Organism , population [ ] Organism ) [ ] Organism { next := make ( [ ] Organism , len ( population ) ) for i := 0 ; i < len ( population ) ; i ++ { r1 , r2 := rand . Intn ( len ( pool ) ) , rand . Intn ( len ( pool ) ) a := pool [ r1 ] b := pool [ r2 ] child := crossover ( a , b ) child . mutate ( ) if ! child . isValid ( ) { child = createOrganism ( cost_matrix , flow_matrix , alpha , no_hubs ) } child . calcFitness ( ) next [ i ] = child } return next }
perform natural selection to create the next generation
perform natural selection to create the next generation