crn
Class CRN

java.lang.Object
  extended bycrn.CRN

public class CRN
extends java.lang.Object

The Case Retrieval Net.

Author:
Piotrek

Field Summary
private  java.util.ArrayList cases
          A list of all cases in the CRN.
private  java.util.ArrayList ies
          A list of all ies in the CRN.
private  java.util.Hashtable iesWeights
          The weights of the IEs.
private  IESpecificComparisonManager specificComparisonManager
          The IE specific comparison manager.
 
Constructor Summary
CRN()
           
 
Method Summary
 void AddCase(Case newCase, float defaultWeightForNewIEs)
          Adds the given case to the CRN.
private  void AddIE(IE ie, float defaultWeight, Case travelCase)
          Adds the given IE to the CRN.
 void AddSpecificComparator(java.lang.String ieName, IEComparator ieComparator)
          Adds a specific comparator for the IEs with the given name.
private  void CompareCases(Case myCase, Case otherCase)
          Compares the two given cases.
private  float CompareIEsSets(java.util.ArrayList ies1, java.util.ArrayList ies2)
          Compares two sets of IEs (all of which are of the same type).
 java.util.ArrayList FindSimilarCases(Case travelCase, float similarityTreshold)
          Finds all the similiar cases in the CRN.
 Case FindTheMostSimilarCase(Case travelCase)
          Finds the most similiar case in the CRN.
private  java.util.ArrayList GetActivatedCases(Case travelCase, float activationTreshold)
          Gets the list of activated cases by the given one.
 java.util.Iterator GetCases()
          Gets the iterator for the cases.
 float GetIEWeight(java.lang.String ieName)
          Gets the weight of the given IE.
 void RemoveAllCases()
          Removes all the cases from the CRN.
 void RemoveCase(Case travelCase)
          Removes the given case from the CRN.
 void RemoveSpecificComparator(java.lang.String ieName)
          Removes a specific comparator for the IEs with the give name.
 void SetIEWeight(java.lang.String ieName, float ieWeight)
          Sets the weight of the given IE.
 void StoreToFile(java.lang.String fileName)
          Stores the CRN to the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ies

private java.util.ArrayList ies
A list of all ies in the CRN.


cases

private java.util.ArrayList cases
A list of all cases in the CRN.


iesWeights

private java.util.Hashtable iesWeights
The weights of the IEs. Name of the IE is a key. The value is a weight of the IE (Float).


specificComparisonManager

private IESpecificComparisonManager specificComparisonManager
The IE specific comparison manager.

Constructor Detail

CRN

public CRN()
Method Detail

AddCase

public void AddCase(Case newCase,
                    float defaultWeightForNewIEs)
Adds the given case to the CRN.

Parameters:
newCase - The case to be added. The added case is not the one given, but its close copy.
defaultWeightForNewIEs - A default weight for the new IEs. Used only if there is not yet defined weight for the type of the given IE.

RemoveCase

public void RemoveCase(Case travelCase)
Removes the given case from the CRN.

Parameters:
travelCase - A case to be removed.

FindSimilarCases

public java.util.ArrayList FindSimilarCases(Case travelCase,
                                            float similarityTreshold)
Finds all the similiar cases in the CRN.

Parameters:
travelCase - A case to find similiar cases to.
similarityTreshold - The level at which two cases are consider similiar (0 <= treshold <= 1).
Returns:
A list of similiat cases. If there are no similiar cases, the empty list is returned.

FindTheMostSimilarCase

public Case FindTheMostSimilarCase(Case travelCase)
Finds the most similiar case in the CRN.

Parameters:
travelCase - A case to find the most similiar case for.
Returns:
The most similar case. If there are more cases with the same similarity the more recent one is returned. If there are no cases in the history the null is returned.

GetIEWeight

public float GetIEWeight(java.lang.String ieName)
                  throws java.lang.IllegalArgumentException
Gets the weight of the given IE.

Parameters:
ieName - The name of IE to look for.
Returns:
The weight of the requestes IE.
Throws:
java.lang.IllegalArgumentException - If there is no such an IE in the CRN.

SetIEWeight

public void SetIEWeight(java.lang.String ieName,
                        float ieWeight)
                 throws java.lang.IllegalArgumentException
Sets the weight of the given IE.

Parameters:
ieName - The name of IE to set for.
ieWeight - The new weight for teh given type of IE.
Throws:
java.lang.IllegalArgumentException - If there is no such an IE in the CRN.

CompareCases

private void CompareCases(Case myCase,
                          Case otherCase)
                   throws java.lang.IllegalArgumentException
Compares the two given cases. Sets the similarity to the first one of them (muCase).

Parameters:
myCase - The fisrt case to be compared. Must belong to this CRN. This one will have the similiairty set.
otherCase - The second case to be compared. Do not have to belong to this CRN (usually does not). This one will not have the similiairty set.
Throws:
java.lang.IllegalArgumentException - Thrown if the myCase case does not belong to this CRN.

CompareIEsSets

private float CompareIEsSets(java.util.ArrayList ies1,
                             java.util.ArrayList ies2)
Compares two sets of IEs (all of which are of the same type).

Parameters:
ies1 - The first set of IEs to compare.
ies2 - The second set of IEs to compare.
Returns:
The similarity of those two sets of IEs.

AddIE

private void AddIE(IE ie,
                   float defaultWeight,
                   Case travelCase)
Adds the given IE to the CRN.

Parameters:
ie - The IE to be added.
defaultWeight - The default weight for this IE (if a new one).
travelCase - The case this IE is referencing to.

GetActivatedCases

private java.util.ArrayList GetActivatedCases(Case travelCase,
                                              float activationTreshold)
Gets the list of activated cases by the given one. Activated are cases that has at least one similiar enough IE (with the similarity greater or equal to the treshold).

Parameters:
travelCase - The activator case.
activationTreshold - The activation treshold.
Returns:
The list of all activated cases. If there are no activated cases, the empty list is returned.

AddSpecificComparator

public void AddSpecificComparator(java.lang.String ieName,
                                  IEComparator ieComparator)
Adds a specific comparator for the IEs with the given name.

Parameters:
ieName - The name of the IEs the given comaparator should be applied to.
ieComparator - The comparator for the IEs with the given name.
See Also:
IESpecificComparisonManager.AddSpecificComparator(java.lang.String ieName, crn.IEComparator ieComparator)

RemoveSpecificComparator

public void RemoveSpecificComparator(java.lang.String ieName)
Removes a specific comparator for the IEs with the give name.

Parameters:
ieName - A name of the IEs for which the specific comparator is to be removed.
See Also:
IESpecificComparisonManager.RemoveSpecificComparator(java.lang.String ieName)

StoreToFile

public void StoreToFile(java.lang.String fileName)
                 throws java.io.IOException
Stores the CRN to the given file.

Parameters:
fileName - The name of file to store the CRN to.
Throws:
java.io.IOException - Thrown in case of IO problems.

GetCases

public java.util.Iterator GetCases()
Gets the iterator for the cases.

Returns:
The requested iterator.

RemoveAllCases

public void RemoveAllCases()
Removes all the cases from the CRN.