Skip to content

Commit

Permalink
update copeland and add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Feb 2, 2022
1 parent db936f3 commit f2f8bb6
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.3.4
- Add new tests for Copeland
- Documentation added for Copeland


### 0.3.3
- ROV (Range of Value) Method implemented.

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JMcDM"
uuid = "358108f5-d052-4d0a-8344-d5384e00c0e5"
authors = ["Mehmet Hakan Satman (jbytecode) <[email protected]>", "Bahadir Fatih Yildirim <[email protected]>"]
version = "0.3.3"
version = "0.3.4"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
1 change: 1 addition & 0 deletions src/codas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ end

"""
codas(setting; tau = 0.02)
Apply CODAS (COmbinative Distance-based ASsessment) method for a given matrix, weights and, type of criteria.
# Arguments:
Expand Down
14 changes: 14 additions & 0 deletions src/copeland.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ function winloss_scores(dommat::Array{Int, 2})::Array{Int, 2}
return winlossmat
end

"""
copeland(ordering_mat)
# Arguments
- `ordering_mat`::Array{Int, 2}`: Ordering matrix.
# Description
The function takes an ordering matrix as input. Different ordering results are in columns.
Orderings are in ascending order. The function returns the ranks. The alternative with rank
1 is the winner.
# Output
- `::Array{Int, 1}`: Vector of ranks.
"""
function copeland(ordering_mat::Array{Int, 2})::Array{Int, 1}
winlosses = ordering_mat |> dominance_scores |> winloss_scores
n, _ = size(winlosses)
Expand Down
293 changes: 258 additions & 35 deletions test/testcopeland.jl
Original file line number Diff line number Diff line change
@@ -1,37 +1,260 @@
@testset "Copeland" begin
"""
This example is interpreted from the results of
Arslan, Rahim, and Hüdaverdi Bircan. "Çok Kriterli Karar Verme Teknikleriyle Elde Edilen
Sonuçların Copeland Yöntemiyle Birleştirilmesi ve Karşılaştırılması." Yönetim ve Ekonomi:
Celal Bayar Üniversitesi İktisadi ve İdari Bilimler Fakültesi Dergisi 27.1 (2020): 109-127.
for testing the method.
"""
topsis_ord =
[7, 17, 3, 14, 6, 18, 10, 19, 8, 15, 22, 12, 2, 9, 23, 11, 16, 20, 5, 13, 1, 21, 4]
gia_ord =
[9, 17, 3, 14, 6, 18, 7, 19, 8, 16, 22, 13, 1, 10, 23, 11, 15, 20, 5, 12, 2, 21, 4]
vikor_ord =
[7, 17, 3, 14, 5, 18, 10, 19, 8, 16, 22, 13, 1, 9, 23, 11, 15, 20, 6, 12, 2, 21, 4]
mooraref_ord =
[3, 14, 2, 15, 16, 21, 10, 23, 8, 9, 19, 6, 7, 5, 22, 17, 13, 18, 12, 11, 1, 20, 4]
copras_ord =
[7, 17, 3, 14, 6, 18, 11, 19, 8, 15, 22, 12, 1, 9, 23, 10, 16, 20, 5, 13, 2, 21, 4]
moora_ord =
[7, 17, 3, 14, 5, 18, 11, 19, 8, 15, 22, 12, 1, 9, 23, 10, 16, 20, 6, 13, 2, 21, 4]
aras_ord =
[7, 17, 3, 14, 6, 18, 11, 19, 8, 15, 22, 12, 1, 9, 23, 10, 16, 20, 5, 13, 2, 21, 4]

mat = hcat(topsis_ord, gia_ord, vikor_ord, mooraref_ord)

c = copeland(mat)

d = c |> sortperm

#show(d)
#@info d

@test d == [15, 11, 22, 18, 8, 6, 2, 10, 17, 4, 12, 20, 16, 7, 14, 9, 1, 5, 19, 23, 3, 13, 21]


@testset "Copeland Example 1" begin
"""
This example is interpreted from the results of
Arslan, Rahim, and Hüdaverdi Bircan. "Çok Kriterli Karar Verme Teknikleriyle Elde Edilen
Sonuçların Copeland Yöntemiyle Birleştirilmesi ve Karşılaştırılması." Yönetim ve Ekonomi:
Celal Bayar Üniversitesi İktisadi ve İdari Bilimler Fakültesi Dergisi 27.1 (2020): 109-127.
for testing the method.
"""
topsis_ord = [
7,
17,
3,
14,
6,
18,
10,
19,
8,
15,
22,
12,
2,
9,
23,
11,
16,
20,
5,
13,
1,
21,
4,
]
gia_ord = [
9,
17,
3,
14,
6,
18,
7,
19,
8,
16,
22,
13,
1,
10,
23,
11,
15,
20,
5,
12,
2,
21,
4,
]
vikor_ord = [
7,
17,
3,
14,
5,
18,
10,
19,
8,
16,
22,
13,
1,
9,
23,
11,
15,
20,
6,
12,
2,
21,
4,
]
mooraref_ord = [
3,
14,
2,
15,
16,
21,
10,
23,
8,
9,
19,
6,
7,
5,
22,
17,
13,
18,
12,
11,
1,
20,
4,
]
copras_ord = [
7,
17,
3,
14,
6,
18,
11,
19,
8,
15,
22,
12,
1,
9,
23,
10,
16,
20,
5,
13,
2,
21,
4,
]
moora_ord = [
7,
17,
3,
14,
5,
18,
11,
19,
8,
15,
22,
12,
1,
9,
23,
10,
16,
20,
6,
13,
2,
21,
4,
]
aras_ord = [
7,
17,
3,
14,
6,
18,
11,
19,
8,
15,
22,
12,
1,
9,
23,
10,
16,
20,
5,
13,
2,
21,
4,
]

mat = hcat(topsis_ord, gia_ord, vikor_ord, mooraref_ord)

c = copeland(mat)

d = c |> sortperm

#show(d)
#@info d

@test d == [
15,
11,
22,
18,
8,
6,
2,
10,
17,
4,
12,
20,
16,
7,
14,
9,
1,
5,
19,
23,
3,
13,
21,
]

end


@testset "Copeland Example 2" begin
"""
This example is interpreted from the result of
Özdağoğlu, Aşkın, et al. "Combining different MCDM methods with the Copeland method:
An investigation on motorcycle selection." Journal of process management and new
technologies 9.3-4 (2021): 13-27.
in this test.
"""
mopa_rank = [1, 4, 2, 3]
moosra_rank = [1, 2, 3, 4]
copras_rank = [1, 3, 2, 4]
saw_rank = [1, 3, 2, 4]
wpm_rank = [1, 3, 2, 4]
rov_rank = [4, 1, 2, 3]

mopa_order = reverse(mopa_rank)
moosra_order = reverse(moosra_rank)
copras_order = reverse(copras_rank)
saw_order = reverse(saw_rank)
wpm_order = reverse(wpm_rank)
rov_order = reverse(rov_rank)

mat = hcat(mopa_order, moosra_order, copras_order, saw_order, wpm_order, rov_order)

c = copeland(mat)

d = c |> sortperm

@test d == [1, 3, 2, 4]
end

end

0 comments on commit f2f8bb6

Please sign in to comment.