ptolemy.actor.util
Class SuperdenseDependency

java.lang.Object
  extended by ptolemy.actor.util.SuperdenseDependency
All Implemented Interfaces:
java.lang.Comparable<Dependency>, Dependency

public class SuperdenseDependency
extends java.lang.Object
implements Dependency

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: SuperdenseDependency.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Edward A. Lee, Slobodan Matic, Jia Zou
Accepted Rating:
Red (eal)
Proposed Rating:
Yellow (eal)

Field Summary
private  int _index
          The superdense time index.
private  double _time
          The real (time) value.
static SuperdenseDependency OPLUS_IDENTITY
          The additive identity.
static SuperdenseDependency OTIMES_IDENTITY
          The multiplicative identity.
 
Fields inherited from interface ptolemy.actor.util.Dependency
EQUALS, GREATER_THAN, INCOMPARABLE, LESS_THAN
 
Constructor Summary
private SuperdenseDependency(double time, int index)
          Construct a dependency with the specified value.
 
Method Summary
 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 RealDepedency.
 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 java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OPLUS_IDENTITY

public static final SuperdenseDependency OPLUS_IDENTITY
The additive identity.


OTIMES_IDENTITY

public static final SuperdenseDependency OTIMES_IDENTITY
The multiplicative identity.


_index

private int _index
The superdense time index.


_time

private double _time
The real (time) value.

Constructor Detail

SuperdenseDependency

private SuperdenseDependency(double time,
                             int index)
Construct a dependency with the specified value. The constructor is private. Use valueOf() to construct an instance.

Parameters:
time - The real part of the dependency.
index - The supersense index part of the dependency.
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 interface java.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 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 RealDepedency.

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 class java.lang.Object
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 class java.lang.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 interface Dependency
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 interface Dependency
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 interface Dependency
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 interface Dependency
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 class java.lang.Object
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, then OPLUS_IDENTITY is returned. Otherwise the SuperdenseDependency constructor is called.