Skip to content

Commit

Permalink
Add weak disposal in additive model
Browse files Browse the repository at this point in the history
Add weak input and output disposal in additive model.
  • Loading branch information
javierbarbero committed Mar 17, 2020
1 parent 7f356c9 commit d7e1f10
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
46 changes: 39 additions & 7 deletions src/deaadd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Model specification:
- `WY`: matrix of weights of outputs. Only if `model=:Custom`.
- `Xref=X`: Identifies the reference set of inputs against which the units are evaluated.
- `Yref=Y`: Identifies the reference set of outputs against which the units are evaluated.
- `disposalX=:Strong`: chooses strong disposal of inputs. For weak disposal choose `:Weak`.
- `disposalY=:Strong`: chooses strong disposal of outputs. For weak disposal choose `:Weak`.
# Examples
```jldoctest
Expand Down Expand Up @@ -68,7 +70,8 @@ Weights = MIP
function deaadd(X::Matrix, Y::Matrix, model::Symbol = :Default; orient::Symbol = :Graph,
rts::Symbol = :VRS,
wX::Matrix = Array{Float64}(undef, 0, 0), wY::Matrix = Array{Float64}(undef, 0, 0),
Xref::Matrix = X, Yref::Matrix = Y)::AdditiveDEAModel
Xref::Matrix = X, Yref::Matrix = Y,
disposalX::Symbol = :Strong, disposalY::Symbol = :Strong)::AdditiveDEAModel

# Check parameters
nx, m = size(X)
Expand All @@ -90,6 +93,23 @@ function deaadd(X::Matrix, Y::Matrix, model::Symbol = :Default; orient::Symbol =
error("number of outputs in evaluation set and reference set is different")
end

if disposalX != :Strong && disposalX != :Weak
error("Invalued inputs disposal $disposalX. Disposal should be :Strong or :Weak")
end
if disposalY != :Strong && disposalY != :Weak
error("Invalid outputs disposal $disposalY. Disposal should be :Strong or :Weak")
end

if orient == :Input && disposalX == :Weak
error("Weak input disposal not possible in input oriented model")
end
if orient == :Output && disposalY == :Weak
error("Weak output disposal not possible in output oriented model")
end
if orient == :Graph && (disposalX == :Weak || disposalY == :Weak)
error("Weak disposal not possible in graph oriented model")
end

# Default behaviour
if model == :Default
# If no weights are specified use :Ones
Expand Down Expand Up @@ -140,6 +160,15 @@ function deaadd(X::Matrix, Y::Matrix, model::Symbol = :Default; orient::Symbol =
wX0 = wX[i,:]
wY0 = wY[i,:]

# Set weights to zero if Weak disposal
if disposalX == :Weak
wX0 = zeros(1, n)
end

if disposalY == :Weak
wY0 = zeros(1, n)
end

# Create the optimization model
deamodel = Model(GLPK.Optimizer)

Expand Down Expand Up @@ -209,37 +238,40 @@ end
function deaadd(X::Vector, Y::Matrix, model::Symbol = :Default; orient::Symbol = :Graph,
rts::Symbol = :VRS,
wX::Vector = Array{Float64}(undef, 0), wY::Matrix = Array{Float64}(undef, 0, 0),
Xref::Vector = X, Yref::Matrix = Y)::AdditiveDEAModel
Xref::Vector = X, Yref::Matrix = Y,
disposalX::Symbol = :Strong, disposalY::Symbol = :Strong)::AdditiveDEAModel

X = X[:,:]
wX = wX[:,:]
Xref = Xref[:,:]
return deaadd(X, Y, model, orient = orient, rts = rts, wX = wX, wY = wY, Xref = Xref, Yref = Yref)
return deaadd(X, Y, model, orient = orient, rts = rts, wX = wX, wY = wY, Xref = Xref, Yref = Yref, disposalX = disposalX, disposalY = disposalY)
end

function deaadd(X::Matrix, Y::Vector, model::Symbol = :Default; orient::Symbol = :Graph,
rts::Symbol = :VRS,
wX::Matrix = Array{Float64}(undef, 0, 0), wY::Vector = Array{Float64}(undef, 0),
Xref::Matrix = X, Yref::Vector = Y)::AdditiveDEAModel
Xref::Matrix = X, Yref::Vector = Y,
disposalX::Symbol = :Strong, disposalY::Symbol = :Strong)::AdditiveDEAModel

Y = Y[:,:]
wY = wY[:,:]
Yref = Yref[:,:]
return deaadd(X, Y, model, orient = orient, rts = rts, wX = wX, wY = wY, Xref = Xref, Yref = Yref)
return deaadd(X, Y, model, orient = orient, rts = rts, wX = wX, wY = wY, Xref = Xref, Yref = Yref, disposalX = disposalX, disposalY = disposalY)
end

function deaadd(X::Vector, Y::Vector, model::Symbol = :Default; orient::Symbol = :Graph,
rts::Symbol = :VRS,
wX::Vector = Array{Float64}(undef, 0), wY::Vector = Array{Float64}(undef, 0),
Xref::Vector = X, Yref::Vector = Y)::AdditiveDEAModel
Xref::Vector = X, Yref::Vector = Y,
disposalX::Symbol = :Strong, disposalY::Symbol = :Strong)::AdditiveDEAModel

X = X[:,:]
wX = wX[:,:]
Xref = Xref[:,:]
Y = Y[:,:]
wY = wY[:,:]
Yref = Yref[:,:]
return deaadd(X, Y, model, orient = orient, rts = rts, wX = wX, wY = wY, Xref = Xref, Yref = Yref)
return deaadd(X, Y, model, orient = orient, rts = rts, wX = wX, wY = wY, Xref = Xref, Yref = Yref, disposalX = disposalX, disposalY = disposalY)
end

function Base.show(io::IO, x::AdditiveDEAModel)
Expand Down
22 changes: 22 additions & 0 deletions test/deaadd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,26 @@
@test slacks(deaaddoutput, :X) [0; 0; 0; 0.0; 1.0]
@test slacks(deaaddoutput, :Y) [0; 0; 0; 2.0; 1.0]

# Input orientation with Weak disposal in outputs
deaaddinputweak = deaadd(X, Y, orient = :Input, disposalY = :Weak)
@test efficiency(deaaddinputweak) [0; 0; 0; 0.0; 2.0]
@test slacks(deaaddinputweak, :X) [0; 0; 0; 0.0; 2.0]
@test slacks(deaaddinputweak, :Y) [0; 0; 0; 0.0; 0.0]

# Output orientation with Weak disposal in inputs
deaaddoutputweak = deaadd(X, Y, orient = :Output, disposalX = :Weak)
@test efficiency(deaaddoutputweak) [0; 0; 0; 2.0; 0.0]
@test slacks(deaaddoutputweak, :X) [0; 0; 0; 0.0; 0.0]
@test slacks(deaaddoutputweak, :Y) [0; 0; 0; 2.0; 0.0]

# Test errors with orientation and disposal
@test_throws ErrorException deaadd([12 ; 3], [4 ; 5; 6], orient = :Graph, disposalX = :Error) # Invalid inputs disposal
@test_throws ErrorException deaadd([12 ; 3], [4 ; 5; 6], orient = :Graph, disposalY = :Error) # Invalid output disposal
@test_throws ErrorException deaadd([12 ; 3], [4 ; 5; 6], orient = :Graph, disposalX = :Weak) # Weak disposal not possible in graph oriented model
@test_throws ErrorException deaadd([12 ; 3], [4 ; 5; 6], orient = :Graph, disposalX = :Weak) # Weak disposal not possible in graph oriented model

@test_throws ErrorException deaadd([12 ; 3], [4 ; 5; 6], orient = :Input, disposalX = :Weak) # Weak input disposal not possible in input oriented model

@test_throws ErrorException deaadd([12 ; 3], [4 ; 5; 6], orient = :Output, disposalY = :Weak) # Weak output disposal not possible in output oriented model

end

0 comments on commit d7e1f10

Please sign in to comment.