@Override
    public boolean isEqWithEpsilon(RelOptCost other) {
        if (!(other instanceof Cost)) {
            return false;
        }

        Cost other0 = (Cost) other;

        if (isInfinite() || other0.isInfinite()) {
            return false;
        }

        if (this == other0) {
            return true;
        }

        return Math.abs(getValue() - other0.getValue()) < RelOptUtil.EPSILON;
    }
@Test
    public void testEpsilon() {
        CostFactory factory = CostFactory.INSTANCE;

        Cost cost1 = factory.makeCost(1.0d, 2.0d, 3.0d);
        Cost cost2 = factory.makeCost(1.0d, 2.0d + RelOptUtil.EPSILON / 2, 3.0d);
        Cost cost3 = factory.makeCost(1.0d, 2.0d + RelOptUtil.EPSILON * 2, 3.0d);

        assertTrue(cost1.isEqWithEpsilon(cost2));
        assertFalse(cost1.isEqWithEpsilon(cost3));

        assertTrue(cost2.isEqWithEpsilon(cost1));
        assertFalse(cost2.isEqWithEpsilon(cost3));

        assertFalse(cost3.isEqWithEpsilon(cost1));
        assertFalse(cost3.isEqWithEpsilon(cost2));

        Cost infiniteCost = factory.makeInfiniteCost();

        assertFalse(cost1.isEqWithEpsilon(infiniteCost));
        assertFalse(infiniteCost.isEqWithEpsilon(cost1));
        assertFalse(infiniteCost.isEqWithEpsilon(infiniteCost));
    }