LBJ2.infer
Class PropositionalAtLeast

java.lang.Object
  extended by LBJ2.infer.Constraint
      extended by LBJ2.infer.PropositionalConstraint
          extended by LBJ2.infer.PropositionalNAryConstraint
              extended by LBJ2.infer.PropositionalAtLeast
All Implemented Interfaces:
java.lang.Cloneable

public class PropositionalAtLeast
extends PropositionalNAryConstraint

Represents the constraint that at least m of the children constraints must be true.


Field Summary
protected  PropositionalConstraint[] children
          The children are stored in an array in this class.
protected  int m
          The number of child constraints that must be true.
 
Constructor Summary
private PropositionalAtLeast()
          Default constructor.
  PropositionalAtLeast(PropositionalConstraint[] c, int m)
          Initializing constructor.
 
Method Summary
 java.lang.Object clone()
          This method returns a shallow clone.
 PropositionalConstraint CNF()
          Produces a new, logically simplified version of this constraint in conjunctive normal form (CNF).
 boolean contains(PropositionalConstraint c)
          Determines whether the given constraint is a term of this constraint.
 PropositionalConstraint DNF()
          Produces a new, logically simplified version of this constraint in disjunctive normal form (DNF).
 boolean equals(java.lang.Object o)
          Two PropositionalAtLeasts are equivalent when they are topologically equivalent; this implementation currently does not respect the associativity and commutativity of at-least.
 boolean evaluate()
          Determines whether the constraint is satisfied.
 Constraint[] getChildren()
          Returns the children of this constraint in an array.
 int getM()
          Returns the value of m.
 int hashCode()
          The hash code of a PropositionalAtLeast is the sum of the hash codes of its children plus two.
 boolean moreGeneralThan(PropositionalConstraint c)
          Compares topology to determine if this constraint is more general than the given constraint; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalAtLeast c)
          Compares topology to determine if this constraint is more specific than the given at-least; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalConjunction c)
          Compares topology to determine if this constraint is more specific than the given conjunction; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalConstant c)
          Compares topology to determine if this constraint is more specific than the given constant; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalDisjunction c)
          Compares topology to determine if this constraint is more specific than the given disjunction; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalDoubleImplication c)
          Compares topology to determine if this constraint is more specific than the given double implication; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalImplication c)
          Compares topology to determine if this constraint is more specific than the given implication; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalNegation c)
          Compares topology to determine if this constraint is more specific than the given negation; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalVariable c)
          Compares topology to determine if this constraint is more specific than the given variable; note: this method is not required to be correct when it answers false.
 PropositionalConstraint negate()
          The negation of an at-least(m) is the at-least(n-m+1) of the negated children.
protected static boolean nextChoice(int[] I, int max)
          Given a particular choice of k of the first n non-negative integers, this method computes the next logical choice of k integers, modifying the input array to contain that choice.
 void remove(int r)
          Replaces the children array with a new array containing all the same elements except the element with the given index.
 void runVisit(Inference infer)
          Calls the appropriate visit(·) method of the given Inference for this Constraint, as per the visitor pattern.
 PropositionalConstraint simplify()
          Produces a new, logically simplified version of this constraint, preserving variable consolidation.
 int size()
          Returns the number of terms in this constraint.
 void write(java.lang.StringBuffer buffer)
          Creates a string respresentation of this constraint using the string representations of the objects involved.
 
Methods inherited from class LBJ2.infer.PropositionalNAryConstraint
consolidateVariables
 
Methods inherited from class LBJ2.infer.PropositionalConstraint
toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

children

protected PropositionalConstraint[] children
The children are stored in an array in this class.


m

protected int m
The number of child constraints that must be true.

Constructor Detail

PropositionalAtLeast

private PropositionalAtLeast()
Default constructor.


PropositionalAtLeast

public PropositionalAtLeast(PropositionalConstraint[] c,
                            int m)
Initializing constructor.

Parameters:
c - A collection of children constraints.
m - The number of children that must be true.
Method Detail

getChildren

public Constraint[] getChildren()
Returns the children of this constraint in an array.

Overrides:
getChildren in class PropositionalNAryConstraint
Returns:
The children of this constraint in an array.

getM

public int getM()
Returns the value of m.


contains

public boolean contains(PropositionalConstraint c)
Determines whether the given constraint is a term of this constraint.

Overrides:
contains in class PropositionalNAryConstraint
Parameters:
c - The given constraint.
Returns:
true iff the given constraint is contained in this constraint.

size

public int size()
Returns the number of terms in this constraint.

Overrides:
size in class PropositionalNAryConstraint
Returns:
The number of terms in this constraint.

evaluate

public boolean evaluate()
Determines whether the constraint is satisfied.

Specified by:
evaluate in class Constraint

remove

public void remove(int r)
Replaces the children array with a new array containing all the same elements except the element with the given index.

Parameters:
r - The index of the child to remove.

simplify

public PropositionalConstraint simplify()
Produces a new, logically simplified version of this constraint, preserving variable consolidation.

Specified by:
simplify in class PropositionalConstraint
Returns:
A logically simplified version of this constraint.
See Also:
Constraint.consolidateVariables(java.util.AbstractMap)

negate

public PropositionalConstraint negate()
The negation of an at-least(m) is the at-least(n-m+1) of the negated children.

Specified by:
negate in class PropositionalConstraint
Returns:
A simplified constraint representing the negation of this constraint.

CNF

public PropositionalConstraint CNF()
Produces a new, logically simplified version of this constraint in conjunctive normal form (CNF).

Specified by:
CNF in class PropositionalConstraint
Returns:
The conjunctive normal form of this constraint.

DNF

public PropositionalConstraint DNF()
Produces a new, logically simplified version of this constraint in disjunctive normal form (DNF).

Specified by:
DNF in class PropositionalConstraint
Returns:
The disjunctive normal form of this constraint.

nextChoice

protected static boolean nextChoice(int[] I,
                                    int max)
Given a particular choice of k of the first n non-negative integers, this method computes the next logical choice of k integers, modifying the input array to contain that choice. The parameter I contains the current choice, and it must be sorted in ascending order. The parameter max contains the largest allowable value for any integer in I. Therefore, n = max + 1, and k = I.length. It is also assumed that the "first" choice is the integers 0 through k - 1 inclusive and the "last" choice is max - k + 1 through max inclusive.

Parameters:
I - The current choice of k out of the first n non-negative integers, sorted in decreasing order.
max - The largest value allowed to appear in I (n - 1).
Returns:
true iff the input did not represent the last choice.

moreGeneralThan

public boolean moreGeneralThan(PropositionalConstraint c)
Compares topology to determine if this constraint is more general than the given constraint; note: this method is not required to be correct when it answers false.

Specified by:
moreGeneralThan in class PropositionalConstraint
Parameters:
c - The given constraint.
Returns:
true if a topological analysis determined that this constraint is more general than the given constraint.

moreSpecificThan

public boolean moreSpecificThan(PropositionalImplication c)
Compares topology to determine if this constraint is more specific than the given implication; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given implication.
Returns:
true if a topological analysis determined that this constraint is more general than the given implication.

moreSpecificThan

public boolean moreSpecificThan(PropositionalDoubleImplication c)
Compares topology to determine if this constraint is more specific than the given double implication; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given double implication.
Returns:
true if a topological analysis determined that this constraint is more general than the given double implication.

moreSpecificThan

public boolean moreSpecificThan(PropositionalConjunction c)
Compares topology to determine if this constraint is more specific than the given conjunction; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given conjunction.
Returns:
true if a topological analysis determined that this constraint is more general than the given conjunction.

moreSpecificThan

public boolean moreSpecificThan(PropositionalDisjunction c)
Compares topology to determine if this constraint is more specific than the given disjunction; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given disjunction.
Returns:
true if a topological analysis determined that this constraint is more general than the given disjunction.

moreSpecificThan

public boolean moreSpecificThan(PropositionalAtLeast c)
Compares topology to determine if this constraint is more specific than the given at-least; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given at-least.
Returns:
true if a topological analysis determined that this constraint is more specific than the given disjunction.

moreSpecificThan

public boolean moreSpecificThan(PropositionalNegation c)
Compares topology to determine if this constraint is more specific than the given negation; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given negation.
Returns:
true if a topological analysis determined that this constraint is more general than the given negation.

moreSpecificThan

public boolean moreSpecificThan(PropositionalVariable c)
Compares topology to determine if this constraint is more specific than the given variable; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given variable.
Returns:
true if a topological analysis determined that this constraint is more general than the given variable.

moreSpecificThan

public boolean moreSpecificThan(PropositionalConstant c)
Compares topology to determine if this constraint is more specific than the given constant; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given constant.
Returns:
true if a topological analysis determined that this constraint is more general than the given constant.

hashCode

public int hashCode()
The hash code of a PropositionalAtLeast is the sum of the hash codes of its children plus two.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this PropositionalConjunction.

equals

public boolean equals(java.lang.Object o)
Two PropositionalAtLeasts are equivalent when they are topologically equivalent; this implementation currently does not respect the associativity and commutativity of at-least.

Overrides:
equals in class java.lang.Object
Returns:
true iff the argument is an equivalent PropositionalAtLeast.

runVisit

public void runVisit(Inference infer)
Calls the appropriate visit(·) method of the given Inference for this Constraint, as per the visitor pattern.

Specified by:
runVisit in class Constraint
Parameters:
infer - The inference visiting this constraint.

write

public void write(java.lang.StringBuffer buffer)
Creates a string respresentation of this constraint using the string representations of the objects involved.

Specified by:
write in class PropositionalConstraint
Parameters:
buffer - The output of this method will be appended to this buffer.

clone

public java.lang.Object clone()
This method returns a shallow clone.

Overrides:
clone in class PropositionalNAryConstraint
Returns:
A shallow clone.