-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathADNLPProblems.jl
More file actions
40 lines (32 loc) · 1.02 KB
/
ADNLPProblems.jl
File metadata and controls
40 lines (32 loc) · 1.02 KB
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
module ADNLPProblems
using Requires
import ..OptimizationProblems: @adjust_nvar_warn
const default_nvar = 100
const data_path = joinpath(@__DIR__, "..", "..", "data")
reshape_array(a, dims) = invoke(Base._reshape, Tuple{AbstractArray, typeof(dims)}, a, dims)
const _data_loaded = Dict{Symbol, Ref{Bool}}()
const _data_locks = Dict{Symbol, ReentrantLock}()
function _ensure_data!(key::Symbol, relpath::AbstractString)
flag = get!(_data_loaded, key, Ref(false))
flag[] && return
lck = get!(_data_locks, key, ReentrantLock())
lock(lck) do
flag[] && return
Base.include(@__MODULE__, joinpath(@__DIR__, "..", "..", "data", relpath))
flag[] = true
end
return
end
@init begin
@require ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a" begin
using JLD2, LinearAlgebra, SparseArrays, SpecialFunctions
path = dirname(@__FILE__)
files = filter(x -> x[(end - 2):end] == ".jl", readdir(path))
for file in files
if file ≠ "ADNLPProblems.jl"
include(file)
end
end
end
end
end