Package fuzzy4j.util

Examples of fuzzy4j.util.SimpleInterval


        double max = Math.min(A_sup.max(), B_sup.max());

        if (min > max)
            return null;
        else
            return new SimpleInterval(true, min, max, true);
    }
View Full Code Here


        nec.add(Math.max(p.y, 1.0 - B.apply(p.x)));
    }

    public double[] calculate(PointsLinearFunction A, SimpleInterval B) {

        SimpleInterval A_sup = A.support(); // find spport
        SimpleInterval B_sup = B.support();

        SimpleInterval overlap = overlap(A_sup, B_sup); // calculate overlapping support

        if (overlap == null)
            return new double[]{0, 1};

        List<Double> nec = new ArrayList<Double>();
        List<Double> pos = new ArrayList<Double>();

        // border cases
        updateNecPos(nec, pos, new Point(overlap.min(), A.apply(overlap.min())), B);
        updateNecPos(nec, pos, new Point(overlap.max(), A.apply(overlap.max())), B);

        for (Point p : A.points)
            updateNecPos(pos, nec, p, B);

        return new double[]{ Collections.min(nec), Collections.max(pos) };
View Full Code Here

        return new double[]{ Collections.min(nec), Collections.max(pos) };
    }

    public double[] calculate(TriangularFunction A, SimpleInterval B) {

        SimpleInterval A_sup = A.support(); // find spport
        SimpleInterval B_sup = B.support();

        SimpleInterval overlap = overlap(A_sup, B_sup); // calculate overlapping support

        if (overlap == null)
            return new double[]{0, 1};

        List<Double> values = new ArrayList<Double>();
        values.add(A.apply(overlap.min()));
        values.add(A.apply(overlap.max()));

        if (overlap.within(A.b))
            values.add(1.0);

        return new double[]{ Collections.min(values), Collections.max(values) };
    }
View Full Code Here

                new Point(1.6, 0.0),
                new Point(2.0, 1.0),
                new Point(Double.POSITIVE_INFINITY, 1.0)
        );

        SimpleInterval B = _(1.7, 1.8);

        double[] necPos = support.calculate(A, B);

        assertEquals(0.25, necPos[0], 0.001);
        assertEquals(0.5,  necPos[1], 0.001);

        // on top
        SimpleInterval B_2 = _(10, 11);
        double[] necPos_2  = support.calculate(A, B_2);
        assertEquals(1.0,  necPos_2[0], 0.001);
        assertEquals(1.0,  necPos_2[1], 0.001);

        // below
        SimpleInterval B_3 = _(0, 1);
        double[] necPos_3  = support.calculate(A, B_3);
        assertEquals(0.0,  necPos_3[0], 0.001);
        assertEquals(1.0,  necPos_3[1], 0.001);

        // from below overlap
        SimpleInterval B_4 = _(0, 1.7);
        double[] necPos_4  = support.calculate(A, B_4);

        assertEquals(0.0,  necPos_4[0], 0.001);
        assertEquals(0.25,  necPos_4[1], 0.001);

        // from top overlap
        SimpleInterval B_5 = _(1.8, 10);
        double[] necPos_5  = support.calculate(A, B_5);

        assertEquals(0.5,  necPos_5[0], 0.001);
        assertEquals(1.0,  necPos_5[1], 0.001);
View Full Code Here

    public void calculate_Interval_Triangular() throws Exception {

        MinimumSupport support = new MinimumSupport();

        TriangularFunction A = new TriangularFunction(0, 1, 2);
        SimpleInterval B_low = new SimpleInterval(true, -2, -1, true);
        SimpleInterval B_hig = new SimpleInterval(true, 3, 4, true);

        SimpleInterval B_i_l = new SimpleInterval(true, -0.5, 0.5, true);

        SimpleInterval B_one = new SimpleInterval(true, 0.5, 0.5, true);

        SimpleInterval B_inner = new SimpleInterval(true, 0.5, 1.0, true);

        SimpleInterval B_outer = new SimpleInterval(true, -0.5, 2.5, true);

        double[] i_1 = support.calculate(A, B_low);
        assertEquals(0.0, i_1[0], 0.0001);
        assertEquals(1.0, i_1[1], 0.0001);
View Full Code Here

        double min = Double.POSITIVE_INFINITY, max = Double.NEGATIVE_INFINITY;
        for (Point p : elements) {
            min = Math.min(p.x, min);
            max = Math.max(p.x, max);
        }
        return new SimpleInterval(true, min, max, true);
    }
View Full Code Here

        this.defaultValue = defaultValue;
    }

    @Override
    public SimpleInterval support() {
        return new SimpleInterval(true, points[0].x, points[points.length-1].x, true);
    }
View Full Code Here

        return new double[]{ Collections.min(values), Collections.max(values) };
    }

    public double[] calculate(TriangularFunction A, TriangularFunction B) {

        SimpleInterval A_sup = A.support(); // find spport
        SimpleInterval B_sup = B.support();

        SimpleInterval overlap = overlap(A_sup, B_sup);

        if (overlap == null)
            return new double[]{0, 1};

        // calculate points for intersection of each of the segments.
        Line A_left = Line.fromPoints(new Point(A.a, 0.0), new Point(A.b, 1.0));
        Line A_right = Line.fromPoints(new Point(A.b, 1.0), new Point(A.c, 0.0));

        Line B_left = Line.fromPoints(new Point(B.a, 0.0), new Point(B.b, 1.0));
        Line B_right = Line.fromPoints(new Point(B.b, 1.0), new Point(B.c, 0.0));

        List<Double> nec = new ArrayList<Double>();
        List<Double> pos = new ArrayList<Double>();

        nec.add(Math.max(A.apply(overlap.min()), 1.0 - B.apply(overlap.min())));
        nec.add(Math.max(A.apply(overlap.max()), 1.0 - B.apply(overlap.max())));

        pos.add(Math.min(A.apply(overlap.min()), B.apply(overlap.min())));
        pos.add(Math.min(A.apply(overlap.max()), B.apply(overlap.max())));

        Point A_1_B_1 = A_left.intersection(B_left);
        update(A_1_B_1, overlap, nec, pos);

        Point A_1_B_2 = A_left.intersection(B_right);
View Full Code Here

            return 1;
    }

    @Override
    public SimpleInterval support() {
        return new SimpleInterval(false, a, Double.POSITIVE_INFINITY, true);
    }
View Full Code Here

    @Override
    public SimpleInterval support() {
        double min = x0 - 9 / Math.abs(alpha);
        double max = x0 + 9 / Math.abs(alpha);
        return new SimpleInterval(true, min, max, true);
    }
View Full Code Here

TOP

Related Classes of fuzzy4j.util.SimpleInterval

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.