Skip to content

Commit

Permalink
add exclude in unconstrained check
Browse files Browse the repository at this point in the history
  • Loading branch information
tmigot committed Jul 23, 2021
1 parent ed33693 commit a7ff2ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/nlp/consistency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function consistent_nlps(
)
consistent_counters(nlps)
test_meta && consistent_meta(nlps, rtol = rtol)
unconstrained_api(nlps)
unconstrained_api(nlps, exclude = exclude)
consistent_functions(nlps, rtol = rtol, exclude = exclude)
consistent_counters(nlps)
for nlp in nlps
Expand Down Expand Up @@ -60,19 +60,19 @@ function consistent_nlps(
end
end

function unconstrained_api(nlps)
function unconstrained_api(nlps; exclude = [])
for nlp in nlps
if nlp.meta.ncon == 0
x1 = ones(nlp.meta.nvar)
x0, x1 = nlp.meta.x0, ones(nlp.meta.nvar)
@test nlp.meta.nnzj == 0
@test cons(nlp, nlp.meta.x0) == []
@test jac_coord(nlp, nlp.meta.x0) == []
@test jac_structure(nlp) == ([], [])
@test jac(nlp, nlp.meta.x0) == zeros(0, nlp.meta.nvar)
@test all(jtprod(nlp, nlp.meta.x0, nlp.meta.y0) .== 0)
@test jprod(nlp, nlp.meta.x0, x1) == []
@test hess(nlp, nlp.meta.x0, ones(0)) == hess(nlp, nlp.meta.x0)
@test hprod(nlp, nlp.meta.x0, ones(0), x1) == hprod(nlp, nlp.meta.x0, x1)
@test cons exclude ? cons(nlp, x0) == [] : true
@test jac_coord exclude ? jac_coord(nlp, x0) == [] : true
@test jac_coord exclude ? jac_structure(nlp) == ([], []) : true
@test jac exclude ? jac(nlp, x0) == zeros(0, nlp.meta.nvar) : true
@test jtprod exclude ? all(jtprod(nlp, x0, nlp.meta.y0) .== 0) : true
@test jprod exclude ? jprod(nlp, x0, x1) == [] : true
@test hess exclude ? hess(nlp, x0, ones(0)) == hess(nlp, x0) : true
@test hprod exclude ? hprod(nlp, x0, ones(0), x1) == hprod(nlp, x0, x1) : true
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/nls/consistency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function consistent_nlss(
reset!(nls)
end
consistent_functions(nlss, exclude = exclude)
unconstrained_api(nlss)
unconstrained_api(nlss, exclude = exclude)

if test_slack && has_inequalities(nlss[1])
reset!.(nlss)
Expand Down

0 comments on commit a7ff2ac

Please sign in to comment.