net.sf.myra.antree
Class Graph

java.lang.Object
  extended by net.sf.myra.antree.Graph
Direct Known Subclasses:
MaxMinGraph

public class Graph
extends java.lang.Object

Version:
$Revision: 2344 $ $Date:: 2011-08-29 12:46:17#$
Author:
Fernando Esteban Barril Otero

Nested Class Summary
static class Graph.Entry
          This class is used as the key of an entry in the pheromone matrix.
static class Graph.Vertex
          Struct-like class that represents a vertex of the construction graph.
 
Field Summary
protected  java.util.Map<java.lang.Integer,Graph.Entry> cache
          The cache for Entry objects [encoding,entry].
protected  Heuristic heuristic
          The heuristic information.
protected  java.util.Map<java.lang.String,java.lang.Integer> mapping
          The mapping of attribute indexes.
protected  double[][] matrix
          The (dynamic) pheromone matrix.
protected  double[] template
          Template pheromone array.
protected  net.sf.myra.datamining.data.Attribute[] vertices
          The attribute array representing the vertices.
 
Constructor Summary
Graph(net.sf.myra.datamining.data.Metadata metadata, Heuristic heuristic)
          Creates a new Graph instance.
 
Method Summary
 void evaporate()
          Evaporates the pheromone values of each branch by normalising the values.
protected  Graph.Entry getEntry(Branch branch)
          Returns a correspondent Entry object for the specified branch.
 java.util.Collection<Graph.Vertex> getVertices(Branch branch)
          Returns the collection of vertices for the specified branch.
 java.util.Collection<Graph.Vertex> getVertices(Branch branch, java.util.Collection<net.sf.myra.datamining.data.Attribute> used)
          Returns the collection of vertices for the specified branch.
 java.lang.String stats()
           
 void update(Tree tree)
          Updates the pheromone values of the branches used in the specified tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matrix

protected double[][] matrix
The (dynamic) pheromone matrix.


cache

protected java.util.Map<java.lang.Integer,Graph.Entry> cache
The cache for Entry objects [encoding,entry].


vertices

protected net.sf.myra.datamining.data.Attribute[] vertices
The attribute array representing the vertices.


mapping

protected java.util.Map<java.lang.String,java.lang.Integer> mapping
The mapping of attribute indexes.


template

protected double[] template
Template pheromone array. This array is used for new entries on the pheromone matrix.


heuristic

protected Heuristic heuristic
The heuristic information.

Constructor Detail

Graph

public Graph(net.sf.myra.datamining.data.Metadata metadata,
             Heuristic heuristic)
Creates a new Graph instance.

Parameters:
metadata - the current dataset's metadata.
heuristic - the heuristic information.
Method Detail

getVertices

public java.util.Collection<Graph.Vertex> getVertices(Branch branch)
Returns the collection of vertices for the specified branch. If the branch is null, it returns the collection of vertices at the start of the graph.

Parameters:
branch - the current branch being followed.
Returns:
the collection of vertices for the specified branch.

getVertices

public java.util.Collection<Graph.Vertex> getVertices(Branch branch,
                                                      java.util.Collection<net.sf.myra.datamining.data.Attribute> used)
Returns the collection of vertices for the specified branch. If the branch is null, it returns the collection of vertices at the start of the graph.

Parameters:
branch - the current branch being followed.
used - the list of used attributes, which cannot be reused.
Returns:
the collection of vertices for the specified branch.

update

public void update(Tree tree)
Updates the pheromone values of the branches used in the specified tree. Note: This method is not thread-safe.

Parameters:
tree - the tree used to update the pheromone values.

evaporate

public void evaporate()
Evaporates the pheromone values of each branch by normalising the values. Therefore, the values that have not been updated are decreased.


getEntry

protected Graph.Entry getEntry(Branch branch)
Returns a correspondent Entry object for the specified branch. Note: This implementation is not thread-safe.

Parameters:
branch - the branch to return the entry.
Returns:
a correspondent Entry object for the specified branch.

stats

public java.lang.String stats()


Copyright © 2013. All Rights Reserved.