org.cpsolver.ifs.algorithms

## Class StepCountingHillClimber.StepCountingHillClimberContext

- java.lang.Object
- - org.cpsolver.ifs.algorithms.NeighbourSearch.NeighbourSearchContext
  - - org.cpsolver.ifs.algorithms.HillClimber.HillClimberContext
    - - org.cpsolver.ifs.algorithms.StepCountingHillClimber.StepCountingHillClimberContext

- All Implemented Interfaces:
    AssignmentContext, SolutionListener<V,T>
  Enclosing class:
    StepCountingHillClimber<V extends Variable<V,T>,T extends Value<V,T>>

      public class StepCountingHillClimber.StepCountingHillClimberContext
      extends HillClimber.HillClimberContext

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Double` | `iBound`
    `protected int` | `iCounter`

    - ### Fields inherited from class org.cpsolver.ifs.algorithms.HillClimber.HillClimberContext

      `iLastImprovingIter`

    - ### Fields inherited from class org.cpsolver.ifs.algorithms.NeighbourSearch.NeighbourSearchContext

      `iIter, iT0`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StepCountingHillClimberContext()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `accept(Assignment<V,T> assignment, Model<V,T> model, Neighbour<V,T> neighbour, double value, boolean lazy)` Accept any move that does not worsen the solution (value <= 0) or that is below the bound.
    `void` | `activate(Solution<V,T> solution)` Reset the bound and the steps counter.
    `protected boolean` | `canContinue(Solution<V,T> solution)` Stop the search when the number of idle iterations is reached and the bound is no longer decreasing
    `protected int` | `getCounterLimit(int idx)`
    `void` | `incIteration(Solution<V,T> solution)` Increase iteration number, also update bound when the given number of steps is reached.

    - ### Methods inherited from class org.cpsolver.ifs.algorithms.NeighbourSearch.NeighbourSearchContext

      `bestCleared, bestRestored, bestSaved, deactivate, getInfo, getInfo, getTimeMillis, solutionUpdated`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### iBound

          protected Double iBound

    - #### iCounter

          protected int iCounter

  - ### Constructor Detail

    - #### StepCountingHillClimberContext

          public StepCountingHillClimberContext()

  - ### Method Detail

    - #### activate

          public void activate(Solution<V,T> solution)

      Reset the bound and the steps counter.
      Overrides:
        `activate` in class `HillClimber.HillClimberContext`
      Parameters:
        `solution` - current solution

    - #### getCounterLimit

          protected int getCounterLimit(int idx)

    - #### incIteration

          public void incIteration(Solution<V,T> solution)

      Increase iteration number, also update bound when the given number of steps is reached.
      Overrides:
        `incIteration` in class `HillClimber.HillClimberContext`
      Parameters:
        `solution` - current solution

    - #### accept

          protected boolean accept(Assignment<V,T> assignment,
                                   Model<V,T> model,
                                   Neighbour<V,T> neighbour,
                                   double value,
                                   boolean lazy)

      Accept any move that does not worsen the solution (value <= 0) or that is below the bound. Also increase the step counter.
      Overrides:
        `accept` in class `HillClimber.HillClimberContext`
      Parameters:
        `assignment` - current assignment
        `model` - problem model
        `neighbour` - a generated move
        `value` - value of the generated move (i.e., its impact on the solution value)
        `lazy` - true if lazy move
      Returns:
        true if the generated move is to be assigned

    - #### canContinue

          protected boolean canContinue(Solution<V,T> solution)

      Stop the search when the number of idle iterations is reached and the bound is no longer decreasing
      Overrides:
        `canContinue` in class `HillClimber.HillClimberContext`
      Parameters:
        `solution` - current solution
      Returns:
        true if can continue