org.cpsolver.ifs.algorithms

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

- java.lang.Object
- - org.cpsolver.ifs.assignment.context.NeighbourSelectionWithContext<V,T,NeighbourSearch.NeighbourSearchContext>
  - - org.cpsolver.ifs.algorithms.NeighbourSearch<V,T>
    - - org.cpsolver.ifs.algorithms.GreatDeluge<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    CanHoldContext, HasAssignmentContext<V,T,NeighbourSearch.NeighbourSearchContext>, NeighbourSelection<V,T>, LazyNeighbour.LazyNeighbourAcceptanceCriterion<V,T>, SolutionListener<V,T>

      public class GreatDeluge<V extends Variable<V,T>,T extends Value<V,T>>
      extends NeighbourSearch<V,T>

  Great deluge. In each iteration, one of the given neighbourhoods is selected first, then a neighbour is generated and it is accepted if the value of the new solution is below certain bound. This bound is initialized to the GreatDeluge.UpperBoundRate × value of the best solution ever found. After each iteration, the bound is decreased by GreatDeluge.CoolRate (new bound equals to old bound × GreatDeluge.CoolRate). If the bound gets bellow GreatDeluge.LowerBoundRate × value of the best solution ever found, it is changed back to GreatDeluge.UpperBoundRate × value of the best solution ever found.
  If there was no improvement found between the bounds, the new bounds are changed to GreatDeluge.UpperBoundRate^2 and GreatDeluge.LowerBoundRate^2, GreatDeluge.UpperBoundRate^3 and GreatDeluge.LowerBoundRate^3, etc. till there is an improvement found.
  Custom neighbours can be set using GreatDeluge.Neighbours property that should contain semicolon separated list of `NeighbourSelection`. By default, each neighbour selection is selected with the same probability (each has 1 point in a roulette wheel selection). It can be changed by adding @n at the end of the name of the class, for example:

       GreatDeluge.Neighbours=org.cpsolver.ifs.algorithms.neighbourhoods.RandomMove;org.cpsolver.ifs.algorithms.neighbourhoods.RandomSwapMove@0.1

  Selector RandomSwapMove is 10× less probable to be selected than other selectors. When GreatDeluge.Random is true, all selectors are selected with the same probability, ignoring these weights.
  When GreatDeluge.Update is true, `NeighbourSelector.update(Assignment, Neighbour, long)` is called after each iteration (on the selector that was used) and roulette wheel selection that is using `NeighbourSelector.getPoints()` is used to pick a selector in each iteration. See `NeighbourSelector` for more details.
  Version:
    IFS 1.3 (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/.
  Author:
    Tomáš Müller

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `GreatDeluge.GreatDelugeContext`

    - ### Nested classes/interfaces inherited from class org.cpsolver.ifs.algorithms.NeighbourSearch

      `NeighbourSearch.NeighbourSearchContext`

  - ### Field Summary

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

      `iDF2, iPhase`

    - ### Fields inherited from class org.cpsolver.ifs.assignment.context.NeighbourSelectionWithContext

      `iContextOverride`

    - ### Fields inherited from interface org.cpsolver.ifs.assignment.context.CanHoldContext

      `sMaxSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GreatDeluge(DataProperties properties)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `NeighbourSearch.NeighbourSearchContext` | `createAssignmentContext(Assignment<V,T> assignment)` Create a new assignment context for the given assignment.
    `String` | `getParameterBaseName()` Parameter base name.

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

      `accept, accept, addNeighbourSelection, bestCleared, bestRestored, bestSaved, generateMove, getInfo, getInfo, getNeighbours, info, init, isMaster, logNeibourStatus, nextNeighbourSelection, selectNeighbour, setHCMode, setProgress, setProgressPhase, solutionUpdated`

    - ### Methods inherited from class org.cpsolver.ifs.assignment.context.NeighbourSelectionWithContext

      `getAssignmentContextReference, getContext, getContext, hasContextOverride, isSingleContextSolver, setAssignmentContextReference`

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

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

- - ### Constructor Detail

    - #### GreatDeluge

          public GreatDeluge(DataProperties properties)

      Constructor. Following problem properties are considered:
      - GreatDeluge.CoolRate ... bound cooling rate (default 0.99999995)
      - GreatDeluge.UpperBoundRate ... bound upper bound relative to best solution ever found (default 1.05)
      - GreatDeluge.LowerBoundRate ... bound lower bound relative to best solution ever found (default 0.95)
      - GreatDeluge.Neighbours ... semicolon separated list of classes implementing `NeighbourSelection`
      - GreatDeluge.AdditionalNeighbours ... semicolon separated list of classes implementing `NeighbourSelection`
      - GreatDeluge.Random ... when true, a neighbour selector is selected randomly
      - GreatDeluge.Update ... when true, a neighbour selector is selected using `NeighbourSelector.getPoints()` weights (roulette wheel selection)
      Parameters:
        `properties` - problem properties

  - ### Method Detail

    - #### getParameterBaseName

          public String getParameterBaseName()

      Description copied from class: `NeighbourSearch`
      Parameter base name. This can be used to distinguish between parameters of different search algorithms.
      Specified by:
        `getParameterBaseName` in class `NeighbourSearch<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        solver parameter base name for this search technique

    - #### createAssignmentContext

          public NeighbourSearch.NeighbourSearchContext createAssignmentContext(Assignment<V,T> assignment)

      Description copied from interface: `HasAssignmentContext`
      Create a new assignment context for the given assignment. If there are already some variables assigned in the value, the method should make sure that the context is appropriately initialized.
      Parameters:
        `assignment` - an assignment for which there needs to be an assignment context
      Returns:
        a new instance of the assignment context, filled according to the given assignment