diff --git a/examples/ex1.jl b/examples/ex1.jl index 0412afc..9dfb167 100644 --- a/examples/ex1.jl +++ b/examples/ex1.jl @@ -19,8 +19,8 @@ print(m) # ┌ Warning: disj_y[2] : x in [5.0, 9.0] uses the `MOI.Interval` set. Each instance of the interval set has been split into two constraints, one for each bound. # Feasibility # Subject to -# XOR(disj_y) : y[1] + y[2] == 1.0 <- XOR constraint -# y[1] ∨ y[2] : y[1] + y[2] >= 1.0 <- reformulated logical proposition (name is the proposition) +# XOR : y[1] + y[2] == 1.0 <- XOR constraint +# prop : y[1] + y[2] >= 1.0 <- reformulated logical proposition (name is the proposition) # disj_y[1,lb] : -x + 5 y[1] <= 5.0 <- left-side of constraint in 1st disjunct (name is assigned to disj_y[1][lb]) # disj_y[1,ub] : x + 7 y[1] <= 10.0 <- right-side of constraint in 1st disjunct (name is assigned to disj_y[1][ub]) # disj_y[2,lb] : -x + 10 y[2] <= 5.0 <- left-side of constraint in 2nd disjunct (name is assigned to disj_y[2][lb]) diff --git a/examples/ex2.jl b/examples/ex2.jl index 992012b..bf840cb 100644 --- a/examples/ex2.jl +++ b/examples/ex2.jl @@ -20,7 +20,7 @@ print(m) # Feasibility # Subject to -# XOR(disj_y) : y[1] + y[2] == 1.0 <- XOR constraint +# XOR : y[1] + y[2] == 1.0 <- XOR constraint # con1[1,lb] : -x[1] + 5 y[1] <= 5.0 <- left-side of con1[1] # con1[1,ub] : x[1] + 7 y[1] <= 10.0 <- right-side of con1[1] # con1[2,lb] : -x[2] + 5 y[1] <= 5.0 <- left-side of con1[2] diff --git a/src/bigm.jl b/src/bigm.jl index e701393..42d7425 100644 --- a/src/bigm.jl +++ b/src/bigm.jl @@ -41,11 +41,11 @@ big_m_reformulation!(constr::AbstractArray{<:ConstraintRef}, bin_var, M, i, j, k big_m_reformulation(constr[k], bin_var, M, i, j, k) """ - infer_bigm(constr) + calculate_tight_M(constr::ConstraintRef{<:AbstractModel, MOI.ConstraintIndex{MOI.ScalarAffineFunction{T},V}}) where {T,V} -Apply interval arithmetic on a constraint to infer the tightest Big-M value from the bounds on the constraint. +Apply interval arithmetic on a linear constraint to infer the tightest Big-M value from the bounds on the constraint. """ -function infer_bigm(constr::ConstraintRef) +function calculate_tight_M(constr::ConstraintRef{<:AbstractModel, MOI.ConstraintIndex{MOI.ScalarAffineFunction{T},V}}) where {T,V} constr_obj = constraint_object(constr) constr_terms = constr_obj.func.terms constr_set = constr_obj.set @@ -78,4 +78,4 @@ function infer_bigm(constr::ConstraintRef) isinf(M) && error("M parameter for $constr cannot be infered due to lack of variable bounds.") return M end -infer_bigm(constr::NonlinearConstraintRef) = error("$constr is a nonlinear constraint and a tight Big-M parameter cannot be inferred via interval arithmetic.") \ No newline at end of file +calculate_tight_M(constr::ConstraintRef) = error("$constr is a nonlinear or quadratic constraint and a tight Big-M parameter cannot be inferred via interval arithmetic.") \ No newline at end of file diff --git a/src/utils.jl b/src/utils.jl index 938f8e6..54af519 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -15,7 +15,7 @@ get_indices(arr) = Iterators.product(axes(arr)...) Get M or ϵ parameter for reformulation. """ -get_reform_param(param::Missing, args...; constr) = infer_bigm(constr) #if param is missing, infer bigM (ϵ does not pass a kwarg) +get_reform_param(param::Missing, args...; constr) = calculate_tight_M(constr) #if param is missing, infer bigM (ϵ does not pass a kwarg) get_reform_param(param::Number, args...; kwargs...) = param #if param is a number return it get_reform_param(param::Union{Vector,Tuple}, idx::Int, args...; kwargs...) = #index param by next Integer arg (idx) get_reform_param(param[idx], args...; kwargs...)