예제 #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);
                }
            }
        }
예제 #2
0
        /// <summary>
        ///   Writes the results.
        /// </summary>
        public void WriteResults()
        {
            Log.InfoFormat("Writing in-memory log to '{0}'", LogFileName);
            InMemoryLogger.CsvSerialise(LogFileName, "GriddedCalib");

            Log.InfoFormat("Root: saving final parameters to '{0}'", OutputFileName);
            MetaheuristicsHelper.SaveAsCsv <MpiSysConfig>(Results, OutputFileName);

            string parameterSetPath = Path.Combine(OutputPath.FullName, "BestParamSet.xml");

            Log.InfoFormat("Root: saving reseed parameters to '{0}'", parameterSetPath);
            GridModelHelper.WriteParameters <MpiSysConfig>(Results, SeedParametersFile, parameterSetPath);
        }