From da542bece8f03303a0afe8a9b955cf82a52285b5 Mon Sep 17 00:00:00 2001 From: juanbc Date: Fri, 6 May 2022 21:32:42 -0300 Subject: [PATCH] docs done --- CHANGELOG.md | 7 +++-- docs/source/_dynamic/CHANGELOG.rst | 9 ++++-- docs/source/refs.bib | 29 ++++++++++++++++++ skcriteria/madm/_base.py | 4 +-- skcriteria/madm/electre.py | 49 +++++++++++++++++++++++++++--- 5 files changed, 86 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 185394a..36b171a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ ## Version 0.7 - **New method**: `ELECTRE2`. - +- **New preprocessin strategy:** A new way to transform from minimization to + maximization criteria: `NegateMinimize()` which reverses the sign of the + values of the criteria to be minimized (useful for not breaking distance + relations in methods like *TOPSIS*). Additionally the previous we rename the + `MinimizeToMaximize()` transformer to `InvertMinimize()`. - Now the `RankingResult`, support repeated/tied rankings and some were implemented to deal with these cases. @@ -13,7 +17,6 @@ - `RankingResult.ties_` to see how often values are repeated. - `RankingResult.untided_rank_` to get a ranking with no repeated values. repeated values. - - `KernelResult` now implements several new properties: - `kernel_alternatives_` to know which alternatives are in the kernel. diff --git a/docs/source/_dynamic/CHANGELOG.rst b/docs/source/_dynamic/CHANGELOG.rst index 07addc2..141db55 100644 --- a/docs/source/_dynamic/CHANGELOG.rst +++ b/docs/source/_dynamic/CHANGELOG.rst @@ -4,9 +4,12 @@ Version 0.7 ----------- -* - **New method**\ : ``ELECTRE2``. - +* **New method**\ : ``ELECTRE2``. +* **New preprocessin strategy:** A new way to transform from minimization to + maximization criteria: ``NegateMinimize()`` which reverses the sign of the + values of the criteria to be minimized (useful for not breaking distance + relations in methods like *TOPSIS*\ ). Additionally the previous we rename the + ``MinimizeToMaximize()`` transformer to ``InvertMinimize()``. * Now the ``RankingResult``\ , support repeated/tied rankings and some were implemented to deal with these cases. diff --git a/docs/source/refs.bib b/docs/source/refs.bib index ee87afd..f0349de 100644 --- a/docs/source/refs.bib +++ b/docs/source/refs.bib @@ -30,6 +30,35 @@ @article{roy1968classement publisher = {EDP Sciences} } +@book{gomez2004tomada, + author = {Gomes, Luiz and González-Araya, Marcela and Carignano, Claudia}, + year = {2004}, + month = {11}, + pages = {}, + title = {Tomada de decisões em cenários complexos}, + isbn = {85-221-0354-2}, + publisher = {Thomson} +} + + +@article{roy1971methode, + title = {La m{\'e}thode Electre II}, + author = {Roy, Bernard and Bertier, Patrice}, + journal = {Note de travail}, + volume = {142}, + year = {1971} +} + +@article{roy1973methode, + title = {La M{\'e}thode ELECTRE II(Une application au m{\'e}dia-planning...)}, + author = {Roy, Bertier and Bertier, Patrice}, + year = {1973}, + journal = {VII {\`e}me Conf{\`e}rence internationale de recherch{\'e} op{\'e}rationalle}, + publisher = {Metra international} +} + + + % skcriteria.madm.moora @article{brauers2006moora, diff --git a/skcriteria/madm/_base.py b/skcriteria/madm/_base.py index 3a41277..8419e48 100644 --- a/skcriteria/madm/_base.py +++ b/skcriteria/madm/_base.py @@ -221,7 +221,7 @@ def _validate_result(self, values): @property def has_ties_(self): - """True if two alternatives shares the same ranking.""" + """Return True if two alternatives shares the same ranking.""" values = self.values return len(np.unique(values)) != len(values) @@ -291,7 +291,7 @@ def kernel_(self): @property def kernel_size_(self): - """How many alternatives has the kernel""" + """How many alternatives has the kernel.""" return np.sum(self.kernel_) @property diff --git a/skcriteria/madm/electre.py b/skcriteria/madm/electre.py index 864bdad..a9cb532 100644 --- a/skcriteria/madm/electre.py +++ b/skcriteria/madm/electre.py @@ -124,7 +124,7 @@ def electre1(matrix, objectives, weights, p=0.65, q=0.35): class ELECTRE1(SKCDecisionMakerABC): - """Find a the kernel solution through ELECTRE-1. + """Find a kernel of alternatives through ELECTRE-1. The ELECTRE I model find the kernel solution in a situation where true criteria and restricted outranking relations are given. @@ -198,7 +198,16 @@ def _make_result(self, alternatives, values, extra): def weights_outrank(matrix, weights, objectives): + """Calculate a matrix of comparison of alternatives where the value of \ + each cell determines how many times the value of the criteria weights of \ + the row alternative exceeds those of the column alternative. + Notes + ----- + For more information about this matrix please check "Tomada de decisões em + cenários complexos" :cite:p:`gomez2004tomada`, p. 100 + + """ alt_n = len(matrix) alt_combs = it.combinations(range(alt_n), 2) outrank = np.full((alt_n, alt_n), False, dtype=bool) @@ -230,8 +239,6 @@ def _electre2_ranker( alt_n, original_outrank_s, original_outrank_w, invert_ranking ): - # Here we create the ranking loop - # here we store the final rank ranking = np.zeros(alt_n, dtype=int) @@ -294,7 +301,6 @@ def electre2( matrix, objectives, weights, p0=0.65, p1=0.5, p2=0.35, q0=0.65, q1=0.35 ): """Execute ELECTRE2 without any validation.""" - matrix_concordance = concordance(matrix, objectives, weights) matrix_discordance = discordance(matrix, objectives) matrix_wor = weights_outrank(matrix, objectives, weights) @@ -340,7 +346,40 @@ def electre2( class ELECTRE2(SKCDecisionMakerABC): - """Find a the rankin solution through ELECTRE-2.""" + """Find the rankin solution through ELECTRE-2. + + ELECTRE II was proposed by Roy and Bertier (1971-1973) to overcome ELECTRE + I's inability to produce a ranking of alternatives. Instead of simply + finding the kernel set, ELECTRE II can order alternatives by introducing + the strong and the weak outranking relations. + + Notes + ----- + This implementation is based on the one presented in the book + "Tomada de decisões em cenários complexos" :cite:p:`gomez2004tomada`. + + Parameters + ---------- + p0, p1, p2 : float, optional (default=0.65, 0.5, 0.35) + Matching thresholds. These are the thresholds that indicate the extent + to which an alternative can be considered equivalent, good or very good + with respect to another alternative. + + These thresholds must meet the condition "1 >= p0 >= p1 >= p2 >= 0". + + q0, q1 : float, optional (default=0.65, 0.35) + Discordance threshold. Threshold of the degree to which an alternative + is equivalent, preferred or strictly preferred to another alternative. + + These thresholds must meet the condition "1 >= q0 >= q1 >= 0". + + References + ---------- + :cite:p:`gomez2004tomada` + :cite:p:`roy1971methode` + :cite:p:`roy1973methode` + + """ _skcriteria_parameters = ["p0", "p1", "p2", "q0", "q1"]