System.out.println("THEN ");
for(Decision d: r.getDecisions()){
System.out.print("\t"+d.getAttribute().getName()+" is set to ");
Expression e = d.getDecision();
System.out.print(e);
}
System.out.println();
}
System.out.println();
System.out.println("=============================");
}
StateElement weatherE = new StateElement();
StateElement activityE = new StateElement();
StateElement userProfileE = new StateElement();
weatherE.setAttributeName("weather");
Value rainy = new SimpleSymbolic("rainy", null, 0.6f);
weatherE.setValue(rainy);
userProfileE.setAttributeName("user_profile");
SetValue profile = new SetValue();
Value[] prifleElements = {
new SimpleSymbolic("eating",null,0.6f),
new SimpleSymbolic("culture",null,0.2f),
new SimpleSymbolic("entertainment", null, 0.8f),
new SimpleSymbolic("sightseeing",null,0.2f)
};
profile.setValues(Arrays.asList(prifleElements));
userProfileE.setValue(profile);
activityE.setAttributeName("activity");
SimpleSymbolic walking = new SimpleSymbolic("walking",null,0.8f);
activityE.setValue(walking);
State XTTstate = new State();
XTTstate.addStateElement(activityE);
XTTstate.addStateElement(weatherE);
XTTstate.addStateElement(userProfileE);
System.out.println("Printing current state");
State current = HeaRT.getWm().getCurrentState(model);
for(StateElement se : current){
System.out.println("Attribute "+se.getAttributeName()+" = "+se.getValue());
}
//TODO -
try{
HeaRT.fixedOrderInference(model, new String[]{"Recommendations"},
new Configuration.Builder()
.setUte(new CertaintyFactorsEvaluator())
.setInitialState(XTTstate)
.build());
}catch(UnsupportedOperationException e){
e.printStackTrace();
} catch (AttributeNotRegisteredException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Printing current state (after inference");
current = HeaRT.getWm().getCurrentState(model);
for(StateElement se : current){
System.out.println("Attribute "+se.getAttributeName()+" = "+se.getValue());
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BuilderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NotInTheDomainException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RangeFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}