Class SimFinder

java.lang.Object
  |
  +--SimFinder

public class SimFinder
extends java.lang.Object

The SimFinder is the GA that we use to search for similarities in MusicGraphs. This is where all the loose ends come together.


Field Summary
 double crossoverrate
           
 java.util.Vector forbiddenSubgraphs
          A Vector of Subgraphs which we do not want to find again.
 double freshBloodChance
          The probability that a mutation of a similarity statement will result in a total replacement of one of its subgraphs.
 double groupBaseGamma
          A parameter for the grouping viewpoint.
 int initSubSize
          Initial size of random subgraphs.
 int maxSubSize
          The upper limit on the size of subgraphs inside similarity statements; if 0, there is no upper limit.
 double mutationrate
           
 MotherGraph piece
          The MotherGraph being search for similarities.
 int popsize
          The population size.
 int reportFrequency
          How many generations should pass in the GA before a new statusreport is printed on screen.
 SimilarityMeasure simMeasure
          The similarity measure used to evaluate similarity statements in the population.
 
Constructor Summary
SimFinder(int psize, java.lang.String fname, int isubsize, double co, double mut, int repFreq, SimilarityMeasure sm, Subgraph occ, int mxsubsize, double freshBlood)
          Constructs a Simfinder running on a MIDI file.
SimFinder(MotherGraph mother, int psize, int isubsize, double co, double mut, int repFreq, SimilarityMeasure sm, Subgraph occ, int mxsubsize, double freshBlood, double groupBase)
          Constructs a Simfinder from any MotherGraph.
 
Method Summary
 void appendVertexUseStatsToFile(java.lang.String filename)
           
 void checkPopulation(java.lang.String label)
          For debugging.
 StatusInfo collectStatusInfo(int gen)
          Returns a StatusInfo object describing this generation.
 int countIdSub(java.util.Vector pop)
          Returns the number of SimilarityStatements which have identical Subgraphs.
 void countUsageInfo()
          Sets the useCounter in each vertice.
 void crossover(java.util.Vector next)
          Adds a new SimilarityStatements to the population of the next generation.
 void deprecatedStatusInfo(int gen)
           
 int edgeCoverage()
          Computes how many edges in the mother piece that are included in a SimStmt in the population
 SimilarityStatement findBest()
          Returns the individual in the population with the best fitness.
static void main(java.lang.String[] args)
          Creates a SimFinder from a MIDI file, with some hardcoded parameters.
 void mutatePercentageOfPop(double percent)
          Mutates a percentage of the population.
 void mutation(java.util.Vector next)
          Picks a random individual in the population.
 int numberPickedByCrossover()
          Returns the number of individuals in the next generation to be found by crossover.
 int numberPickedByMutation()
          Returns the number of individuals in the next generation to be found by mutation.
 int numberPickedByTournament()
          Returns the number of individuals in the next generation to be found by tournament selection.
 boolean occurrenceSearch()
          Returns true if it is doing an occurrence search.
 void printMemStatus()
          Prints the memory status of the computer.
 void run(int generations, java.lang.String statusFilename)
          Runs the Simfinder for a number of generations.
 boolean seqPop()
          Returns true, if the population is sequential.
 void showBest()
          Opens two GraphWindow's showing the two subgraphs of the best SimilarityStatement.
 void showPopulation()
          Opens a GraphList's showing the subgraphs of the population.
 void sleep(long millisecs)
          Lets the thread sleep for millisecs milliseconds.
 void testPopulationIntegrity()
          for debugging
 SimilarityStatement tournament()
          Returns a clone of the most fit of two rendomly chosen SimilarityStatement.
 int vertexCoverage()
          Computes how many vertices in the mother piece that are included in a SimStmt in the population
 void writeHistoryToFile(java.lang.String statusFilename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

popsize

public int popsize
The population size.


piece

public MotherGraph piece
The MotherGraph being search for similarities.


initSubSize

public int initSubSize
Initial size of random subgraphs.


maxSubSize

public int maxSubSize
The upper limit on the size of subgraphs inside similarity statements; if 0, there is no upper limit.


crossoverrate

public double crossoverrate

mutationrate

public double mutationrate

freshBloodChance

public double freshBloodChance
The probability that a mutation of a similarity statement will result in a total replacement of one of its subgraphs.


reportFrequency

public int reportFrequency
How many generations should pass in the GA before a new statusreport is printed on screen.


simMeasure

public SimilarityMeasure simMeasure
The similarity measure used to evaluate similarity statements in the population.


forbiddenSubgraphs

public java.util.Vector forbiddenSubgraphs
A Vector of Subgraphs which we do not want to find again.


groupBaseGamma

public double groupBaseGamma
A parameter for the grouping viewpoint.

Constructor Detail

SimFinder

public SimFinder(int psize,
                 java.lang.String fname,
                 int isubsize,
                 double co,
                 double mut,
                 int repFreq,
                 SimilarityMeasure sm,
                 Subgraph occ,
                 int mxsubsize,
                 double freshBlood)
          throws java.lang.Exception
Constructs a Simfinder running on a MIDI file. Parameters are set for the GA. The MotherGraph is constructed from a MIDI file name.


SimFinder

public SimFinder(MotherGraph mother,
                 int psize,
                 int isubsize,
                 double co,
                 double mut,
                 int repFreq,
                 SimilarityMeasure sm,
                 Subgraph occ,
                 int mxsubsize,
                 double freshBlood,
                 double groupBase)
          throws java.lang.Exception
Constructs a Simfinder from any MotherGraph. Parameters are set for the GA.

Parameters:
mother - the MotherGraph.
psize - the GA-population size.
isubsize - the initial size of the subgraphs in the population.
co - the GA-crossover rate.
mut - the GA-mutation rate.
repFreq - the report frequency. Info is printed for every frequency generarions.
sm - the SimilarityMeasure to be used in this SimFinder.
occ - the graph to be found more occurrences of.
freshBlood - the GA-freshblood chance.
groupBase - the grouping structure value.
Throws:
java.lang.Exception - throws an exception if it is not able to make an initialisation of new SimStmts with the specified isubsize.
Method Detail

occurrenceSearch

public boolean occurrenceSearch()
Returns true if it is doing an occurrence search.


main

public static void main(java.lang.String[] args)
Creates a SimFinder from a MIDI file, with some hardcoded parameters.


seqPop

public boolean seqPop()
Returns true, if the population is sequential.


numberPickedByCrossover

public int numberPickedByCrossover()
Returns the number of individuals in the next generation to be found by crossover.


numberPickedByTournament

public int numberPickedByTournament()
Returns the number of individuals in the next generation to be found by tournament selection.


numberPickedByMutation

public int numberPickedByMutation()
Returns the number of individuals in the next generation to be found by mutation.


run

public void run(int generations,
                java.lang.String statusFilename)
         throws java.lang.Exception
Runs the Simfinder for a number of generations. Output is written to a file.

Parameters:
generations - the number of generations
statusFilename - the output file
Throws:
java.lang.Exception - if the SimFinder is not properly initialised (popSize is 0)

printMemStatus

public void printMemStatus()
Prints the memory status of the computer.


writeHistoryToFile

public void writeHistoryToFile(java.lang.String statusFilename)

findBest

public SimilarityStatement findBest()
Returns the individual in the population with the best fitness.


showBest

public void showBest()
Opens two GraphWindow's showing the two subgraphs of the best SimilarityStatement.


showPopulation

public void showPopulation()
Opens a GraphList's showing the subgraphs of the population.


collectStatusInfo

public StatusInfo collectStatusInfo(int gen)
Returns a StatusInfo object describing this generation.


deprecatedStatusInfo

public void deprecatedStatusInfo(int gen)

countIdSub

public int countIdSub(java.util.Vector pop)
Returns the number of SimilarityStatements which have identical Subgraphs.


crossover

public void crossover(java.util.Vector next)
Adds a new SimilarityStatements to the population of the next generation. Crossover is done by randomly selecting two SimilarityStatements in the population and then selecting randomly one Subgraph from each SimilarityStatement. The selected Subgraphs are put into a new SimilarityStatement which is added to the population in the next generation.


mutatePercentageOfPop

public void mutatePercentageOfPop(double percent)
Mutates a percentage of the population.


mutation

public void mutation(java.util.Vector next)
Picks a random individual in the population. Mutates it and adds it to the population for the next generation.


tournament

public SimilarityStatement tournament()
Returns a clone of the most fit of two rendomly chosen SimilarityStatement.


vertexCoverage

public int vertexCoverage()
Computes how many vertices in the mother piece that are included in a SimStmt in the population


edgeCoverage

public int edgeCoverage()
Computes how many edges in the mother piece that are included in a SimStmt in the population


countUsageInfo

public void countUsageInfo()
Sets the useCounter in each vertice. The useCounter tells how many Subgraphs of the SimilarityStatements in the population the vertice can be found in.


appendVertexUseStatsToFile

public void appendVertexUseStatsToFile(java.lang.String filename)

testPopulationIntegrity

public void testPopulationIntegrity()
for debugging


sleep

public void sleep(long millisecs)
Lets the thread sleep for millisecs milliseconds.


checkPopulation

public void checkPopulation(java.lang.String label)
For debugging.