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
ref_rhs =0#Could be calculated with: parse(Float64,split(ref_str, " ")[end]). NOTE: @NLconstraint will always have a 0 RHS.
70
72
elseif ref isa ConstraintRef
71
73
ref_obj =constraint_object(ref)
72
74
@assert ref_obj.set isa MOI.LessThan || ref_obj.set isa MOI.GreaterThan || ref_obj.set isa MOI.EqualTo "$ref must be one the following: GreaterThan, LessThan, or EqualTo."
@@ -102,7 +104,7 @@ function apply_interval_arithmetic(ref)
102
104
end
103
105
end
104
106
105
-
functionCHR(m, constr, M, bin_var, i, k =missing)
107
+
functionCHR(m, constr, bin_var, i, k=missing; M=missing)
106
108
ifismissing(k)
107
109
@assertis_valid(m,constr) "$constr is not a valid constraint in the model."
108
110
ref = constr
@@ -111,35 +113,54 @@ function CHR(m, constr, M, bin_var, i, k = missing)
@assertlength(set_fields) ==1"A reformulation cannot be done on constraint $ref because it is not one of the following GreaterThan, LessThan, or EqualTo."
117
-
@assert:valuein set_fields ||:lowerin set_fields ||:upperin set_fields "$ref must be one the following: GreaterThan, LessThan, or EqualTo."
118
116
for var in m[:original_model_variables]
119
-
coeff =normalized_coefficient(ref,var)
120
-
iszero(coeff) &&continue
121
-
ifismissing(M)
122
-
ifhas_upper_bound(var)
123
-
M =upper_bound(var)
124
-
else
125
-
error("Variable $var does not have an upper bound, an M value must be specified")
126
-
end
127
-
end
117
+
#get bounds for disaggregated variable
118
+
@asserthas_upper_bound(var) "Variable $var does not have an upper bound."
119
+
@asserthas_lower_bound(var) "Variable $var does not have a lower bound."
functionlin_perspective_function(ref, bin_var_ref, var, i)
147
+
#check constraint type
148
+
ref_obj =constraint_object(ref)
149
+
@assert ref_obj.set isa MOI.LessThan || ref_obj.set isa MOI.GreaterThan || ref_obj.set isa MOI.EqualTo "$ref must be one the following: GreaterThan, LessThan, or EqualTo."
150
+
#check var is present in the constraint
151
+
coeff =normalized_coefficient(ref,var)
152
+
iszero(coeff) &&return
153
+
#check CHR can be applied to this constraint
154
+
rhs =normalized_rhs(ref) #get rhs
155
+
@assert!iszero(rhs) "The convex hull reformulation cannot be done on constraint $ref because its right-hand-side is zero. Use Big-M instead."
0 commit comments