nenok.lc
Class JoinTree

java.lang.Object
  extended by nenok.lc.JoinTree
All Implemented Interfaces:
Iterable<Node>
Direct Known Subclasses:
DPJoinTree, HJoinTree, IDJoinTree, LSJoinTree, SSJoinTree

public abstract class JoinTree
extends Object
implements Iterable<Node>

This is the head class for the various join tree implementations. Each join tree class is equivalent to an architecture of local computation.

Version:
$LastChangedRevision: 557 $
$LastChangedDate: 2008-03-26 14:23:32 +0100 (Mi, 26 Mrz 2008) $
Author:
Marc Pouly

Nested Class Summary
 class JoinTree.Construction
          Inner class wrapping all necessary data for the join tree construction process.
 
Field Summary
protected  Adapter adapter
           
protected  Node root
           
 
Constructor Summary
protected JoinTree(Knowledgebase kb, Collection<Domain> queries, Algorithm algo)
          Constructor:
 
Method Summary
 Valuation answer(Domain query)
          Method to answer a given query represented by a domain.
 void collect()
          Executes the collect propagation.
 boolean containsRemoteData()
           
 int countNodes()
           
abstract  Node createNode()
           
 void distribute(boolean... args)
          Executes the distribute propagation.
 Adapter getAdapter()
           
 Allocator getAllocator()
           
abstract  String getArchitecture()
           
 double getCollectTime()
           
 Algorithm getConstructionAlgorithm()
           
 JoinTree.Construction getConstructionData()
           
 double getDistributeTime()
           
 Domain getLargestDomain()
           
 Set<Uuid> getProcessorSet()
           
 double getPropagationTime()
           
 Collection<Domain> getQueries()
           
 Node getRoot()
           
 Domain getTreeDomain()
           
 boolean isBinary()
           
 boolean isCollected()
           
 boolean isDistributed()
           
 Iterator<Node> iterator()
          Join trees can iterate over their nodes.
 void makeBinary()
          Transforms this join tree to a binary join tree.
 void propagate(boolean... args)
          Executes collect & distribute propagation.
abstract  void scale()
          Performs the scaling operations for this architecture.
 void setRoot(Node node, boolean redirect)
          Changes the root node of this jointree.
 String toASCII(boolean content)
          Prints the jointree as ASCII string.
 String toString()
           
abstract  boolean verify(Class type)
          Verifies that the given knowledgebase can indeed be used with this architecture.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

root

protected Node root

adapter

protected Adapter adapter
Constructor Detail

JoinTree

protected JoinTree(Knowledgebase kb,
                   Collection<Domain> queries,
                   Algorithm algo)
            throws ConstrException
Constructor:

Parameters:
kb - The knowledgebase to build a jointree.
queries - The set of queries that must be covered by this join tree.
algo - The construction algorithm to build the tree.
Throws:
ConstrException
Method Detail

scale

public abstract void scale()
                    throws LCException
Performs the scaling operations for this architecture. This method is executed, if the valuations are of type Scalability.

Throws:
LCException - Exception thrown while executing the scaling operation.

getArchitecture

public abstract String getArchitecture()
Returns:
The join tree's architecture type.

verify

public abstract boolean verify(Class type)
Verifies that the given knowledgebase can indeed be used with this architecture.

Parameters:
type - The type of the locators that are contained in the knowledgebase.
Returns:
true, if the knowledgebase satifies the mathematical restrictions for this architecture.

createNode

public abstract Node createNode()
Returns:
Returns a new node instance corresponding to the architecture type of this jointree.

getQueries

public Collection<Domain> getQueries()
Returns:
The set of queries that were guarantueed to be covered.

propagate

public void propagate(boolean... args)
               throws LCException
Executes collect & distribute propagation.

Parameters:
args - args[0] = false averts scaling if the valuation algebra instance is of type Scalability.
Throws:
LCException - Exception thrown during join tree propagation.

collect

public void collect()
             throws LCException
Executes the collect propagation.

Throws:
LCException - Exception thrown during join tree propagation.

distribute

public void distribute(boolean... args)
                throws LCException
Executes the distribute propagation.

Parameters:
args - args[0] = false averts scaling if the valuation algebra instance is of type Scalability.
Throws:
LCException - Exception thrown when trying to execute distribute before collect has been terminated.

answer

public Valuation answer(Domain query)
                 throws LCException
Method to answer a given query represented by a domain. This method chooses non-deterministically a jointree node that covers the query given as argument and returns the content of this node.

Parameters:
query - The query to answer.
Returns:
The valuation of an (arbitrary) node in the tree with the query's domain.
Throws:
LCException - Exception caused from communication problems when dealing with remote valuations.

getCollectTime

public double getCollectTime()
Returns:
The time elapsed while executing collect. -1, if collect has not yet been executed.

getDistributeTime

public double getDistributeTime()
Returns:
The time elapsed while executing distribute. -1, if distribute has not yet been executed.

getPropagationTime

public double getPropagationTime()
Returns:
The time elapsed while executing collect and distribute. -1, if the propagation has not yet been executed.

getAdapter

public Adapter getAdapter()
Returns:
The adapter of this jointree.

getAllocator

public Allocator getAllocator()
Returns:
The processor allocation model. Returns null if either propagation has not yet been executed or join tree has been constructed from a local knowledgebase.

getConstructionAlgorithm

public Algorithm getConstructionAlgorithm()
Returns:
The construction algorithm having built this join tree.

getConstructionData

public JoinTree.Construction getConstructionData()
Returns:
The data that was used to construct this join tree. Implementation note: This method cannot be part of Algorithm, because those object must obviously be created beforehand.

getRoot

public Node getRoot()
Returns:
The root node of this join tree.

setRoot

public void setRoot(Node node,
                    boolean redirect)
             throws ConstrException
Changes the root node of this jointree.

Parameters:
node - The new root node.
redirect - Flag that indicates NENOK if the jointree needs to be redirected.
  • true, NENOK redirects the jointree edges to the new root node according to (Kohlas 2003).
  • false, the root node is changed but no redirection is performed.
Throws:
ConstrException - Exception thrown when new root is inappropriate. Attention: if the flag is set to false, the user needs to take the responsibility for the jointree's correctness. This functionality is provided for updating reasons (Schneuwly & Kohlas 2006).

iterator

public Iterator<Node> iterator()
Join trees can iterate over their nodes.

Specified by:
iterator in interface Iterable<Node>
Returns:
The jointree's node iterator.
See Also:
Iterable.iterator()

getLargestDomain

public Domain getLargestDomain()
Returns:
The largest domain in this join tree.

getTreeDomain

public Domain getTreeDomain()
Returns:
The union of all node domains within the tree.

countNodes

public int countNodes()
Returns:
Counts the number of nodes within the join tree.

getProcessorSet

public Set<Uuid> getProcessorSet()
Returns:
A set of all processors that are assigned to at least one node on this join tree.

toString

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

toASCII

public String toASCII(boolean content)
Prints the jointree as ASCII string.

Parameters:
content - true to print the content of each node.
Returns:
The current jointree as ASCII string.

isCollected

public boolean isCollected()
Returns:
true, if the collect algorithm has been executed.

isDistributed

public boolean isDistributed()
Returns:
true, if the distribute algorithm has been executed.

isBinary

public boolean isBinary()
Returns:
true, if this join tree is binary.

containsRemoteData

public boolean containsRemoteData()
Returns:
true, if this join tree has been created from a remote knowledgebase.

makeBinary

public void makeBinary()
Transforms this join tree to a binary join tree.