Example of using CBR*Tools4.7.Complete source code of the exampleThe example represents the definition of ten classes of which each one gives the entirety of the Java code corresponding in alphabetical order: CarCase, CarCaseSituation, CarFileSimpleCaseBase, CarIndexBase, CarReasonerFactory, CarRetain, CarRetrieve, CarReuse, CarsApp, CarSimilarity. 4.7.1.CarCase
package aid.cbr.samples.cars;
import aid.cbr.tools.core.cbrcase.CompoundIndice;
import aid.cbr.tools.core.cbrcase.AbstractCbrCase;
public class CarCase extends AbstractCbrCase {
public int risk = 0;
public CarCaseSituation indices = new CarCaseSituation();
public CompoundIndice getPotentialIndices() {
return indices;
}
}
4.7.2.CarCaseSituation
package aid.cbr.samples.cars;
import aid.cbr.tools.core.cbrcase.*;
public class CarCaseSituation extends JavaClassIndice {
// these fields are used to store indices
public int normalizedLosses;
public String make;
public int fuelType;
public int aspiration;
public int numOfDoors;
public String bodyStyle;
public int driveWheels;
public int engineLocation;
public float wheelBase;
public float length;
public float height;
public float width;
public float curbWeight;
public String engineType;
public int numOfCylinders;
public float engineSize;
public String fuelSystem;
public float bore;
public float stroke;
public float compressionRatio;
public float horsePower;
public float peakRpm;
public float cityMpg;
public float highwayMpg;
public float price;
static private int _fuel [] = {1,2};
static private int _doors [] = {2,4};
static private int _asp [] = {1,2};
static private int _cylinders [] = {2,3,4,5,6,8,12};
static private int _wheels [] = {1,2,3};
static private int _loc [] = {1,2};
static {
ArrayIndiceDescriptor desc = new ArrayIndiceDescriptor("aid.cbr.samples.cars.CarCaseSituation");
desc.addIndiceDescriptor(new IndiceDescriptor("normalizedLosses", new RangeIntType(65,256)));
desc.addIndiceDescriptor(new IndiceDescriptor("make", StringType.STRING));
desc.addIndiceDescriptor(new IndiceDescriptor("fuelType", new ListIntType(_fuel)));
desc.addIndiceDescriptor(new IndiceDescriptor("aspiration", new ListIntType(_asp)));
desc.addIndiceDescriptor(new IndiceDescriptor("numOfDoors", new ListIntType(_doors)));
desc.addIndiceDescriptor(new IndiceDescriptor("bodyStyle", StringType.STRING ));
desc.addIndiceDescriptor(new IndiceDescriptor("driveWheels", new ListIntType(_wheels)));
desc.addIndiceDescriptor(new IndiceDescriptor("engineLocation", new ListIntType(_loc) ));
desc.addIndiceDescriptor(new IndiceDescriptor("wheelBase", new RangeFloatType(86,121)));
desc.addIndiceDescriptor(new IndiceDescriptor("length", new RangeFloatType(140,210)));
desc.addIndiceDescriptor(new IndiceDescriptor("height", new RangeFloatType(60,75)));
desc.addIndiceDescriptor(new IndiceDescriptor("width", new RangeFloatType(47,60)));
desc.addIndiceDescriptor(new IndiceDescriptor("curbWeight", new RangeFloatType(1488,4066)));
desc.addIndiceDescriptor(new IndiceDescriptor("engineType", StringType.STRING));
desc.addIndiceDescriptor(new IndiceDescriptor("numOfCylinders",new ListIntType(_cylinders)) );
desc.addIndiceDescriptor(new IndiceDescriptor("engineSize", new RangeFloatType(60,326)));
desc.addIndiceDescriptor(new IndiceDescriptor("fuelSystem",StringType.STRING));
desc.addIndiceDescriptor(new IndiceDescriptor("bore", new RangeFloatType(2,4)));
desc.addIndiceDescriptor(new IndiceDescriptor("stroke", new RangeFloatType(2,5)));
desc.addIndiceDescriptor(new IndiceDescriptor("compressionRatio", new RangeFloatType(7,23)));
desc.addIndiceDescriptor(new IndiceDescriptor("horsePower", new RangeFloatType(48,288)));
desc.addIndiceDescriptor(new IndiceDescriptor("peakRpm", new RangeFloatType(4150,6600)));
desc.addIndiceDescriptor(new IndiceDescriptor("cityMpg", new RangeFloatType(13,49)));
desc.addIndiceDescriptor(new IndiceDescriptor("highwayMpg", new RangeFloatType(16,54)));
desc.addIndiceDescriptor(new IndiceDescriptor("price", new RangeFloatType(5000,50000)));
}
}
4.7.3.CarFileSimpleCaseBase
package aid.cbr.samples.cars;
import aid.cbr.tools.core.memory.casebase.*;
import aid.cbr.tools.core.cbrcase.*;
import java.util.StringTokenizer;
import java.util.NoSuchElementException;
public class CarFileSimpleCaseBase extends FileSimpleCaseBase {
public CarFileSimpleCaseBase (String name,String filename) {
super (name,filename);
}
protected void setFloat (String name, JavaClassIndice s, String token){
int i = s.indexOf(name);
if (token.equals("?")) {
s.setUnknown(i);
} else {
s.setFloatIndice(Float.valueOf(token).floatValue(),i);
}
}
protected void setInt (String name, JavaClassIndice s, String token){
int i = s.indexOf(name);
if (token.equals("?")) {
s.setUnknown(i);
} else {
s.setIntIndice(Integer.parseInt(token),i);
}
}
protected void setSymbol (String name, JavaClassIndice s, String token){
int i = s.indexOf(name);
if (token.equals("?")) {
s.setUnknown(i);
} else {
s.setIndice(token,i);
}
}
protected CbrCase stringToCase (String l) throws CaseBaseAccessException{
CarCase c= new CarCase();
CarCaseSituation s = (CarCaseSituation)c.getPotentialIndices();
StringTokenizer t = new StringTokenizer(l,",");
try {
//caseid
c.setCaseId(new Integer(Integer.parseInt(t.nextToken())));
// risk
String token = t.nextToken().trim();
if (token.equals("?")) throw new CaseBaseAccessException ("Token cannot be unknown");
c.risk= Integer.parseInt(token);
// potential indices
setInt("normalizedLosses",s,t.nextToken().trim());
setSymbol("make",s,t.nextToken().trim());
setInt("fuelType",s,t.nextToken().trim());
setInt("aspiration",s,t.nextToken().trim());
setInt("numOfDoors",s,t.nextToken().trim());
setSymbol("bodyStyle",s,t.nextToken().trim());
setInt("driveWheels",s,t.nextToken().trim());
setInt("engineLocation",s,t.nextToken().trim());
setFloat("wheelBase",s,t.nextToken().trim());
setFloat("length",s,t.nextToken().trim());
setFloat("height",s,t.nextToken().trim());
setFloat("width",s,t.nextToken().trim());
setFloat("curbWeight",s,t.nextToken().trim());
setSymbol("engineType",s,t.nextToken().trim());
setInt("numOfCylinders",s,t.nextToken().trim());
setFloat("engineSize",s,t.nextToken().trim());
setSymbol("fuelSystem",s,t.nextToken().trim());
setFloat("bore",s,t.nextToken().trim());
setFloat("stroke",s,t.nextToken().trim());
setFloat("compressionRatio",s,t.nextToken().trim());
setFloat("horsePower",s,t.nextToken().trim());
setFloat("peakRpm",s,t.nextToken().trim());
setFloat("cityMpg",s,t.nextToken().trim());
setFloat("highwayMpg",s,t.nextToken().trim());
setFloat("price",s,t.nextToken().trim());
return c;
} catch (NoSuchElementException e) {
throw new CaseBaseAccessException("Token missing");
}
}
protected String caseToString (CbrCase c){
CarCaseSituation s = (CarCaseSituation)c.getPotentialIndices();
StringBuffer buff = new StringBuffer(255);
buff.append(c.getCaseId()); buff.append(",");
buff.append(((CarCase)c).risk); buff.append(",");
if (s.isUnknown(s.indexOf("normalizedLosses"))) buff.append("?"); else buff.append(s.normalizedLosses); buff.append(",");
if (s.isUnknown(s.indexOf("make"))) buff.append("?"); else buff.append(s.make); buff.append(",");
if (s.isUnknown(s.indexOf("fuelType"))) buff.append("?"); else buff.append(s.fuelType); buff.append(",");
if (s.isUnknown(s.indexOf("aspiration"))) buff.append("?"); else buff.append(s.aspiration); buff.append(",");
if (s.isUnknown(s.indexOf("numOfDoors"))) buff.append("?"); else buff.append(s.numOfDoors); buff.append(",");
if (s.isUnknown(s.indexOf("bodyStyle"))) buff.append("?"); else buff.append(s.bodyStyle); buff.append(",");
if (s.isUnknown(s.indexOf("driveWheels"))) buff.append("?"); else buff.append(s.driveWheels); buff.append(",");
if (s.isUnknown(s.indexOf("engineLocation"))) buff.append("?"); else buff.append(s.engineLocation); buff.append(",");
if (s.isUnknown(s.indexOf("wheelBase"))) buff.append("?"); else buff.append(s.wheelBase); buff.append(",");
if (s.isUnknown(s.indexOf("length"))) buff.append("?"); else buff.append(s.length); buff.append(",");
if (s.isUnknown(s.indexOf("height"))) buff.append("?"); else buff.append(s.height); buff.append(",");
if (s.isUnknown(s.indexOf("width"))) buff.append("?"); else buff.append(s.width); buff.append(",");
if (s.isUnknown(s.indexOf("curbWeight"))) buff.append("?"); else buff.append(s.curbWeight); buff.append(",");
if (s.isUnknown(s.indexOf("engineType"))) buff.append("?"); else buff.append(s.engineType);buff.append(",");
if (s.isUnknown(s.indexOf("numOfCylinders"))) buff.append("?"); else buff.append(s.numOfCylinders); buff.append(",");
if (s.isUnknown(s.indexOf("engineSize"))) buff.append("?"); else buff.append(s.engineSize); buff.append(",");
if (s.isUnknown(s.indexOf("fuelSystem"))) buff.append("?"); else buff.append(s.fuelSystem); buff.append(",");
if (s.isUnknown(s.indexOf("bore"))) buff.append("?"); else buff.append(s.bore); buff.append(",");
if (s.isUnknown(s.indexOf("stroke"))) buff.append("?"); else buff.append(s.stroke); buff.append(",");
if (s.isUnknown(s.indexOf("compressionRatio"))) buff.append("?"); else buff.append(s.compressionRatio);buff.append(",");
if (s.isUnknown(s.indexOf("horsePower"))) buff.append("?"); else buff.append(s.horsePower); buff.append(",");
if (s.isUnknown(s.indexOf("peakRpm"))) buff.append("?"); else buff.append(s.peakRpm); buff.append(",");
if (s.isUnknown(s.indexOf("cityMpg"))) buff.append("?"); else buff.append(s.cityMpg); buff.append(",");
if (s.isUnknown(s.indexOf("highwayMpg"))) buff.append("?"); else buff.append(s.highwayMpg); buff.append(",");
if (s.isUnknown(s.indexOf("price"))) buff.append("?"); else buff.append(s.price);
retur nnew String(buff);
}
}
4.7.4.CarIndexBase
package aid.cbr.samples.cars;
import aid.cbr.tools.core.cbrcase.*;
import aid.cbr.tools.core.memory.similarity.*;
import aid.cbr.tools.core.memory.index.*;
public class CarIndexBase extends BasicIndexBase {
CarIndexBase() {
// First strategy: knn
buildAndDeclareKnn();
// Second strategy: prototype + knn
declarePrototype();
declareKnnForPrototype();
buildProtoKnn();
}
protected void buildAndDeclareKnn() {
LinearKnnIndex knnIndex = new LinearKnnIndex(new CmpFactorValueOrder(),new CarSimilarity(),5);
knnIndex.setName("CarCaseKnn");
knnIndex.setComments("This index uses Knn method to retrieve car cases");
knnIndex.setUnknownCmpValue(new CmpFactorValue((float)0.5));
addTopLevelIndex(knnIndex);
}
protected void declarePrototype() {
PrototypeIndex protoIndex = new PrototypeIndex();
protoIndex.setName("ProtoIndex");
protoIndex.setAddCaseToAcceptedPrototypes(true);
Prototype p1 = new BooleanPrototype () { // root prototype
public CmpValue computeMatching(CompoundIndice indices){
return CmpBoolValue.TRUE;
}
};
p1.setName("Root");
protoIndex.addPrototype(p1);
Prototype p2 = new BooleanPrototype () {
// expensive cars prototype
public CmpValue computeMatching(CompoundIndice indices) {
int priceIndex = ((JavaClassIndice)indices).indexOf("price");
if (!indices.isUnknown(priceIndex)) {
float price = indices.getFloatIndice(priceIndex);
return (price > 10000)?CmpBoolValue.TRUE:CmpBoolValue.FALSE;
}
return CmpBoolValue.TRUE;
}
};
p2.setName("ExpensiveCars");
protoIndex.addPrototype(p2);
Prototype p3 = new BooleanPrototype () {
// big cars prototype
public CmpValue computeMatching(CompoundIndice indices) {
int lengthIndex = ((JavaClassIndice)indices).indexOf("length");
int widthIndex = ((JavaClassIndice)indices).indexOf("width");
int heightIndex = ((JavaClassIndice)indices).indexOf("height");
if ( !indices.isUnknown(lengthIndex) && !indices.isUnknown(widthIndex) && !indices.isUnknown(heightIndex)) {
float length = indices.getFloatIndice(lengthIndex);
float width = indices.getFloatIndice(widthIndex);
float height = indices.getFloatIndice(heightIndex);
return (length > 180 && height > 50 && width > 50)?CmpBoolValue.TRUE:CmpBoolValue.FALSE;
}
return CmpBoolValue.TRUE;
}
};
p3.setName("BigCars");
protoIndex.addPrototype(p3);
// build the tree
p1.addSon(p2);
p1.addSon(p3);
protoIndex.setRoot(p1);
addIndex(protoIndex);
}
protected void declareKnnForPrototype() {
LinearKnnIndex knnIndex = new LinearKnnIndex(new CmpFactorValueOrder(),new CarSimilarity(),5);
knnIndex.setName("CarCaseKnnAfterProto");
knnIndex.setComments("This index uses Knn method to retrieve car cases");
knnIndex.setUnknownCmpValue(new CmpFactorValue((float)0.5));
addIndex(knnIndex);
}
protected void buildProtoKnn() {
// connect the indexes
ToDynamicKnnIndex index = new ToDynamicKnnIndex();
index.setName("Proto+KNN");
index.addIndex(getIndex("ProtoIndex"));
index.addIndex(getIndex("CarCaseKnnAfterProto"));
addTopLevelIndex(index);
}
}
4.7.5.CarReasonerFactory
package aid.cbr.samples.cars;
import aid.cbr.tools.core.reasoner.*;
import aid.cbr.tools.core.cbrcase.*;
import aid.cbr.tools.core.memory.index.*;
import aid.cbr.tools.core.memory.casebase.*;
public class CarReasonerFactory extends AbstractReasonerFactory {
public CbrCase newTagetCase() {
return new CarCase();
}
public CaseBase new CaseBase() {
return new CarFileSimpleCaseBase("CarCaseBase","cars.txt");
}
public Retrieve new RetrieveStep() {
return new CarRetrieve();
}
public Reuse new ReuseStep() {
return new CarReuse();
}
public Retain new RetainStep() {
return new CarRetain();
}
public IndexBase new IndexBase() {
return new CarIndexBase();
}
}
4.7.6.CarRetain
package aid.cbr.samples.cars;
import aid.cbr.tools.core.cbrcase.CbrCase;
import aid.cbr.tools.core.reasoner.*;
import aid.cbr.tools.core.memory.similarity.CmpFactorValue;
public class CarRetain extends ResponsibilityChainRetainPattern{
CarRetain() {
RetainAnalyser a1 = new CaseBaseSizeRetainAnalyser(250);
RetainAnalyser a2 = new SimilarityRetainAnalyser(new CmpFactorValue((float)0.95));
a1.setNextAnalyser(a2);
setAnalyser(a1);
}
}
4.7.7.CarRetrieve
package aid.cbr.samples.cars;
import aid.cbr.tools.core.reasoner.*;
import aid.cbr.tools.core.memory.index.*;
import aid.cbr.tools.core.memory.similarity.*;
import com.sun.java.util.collections.*;
import aid.util.assoc.*;
public class CarRetrieve extends BasicRetrievePattern {
protected void updateRetrieveResult(IndexResult result, RetrieveResult stepResult){
List res= Assoc.getFactory().newListAssoc();
res.addAll(((CaseSetIndexResult)result).retrievedCases());
stepResult.setCases(res);
for (Iterator it = ((CaseSetIndexResult)result).retrievedCases().iterator();
it.hasNext(); ) {
Object id = it.next();
float f = ((CmpFactorValue)((CaseSimIndexResult)result).getCaseMatchingResults(id)).getFactor();
((UsefulnessRetrieveResult)stepResult).setCaseUsefulness(id,f);
}
}
}
4.7.8.CarReuse
package aid.cbr.samples.cars;
import aid.cbr.tools.core.cbrcase.CbrCase;
import aid.cbr.tools.core.reasoner.*;
public class CarReuse extends CaseSetFormulaReusePattern {
protected float getSourceCaseSolution(CbrCase c){
return ((CarCase)c).risk;
}
protected void setTargetCaseSolution(CbrCase c, float sol){
((CarCase)c).risk=(int)sol;
}
CarReuse () {
setFormula( new MeanAdaptationFormula() {
public float compute(float[] solutions, float[] usefullness) {
float f = super.compute(solutions,usefullness);
return Math.round(f);
}
};
}
}
4.7.9.CarsApp
package aid.cbr.samples.cars;
import aid.cbr.tools.core.cbrcase.*;
import aid.cbr.tools.core.reasoner.*;
import aid.cbr.tools.core.memory.similarity.*;
import aid.cbr.tools.core.memory.index.*;
import aid.cbr.tools.core.memory.casebase.*;
import aid.cbr.tools.core.memory.*;
import com.sun.java.util.collections.*;
import java.util.Date;
public class CarsApp {
public static void initialize(CbrCase c) throws CaseBaseAccessException {
CaseBase cb = new CarFileSimpleCaseBase("TargetCases","target.txt");
cb.open(true);
((CarCase)c)._indices=(CarCaseSituation)cb.getCase(new Integer(1)).getPotentialIndices();
cb.close();
}
public static void printReport(Reasoning r) throws CaseBaseAccessException{
StringBuffer buf = new StringBuffer(250);
buf.append("\n\n*****Reasoning Report*****\n");
buf.append("\nstarted at "+new Date(r.getBeginDate()));
buf.append("\ndone in "+r.duration()+ " ms");
appendRetrieveReport(r,buf);
appendReuseReport(r,buf);
appendReviseReport(r,buf);
appendRetainReport(r,buf);
//print the report
System.out.print(buf);
}
public static void appendRetrieveReport(Reasoning r, StringBuffer buf) throws CaseBaseAccessException{
RetrieveResult retrieve = r.getRetrieveResult();
if (retrieve!=null && retrieve.done()) {
buf.append("\n\n1/ retrieve done in "+retrieve.duration()+ " ms");
if (retrieve.isCaseRetrieved()) {
int nbCases = retrieve.cases().size();
buf.append("\nfound "+nbCases+" cases");
for (Iterator it = retrieve.cases().iterator();
it.hasNext();){
Object id = it.next();
float f =((UsefulnessRetrieveResult)retrieve).getCaseUsefulness(id);
float sol = ((CarCase)r.getMemory().getCaseBase().getCase(id)).risk;
buf.append("\ncaseid="+id+" usefulness="+f+ " risk="+sol);
}
} else {
buf.append("\nno case found");
}
}else {
buf.append("\n\n1/ retrieve not done");
}
}
public static void appendReuseReport(Reasoning r, StringBuffer buf){
ReuseResult reuse = r.getReuseResult();
if (reuse!=null && reuse.done()) {
buf.append("\n\n2/ reuse done in "+reuse.duration()+ " ms");
if (reuse.isAdaptationDone()) {
buf.append("\nassigned risk by adaptation is "+reuse.getAdaptedSolution());
} else {
buf.append("\nadaptation not performed");
}
}else {
buf.append("\n\n2/ reuse not done");
}
}
public static void appendReviseReport(Reasoning r, StringBuffer buf) {
ReviseResult revise = r.getReviseResult();
if (revise!=null && revise.done()) {
buf.append("\n\n3/ revise done in "+revise.duration()+ " ms");
}else {
buf.append("\n\n3/ revise not done");
}
}
public static void appendRetainReport(Reasoning r, StringBuffer buf) {
RetainResult retain = r.getRetainResult();
if (retain!=null && retain.done()) {
buf.append("\n\n4/ retain done in "+retain.duration()+ " ms");
if (retain.isTargetCaseRetained())
buf.append("\n target case added");
else
buf.append("\n target case not added");
}else {
buf.append("\n\n4/ retain not done");
}
}
public static void main(String[] args) {
try {
// create the reasoner
ReasonerFactory factory = new CarReasonerFactory();
Reasoner reasoner = factory.getReasoner();
// initialise the case base and the indexes
reasoner.getMemory().getCaseBase().open();
reasoner.getMemory().buildFromCaseBase(new GlobalIndexParams());
// start a reasoning
CbrCase target = factory.newTagetCase();
initialize(target);
Reasoning reasoning = reasoner.startReasoning(target);
// print the report
printReport(reasoning);
// start a second reasoning
((BasicRetrievePattern)reasoner.getRetrieveStep()).getDefaultParams().
setSelectedIndex(reasoner.getMemory().getIndexBase().getIndex("Proto+KNN"));
((KnnIndex)reasoner.getMemory().getIndexBase().getIndex("CarCaseKnnAfterProto")).setK(10);
target = factory.newTagetCase();
initialize(target);
reasoning = reasoner.startReasoning(target);
// print the report
printReport(reasoning);
reasoner.getMemory().getCaseBase().close();
} catch (CaseBaseAccessException expt) {
expt.printStackTrace();
} catch (MemoryAccessException expt) {
expt.printStackTrace();
} catch (ReasoningAbortedException expt) {
System.out.println("Reasoner exited abormally");
expt.printStackTrace();
}
}
}
4.7.10.CarsSimilarity
package aid.cbr.samples.cars;
import aid.cbr.tools.core.memory.similarity.*;
import aid.cbr.tools.core.cbrcase.*;
public class CarSimilarity extends CompoundIndiceArraySimilarity{
public CarSimilarity () {
super(new MeanAggregationFct(),25);
Class c = JavaClassIndice.getClass("aid.cbr.samples.cars.CarCaseSituation");
// indices with float similarity on float Domain
SimpleIndiceSimilarity floatAtt = new SimpleIndiceSimilarity(new FloatDomainSimilarityFct());
setSubSimilarity(CarCaseSituation.indexOf(c,"wheelBase"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"length"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"height"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"width"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"curbWeight"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"engineSize"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"bore"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"stroke"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"compressionRatio"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"horsePower"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"peakRpm"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"cityMpg"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"highwayMpg"),floatAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"price"),floatAtt);
SimpleIndiceSimilarity intAtt = new
SimpleIndiceSimilarity(new IntDomainSimilarityFct());
setSubSimilarity(CarCaseSituation.indexOf(c,"normalizedLosses"),intAtt);
setSubSimilarity(CarCaseSituation.indexOf(c,"numOfCylinders"),intAtt);
// indices with equality Similarity
SimpleIndiceSimilarity eqsim = new SimpleIndiceSimilarity(new IdentitySimilarityFct(new CmpFactorValue(1),
new CmpFactorValue(0)));
setSubSimilarity(CarCaseSituation.indexOf(c,"make"),eqsim);
setSubSimilarity(CarCaseSituation.indexOf(c,"fuelType"),eqsim);
setSubSimilarity(CarCaseSituation.indexOf(c,"aspiration"),eqsim);
setSubSimilarity(CarCaseSituation.indexOf(c,"numOfDoors"),eqsim);
setSubSimilarity(CarCaseSituation.indexOf(c,"driveWheels"),eqsim);
setSubSimilarity(CarCaseSituation.indexOf(c,"engineLocation"),eqsim);
setSubSimilarity(CarCaseSituation.indexOf(c,"engineType"),eqsim);
setSubSimilarity(CarCaseSituation.indexOf(c,"fuelSystem"),eqsim);
// Body style
SymetricExtensionSimilarityFct bodyStyleSim = new SymetricExtensionSimilarityFct(new CmpFactorValue(0),
new CmpFactorValue(1));
bodyStyleSim.define("hardtop","convertible", new CmpFactorValue((float)0.9));
bodyStyleSim.define("hardtop","hatchback", new CmpFactorValue((float)0.5));
bodyStyleSim.define("hardtop","sedan", new CmpFactorValue((float)0.5));
setSubSimilarity(CarCaseSituation.indexOf(c,"bodyStyle"),new SimpleIndiceSimilarity(bodyStyleSim));
}
}
|