Ejemplo n.º 1
0
        //[TestMethod]
        public void TestA3()
        {
            Boolean passed = true;
            initialiseA();
            GeneticEngine testEngine = new GeneticEngine(APopulator, AEvaluator, AGeneticOperator, AFitnessThresholdTerminator, AOutputter, null);
            //testEngine.Reset();
            if (testEngine.IsComplete) passed = false;//throw new Exception("Is Complete returns true when expected value is false.");
            testEngine.Step();
            if (testEngine.IsComplete) passed = false;// throw new Exception("Is Complete returns true when expected value is false.");
            testEngine.Repeat(99);
            if (testEngine.IsComplete) passed = false;// throw new Exception("Is Complete returns true when expected value is false.");
            testEngine.Step();
            if (!testEngine.IsComplete) passed = false;// throw new Exception("Is Complete returns false when expected value is true.");

            Assert.IsTrue(passed);
            //If no exceptions halt test, then successful:
            Console.WriteLine("Test A3 Successful");
        }
Ejemplo n.º 2
0
 public void TestA4()
 {
     initialiseA();
     GeneticEngine testEngine = new GeneticEngine(APopulator, AEvaluator, AGeneticOperator, AFitnessThresholdTerminator, AOutputter, null);
     //testEngine.Reset();
     testEngine.Repeat(5);
     currentGeneration = testEngine.Generation;
     //Assert.Equals
     Assert.AreEqual(5, AOutputter.numberGenerations);
     //Fails here, output expected is 99 but 0 is returned. The assertions after this pass though (101, 103,..)
     Assert.AreEqual(101, AOutputter.fitnesses[1]);
     Assert.AreEqual(103, AOutputter.fitnesses[2]);
     Assert.AreEqual(105, AOutputter.fitnesses[3]);
     Assert.AreEqual(107, AOutputter.fitnesses[4]);
 }
Ejemplo n.º 3
0
        static void run()
        {
            IPopulator populator = new Populator("map.xml");
            IEvaluator evaluator = new Evaluator(null);
            IGeneticOperator mutator = new Mutator(null);
            ITerminator terminator = new FitnessThresholdTerminator(FitnessConverter.FromFloat(1.0f / 1024.0f));
            IOutputter outputter = new RoadNetworkXmlOutputter(@"c:\roadnetworktest\index.xml");

            GeneticEngine engine = new GeneticEngine(populator, evaluator, mutator, terminator, outputter);
            engine.Repeat(100);
            engine.FinishOutput();
        }