Beispiel #1
0
        public void TestPopulationSeeding()
        {
            var fTmp             = Path.GetTempFileName();
            var f                = Path.Combine(Path.GetDirectoryName(fTmp), Path.GetFileNameWithoutExtension(fTmp) + ".csv");
            int numScores        = 5;
            var pSet             = new ParameterSet(new MockTimeModel());
            var expectedMaxBound = 3.0;

            pSet.paramSpec("x").max = expectedMaxBound;
            var pSpaceReference = new MpiSysConfigTIME(pSet);

            IObjectiveScores[] scores = createScores(numScores);
            try
            {
                MetaheuristicsHelper.SaveAsCsv <MpiSysConfig>(scores, f);
                var seeds = GridModelHelper.LoadParameterSets(f, pSpaceReference);
                Assert.AreEqual(numScores, seeds.Length);
                Assert.AreEqual(expectedMaxBound, seeds[0].GetMaxValue("x"));
                Assert.AreEqual(MockTimeModel.getX(4), seeds[4].GetValue("x"), 1e-9);
                Assert.AreEqual(MockTimeModel.getY(3), seeds[3].GetValue("y"), 1e-9);
            }
            finally
            {
                if (File.Exists(f))
                {
                    File.Delete(f);
                }
                if (File.Exists(fTmp))
                {
                    File.Delete(fTmp);
                }
            }
        }
Beispiel #2
0
        private IObjectiveScores[] createScores(int p)
        {
            var parameterSets = new MpiSysConfig[p];

            for (int i = 0; i < p; i++)
            {
                var m = new MockTimeModel();
                m.x = MockTimeModel.getX(i);
                m.y = MockTimeModel.getY(i);
                parameterSets[i] = new MpiSysConfigTIME(new ParameterSet(m));
            }
            return(InMemoryLoggerTests.CreateTestScores(2, parameterSets));
        }