Skip to content

Commit 39f7896

Browse files
committed
up
1 parent ce775a6 commit 39f7896

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

src/constraints/GreaterThanConstraint.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function vexity(vex, ::MOI.Nonnegatives)
1111
return vex
1212
end
1313

14-
function Base.:>=(lhs::AbstractExpr, rhs::AbstractExpr)
14+
function _promote_size(lhs::AbstractExpr, rhs::AbstractExpr)
1515
if sign(lhs) == ComplexSign() || sign(rhs) == ComplexSign()
1616
error(
1717
"Cannot create inequality constraint between expressions of sign $(sign(lhs)) and $(sign(rhs))",
@@ -32,6 +32,11 @@ function Base.:>=(lhs::AbstractExpr, rhs::AbstractExpr)
3232
"Cannot create inequality constraint between expressions of size $(lhs.size) and $(rhs.size)",
3333
)
3434
end
35+
return lhs, rhs
36+
end
37+
38+
function Base.:>=(lhs::AbstractExpr, rhs::AbstractExpr)
39+
lhs, rhs = _promote_size(lhs, rhs)
3540
return GenericConstraint{MOI.Nonnegatives}(lhs - rhs)
3641
end
3742

src/constraints/LessThanConstraint.jl

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,7 @@ function vexity(vex, ::MOI.Nonpositives)
1212
end
1313

1414
function Base.:<=(lhs::AbstractExpr, rhs::AbstractExpr)
15-
if sign(lhs) == ComplexSign() || sign(rhs) == ComplexSign()
16-
error(
17-
"Cannot create inequality constraint between expressions of sign $(sign(lhs)) and $(sign(rhs))",
18-
)
19-
end
20-
if lhs.size == rhs.size || lhs.size == (1, 1)
21-
sz = rhs.size
22-
if lhs.size == (1, 1) && rhs.size != (1, 1)
23-
lhs = lhs * ones(rhs.size)
24-
end
25-
elseif rhs.size == (1, 1)
26-
sz = lhs.size
27-
if rhs.size == (1, 1) && lhs.size != (1, 1)
28-
rhs = rhs * ones(lhs.size)
29-
end
30-
else
31-
error(
32-
"Cannot create inequality constraint between expressions of size $(lhs.size) and $(rhs.size)",
33-
)
34-
end
15+
lhs, rhs = _promote_size(lhs, rhs)
3516
return GenericConstraint{MOI.Nonpositives}(lhs - rhs)
3617
end
3718

src/constraints/SecondOrderConeConstraint.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const SecondOrderConeConstraint = Constraint{MOI.SecondOrderCone}
1+
mutable struct SecondOrderConeConstraint <: Constraint
2+
children::Tuple
3+
dual::Union{Value,Nothing}
24

3-
function set_with_size(::Type{MOI.SecondOrderCone}, sz::Tuple{Int})
4-
return MOI.SecondOrderCone(sz[1])
5+
SecondOrderConeConstraint(args::AbstractExpr...) = new(args, nothing)
56
end
67

78
head(io::IO, ::SecondOrderConeConstraint) = print(io, "soc")

0 commit comments

Comments
 (0)