gov.nist.antd.merlin.algorithm.wavelength.bestfit
Class BestFit

java.lang.Object
  |
  +--gov.nist.antd.merlin.algorithm.AlgorithmTemplate
        |
        +--gov.nist.antd.merlin.algorithm.wavelength.bestfit.BestFit
All Implemented Interfaces:
Algorithm, DMLDump

public class BestFit
extends AlgorithmTemplate

This class computes the channels of lambdas for an optical route, according to a best fit philosophy.

 This class was developed at the National Institute of Standards and
 Technology by employees of the Federal Government in the course of
 their official duties. Pursuant to title 17 Section 105 of the United
 States Code this software is not subject to copyright protection and
 is in the public domain.
 NIST assumes no responsibility whatsoever for its use by other parties,
 and makes no guarantees, expressed or implied, about its quality,
 reliability, or any other characteristic.
 
We would appreciate acknowledgement if the software is used.
NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.

Author:
borchert
, gallo , rouil

Field Summary
(package private)  double[] allBwVals
          an array of all possible bandwidth values for the current optical route.
(package private)  OpticalConnection currentRoute
          pointer to the oRoute associated w/ this path
(package private)  double maxGig
          the maximum bandwidth value present in the current oRoute
(package private)  double minGig
          the minimum bandwidth value present in the current oRoute
(package private)  ONIC[] onics
          array of onics in the optical path
(package private)  double reqGig
          desired bandwidth of the oPath
 
Fields inherited from class gov.nist.antd.merlin.algorithm.AlgorithmTemplate
 
Fields inherited from interface gov.nist.antd.optical.algorithm.Algorithm
ROUTING, RWA, UNKNOWN, WAVELENGTH
 
Constructor Summary
BestFit()
          Default constructor
 
Method Summary
private  boolean checkLam(Lambda lambda, double gig)
          utility function for findWavelength(), checks if the lambda can be included
private  void clear(java.util.LinkedList list)
          utility function to make the lambdas in the channels list available again.
 java.lang.Object[] execute(Glass net, OpticalConnection[] routes, java.lang.Object[] parameter)
          this function executes the algorithm
 java.util.Vector execute(Glass net, java.util.Vector routes, java.util.Vector parameter)
          this function executes the algorithm
 Lambda find(double gig, Fiber[] fibs, double waveLength)
          find a lamda w/ bandwidth in an array of outgoing fibers.
private  double[] findAllBw()
          utility function to return an array of all bandwidth values in the current optical Route
private  double findNearestBw(double currentGig, boolean includeBounds)
          utility function to find the bandwidth value closest to but less than the parameter value
private  double findNearestGreaterBw(double currentGig)
          utility function to find the bandwidth value > the parameter value closest to the parameter value
 int findWavelength(double gig, int index, Lambda[] channel, boolean atStart)
          (recursive)find a path through hosts where converter==false, where the bandwidth same as gig
 Lambda[] getChannel(double gig)
          get a channel from this opticalPath that has bandwidth gig.
private  ExtRouter getHost(ONIC o)
          utility fuction to get the host of an onic
 ONIC[] getOnics(java.util.Vector links)
          return an array of onics that contain all of the onics who are the source of the outgoing fibers in the vector of links that make up the oPath.
 byte getType()
          Retruns the type of wavelength.
(package private)  void makePath(OpticalPath path)
          this function, called from execute(), does the work of creating the channels for each optical route
static void print(java.lang.Object o)
          utility to make printing to System.out easier
static void println(java.lang.Object o)
          utility to make printing to System.out easier
 void recMake(java.util.LinkedList channels, double currentGig)
          recMake recursively populates a linked list with optical channels.
 java.lang.String toDML()
          This method generates the DML representation of this class.
 
Methods inherited from class gov.nist.antd.merlin.algorithm.AlgorithmTemplate
config, getName, isDebug, setDebug, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

onics

ONIC[] onics
array of onics in the optical path


reqGig

double reqGig
desired bandwidth of the oPath


allBwVals

double[] allBwVals
an array of all possible bandwidth values for the current optical route.


minGig

double minGig
the minimum bandwidth value present in the current oRoute


maxGig

double maxGig
the maximum bandwidth value present in the current oRoute


currentRoute

OpticalConnection currentRoute
pointer to the oRoute associated w/ this path

Constructor Detail

BestFit

public BestFit()
Default constructor

Method Detail

execute

public java.util.Vector execute(Glass net,
                                java.util.Vector routes,
                                java.util.Vector parameter)
                         throws AlgorithmException
this function executes the algorithm

Specified by:
execute in interface Algorithm
Specified by:
execute in class AlgorithmTemplate
Parameters:
net - The OpNet that contains the topology.
routes - The vector of potential routes.
parameter - The vector of objects containing the parameters for the algorithm
Returns:
the modified optical routes
Throws:
AlgorithmException

execute

public java.lang.Object[] execute(Glass net,
                                  OpticalConnection[] routes,
                                  java.lang.Object[] parameter)
                           throws AlgorithmException
this function executes the algorithm

Specified by:
execute in interface Algorithm
Overrides:
execute in class AlgorithmTemplate
Parameters:
net - The OpNet that contains the topology.
routes - The array of potential Optical Routes.
parameter - The array of objects containing the parameters for the algorithm
Returns:
the modified optical routes
Throws:
AlgorithmException

makePath

void makePath(OpticalPath path)
        throws AlgorithmException
this function, called from execute(), does the work of creating the channels for each optical route

Parameters:
path - the path associated w/ the route passed in from execute()
Throws:
AlgorithmException

getOnics

public ONIC[] getOnics(java.util.Vector links)
return an array of onics that contain all of the onics who are the source of the outgoing fibers in the vector of links that make up the oPath.

Parameters:
links - vector of links from opticalPath
Returns:
array of onics from these links

recMake

public void recMake(java.util.LinkedList channels,
                    double currentGig)
recMake recursively populates a linked list with optical channels.

Parameters:
channels - list where channels will be stored
currentGig - the current bandwidth to be searched for

clear

private void clear(java.util.LinkedList list)
utility function to make the lambdas in the channels list available again.

Parameters:
list - list of Lambda[], channels that can not be used.

findAllBw

private double[] findAllBw()
utility function to return an array of all bandwidth values in the current optical Route

Returns:
double[] array of all bandwidth values, sorted in ascending order

findNearestBw

private double findNearestBw(double currentGig,
                             boolean includeBounds)
utility function to find the bandwidth value closest to but less than the parameter value

Parameters:
currentGig - value to search for
includeBounds - true if you want a value equal to the currentGig, false if you want a value strictly less than currentGig.
Returns:
double less than or equal to currentGig

findNearestGreaterBw

private double findNearestGreaterBw(double currentGig)
utility function to find the bandwidth value > the parameter value closest to the parameter value

Parameters:
currentGig - value to search for
Returns:
double less than or equal to currentGig

getChannel

public Lambda[] getChannel(double gig)
get a channel from this opticalPath that has bandwidth gig.

Parameters:
gig - The requested bandwidth
Returns:
Lambda[] the lambdas in the channel, or null in no channel

find

public Lambda find(double gig,
                   Fiber[] fibs,
                   double waveLength)
find a lamda w/ bandwidth in an array of outgoing fibers.

Parameters:
gig - requested bandwidth
fibs - outgoing fibers to search
waveLength - The wavelength that will be a search criterion for a suitable lambda.
Returns:
Lambda lambda w/ bandwidth, or null if none exists.

findWavelength

public int findWavelength(double gig,
                          int index,
                          Lambda[] channel,
                          boolean atStart)
(recursive)find a path through hosts where converter==false, where the bandwidth same as gig

Parameters:
gig - requested bandwidth
index - current index in onics[]
channel - the current channel being constructed
atStart - true on first call, false otherwise
Returns:
int number of lambdas added to channel

checkLam

private boolean checkLam(Lambda lambda,
                         double gig)
utility function for findWavelength(), checks if the lambda can be included

Parameters:
lambda - The Lambda to be checked
gig - bandwidth that the lambda must be
Returns:
boolean true if l can be added, false otherwise

getHost

private ExtRouter getHost(ONIC o)
utility fuction to get the host of an onic

Parameters:
o - onic whose host is desired
Returns:
OCXEdgeRouter=the host of of onic o.

println

public static void println(java.lang.Object o)
utility to make printing to System.out easier

Parameters:
o - object to be printed

print

public static void print(java.lang.Object o)
utility to make printing to System.out easier

Parameters:
o - object to be printed

toDML

public java.lang.String toDML()
This method generates the DML representation of this class. Only return the options.

Specified by:
toDML in interface DMLDump
Overrides:
toDML in class AlgorithmTemplate
Returns:
The DML configuration as String

getType

public final byte getType()
Retruns the type of wavelength.

Specified by:
getType in interface Algorithm
Overrides:
getType in class AlgorithmTemplate
Returns:
Algorithm.WAVELENGTH.
Since:
1.1