Package expressions

Examples of expressions.FuzzyBinaryExpression


            }
            else
                throw new UnsupportedOperationException();
        }
        else if (exp instanceof FuzzyBinaryExpression) {
            FuzzyBinaryExpression binexp = (FuzzyBinaryExpression) exp;
            if (binexp.getOperator() instanceof TW) {
                IntegerExpressionVariable var1 = getExpression(binexp.getArgument1());
                IntegerExpressionVariable var2 = getExpression(binexp.getArgument2());
                return max(new IntegerConstantVariable(0), plus(var1, plus(var2, -totalNumberOfDegrees)));
            }
            else if (binexp.getOperator() instanceof SM) {
                IntegerExpressionVariable var1 = getExpression(binexp.getArgument1());
                IntegerExpressionVariable var2 = getExpression(binexp.getArgument2());
                return max(var1, var2);
            }
            else
                throw new UnsupportedOperationException();
        }
View Full Code Here


        }
        throw new UnsupportedOperationException();
    }

    public static void main(String[] args) {
        FuzzyBinaryExpression exp1 = new FuzzyBinaryExpression(new FuzzyVariableExpression("x"),
                                                               new FuzzyVariableExpression("y"), new TW());
        FuzzyBinaryExpression exp2 = new FuzzyBinaryExpression(exp1, new FuzzyVariableExpression("z"), new SW());
//        FuzzyExpression exp1 = new FuzzyVariableExpression("x");
        FuzzyClause fc1 = new FuzzyClause(new FuzzyLiteral(0.7, 0.7, exp1));
        FuzzyClause fc2 = new FuzzyClause(new FuzzyLiteral(0.5, 0.9, new FuzzyVariableExpression("y")));
        FuzzyClause fc3 = new FuzzyClause(new FuzzyLiteral(0.2, 0.4, new FuzzyVariableExpression("y")));
        ChocoSolver solver = new ChocoSolver(10);
View Full Code Here

        String head = w[startIndex];
        if (head.equals("TW") || head.equals("IW") || head.equals("SW") || head.equals("SM") || head.equals("TM")) {
            Pair<FuzzyExpression, Integer> exp1 = parseExpression(w, startIndex + 1);
            Pair<FuzzyExpression, Integer> exp2 = parseExpression(w, exp1.b);
            if (head.equals("TW"))
                return new Pair(new FuzzyBinaryExpression(exp1.a, exp2.a, new TW()), exp2.b);
            else if (head.equals("IW"))
                return new Pair(new FuzzyBinaryExpression(exp1.a, exp2.a, new IW()), exp2.b);
            else if (head.equals("SW"))
                return new Pair(new FuzzyBinaryExpression(exp1.a, exp2.a, new SW()), exp2.b);
            else if (head.equals("TM"))
                return new Pair(new FuzzyBinaryExpression(exp1.a, exp2.a, new TM()), exp2.b);
            else if (head.equals("SM"))
                return new Pair(new FuzzyBinaryExpression(exp1.a, exp2.a, new SM()), exp2.b);
            else {
                System.err.println("WARNING: ILLEGAL FUZZY EXPRESSION 2 (parseExpression/RandomProblemGenerator");
                return null;
            }
        }
View Full Code Here

        if (p < pBinary) {
            FuzzyExpression arg1 = getRandomExpression(variables, pBinary, pUnary, pVar, pConst, maxDepth - 1);
            FuzzyExpression arg2 = getRandomExpression(variables, pBinary, pUnary, pVar, pConst, maxDepth - 1);
            double p2 = rand.nextDouble();
            if (p2 < 0.33)
                return new FuzzyBinaryExpression(arg1, arg2, new TW());
            else if (p2 < 0.66)
                return new FuzzyBinaryExpression(arg1, arg2, new IW());
            else
                return new FuzzyBinaryExpression(arg1, arg2, new SW());
        }
        else if (p < pBinary + pUnary) {
            FuzzyExpression arg1 = getRandomExpression(variables, pBinary, pUnary, pVar, pConst, maxDepth - 1);
            return new FuzzyUnaryExpression(arg1, new N());
        }
View Full Code Here

            int nr2 = nrVariables - nr1;
            FuzzyExpression arg1 = getRandomExpression2(variables, pNegation, nr1, false);
            FuzzyExpression arg2 = getRandomExpression2(variables, pNegation, nr2, false);
//            double p2 = rand.nextDouble();
//            if (p2 < 0.33)
            return new FuzzyBinaryExpression(arg1, arg2, new TW());
//            else if (p2 < 0.66)
//                return new FuzzyBinaryExpression(arg1, arg2, new IW());
//            else
//                return new FuzzyBinaryExpression(arg1, arg2, new SW());
        }
View Full Code Here

            int nr2 = nrVariables - nr1;
            FuzzyExpression arg1 = getRandomMixedExpression(variables, pNegation, pMinimum, nr1, false);
            FuzzyExpression arg2 = getRandomMixedExpression(variables, pNegation, pMinimum, nr2, false);
            double p2 = rand.nextDouble();
            if (p2 < pMinimum)
                return new FuzzyBinaryExpression(arg1, arg2, new TM());
            else
                return new FuzzyBinaryExpression(arg1, arg2, new TW());

        }
    }
View Full Code Here

                args.add(r.convertBodyExpression());
                args.add(new FuzzyConstantExpression(rho.getValue(r)));
                FuzzyExpression support = new FuzzyMultiExpression(args, r.getRuleTNorm());
                if (litMap.containsKey(l)) {
                    // Use the maximum directly in the expression associated.
                    litMap.put(l, new FuzzyBinaryExpression(litMap.get(l), support, new SM()));
                } else {
                    litMap.put(l, support);
                }
            }
        }
View Full Code Here

            }
            else
                throw new UnsupportedOperationException();
        }
        else if (fexp instanceof FuzzyBinaryExpression) {
            FuzzyBinaryExpression fu = (FuzzyBinaryExpression) fexp;
            if (fu.getOperator() instanceof TW) {
                MaxMinExp arg1 = clauseToMaxMin(fu.getArgument1());
                MaxMinExp arg2 = clauseToMaxMin(fu.getArgument2());
                MaxMinExp res = arg1.add(arg2);
                NodeExp c = new NodeExp(new HashMap(), -1);
                MaxMinExp a = res.add(c);
                MaxMinExp b = new NodeExp(new HashMap(), 0);
                return new MaxExp(a, b);
            }
            else if (fu.getOperator() instanceof SM) {
                MaxMinExp arg1 = clauseToMaxMin(fu.getArgument1());
                MaxMinExp arg2 = clauseToMaxMin(fu.getArgument2());
                return new MaxExp(arg1, arg2);
            }
            else
                throw new UnsupportedOperationException();
        }
View Full Code Here

            return res;
        }
    }

    public static void main(String[] args) {
        FuzzyExpression exp = new FuzzyBinaryExpression(new FuzzyBinaryExpression(new FuzzyVariableExpression("a"),
                                                                                  new FuzzyVariableExpression("b"), new SW()),
                                                        new FuzzyBinaryExpression(new FuzzyVariableExpression("c"),
                                                                                  new FuzzyVariableExpression("d"), new SW()),
                                                        new TW());
        FuzzyLiteral lit = new FuzzyLiteral(0.3, 0.7, exp);
        List<DisjunctiveLinearInequality> res = process(lit,1000);
        for (DisjunctiveLinearInequality dli : res)
View Full Code Here

    }

    public static boolean isMaximum(FuzzyExpression exp) {
        if (!(exp instanceof FuzzyBinaryExpression))
            return false;
        FuzzyBinaryExpression fu = (FuzzyBinaryExpression) exp;
        return (fu.getOperator() instanceof SM);
    }
View Full Code Here

TOP

Related Classes of expressions.FuzzyBinaryExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.