Class Net

java.lang.Object
  |
  +--Net

public class Net
extends java.lang.Object

The Net class is in essence an n-dimensional array of Nodes.


Field Summary
 int cycleNum
          The number of cycles the algorithm has taken so far
 int dim
          The number of dimesions
 Node[] grid
          The actual array of Nodes
 int gridSize
          The number of cells (L^dim)
 float J
          The bond strength
 int L
          The side length of the Net
 int trueSize
          The number of cells including the virtual "+" and "-" cells (gridSize+2)
 
Constructor Summary
Net(java.io.File f, Wrapper didItFail)
          Creates a Net from a previously saved file
Net(int size, float sigma, int d)
          Creates a random Net
Net(int size, int d)
          Creates an empty Net
 
Method Summary
 void clearFlows()
          "Resets" the Net by clearing all flows so it may be solved multiple times sequentially
 java.lang.Object clone()
          Creates an independent copy of the Net.
 double findEnergy()
          Finds the energy (aka max-flow value) of the Net once it has been solved
 int[] getCoords(Node node)
          Returns the coordinates of a given Node
 Node getNode(int[] coords)
          Returns a node given an array of its coordinates
 ArrayHeap globalUpdate()
          For Heaps
 void globalUpdate(Deque S)
          For Stacks
 void globalUpdate(Queue Q)
          For Queues
 void globalUpdate(Queue Q, boolean b)
          For double-sided queues.
static void main(java.lang.String[] arg)
           
 void prStep(ArrayHeap H)
          For Heaps (uses gap)
 void prStep(ArrayHeap H, boolean gapFlag)
          For Heaps
 void prStep(Deque S)
          For Stacks
 void prStep(Queue Q)
          For Queues
 void prStep(Queue Q, boolean b)
          For double-sided queues
 void randNet(float cs)
          Changes the field strength of each Node in the Net by a small (or large) amount.
 void reTimes(float oldS, float newS)
          Gives a Net a new field strength by multilplying every Node's field strength b a conversion factor.
 void saveNet(java.io.File f)
          Writes the net to a file as the number of dimensions, followed by the side length, followed by the random field strengths, each on a new line
 void solve(int method, boolean gap, int updateFreq)
          The actual push-relabel algorithm
 java.lang.String toString()
          Not used in the actual applet, this method is included for use in debugging algorithmic changes.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

L

public int L
The side length of the Net


dim

public int dim
The number of dimesions


gridSize

public int gridSize
The number of cells (L^dim)


trueSize

public int trueSize
The number of cells including the virtual "+" and "-" cells (gridSize+2)


J

public float J
The bond strength


grid

public Node[] grid
The actual array of Nodes


cycleNum

public int cycleNum
The number of cycles the algorithm has taken so far

Constructor Detail

Net

public Net(java.io.File f,
           Wrapper didItFail)
Creates a Net from a previously saved file


Net

public Net(int size,
           float sigma,
           int d)
Creates a random Net

Parameters:
size - is the side length (L) of the Net
sigma - is the standard deviation of the Gaussian-distributed random field strengths
d - is the number of dimensions

Net

public Net(int size,
           int d)
Creates an empty Net

Parameters:
size - is the side length (L) of the Net
d - is the number of dimensions
Method Detail

randNet

public void randNet(float cs)
Changes the field strength of each Node in the Net by a small (or large) amount.

Parameters:
cs - is standard deviation of the Gaussian distribution governing the changes

clearFlows

public void clearFlows()
"Resets" the Net by clearing all flows so it may be solved multiple times sequentially


toString

public java.lang.String toString()
Not used in the actual applet, this method is included for use in debugging algorithmic changes. It shows the flow through every bond in a 2D Net, and a single face for a 3D.

Overrides:
toString in class java.lang.Object

solve

public void solve(int method,
                  boolean gap,
                  int updateFreq)
The actual push-relabel algorithm

Parameters:
method - the heuristic to use (heap, stack, queue, etc.)
gap - whether or not to use the gap (only meaningful if a heap-based heuristic is used)
updateFreq - the number of push-relabel cycles to elapse between global updates (-1 gives no global updates)

prStep

public void prStep(ArrayHeap H)
For Heaps (uses gap)


prStep

public void prStep(ArrayHeap H,
                   boolean gapFlag)
For Heaps

Parameters:
gapFlag - specifies whether the gap is to be used or not

globalUpdate

public ArrayHeap globalUpdate()
For Heaps


prStep

public void prStep(Deque S)
For Stacks


globalUpdate

public void globalUpdate(Deque S)
For Stacks


prStep

public void prStep(Queue Q)
For Queues


globalUpdate

public void globalUpdate(Queue Q)
For Queues


prStep

public void prStep(Queue Q,
                   boolean b)
For double-sided queues


globalUpdate

public void globalUpdate(Queue Q,
                         boolean b)
For double-sided queues. Note that this global update takes twice as long as the others, since the positive and negative excesses have different height fields.


reTimes

public void reTimes(float oldS,
                    float newS)
Gives a Net a new field strength by multilplying every Node's field strength b a conversion factor.


getNode

public Node getNode(int[] coords)
Returns a node given an array of its coordinates


getCoords

public int[] getCoords(Node node)
Returns the coordinates of a given Node


findEnergy

public double findEnergy()
Finds the energy (aka max-flow value) of the Net once it has been solved


clone

public java.lang.Object clone()
Creates an independent copy of the Net. Note that flows are *not* copied over, so this should only be used before any algorithm steps have occurred.

Overrides:
clone in class java.lang.Object

saveNet

public void saveNet(java.io.File f)
Writes the net to a file as the number of dimensions, followed by the side length, followed by the random field strengths, each on a new line


main

public static void main(java.lang.String[] arg)