classifierLibrary
Class ClassifierSystem

java.lang.Object
  extended byclassifierLibrary.ClassifierSystem
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
ZLCS

public class ClassifierSystem
extends java.lang.Object
implements java.lang.Cloneable

Library classifierLibrary, Class ClassifierSystem

Copyright by Klaus Hufschlag 2004,2005,2006

This file is part of the Generic Classifier Library. The Generic Classifier Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The Generic Classifier Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the Generic Classifier Library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Version:
1.4
Author:
Klaus Hufschlag

Constructor Summary
ClassifierSystem()
          Constructor
ClassifierSystem(java.lang.String name, Classifier sample, int size, boolean randomized)
          Enhanced Constructor, initializing the CS following given parameters.
 
Method Summary
 void add(Classifier cl)
          Adds a Classifier to the instances' internal ruleset.
 void add(ClassifierSystem cs)
          Adds all Classifiers of another instance to the instances' internal ruleset.
 java.lang.Object clone()
          Clone-method creates a duplicate of the cs.
 ClassifierSystem crossover()
          Creates a clone of the instance and fills clone with pairwise crossover (at random positions) of all classfiers.
 ClassifierSystem csSelection(double thresh, boolean minimize, java.lang.String which)
          Creates a new LCS with a selection of classifiers, having a criterion-value above (or below, if minimize is true) a given threshold.
 void debug_out()
          Method for debugging purposes.
 ClassifierSystem filterbyaction(Situation action)
          Returns a subset of the CS with all rules that match a given action with their action part.
 ClassifierSystem filterbyaction(Situation action, boolean subsumptive)
          Returns a subset of the CS with all rules that match a given action with their action part.
 ClassifierSystem filterByCondition(Situation condition)
          Returns a subset of the CS with all rules that match a given condition with their action part.
 ClassifierSystem filterByCondition(Situation condition, boolean subsumtive)
          Returns a subset of the CS with all rules that match a given condition with their action part.
 double getAverage(java.lang.String which)
          Calculates the average of a given functional method called for all classifiers in the CS.
 Classifier getClassifier(int index)
          Returns a classifier at a given position
 double[] getExtremeValues(java.lang.String which)
          Returns an array with minimum and maximum numerical value a given functional method (of the classifiers) reaches in the CS
 java.lang.String getName()
          Returning the name of the instance.
 Classifier getSample()
          Returns the sample classifier defined for the instance.
 double getTotal(java.lang.String which)
          Calculates the total of a given functional method called for all classifiers in the CS.
 void init(Classifier sample, long size, boolean randomized)
          CS is initialized with a given number of classifiers following a sample (by cloning the sample).
 java.util.Iterator iterator()
          (Delegate)-Function returns an iterator to the set of classifiers.
 ClassifierSystem mutation(double probability)
          Creates a clone of the instance and fills it with mutations of all classfiers, handing over a given probability for mutation.
 ClassifierSystem randomSubset(long size)
          Returns a subset of the CS of a given size.
 void remove()
          Removes all classifiers.
 void remove(Classifier cl)
          Function removes a given Classifier from CS.
 void remove(ClassifierSystem cs)
          Removes (subtracts) all classifiers contained in a given CS from this instance.
 Classifier RoulettewheelChoice(java.lang.String which, boolean invert)
          Returns roulettewheel-choice, using a given method of the classifiers for determining probability/weight.
 void setName(java.lang.String name)
          Used for setting the name of the instance.
 int size()
          Returns the number of Classifiers contained.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassifierSystem

public ClassifierSystem()
Constructor


ClassifierSystem

public ClassifierSystem(java.lang.String name,
                        Classifier sample,
                        int size,
                        boolean randomized)
Enhanced Constructor, initializing the CS following given parameters.

Parameters:
name - Name of the CS
sample - Sample-classifier, CS will be filled with clones of the sample.
size - Number of classifiers
randomized - Classifiers are randomized if parameter is set to true.
See Also:
init()
Method Detail

init

public void init(Classifier sample,
                 long size,
                 boolean randomized)
CS is initialized with a given number of classifiers following a sample (by cloning the sample). If randomized-parameter is true, the randomization-method of the clones is called, therefore the LCS-set then will be random.

Parameters:
sample - Sample-classifier, CS will be filled with clones of the sample.
size - Number of classifiers
randomized - Classifiers are randomized if parameter is set to true.

clone

public java.lang.Object clone()
Clone-method creates a duplicate of the cs. ATTENTION: Classifiers themselves are not cloned, only the references to them!

See Also:
java.lang.Object#clone()

setName

public void setName(java.lang.String name)
Used for setting the name of the instance.

Parameters:
name - Name to be set

getName

public java.lang.String getName()
Returning the name of the instance.

Returns:
Name of CS

getSample

public Classifier getSample()
Returns the sample classifier defined for the instance.

Returns:
Sample-Classifier

size

public int size()
Returns the number of Classifiers contained.

Returns:
Number of Classifiers

add

public void add(Classifier cl)
         throws SimLibraryError
Adds a Classifier to the instances' internal ruleset.

Parameters:
cl - Classifier to be added
Throws:
SimLibraryError

iterator

public java.util.Iterator iterator()
(Delegate)-Function returns an iterator to the set of classifiers.

Returns:
Iterator über alle Classifer des CS
See Also:
AbstractList.iterator()

add

public void add(ClassifierSystem cs)
Adds all Classifiers of another instance to the instances' internal ruleset.

Parameters:
cs - CS whose classifiers are to be added to the CS

getClassifier

public Classifier getClassifier(int index)
Returns a classifier at a given position

Parameters:
index - Position
Returns:
Classifier at given position

remove

public void remove(Classifier cl)
Function removes a given Classifier from CS.

Parameters:
cl - Classifier der entfernt werden soll.

remove

public void remove()
Removes all classifiers.


remove

public void remove(ClassifierSystem cs)
Removes (subtracts) all classifiers contained in a given CS from this instance.

Parameters:
cs - CS, whose classifiers are to be removed from the CS.

debug_out

public void debug_out()
Method for debugging purposes.


mutation

public ClassifierSystem mutation(double probability)
Creates a clone of the instance and fills it with mutations of all classfiers, handing over a given probability for mutation.

Parameters:
probability - Probability for mutation
Returns:
new CS with mutated classifiers

crossover

public ClassifierSystem crossover()
Creates a clone of the instance and fills clone with pairwise crossover (at random positions) of all classfiers.

Returns:
neues CS mit paarweise gekreuzten Classifiern

csSelection

public ClassifierSystem csSelection(double thresh,
                                    boolean minimize,
                                    java.lang.String which)
Creates a new LCS with a selection of classifiers, having a criterion-value above (or below, if minimize is true) a given threshold. The criterion value should be returned by the function, whose name is defined in parameter 'which'.

Parameters:
thresh - Threshold value
minimize - If true, values must be below or equal thresh, otherwise above or equal.
which - Name of a functional method of the classifiers returning a numeric value as criterion for selection.
Returns:
new CS with classifiers following the criteria for selection

getExtremeValues

public double[] getExtremeValues(java.lang.String which)
Returns an array with minimum and maximum numerical value a given functional method (of the classifiers) reaches in the CS

Parameters:
which - Name of a classifier's method returning a numerical value
Returns:
Array like {min,max}

getTotal

public double getTotal(java.lang.String which)
Calculates the total of a given functional method called for all classifiers in the CS.

Parameters:
which - Name of a functional method that returns a numerical value
Returns:
Total of returned values

getAverage

public double getAverage(java.lang.String which)
Calculates the average of a given functional method called for all classifiers in the CS.

Parameters:
which - Name of a functional method that returns a numerical value
Returns:
Average value

RoulettewheelChoice

public Classifier RoulettewheelChoice(java.lang.String which,
                                      boolean invert)
Returns roulettewheel-choice, using a given method of the classifiers for determining probability/weight. Probablility is inverted if 'Invert' is true.

Parameters:
which - NName of a functional method that returns a numerical value
invert - If true, the wheigts for probablity are inverted.
Returns:
Chosen classifier.

randomSubset

public ClassifierSystem randomSubset(long size)
Returns a subset of the CS of a given size. If given size is not smaller than actual size, the entire set of CS is returned.

Parameters:
size - Size of subset
Returns:
new CS with randomly chosen classifiers.

filterbyaction

public ClassifierSystem filterbyaction(Situation action,
                                       boolean subsumptive)
Returns a subset of the CS with all rules that match a given action with their action part. If parameter 'subsumtive' is true, wildcards are used.

Parameters:
action - Action used as criterion for selection
subsumptive - If set to true, wildcards are used
Returns:
Subset of CS as a new CS

filterbyaction

public ClassifierSystem filterbyaction(Situation action)
Returns a subset of the CS with all rules that match a given action with their action part. No wildcards are used.

Parameters:
action - Action used as criterion for selection
Returns:
Subset of CS as a new CS

filterByCondition

public ClassifierSystem filterByCondition(Situation condition,
                                          boolean subsumtive)
Returns a subset of the CS with all rules that match a given condition with their action part. If parameter 'subsumtive' is true, wildcards are used.

Parameters:
condition - Condition to be used as criterion for selection
subsumtive - If set to true, wildcards are used
Returns:
Subset of CS as a new CS

filterByCondition

public ClassifierSystem filterByCondition(Situation condition)
Returns a subset of the CS with all rules that match a given condition with their action part. No wildcards are used.

Parameters:
condition - Condition to be used as criterion for selection
Returns:
Subset of CS as a new CS