Example #1
0
def test_weights_input():
    td2 = TODIM(dec_mat_1, weights=[1, 2])
    assert np.isclose(td2.weights.sum(), 1.0)
    with pytest.raises(ValueError):
        td3 = TODIM(dec_mat_1, weights=[1, 2, 3])
    with pytest.raises(ValueError):
        td4 = TODIM(dec_mat_1, weights=10)
Example #2
0
def test_closs_coefficient():
    td = TODIM(dec_mat_1, weights=[0.5107, 0.4893], theta=2.5)
    td.get_closeness_coefficient()
    assert np.allclose(td.clos_coefficient, closs_coeff)
Example #3
0
def test_delta():
    td = TODIM(dec_mat_1, weights=[0.5107, 0.4893], theta=2.5)
    td.get_delta()
    assert np.allclose(td.delta, delta)
Example #4
0
def test_weights_none():
    td = TODIM(dec_mat_1)
    assert td.n_crit == len(td.weights)
    assert np.isclose(td.weights.sum(), 1.0)
Example #5
0
def test_input_invalid():
    with pytest.raises(ValueError):
        td = TODIM(10)
Example #6
0
def test_num_crit_alter():
    td = TODIM(dec_mat_1)
    assert td.n_alt == 10
    assert td.n_crit == 2
Example #7
0
def test_input_from_numpy():
    td = TODIM(np.array(dec_mat_1))
    assert np.allclose(td.matrix_d, dec_mat_1)
Example #8
0
def test_input_from_list():
    td = TODIM(dec_mat_1)
    assert np.allclose(td.matrix_d, dec_mat_1)
Example #9
0
def test_input_from_csv_file_criteria():
    td = TODIM("dec_mat_1.csv",
               crit_col_names=["criterion 1", "criterion 2"],
               alt_col_name="alternative")
    assert is_equal(list(td.criteria), criteria_1)
Example #10
0
def test_input_from_csv_file_normal_flow():
    td = TODIM("dec_mat_1.csv",
               crit_col_names=["criterion 1", "criterion 2"],
               alt_col_name="alternative")
    assert np.allclose(td.matrix_d, dec_mat_1)
Example #11
0
"""

import sys
sys.path.append("../src")
from decision_making import TODIM

weights = [0.5107, 0.4893]
theta = 2.5

########################################################################################################################
# Approach 1: using the csv file in "../test/dec_mat_1.csv"
########################################################################################################################

td_1 = TODIM("../test/dec_mat_1.csv",
             weights=weights,
             theta=theta,
             alt_col_name="alternative",
             crit_col_names=["criterion 1", "criterion 2"])
print("-" * 50)
print("- Approach 1:")
print("-" * 50)
td_1.get_closeness_coefficient(verbose=True)
td_1.plot_ranking()
print("-" * 50)
print("")
########################################################################################################################
# Approach 2: using the matrix as a list of list (but it could be a numpy array as well
########################################################################################################################
dec_mat_1 = [[8.627, 5.223], [9.838, 4.023], [10.374, 3.495], [8.200, 5.659],
             [5.854, 7.989], [8.108, 5.790], [6.845, 7.083], [5.738, 8.238],
             [5.858, 8.189], [6.269, 7.808]]