Skip to content

Commit 31e9dbc

Browse files
authored
Merge branch 'hdavid16:master' into master
2 parents a1bfc45 + 651a216 commit 31e9dbc

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/big_M.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
function big_m_reformulation!(constr, bin_var, i, k, M)
22
if ismissing(k)
33
ref = constr
4+
elseif k isa CartesianIndex
5+
ref = constr[k]
46
else
57
ref = constr[k...]
68
end
79
if ismissing(M)
810
M = apply_interval_arithmetic(ref)
911
# @warn "No M value passed for $ref. M = $M was inferred from the variable bounds."
10-
elseif !ismissing(k)
12+
elseif !ismissing(k) && !isa(M,Real)
1113
M = M[k]
1214
end
1315
if ref isa NonlinearConstraintRef

src/utils.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ end
150150

151151
function replace_intevals!(expr, intervals)
152152
#replace variables with their intervals
153-
if string(expr) in keys(intervals) #check if expression is one of the model variables in the intervals dict
154-
return intervals[string(expr)] #replace expression with interval
153+
expr_str = replace(string(expr), ", " => ",") #remove any blank space after index commas
154+
if expr_str in keys(intervals) #check if expression is one of the model variables in the intervals dict
155+
return intervals[expr_str] #replace expression with interval
155156
elseif expr isa Expr
156157
if length(expr.args) == 1 #run recursive relation on the leaf node on expression tree
157158
expr.args[i] = replace_intevals!(expr.args[i], intervals)

0 commit comments

Comments
 (0)