public bool IsFeasible(Knapsack knapsack) { int sum = 0; for (int i = 0; i < genes.Length; i++) { sum += genes[i] ? knapsack.GetWeight(i) : 0; } if (sum > knapsack.constraint) { return(false); } return(true); }
public bool IsFeasible(Knapsack knapsack) { int sum = 0; for (int i = 0; i < genes.Length; i++) { sum += genes[i] ? knapsack.GetWeight(i) : 0; } if (sum > knapsack.constraint) { return false; } return true; }