public ProgramRunner(
     ITestsConfig testsConfig, SingleTestRunner singleTestRunner, OptimizationScheme optimizationScheme)
 {
     this._testsConfig        = testsConfig;
     this._singleTestRunner   = singleTestRunner;
     this._optimizationScheme = optimizationScheme;
 }
        public IEnumerable <ParallelOptimizationTest> CreateFor(uint testType, ITestsConfig testsConfig)
        {
            var tests    = new List <ParallelOptimizationTest>();
            var scenario = testsConfig.ScenarioProfiles[testType];

            if (scenario == null)
            {
                return(tests);
            }

            //changes parameters of main optim test according to scenario
            this.AddMainTest(testsConfig, scenario, tests);

            //creates a top test according to scheme and scenario
            if (this.topTestsScheme == null)
            {
                return(tests);
            }
            this.AddTopTests(testsConfig, scenario, tests);

            //changes parameters of final optim test according to scenario
            if (this.finalTest == null)
            {
                return(tests);
            }
            this.AddFinalTest(testsConfig, scenario, tests);

            return(tests);
        }
        protected virtual void AddMainTest(
            ITestsConfig testsConfig, IScenario scenario, List <ParallelOptimizationTest> tests)
        {
            var testFactory = testsConfig.CreateTestFactory(scenario, testsConfig.NumSimulations, testsConfig.NumSamples);

            this.mainTest.OptimizationTestFactory = testFactory;
            tests.Add(this.mainTest);
        }
Example #4
0
 public TestParameterRanker(ITestsConfig testsConfig, IOptimizationTestFactory testFactory)
 {
     this.TestsConfig            = testsConfig;
     this.TestFactory            = testFactory;
     this.TestMeasures           = testFactory.CreateTestMeasureList();
     this.TestMeasures.WriteTemp = false;
     this.SortedTestParameters   = new Dictionary <uint, List <ITestParameters> >();
 }
Example #5
0
        private static ITestsConfig CreateNewTestsConfig(
            ITestsConfig baseTestsConfig, uint testType, ITestParameters testParameters)
        {
            var testsConfig = baseTestsConfig.CloneJson();

            testsConfig.Init();
            testsConfig.SingleTestType       = testType;
            testsConfig.SingleTestParameters = testParameters;
            return(testsConfig);
        }
        public SingleScenario(IAgent baseAgent, IEnvironment baseEnvironment, ITestsConfig testsConfig)
        {
            this._baseAgent       = baseAgent;
            this._baseEnvironment = baseEnvironment;
            this.TestsConfig      = testsConfig;

            //defaults, can be change in TestsConfig
            this.AgentFitnessFunction = new CumulativeFitnessFunction();
            this.FitnessText          = "Fitness";
        }
Example #7
0
        private static List <ITestParameters> GetTestParameters(ITestsConfig baseTestsConfig, uint testType)
        {
            //gets sampled parameter list for given test type
            var testProfile    = baseTestsConfig.ScenarioProfiles[testType];
            var testParameters = baseTestsConfig.GetOptimizationTestParameters();

            //also adds special tests
            testParameters.AddRange(baseTestsConfig.GetSpecialTestParameters(testProfile));

            return(testParameters);
        }
        protected virtual void AddFinalTest(
            ITestsConfig testsConfig, IScenario scenario, List <ParallelOptimizationTest> tests)
        {
            if (this.finalTest == null)
            {
                return;
            }
            var testFactory = testsConfig.CreateTestFactory(
                scenario, testsConfig.NumSimulations, testsConfig.NumTimeSteps);

            this.finalTest.OptimizationTestFactory = testFactory;
            tests.Add(this.finalTest);
        }
        protected override void AddMainTest(ITestsConfig testsConfig, IScenario scenario,
                                            List <ParallelOptimizationTest> tests)
        {
            base.AddMainTest(testsConfig, scenario, tests);
            if (!(testsConfig is IGPTestsConfig))
            {
                return;
            }

            //adds a select best test
            var multipleTestFactory =
                testsConfig.CreateTestFactory(scenario, this._numSelectBestSimulations, testsConfig.NumSamples);

            tests.Add(new SelectBestFitnessTest(multipleTestFactory, ((IGPTestsConfig)testsConfig).StdDevTimes));
        }
        protected override void AddFinalTest(ITestsConfig testsConfig, IScenario scenario, List <ParallelOptimizationTest> tests)
        {
            if (this.finalTest == null)
            {
                return;
            }
            if (!(testsConfig is IGPTestsConfig gpTestsConfig))
            {
                base.AddFinalTest(testsConfig, scenario, tests);
                return;
            }
            var testFactory = gpTestsConfig.CreateSimplifierTestFactory(
                scenario, testsConfig.NumSimulations, testsConfig.NumTimeSteps);

            this.finalTest.OptimizationTestFactory = testFactory;
            tests.Add(this.finalTest);
        }
        protected virtual void AddTopTests(
            ITestsConfig testsConfig, IScenario scenario, List <ParallelOptimizationTest> tests)
        {
            if (this.topTestsScheme == null)
            {
                return;
            }
            for (var i = 0; i < this.topTestsScheme.Count; i++)
            {
                var topTestScheme = this.topTestsScheme[i];

                //in last test always make 1 sample-per-step
                var testFactory = testsConfig.CreateTestFactory(
                    scenario, topTestScheme.NumSimulations,
                    i == this.topTestsScheme.Count - 1 ? testsConfig.NumTimeSteps : testsConfig.NumSamples);

                tests.Add(new SelectTopFitnessTest(testFactory, topTestScheme.NumTests, true));
            }
        }
Example #12
0
        public static List <ITestsConfig> GenerateAllTestsConfigs(ITestsConfig baseTestsConfig)
        {
            var testsConfigList = new List <ITestsConfig>();

            var multipleTestTypes = baseTestsConfig.MultipleTestTypes;

            if ((multipleTestTypes == null) || (multipleTestTypes.Length == 0))
            {
                return(testsConfigList);
            }

            //gets all test parameters for each type of test
            foreach (var testType in multipleTestTypes)
            {
                testsConfigList.AddRange(GetTestsConfig(baseTestsConfig, testType));
            }

            return(testsConfigList);
        }
Example #13
0
        private static List <ITestsConfig> GetTestsConfig(ITestsConfig baseTestsConfig, uint testType)
        {
            //gets all test parameters for the type of test
            var testParamsSet = new HashSet <ITestParameters>(GetTestParameters(baseTestsConfig, testType));

            //removes possible unnecessary test parameters
            baseTestsConfig = baseTestsConfig.CloneJson();
            baseTestsConfig.Init();

            var testProfile = baseTestsConfig.ScenarioProfiles[testType];

            if (File.Exists(testProfile.TestMeasuresFilePath))
            {
                var testFactory  = baseTestsConfig.CreateTestFactory(testProfile);
                var testMeasures = testFactory.CreateTestMeasureList();
                testMeasures.ReadFromFile(testProfile.TestMeasuresFilePath);
                testParamsSet.RemoveWhere(testMeasures.Contains);
            }

            //adds a new config for each specific test params
            return(testParamsSet.Select(testParameters =>
                                        CreateNewTestsConfig(baseTestsConfig, testType, testParameters)).ToList());
        }
 protected SingleTestRunner(ITestsConfig testsConfig)
     : base(testsConfig)
 {
 }
Example #15
0
 public ParallelOptimTestRunnner(ITestsConfig testsConfig, OptimizationScheme optimizationScheme)
     : base(testsConfig)
 {
     this.optimizationScheme = optimizationScheme;
 }
 public SocialScenario(ISocialAgent baseAgent, ISocialEnvironment baseEnvironment, ITestsConfig testsConfig)
     : base(baseAgent, baseEnvironment, testsConfig)
 {
     //default fitness function
     this.PopulationFitnessFunction = new MeanPopFitnessFunction();
 }
Example #17
0
 public FormsSingleTestRunner(ITestsConfig testsConfig) : base(testsConfig)
 {
 }
Example #18
0
 public EmotionalSingleTestRunner(ITestsConfig testsConfig) : base(testsConfig)
 {
 }
Example #19
0
 public PacmanScenario(IAgent baseAgent, IEnvironment baseEnvironment, ITestsConfig testsConfig)
     : base(baseAgent, baseEnvironment, testsConfig)
 {
 }
Example #20
0
 public FormsParallelOptimTestRunnner(ITestsConfig testsConfig, OptimizationScheme optimizationScheme)
     : base(testsConfig, optimizationScheme)
 {
 }
Example #21
0
 public CondorScriptBuilder(ITestsConfig testsConfig)
 {
     this.MaxJobsPerFile = DEF_MAX_JOBS_PER_FILE;
     this.TestsConfig    = testsConfig;
 }
Example #22
0
 protected TestRunner(ITestsConfig testsConfig)
 {
     this.TestsConfig  = testsConfig;
     this.ForceConsole = false;
 }