Exemple #1
0
def test_normalize_priorities_1():
    criteria_pr = np.array([[1.0], [2.0], [3.0]])
    global_pr = np.array([1.0, 2.0, 3.0])

    result = normalize_priorities(criteria_pr, global_pr)
    expected = np.array([14.0])

    assert np.array_equal(expected, result)
Exemple #2
0
    def get_priorities(self):
        """Get the priority of the nodes in the level below this node.

        Returns:
            Priorities at current level, normalized if an internal node.
        """
        p_m = np.array(self.preference_matrices[self.p_m_key])
        p_m = to_reciprocal_matrix(p_m)
        sub_crit_pr = self.solver.estimate(p_m)

        if self.leaf:
            return sub_crit_pr

        criteria_pr = [criterion.get_priorities() for criterion in self.sub_criteria]

        return normalize_priorities(criteria_pr, sub_crit_pr)
Exemple #3
0
    def get_priorities(self, round_results=True, decimals=3):
        """Get the priority of the nodes in the level below this node.

        Args:
            round_results (bool): Return rounded priorities. Default is True.
            decimals (int): Number of decimals to round to, ignored if `round_results=False`. Default is 3.

        Returns:
            Global priorities of the alternatives in the model, rounded to `decimals` positions if `round_results=True`.
        """
        crit_pm = np.array(self.preference_matrices['criteria'])
        crit_pr = self.solver.estimate(crit_pm)

        crit_attr_pr = [criterion.get_priorities() for criterion in self.criteria]
        priorities = normalize_priorities(crit_attr_pr, crit_pr)

        if round_results:
            return np.around(priorities, decimals=decimals)

        return priorities
Exemple #4
0
    def get_priorities(self):
        """Get the priority of the nodes in the level below this node.

        Returns:
            Priorities at current level, normalized if an internal node.
        """
        pp = pprint.PrettyPrinter(indent=4)
        p_m = np.array(self.preference_matrices[self.p_m_key])
        sub_crit_pr = self.solver.estimate(p_m)
        pp.pprint(sub_crit_pr)

        if self.leaf:
            return sub_crit_pr

        criteria_pr = [
            criterion.get_priorities() for criterion in self.sub_criteria
        ]
        pp.pprint(criteria_pr)

        return normalize_priorities(criteria_pr, sub_crit_pr)