Skip to content

Commit

Permalink
fixed electre, pump version v0.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Dec 13, 2021
1 parent 202d7e8 commit 121fdca
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
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.2.5"
version = "0.2.6"

[deps]
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
Expand Down
15 changes: 10 additions & 5 deletions src/electre.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@ function electre(decisionMat::DataFrame, weights::Array{Float64,1}, fns::Array{F
r_ik_full = weightednormalizedMat[i, :]
r_jk_full = weightednormalizedMat[j, :]

nom = maximum(abs.(r_ik - r_jk))
dom = maximum(abs.(r_ik_full - r_jk_full))
nonfitnessmatrix[i, j] = nom / dom
end
if length(r_ik) > 0 && length(r_jk) > 0
nom = maximum(abs.(r_ik - r_jk))
dom = maximum(abs.(r_ik_full - r_jk_full))
nonfitnessmatrix[i, j] = nom / dom
else
nonfitnessmatrix[i, j] = Inf64
end # end if

end # end for

C = zeros(Float64, nalternatives)
D = zeros(Float64, nalternatives)
Expand All @@ -153,7 +158,7 @@ function electre(decisionMat::DataFrame, weights::Array{Float64,1}, fns::Array{F
result = ElectreResult(
decisionMat,
w,
weightednormalizedMat,
weightednormalizedMat,
fitnessTable,
nonfitnessTable,
fitnessmatrix,
Expand Down
15 changes: 15 additions & 0 deletions test/testmcdm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,21 @@
@test result3.bestIndex == result.bestIndex
end

@testset "Electre (failed in previous release <= v0.2.5" begin
df = DataFrame(
x = [1.0, 2.0, 3.0, 2.0],
y = [1.0, 2.0, 1.0, 1.0],
z = [1.0, 3.0, 2.0, 2.0],
k = [4.0, 2, 1, 4],
)
fns = makeminmax([maximum, maximum, maximum, maximum])
ws = [0.25, 0.25, 0.25, 0.25]
e = electre(df, ws, fns)

@test e isa ElectreResult
@test e.bestIndex == (2, 1)
end


@testset "MOORA" begin
tol = 0.00001
Expand Down

0 comments on commit 121fdca

Please sign in to comment.