Skip to content

Commit

Permalink
fix hashing bug in all constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
karanveerm committed Jan 10, 2015
1 parent ac7240d commit 3836d0c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/constraints/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type EqConstraint <: Constraint
lhs::AbstractExpr
rhs::AbstractExpr
size::(Int, Int)
dual::ValueOrNothing

function EqConstraint(lhs::AbstractExpr, rhs::AbstractExpr)
if lhs.size == rhs.size || lhs.size == (1, 1)
Expand All @@ -17,7 +18,7 @@ type EqConstraint <: Constraint
else
error("Cannot create equality constraint between expressions of size $(lhs.size) and $(rhs.size)")
end
return new(:(==), hash((lhs, rhs)), lhs, rhs, sz)
return new(:(==), hash((lhs, rhs, :(==))), lhs, rhs, sz, nothing)
end
end

Expand Down Expand Up @@ -61,7 +62,7 @@ type LtConstraint <: Constraint
else
error("Cannot create inequality constraint between expressions of size $(lhs.size) and $(rhs.size)")
end
return new(:(<=), hash((lhs, rhs)), lhs, rhs, sz)
return new(:(<=), hash((lhs, rhs, :(<=))), lhs, rhs, sz)
end
end

Expand Down Expand Up @@ -106,7 +107,7 @@ type GtConstraint <: Constraint
else
error("Cannot create inequality constraint between expressions of size $(lhs.size) and $(rhs.size)")
end
return new(:(>=), hash((lhs, rhs)), lhs, rhs, sz)
return new(:(>=), hash((lhs, rhs, :(>=))), lhs, rhs, sz)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/constraints/exp_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ExpConstraint <: Constraint
# @assert(x.size == (1,1),
# "Exponential constraint requires x, y, and z to be scalar for now")
sz = x.size
return new(:exp, hash((x,y,z)), (x, y, z), sz)
return new(:exp, hash((x,y,z, :exp)), (x, y, z), sz)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/constraints/sdp_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type SDPConstraint <: Constraint
if sz[1] != sz[2]
error("Positive semidefinite expressions must be square")
end
return new(:sdp, hash(child), child, sz)
return new(:sdp, hash((child, :sdp)), child, sz)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/constraints/soc_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type SOCConstraint <: Constraint

function SOCConstraint(args::AbstractExpr...)
children = tuple(args...)
return new(:soc, hash(children), children)
return new(:soc, hash((children, :soc)), children)
end
end

Expand Down

0 comments on commit 3836d0c

Please sign in to comment.