edu.cs.ai.kreator.logic.metaconstraints
Class NotEqualConstraint

java.lang.Object
  extended by edu.cs.ai.kreator.logic.metaconstraints.NotEqualConstraint
All Implemented Interfaces:
Latexable, MetaConstraint

public class NotEqualConstraint
extends java.lang.Object
implements MetaConstraint

This class implements the Meta-Constraint for RME-Conditionals which prohibits the instantiation of two variables with the same constant, e.g. [X!=Y].

Author:
Sebastian Loh, Matthias Thimm

Constructor Summary
NotEqualConstraint(Variable var1, Variable var2)
          Constructs a new NotEqualConstraint for two Variables which not should substituted by the sameConstant.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Return true if other is a MetaConstraint and both have equal attributes.
 java.util.Set<Variable> getVariables()
          Returns all variables appearing in this constraint.
 int hashCode()
           
 boolean isValidSubstitution(java.util.Map<Variable,Constant> substitution)
          Checks if a given substitution violates this MetaConstraint.
 java.lang.String toLatex()
          Returns a Latex grammar conform string to generate variables, rules (conditionals) etc.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NotEqualConstraint

public NotEqualConstraint(Variable var1,
                          Variable var2)
Constructs a new NotEqualConstraint for two Variables which not should substituted by the sameConstant.

Parameters:
var1 - the first Variable, Variables must be different.
var2 - the second Variable, Variables must be different.
Method Detail

isValidSubstitution

public boolean isValidSubstitution(java.util.Map<Variable,Constant> substitution)
Description copied from interface: MetaConstraint
Checks if a given substitution violates this MetaConstraint. E.g if this is a NotEqualConstraint like X!=Y, then substitution.get(X).equals(substitution.get(Y) == false will be returned. If this is an ExclusionConstraint X != (v_1, ... ,v_n) then substitution.get(X).equals(v_1) should hold for all 1<= i <= n.

Specified by:
isValidSubstitution in interface MetaConstraint
Parameters:
substitution - the substitution to check.
Returns:
true if the no MetaConstraint is violated by the given susbtitution.

toString

public java.lang.String toString()
Specified by:
toString in interface MetaConstraint
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this MetaConstraint.

getVariables

public java.util.Set<Variable> getVariables()
Description copied from interface: MetaConstraint
Returns all variables appearing in this constraint.

Specified by:
getVariables in interface MetaConstraint
Returns:
all variables appearing in this constraint.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:

NOTE: HashCode is the same for symmetric {@link NotEqualConstraint} constraints. For example hashCode( X!=Y ) == hashCode( Y!=X ) holds true.

equals

public boolean equals(java.lang.Object obj)
Description copied from interface: MetaConstraint
Return true if other is a MetaConstraint and both have equal attributes.

Specified by:
equals in interface MetaConstraint
Overrides:
equals in class java.lang.Object
Parameters:
obj - a Object
Returns:
true if other is a MetaConstraint and both have equal attributes.
See Also:
NOTE: The {@link MetaConstraint} X!=Y is equal to Y!=X

toLatex

public java.lang.String toLatex()
Description copied from interface: Latexable
Returns a Latex grammar conform string to generate variables, rules (conditionals) etc.

Specified by:
toLatex in interface Latexable
Specified by:
toLatex in interface MetaConstraint
Returns:
a Latex grammar conform string.