/
model.jl
60 lines (51 loc) · 1.71 KB
/
model.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# This file contains types and structures for DEA model
"""
AbstractDEAModel
An abstract type representing a DEA model.
"""
abstract type AbstractDEAModel end
"""
nbos(model::Abstract DEAModel)
Return number of observations of a DEA model.
"""
nobs(model::AbstractDEAModel) = model.n
"""
ninputs(model::AbstractDEAModel)
Return number of inputs of a DEA model.
"""
ninputs(model::AbstractDEAModel) = model.m
"""
noutputs(model::AbstractDEAModel)
Return number of outputs of a DEA model.
"""
noutputs(model::AbstractDEAModel) = model.s
"""
names(model::AbstractDEAModel)
Return the names of the decision making units (DMUs)
"""
function Base.names(model::AbstractDEAModel)
xnobs = nobs(model)
if isdefined(model, :dmunames)
if model.dmunames === nothing
# If model have no names, return numeric sequence
retnames = ["$i" for i in 1:xnobs]
else
xnameslength = length(model.dmunames)
if xnameslength == xnobs
retnames = model.dmunames
elseif xnameslength < xnobs
# If length of names is lower than number of observations, append numbers to match
@warn("Length of names lower than number of observations")
retnames = [model.dmunames; ["$i" for i in (xnameslength + 1):xnobs]]
elseif xnameslength > xnobs
# If length of names is greater than number of observations, split
@warn("Length of names greater than number of observations")
retnames = model.dmunames[1:xnobs]
end
end
else
# Return numeric sequence
retnames = ["$i" for i in 1:xnobs]
end
return retnames
end