org.cpsolver.ifs.algorithms

## Class HillClimber.HillClimberContext

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

- All Implemented Interfaces:
    AssignmentContext, SolutionListener<V,T>
  Direct Known Subclasses:
    StepCountingHillClimber.StepCountingHillClimberContext
  Enclosing class:
    HillClimber<V extends Variable<V,T>,T extends Value<V,T>>

      public class HillClimber.HillClimberContext
      extends NeighbourSearch.NeighbourSearchContext

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `iLastImprovingIter`

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

      `iIter, iT0`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HillClimberContext()`

  - ### 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)
    `protected void` | `activate(Solution<V,T> solution)` Reset the idle iterations counter
    `protected boolean` | `canContinue(Solution<V,T> solution)` Stop the search after a given number of idle (not improving) iterations
    `protected void` | `incIteration(Solution<V,T> solution)` Increase iteration counter

    - ### 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

    - #### iLastImprovingIter

          protected int iLastImprovingIter

  - ### Constructor Detail

    - #### HillClimberContext

          public HillClimberContext()

  - ### Method Detail

    - #### incIteration

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

      Increase iteration counter
      Overrides:
        `incIteration` in class `NeighbourSearch.NeighbourSearchContext`
      Parameters:
        `solution` - current solution

    - #### canContinue

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

      Stop the search after a given number of idle (not improving) iterations
      Overrides:
        `canContinue` in class `NeighbourSearch.NeighbourSearchContext`
      Parameters:
        `solution` - current solution
      Returns:
        true if can continue

    - #### activate

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

      Reset the idle iterations counter
      Overrides:
        `activate` in class `NeighbourSearch.NeighbourSearchContext`
      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)
      Specified by:
        `accept` in class `NeighbourSearch.NeighbourSearchContext`
      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