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
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,9 @@ After defining a JuMP model, disjunctions can be added to the model by using the
19
19
20
20
NOTES:
21
21
- Vectorized constraints (using `.` notation) are not currently supported. The current workarround is to first creating the constraint outside of the `@disjunction` macro and then passing the reference to the constraint to the `@disjunction` macro.
22
-
- Any constraints that are of `Interval` type are split into two constraints (one for each bound). It is assumed that the disjuncts belonging to a disjunction are proper disjunctions (mutually exclussive) and only one of them will be selected (`XOR`).
22
+
- Any constraints that are of `EqualTo` type are split into two constraints (e.g., `f(x) == 0` -> `0 <= f(x) <= 0`). This is necessary only for the Big-M reformulation of equality constraints, but is currently applied regardless of the reformulation technique.
23
+
- Any constraints that are of `Interval` type are split into two constraints (one for each bound).
24
+
- It is assumed that the disjuncts belonging to a disjunction are proper disjunctions (mutually exclussive) and only one of them will be selected (`XOR`).
23
25
24
26
The valid key-word arguments for the `@disjunction` macro are:
25
27
-`reformulation::Symbol`: `:big_m` for [Big-M Reformulation](https://optimization.mccormick.northwestern.edu/index.php/Disjunctive_inequalities#Big-M_Reformulation), `:convex_hull` for [Convex-Hull Reformulation](https://optimization.mccormick.northwestern.edu/index.php/Disjunctive_inequalities#Convex-Hull_Reformulation)
@@ -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)
if ref isa NonlinearConstraintRef ||constraint_object(ref).func isa QuadExpr
@@ -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
@@ -99,8 +109,8 @@ end
99
109
functionadd_disaggregated_variable(m, LB, UB, var, base_name)
0 commit comments