Skip to content

Commit 60a580e

Browse files
committed
fix
1 parent a5e7e99 commit 60a580e

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

src/OptimizationProblems.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ for file in files
1616
end
1717
number_of_problems = length(files)
1818

19-
const names = [
19+
const cols_names = [
2020
:nvar
2121
:variable_nvar
2222
:ncon
@@ -82,9 +82,9 @@ The following keys are valid:
8282
- `defined_everywhere::Union{Bool, Missing}`: true if the objective is define for all values of the variables
8383
- `origin::Symbol`: origin of the problem, in [:academic, :modelling, :real, :unknown]
8484
"""
85-
const meta = DataFrame(names .=> [Array{T}(undef, number_of_problems) for T in types])
85+
const meta = DataFrame(cols_names .=> [Array{T}(undef, number_of_problems) for T in types])
8686

87-
for name in names, i = 1:number_of_problems
87+
for name in cols_names, i = 1:number_of_problems
8888
meta[!, name][i] = eval(Meta.parse("$(split(files[i], ".")[1])_meta"))[name]
8989
end
9090

test/runtests.jl

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ addprocs(np - 1)
99

1010
@everywhere import ADNLPModels
1111

12-
@everywhere include("test-defined-problems.jl")
12+
@everywhere function defined_names(mod::Module)
13+
# Exported only (default) + actually defined. Adjust all=true if you prefer.
14+
[n for n in names(mod) if isdefined(mod, n)]
15+
end
16+
17+
const list_problems =
18+
setdiff(union(defined_names(ADNLPProblems), defined_names(PureJuMP)), [:PureJuMP, :ADNLPProblems])
19+
20+
# The problems included should be carefully argumented and issues
21+
# to create them added.
22+
# TODO: tests are limited for JuMP-only problems
23+
const list_problems_not_ADNLPProblems = Symbol[]
24+
const list_problems_ADNLPProblems = setdiff(list_problems, list_problems_not_ADNLPProblems)
25+
const list_problems_not_PureJuMP = Symbol[]
26+
const list_problems_PureJuMP = setdiff(list_problems, list_problems_not_PureJuMP)
27+
28+
include("test-defined-problems.jl")
1329
@everywhere include("test-utils.jl")
1430

1531
@test ndef == OptimizationProblems.PureJuMP.default_nvar
@@ -69,10 +85,16 @@ end
6985
end
7086
end
7187

72-
if prob in list_problems_PureJuMP
88+
model = begin
89+
mod = PureJuMP
90+
if isdefined(mod, prob)
91+
getfield(mod, prob)(n = ndef)
92+
else
93+
nothing
94+
end
95+
end
96+
if !isnothing(model)
7397
@testset "Test problems compatibility for $prob" begin
74-
prob_fn = eval(Meta.parse("PureJuMP.$(prob)"))
75-
model = prob_fn(n = ndef)
7698
nlp_jump = MathOptNLPModel(model)
7799
test_compatibility(prob, nlp_jump, nlp_ad, ndef)
78100
end

test/test-defined-problems.jl

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
@everywhere function defined_names(mod::Module)
2-
# Exported only (default) + actually defined. Adjust all=true if you prefer.
3-
[n for n in names(mod) if isdefined(mod, n)]
4-
end
5-
6-
@everywhere const list_problems =
7-
intersect(defined_names(ADNLPProblems), defined_names(PureJuMP))
8-
9-
# The problems included should be carefully argumented and issues
10-
# to create them added.
11-
# TODO: tests are limited for JuMP-only problems
12-
@everywhere const list_problems_not_ADNLPProblems = Symbol[]
13-
@everywhere const list_problems_not_PureJuMP = Symbol[]
14-
15-
@everywhere const list_problems_ADNLPProblems =
16-
setdiff(list_problems, list_problems_not_ADNLPProblems)
17-
18-
@everywhere const list_problems_PureJuMP =
19-
setdiff(list_problems, list_problems_not_PureJuMP)
20-
21-
@test setdiff(union(names(ADNLPProblems), list_problems_not_ADNLPProblems), list_problems) ==
22-
[:ADNLPProblems]
23-
@test setdiff(union(names(PureJuMP), list_problems_not_PureJuMP), list_problems) ==
24-
[:PureJuMP]
25-
261
@everywhere function probe_missing(mod::Module, syms::Vector{Symbol})
272
missing = Symbol[]
283
for s in syms
@@ -33,16 +8,25 @@ end
338
return (pid = myid(), missing = missing)
349
end
3510

11+
const list_problems_ADNLPProblems =
12+
setdiff(list_problems, list_problems_not_ADNLPProblems)
3613
probes = @sync begin
3714
for pid in workers()
3815
@async remotecall_fetch(probe_missing, pid, ADNLPProblems, list_problems_ADNLPProblems)
3916
end
4017
end
4118
@info "ADNLPProblems missing per worker" probes
4219

20+
const list_problems_PureJuMP =
21+
setdiff(list_problems, list_problems_not_PureJuMP)
4322
probes = @sync begin
4423
for pid in workers()
4524
@async remotecall_fetch(probe_missing, pid, PureJuMP, list_problems_PureJuMP)
4625
end
4726
end
4827
@info "PureJuMP missing per worker" probes
28+
29+
@test setdiff(union(names(ADNLPProblems), list_problems_not_ADNLPProblems), list_problems) ==
30+
[:ADNLPProblems]
31+
@test setdiff(union(names(PureJuMP), list_problems_not_PureJuMP), list_problems) ==
32+
[:PureJuMP]

0 commit comments

Comments
 (0)