예제 #1
0
        BuildLingelingAlgorithmTuner(
            AlgorithmTunerConfiguration tunerConfig,
            string trainingInstanceFolder,
            string testInstanceFolder,
            LingelingRunnerConfiguration 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 <LingelingRunner, InstanceSeedFile, RuntimeResult, TLearnerModel,
                                            TPredictorModel,
                                            TSamplingStrategy>(
                targetAlgorithmFactory: new LingelingRunnerFactory(runnerConfig.PathToExecutable, tunerConfig, runnerConfig.MemoryLimitMegabyte),
                runEvaluator: runEvaluator,
                trainingInstances: InstanceSeedFile.CreateInstanceSeedFilesFromDirectory(
                    trainingInstanceFolder,
                    LingelingUtils.ListOfValidFileExtensions,
                    runnerConfig.NumberOfSeeds,
                    runnerConfig.RngSeed),
                parameterTree: LingelingUtils.CreateParameterTree(),
                configuration: tunerConfig);

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

            return(tuner);
        }
예제 #2
0
        BuildLingelingAlgorithmTuner(
            AlgorithmTunerConfiguration tunerConfig,
            string trainingInstanceFolder,
            string testInstanceFolder,
            LingelingRunnerConfiguration runnerConfig)
        {
            var tuner = new AlgorithmTuner <LingelingRunner, InstanceSeedFile, RuntimeResult, TLearnerModel,
                                            TPredictorModel,
                                            TSamplingStrategy>(
                targetAlgorithmFactory: new LingelingRunnerFactory(runnerConfig.PathToExecutable, tunerConfig, runnerConfig.MemoryLimitMegabyte),
                runEvaluator: new SortByRuntime(runnerConfig.FactorParK),
                trainingInstances: LingelingUtils.CreateInstances(trainingInstanceFolder, runnerConfig.NumberOfSeeds, runnerConfig.RngSeed),
                parameterTree: LingelingUtils.CreateParameterTree(),
                configuration: tunerConfig);

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

            return(tuner);
        }
예제 #3
0
        /// <summary>
        /// Logs the best parameters.
        /// </summary>
        /// <param name="bestParameters">The parameters.</param>
        /// <param name="lingelingConfig">The config.</param>
        private static void LogBestParameters(Dictionary <string, IAllele> bestParameters, LingelingRunnerConfiguration lingelingConfig)
        {
            var bestParametersConsoleFormat = string.Join(" ", bestParameters.Select(parameter => $"--{parameter.Key}={parameter.Value}"));
            var lingelingCommand            =
                $"{lingelingConfig.PathToExecutable} -T [TIMEOUT] -f --seed=[SEED] --memlim={lingelingConfig.MemoryLimitMegabyte} {bestParametersConsoleFormat} [INSTANCE]";

            LoggingHelper.WriteLine(VerbosityLevel.Info, "Command to start lingeling with best parameters:");
            LoggingHelper.WriteLine(VerbosityLevel.Info, lingelingCommand);
        }
예제 #4
0
        /// <summary>
        /// Runs the master.
        /// </summary>
        /// <param name="remainingArguments">Remaining arguments for the tuner.</param>
        /// <param name="runnerConfig">Configuration of the algorithm.</param>
        /// <returns>The best parameters.</returns>
        public static Dictionary <string, IAllele> Run(IEnumerable <string> remainingArguments, LingelingRunnerConfiguration runnerConfig)
        {
            var bestParameters = Master <LingelingRunner, InstanceSeedFile, RuntimeResult, TLearnerModel, TPredictorModel, TSamplingStrategy> .Run(
                args : remainingArguments.ToArray(),
                algorithmTunerBuilder : (tunerConfig, trainingInstanceFolder, testInstanceFolder) =>
                GenericLingelingEntryPoint <TLearnerModel, TPredictorModel, TSamplingStrategy> .BuildLingelingAlgorithmTuner(
                    tunerConfig,
                    trainingInstanceFolder,
                    testInstanceFolder,
                    runnerConfig));

            return(bestParameters);
        }