示例#1
0
        public void TestRandomRestartHillClimberIncrementingRestartPoint()
        {
            comparer  = new MaximizingComparer <TestIntegerEvaluableState>();
            generator = new TestExponentialIntegerSuccessorGenerator();

            var climberConfiguration = new ClimberConfiguration <TestIntegerEvaluableState, int>()
                                       .ComparesUsing(comparer)
                                       .GeneratesSuccessorsWith((c) => generator.GetSuccessors(c));

            randomizer = new TestIntegerRandomizerSimulator();
            climber    = new RandomRestartHillClimber <TestIntegerEvaluableState, int>(5, randomizer, climberConfiguration);

            RunTest(climber, 1, 10000);
        }
示例#2
0
        public void TestRandomRestartHillClimberSameRestartPointEachTime()
        {
            comparer   = new MaximizingComparer <TestIntegerEvaluableState>();
            generator  = new TestLinearIntegerSuccessorGenerator();
            randomizer = new TestIntegerEvaluableStateNonRandomizer();

            var climberConfiguration = new ClimberConfiguration <TestIntegerEvaluableState, int>()
                                       .ComparesUsing(comparer)
                                       .GeneratesSuccessorsWith((c) => generator.GetSuccessors(c));

            randomizer = new TestIntegerEvaluableStateNonRandomizer();
            climber    = new RandomRestartHillClimber <TestIntegerEvaluableState, int>(5, randomizer, climberConfiguration);

            RunTest(climber, 2, 100);
        }
示例#3
0
 /// <summary>
 /// Creates a new ClimberAlgorithm using the given comparison strategy to compare
 /// evaluations and the given successorPicker to select the next EvaluableState to
 /// evaluate against.
 /// </summary>
 /// <param name="successorPicker">The successor picker to choose the next EvaluableState in to evaluate at an optimization step</param>
 protected ClimberAlgorithm(ISuccessorSelector <TState, TEvaluation> successorPicker)
 {
     this.successorPicker = successorPicker;
 }
 /// <summary>
 /// Creates a new NumericClimberAlgorithm using the given comparison strategy to compare
 /// discrete evaluations and the given successorPicker to select the next EvaluableState to
 /// evaluate against non-greedily
 /// </summary>
 /// <param name="successorPicker">The successor picker to choose the next EvaluableState in to evaluate at an optimization step</param>
 ///
 public NumericClimberAlgorithm(ISuccessorSelector <TState, int> successorPicker) : base(successorPicker)
 {
 }
 /// <summary>
 /// Creates a new <see cref="RandomRestartHillClimber{TState, TEvaluation}"/> that will perform numRestarts number of climber operations
 /// </summary>
 /// <param name="numRestarts">The number of climber operations to perform before returning a result</param>
 /// <param name="stateRandomizer">A complex state randomization strategy</param>
 /// <param name="climberConfiguration">A configuration for the climber that will be executed at each restart</param>
 public RandomRestartHillClimber(uint numRestarts, ISuccessorSelector <TState, TEvaluation> stateRandomizer, IClimberConfiguration <TState, TEvaluation> climberConfiguration)
     : this(numRestarts, climberConfiguration, c => stateRandomizer.Next(c))
 {
 }
示例#6
0
 /// <summary>
 /// Create a new StateRandomizer with the given compaer, using the given SuccessorPicker that will perform
 /// the given number of randomizations before returning a result. A numRanfomizations of -1 will have the optimier
 /// return the first encountered optimal state
 /// </summary>
 /// <param name="evaluationComparer"></param>
 /// <param name="successorPicker"></param>
 /// <param name="numRandomizations"></param>
 public StateRandomizer(IComparer <TState> evaluationComparer, ISuccessorSelector <TState, TEvaluation> successorPicker, int numRandomizations)
 {
     SuccessorPicker    = successorPicker;
     EvaluationComparer = evaluationComparer;
     NumRandomizations  = numRandomizations;
 }
示例#7
0
 /// <summary>
 /// Create a new StateRandomizer with the given compaer, using the given SuccessorPicker that will perform
 /// a single randomization and return the most optimal result
 /// </summary>
 /// <param name="evaluationComparer"></param>
 /// <param name="successorPicker"></param>
 public StateRandomizer(IComparer <TState> evaluationComparer, ISuccessorSelector <TState, TEvaluation> successorPicker)
     : this(evaluationComparer, successorPicker, 1)
 {
 }
 /// <summary>
 /// Creates a new LocalClimberAlgorithm using the given comparison strategy to compare
 /// evaluations and the given successorPicker to select the next EvaluableState to
 /// evaluate against
 /// </summary>
 /// <param name="successorPicker">The successor picker to choose the next EvaluableState in to evaluate at an optimization step</param>
 ///
 public LocalClimberAlgorithm(ISuccessorSelector <TState, TEvaluation> successorPicker) : base(successorPicker)
 {
 }