Skip to content

Commit

Permalink
fixed type-inf in johnson's rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed May 21, 2024
1 parent bfde609 commit 58f4349
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### 0.2.1 (Upcoming Release)

- Typed Inf used instead of Inf64 in Johnson's rule.


### 0.2.1

Expand Down
5 changes: 4 additions & 1 deletion src/johnsons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ function johnsons_2machines(timesmatrix::Matrix)::JohnsonResult
times = copy(timesmatrix)
n, m = size(times)
@assert m == 2

typed_inf = typemax(eltype(times))

permutation = [-1 for i in 1:n]
for i in 1:n
locrow, loccol = argmin(times).I
Expand All @@ -100,7 +103,7 @@ function johnsons_2machines(timesmatrix::Matrix)::JohnsonResult
else
dolast!(locrow, permutation)
end
times[locrow, :] .= Inf
times[locrow, :] .= typed_inf
end
return JohnsonResult(permutation)
end
Expand Down
19 changes: 19 additions & 0 deletions test/testjohnsons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,24 @@

end

@testset "Other types of matrices (Int)" begin

mat = rand(1:10, 10, 2)

result = johnsons(mat)

# expect no error
@test true
end

@testset "Other types of matrices (UInt8)" begin

mat = convert(Array{UInt8, 2}, rand(1:10, 10, 2))

result = johnsons(mat)

# expect no error
@test true
end

end

0 comments on commit 58f4349

Please sign in to comment.