1

I found a solution for just one term here.

How can we formulate constraints of the form

|x1- a1| +|x2-a2| + .... + |xn - an| >= K

in Mixed Integer Linear Programming ?

Vinay
  • 1,149
  • 3
  • 16
  • 28
  • [Optimization with absolute values](https://optimization.cbe.cornell.edu/index.php?title=Optimization_with_absolute_values). – user2974951 Aug 18 '22 at 10:56
  • This link has examples for objective function but not for constraints with absolute values – Vinay Aug 18 '22 at 11:21

1 Answers1

2

Let's write this as:

 sum(i, |x[i]-a[i]|) >= K

This is non-convex and needs special treatment. Sorry: this is not very simple.

One way to model this is:

 x[i] - a[i] = zplus[i] - zmin[i]
 sum(i, zplus[i] + zmin[i]) >= K
 zplus[i] <= δ[i]*M[i]
 zmin[i] <= (1-δ[i])*M[i]
 zmin[i],zplus[i] >= 0
 δ[i] ∈ {0,1}  
 

Here M[i] are large enough constants. This needs some thought to find good values. Basically we want: M[i]=max(|x[i] - a[i]|).

Alternative formulations are possible using indicator constraints and SOS1 variables. Some modeling tools and solvers have direct support for absolute values.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39