Package ptolemy.graph
Class Inequality
- java.lang.Object
-
- ptolemy.graph.Inequality
-
public class Inequality extends java.lang.ObjectAn inequality over a CPO. Each inequality consists of twoInequalityTerms, the lesser term and the greater term. The relation between them is less than or equal to. In addition, an inequality keeps a list of variables in it. The variables areInequalityTermsthat consist of a single variable.- Since:
- Ptolemy II 0.2
- Version:
- $Id$
- Author:
- Yuhong Xiong
- See Also:
InequalityTerm- Pt.AcceptedRating:
- Green (kienhuis)
- Pt.ProposedRating:
- Green (yuhong)
-
-
Constructor Summary
Constructors Constructor Description Inequality(InequalityTerm lesserTerm, InequalityTerm greaterTerm)Construct an inequality.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)Return true if object named by the argument is equal to this Inequality object.InequalityTermgetGreaterTerm()Return the greater term of this inequality.InequalityTermgetLesserTerm()Return the lesser term of this inequality.inthashCode()Return the hashCode of this object.booleanisSatisfied(CPO cpo)Test if this inequality is satisfied with the current value of variables.java.lang.StringtoString()Override the base class to describe the inequality.
-
-
-
Constructor Detail
-
Inequality
public Inequality(InequalityTerm lesserTerm, InequalityTerm greaterTerm)
Construct an inequality.- Parameters:
lesserTerm- AnInequalityTermthat is less than or equal to the second argument.greaterTerm- AnInequalityTermthat is greater than or equal to the first argument.- Throws:
java.lang.IllegalArgumentException- If thelesserTermor thegreaterTermisnull.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object object)
Return true if object named by the argument is equal to this Inequality object.Override to return true if the greater and lesser terms of this object are the same as the greater and lesser terms of the specified object.
- Overrides:
equalsin classjava.lang.Object- Parameters:
object- Object to compare against.- Returns:
- true If the object is an Inequality and both the greater term and lesser term are equal to the corresponding terms of this object.
-
getGreaterTerm
public InequalityTerm getGreaterTerm()
Return the greater term of this inequality.- Returns:
- An
InequalityTerm
-
getLesserTerm
public InequalityTerm getLesserTerm()
Return the lesser term of this inequality.- Returns:
- An
InequalityTerm
-
hashCode
public int hashCode()
Return the hashCode of this object.Override to return the exclusive OR of the hashcodes of the greater and lesser terms. This ensures that two objects that return true to equals() have the same hashcode.
- Overrides:
hashCodein classjava.lang.Object- Returns:
- The XOR of the greater and lesser terms.
-
isSatisfied
public boolean isSatisfied(CPO cpo) throws IllegalActionException
Test if this inequality is satisfied with the current value of variables.- Parameters:
cpo- A CPO over which this inequality is defined.- Returns:
- True if this inequality is satisfied; false otherwise.
- Throws:
IllegalActionException- If thrown while getting the value of the terms.
-
toString
public java.lang.String toString()
Override the base class to describe the inequality.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string describing the inequality.
-
-