org.cpsolver.ifs.heuristics

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

- java.lang.Object
- - org.cpsolver.ifs.heuristics.GeneralValueSelection<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    ValueSelection<V,T>

      public class GeneralValueSelection<V extends Variable<V,T>,T extends Value<V,T>>
      extends Object
      implements ValueSelection<V,T>

  General implementation of value selection criterion.
  Value selection criterion is based on weighted sum of various criteria. It also allows random walk technique and tabu search.
  Parameters:

  Parameter | Type | Comment
  --- | --- | ---
  General.MPP | `Boolean` | if true, MPP is being solved
  Value.MPPLimit | `Integer` | MPP: limitation of the number of allowed perturbations. If a solution within this limit is gound, it is decreased.
  Value.InitialSelectionProb | `Double` | MPP: probability of selection of the initial value
  Value.RandomWalkProb | `Double` | Random Walk: probability of selection of a value randomly among all the values
  Value.Tabu | `Integer` | Tabu Search: length of the tabu-list
  Value.GoodSelectionProb | `Double` | In case of `MacPropagation`, with this probability (1.0 means always), the selection is made only among good values (not removed from the domain).

  Following weights are used in the weighted sum (computed for all values). The value with the lowest weighted sum is selected. If there are more than one of such values, one of them is selected randomly.

  Parameter | Type | Comment
  --- | --- | ---
  Value.WeightDeltaInitialAssignments | `Double` | MPP: Difference in the number of assigned initial values if the value is assigned to the variable (weighted by this Value.WeightDeltaInitialAssignments): -1 if the value is initial, 0 otherwise, increased by the number of initial values assigned to variables with hard conflicts with the value
  Value.WeightWeightedConflicts | `Double` | When `ConflictStatistics` is used: weighted number of conflicting variables
  Value.WeightPotentialConflicts | `Double` | When `ConflictStatistics` is used: weighted number of potentially conflicting variables
  Value.WeightConflicts | `Double` | Number of conflicting variables `Model.conflictValues(Assignment, Value)`.
  Value.WeightValue | `Double` | Value `Value.toDouble(Assignment)`

  Version:
    IFS 1.3 (Iterative Forward Search)
    Copyright (C) 2006 - 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.
  See Also:
    `VariableSelection`, `Solver`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ArrayList<T>` | `iTabu`
    `protected int` | `iTabuPos`
    `protected int` | `iTabuSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GeneralValueSelection()`
    `GeneralValueSelection(DataProperties properties)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `init(Solver<V,T> solver)` Initialization
    `T` | `selectValue(Solution<V,T> solution, V selectedVariable)` Value selection

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

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

- - ### Field Detail

    - #### iTabuSize

          protected int iTabuSize

    - #### iTabu

          protected ArrayList<T extends Value<V,T>> iTabu

    - #### iTabuPos

          protected int iTabuPos

  - ### Constructor Detail

    - #### GeneralValueSelection

          public GeneralValueSelection()

    - #### GeneralValueSelection

          public GeneralValueSelection(DataProperties properties)

      Constructor
      Parameters:
        `properties` - input configuration

  - ### Method Detail

    - #### init

          public void init(Solver<V,T> solver)

      Initialization
      Specified by:
        `init` in interface `ValueSelection<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `solver` - current solver

    - #### selectValue

          public T selectValue(Solution<V,T> solution,
                               V selectedVariable)

      Value selection
      Specified by:
        `selectValue` in interface `ValueSelection<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `solution` - current solution
        `selectedVariable` - selected variable
      Returns:
        selected value (of the given variable)