## org.opencyc.constraintsolver
Class RuleEvaluator

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

public class RuleEvaluator
extends java.lang.Object

`RuleEvaluator` object evaluates constraint rules for the parent `ConstraintProblem` object. Although all rules may be evaluated by asking the OpenCyc KB, some rules having evaluatable predicates and functions may be efficiently evaluated locally

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 CycConstant` `and` Cached reference to #$and logical operator.
`protected ConstraintProblem` `constraintProblem` Reference to the parent `ConstraintProblem` object.
`protected CycConstant` `different` Cached reference to #$different predicate.
`protected CycConstant` `not` Cached reference to #$not logical operator.
`protected CycConstant` `numericallyEqual` Cached reference to #$numericallyEqual predicate.
`protected CycConstant` `or` Cached reference to #$or logical operator.
`protected CycConstant` `plusFn` Cached reference to #$PlusFn function.
`protected int` `verbosity` Sets verbosity of the constraint solver output.

Constructor Summary
`RuleEvaluator(ConstraintProblem constraintProblem)` Constructs a new `RuleEvaluator` object for the parent `ConstraintProblem`.

Method Summary
`boolean` `ask(ConstraintRule rule)` Return `true` iff the instantiated constraint rule is proven true, otherwise return `false`
`void` `initialize()` Initializes this instance once the parent `ConstraintProblem` object creates a `CycAccess` object.
`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

### constraintProblem

    protected ConstraintProblem constraintProblem

  Reference to the parent `ConstraintProblem` object.

### verbosity

    protected int verbosity

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

### numericallyEqual

    protected CycConstant numericallyEqual

  Cached reference to #$numericallyEqual predicate.

### and

    protected CycConstant and

  Cached reference to #$and logical operator.

### or

    protected CycConstant or

  Cached reference to #$or logical operator.

### not

    protected CycConstant not

  Cached reference to #$not logical operator.

### different

    protected CycConstant different

  Cached reference to #$different predicate.

### plusFn

    protected CycConstant plusFn

  Cached reference to #$PlusFn function.

Constructor Detail

### RuleEvaluator

    public RuleEvaluator(ConstraintProblem constraintProblem)

  Constructs a new `RuleEvaluator` object for the parent `ConstraintProblem`.
  Parameters:
    `constraintProblem` - the parent constraint problem

Method Detail

### initialize

    public void initialize()

  Initializes this instance once the parent `ConstraintProblem` object creates a `CycAccess` object.

### ask

    public boolean ask(ConstraintRule rule)
                throws java.io.IOException,
                       CycApiException

  Return `true` iff the instantiated constraint rule is proven true, otherwise return `false`
  Parameters:
    `rule` - the instantiated constraint rule to be evaluated
  Returns:
    `true` iff the instantiated constraint rule is proven true, otherwise return `false`

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