/// <summary> /// Returns the sum of the weights of all items in the backpack of the inhabitant. /// </summary> /// <param name="inhabitant"></param> /// <returns></returns> public double GetWeight(Inhabitant inhabitant) { double weight = 0.0; for (uint i = 0; i < Size; i++) weight += element_array[i].Weight * (inhabitant.GetChromosome()[i] ? 1.0 : 0.0); return weight; }
/// <summary> /// Returns the sum of the values of all items in the backpack of the inhabitant. /// </summary> /// <param name="inhabitant"></param> /// <returns></returns> public double GetValue(Inhabitant inhabitant) { double value = 0.0; for (uint i = 0; i < Size; i++) value += element_array[i].Value * (inhabitant.GetChromosome()[i] ? 1.0 : 0.0); return value; }