func (d *Organism) calcFitness() {
	var total_cost float64

	solution := d.DNA.Solution

	total_cost = 0.0
	for i, _ := range flow_matrix {
		for j, _ := range flow_matrix {
			collection_cost := flow_matrix[i][j] * cost_matrix[i][solution[i]]
			transportation_cost := flow_matrix[i][j] * cost_matrix[solution[i]][solution[j]] * alpha
			distribution_cost := flow_matrix[i][j] * cost_matrix[solution[j]][j]
			cost := collection_cost + transportation_cost + distribution_cost
			total_cost += cost
		}
	}

	d.Fitness = 1 / (total_cost / total_flow)
	d.DNA.Cost = total_cost / total_flow
	return
}
// calculates the fitness of the Organism
calculates the fitness of the Organism
// calculates the fitness of the Organism
func (d *Organism) calcFitness() {
	var total_cost float64
	solution := d.DNA.Solution
	total_cost = 0.0
	for i, _ := range flow_matrix {
		for j, _ := range flow_matrix {
			collection_cost := flow_matrix[i][j] * cost_matrix[i][solution[i]]
			transportation_cost := flow_matrix[i][j] * cost_matrix[solution[i]][solution[j]] * alpha
			distribution_cost := flow_matrix[i][j] * cost_matrix[solution[j]][j]
			cost := collection_cost + transportation_cost + distribution_cost
			total_cost += cost
		}
	}
	d.Fitness = 1 / (total_cost / total_flow)
	d.DNA.Cost = total_cost / total_flow
	return
}
func ( d * Organism ) calcFitness ( ) { var total_cost float64 solution := d . DNA . Solution total_cost = 0.0 for i , _ := range flow_matrix { for j , _ := range flow_matrix { collection_cost := flow_matrix [ i ] [ j ] * cost_matrix [ i ] [ solution [ i ] ] transportation_cost := flow_matrix [ i ] [ j ] * cost_matrix [ solution [ i ] ] [ solution [ j ] ] * alpha distribution_cost := flow_matrix [ i ] [ j ] * cost_matrix [ solution [ j ] ] [ j ] cost := collection_cost + transportation_cost + distribution_cost total_cost += cost } } d . Fitness = 1 / ( total_cost / total_flow ) d . DNA . Cost = total_cost / total_flow return }
calculates the fitness of the Organism
calculates the fitness of the Organism