## org.opencyc.constraintsolver
Class ValueDomains

    java.lang.Object
      |
      +--org.opencyc.constraintsolver.ValueDomains

public class ValueDomains
extends java.lang.Object

`ValueDomains` object to model the attributes and behavior of value domains of variables during forward checking search for one or more solutions to the `ConstraintProblem`.

Author:
  Stephen L. Reed

  Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

  the license

  www.opencyc.org

  OpenCyc at SourceForge

  THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

See Also:
  `UnitTest#testConstraintProblem`

Field Summary
`protected ConstraintProblem` `constraintProblem` Reference to the parent `ConstraintProblem` object.
`protected java.util.HashMap` `domains` Dictionary of dictionaries of objects used to mark domain values during search.
`protected java.util.HashMap` `varsDictionary` Dictionary of variable --> domain value `ArrayList`.
`protected int` `verbosity` Sets verbosity of the constraint solver output.

Constructor Summary
`ValueDomains(ConstraintProblem constraintProblem)` Constructs a new `ValueDomains` object.

Method Summary
`void` `addDomainValue(CycVariable cycVariable, java.lang.Object value)` Adds an `Object` value to the domain for a variable.
`void` `complementDomainValues(CycVariable cycVariable, java.lang.Integer newLevel, Binding selectedBinding)` Iterates over the domain values for the given variable, changing any entries marked `true` to `Integer` level.
`void` `displayVariablesAndDomains()` Displays the variables and their value domains.
`boolean` `domainHasValue(CycVariable cycVariable, java.lang.Object value)` Returns `true` if the variable has value in its domain.
`java.util.ArrayList` `getDomainValues(CycVariable cycVariable)` Returns the `ArrayList` of domain values for a variable.
`int` `getUnmarkedDomainSize(CycVariable cycVariable)` Returns the number of unmarked (eligible for the solution) domain values for the given variable.
`java.util.ArrayList` `getUnmarkedDomainValues(CycVariable cycVariable)` Returns the `ArrayList` of unmarked (eligible for the solution) domain values for the given variable.
`void` `initializeDomainValueMarking()` Initializes the domain value marking structure.
`boolean` `isDomainMarked(CycVariable cycVariable, java.lang.Object value)` Returns `true` iff the variable / value combination is marked with any level number.
`boolean` `isDomainMarkedAtLevel(CycVariable cycVariable, java.lang.Object value, java.lang.Integer level)` Returns `true` iff the variable / value combination is marked with a given level number.
`boolean` `isDomainWipedOut(CycVariable cycVariable)` Returns `true` iff all the domain values of the variable have been marked and thus eliminated from consideration as a solution.
`void` `markDomain(CycVariable cycVariable, java.lang.Object value, java.lang.Object level)` Marks the entry for the variable / domain value with an `Integer` level number, or a `Boolean` `True`, or `null`.
`void` `removeFromValue(CycVariable cycVariable, java.lang.Object value)` Removes the given value from the given variable's value domain.
`void` `setDomainValues(CycVariable cycVariable, java.util.ArrayList domainValues)` Sets the `ArrayList` of domain values for a variable.
`void` `setVerbosity(int verbosity)` Sets verbosity of the constraint solver output.
`void` `unmarkDomain(CycVariable cycVariable, java.lang.Object value)` Resets the entry for the variable / domain value marking.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### verbosity

    protected int verbosity

  Sets verbosity of the constraint solver output. 0 --> quiet ... 9 -> maximum diagnostic input.

### varsDictionary

    protected java.util.HashMap varsDictionary

  Dictionary of variable --> domain value `ArrayList`.

### domains

    protected java.util.HashMap domains

  Dictionary of dictionaries of objects used to mark domain values during search. The purpose of marking is to eliminate values from the solution. First key indexes by constraint variable, second key indexes by domain value for the variable, and the object represents the integer search level at which the variable domain value was marked, or the boolean `true` during a complement operation, or `null` if the value is unmarked.

### constraintProblem

    protected ConstraintProblem constraintProblem

  Reference to the parent `ConstraintProblem` object.

Constructor Detail

### ValueDomains

    public ValueDomains(ConstraintProblem constraintProblem)

  Constructs a new `ValueDomains` object.
  Parameters:
    `constraintProblem` - the parent constraint problem

Method Detail

### displayVariablesAndDomains

    public void displayVariablesAndDomains()

  Displays the variables and their value domains.

### initializeDomainValueMarking

    public void initializeDomainValueMarking()

  Initializes the domain value marking structure.

### getDomainValues

    public java.util.ArrayList getDomainValues(CycVariable cycVariable)

  Returns the `ArrayList` of domain values for a variable.
  Parameters:
    `cycVariable` - the variable for domain values are sought
  Returns:
    the `ArrayList` of domain values for a variable

### setDomainValues

    public void setDomainValues(CycVariable cycVariable,
                                java.util.ArrayList domainValues)

  Sets the `ArrayList` of domain values for a variable.
  Parameters:
    `cycVariable` - the variable
    `domainValues` - the `ArrayList` of domain values for the variable

### addDomainValue

    public void addDomainValue(CycVariable cycVariable,
                               java.lang.Object value)

  Adds an `Object` value to the domain for a variable.
  Parameters:
    `cycVariable` - the variable
    `value` - the `Object` value which is added to the domain for the variable

### domainHasValue

    public boolean domainHasValue(CycVariable cycVariable,
                                  java.lang.Object value)

  Returns `true` if the variable has value in its domain.
  Parameters:
    `cycVariable` - the variable under consideration
    `value` - the value for comparison with the variable's value domain.
  Returns:
    `true` if the variable has value in its domain.

### removeFromValue

    public void removeFromValue(CycVariable cycVariable,
                                java.lang.Object value)

  Removes the given value from the given variable's value domain.
  Parameters:
    `cycVariable` - the variable under consideration
    `value` - the `Object` to be removed from the variable's value domain

### unmarkDomain

    public void unmarkDomain(CycVariable cycVariable,
                             java.lang.Object value)

  Resets the entry for the variable / domain value marking.

### markDomain

    public void markDomain(CycVariable cycVariable,
                           java.lang.Object value,
                           java.lang.Object level)

  Marks the entry for the variable / domain value with an `Integer` level number, or a `Boolean` `True`, or `null`.

### getUnmarkedDomainSize

    public int getUnmarkedDomainSize(CycVariable cycVariable)

  Returns the number of unmarked (eligible for the solution) domain values for the given variable.

### getUnmarkedDomainValues

    public java.util.ArrayList getUnmarkedDomainValues(CycVariable cycVariable)

  Returns the `ArrayList` of unmarked (eligible for the solution) domain values for the given variable.

### complementDomainValues

    public void complementDomainValues(CycVariable cycVariable,
                                       java.lang.Integer newLevel,
                                       Binding selectedBinding)

  Iterates over the domain values for the given variable, changing any entries marked `true` to `Integer` level.
  Parameters:
    `cycVariable` - the variable for domain value complementation
    `newLevel` - the new search level for the variable's domain
    `selectedBinding` - a variable binding for optional diagnostic display

### isDomainWipedOut

    public boolean isDomainWipedOut(CycVariable cycVariable)

  Returns `true` iff all the domain values of the variable have been marked and thus eliminated from consideration as a solution.
  Returns:
    `true` if and only if all the domain values of the variable have been marked and thus eliminated from consideration as a solution

### isDomainMarked

    public boolean isDomainMarked(CycVariable cycVariable,
                                  java.lang.Object value)

  Returns `true` iff the variable / value combination is marked with any level number.
  Returns:
    `true` iff the variable / value combination is marked with aany level number

### isDomainMarkedAtLevel

    public boolean isDomainMarkedAtLevel(CycVariable cycVariable,
                                         java.lang.Object value,
                                         java.lang.Integer level)

  Returns `true` iff the variable / value combination is marked with a given level number.
  Returns:
    `true` iff the variable / value combination is marked with a given level number

### setVerbosity

    public void setVerbosity(int verbosity)

  Sets verbosity of the constraint solver output. 0 --> quiet ... 9 -> maximum diagnostic input.
  Parameters:
    `verbosity` - 0 --> quiet ... 9 -> maximum diagnostic input