Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.opencyc.inferencesupport
Class Solution

    java.lang.Object
      |
      +--org.opencyc.inferencesupport.Solution

public class Solution
extends java.lang.Object

`Solution` object to model the attributes and behavior of 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
`static int` | `DEFAULT_VERBOSITY` The default verbosity of the solution output.
`protected int` | `nbrSolutionsFound` Number of solutions found by the search.
`protected java.lang.Integer` | `nbrSolutionsRequested` The number of solutions requested in the parent object.
`protected java.util.ArrayList` | `solutions` List of solutions where each solution is a list of constraint variable - domain value bindings which satisfy all the constraint rules.
`protected int` | `verbosity` Sets verbosity of the constraint solver output.

Constructor Summary
`Solution(java.lang.Integer nbrSolutionsRequested, int verbosity)` Constructs a new `Solution` object given the parent `ConstraintProblem` object.

Method Summary
`void` | `addBindingSet(BindingSet bindingSet)` Adds the solutions contained in the given binding set.
`void` | `addBindingToCurrentSolution(Binding binding)` Adds the variable / value binding to the current solution.
`void` | `addSolution(java.util.ArrayList solution)` Adds a new solution to the solution set.
`void` | `displaySolution(java.util.ArrayList solution)` Displays the bindings in a given solution to the constraint problem.
`void` | `displaySolutions()` Displays the bindings in all solutions to the constraint problem.
`void` | `finalizeAllSolutions()` Removes the current empty solution in the special case where all solutions were requested and where all solutions were found.
`java.util.ArrayList` | `getCurrentSolution()` Returns the current solution.
`int` | `getNbrSolutionsFound()` Returns the number of solutions found.
`java.util.ArrayList` | `getSolutions()` Returns all solutions.
`void` | `recordNewSolution(Binding binding)` Records the current solution state by copying the current solution into a new partial solution without including the given binding, which is already part of a prior solution.
`void` | `removeBindingFromCurrentSolution(Binding binding)` Removes the variable / value binding from the current solution.
`void` | `setNbrSolutionsFound(int nbrSolutionsFound)` Sets the number of solutions found.
`void` | `setSolutions(java.util.ArrayList solutions)` Sets solutions to the given list of solutions.
`void` | `setVerbosity(int verbosity)` Sets verbosity of the constraint solver output.

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

Field Detail

### DEFAULT_VERBOSITY

    public static final int DEFAULT_VERBOSITY

  The default verbosity of the solution output. 0 --> quiet ... 9 -> maximum diagnostic input.

### verbosity

    protected int verbosity

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

### nbrSolutionsRequested

    protected java.lang.Integer nbrSolutionsRequested

  The number of solutions requested in the parent object.

### nbrSolutionsFound

    protected int nbrSolutionsFound

  Number of solutions found by the search. Will not be more than the number requested if `nbrSolutionsRequested` is not `null`.

### solutions

    protected java.util.ArrayList solutions

  List of solutions where each solution is a list of constraint variable - domain value bindings which satisfy all the constraint rules. Newest solution is at the end of the list.

Constructor Detail

### Solution

    public Solution(java.lang.Integer nbrSolutionsRequested,
                    int verbosity)

  Constructs a new `Solution` object given the parent `ConstraintProblem` object. Initializes the solutions to a single empty solution.
  Parameters:
    `parent` - the parent `ConstraintProblem` or `QueryProcessor` object

Method Detail

### addBindingSet

    public void addBindingSet(BindingSet bindingSet)

  Adds the solutions contained in the given binding set.
  Parameters:
    `bindingSet` - the binding set whose variable value bindings are to be added to the solution

### addBindingToCurrentSolution

    public void addBindingToCurrentSolution(Binding binding)

  Adds the variable / value binding to the current solution.
  Parameters:
    `binding` - the variable / value binding to be added

### removeBindingFromCurrentSolution

    public void removeBindingFromCurrentSolution(Binding binding)

  Removes the variable / value binding from the current solution.
  Parameters:
    `binding` - the variable / value binding to be removed

### addSolution

    public void addSolution(java.util.ArrayList solution)

  Adds a new solution to the solution set. The added solution becomes the current solution.
  Parameters:
    `the` - new solution `ArrayList` of `Binding` objects to be added to the solution set

### getCurrentSolution

    public java.util.ArrayList getCurrentSolution()

  Returns the current solution.
  Returns:
    the current solution

### setNbrSolutionsFound

    public void setNbrSolutionsFound(int nbrSolutionsFound)

  Sets the number of solutions found.
  Parameters:
    `nbrSolutionsFound` - the new value for the number of solutions found

### getNbrSolutionsFound

    public int getNbrSolutionsFound()

  Returns the number of solutions found.
  Returns:
    the number of solutions found

### getSolutions

    public java.util.ArrayList getSolutions()

  Returns all solutions.
  Returns:
    the `ArrayList` of solutions, each solution is an `ArrayList` of `Binding` objects

### setSolutions

    public void setSolutions(java.util.ArrayList solutions)

  Sets solutions to the given list of solutions.
  Parameters:
    `solutions` - the list of solutions

### recordNewSolution

    public void recordNewSolution(Binding binding)

  Records the current solution state by copying the current solution into a new partial solution without including the given binding, which is already part of a prior solution.
  Parameters:
    `binding` - the variable / value binding, which is not to be included in the new partial solution

### displaySolution

    public void displaySolution(java.util.ArrayList solution)

  Displays the bindings in a given solution to the constraint problem.

### displaySolutions

    public void displaySolutions()

  Displays the bindings in all solutions to the constraint problem.

### finalizeAllSolutions

    public void finalizeAllSolutions()

  Removes the current empty solution in the special case where all solutions were requested and where all solutions were found.

### 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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD