Package expressions

Examples of expressions.FuzzyVariableExpression


            throw new UnsupportedOperationException();
    }

    public IntegerExpressionVariable getExpression(FuzzyExpression exp) {
        if (exp instanceof FuzzyVariableExpression) {
            FuzzyVariableExpression varexp = (FuzzyVariableExpression) exp;
            String name = varexp.getName();
            if (!varMap.containsKey(name))
                addVariable(name);
            return varMap.get(name);
        }
        else if (exp instanceof FuzzyConstantExpression) {
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);
        solver.addFuzzyClause(fc1);
        solver.addFuzzyClause(fc2);
        solver.addFuzzyClause(fc3);
        System.out.println(solver.model.constraintsToString());
View Full Code Here

        else if (head.equals("NM")) {
            Pair<FuzzyExpression, Integer> exp1 = parseExpression(w, startIndex + 1);
            return new Pair(new FuzzyUnaryExpression(exp1.a, new NM()), exp1.b);
        }
        else if (!Character.isDigit(head.charAt(0)))
            return new Pair(new FuzzyVariableExpression(head), startIndex + 1);
        else
            return new Pair(new FuzzyConstantExpression(Double.parseDouble(head)), startIndex + 1);
    }
View Full Code Here

        else if (p < pBinary + pUnary) {
            FuzzyExpression arg1 = getRandomExpression(variables, pBinary, pUnary, pVar, pConst, maxDepth - 1);
            return new FuzzyUnaryExpression(arg1, new N());
        }
        else if (p < pBinary + pUnary + pVar)
            return new FuzzyVariableExpression(variables.get(rand.nextInt(variables.size())));
        else {
            int m = (int) (1.0 / STEP_CONST);
            double val = ((double) rand.nextInt(m + 1)) / ((double) m);
            return new FuzzyConstantExpression(val);
        }
View Full Code Here

    private static FuzzyExpression getRandomExpression2(List<String> variables, double pNegation, int nrVariables, boolean isNegated) {
        if (!isNegated && rand.nextDouble() < pNegation)
            return new FuzzyUnaryExpression(getRandomExpression2(variables, pNegation, nrVariables, true), new N());
        else if (nrVariables == 1) {
            return new FuzzyVariableExpression(variables.get(rand.nextInt(variables.size())));
        }
        else {
            int nr1 = 1 + rand.nextInt(nrVariables - 1);
            int nr2 = nrVariables - nr1;
            FuzzyExpression arg1 = getRandomExpression2(variables, pNegation, nr1, false);
View Full Code Here

    private static FuzzyExpression getRandomMixedExpression(List<String> variables, double pNegation, double pMinimum, int nrVariables, boolean isNegated) {
        if (!isNegated && rand.nextDouble() < pNegation)
            return new FuzzyUnaryExpression(getRandomMixedExpression(variables, pNegation, pMinimum, nrVariables, true), new N());
        else if (nrVariables == 1) {
            return new FuzzyVariableExpression(variables.get(rand.nextInt(variables.size())));
        }
        else {
            int nr1 = 1 + rand.nextInt(nrVariables - 1);
            int nr2 = nrVariables - nr1;
            FuzzyExpression arg1 = getRandomMixedExpression(variables, pNegation, pMinimum, nr1, false);
View Full Code Here

  public GroundPredicate(String name, ArrayList<FaspConstant> args) {
    super(name,args);
  }

  public FuzzyExpression convertToFuzzyExpression () {
    return new FuzzyVariableExpression(toString());
  }
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)
            System.out.println(dli);
View Full Code Here

            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)) {
View Full Code Here

            this.name = name;
        }
    }

    public static void main(String[] args) {
        FuzzyExpression exp1 = new FuzzyBinaryExpression(new FuzzyVariableExpression("a"), new FuzzyVariableExpression("b"), new TW());
        FuzzyExpression exp2 = new FuzzyUnaryExpression(new FuzzyVariableExpression("c"), new N());
        FuzzyExpression exp = new FuzzyBinaryExpression(exp1, exp2, new TW());
        FuzzyLiteral lit = new FuzzyLiteral(0.2, 0.4, exp);
        FuzzyClause cl = new FuzzyClause(lit);
        List<FuzzyClause> constraints = new ArrayList();
        constraints.add(cl);
View Full Code Here

TOP

Related Classes of expressions.FuzzyVariableExpression

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.