com.kpro.algorithm
Class CBR

java.lang.Object
  extended by com.kpro.algorithm.CBR

public class CBR
extends java.lang.Object

Case based reason. This is a working CBR class that handles process flow between init and shutdown. Should be easy to extend and overload various features, but should work for most cases as is.

Version:
29.09.11.1
Author:
ngerstle

Field Summary
protected  ConclusionAlgorithm conclusAlg
           
protected  LearnAlgorithm learnAlg
           
protected  ReductionAlgorithm reduceAlg
           
protected  Gio theIO
           
protected  java.util.Properties weightsConfig
           
 
Constructor Summary
CBR(Gio theIO)
          constructor that so we can call cbr.parse(string)
CBR(Gio theIO, java.util.Properties weightsConfig, ReductionAlgorithm reduceAlg, ConclusionAlgorithm conclusAlg, LearnAlgorithm learnAlg)
          Our generic constructor.
 
Method Summary
private  ConclusionAlgorithm getConclusionAlgorihm(java.lang.String algorithm, DistanceMetric dm)
          Parse the conclusion algorithm substring into a ConclusionAlgorithm obejct with the right attributes and values.
private  DistanceMetric getDistanceMetricAlgorithm(java.lang.String algorithm, java.util.Properties weightsConfig)
          Parse the distance metric substring into a DistanceMetric object with the right attributes and values.
private  LearnAlgorithm getLearnAlgorihm(java.lang.String algorithm, java.util.Properties weightsConfig)
          Parse the learning algorithm substring into a LearningAlgorithm obejct with the right attributes and values.
private  ReductionAlgorithm getReductionAlgorithm(java.lang.String algorithm, DistanceMetric dm, PolicyDatabase pdb)
          Parse the reduction algorithm substring into a ReductionAlgorithm object with the right attributes and values.
 CBR parse(java.lang.String string)
          Parses the CBR option to create the class and instantiate correct algorithms.
private  PolicyObject process(PolicyObject newPO)
          Accepts a parsed PolicyObject that needs a action attached to it, and returns with the same object with an action in it.
 void run(PolicyObject newpol)
          runs through CBR with selected algorithms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theIO

protected Gio theIO

weightsConfig

protected java.util.Properties weightsConfig

reduceAlg

protected ReductionAlgorithm reduceAlg

conclusAlg

protected ConclusionAlgorithm conclusAlg

learnAlg

protected LearnAlgorithm learnAlg
Constructor Detail

CBR

public CBR(Gio theIO,
           java.util.Properties weightsConfig,
           ReductionAlgorithm reduceAlg,
           ConclusionAlgorithm conclusAlg,
           LearnAlgorithm learnAlg)
Our generic constructor.

Parameters:
theIO - the GIO instance
weightsConfig - the weights to use for distance metric & learning algorithm
reduceAlg - the retrival algorithm- produce relevent cases from history
conclusAlg - the 'reuse' algorithm- produces a solution from relevant cases
learnAlg - the retain algorithm- modifies the 'weightsConfig' so the distance metric is more accurate

CBR

public CBR(Gio theIO)
constructor that so we can call cbr.parse(string)

Parameters:
the - io class/object/mess
Method Detail

process

private PolicyObject process(PolicyObject newPO)
Accepts a parsed PolicyObject that needs a action attached to it, and returns with the same object with an action in it.

Parameters:
newPO - the new policy to be processed
Returns:
the same policy object with an action

run

public void run(PolicyObject newpol)
runs through CBR with selected algorithms

Parameters:
newPolicy -

parse

public CBR parse(java.lang.String string)
          throws java.lang.Exception
Parses the CBR option to create the class and instantiate correct algorithms.

Parameters:
string - the string from either configuration file or commandline
Returns:
the CBR defined by the input string
Throws:
java.lang.Exception

getDistanceMetricAlgorithm

private DistanceMetric getDistanceMetricAlgorithm(java.lang.String algorithm,
                                                  java.util.Properties weightsConfig)
                                           throws java.lang.ClassNotFoundException
Parse the distance metric substring into a DistanceMetric object with the right attributes and values.

Parameters:
algorithm - the string specifying which distancemetric algorithm to use
weightsConfig - the weightsConfiguration file (load this from Gio)
Returns:
the DistanceMetric class specified
Throws:
java.lang.ClassNotFoundException

getReductionAlgorithm

private ReductionAlgorithm getReductionAlgorithm(java.lang.String algorithm,
                                                 DistanceMetric dm,
                                                 PolicyDatabase pdb)
                                          throws java.lang.ClassNotFoundException
Parse the reduction algorithm substring into a ReductionAlgorithm object with the right attributes and values.

Parameters:
algorithm - the string specifying which reduction algorithm to use and number of relevant policies to include in format "algorithmName:k" where k is an integer
dm - the distance metric to use
pdb - the policy database to run on
Returns:
the ReductionAlgorithm class specified
Throws:
java.lang.ClassNotFoundException

getConclusionAlgorihm

private ConclusionAlgorithm getConclusionAlgorihm(java.lang.String algorithm,
                                                  DistanceMetric dm)
                                           throws java.lang.ClassNotFoundException
Parse the conclusion algorithm substring into a ConclusionAlgorithm obejct with the right attributes and values.

Parameters:
algorithm - the string specifying which conclusion algorithm to use
dm - the distance metric to use
Returns:
the ConclusionAlgorithm class specified
Throws:
java.lang.ClassNotFoundException

getLearnAlgorihm

private LearnAlgorithm getLearnAlgorihm(java.lang.String algorithm,
                                        java.util.Properties weightsConfig)
                                 throws java.lang.ClassNotFoundException
Parse the learning algorithm substring into a LearningAlgorithm obejct with the right attributes and values.

Parameters:
algorithm - the string specifying which learning algorithm to use
weightsConfig - the weightsConfiguration file (load this from Gio)
Returns:
the LearningAlgorithm class specified
Throws:
java.lang.ClassNotFoundException