Read costs matrix and preprocess it

This commit is contained in:
Dimitri Lozeve 2020-02-18 22:43:37 +01:00
parent f7f1db9246
commit e9e7f927ab
2 changed files with 10 additions and 0 deletions

View file

@ -4,6 +4,7 @@ authors = ["Dimitri Lozeve <dimitri@lozeve.com>"]
version = "0.1.0" version = "0.1.0"
[deps] [deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
[compat] [compat]

View file

@ -1,5 +1,6 @@
module GardenOptim module GardenOptim
using CSV
using Logging using Logging
export update! export update!
@ -46,5 +47,13 @@ function update!(grid::Array{Int, 2}, costs::Array{Float64, 2}, beta::Float64 =
grid grid
end end
function loadcosts()
df = CSV.read("data/costs.csv")
df = coalesce.(df, 0) # replace missing values by 0
costs = convert(Matrix, df[:, 2:end])
@debug "cost matrix of size $(size(costs))"
# ensure the matrix is symmetric: keep the max of itself and its transpose
costs = max.(costs, permutedims(costs))
end
end # module end # module