bcds.phison.ra
Class RoutingAlgBase<V,E>

java.lang.Object
  extended by bcds.phison.ra.RoutingAlgBase<V,E>
Direct Known Subclasses:
BetweennessCentrality, DijkstraAll, FloydWarshall, LMIR, MaxFlowEK, Null, ProtectionAlgBase, SWP

public class RoutingAlgBase<V,E>
extends java.lang.Object

Provides default implementation of the methods defined in RoutingAlg as well as additional methods useful for routing algorithms.

Author:
Juan Segovia S.

Constructor Summary
RoutingAlgBase()
           
 
Method Summary
 Path<V,E> buildPathFromParentNodes(SimGraph<V,E> g, V dest, java.util.Map<V,V> parent)
          Builds a Path object from the "parent" structure produced by routing algorithms such as Dijkstra's.
 void commitBackupPath(ConnectionInfo<V,E> cnx)
          Does nothing.
 void commitWorkingPath(ConnectionInfo<V,E> cnx)
          Calls ted.updateResidualCap() to decrease the available capacity on the links included in cnx.wrk_path.
 void dumpState()
          Prints (to stdout) the environment, followed by the residual capacity and cost of each link, as reported by the TED object.
 Path<V,E> getBackupPath()
          Throws UnsupportedOperationException to indicate that protection is not implemented.
 double getCost(E e)
          Returns the cost of link e, which in this implementation is simply the cost registered in the TED's cost map.
 Environ getEnviron()
          Returns a reference to the environment object.
 java.lang.Object[] getEnvParams()
          Returns an zero-length, empty array, suitable for routing algorithms that do not need addtional environment parameters.
 java.lang.String getName()
          Returns the "short" class name (without any package name).
 TED<V,E> getTED()
          Returns a reference to the TED object.
 Path<V,E> getWorkingPath()
          Returns a reference to the object returned by the last call to run().
 boolean offersProtection()
          Returns false.
 void setBackupPath(Path<V,E> path)
          Sets the backup path.
 void setRequest(V src, V dest, int rq_cap)
          Saves for future use the source, destination and requested capacity.
 void setup(TED<V,E> ted, Environ env)
          Saves a copy of the reference to the TED object and to the environment object.
 void setWorkingPath(Path<V,E> path)
          Sets the working path.
 void topologyHasChanged()
          Does nothing.
 void uncommitBackupPath(ConnectionInfo<V,E> cnx)
          Does nothing.
 void uncommitWorkingPath(ConnectionInfo<V,E> cnx)
          Performs the opposite actions of commitWorkingPath(bcds.phison.ra.ConnectionInfo).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoutingAlgBase

public RoutingAlgBase()
Method Detail

setup

public void setup(TED<V,E> ted,
                  Environ env)
Saves a copy of the reference to the TED object and to the environment object.

If env is null, a new Environ is created. If env.getStr("args") is non-null, the key-value pairs in there are inserted into the environment, and the key "args" is finally removed (see Environ.fromArgsString(String) for a description of the key-values pairs format). If a given key already exists in env, it is left unchanged, that is, "args" does not override the keys in env.

Finally, getEnvParams() is called, either to insert any default parameter missing in the environment, or to check (and adapt if possible) each value's type.

Throws:
java.lang.IllegalArgumentException - if there is an uncorrectable type mismatch between the environment values and the default values.

offersProtection

public boolean offersProtection()
Returns false.


getCost

public double getCost(E e)
Returns the cost of link e, which in this implementation is simply the cost registered in the TED's cost map.


commitWorkingPath

public void commitWorkingPath(ConnectionInfo<V,E> cnx)
Calls ted.updateResidualCap() to decrease the available capacity on the links included in cnx.wrk_path.


uncommitWorkingPath

public void uncommitWorkingPath(ConnectionInfo<V,E> cnx)
Performs the opposite actions of commitWorkingPath(bcds.phison.ra.ConnectionInfo).


commitBackupPath

public void commitBackupPath(ConnectionInfo<V,E> cnx)
Does nothing.


uncommitBackupPath

public void uncommitBackupPath(ConnectionInfo<V,E> cnx)
Does nothing.


getTED

public TED<V,E> getTED()
Returns a reference to the TED object.


getEnviron

public Environ getEnviron()
Returns a reference to the environment object.


getName

public java.lang.String getName()
Returns the "short" class name (without any package name).


setRequest

public void setRequest(V src,
                       V dest,
                       int rq_cap)
Saves for future use the source, destination and requested capacity.


getWorkingPath

public Path<V,E> getWorkingPath()
Returns a reference to the object returned by the last call to run(). Note that it can be null.


getBackupPath

public Path<V,E> getBackupPath()
Throws UnsupportedOperationException to indicate that protection is not implemented.


setWorkingPath

public void setWorkingPath(Path<V,E> path)
Sets the working path. This exists so that derived classes that are not part of this package can establish the working path.


setBackupPath

public void setBackupPath(Path<V,E> path)
Sets the backup path. This exists so that derived classes that are not part of this package can establish the backup path.


buildPathFromParentNodes

public Path<V,E> buildPathFromParentNodes(SimGraph<V,E> g,
                                          V dest,
                                          java.util.Map<V,V> parent)
Builds a Path object from the "parent" structure produced by routing algorithms such as Dijkstra's. The path returned is from the current src (see setRequest(V, V, int)) up to the parameter dest. Further details on the "parent" map can be found in the class DijkstraAll.

Throws:
IllegalArtumentException - if the path includes loops or if it has "holes" that prevents reaching the source.

getEnvParams

public java.lang.Object[] getEnvParams()
Returns an zero-length, empty array, suitable for routing algorithms that do not need addtional environment parameters.


topologyHasChanged

public void topologyHasChanged()
Does nothing.


dumpState

public void dumpState()
Prints (to stdout) the environment, followed by the residual capacity and cost of each link, as reported by the TED object. Derived classes are expected to override/supplement this method.