Skip to content

Commit cce9926

Browse files
wildartpkofod
andauthored
fix BoxConstraints call (#125)
* fix BoxConstraints * Update constraints.jl Co-authored-by: Patrick Kofod Mogensen <[email protected]>
1 parent 770fb0b commit cce9926

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/objective_types/constraints.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function Base.show(io::IO, cb::ConstraintBounds)
8989
end
9090

9191
# Synonym constructor for ConstraintBounds with no c(x)
92-
BoxConstraints(lx, ux) = ConstraintBounds(lx, ux)
92+
BoxConstraints(lx, ux) = ConstraintBounds(lx, ux, [], [])
9393

9494
abstract type AbstractConstraints end
9595

test/constraints.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
s = String(take!(io))
3535
@test s == "ConstraintBounds:\n Variables:\n x[1]≥1.0, x[1]≤3.0, x[2]≥2.0, x[2]≤4.0\n Linear/nonlinear constraints:\n c_1≤10.0, c_2≤20.0, c_3≤30.0"
3636

37+
for i = 1:5
38+
cb = NLSolversBase.BoxConstraints(fill(0, i), fill(0, i))
39+
@test NLSolversBase.nconstraints(cb) == 0
40+
@test NLSolversBase.nconstraints_x(cb) == i
41+
end
3742
end
3843

3944
@testset "Once differentiable constraints" begin

0 commit comments

Comments
 (0)