BuildSapsAlgorithmTuner(
            AlgorithmTunerConfiguration tunerConfig,
            string trainingInstanceFolder,
            string testInstanceFolder,
            SapsRunnerConfiguration runnerConfig)
        {
            var tuner = new AlgorithmTuner <SapsRunner, InstanceSeedFile, RuntimeResult, TLearnerModel, TPredictorModel, TSamplingStrategy>(
                targetAlgorithmFactory: new SapsRunnerFactory(runnerConfig.PathToExecutable, tunerConfig.CpuTimeout),
                runEvaluator: new SortByRuntime(runnerConfig.FactorParK),
                trainingInstances: SapsUtils.CreateInstances(trainingInstanceFolder, runnerConfig.NumberOfSeeds, runnerConfig.RngSeed),
                parameterTree: SapsUtils.CreateParameterTree(),
                configuration: tunerConfig);

            if (!string.IsNullOrWhiteSpace(testInstanceFolder))
            {
                tuner.SetTestInstances(SapsUtils.CreateInstances(testInstanceFolder, runnerConfig.NumberOfSeeds, runnerConfig.RngSeed));
            }

            return(tuner);
        }
Beispiel #2
0
        BuildSapsAlgorithmTuner(
            AlgorithmTunerConfiguration tunerConfig,
            string trainingInstanceFolder,
            string testInstanceFolder,
            SapsRunnerConfiguration runnerConfig)
        {
            IRunEvaluator <InstanceSeedFile, RuntimeResult> runEvaluator;

            if (runnerConfig.FactorParK == 0)
            {
                runEvaluator = new SortByUnpenalizedRuntime <InstanceSeedFile>(tunerConfig.CpuTimeout);
            }
            else
            {
                runEvaluator = new SortByPenalizedRuntime <InstanceSeedFile>(runnerConfig.FactorParK, tunerConfig.CpuTimeout);
            }

            var tuner = new AlgorithmTuner <SapsRunner, InstanceSeedFile, RuntimeResult, TLearnerModel, TPredictorModel, TSamplingStrategy>(
                targetAlgorithmFactory: new SapsRunnerFactory(runnerConfig.PathToExecutable, tunerConfig.CpuTimeout),
                runEvaluator: runEvaluator,
                trainingInstances: InstanceSeedFile.CreateInstanceSeedFilesFromDirectory(
                    trainingInstanceFolder,
                    SapsUtils.ListOfValidFileExtensions,
                    runnerConfig.NumberOfSeeds,
                    runnerConfig.RngSeed),
                parameterTree: SapsUtils.CreateParameterTree(),
                configuration: tunerConfig);

            if (!string.IsNullOrWhiteSpace(testInstanceFolder))
            {
                tuner.SetTestInstances(
                    InstanceSeedFile.CreateInstanceSeedFilesFromDirectory(
                        testInstanceFolder,
                        SapsUtils.ListOfValidFileExtensions,
                        runnerConfig.NumberOfSeeds,
                        runnerConfig.RngSeed));
            }

            return(tuner);
        }