org.cpsolver.ifs.dbt

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

- java.lang.Object
- - org.cpsolver.ifs.extension.Extension<V,T>
  - - org.cpsolver.ifs.assignment.context.ExtensionWithContext<V,T,MacPropagation.NoGood>
    - - org.cpsolver.ifs.extension.MacPropagation<V,T>
      - - org.cpsolver.ifs.dbt.DbtPropagation<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    CanHoldContext, HasAssignmentContext<V,T,MacPropagation.NoGood>, ModelListener<V,T>, SolverListener<V,T>

      public class DbtPropagation<V extends Variable<V,T>,T extends Value<V,T>>
      extends MacPropagation<V,T>
      implements SolverListener<V,T>

  Maintenance of arc consistency in dynamic backtracking.
  The difference between `MacPropagation` and this DBT propagation is that all not-assigned values of an assigned variable are marked as nogood. Also, when a dead end is reached, unassignment or failure takes place.
  This IFS solver extension is to be used only in case of dynamic backtracking and it has no parameters.
  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.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.cpsolver.ifs.extension.MacPropagation

      `MacPropagation.NoGood`

  - ### Field Summary

    - ### Fields inherited from class org.cpsolver.ifs.extension.MacPropagation

      `iConstraints, iIteration`

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

      `sMaxSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DbtPropagation(Solver<V,T> solver, DataProperties properties)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterAssigned(Assignment<V,T> assignment, long iteration, T value)` Propagation takes place every time a value is assigned to a variable.
    `void` | `afterUnassigned(Assignment<V,T> assignment, long iteration, T value)` Undo propagation when a value is unassigned.
    `void` | `neighbourFailed(Assignment<V,T> assignment, long iteration, Neighbour<V,T> neighbour)` Called when `ParallelSolver` failed to assign the given neighbour
    `boolean` | `neighbourSelected(Assignment<V,T> assignment, long iteration, Neighbour<V,T> neighbour)` A neighbour was selected
    `boolean` | `valueSelected(Assignment<V,T> assignment, long iteration, V variable, T value)` If no value is selected (because of a dead end), make some unassignments.
    `boolean` | `variableSelected(Assignment<V,T> assignment, long iteration, V variable)` If no variable is selected (all variables are assinged), unassign the last assigned variable.

    - ### Methods inherited from class org.cpsolver.ifs.extension.MacPropagation

      `addConstraint, beforeAssigned, contains, createAssignmentContext, goodValues, isGood, noGood, propagate, setGood, setNoGood, undoPropagate`

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

      `getAssignmentContextReference, getContext, getContext, init, setAssignmentContextReference, unregister`

    - ### Methods inherited from class org.cpsolver.ifs.extension.Extension

      `beforeUnassigned, constraintAdded, constraintRemoved, getModel, getProperties, getSolver, isRegistered, register, variableAdded, variableRemoved`

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

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

- - ### Constructor Detail

    - #### DbtPropagation

          public DbtPropagation(Solver<V,T> solver,
                                DataProperties properties)

      Constructor. No parameter is taken from properties.
      Parameters:
        `solver` - current solver
        `properties` - solver configuration

  - ### Method Detail

    - #### afterAssigned

          public void afterAssigned(Assignment<V,T> assignment,
                                    long iteration,
                                    T value)

      Propagation takes place every time a value is assigned to a variable.
      - Prints a warning if the value is nogood (should not never happen),
      - sets all other values of the variable to nogood (explanation is the assigned value itself),
      - runs propagation.
      Specified by:
        `afterAssigned` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Overrides:
        `afterAssigned` in class `MacPropagation<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value to be assigned
      See Also:
        `MacPropagation.propagate(Assignment, Variable)`

    - #### afterUnassigned

          public void afterUnassigned(Assignment<V,T> assignment,
                                      long iteration,
                                      T value)

      Undo propagation when a value is unassigned.
      - Prints an error if the value is nogood (should not never happen),
      - runs propagation undo.
      Specified by:
        `afterUnassigned` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Overrides:
        `afterUnassigned` in class `MacPropagation<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value to be unassigned
      See Also:
        `MacPropagation.undoPropagate(Assignment, Variable)`

    - #### variableSelected

          public boolean variableSelected(Assignment<V,T> assignment,
                                          long iteration,
                                          V variable)

      If no variable is selected (all variables are assinged), unassign the last assigned variable.
      Do not allow to select an assigned variable.
      If no variable is selected (because all variables are assigned, see `DbtVariableSelection`):
      - find the last assigned variable and
      - unassign it (explanation is a union of assignments of all other variables).
      Specified by:
        `variableSelected` in interface `SolverListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `variable` - selected variable
      Returns:
        if false is returned the variable will be discarded (search continues with the next variable selection)
      See Also:
        `DbtVariableSelection.selectVariable(Solution)`

    - #### valueSelected

          public boolean valueSelected(Assignment<V,T> assignment,
                                       long iteration,
                                       V variable,
                                       T value)

      If no value is selected (because of a dead end), make some unassignments.
      If no value is selected (e.g., because the selected variable has all values marked as nogood, see `DbtValueSelection`),
      - compute a union of explanations of all values,
        - if it is empty fail (inconsistency is found),
      - otherwise pick the last assigned variable from the computed union of explanation and unassign it

             (explanation for that is the computed union of explanations without the last assignment).

      Specified by:
        `valueSelected` in interface `SolverListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `variable` - selected variable
        `value` - selected variable
      Returns:
        if false is returned the selected value is not assigned
      See Also:
        `DbtVariableSelection.selectVariable(Solution)`

    - #### neighbourSelected

          public boolean neighbourSelected(Assignment<V,T> assignment,
                                           long iteration,
                                           Neighbour<V,T> neighbour)

      Description copied from interface: `SolverListener`
      A neighbour was selected
      Specified by:
        `neighbourSelected` in interface `SolverListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `neighbour` - neighbour
      Returns:
        if false is returned the selected neighbour is not assigned

    - #### neighbourFailed

          public void neighbourFailed(Assignment<V,T> assignment,
                                      long iteration,
                                      Neighbour<V,T> neighbour)

      Description copied from interface: `SolverListener`
      Called when `ParallelSolver` failed to assign the given neighbour
      Specified by:
        `neighbourFailed` in interface `SolverListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `neighbour` - neighbour