net.sf.cpsolver.ifs.dbt
Class DbtPropagation

java.lang.Object
  extended by net.sf.cpsolver.ifs.extension.Extension
      extended by net.sf.cpsolver.ifs.extension.MacPropagation
          extended by net.sf.cpsolver.ifs.dbt.DbtPropagation
All Implemented Interfaces:
ModelListener, SolverListener

public class DbtPropagation
extends MacPropagation
implements SolverListener

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.1 (Iterative Forward Search)
Copyright (C) 2006 Tomáš Müller
muller@unitime.org
Lazenska 391, 76314 Zlin, Czech Republic

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 2.1 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Field Summary
 
Fields inherited from class net.sf.cpsolver.ifs.extension.MacPropagation
iConstraints, iIteration
 
Constructor Summary
DbtPropagation(Solver solver, DataProperties properties)
          Constructor.
 
Method Summary
 void afterAssigned(long iteration, Value value)
          Propagation takes place every time a value is assigned to a variable.
 void afterUnassigned(long iteration, Value value)
          Undo propagation when a value is unassigned.
 boolean neighbourSelected(long iteration, Neighbour neighbour)
          A neighbour was selected
 boolean valueSelected(long iteration, Variable variable, Value value)
          If no value is selected (because of a dead end), make some unassignments.
 boolean variableSelected(long iteration, Variable variable)
          If no variable is selected (all variables are assinged), unassign the last assigned variable.
 
Methods inherited from class net.sf.cpsolver.ifs.extension.MacPropagation
addConstraint, beforeAssigned, contains, goodValues, init, isGood, noGood, propagate, propagate, propagate, propagate, setGood, setNoGood, undoPropagate
 
Methods inherited from class net.sf.cpsolver.ifs.extension.Extension
beforeUnassigned, constraintAdded, constraintRemoved, getModel, getProperties, getSolver, isRegistered, register, unregister, useValueExtra, useVariableExtra, 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 solver,
                      DataProperties properties)
Constructor. No parameter is taken from properties.

Method Detail

afterAssigned

public void afterAssigned(long iteration,
                          Value 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
    Overrides:
    afterAssigned in class MacPropagation
    Parameters:
    iteration - current iteration
    value - value to be assigned
    See Also:
    MacPropagation.propagate(Variable)

  • afterUnassigned

    public void afterUnassigned(long iteration,
                                Value 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
    Overrides:
    afterUnassigned in class MacPropagation
    Parameters:
    iteration - current iteration
    value - value to be unassigned
    See Also:
    MacPropagation.undoPropagate(Variable)

  • variableSelected

    public boolean variableSelected(long iteration,
                                    Variable 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):

    Specified by:
    variableSelected in interface SolverListener
    Parameters:
    iteration - current iteration
    variable - selected variable
    See Also:
    DbtVariableSelection.selectVariable(Solution)

    valueSelected

    public boolean valueSelected(long iteration,
                                 Variable variable,
                                 Value 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),

    Specified by:
    valueSelected in interface SolverListener
    Parameters:
    iteration - current iteration
    variable - selected variable
    value - selected variable
    See Also:
    DbtVariableSelection.selectVariable(Solution)

    neighbourSelected

    public boolean neighbourSelected(long iteration,
                                     Neighbour neighbour)
    Description copied from interface: SolverListener
    A neighbour was selected

    Specified by:
    neighbourSelected in interface SolverListener
    Parameters:
    iteration - current iteration
    neighbour - neighbour