Package expressions

Examples of expressions.FuzzyUnaryExpression


            FuzzyConstantExpression cstexp = (FuzzyConstantExpression) exp;
            int val = (int) (Math.round(cstexp.getValue() * totalNumberOfDegrees));
            return new IntegerConstantVariable(val);
        }
        else if (exp instanceof FuzzyUnaryExpression) {
            FuzzyUnaryExpression unexp = (FuzzyUnaryExpression) exp;
            if (unexp.getOperator() instanceof N) {
                IntegerExpressionVariable arg = getExpression(unexp.getArgument());
                return plus(totalNumberOfDegrees, mult(arg, -1));
            }
            else if(unexp.getOperator() instanceof NM){
                Constraint cnstr = lt(0,getExpression(unexp.getArgument()));
                return ifThenElse(cnstr,new IntegerConstantVariable(0),new IntegerConstantVariable(totalNumberOfDegrees));
            }
            else
                throw new UnsupportedOperationException();
        }
View Full Code Here


                return null;
            }
        }
        else if (head.equals("N")) {
            Pair<FuzzyExpression, Integer> exp1 = parseExpression(w, startIndex + 1);
            return new Pair(new FuzzyUnaryExpression(exp1.a, new N()), exp1.b);
        }
        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
                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());
        }
        else if (p < pBinary + pUnary + pVar)
            return new FuzzyVariableExpression(variables.get(rand.nextInt(variables.size())));
        else {
            int m = (int) (1.0 / STEP_CONST);
View Full Code Here

        return getRandomExpression2(variables, pNegation, nrVariables, false);
    }

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

        return getRandomMixedExpression(variables, pNegation, pMinimum, nrVariables, false);
    }

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

            Map<String, Integer> m = new HashMap();
            m.put(((FuzzyVariableExpression) fexp).getName(), 1);
            return new NodeExp(m, 0);
        }
        else if (fexp instanceof FuzzyUnaryExpression) {
            FuzzyUnaryExpression fu = (FuzzyUnaryExpression) fexp;
            if (fu.getOperator() instanceof N) {
                MaxMinExp arg = clauseToMaxMin(fu.getArgument());
                return arg.getComplement();
            }
            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

    }

    public static boolean isNegation(FuzzyExpression exp) {
        if (!(exp instanceof FuzzyUnaryExpression))
            return false;
        FuzzyUnaryExpression fu = (FuzzyUnaryExpression) exp;
        return (fu.getOperator() instanceof N);
    }
View Full Code Here

        FuzzyBinaryExpression fu = (FuzzyBinaryExpression) exp;
        return (fu.getOperator() instanceof SM);
    }

    public FuzzyExpression getUnaryArgument(FuzzyExpression exp) {
        FuzzyUnaryExpression fu = (FuzzyUnaryExpression) exp;
        return fu.getArgument();
    }
View Full Code Here

                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

        }
    }

    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.FuzzyUnaryExpression

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.