Class EdgeCostHeuristic

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

public class EdgeCostHeuristic
extends AbstractCCAHeuristic
implements javax.swing.event.ChangeListener

This class implements an heuristic bases on edge costs for selecting operations to reduce a Yutsis object.

With every edge a cost is associated equal to the difference of the length of the two smallest cycles the edge is part of. The cost of a cycle is defined to be the minimum of the cost of the edges in the cycle. If two girth cycles have the same cost, the cycle for which the minimum cost is most reached is chosen. It this is also equal the cycle with lowest total edgecost is picked.

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

Constructor Summary
EdgeCostHeuristic()
          Default constructor: constructs a new CycleCountHeuristic object
EdgeCostHeuristic(Yutsis y)
          Constructs a new CycleCountHeuristic object and sets the problem.
EdgeCostHeuristic(Yutsis y, CycleGenerator cg)
          Constructs a new CycleCountHeuristic object and sets the problem.
 
Method Summary
 Cycle bestCycle(int[] bestcycleedge, int[] besticnodes, java.util.ArrayList candidates)
          This function returns the best Cycle to reduce and fills the best edge to interchange out of the cycle (min length 4).
 void printCycleCost(Cycle c, java.io.PrintStream out)
          Prints the given Cycle with the costs of his edges on the given PrintStream.
 void printCycleCosts()
          Prints all considered Cycle with the costs of their edges on System.out.
 void printCycleCosts(java.io.PrintStream out)
          Prints all considered Cycle with the costs of their edges on the given PrintStream.
 void setProblem(Yutsis y, CycleGenerator cg)
          Sets the Yutsis object defining for which operations must be choosen, together with the CycleGenerator delivering the relevant cycles.
 void stateChanged(javax.swing.event.ChangeEvent e)
          Implementation of the ChangeListener interface.
 
Methods inherited from class AbstractCCAHeuristic
bestCycle, bestCycle, canonicalIC, canonicalIC, cycleGenerator, interchangeNodes, problem, setProblem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EdgeCostHeuristic

public EdgeCostHeuristic()
Default constructor: constructs a new CycleCountHeuristic object


EdgeCostHeuristic

public EdgeCostHeuristic(Yutsis y)
Constructs a new CycleCountHeuristic object and sets the problem. This equivalent with calling the default constructor and setProblem afterwards.

Parameters:
y - the Yutsis object for which an operation has to be chosen
See Also:
Yutsis

EdgeCostHeuristic

public EdgeCostHeuristic(Yutsis y,
                         CycleGenerator cg)
Constructs a new CycleCountHeuristic object and sets the problem. This equivalent with calling the default constructor and setProblem afterwards.

Parameters:
y - the Yutsis object for which an operation has to be chosen
cg - the cycle generator containing the relevant cycles of y
See Also:
Yutsis, CycleGenerator
Method Detail

setProblem

public void setProblem(Yutsis y,
                       CycleGenerator cg)
Sets the Yutsis object defining for which operations must be choosen, together with the CycleGenerator delivering the relevant cycles.

Specified by:
setProblem in interface CCAHeuristic
Overrides:
setProblem in class AbstractCCAHeuristic
Parameters:
y - the Yutsis object for which an operation has to be chosen
cg - the cycle generator containing the relevant cycles of y
See Also:
Yutsis, CycleGenerator

bestCycle

public Cycle bestCycle(int[] bestcycleedge,
                       int[] besticnodes,
                       java.util.ArrayList candidates)
This function returns the best Cycle to reduce and fills the best edge to interchange out of the cycle (min length 4). It will use a CycleGenerator to generate all relevant cycles. Afterwards it calculates all edgecosts and searches for the smallest cycle with the edge with minimal cost. When there are multiple cycles of this kind the one with lowest cost is returned.

Specified by:
bestCycle in interface CCAHeuristic
Parameters:
bestcycleedge - array where the best edge to be interchanged out of the Cycle will be filled in
besticnodes - array where the best icnodes will be filled in
candidates - ArrayList which will be filled with equivalent operations, the first corresponds to the returned best Cycle.
Returns:
the best Cycle
See Also:
Cycle, CCAHeuristic

printCycleCosts

public void printCycleCosts()
Prints all considered Cycle with the costs of their edges on System.out.

See Also:
Cycle

printCycleCosts

public void printCycleCosts(java.io.PrintStream out)
Prints all considered Cycle with the costs of their edges on the given PrintStream.

Parameters:
out - the PrintStream to print to
See Also:
Cycle

printCycleCost

public void printCycleCost(Cycle c,
                           java.io.PrintStream out)
Prints the given Cycle with the costs of his edges on the given PrintStream.

Parameters:
c - the Cycle to printed
out - the PrintStream to print to
See Also:
Cycle

stateChanged

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

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