sdf
Class SDF

java.lang.Object
  extended by sdf.SDF
All Implemented Interfaces:
Serializable, Cloneable, Idempotency, Regularity, Valuation

public class SDF
extends Object
implements Valuation, Idempotency

Shortest distance functions are an example of a valuation algebra and this class is a possible implementation of the valuation interface for the case of shortest distance functions. Internally it is represented by a two- dimensional hashtable.

Version:
1.1
Author:
Antoine De Groote, Marc Pouly
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface nenok.va.Idempotency
Idempotency.Implementor
 
Constructor Summary
  SDF(SDF_Variable[] variables, double[][] values)
          Constructor:
protected SDF(SDF_Variable[] variables, Hashtable<SDF_Variable,Hashtable<SDF_Variable,Double>> values)
          Constructor:
 
Method Summary
 Object clone()
          Clones this SDF.
 Valuation combine(Valuation val)
          Combines this SDF with val and returns a new SDF object.
 String displayText()
           
 boolean equals(Object o)
          Compares SDFs for equality.
 Valuation extension(Domain dom)
          Calculates the vacuous extension of this SDF to the specified domain.
 Regularity inverse()
           
 Domain label()
          Returns the domain of this SDF.
 Valuation marginalize(Domain dom)
          Marginalizes this SDF to the domain dom.
protected static boolean numericTest(double d1, double d2)
          This test compares two numeric double values on equality.
 Predictor predictor()
           
 String toString()
          Same as displayText(): invokes this method internally.
 int weight()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SDF

public SDF(SDF_Variable[] variables,
           double[][] values)
Constructor:

Parameters:
variables - The nodes of the network that this distance function covers.
values - The values for each possible link. (bidimensional array) If variables is of size n, then values must be of size n*n.

SDF

protected SDF(SDF_Variable[] variables,
              Hashtable<SDF_Variable,Hashtable<SDF_Variable,Double>> values)
Constructor:

Parameters:
variables - The nodes of the network that this distance function covers.
values - The values for each possible link. (bidimensional hashtable) If variables is of size n, then values must be of size n*n.
Method Detail

label

public Domain label()
Returns the domain of this SDF.

Specified by:
label in interface Valuation
See Also:
Valuation.label()

combine

public Valuation combine(Valuation val)
Combines this SDF with val and returns a new SDF object.

Specified by:
combine in interface Valuation
Parameters:
val - the SDF this SDF is to be combined with
Returns:
the resulting, newly created SDF
See Also:
Valuation.combine(nenok.va.Valuation)

marginalize

public Valuation marginalize(Domain dom)
Marginalizes this SDF to the domain dom. Row and columns (i.e. hashtable entries) that don't appear in dom are dropped, and a new SDF object is returned.

Specified by:
marginalize in interface Valuation
Parameters:
dom - the domain this SDF is to be projected to
Returns:
a new, projected SDF object
See Also:
Valuation.marginalize(nenok.va.Domain)

extension

public Valuation extension(Domain dom)
Calculates the vacuous extension of this SDF to the specified domain.

Parameters:
dom - The domain to which this SDF is to be extended.
Returns:
an SDF with domain dom

clone

public Object clone()
Clones this SDF.

Overrides:
clone in class Object
Returns:
a copy of this SDF
See Also:
Object.clone()

weight

public int weight()
Specified by:
weight in interface Valuation
See Also:
Valuation.weight()

inverse

public Regularity inverse()
Specified by:
inverse in interface Regularity
See Also:
Regularity.inverse()

predictor

public Predictor predictor()
Returns:
The prdictor of this valuation algebra instance.
See Also:
Predictability.predictor()

equals

public boolean equals(Object o)
Compares SDFs for equality. This is the case if the hashtable entries are identical.

Overrides:
equals in class Object
Parameters:
o - the object this SDF is to be compared to
Returns:
true or false, regarding equality
See Also:
Object.equals(java.lang.Object)

displayText

public String displayText()
Returns:
The current SDF as a string.

toString

public String toString()
Same as displayText(): invokes this method internally.

Overrides:
toString in class Object
See Also:
Object.toString()

numericTest

protected static boolean numericTest(double d1,
                                     double d2)
This test compares two numeric double values on equality. They are equal if their distance is smaller that the EPSILON constant.

Parameters:
d1 - The first value.
d2 - The second value.
Returns:
true, if the two values are equal.