Add files with expressions, parser, Nikuradse dataset and a new test case.

This commit is contained in:
Gabriel Kronberger
2025-04-18 08:19:22 +02:00
parent 6ab826cc42
commit 293c5f13a4
14 changed files with 689 additions and 0 deletions

View File

@ -1,5 +1,9 @@
using LinearAlgebra
using BenchmarkTools
using DelimitedFiles
using GZip
include("parser.jl") # to parse expressions from a file
function test_cpu_interpreter(nrows; parallel = false)
exprs = [
@ -45,3 +49,27 @@ end
@test test_cpu_interpreter(1000, parallel=true) # start julia -t 6 for six threads
@test test_cpu_interpreter(10000)
@test test_cpu_interpreter(10000, parallel=true)
function test_cpu_interpreter_nikuradse()
data,varnames = readdlm("data/nikuradse_1.csv", ',', header=true);
X = convert(Matrix{Float32}, data)
exprs = Expr[]
parameters = Vector{Vector{Float32}}()
varnames = ["x$i" for i in 1:10]
paramnames = ["p$i" for i in 1:20]
# data/esr_nvar2_len10.txt.gz_9.txt.gz has ~250_000 exprs
# data/esr_nvar2_len10.txt.gz_10.txt.gz has ~800_000 exrps
GZip.open("data/esr_nvar2_len10.txt.gz_9.txt.gz") do io
for line in eachline(io)
expr, p = parse_infix(line, varnames, paramnames)
push!(exprs, expr)
push!(parameters, randn(Float32, length(p)))
end
end
interpret_cpu(exprs, X, parameters) # TODO: sufficient to do up to 10 repetitions per expression,
end