Class CycleCostAlgorithm

java.lang.Object
  |
  +--CycleCostAlgorithm
All Implemented Interfaces:
javax.swing.event.ChangeListener, java.util.EventListener

public class CycleCostAlgorithm
extends java.lang.Object
implements javax.swing.event.ChangeListener

This class represents an improved algorithm to be used in collaboration with an heuristic on the algorithm using graphical methods by Yutsis, Vanagas et. al for the calculation of general recoupling coefficients of angular momenta. When constructing an CycleCostAlgorithm object an heuristic by means of an object implementing the CCAHeuristic interface has to be delivered.

This algorithm will reduce the graph in the following way: when there are bubbles present they are removed, otherwise when there are triangles present they are removed. When there are no bubbles nor triangles present, the heuristic will decide which interchange will be applied.

Author:
Dries.VanDyck@rug.ac.be
See Also:
Yutsis, CCAHeuristic

Constructor Summary
CycleCostAlgorithm(Yutsis y, CCAHeuristic h)
          Constructs a new CycleCostAlgorithm object for the Yutsis y with heuristic h.
 
Method Summary
 CCAHeuristic heuristic()
          Returns the used CCAHeuristic object.
protected  void log(java.lang.String tolog)
          Write the String to the logstream.
static void main(java.lang.String[] args)
          This program reduces a Yutsis Graph to a so called triangular delta in as few operations possible, while constructing the general recoupling coefficient associated with it, which is written to the screen.
 int nrOfInterchanges()
          Returns the number of interchanges performed so far to reduce the Yutsis object.
static void outputResults(Yutsis y, CycleCostAlgorithm cca)
          Outputs the results of the reduction process; if the Yutsis object is a instance of YutsisGraph, the generated summation formula, an instance of GenRecoupCoeff, is printed to System.out.
static void outputResults(Yutsis y, CycleCostAlgorithm cca, GRVisitor grv)
          Outputs the results of the reduction process; if the Yutsis object is a instance of YutsisGraph, the generated summation formula, an instance of GenRecoupCoeff, is printed to the given PrintStream in the format delivered by the GRVisitor.
static void outputResults(Yutsis y, CycleCostAlgorithm cca, GRVisitor grv, java.io.PrintStream out)
          Outputs the results of the reduction process; if the Yutsis object is a instance of YutsisGraph, the generated summation formula, an instance of GenRecoupCoeff, is printed to the given PrintStream in the format delivered by the GRVisitor.
 void performOperation()
          Searches for the best operation to reduce the Yutsis object and performs it.
 Yutsis problem()
          Returns the Yutsis object defining the problem.
 void reduce()
          Reduces the Yutsis object to a so called triangular delta by repeatedly calling performOperation.
static CycleCostAlgorithm reduceYutsisGraph(Yutsis y, CCAHeuristic h, java.io.PrintStream ruleslogstream, java.lang.String gmlbasename)
          This function calls performOperation until the given Yutsis object is equal to a triangular delta and returns the used CycleCostAlgorithm object.
 void setGmlOutputBasename(java.lang.String gmlbasename)
          Sets the basename of the file(s) where the graphs will be written after each reductionstep in gml-format (graphlet).
 void setHeuristic(CCAHeuristic h)
          Sets the CCAHeuristic, used to select an operation when no bubbles or triangles are present.
 void setLogStream(java.io.PrintStream logstream)
          Sets the PrintStream to which all operation which alter the graph will be logged.
 void stateChanged(javax.swing.event.ChangeEvent e)
          Implementation of the ChangeListener interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CycleCostAlgorithm

public CycleCostAlgorithm(Yutsis y,
                          CCAHeuristic h)
Constructs a new CycleCostAlgorithm object for the Yutsis y with heuristic h.

Parameters:
y - the Yutsis object defining the problem
h - the heuristic to be used when no bubbles or triangles are present
See Also:
Yutsis, CCAHeuristic
Method Detail

nrOfInterchanges

public int nrOfInterchanges()
Returns the number of interchanges performed so far to reduce the Yutsis object.

Returns:
the number of interchanges performed so far to reduce the Yutsis object.
See Also:
Yutsis

performOperation

public void performOperation()
Searches for the best operation to reduce the Yutsis object and performs it. If there is a bubble or triangle in the graph it will remove the bubble or triangle. Otherwise it will use the delivered CCAHeuristic object to select an operation.

See Also:
CCAHeuristic

problem

public Yutsis problem()
Returns the Yutsis object defining the problem.

Returns:
the Yutsis object defining the problem.
See Also:
Yutsis

heuristic

public CCAHeuristic heuristic()
Returns the used CCAHeuristic object.

Returns:
the used CCAHeuristic object.
See Also:
CCAHeuristic

setHeuristic

public void setHeuristic(CCAHeuristic h)
Sets the CCAHeuristic, used to select an operation when no bubbles or triangles are present.

Parameters:
h - the CCAHeuristic object to be used.

log

protected void log(java.lang.String tolog)
Write the String to the logstream.

Parameters:
tolog - the String to be logged

setLogStream

public void setLogStream(java.io.PrintStream logstream)
Sets the PrintStream to which all operation which alter the graph will be logged. Default logstream is System.err. When no logging is desired, set it to be null.

Parameters:
logstream - The PrintStream where logging will be done

reduce

public void reduce()
Reduces the Yutsis object to a so called triangular delta by repeatedly calling performOperation.

See Also:
#performOperation., Yutsis

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Implementation of the ChangeListener interface.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

setGmlOutputBasename

public void setGmlOutputBasename(java.lang.String gmlbasename)
Sets the basename of the file(s) where the graphs will be written after each reductionstep in gml-format (graphlet). The graph after step i will be in the file
"gmlbasename.i.gml".

Parameters:
gmlbasename - the basename of the files to which gml-output will be written after each step.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
This program reduces a Yutsis Graph to a so called triangular delta in as few operations possible, while constructing the general recoupling coefficient associated with it, which is written to the screen.

java.io.IOException

reduceYutsisGraph

public static CycleCostAlgorithm reduceYutsisGraph(Yutsis y,
                                                   CCAHeuristic h,
                                                   java.io.PrintStream ruleslogstream,
                                                   java.lang.String gmlbasename)
This function calls performOperation until the given Yutsis object is equal to a triangular delta and returns the used CycleCostAlgorithm object.

Parameters:
y - the Yutsis to be reduced
h - the heuristic to be used as a CCAHeuristic object
ruleslogstream - the stream to where the applied rules have to be logged
gmlbasename - the basename of the files to which the graphs will be written in gml-format (graphlet) after each step or null for no gml output.
Returns:
the used CycleCostAlgorithm object.
See Also:
performOperation(), Yutsis, CCAHeuristic

outputResults

public static void outputResults(Yutsis y,
                                 CycleCostAlgorithm cca)
Outputs the results of the reduction process; if the Yutsis object is a instance of YutsisGraph, the generated summation formula, an instance of GenRecoupCoeff, is printed to System.out.

Parameters:
y - the Yutsis object for which the results will be printed.
cca - the CycleCostAlgorithm object used to reduce y.
See Also:
Yutsis, YutsisGraph, GenRecoupCoeff

outputResults

public static void outputResults(Yutsis y,
                                 CycleCostAlgorithm cca,
                                 GRVisitor grv)
Outputs the results of the reduction process; if the Yutsis object is a instance of YutsisGraph, the generated summation formula, an instance of GenRecoupCoeff, is printed to the given PrintStream in the format delivered by the GRVisitor.

Parameters:
y - the Yutsis object for which the results will be printed.
cca - the CycleCostAlgorithm object used to reduce y.
grv - the GRVisitor visiting the GenRecoupCoeff
See Also:
Yutsis, YutsisGraph, GRVisitor, GenRecoupCoeff

outputResults

public static void outputResults(Yutsis y,
                                 CycleCostAlgorithm cca,
                                 GRVisitor grv,
                                 java.io.PrintStream out)
Outputs the results of the reduction process; if the Yutsis object is a instance of YutsisGraph, the generated summation formula, an instance of GenRecoupCoeff, is printed to the given PrintStream in the format delivered by the GRVisitor.

Parameters:
y - the Yutsis object for which the results will be printed.
cca - the CycleCostAlgorithm object used to reduce y.
grv - the GRVisitor visiting the GenRecoupCoeff
out - the PrintStream to which the output will be printed.
See Also:
Yutsis, YutsisGraph, GRVisitor, GenRecoupCoeff