public void Insert(Version version)
        {
            _experiments.Add(nameof(Version.StartDateTime), version.StartDateTime);
            _experiments.Add(nameof(Version.ImplementationVersion), Version.ImplementationVersion);
            _experiments.Add(nameof(Version.ExperimentParametersHashString), version.ExperimentParametersHashString);

            _versions.Add(nameof(Version.StartDateTime), version.StartDateTime);
            _versions.Add(nameof(Version.ImplementationVersion), Version.ImplementationVersion);
            _versions.Add(nameof(Version.ExperimentParametersHashString), version.ExperimentParametersHashString);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;//CultureInfo.GetCultureInfo("en-US");

            var dbPath          = Path.GetFullPath("Database test.db");
            var databaseContext = new DatabaseContext(dbPath);

            //var experimentParameters = Arguments.GetExperimentParameters();

            var experimentParameters = new ExperimentParameters(2, 10,
                                                                typeOfMutation: ExperimentParameters.MutationType.Correlated,
                                                                typeOfBenchmark: ExperimentParameters.BenchmarkType.Simplexn,
                                                                stepThreshold: 0.1, numberOfGenerations: 1,
                                                                basePopulationSize: 15,
                                                                //basePopulationSize: 3,
                                                                offspringPopulationSize: 100,
                                                                //offspringPopulationSize: 20,
                                                                globalLerningRate: 1 / Math.Sqrt(2 * 2),
                                                                //globalLerningRate: 0.7,
                                                                individualLearningRate: 1 / Math.Sqrt(2 * Math.Sqrt(2)),
                                                                //individualLearningRate: 0.8,
                                                                numberOfPositivePoints: 10,
                                                                numberOfNegativePoints: 10,
                                                                ballnBoundaryValue: 2,
                                                                //simplexnBoundaryValue: 2,
                                                                seed: 1,
                                                                useRecombination: false,
                                                                numberOfParentsSolutionsToSelect: 5
                                                                //domainSamplingStep: 1
                                                                );

            if (databaseContext.Exists(experimentParameters))
            {
                return;
            }

            if (experimentParameters.TypeOfBenchmark == ExperimentParameters.BenchmarkType.Other)
            {
                experimentParameters.ConstraintsToPointsGeneration = ReferenceModelsExamples.Example1;
            }

            var version            = new Version(DateTime.Now, experimentParameters.GetHashString());
            var stoper             = new Stopwatch();
            var distanceCalculator = new CanberraDistanceCalculator();

            var engine = EngineFactory.GetEngine(experimentParameters);

            stoper.Restart();

            var positivePointsGenerator = new PositivePointsGenerator();
            var positiveTrainingPoints  = positivePointsGenerator.GeneratePoints(experimentParameters.NumberOfPositivePoints, engine.Benchmark);

            stoper.Stop();
            engine.Statistics.PositiveTrainingPointsGenerationTime = stoper.Elapsed;
            stoper.Restart();

            var negativePointsGenerator = new NegativePointsGenerator(positiveTrainingPoints, distanceCalculator, new NearestNeighbourDistanceCalculator(distanceCalculator));
            var negativeTrainingPoints  = negativePointsGenerator.GeneratePoints(experimentParameters.NumberOfNegativePoints, engine.Benchmark);

            stoper.Stop();
            engine.Statistics.NegativeTrainingPointsGenerationTime = stoper.Elapsed;

            var trainingPoints = positiveTrainingPoints.Concat(negativeTrainingPoints).ToArray();

            var mathModel = engine.SynthesizeModel(trainingPoints);

            stoper.Restart();

            var positiveTestPoints = positivePointsGenerator.GeneratePoints(experimentParameters.NumberOfPositivePoints, engine.Benchmark);

            var negativeTestPoints = negativePointsGenerator.GeneratePoints(experimentParameters.NumberOfNegativePoints, engine.Benchmark);

            var testPoints = positiveTestPoints.Concat(negativeTestPoints).ToArray();

            stoper.Stop();
            engine.Statistics.TestPointsGenerationTime = stoper.Elapsed;

            var statistics = engine.EvaluateModel(testPoints);

            databaseContext.Insert(version);
            databaseContext.Insert(experimentParameters);
            databaseContext.Insert(statistics);
            databaseContext.Insert(mathModel);
            databaseContext.Save();
            databaseContext.Dispose();

            TryGetVisibleResults(engine, positiveTrainingPoints, negativeTrainingPoints);
        }