Skip to content

Commit fe85bce

Browse files
committed
replace Array{T,1} and Array{T, 2} with Vector{T} and Matrix{T}, respectively
1 parent 7b12761 commit fe85bce

File tree

12 files changed

+34
-33
lines changed

12 files changed

+34
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Make initial solution optional in Transportation problems
44
- Add tests for the shortest problem problem
55
- Add a 100x100 test problem for assignment
6+
- Replace `Array{Type, 1}` and `Array{Type, 2}` with `Vector{T}` and `Matrix{Type}`, respectively
67

78

89
### 0.2.5

src/assignment.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import ..OperationsResearchModels: solve
1414
1515
# Arguments
1616
17-
- `costs::Array{T,2}`: The cost matrix of the assignment problem.
17+
- `costs::Matrix{T}`: The cost matrix of the assignment problem.
1818
1919
# Description
2020
2121
The `AssignmentProblem` struct represents an assignment problem with a cost matrix.
2222
"""
2323
struct AssignmentProblem{T<:Real}
24-
costs::Array{T,2}
24+
costs::Matrix{T}
2525
end
2626

2727

src/cpm.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function findpertactivities(
226226
pertactivities::Vector{PertActivity},
227227
)
228228
L = length(cpmpath)
229-
perts = Array{PertActivity,1}(undef, L)
229+
perts = Vector{PertActivity}(undef, L)
230230
for i = 1:L
231231
currentcpmactivity = cpmpath[i]
232232
pertactivity = filter(x -> x.name == currentcpmactivity.name, pertactivities)[1]
@@ -284,7 +284,7 @@ function solve(problem::PertProblem)::PertResult
284284

285285
L = length(activities)
286286

287-
cpmactivities = Array{CpmActivity,1}(undef, L)
287+
cpmactivities = Vector{CpmActivity}(undef, L)
288288

289289
for i = 1:L
290290
current::PertActivity = activities[i]

src/game.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424

2525

2626
"""
27-
game(decisionMatrix::Matrix{<:Real}; verbose::Bool = false)::Array{GameResult,1}
27+
game(decisionMatrix::Matrix{<:Real}; verbose::Bool = false)::Vector{GameResult}
2828
2929
Solves a zero-sum game using the simplex method.
3030
@@ -36,7 +36,7 @@ end
3636
# Returns
3737
- An array of `GameResult` objects containing the probabilities and value of the game.
3838
"""
39-
function game(decisionMatrix::Matrix{<:Real}; verbose::Bool = false)::Array{GameResult,1}
39+
function game(decisionMatrix::Matrix{<:Real}; verbose::Bool = false)::Vector{GameResult}
4040
rowplayers_result = game_solver(decisionMatrix, verbose = verbose)
4141
columnplayers_result = game_solver(Matrix(decisionMatrix') * -1.0, verbose = verbose)
4242
return [rowplayers_result, columnplayers_result]

src/johnsons.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function makespan(times::Matrix, permutation::Vector{Int})::Float64
227227

228228
n, m = size(times)
229229

230-
timetable = Array{Process,2}(undef, m, n)
230+
timetable = Matrix{Process}(undef, m, n)
231231

232232
for machine_id in 1:m
233233
for task_id in 1:n

src/maximumflow.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ export MaximumFlowResult
1111

1212

1313
struct MaximumFlowResult
14-
path::Array{Connection,1}
14+
path::Vector{Connection}
1515
flow::Float64
1616
end
1717

1818
struct MaximumFlowProblem
19-
connections::Array{Connection,1}
19+
connections::Vector{Connection}
2020
end
2121

2222

@@ -69,7 +69,7 @@ function solve(problem::MaximumFlowProblem)
6969

7070
cns = problem.connections
7171

72-
function leftexpressions(node::Int64, nodes::Array{Connection,1}, model)
72+
function leftexpressions(node::Int64, nodes::Vector{Connection}, model)
7373
lst = []
7474
for conn in nodes
7575
if conn.to == node
@@ -86,7 +86,7 @@ function solve(problem::MaximumFlowProblem)
8686
return expr
8787
end
8888

89-
function rightexpressions(node::Int64, nodes::Array{Connection,1}, model)
89+
function rightexpressions(node::Int64, nodes::Vector{Connection}, model)
9090
lst = []
9191
for conn in nodes
9292
if conn.from == node

src/network.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct Connection
1818
end
1919

2020

21-
function nodes(cns::Array{Connection,1})::Set{Int64}
21+
function nodes(cns::Vector{Connection})::Set{Int64}
2222
s = Set{Int64}()
2323
for conn in cns
2424
push!(s, conn.from)
@@ -27,7 +27,7 @@ function nodes(cns::Array{Connection,1})::Set{Int64}
2727
return s
2828
end
2929

30-
function iseveronleft(cns::Array{Connection,1}, n::Int64)::Bool
30+
function iseveronleft(cns::Vector{Connection}, n::Int64)::Bool
3131
for conn in cns
3232
if conn.from == n
3333
return true
@@ -36,7 +36,7 @@ function iseveronleft(cns::Array{Connection,1}, n::Int64)::Bool
3636
return false
3737
end
3838

39-
function iseveronright(cns::Array{Connection,1}, n::Int64)::Bool
39+
function iseveronright(cns::Vector{Connection}, n::Int64)::Bool
4040
for conn in cns
4141
if conn.to == n
4242
return true
@@ -45,7 +45,7 @@ function iseveronright(cns::Array{Connection,1}, n::Int64)::Bool
4545
return false
4646
end
4747

48-
function finish(cns::Array{Connection,1})::Int64
48+
function finish(cns::Vector{Connection})::Int64
4949
nodeset = nodes(cns)
5050
for n in nodeset
5151
if !iseveronleft(cns, n)
@@ -55,7 +55,7 @@ function finish(cns::Array{Connection,1})::Int64
5555
error("No finish node found in connection list.")
5656
end
5757

58-
function start(cns::Array{Connection,1})::Int64
58+
function start(cns::Vector{Connection})::Int64
5959
nodeset = nodes(cns)
6060
for n in nodeset
6161
if !iseveronright(cns, n)

src/shortestpath.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export ShortestPathResult
1212

1313

1414
struct ShortestPathProblem
15-
connections::Array{Connection,1}
15+
connections::Vector{Connection}
1616
end
1717

1818
struct ShortestPathResult
19-
path::Array{Connection,1}
19+
path::Vector{Connection}
2020
cost::Float64
2121
end
2222

@@ -68,7 +68,7 @@ function solve(problem::ShortestPathProblem)
6868

6969
cns = problem.connections
7070

71-
function leftexpressions(node::Int64, nodes::Array{Connection,1}, model)
71+
function leftexpressions(node::Int64, nodes::Vector{Connection}, model)
7272
lst = []
7373
for conn in nodes
7474
if conn.to == node
@@ -85,7 +85,7 @@ function solve(problem::ShortestPathProblem)
8585
return expr
8686
end
8787

88-
function rightexpressions(node::Int64, nodes::Array{Connection,1}, model)
88+
function rightexpressions(node::Int64, nodes::Vector{Connection}, model)
8989
lst = []
9090
for conn in nodes
9191
if conn.from == node

src/simplex.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end
4747

4848
function SimplexProblem()::SimplexProblem
4949
SimplexProblem(
50-
Array{Float64,2}(undef, 0, 0), # LHS
50+
Matrix{Float64}(undef, 0, 0), # LHS
5151
Float64[], # RHS
5252
Float64[], # z
5353
Maximize, # opttype
@@ -108,7 +108,7 @@ end
108108

109109
function setautomaticvarnames(s::SimplexProblem)
110110
_, p = size(s.lhs)
111-
s.varnames = Array{String,1}(undef, p)
111+
s.varnames = Vector{String}(undef, p)
112112
for i = 1:p
113113
s.varnames[i] = string("x", i)
114114
end
@@ -425,7 +425,7 @@ function solve!(s::SimplexProblem)::SimplexProblem
425425
end
426426

427427
function simplexiterations(s::SimplexProblem)::Vector{SimplexProblem}
428-
iterations = Array{SimplexProblem,1}(undef, 0)
428+
iterations = Vector{SimplexProblem}(undef, 0)
429429

430430
s1 = copy(s)
431431
standardform!(s1)

src/transportation.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ import ..OperationsResearchModels: solve
1919
2020
# Arguments
2121
22-
- `costs::Array{T,2}`: The cost matrix of the transportation problem.
23-
- `demand::Array{T,1}`: The demand vector of the transportation problem.
24-
- `supply::Array{T,1}`: The supply vector of the transportation problem.
22+
- `costs::Matrix{T}`: The cost matrix of the transportation problem.
23+
- `demand::Vector{T}`: The demand vector of the transportation problem.
24+
- `supply::Vector{T}`: The supply vector of the transportation problem.
2525
2626
# Description
2727
2828
The `TransportationProblem` struct represents a transportation problem with a cost matrix, demand vector, and supply vector.
2929
"""
3030
mutable struct TransportationProblem{T<:Real}
31-
costs::Array{T,2}
32-
demand::Array{T,1}
33-
supply::Array{T,1}
31+
costs::Matrix{T}
32+
demand::Vector{T}
33+
supply::Vector{T}
3434
end
3535

3636

0 commit comments

Comments
 (0)