Ejemplo n.º 1
0
 def test_default(self):
     """
     Test the integration with the default selections.
     """
     x_matrix, _alt_names = mcdm.load(
         os.path.join(DIR_PATH, "data", "example03.tsv"),
         delimiter="\t",
     )
     self.assertAlmostEqualRankings(mcdm.rank(x_matrix), get_ranking01())
Ejemplo n.º 2
0
 def test_mew(self):
     """
     Test the integration with the MEW scoring method.
     """
     x_matrix, _alt_names = mcdm.load(
         os.path.join(DIR_PATH, "data", "example03.tsv"),
         delimiter="\t",
     )
     self.assertAlmostEqualRankings(
         mcdm.rank(x_matrix, s_method="MEW"),
         get_ranking17(),
     )
Ejemplo n.º 3
0
 def test_example01(self):
     """
     Test the loading of a matrix from a CSV file with the default
     parameter values.
     """
     obtained_matrix, obtained_row_labels = load(
         os.path.join(DIR_PATH, "data", "example01.csv"), )
     self.assertAlmostEqualArrays(
         obtained_matrix,
         np.array(get_matrix01(), dtype=np.float64),
     )
     self.assertEqual(obtained_row_labels, None)
Ejemplo n.º 4
0
 def test_topsis_w(self):
     """
     Test the integration with the TOPSIS scoring method and predefined
     weights.
     """
     x_matrix, _alt_names = mcdm.load(
         os.path.join(DIR_PATH, "data", "example03.tsv"),
         delimiter="\t",
     )
     self.assertAlmostEqualRankings(
         mcdm.rank(x_matrix, w_vector=get_vector01(), s_method="TOPSIS"),
         get_ranking18(),
     )
Ejemplo n.º 5
0
 def test_example05(self):
     """
     Test the loading of a matrix from a CSV file that contains row labels.
     """
     obtained_matrix, obtained_row_labels = load(
         os.path.join(DIR_PATH, "data", "example05.csv"),
         labeled_rows=True,
     )
     self.assertAlmostEqualArrays(
         obtained_matrix,
         np.array(get_matrix05(), dtype=np.float64),
     )
     self.assertEqual(obtained_row_labels, get_labels02())
Ejemplo n.º 6
0
 def test_integration_mew_vic(self):
     """Test integration with the MEW and VIC methods."""
     filepath = os.path.join(DIR_PATH, "data", "example09.tsv")
     x_matrix, alt_names = mcdm.load(
         filepath, delimiter="\t", skiprows=1, labeled_rows=True)
     obtained_ranking = mcdm.rank(
         x_matrix, alt_names=alt_names, w_method="VIC", s_method="MEW")
     expected_ranking = [
         ("COORD.PRoPHET", 0.475401),
         ("DF.PRoPHET",    0.472054),
         ("CnR.LTS",       0.380770),
         ("SimBetTS.L8",   0.380006),
         ("SimBetTS.L16",  0.379992),
         ("CnR.DestEnc",   0.379448),
         ("LSF-SnW.L16",   0.377400),
         ("DF.DestEnc",    0.373788),
         ("COORD.DestEnc", 0.373536),
         ("SimBetTS.L4",   0.372440),
         ("LSF-SnW.L8",    0.368945),
         ("DF.LTS",        0.366043),
         ("COORD.LTS",     0.365320),
         ("LSF-SnW.L4",    0.344986),
         ("CnF.PRoPHET",   0.344899),
         ("CnF.DestEnc",   0.340809),
         ("CnF.LTS",       0.336824),
         ("SnF.L8",        0.333813),
         ("SnF.L4",        0.331080),
         ("CnR.PRoPHET",   0.328371),
         ("SnF.L2",        0.328271),
         ("SnF.L16",       0.325965),
         ("SimBetTS.L2",   0.319820),
         ("LSF-SnW.L2",    0.283363),
         ("CnR.Enc",       0.253889),
         ("DF.Enc",        0.196428),
         ("COORD.Enc",     0.185271),
         ("Epidemic",      0.176182),
         ("Direct",        0.144637),
         ("EBR.L16",       0.144275),
         ("SnW.L16",       0.144196),
         ("EBR.L2",        0.139577),
         ("SnW.L2",        0.139347),
         ("SnW.L8",        0.137288),
         ("EBR.L8",        0.137283),
         ("EBR.L4",        0.136547),
         ("SnW.L4",        0.136425),
         ("CnF.Enc",       0.117134),
     ]
     self.assertEqual(len(obtained_ranking), len(expected_ranking))
     for i, tmp in enumerate(obtained_ranking):
         self.assertEqual(tmp[0], expected_ranking[i][0])
         self.assertAlmostEqual(tmp[1], expected_ranking[i][1], places=6)
Ejemplo n.º 7
0
 def test_example07(self):
     """
     Test the loading of a matrix from a CSV file that contains a
     multi-line comment.
     """
     obtained_matrix, obtained_row_labels = load(
         os.path.join(DIR_PATH, "data", "example07.csv"),
         skiprows=3,
     )
     self.assertAlmostEqualArrays(
         obtained_matrix,
         np.array(get_matrix07(), dtype=np.float64),
     )
     self.assertEqual(obtained_row_labels, None)
Ejemplo n.º 8
0
 def test_example03(self):
     """
     Test the loading of a matrix from a TSV file that does not contain any
     labels.
     """
     obtained_matrix, obtained_row_labels = load(
         os.path.join(DIR_PATH, "data", "example03.tsv"),
         delimiter="\t",
     )
     self.assertAlmostEqualArrays(
         obtained_matrix,
         np.array(get_matrix03(), dtype=np.float64),
     )
     self.assertEqual(obtained_row_labels, None)
Ejemplo n.º 9
0
 def test_example09(self):
     """
     Test the loading of a matrix from a large TSV file.
     """
     obtained_matrix, obtained_row_labels = load(
         os.path.join(DIR_PATH, "data", "example09.tsv"),
         delimiter="\t",
         skiprows=1,
         labeled_rows=True,
     )
     self.assertAlmostEqualArrays(
         obtained_matrix,
         np.array(get_matrix09(), dtype=np.float64),
     )
     self.assertEqual(obtained_row_labels, get_labels04())
Ejemplo n.º 10
0
 def test_example04(self):
     """
     Test the loading of a matrix from a TSV file that contains a
     single-line comment.
     """
     obtained_matrix, obtained_row_labels = load(
         os.path.join(DIR_PATH, "data", "example04.tsv"),
         delimiter="\t",
         skiprows=1,
     )
     self.assertAlmostEqualArrays(
         obtained_matrix,
         np.array(get_matrix04(), dtype=np.float64),
     )
     self.assertEqual(obtained_row_labels, None)
Ejemplo n.º 11
0
 def test_integration_mew(self):
     """Test integration with the MEW method."""
     filepath = os.path.join(DIR_PATH, "data", "example03.tsv")
     x_matrix, alt_names = mcdm.load(filepath, delimiter="\t")
     obtained_ranking = mcdm.rank(x_matrix, s_method="MEW")
     expected_ranking = [
         ("a3", 0.500000),
         ("a2", 0.433013),
         ("a4", 0.433013),
         ("a1", 0.000000),
         ("a5", 0.000000),
     ]
     self.assertEqual(len(obtained_ranking), len(expected_ranking))
     for i, tmp in enumerate(obtained_ranking):
         self.assertEqual(tmp[0], expected_ranking[i][0])
         self.assertAlmostEqual(tmp[1], expected_ranking[i][1], places=6)
Ejemplo n.º 12
0
 def test_integration_topsis_is_benefit_x(self):
     """Test integration with the TOPSIS method and mixed criteria."""
     filepath = os.path.join(DIR_PATH, "data", "example03.tsv")
     x_matrix, alt_names = mcdm.load(filepath, delimiter="\t")
     obtained_ranking = mcdm.rank(
         x_matrix, is_benefit_x=[True, False], s_method="TOPSIS")
     expected_ranking = [
         ("a5", 1.000000),
         ("a4", 0.750000),
         ("a3", 0.500000),
         ("a2", 0.250000),
         ("a1", 0.000000),
     ]
     self.assertEqual(len(obtained_ranking), len(expected_ranking))
     for i, tmp in enumerate(obtained_ranking):
         self.assertEqual(tmp[0], expected_ranking[i][0])
         self.assertAlmostEqual(tmp[1], expected_ranking[i][1], places=6)
Ejemplo n.º 13
0
 def test_integration_topsis_w(self):
     """Test integration with the TOPSIS and w_vector methods."""
     filepath = os.path.join(DIR_PATH, "data", "example03.tsv")
     x_matrix, alt_names = mcdm.load(filepath, delimiter="\t")
     obtained_ranking = mcdm.rank(
         x_matrix, w_vector=[0.7, 0.3], s_method="TOPSIS")
     expected_ranking = [
         ("a5", 0.700000),
         ("a4", 0.650413),
         ("a3", 0.500000),
         ("a2", 0.349587),
         ("a1", 0.300000),
     ]
     self.assertEqual(len(obtained_ranking), len(expected_ranking))
     for i, tmp in enumerate(obtained_ranking):
         self.assertEqual(tmp[0], expected_ranking[i][0])
         self.assertAlmostEqual(tmp[1], expected_ranking[i][1], places=6)
Ejemplo n.º 14
0
 def test_topsis_is_benefit_x(self):
     """
     Test the integration with the TOPSIS scoring method and a mixture of
     benefit and cost criteria.
     """
     x_matrix, _alt_names = mcdm.load(
         os.path.join(DIR_PATH, "data", "example03.tsv"),
         delimiter="\t",
     )
     self.assertAlmostEqualRankings(
         mcdm.rank(
             x_matrix,
             is_benefit_x=[True, False],
             s_method="TOPSIS",
         ),
         get_ranking19(),
     )
Ejemplo n.º 15
0
 def test_integration_topsis_sd_vector(self):
     """Test integration with the TOPSIS, SD, Vector methods."""
     filepath = os.path.join(DIR_PATH, "data", "example08.tsv")
     x_matrix, alt_names = mcdm.load(
         filepath, delimiter="\t", labeled_rows=True)
     obtained_ranking = mcdm.rank(
         x_matrix, alt_names=alt_names, n_method="Vector",
         w_method="SD", s_method="TOPSIS")
     expected_ranking = [
         ("A", 0.562314),
         ("D", 0.472564),
         ("C", 0.447428),
         ("B", 0.438744),
     ]
     self.assertEqual(len(obtained_ranking), len(expected_ranking))
     for i, tmp in enumerate(obtained_ranking):
         self.assertEqual(tmp[0], expected_ranking[i][0])
         self.assertAlmostEqual(tmp[1], expected_ranking[i][1], places=6)
Ejemplo n.º 16
0
 def test_integration_mtopsis_em_linear3(self):
     """Test integration with the mTOPSIS, EM, Linear3 methods."""
     filepath = os.path.join(DIR_PATH, "data", "example08.tsv")
     x_matrix, alt_names = mcdm.load(
         filepath, delimiter="\t", labeled_rows=True)
     obtained_ranking = mcdm.rank(
         x_matrix, alt_names=alt_names, n_method="Linear3",
         w_method="EM", s_method="mTOPSIS")
     expected_ranking = [
         ("A", 0.567198),
         ("D", 0.473771),
         ("B", 0.440236),
         ("C", 0.439791),
     ]
     self.assertEqual(len(obtained_ranking), len(expected_ranking))
     for i, tmp in enumerate(obtained_ranking):
         self.assertEqual(tmp[0], expected_ranking[i][0])
         self.assertAlmostEqual(tmp[1], expected_ranking[i][1], places=6)
Ejemplo n.º 17
0
 def test_integration_saw_critic_linear2(self):
     """Test integration with the SAW, CRITIC, Linear2 methods."""
     filepath = os.path.join(DIR_PATH, "data", "example08.tsv")
     x_matrix, alt_names = mcdm.load(
         filepath, delimiter="\t", labeled_rows=True)
     obtained_ranking = mcdm.rank(
         x_matrix, alt_names=alt_names, n_method="Linear2",
         w_method="CRITIC", s_method="SAW")
     expected_ranking = [
         ("C", 0.586404),
         ("A", 0.536356),
         ("B", 0.422726),
         ("D", 0.418160),
     ]
     self.assertEqual(len(obtained_ranking), len(expected_ranking))
     for i, tmp in enumerate(obtained_ranking):
         self.assertEqual(tmp[0], expected_ranking[i][0])
         self.assertAlmostEqual(tmp[1], expected_ranking[i][1], places=6)
Ejemplo n.º 18
0
 def test_integration_mew_vic_linear1(self):
     """Test integration with the MEW, VIC, Linear1 methods."""
     filepath = os.path.join(DIR_PATH, "data", "example08.tsv")
     x_matrix, alt_names = mcdm.load(
         filepath, delimiter="\t", labeled_rows=True)
     obtained_ranking = mcdm.rank(
         x_matrix, alt_names=alt_names, n_method="Linear1",
         w_method="VIC", s_method="MEW")
     expected_ranking = [
         ("A", 0.596199),
         ("B", 0.592651),
         ("D", 0.581653),
         ("C", 0.507066),
     ]
     self.assertEqual(len(obtained_ranking), len(expected_ranking))
     for i, tmp in enumerate(obtained_ranking):
         self.assertEqual(tmp[0], expected_ranking[i][0])
         self.assertAlmostEqual(tmp[1], expected_ranking[i][1], places=6)
Ejemplo n.º 19
0
 def test_topsis_sd_vector(self):
     """
     Test the integration with the TOPSIS scoring method, the SD weighting
     method, and the Vector normalization method.
     """
     x_matrix, alt_names = mcdm.load(
         os.path.join(DIR_PATH, "data", "example08.tsv"),
         delimiter="\t",
         labeled_rows=True,
     )
     self.assertAlmostEqualRankings(
         mcdm.rank(
             x_matrix,
             alt_names=alt_names,
             n_method="Vector",
             w_method="SD",
             s_method="TOPSIS",
         ),
         get_ranking20(),
     )
Ejemplo n.º 20
0
 def test_mew_vic(self):
     """
     Test the integration with the MEW scoring method and VIC weighting
     method.
     """
     x_matrix, alt_names = mcdm.load(
         os.path.join(DIR_PATH, "data", "example09.tsv"),
         delimiter="\t",
         skiprows=1,
         labeled_rows=True,
     )
     self.assertAlmostEqualRankings(
         mcdm.rank(
             x_matrix,
             alt_names=alt_names,
             w_method="VIC",
             s_method="MEW",
         ),
         get_ranking16(),
     )
Ejemplo n.º 21
0
 def test_mew_vic_linear1(self):
     """
     Test the integration with the MEW scoring method, the VIC weighting
     method, and the Linear1 normalization method.
     """
     x_matrix, alt_names = mcdm.load(
         os.path.join(DIR_PATH, "data", "example08.tsv"),
         delimiter="\t",
         labeled_rows=True,
     )
     self.assertAlmostEqualRankings(
         mcdm.rank(
             x_matrix,
             alt_names=alt_names,
             n_method="Linear1",
             w_method="VIC",
             s_method="MEW",
         ),
         get_ranking23(),
     )
Ejemplo n.º 22
0
 def test_mtopsis_em_linear3(self):
     """
     Test the integration with the mTOPSIS scoring method, the EM weighting
     method, and the Linear3 normalization method.
     """
     x_matrix, alt_names = mcdm.load(
         os.path.join(DIR_PATH, "data", "example08.tsv"),
         delimiter="\t",
         labeled_rows=True,
     )
     self.assertAlmostEqualRankings(
         mcdm.rank(
             x_matrix,
             alt_names=alt_names,
             n_method="Linear3",
             w_method="EM",
             s_method="mTOPSIS",
         ),
         get_ranking22(),
     )