public class PropositionalAtLeast extends PropositionalNAryConstraint
m
of the children constraints must be true.Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
PropositionalAtLeast(PropositionalConstraint[] c,
int m)
Initializing constructor.
|
Modifier and Type | Method and Description |
---|---|
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(Object o)
Two
PropositionalAtLeast s 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(StringBuffer buffer)
Creates a string respresentation of this constraint using the string representations of the
objects involved.
|
consolidateVariables
toString
protected PropositionalConstraint[] children
protected int m
public PropositionalAtLeast(PropositionalConstraint[] c, int m)
c
- A collection of children constraints.m
- The number of children that must be true.public Constraint[] getChildren()
getChildren
in class PropositionalNAryConstraint
public int getM()
m
.public boolean contains(PropositionalConstraint c)
contains
in class PropositionalNAryConstraint
c
- The given constraint.true
iff the given constraint is contained in this constraint.public int size()
size
in class PropositionalNAryConstraint
public boolean evaluate()
evaluate
in class Constraint
public void remove(int r)
children
array with a new array containing all the same elements
except the element with the given index.r
- The index of the child to remove.public PropositionalConstraint simplify()
simplify
in class PropositionalConstraint
Constraint.consolidateVariables(java.util.AbstractMap)
public PropositionalConstraint negate()
negate
in class PropositionalConstraint
public PropositionalConstraint CNF()
CNF
in class PropositionalConstraint
public PropositionalConstraint DNF()
DNF
in class PropositionalConstraint
protected static boolean nextChoice(int[] I, int max)
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.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).true
iff the input did not represent the last choice.public boolean moreGeneralThan(PropositionalConstraint c)
false
.moreGeneralThan
in class PropositionalConstraint
c
- The given constraint.true
if a topological analysis determined that this constraint is more
general than the given constraint.public boolean moreSpecificThan(PropositionalImplication c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given implication.true
if a topological analysis determined that this constraint is more
general than the given implication.public boolean moreSpecificThan(PropositionalDoubleImplication c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given double implication.true
if a topological analysis determined that this constraint is more
general than the given double implication.public boolean moreSpecificThan(PropositionalConjunction c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given conjunction.true
if a topological analysis determined that this constraint is more
general than the given conjunction.public boolean moreSpecificThan(PropositionalDisjunction c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given disjunction.true
if a topological analysis determined that this constraint is more
general than the given disjunction.public boolean moreSpecificThan(PropositionalAtLeast c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given at-least.true
if a topological analysis determined that this constraint is more
specific than the given disjunction.public boolean moreSpecificThan(PropositionalNegation c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given negation.true
if a topological analysis determined that this constraint is more
general than the given negation.public boolean moreSpecificThan(PropositionalVariable c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given variable.true
if a topological analysis determined that this constraint is more
general than the given variable.public boolean moreSpecificThan(PropositionalConstant c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given constant.true
if a topological analysis determined that this constraint is more
general than the given constant.public int hashCode()
PropositionalAtLeast
is the sum of the hash codes of its
children plus two.public boolean equals(Object o)
PropositionalAtLeast
s are equivalent when they are topologically equivalent;
this implementation currently does not respect the associativity and commutativity of
at-least.public void runVisit(Inference infer)
visit(·)
method of the given Inference
for this Constraint
, as per the visitor pattern.runVisit
in class Constraint
infer
- The inference visiting this constraint.public void write(StringBuffer buffer)
write
in class PropositionalConstraint
buffer
- The output of this method will be appended to this buffer.public Object clone()
clone
in class PropositionalNAryConstraint
Copyright © 2016. All rights reserved.