def test_fuzzy_mult():
    vol  = np.r_[.5, .75, 1, 1.25, 1.5]
    V    = np.r_[0, .5, 1, .5, 0]
    pa   = np.r_[.5, 1.75, 2, 2.25, 2.5]
    P    = V.copy()

    test_u, test_mf = fuzzy_mult(pa, P, vol, V)
    expected_u = np.r_[0.25, 0.375, 0.5,0.625, 0.75, 0.875, 1., 1.125, 1.25,
                       1.3125, 1.5,1.6875, 1.75, 1.875, 2., 2.1875, 2.25, 2.5,
                       2.625, 2.8125, 3., 3.125, 3.375, 3.75]
    expected_mf = np.r_[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0.5, 0.5,
                        0.5, 0., 1., 0.5, 0.5, 0.5, 0., 0.5, 0., 0., 0., 0.]
    assert_allclose(test_u, expected_u)
    assert_allclose(test_mf, expected_mf)
예제 #2
0
def test_fuzzy_mult():
    vol = np.r_[.5, .75, 1, 1.25, 1.5]
    V = np.r_[0, .5, 1, .5, 0]
    pa = np.r_[.5, 1.75, 2, 2.25, 2.5]
    P = V.copy()

    test_u, test_mf = fuzzy_mult(pa, P, vol, V)
    expected_u = np.r_[0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1., 1.125, 1.25,
                       1.3125, 1.5, 1.6875, 1.75, 1.875, 2., 2.1875, 2.25, 2.5,
                       2.625, 2.8125, 3., 3.125, 3.375, 3.75]
    expected_mf = np.r_[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0.5, 0.5, 0.5,
                        0., 1., 0.5, 0.5, 0.5, 0., 0.5, 0., 0., 0., 0.]
    assert_allclose(test_u, expected_u)
    assert_allclose(test_mf, expected_mf)