|
tauZaman v0.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--tauzaman.calendricsystem.granularitylattice.GranularityLattice
Nested Class Summary | |
private class |
GranularityLattice.LatticeEdge
LatticeEdge class is a private inner class to
GranularityLattice . |
private class |
GranularityLattice.LatticeNode
LatticeNode class is a private inner class to
GranularityLattice . |
private class |
GranularityLattice.SPElement
SPElement class is a private inner class to
GranularityLattice . |
Field Summary | |
private static int |
BLACK
Constant used in DFS part of induce mappings to indicate a node has been fully explored. |
private static boolean |
BUILDPATH_DEBUG
|
static boolean |
CACHE_DEBUG
|
private static int |
CACHE_SIZE
|
private static int |
COARSER
|
private tauzaman.calendricsystem.granularitylattice.cache.Cache |
coarserSpTableCache
Cache that maps particular granularities to an already computed table of shortest path information to coarser granularities. |
private static int |
CONGRUENT
|
private static int |
FINER
|
private tauzaman.calendricsystem.granularitylattice.cache.Cache |
finerSpTableCache
Cache that maps particular granularities to an already computed table of shortest path information to finer granularities. |
private static int |
GRAY
Constant used in DFS part of induce mappings to indicate a node is currently being explored. |
private static java.lang.Integer |
INFINITY
|
private tauzaman.calendricsystem.granularitylattice.cache.Cache |
mappingCache
Cache that maps a string representing the source granularity to the destination granularity ("sourceGranStr$destGranStr") to mapping paths. |
private java.util.ArrayList |
nodeList
List of all the nodes in the lattice. |
private java.util.HashMap |
nodeTable
This hashtable will contain a reference to all nodes in the granularity lattice by mapping Granularity -> LatticeNode. |
private static boolean |
SP_DEBUG
|
private static int |
SPACES
|
private static int |
WHITE
Constant used in DFS part of induce mappings to indicate a node has not yet been explored. |
Constructor Summary | |
GranularityLattice(Calendar[] calendars,
Mapping[] interCalMappings)
Constructs a GranularityLattice object. |
Method Summary | |
void |
addCalendar(Calendar calendar)
Adds an entire calendar to the lattice by going through each mapping in the calendar, adding any nodes that are not already in the lattice plus the edges connecting the nodes in each mapping. |
void |
addMapping(Mapping mapping)
Creates an edge between the "from" granularity and the "to" granularity in the Mapping object with the Mapping object
itself as the edge's label. |
private java.util.ArrayList |
buildMappingPath(java.util.HashMap spTable,
GranularityLattice.LatticeNode s,
GranularityLattice.LatticeNode v,
int typeOfEdges)
Given a particular predecessor list, builds a mapping path between two nodes. |
private void |
buildPathHelper(java.util.HashMap spTable,
GranularityLattice.LatticeNode s,
GranularityLattice.LatticeNode v,
java.util.ArrayList path)
Recursive helper method used to build the mapping path. |
Granule |
cast(Granule granule,
Granularity toGranularity)
Uses the lattice to cast the given granule from its granularity to another granularity. |
void |
clearCaches()
Resets all of the lattice's caches. |
private java.util.HashMap |
dijkstraShortestPaths(GranularityLattice.LatticeNode s,
int typeOfEdges)
Using Djikstra's algorithm, computes all shortest paths starting from a given lattice node. |
private java.util.ArrayList |
findPath(Granularity sourceGranularity,
Granularity destGranularity)
Finds a path (made up of Mapping objects) that can be used to
convert the given source granularity to the destination granularity.
|
private java.util.HashMap |
getSpTable(GranularityLattice.LatticeNode s,
int typeOfEdges)
Returns a table of shortest path information for the given node and type (i.e. coarser/finer). |
private tauzaman.calendricsystem.granularitylattice.minpriorityqueue.MinPriorityQueue |
getSuccessors(GranularityLattice.LatticeNode node,
int typeOfEdges)
Returns a minimum priority queue of nodes that are reachable by the given node through the given type of edges (i.e. coarser/finer). |
private void |
induceMappings()
Induces all regular mappings in the sets of coarser, finer and congruent edges in the lattice. |
private void |
induceMappings(int typeOfEdges)
Performs a DFS search on each node looking for regular mappings that can be induced. |
private void |
induceMappingsDFSVisit(GranularityLattice.LatticeNode sourceNode,
GranularityLattice.LatticeEdge sourceEdge,
GranularityLattice.LatticeNode curNode,
int typeOfEdges,
java.util.HashMap colorTable)
Recursive helper to the DFS part of the mapping induction. |
private void |
initializeSingleSource(GranularityLattice.LatticeNode s,
java.util.HashMap spTable)
Initializes the data structures used in Djiksta's algorithm. |
boolean |
isCoarser(Granularity g1,
Granularity g2)
Uses the lattice to determine if one granularity is coarser than another. |
boolean |
isEquivalent(Granularity g1,
Granularity g2)
Uses the lattice to determine if the two granularities are equivalent. |
boolean |
isFiner(Granularity g1,
Granularity g2)
Uses the lattice to determine if one granularity is finer than another. |
boolean |
isIncomparable(Granularity g1,
Granularity g2)
Uses the lattice to determine if the two granularities are equivalent. |
private void |
printSpTable(java.util.HashMap preds)
Helper method used to debug findPath by printing out predecessor lists. |
private void |
relax(GranularityLattice.LatticeNode u,
GranularityLattice.LatticeNode v,
int w,
java.util.HashMap spTable,
tauzaman.calendricsystem.granularitylattice.minpriorityqueue.MinPriorityQueue Q)
Tests whether or not we can improve the shortest path to v found so far by going through u, and, if so, updating the shortest path estimation table and the predecessor table. |
java.lang.String |
toString()
Returns a string representation of the lattice. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final int COARSER
private static final int FINER
private static final int CONGRUENT
private static final int SPACES
private static final int CACHE_SIZE
private static final boolean BUILDPATH_DEBUG
public static boolean CACHE_DEBUG
private static final boolean SP_DEBUG
private java.util.HashMap nodeTable
private tauzaman.calendricsystem.granularitylattice.cache.Cache finerSpTableCache
private tauzaman.calendricsystem.granularitylattice.cache.Cache coarserSpTableCache
private tauzaman.calendricsystem.granularitylattice.cache.Cache mappingCache
private java.util.ArrayList nodeList
private static final int WHITE
private static final int GRAY
private static final int BLACK
private static final java.lang.Integer INFINITY
Constructor Detail |
public GranularityLattice(Calendar[] calendars, Mapping[] interCalMappings) throws CalendricSystemFormationException
GranularityLattice
object. The construction is
done by:
(1) For each calendar in calendars, get the calendar's mappings and set
up LatticeNodes
for each granularity encountered and
connecting the nodes with the mappings themselves.
(2) Connecting the granularities in different calendars using the
mappings in the inter-calendar mappings array.
calendars
- the array of all Calendar objects that are
in this calendric system
CalendricSystemFormationException
- if any error occurs while
forming GranularityLattice
Method Detail |
public void addCalendar(Calendar calendar) throws CalendricSystemFormationException
calendar
- Calendar
to be added to the lattice
CalendricSystemFormationException
public void addMapping(Mapping mapping) throws CalendricSystemFormationException
Mapping
object with the Mapping
object
itself as the edge's label.
mapping
- Mapping
that is the edge's label
NoSuchGranularityException
- if either of the Granularities in the
mapping are not recognized by the lattice (i.e., there is no node
in the lattice that has this granularity)
CalendricSystemFormationException
public Granule cast(Granule granule, Granularity toGranularity) throws CalendricSystemServiceException
granule
- the granule to cast from its granularity to
another granularitytoGranularity
- the granularity to which to cast the given
granule
CalendricSystemServiceException
- if either the Granularity of the
given granule or the toGranularity are not recognized by the
lattice (i.e., there is no node in the lattice that has this
granularity)private java.util.ArrayList findPath(Granularity sourceGranularity, Granularity destGranularity) throws CalendricSystemServiceException
Mapping
objects) that can be used to
convert the given source granularity to the destination granularity.
This method works by first finding all shortest paths between the source
granularity and all other granularities. If after this step, a path
has been found from the source granularity to the destination
granularity, the mapping path is built and returned. However, if no
shortest path has been found, all shortest paths between the destination
granularity and all other granularities is found. With these two lists
of shortest paths, the greatest common granularity from which both the
source and destination granularities can be reached is found and a
V-path is built.
sourceGranularity
- the starting granularitydestGranularity
- the destination granularity
CalendricSystemServiceException
- if either the Granularity of the
given granule or the destGranularity are not recognized by the
lattice (i.e., there is no node in the lattice that has this
granularity)private java.util.HashMap getSpTable(GranularityLattice.LatticeNode s, int typeOfEdges)
s
- the node for which to get shortest path informationtypeOfEdges
- the type of edges (FINER/COARSER/CONGRUENT) to use to
get the shortest path information
private tauzaman.calendricsystem.granularitylattice.minpriorityqueue.MinPriorityQueue getSuccessors(GranularityLattice.LatticeNode node, int typeOfEdges)
node
- the node for which to get successor informationtypeOfEdges
- the type of edges (FINER/COARSER/CONGRUENT) to use to
get the successor information
private void printSpTable(java.util.HashMap preds)
preds
- the hash of predecessors for a particular granularitypublic boolean isCoarser(Granularity g1, Granularity g2) throws CalendricSystemServiceException
g1
- the first granule to be comparedg2
- the second granule to be compared
true
if g1 is coarser than g2, false
if
g1 is finer than g2 or if g1 and g2 cannot be compared
NoSuchGranularityException
- if either of the granularities passed
in are not recognized by the lattice (i.e., there is no node in
the lattice that has this granularity)
CalendricSystemServiceException
public boolean isEquivalent(Granularity g1, Granularity g2) throws CalendricSystemServiceException
g1
- the first granule to be compared for equivalenceg2
- the second granule to be compared for equivalence
true
if g1 is equivalent to g2, false
if g1 is not equivalent to g2
NoSuchGranularityException
- if either of the granularities passed
in are not recognized by the lattice (i.e., there is no node in
the lattice that has this granularity)
CalendricSystemServiceException
public boolean isIncomparable(Granularity g1, Granularity g2) throws CalendricSystemServiceException
g1
- the first granule to be compared for equivalenceg2
- the second granule to be compared for equivalence
true
if g1 is equivalent to g2, false
if g1 is not equivalent to g2
NoSuchGranularityException
- if either of the granularities passed
in are not recognized by the lattice (i.e., there is no node in
the lattice that has this granularity)
CalendricSystemServiceException
public boolean isFiner(Granularity g1, Granularity g2) throws CalendricSystemServiceException
g1
- the first granule to be comparedg2
- the second granule to be compared
true
if g1 is finer than g2, false
if
g1 is coarser than g2 or if g1 and g2 cannot be compared
NoSuchGranularityException
- if either of the granularities passed
in are not recognized by the lattice (i.e., there is no node in
the lattice that has this granularity)
CalendricSystemServiceException
public void clearCaches()
public java.lang.String toString()
toString
in class java.lang.Object
private void induceMappings()
private void induceMappings(int typeOfEdges)
typeOfEdges
- the type of edges (FINER/COARSER/CONGRUENT) from
which the regular mappings should be inducedprivate void induceMappingsDFSVisit(GranularityLattice.LatticeNode sourceNode, GranularityLattice.LatticeEdge sourceEdge, GranularityLattice.LatticeNode curNode, int typeOfEdges, java.util.HashMap colorTable)
typeOfEdges
- the relationship we want to do the sort on (FINER/
COARSER/CONGRUENT)private java.util.HashMap dijkstraShortestPaths(GranularityLattice.LatticeNode s, int typeOfEdges)
s
- the node from which we want all shortest paths in the
latticetypeOfEdges
- the relationship from which we want to find the
shortest path on (FINER/COARSER/CONGRUENT)
private void initializeSingleSource(GranularityLattice.LatticeNode s, java.util.HashMap spTable)
s
- the node from which we want all shortest
paths in the latticespTable
- the table that maps [node --> sp est,
predecessor in shortest path to source]private void relax(GranularityLattice.LatticeNode u, GranularityLattice.LatticeNode v, int w, java.util.HashMap spTable, tauzaman.calendricsystem.granularitylattice.minpriorityqueue.MinPriorityQueue Q)
u
- the new node that we can now use to get a
shortest pathv
- the destination node of relaxation processw
- the weight of the edge between u and vspTable
- the table that maps [node --> sp est,
predecessor in shortest path to source]Q
- the minimum priority queue that is used in
Djiksta's algorithm - needed in this method
to decrease priority of v if path is improvedprivate java.util.ArrayList buildMappingPath(java.util.HashMap spTable, GranularityLattice.LatticeNode s, GranularityLattice.LatticeNode v, int typeOfEdges)
spTable
- the predecessor list composing ests. & shortest pathss
- the source nodev
- the destination nodetypeOfEdges
- the relationship from which we want to build the path
(FINER/COARSER/CONGRUENT)
private void buildPathHelper(java.util.HashMap spTable, GranularityLattice.LatticeNode s, GranularityLattice.LatticeNode v, java.util.ArrayList path)
spTable
- the predecessor list composing ests. & shortest pathss
- the source nodev
- the destination nodepath
- the path being built
|
tauZaman v0.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |