Пример #1
0
        static void evaluate()
        {
            XmlTextReader reader = new XmlTextReader("network.xml");

            reader.MoveToContent();

            RoadNetwork network = new RoadNetwork(reader);

            Console.WriteLine("Dimensions: " + network.Map.Width + " x " + network.Map.Height);
            Console.WriteLine("Start:" + network.Map.Start.X + ", " + network.Map.Start.Y);
            Console.WriteLine("End:" + network.Map.End.X + ", " + network.Map.End.Y);

            for (int i = 0; i < network.Map.TownCount; i++)
            {
                Coordinates town = network.Map.GetTown(i);
                Console.WriteLine("Town:" + town.X + "," + town.Y);
            }

            for (int i = 0; i < network.EdgeCount; i++)
            {
                Edge edge = network.GetEdge(i);
                Console.WriteLine("Edge:" + edge.Start.Coordinates.X + "," + edge.Start.Coordinates.Y + " - " + edge.End.Coordinates.X + "," + edge.End.Coordinates.Y);
            }

            IEvaluator evaluator = new Evaluator(null);

            uint fitness = evaluator.Evaluate(network);
            float v = FitnessConverter.ToFloat(fitness);

            Console.WriteLine("Fitness: " + fitness);
            Console.WriteLine("Floating Point Fitness: " + v + " " + 1 / v);
        }
Пример #2
0
 //[TestMethod]
 public void TestE1()
 {
     Evaluator RoadEvaluator = new Evaluator(null);
     GenerationIndex results = GenerationIndex.Load("index.xml");
     AATreeGeneration temp = new AATreeGeneration();
     for (int i = 0; i < results.Count; i++)
     {
         IGeneration generation = results[i].LoadGeneration(new RoadNetworkReader());
         for (int j = 0; j < results[i].Count; j++) {
             Assert.AreEqual(RoadEvaluator.Evaluate(((IndividualWithFitness)generation.Get(j)).Individual), generation.Get(j).Fitness);
         }
     }
 }