Skip to content

Commit

Permalink
Merge 4cd702e into ab32ab3
Browse files Browse the repository at this point in the history
  • Loading branch information
joehuchette committed May 9, 2014
2 parents ab32ab3 + 4cd702e commit f64bd8f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ end
addToExpression(aff, c, x) = error("Cannot construct an affine expression with a term of type $(typeof(x))")

function parseCurly(x::Expr, aff::Symbol, constantCoef)
if (x.args[1] != :sum)
if (x.args[1] != :sum && x.args[1] != :∑)
error("Expected sum outside curly braces")
end
if length(x.args) < 3
Expand Down Expand Up @@ -158,7 +158,7 @@ macro addConstraint(m, x, extra...)
end
else
# ranged row
if length(x.args) != 5 || x.args[2] != :<= || x.args[4] != :<=
if length(x.args) != 5 || (x.args[2] != :<= && x.args[2] != :) || (x.args[4] != :<= && x.args[4] != :)
error("Only ranged rows of the form lb <= expr <= ub are supported")
end
lb = x.args[1]
Expand Down Expand Up @@ -207,7 +207,7 @@ macro addConstraint(m, x, extra...)
end
else
# ranged row
if length(x.args) != 5 || x.args[2] != :<= || x.args[4] != :<=
if length(x.args) != 5 || (x.args[2] != :<= && x.args[2] != :) || (x.args[4] != :<= && x.args[4] != :)
error("Only ranged rows of the form lb <= expr <= ub are supported")
end
lb = x.args[1]
Expand Down Expand Up @@ -246,7 +246,7 @@ macro defVar(m, x, extra...)
m = esc(m)
if isexpr(x,:comparison)
# we have some bounds
if x.args[2] == :>=
if x.args[2] == :>= || x.args[2] == :
if length(x.args) == 5
error("Use the form lb <= var <= ub instead of ub >= var >= lb")
end
Expand All @@ -255,11 +255,11 @@ macro defVar(m, x, extra...)
lb = esc(x.args[3])
ub = Inf
var = x.args[1]
elseif x.args[2] == :<=
elseif x.args[2] == :<= || x.args[2] == :
if length(x.args) == 5
# lb <= x <= u
lb = esc(x.args[1])
if (x.args[4] != :<=)
if (x.args[4] != :<= && x.args[4] != :)
error("Expected <= operator")
end
ub = esc(x.args[5])
Expand Down Expand Up @@ -407,11 +407,11 @@ macro addNLConstraint(m, x)
if op == :(==)
lb = 0.0
ub = 0.0
elseif op == :(<=)
elseif op == :(<=) || op == :()
lb = -Inf
ub = 0.0
else
@assert op == :(>=)
@assert op == :(>=) || op == :()
lb = 0.0
ub = Inf
end
Expand Down
12 changes: 12 additions & 0 deletions test/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ let

end

# unicode comparisons
if VERSION > v"0.3.0-"
let
m = Model()
@defVar(m, 0 x 1)
@defVar(m, y 2)
@defVar(m, z 3)
@test m.colUpper == [1.0, Inf, 3.0]
@test m.colLower == [0.0, 2.0, -Inf]
end
end

# test @addConstraint(a,b,c)
let
m = Model()
Expand Down

0 comments on commit f64bd8f

Please sign in to comment.