Example #1
0
    public void CrossoverSliceTwoIndividualsTest()
    {
        Vector <float> first  = geneSeed.GetIndividual(0);
        Vector <float> second = geneSeed.GetIndividual(1);


        geneSeed.CrossoverSliceTwoIndividuals(0, 1, 2, 5);


        Assert.AreEqual(first.SubVector(0, 2), geneSeed.GetIndividual(1).SubVector(0, 2));
        Assert.AreEqual(second.SubVector(0, 2), geneSeed.GetIndividual(0).SubVector(0, 2));

        Assert.AreEqual(first.SubVector(5, 5), geneSeed.GetIndividual(1).SubVector(5, 5));
        Assert.AreEqual(second.SubVector(5, 5), geneSeed.GetIndividual(0).SubVector(5, 5));


        /*Debug.Log(geneSeed.GetPopulation());
         * var watch = System.Diagnostics.Stopwatch.StartNew();
         * for(int i=0; i < 1000000;i++)
         *  geneSeed.CrossoverSliceTwoIndividualsColumns(0, 1, 2, 5);
         *
         * watch.Stop();
         * var elapsedMs = watch.ElapsedMilliseconds;
         *
         * Debug.Log("Time Matrix: " + elapsedMs);
         *
         * watch = System.Diagnostics.Stopwatch.StartNew();
         * for (int i = 0; i < 1000000; i++)
         *  geneSeed.CrossoverSliceTwoIndividuals(0, 1, 2, 5);
         * watch.Stop();
         * elapsedMs = watch.ElapsedMilliseconds;
         * Debug.Log("Time Column: " + elapsedMs);*/

        //geneSeed.CrossoverSliceTwoIndividualsColumns(0, 1, 2, 5);

        //Assert.AreEqual();

        //Debug.Log(geneSeed.GetIndividual(0));// + " " + geneSeed.GetIndividual(1));
        //Debug.Log(geneSeed.GetIndividual(1));
    }