Skip to content

Commit

Permalink
mcdm() with default MCDM method
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Jun 1, 2022
1 parent d740c82 commit 417a2d6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 0.4.2 (Upcoming release)
- game() now returns solution vector for both players
- mcdm() function receives TopsisMethod() as default argument

### 0.4.1
- Update documents for CRITIC method
Expand Down
9 changes: 5 additions & 4 deletions src/mcdm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ end


"""
mcdm(setting, method)
mcdm(setting, method = TopsisMethod())
Perform selected method for a given decision matrix, weight vector, and function list.
# Arguments:
- `setting::MCDMSetting`: MCDMSetting object that holds the decision matrix, weight vector, and functions.
- `method::MCDMMethod`: Preferred MCDMMethod.
- `method::MCDMMethod`: Preferred MCDMMethod. The default is TopsisMethod().
# Description
The method is one of the subtypes of MCDMMethod type. See examples.
Expand All @@ -137,8 +137,9 @@ julia> # mcdm(setting, GreyMethod(0.6))
```
"""
function mcdm(setting::MCDMSetting,
method::T1)::MCDMResult where {T1 <: MCDMMethod}
function mcdm(
setting::MCDMSetting,
method::T1 = TopsisMethod())::MCDMResult where {T1 <: MCDMMethod}

mcdm(
setting.df,
Expand Down
21 changes: 21 additions & 0 deletions test/testmcdm.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
@testset "MCDM functions" begin

@testset "mcdm() with default method" begin
tol = 0.00001
df = DataFrame()
df[:, :x] = Float64[9, 8, 7]
df[:, :y] = Float64[7, 7, 8]
df[:, :z] = Float64[6, 9, 6]
df[:, :q] = Float64[7, 6, 6]
w = Float64[4, 2, 6, 8]

fns = makeminmax([maximum, maximum, maximum, maximum])

result = topsis(df, w, fns)

setting = MCDMSetting(df, w, fns)
result2 = mcdm(setting)

@test isa(result2, TopsisResult)
@test result2.bestIndex == result.bestIndex
@test result2.scores == result.scores
end

@testset "MOOSRA" begin
tol = 0.0001

Expand Down

1 comment on commit 417a2d6

@jmejia8
Copy link
Contributor

@jmejia8 jmejia8 commented on 417a2d6 Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly what I need. Thank you :)

Please sign in to comment.