List of usage examples for org.apache.commons.functor.generator.range DoubleRange DoubleRange
public DoubleRange(Endpoint<Double> from, Endpoint<Double> to, double step)
From source file:fuzzy.util.TestMaxMF.java
@Test public void testMaxMF() { Collection<Double> values = new DoubleRange(-10.0, 30.0, 0.1).toCollection(); MembershipFunction<Double> mf = new TrapezoidalMembershipFunction(-5.0, -2.0, 10.0, 20.0); Map<Double, Double> r = MaxMF.of(values, mf); assertTrue(r.containsValue(Double.valueOf(1.0))); }
From source file:fuzzy.util.TestCrispFuzzyProduct.java
@Test public void testCrispFuzzyProduct() { Collection<Double> col = new DoubleRange(0.0, 1.0, 0.1).toCollection(); // crisp MembershipFunction<Double> mf = new GeneralizedBellShapedMembershipFunction(0.2, 0.5, 0.8); // fuzzy Collection<Double> r = CrispFuzzyProduct.of(col, mf); assertTrue(r.size() == 11);/*from w w w. ja va 2s . co m*/ assertEquals(Double.valueOf(0.0), r.iterator().next()); // 0.0 * n = 0.0 }
From source file:fuzzy.df.TestMeanOfMaximaDefuzzificationFunction.java
@Test public void testDefuzzification() { MeanOfMaximaDefuzzificationFunction<Double> df = makeDefuzzificationFunction(); DoubleRange range = new DoubleRange(-10.0, 10.0, 0.1); MembershipFunction<Double> mf = new TrapezoidalMembershipFunction(-10.0, -8.0, -4.0, 7.0); Double d = df.evaluate(range, mf); assertEquals(Integer.valueOf(-6).toString(), new DecimalFormat("#.#").format(d)); }
From source file:fuzzy.df.TestBisectorDefuzzificationFunction.java
@Test public void testDefuzzification() { BisectorDefuzzificationFunction<Double> df = makeDefuzzificationFunction(); DoubleRange range = new DoubleRange(-10.0, 10.0, 0.1); MembershipFunction<Double> mf = new SigmoidalMembershipFunction(-10.0, 10.0); Double d = df.evaluate(range, mf); assertEquals(Integer.valueOf(0).toString(), new DecimalFormat("#.#").format(Math.abs(d))); }
From source file:fuzzy.df.TestCentroidDefuzzificationFunction.java
@Test public void testDefuzzification() { CentroidDefuzzificationFunction<Double> df = makeDefuzzificationFunction(); DoubleRange range = new DoubleRange(-10.0, 10.0, 0.1); MembershipFunction<Double> mf = new SigmoidalMembershipFunction(-10.0, 10.0); Double d = df.evaluate(range, mf); assertEquals(Integer.valueOf(0).toString(), new DecimalFormat("#.#").format(Math.abs(d))); }
From source file:fuzzy.df.TestLargestOfMaximaDefuzzificationFunction.java
@Test public void testDefuzzification() { LargestOfMaximaDefuzzificationFunction<Double> df = makeDefuzzificationFunction(); DoubleRange range = new DoubleRange(-10.0, 10.0, 0.1); MembershipFunction<Double> mf = new TrapezoidalMembershipFunction(-10.0, -8.0, -4.0, 7.0); Double d = df.evaluate(range, mf); assertEquals(Integer.valueOf(-8).toString(), new DecimalFormat("#.#").format(d)); }
From source file:fuzzy.df.TestSmallestOfMaximaDefuzzificationFunction.java
@Test public void testDefuzzification() { SmallestOfMaximaDefuzzificationFunction<Double> df = makeDefuzzificationFunction(); DoubleRange range = new DoubleRange(-10.0, 10.0, 0.1); MembershipFunction<Double> mf = new TrapezoidalMembershipFunction(-10.0, -8.0, -4.0, 7.0); Double d = df.evaluate(range, mf); assertEquals(Integer.valueOf(-4).toString(), new DecimalFormat("#.#").format(d)); }