1
votes

Does Jump support direct use of mathematical logics in a model?

I know it supports conditional indicator, but how about these conditionals?

For example:

1- A bi-conditional indicator is a binary variable that is associated with satisfaction and non-satisfaction statuses of a constraint concerning the current solution.

δi = 1 ⟺ sum(j, a_ij. x_j) <= b_i

2- Either-or Constraints ensuring that at least one of the two constraints is met.

3- If-Then-Else Constraints describing a situation where we want to ensure that if the constraint C1 holds, then the constraint C2 must be held; otherwise the constraint C3 must be held

2

2 Answers

2
votes

Does Julia support direct use of mathematical logics in a model?

I assume you mean JuMP here. (JuMP is a package for mathematical optimization written in Julia.)

JuMP does not have direct syntax for these three constraints.

However, they can all be formulated with some tricks.

The JuMP documentation also has some tips.

Point (2) is https://jump.dev/JuMP.jl/stable/tutorials/Mixed-integer%20linear%20programs/tips_and_tricks/#Big-M-Disjunctive-Constraints-(OR)

2
votes

(1) The constraint

δ(i)=1 ⇔ sum(j, a(i,j)) ≤ b(i)

can be stated as two indicator constraints:

δ(i)=1 ⇒ sum(j, a(i,j)) ≤ b(i)
δ(i)=0 ⇒ sum(j, a(i,j)) ≥ b(i) + 0.0001
δ(i) ∈ {0,1} 

I typically drop the 0.001 and let the problem be slightly ambiguous at equality. This way the solver can pick the best. If the sum is long, use an intermediate variable to prevent duplicating the sum.

(2) Either-or-constraints. Same idea:

δ=1 ⇒ linear constraint 1
δ=0 ⇒ linear constraint 2
δ ∈ {0,1} 

One of the constraints 1 or 2 will be enforced

(3) If-Then-Else Constraints. I.e.

If constraint 1 then constraint 2 else constraint 3

Again similar to what we have above:

δ=1 ⇒ linear constraint 1
δ=1 ⇒ linear constraint 2
δ=0 ⇒ not linear constraint 1
δ=0 ⇒ linear constraint 3

A more complicated case can look like:

δ=1 ⇒ y=b
δ=0 ⇒ y≠b

The second implication needs to be split into two using an additional binary variable. I'll leave that as an exersize.