FuzzyConstantExpression exp1 = (FuzzyConstantExpression) exp;
double constant = exp1.getValue();
return new ConstantResult(negated ? 1 - constant : constant);
}
else if (exp instanceof FuzzyVariableExpression) {
FuzzyVariableExpression exp1 = (FuzzyVariableExpression) exp;
if (!negated)
return new VariableResult(exp1.getName(), new ArrayList());
else {
String name = exp1.getName();
String var = name.startsWith("neg") ? name.substring(3) : "neg" + name;
variables.add(var);
String[] vars = new String[2];
vars[0] = name;
vars[1] = var;
double[] coeffs = new double[2];
coeffs[0] = 1;
coeffs[1] = 1;
LinearInequality li1 = new LinearInequality(vars, coeffs, LpSolve.EQ, 1);
List<DisjunctiveLinearInequality> res = new ArrayList();
res.add(new DisjunctiveLinearInequality(li1));
return new VariableResult(var, res);
}
}
else if (exp instanceof FuzzyUnaryExpression) {
FuzzyUnaryExpression exp1 = (FuzzyUnaryExpression) exp;
UnaryOperator op = exp1.getOperator();
if (op instanceof N)
return process(exp1.getArgument(), !negated);
else {
System.err.println("Unary operator not supported (LinearProgrammingSolver) : " + op);
return null;
}
}
else if (exp instanceof FuzzyBinaryExpression) {
FuzzyBinaryExpression exp1 = (FuzzyBinaryExpression) exp;
BinaryOperator op = exp1.getOperator();
FuzzyExpression arg1 = exp1.getArgument1();
FuzzyExpression arg2 = exp1.getArgument2();
List<DisjunctiveLinearInequality> res = new ArrayList();
if (op instanceof SM) {
IntermediateResult ir1 = process(arg1, false);
IntermediateResult ir2 = process(arg2, false);
if ((ir1 instanceof VariableResult) && (ir2 instanceof ConstantResult)) {