edu.indiana.iucbrf.adaptation
Class DistanceWeightedAdapter

java.lang.Object
  extended by edu.indiana.iucbrf.adaptation.Adaptation
      extended by edu.indiana.iucbrf.adaptation.DistanceWeightedAdapter
All Implemented Interfaces:
java.io.Serializable

public class DistanceWeightedAdapter
extends Adaptation

With DistanceWeightedAdapter, the retrieved cases are given weights directly proportional to their similarity to the problem under examination. Then, the domain-specific adapter is called according to the weightedAdapterClassName provided to the constructor. This adapter makes use of the distance-sensitive weights created by DistanceWeightedAdapter. The domain-specific adapter could, for example, be based on a WeightedAverageAdapter, or a WeightedMajorityAdapter.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.indiana.iucbrf.adaptation.Adaptation
debugMode, wts
 
Constructor Summary
protected DistanceWeightedAdapter()
          Used for serialization only.
  DistanceWeightedAdapter(java.lang.String weightedAdapterClassName)
          Creates new DistanceWeightedAdapter.
  DistanceWeightedAdapter(java.lang.String weightedAdapterClassName, boolean debugMode)
          Creates new DistanceWeightedAdapter
 
Method Summary
 Solution adaptTo(RetrievalResults retrieved, Problem currentProblem, Domain domain)
          Adapt the retrieved cases to get a solution to the current problem.
protected  double[] calculateWeightsFromDifferences(double[] differences)
          Calculate appropriate weights (adaptation influence) for cases with given differences from the current problem.
 
Methods inherited from class edu.indiana.iucbrf.adaptation.Adaptation
setDebugMode, setWeights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistanceWeightedAdapter

protected DistanceWeightedAdapter()
Used for serialization only.


DistanceWeightedAdapter

public DistanceWeightedAdapter(java.lang.String weightedAdapterClassName)
Creates new DistanceWeightedAdapter. debugMode is set to false.

Parameters:
weightedAdapterClassName - The String indicating the weighted adapter class to be used. It will be provided with weights based on the distance of the retrieved cases from the current problem.

DistanceWeightedAdapter

public DistanceWeightedAdapter(java.lang.String weightedAdapterClassName,
                               boolean debugMode)
Creates new DistanceWeightedAdapter

Parameters:
weightedAdapterClassName - The String indicating the weighted adapter class to be used. It will be provided with weights based on the distance of the retrieved cases from the current problem.
debugMode - Set to true to print debugging information, false otherwise.
Method Detail

adaptTo

public Solution adaptTo(RetrievalResults retrieved,
                        Problem currentProblem,
                        Domain domain)
Adapt the retrieved cases to get a solution to the current problem. This method uses a separate weighted adapter (specified in the constructor) to adapt the retrieved cases to the problem.

Specified by:
adaptTo in class Adaptation
Parameters:
retrieved - A RetrievalResults of Case objects, in order from smallest difference to largest.
currentProblem - The problem the system is currently trying to solve.
domain - The domain in which the adaptation is taking place.
Returns:
The adapted solution.

calculateWeightsFromDifferences

protected double[] calculateWeightsFromDifferences(double[] differences)
Calculate appropriate weights (adaptation influence) for cases with given differences from the current problem. The weight for case i is calculated as follows: weight[case i] = differences[farthest case] - differences[case i] + differences[closest case] In this way, a case with the smallest difference from the problem has the greatest weight. Note that this will lead to different magnitudes of weights for different problems, but this is not a concern, because the proportion of weights is all that matters. This function should be overridden in a subclass if weights should be calculated using some other means.

Parameters:
differences - The differences of the cases from the problem.
Returns:
The calculated weights array