Esempio n. 1
0
        public double Evaluate(City warehouse, int k)
        {
            int length = 0;
            var i = Cities.GetEnumerator();
            double totalLength = 0;
            City previousCity = warehouse;
            City currentCity;

            while (i.MoveNext())
            {
                currentCity = i.Current;
                totalLength += previousCity.Distance(currentCity);
                previousCity = currentCity;
                ++length;
                if (length == k)
                {
                    totalLength += previousCity.Distance(warehouse);
                    previousCity = warehouse;
                    length = 0;
                }
            }

            if (length != 0)
                totalLength += previousCity.Distance(warehouse);

            Evaluation = totalLength;
            return totalLength;
        }
Esempio n. 2
0
 public double Distance(City to)
 {
     return Math.Sqrt(Math.Pow(x - to.x, 2) + Math.Pow(y - to.y, 2));
 }