You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -26,7 +29,7 @@ function check_constraint!(m, constr)
26
29
end
27
30
constr_dict =Dict(union(
28
31
[
29
-
split_interval_constraint(m, constr[idx...]) |>
32
+
split_constraint(m, constr[idx...]) |>
30
33
i ->isnothing(i) ?
31
34
(idx...,"") => constr[idx...] :
32
35
[(idx...,"lb") => i[1], (idx...,"ub") => i[2]]
@@ -39,7 +42,7 @@ function check_constraint!(m, constr)
39
42
end
40
43
41
44
if split_flag
42
-
@warn"$(split(string(constr),"}")[end]) uses the `MOI.Interval` set. Each instance of the interval set has been split into two constraints, one for each bound."
45
+
@warn"$constr_str uses the `MOI.Interval` or `MOI.EqualTo` set. Each instance of the interval set has been split into two constraints, one for each bound."
43
46
delete_original_constraint!(m, constr)
44
47
end
45
48
@@ -62,47 +65,67 @@ function gen_constraint_name(constr)
Copy file name to clipboardExpand all lines: src/convex_hull.jl
+12-2Lines changed: 12 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,17 @@ function disaggregate_variables(m, disj, bin_var)
13
13
var_refs = m[:gdp_variable_refs]
14
14
@assertall((has_upper_bound.(var_refs) .&&has_lower_bound.(var_refs)) .||is_binary.(var_refs)) "All variables must be bounded to perform the Convex-Hull reformulation."
15
15
#reformulate variables
16
+
obj_dict =object_dictionary(m)
17
+
bounds_dict =:variable_bounds_dictinkeys(obj_dict) ? obj_dict[:variable_bounds_dict] :Dict() #NOTE: should pass as an keyword argument
16
18
for var_name in m[:gdp_variable_names]
17
19
var = m[var_name]
18
20
#define UB and LB
19
21
if var isa VariableRef
20
-
LB, UB =get_bounds(var)
22
+
ifstring(var) inkeys(bounds_dict)
23
+
LB, UB = bounds_dict[string(var)]
24
+
else
25
+
LB, UB =get_bounds(var)
26
+
end
21
27
elseif var isa Array{VariableRef} || var isa Containers.DenseAxisArray || var isa Containers.SparseAxisArray
22
28
#initialize UB and LB with same container type as variable
23
29
if var isa Array{VariableRef} || var isa Containers.DenseAxisArray
@@ -34,7 +40,11 @@ function disaggregate_variables(m, disj, bin_var)
34
40
end
35
41
#populate UB and LB
36
42
for idx ineachindex(var)
37
-
LB[idx], UB[idx] =get_bounds(var[idx])
43
+
ifstring(var[idx]) inkeys(bounds_dict)
44
+
LB[idx], UB[idx] = bounds_dict[string(var[idx])]
45
+
else
46
+
LB[idx], UB[idx] =get_bounds(var[idx])
47
+
end
38
48
end
39
49
end
40
50
#disaggregate variable and add bounding constraints
0 commit comments