Skip to content

Commit

Permalink
Add ZeroConstraintWithDomain test
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 1, 2018
1 parent 9f322aa commit 44744ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ _iszero(m, p::AbstractArray) = all(q -> _iszero(m, q), p)
function testcon(m, cref, set::ZeroPoly, p, ineqs, eqs, kwargs=[])
@test isa(cref, ConstraintRef{Model, PolyJuMP.PolyConstraint})
c = PolyJuMP.getdelegate(cref)
@test c isa PolyJuMP.ZeroConstraint
if isempty(ineqs)
@test c isa PolyJuMP.ZeroConstraint
else
@test c isa PolyJuMP.ZeroConstraintWithDomain
end
end
function testcon(m, cref, set, p, ineqs, eqs, kwargs=[])
@test isa(cref, ConstraintRef{Model, PolyJuMP.PolyConstraint})
Expand Down Expand Up @@ -59,6 +63,7 @@ _iszero(m, p::AbstractArray) = all(q -> _iszero(m, q), p)
testcon(m, @constraint(m, q - p in NonNegPoly()), TestPolyModule.TestNonNegConstraint(), q - p, [], [])
testcon(m, @constraint(m, p + q >= 0, domain = @set x == y^3), TestPolyModule.TestNonNegConstraint(), p + q, [], [x - y^3])
testcon(m, @constraint(m, p == q, domain = @set x == 1 && f(x, y)), ZeroPoly(), p - q, [], [x - 1, x + y - 2])
testcon(m, @constraint(m, p == q, domain = dom), ZeroPoly(), p - q, [x^3 + x*y^2 + y - 1], [x^2 + y^2 - 1])
testcon(m, @constraint(m, p - q in ZeroPoly(), domain = @set x == 1 && f(x, y)), ZeroPoly(), p - q, [], [x - 1, x + y - 2])
testcon(m, @SDconstraint(m, [p q; q 0] [0 0; 0 p]), TestPolyModule.TestNonNegMatrixConstraint(), [p q; q -p], [], [])
testcon(m, @constraint(m, p <= q, maxdegree=1), TestPolyModule.TestNonNegConstraint(), q - p, [], [], [(:maxdegree, 1)])
Expand Down

0 comments on commit 44744ca

Please sign in to comment.