Skip to content

Commit

Permalink
add documentation for grey mcdm
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed May 2, 2024
1 parent 6f4ec37 commit 11250a0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/src/greynumbers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Multiple-criteria Decision Making Tools with Grey Numbers


# A grey number
## A grey number

```julia
julia> a = GreyNumber(1, 4)
Expand Down Expand Up @@ -35,6 +35,18 @@ julia> a * -1
GreyNumber(-4, -1)
```


## whitenize
```@docs
JMcDM.whitenize
```


## kernel
```@docs
JMcDM.kernel
```

# MCDM Tools with Grey Numbers

## Grey Topsis
Expand Down
47 changes: 47 additions & 0 deletions src/greynumber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,63 @@ function Base.getindex(g::GreyNumber, index::Int)::Real
end


"""
kernel(g::GreyNumber)::Float64
# Description
Calculate the kernel of a grey number
# Arguments
- `g::GreyNumber`: A grey number
# Examples
```julia
julia> g = GreyNumber(1, 2)
GreyNumber(1, 2)
julia> kernel(g)
1.5
```
"""
function kernel(g::GreyNumber)::Float64
return (g.a + g.b) / 2.0
end


"""
whitenizate(g::GreyNumber; t::Float64 = 0.5):: Float64
# Description
Whitenizate a grey number
# Arguments
- `g::GreyNumber`: A grey number
- `t::Float64`: A value between 0 and 1. Default is 0.5.
# Examples
```julia
julia> g = GreyNumber(1, 2)
GreyNumber(1, 2)
julia> whitenizate(g)
1.5
```
"""
function whitenizate(g::GreyNumber; t::Float64 = 0.5)::Float64
@assert 0.0 <= t <= 1.0
return g.a * t + g.b * (1.0 - t)
end


function Base.zero(::Type{GreyNumber})
return GreyNumber(0.0, 0.0)
end
Expand Down

0 comments on commit 11250a0

Please sign in to comment.