Package ptolemy.actor.util
Class RealDependency
- java.lang.Object
-
- ptolemy.actor.util.RealDependency
-
- All Implemented Interfaces:
java.lang.Comparable<Dependency>,Dependency
public class RealDependency extends java.lang.Object implements Dependency
This dependency represents causal relationships that have a real value or are infinite. Infinity represents the lack of a causal relationship. A finite positive real value represents a causal dependency with (typically) a time delay. A zero value represents an immediate causal relationship. See the paper "Causality Interfaces for Actor Networks" by Ye Zhou and Edward A. Lee, ACM Transactions on Embedded Computing Systems (TECS), April 2008, as available as Technical Report No. UCB/EECS-2006-148, November 16, 2006.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Field Summary
Fields Modifier and Type Field Description static RealDependencyOPLUS_IDENTITYThe additive identity.static RealDependencyOTIMES_IDENTITYThe multiplicative identity.-
Fields inherited from interface ptolemy.actor.util.Dependency
EQUALS, GREATER_THAN, INCOMPARABLE, LESS_THAN
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Dependency dependency)Return Dependency.LESS_THAN, EQUALS, or GREATER_THAN depending on whether the argument is less than, equal to, or greater than this dependency.booleanequals(java.lang.Object object)Return true if the value of this dependency equals that of the specified one, and the specified one is an instance of RealDependency.inthashCode()Return the same hashCode that that Java Double object would return had it the same value.DependencyoPlus(Dependency d)Return a dependency that results from parallel composition of this one and the specified one.DependencyoPlusIdentity()Return the dependency that when added to any other dependency using oPlus() yields the other dependency.DependencyoTimes(Dependency d)Return a dependency that results from serial composition of this one and the specified one.DependencyoTimesIdentity()Return the dependency that when multiplied by any other dependency using oTimes() yields the other dependency.java.lang.StringtoString()Return a string representation in the form "RealDependency(value)".doublevalue()Return the double value of the dependency.static RealDependencyvalueOf(double value)Return an instance of RealDependency with the specified value.
-
-
-
Field Detail
-
OPLUS_IDENTITY
public static final RealDependency OPLUS_IDENTITY
The additive identity.
-
OTIMES_IDENTITY
public static final RealDependency OTIMES_IDENTITY
The multiplicative identity.
-
-
Method Detail
-
compareTo
public int compareTo(Dependency dependency)
Return Dependency.LESS_THAN, EQUALS, or GREATER_THAN depending on whether the argument is less than, equal to, or greater than this dependency. Real dependencies are totally ordered, so this never returns Dependency.INCOMPARABLE. The order is the usual numerical ordering of doubles, with Double.POSITIVE_INFINITY on top.- Specified by:
compareToin interfacejava.lang.Comparable<Dependency>- Parameters:
dependency- The dependency to compare against.- Returns:
- The result of comparison.
- Throws:
java.lang.ClassCastException- If the argument is not an instance of RealDependency.
-
equals
public boolean equals(java.lang.Object object)
Return true if the value of this dependency equals that of the specified one, and the specified one is an instance of RealDependency.- Overrides:
equalsin classjava.lang.Object- Parameters:
object- The object to compare against.- Returns:
- true if this object is the same as the object argument.
-
hashCode
public int hashCode()
Return the same hashCode that that Java Double object would return had it the same value.- Overrides:
hashCodein classjava.lang.Object
-
oPlus
public Dependency oPlus(Dependency d)
Return a dependency that results from parallel composition of this one and the specified one.- Specified by:
oPlusin interfaceDependency- Parameters:
d- The dependency to add.- Returns:
- A dependency whose value is the minimum of the two dependency values.
- Throws:
java.lang.ClassCastException- if d is not a RealDependency.
-
oPlusIdentity
public Dependency oPlusIdentity()
Return the dependency that when added to any other dependency using oPlus() yields the other dependency.- Specified by:
oPlusIdentityin interfaceDependency- Returns:
- The additive identity.
-
oTimes
public Dependency oTimes(Dependency d)
Return a dependency that results from serial composition of this one and the specified one.- Specified by:
oTimesin interfaceDependency- Parameters:
d- The dependency to multiply.- Returns:
- A dependency whose value is the sum of the value of this one and the specified one.
- Throws:
java.lang.ClassCastException- if d is not a RealDependency.
-
oTimesIdentity
public Dependency oTimesIdentity()
Return the dependency that when multiplied by any other dependency using oTimes() yields the other dependency.- Specified by:
oTimesIdentityin interfaceDependency- Returns:
- The multiplicative identity.
-
toString
public java.lang.String toString()
Return a string representation in the form "RealDependency(value)".- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation.
-
value
public double value()
Return the double value of the dependency.- Returns:
- The value of the dependency.
-
valueOf
public static RealDependency valueOf(double value)
Return an instance of RealDependency with the specified value. This is preferable to use over the constructor because it uses the same instances for the most common values.- Parameters:
value- The value used to determine the RealDependency to be returned.- Returns:
- an instance of RealDependency, if value
is 0.0, then
OTIMES_IDENTITYis returned, if value is Double.POSITIVE_INFINITY, thenOPLUS_IDENTITYis returned. Otherwise the RealDependency constructor is called.
-
-