Exemple #1
0
        /// <summary>
        /// Creates a <see cref="SystematicStrategy"/> from the specified configuration.
        /// </summary>
        internal static SystematicStrategy Create(Configuration configuration, IRandomValueGenerator generator)
        {
            SystematicStrategy strategy = null;

            if (configuration.SchedulingStrategy is "replay")
            {
                strategy = new ReplayStrategy(configuration);
            }
            else if (configuration.SchedulingStrategy is "random")
            {
                strategy = new RandomStrategy(configuration.MaxFairSchedulingSteps, generator);
            }
            else if (configuration.SchedulingStrategy is "pct")
            {
                strategy = new PCTStrategy(configuration.MaxUnfairSchedulingSteps, configuration.StrategyBound, generator);
            }
            else if (configuration.SchedulingStrategy is "fairpct")
            {
                var prefixLength = configuration.SafetyPrefixBound is 0 ?
                                   configuration.MaxUnfairSchedulingSteps : configuration.SafetyPrefixBound;
                var prefixStrategy = new PCTStrategy(prefixLength, configuration.StrategyBound, generator);
                var suffixStrategy = new RandomStrategy(configuration.MaxFairSchedulingSteps, generator);
                strategy = new ComboStrategy(prefixStrategy, suffixStrategy);
            }
            else if (configuration.SchedulingStrategy is "probabilistic")
            {
                strategy = new ProbabilisticRandomStrategy(configuration.MaxFairSchedulingSteps,
                                                           configuration.StrategyBound, generator);
            }
            else if (configuration.SchedulingStrategy is "rl")
            {
                strategy = new QLearningStrategy(configuration.MaxUnfairSchedulingSteps, generator);
            }
            else if (configuration.SchedulingStrategy is "dfs")
            {
                strategy = new DFSStrategy(configuration.MaxUnfairSchedulingSteps);
            }

            if (configuration.SchedulingStrategy != "replay" &&
                configuration.ScheduleFile.Length > 0)
            {
                strategy = new ReplayStrategy(configuration, strategy);
            }

            return(strategy);
        }