for (GroundLiteral a : getHerbrandBase()) {
for (GroundRule r : getRules()) {
if (r.getHead().equals(a)) {
if (ruleMap.containsKey(a)) {
FuzzyExpression expr = ruleMap.get(a);
ruleMap.put(a, new FuzzyBinaryExpression(r.convertBodyExpression(), expr, new SM()));
} else {
ruleMap.put(a, r.convertBodyExpression());
}
}
}
}
for (GroundLiteral a : getHerbrandBase()) {
FuzzyExpression aExpr = new FuzzyVariableExpression(a.toString());
FuzzyExpression bodyExpr;
if (ruleMap.containsKey(a)) {
bodyExpr = ruleMap.get(a);
} else {
bodyExpr = new FuzzyConstantExpression(0.0);
}
FuzzyExpression exp1 = new FuzzyBinaryExpression(aExpr, bodyExpr, new IW());
FuzzyExpression exp2 = new FuzzyBinaryExpression(bodyExpr, aExpr, new IW());
// TODO DEBUG commenting out following line is a test
//clauseList.add(new FuzzyClause(
// new FuzzyLiteral(1.0, 1.0, new FuzzyBinaryExpression(exp1, exp2, new TM()))));
// TODO DEBUG adding the following two lines is a test as well ...
clauseList.add(new FuzzyClause(new FuzzyLiteral(1.0,1.0, exp1)));
clauseList.add(new FuzzyClause(new FuzzyLiteral(1.0,1.0,exp2)));
//compArgs.add(new FuzzyBinaryExpression(aExpr, bodyExpr, new IW()));
//compArgs.add(new FuzzyBinaryExpression(bodyExpr, aExpr, new IW()));
}
// Add clauses for constraints (only with Lukasiewicz implicator)
// TODO: add other implicators or something
for (GroundRule r : getRules()) {
if (r.getHead() instanceof LattVal) {
Double headVal = ((LattVal) r.getHead()).getValue();
clauseList.add(new FuzzyClause(
new FuzzyLiteral(1.0, 1.0,
new FuzzyBinaryExpression(r.convertBodyExpression(),
new FuzzyConstantExpression(headVal), new IW()))));
}
}
return clauseList;