at.dms.kjc.common
Class SimulatedAnnealing

java.lang.Object
  extended by at.dms.kjc.common.SimulatedAnnealing
Direct Known Subclasses:
AnnealedGreedyLayout, AnnealedLayout, NoSWPipeLayout

public abstract class SimulatedAnnealing
extends Object

This is a abstract class that any simulated annealing assignment algorithm can inherit and use.

Author:
mgordon

Field Summary
static int ANNEALITERATIONS
           
protected  HashMap assignment
          the assignment that we arrive at and use during execution
static int MAXTEMPITERATIONS
           
static int MINTEMPITERATIONS
           
static double TFACTR
           
 
Constructor Summary
protected SimulatedAnnealing()
           
 
Method Summary
 int getRandom(int max)
          Get the nex random number from [0, max).
abstract  void initialize()
          Perform any initialization that has to be done before simulated annealing.
abstract  void initialPlacement()
          The initial assignment, this must set up assignment so that is can be called by placemenCost() and perturbConfiguration(T);
protected abstract  boolean keepNewEqualMin()
          Decide if we should keep a configuration that has a cost that is EQUAL to the current minimum of the search.
abstract  double placementCost(boolean debug)
          The placement cost (energy) of the configuration.
 void printLayoutStats()
          Use this method to print stats for the layout...
abstract  void setAssignment(HashMap newAssign)
          Use this function to reassign the assignment to , update anything that needs to be updated on a new assignment.
protected  void setConstants(int minTempIts, int maxTempIts, int annealIts, double tFactor)
          Set the annealing constants.
 void simAnnealAssign(int iterations, int nover)
          Run the simulated annealing assignment.
abstract  void swapAssignment()
          Called by perturbConfiguration() to perturb the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINTEMPITERATIONS

public static int MINTEMPITERATIONS

MAXTEMPITERATIONS

public static int MAXTEMPITERATIONS

ANNEALITERATIONS

public static int ANNEALITERATIONS

TFACTR

public static double TFACTR

assignment

protected HashMap assignment
the assignment that we arrive at and use during execution

Constructor Detail

SimulatedAnnealing

protected SimulatedAnnealing()
Method Detail

printLayoutStats

public void printLayoutStats()
Use this method to print stats for the layout...


setAssignment

public abstract void setAssignment(HashMap newAssign)
Use this function to reassign the assignment to , update anything that needs to be updated on a new assignment.

Parameters:
newAssign -

swapAssignment

public abstract void swapAssignment()
Called by perturbConfiguration() to perturb the configuration. perturbConfiguration() decides if we should keep the new assignment.


initialPlacement

public abstract void initialPlacement()
The initial assignment, this must set up assignment so that is can be called by placemenCost() and perturbConfiguration(T);


placementCost

public abstract double placementCost(boolean debug)
The placement cost (energy) of the configuration.

Parameters:
debug - Might want to do some debugging...
Returns:
placement cost

initialize

public abstract void initialize()
Perform any initialization that has to be done before simulated annealing. This does not include the initial placement.


setConstants

protected final void setConstants(int minTempIts,
                                  int maxTempIts,
                                  int annealIts,
                                  double tFactor)
Set the annealing constants.

Parameters:
minTempIts -
maxTempIts -
annealIts -
tFactor -

simAnnealAssign

public final void simAnnealAssign(int iterations,
                                  int nover)
Run the simulated annealing assignment.

Parameters:
iterations - The number of simulated annealing iterations to run.
nover - The number of paths tried at an iteration (It was 100 before).

keepNewEqualMin

protected abstract boolean keepNewEqualMin()
Decide if we should keep a configuration that has a cost that is EQUAL to the current minimum of the search. By default, don't keep it. Override if you want other behavior.

Returns:
Should we set the min config to this config (they have the same cost).

getRandom

public int getRandom(int max)
Get the nex random number from [0, max).

Parameters:
max -
Returns:
next random int in range