Package ptolemy.actor.util
Class SuperdenseDependency
- java.lang.Object
-
- ptolemy.actor.util.BooleanDependency
-
- ptolemy.actor.util.SuperdenseDependency
-
- All Implemented Interfaces:
java.lang.Comparable<Dependency>
,Dependency
public class SuperdenseDependency extends BooleanDependency
This dependency represents causal relationships that have a real value and a superdense time index. If the real value is infinite, this 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 no time delay, but whether there is an immediate causal relationship depends on the index. If the index is 0, then there is an immediate causal relationship. Otherwise, there is not. 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, Slobodan Matic, Jia Zou
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Field Summary
Fields Modifier and Type Field Description static SuperdenseDependency
OPLUS_IDENTITY
The additive identity.static SuperdenseDependency
OTIMES_IDENTITY
The multiplicative identity.-
Fields inherited from class ptolemy.actor.util.BooleanDependency
_value
-
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 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.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.int
hashCode()
Return the same hashCode that that Java Double object would return had it the same value as the real part of the value of this dependency.int
indexValue()
Return the index value of this dependency.Dependency
oPlus(Dependency dependency)
Return a dependency that results from parallel composition of this one and the specified one.Dependency
oPlusIdentity()
Return the dependency that when added to any other dependency using oPlus() yields the other dependency.Dependency
oTimes(Dependency dependency)
Return a dependency that results from serial composition of this one and the specified one.Dependency
oTimesIdentity()
Return the dependency that when multiplied by any other dependency using oTimes() yields the other dependency.double
timeValue()
Return the time value of this dependency.java.lang.String
toString()
Return a string representation in the form "SuperdenseDependency(_time, _index)".static SuperdenseDependency
valueOf(double time, int index)
Return an instance of SuperdenseDependency with the specified time and index value.-
Methods inherited from class ptolemy.actor.util.BooleanDependency
valueOf
-
-
-
-
Field Detail
-
OPLUS_IDENTITY
public static final SuperdenseDependency OPLUS_IDENTITY
The additive identity.
-
OTIMES_IDENTITY
public static final SuperdenseDependency 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.In the case where both dependencies have _time value equal to Double.POSITIVE_INFINITY, these two dependencies are equal, even though its indices may differ. This conforms with valueOf() method.
- Specified by:
compareTo
in interfacejava.lang.Comparable<Dependency>
- Overrides:
compareTo
in classBooleanDependency
- Parameters:
dependency
- The dependency to compare against.- Returns:
- The result of comparison.
- Throws:
java.lang.ClassCastException
- If the argument is not an instance of SuperdenseDependency.- See Also:
valueOf(double, int)
-
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.In the case where both dependencies have _time value equal to Double.POSITIVE_INFINITY, these two dependencies are equal, even though its indices may differ. This conforms with valueOf() method.
- Overrides:
equals
in classBooleanDependency
- Parameters:
object
- The object to compare against.- Returns:
- true if this object is the same as the object argument.
- See Also:
valueOf(double, int)
-
hashCode
public int hashCode()
Return the same hashCode that that Java Double object would return had it the same value as the real part of the value of this dependency.- Overrides:
hashCode
in classBooleanDependency
- Returns:
- A hash code for this object.
-
indexValue
public int indexValue()
Return the index value of this dependency.- Returns:
- The index part of the dependency.
-
oPlus
public Dependency oPlus(Dependency dependency)
Return a dependency that results from parallel composition of this one and the specified one.- Specified by:
oPlus
in interfaceDependency
- Overrides:
oPlus
in classBooleanDependency
- Parameters:
dependency
- The dependency to add.- Returns:
- A dependency whose value is the minimum of the two dependency values.
- Throws:
java.lang.ClassCastException
- if dependency is not a SuperdenseDependency.
-
oPlusIdentity
public Dependency oPlusIdentity()
Return the dependency that when added to any other dependency using oPlus() yields the other dependency.- Specified by:
oPlusIdentity
in interfaceDependency
- Overrides:
oPlusIdentity
in classBooleanDependency
- Returns:
- The additive identity.
-
oTimes
public Dependency oTimes(Dependency dependency)
Return a dependency that results from serial composition of this one and the specified one. The real part of the result is the sum of the real parts of this and the specified dependency. The index, however, will be nonzero only if the specified dependency has a real part equal to 0.0. In that case, the index of the result will be the sum of indices of this and the specified dependency. NOTE: This implementation of oTimes is not commutative. Fortunately, the theory does not require it to be.- Specified by:
oTimes
in interfaceDependency
- Overrides:
oTimes
in classBooleanDependency
- Parameters:
dependency
- 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 dependency 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:
oTimesIdentity
in interfaceDependency
- Overrides:
oTimesIdentity
in classBooleanDependency
- Returns:
- The multiplicative identity.
-
timeValue
public double timeValue()
Return the time value of this dependency.- Returns:
- The real part of the dependency.
-
toString
public java.lang.String toString()
Return a string representation in the form "SuperdenseDependency(_time, _index)".- Overrides:
toString
in classBooleanDependency
- Returns:
- A string representation.
-
valueOf
public static SuperdenseDependency valueOf(double time, int index)
Return an instance of SuperdenseDependency with the specified time and index value. This is preferable to use over the constructor because it uses the same instances for the most common values.- Parameters:
time
- The time value.index
- The index value.- Returns:
- an instance of RealDependency, if value
is (0.0, 0) then
OTIMES_IDENTITY
is returned, if value is (Double.POSITIVE_INFINITY, n) for any n, thenOPLUS_IDENTITY
is returned. Otherwise the SuperdenseDependency constructor is called.
-
-