net.sf.cpsolver.ifs.algorithms

## Class StepCountingHillClimber<V extends Variable<V,T>,T extends Value<V,T>>

- java.lang.Object
- - net.sf.cpsolver.ifs.algorithms.NeighbourSearch<V,T>
  - - net.sf.cpsolver.ifs.algorithms.HillClimber<V,T>
    - - net.sf.cpsolver.ifs.algorithms.StepCountingHillClimber<V,T>

- All Implemented Interfaces:
    NeighbourSelection<V,T>, LazyNeighbour.LazyNeighbourAcceptanceCriterion<V,T>, SolutionListener<V,T>

      public class StepCountingHillClimber<V extends Variable<V,T>,T extends Value<V,T>>
      extends HillClimber<V,T>

  Step counting hill climber. Unlike with the ordinary hill climber, there is a bound. The bound is updated (to the value of the current solution) after a given number of moves. Based on the given mode, either all moves, only accepted moves, or only improving moves are counted.
  Version:
    IFS 1.2 (Iterative Forward Search)
    Copyright (C) 2014 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses/.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `StepCountingHillClimber.Mode`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Double` | `iBound`
    `protected int` | `iCounter`
    `protected int` | `iCounterLimit`
    `protected StepCountingHillClimber.Mode` | `iCounterMode`

    - ### Fields inherited from class net.sf.cpsolver.ifs.algorithms.HillClimber

      `iBestValue, iLastImprovingIter, iMaxIdleIters, iSetHCMode`

    - ### Fields inherited from class net.sf.cpsolver.ifs.algorithms.NeighbourSearch

      `iDF2, iIter, iLog, iPhase, iProgress, iT0`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StepCountingHillClimber(DataProperties properties, String name)` Constructor HillClimber.CounterLimit ... number of moves after which the bound is reset (defaults to 1000) HillClimber.CounterMode ... counter mode (all: count all moves, accepted: count accepted moves, improving: count improving moves)

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `accept(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
    `void` | `incIteration(Solution<V,T> solution)` Increase iteration number, also update bound when the given number of steps is reached.

    - ### Methods inherited from class net.sf.cpsolver.ifs.algorithms.HillClimber

      `bestSaved, getParameterBaseName, init, setPhase`

    - ### Methods inherited from class net.sf.cpsolver.ifs.algorithms.NeighbourSearch

      `accept, accept, addNeighbourSelection, bestCleared, bestRestored, deactivate, generateMove, getInfo, getInfo, getNeighbours, getTimeMillis, logNeibourStatus, nextNeighbourSelection, selectNeighbour, setHCMode, 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

    - #### iCounterLimit

          protected int iCounterLimit

    - #### iCounterMode

          protected StepCountingHillClimber.Mode iCounterMode

  - ### Constructor Detail

    - #### StepCountingHillClimber

          public StepCountingHillClimber(DataProperties properties,
                                         String name)

      Constructor
      - HillClimber.CounterLimit ... number of moves after which the bound is reset (defaults to 1000)
      - HillClimber.CounterMode ... counter mode (all: count all moves, accepted: count accepted moves, improving: count improving moves)

  - ### Method Detail

    - #### activate

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

      Reset the bound and the steps counter.
      Overrides:
        `activate` in class `HillClimber<V extends Variable<V,T>,T extends Value<V,T>>`

    - #### 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<V extends Variable<V,T>,T extends Value<V,T>>`

    - #### accept

          protected boolean accept(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<V extends Variable<V,T>,T extends Value<V,T>>`

    - #### 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<V extends Variable<V,T>,T extends Value<V,T>>`