Skip to Content

4. Linear Programs

2019-09-04·Advanced Algorithm

Definition

  • Linear Programming Problem: the problem of either minimizing or maximizing a linear function subject to a finite set of linear constraints
    • feasible solution, feasible area, objective function, objective value, optimal solution, optimal objective value
  • unbounded: have a infinite objective value
  • infeasible: no feasible value
  • Equivalent: for each feasible solution x‾\overline{x} to LL with objective value zz, there is a corresponding feasible solution x‾′\overline{x}' to L′L' with objective value z′z', and for each feasible solution x‾′\overline{x}' to L′L' with objective value z′z', there is a corresponding feasible solution x‾\overline{x} to LL with objective value ́.

Standard Form

  • Maximize ∑j=1ncjxj\sum_{j=1}^nc_jx_j
  • subject to ∑j=1naijxj≤bi,xj≥0\sum_{j=1}^na_{ij}x_j\leq b_i, x_{j}\geq 0
  • Converting to Stand Form
    • Turn Minimize to Maximize
    • x=x1−x2,x1>0,x2>0x=x_1-x_2,x_1>0,x_2>0
    • Turn equation to inequation
    • Turn ≥\geq to ≤\leq
  • (A,b,c)(A,b,c)
    • Maximize cTxc^Tx
    • subject to Ax≤b,x≥0Ax\leq b,x\geq 0

Slack Form

  • Maximize ∑j=1ncjxj\sum_{j=1}^nc_jx_j
  • subject to
    • xn+i=∑j=1ntjxj≥0x_{n+i}=\sum_{j=1}^nt_jx_j\geq0
    • xi≥0x_i\geq 0
  • basic variable: Left side of equation
  • nonbasic variable: Right side of equation
  • (N,B,A,b,c,v)(N,B,A,b,c,v)
    • Maximize cTx+vc^Tx+v
    • subject to
      • xi=bi−∑j∈Naijxj,i∈Bx_i=b_i-\sum_{j\in N}a_{ij}x_j,i\in B
      • xi≥0,i∈Nx_i\geq 0,i\in N

Simplex Algorithm

  • pivot: choose a nonbasic varible(entering variable) and a basic variable(leaving variable) and exchange their roles.
    • (N,B,A,b,c,v)→(N^,B^,A^,b^,c^,v^)(N,B,A,b,c,v)\rightarrow (\hat{N},\hat{B},\hat{A},\hat{b},\hat{c},\hat{v})
  • at most (n+mm)\binom{n+m}{m} iterations, otherwise cycles
  • Bland's rule: choose smallest index then must terminate
//n: number of variable
//m: number of restriction
 
void pivot(int l, int e) {
    // Update leaving basic variable
    b[l] /= a[l][e];
    for (int j = 1; j <= n; j++)
        if (j != e) a[l][j] /= a[l][e];
    a[l][e] = 1 / a[l][e];
    // Update other basic variable
    for (int i = 1; i <= m; i++)
        if (i != l && fabs(a[i][e]) > 0) {
            b[i] -= a[i][e] * b[l];
            for (int j = 1; j <= n; j++)
                if (j != e) a[i][j] -= a[i][e] * a[l][j];
            a[i][e] = -a[i][e] * a[l][e];
        }
    // Update entering nonbasic variable
    ans += c[e] * b[l];
    for (int j = 1; j <= n; j++)
        if (j != e) c[j] -= c[e] * a[l][j];
    c[e] = -c[e] * a[l][e];
}
 
double simplex() {
    while (true) {
        int enter = 0, leave = 0;
        // Select enter variable
        for (enter = 1; enter <= n; ++enter)
            if (c[enter] > eps) break;
        if (enter == n + 1) return ans;
        // Select leave variable
        double mn = INF;
        for (int i = 1; i <= m; ++i)
            if (a[i][enter] > eps && mn > b[i] / a[i][enter]) {
                mn = b[i] / a[i][enter];
                leave = i;
            }
        if (mn == INF) return INF;
        pivot(leave, enter);
    }
}

Formulating Problems

  • Shortest Path
    • Maximize dtd_t
    • subject to dv≤du+w(u,v),ds=0d_v\leq d_u+w(u,v),d_s=0
  • Maximum Flow
    • Maximize ∑v∈Vfsv−∑v∈Vfvs\sum_{v\in V}f_{sv}-\sum_{v\in V}f_{vs}
    • subject to fuv≤c(u,v),∑v∈Vfvu=∑v∈Vfuv,fuv≥0f_{uv}\leq c(u,v),\sum_{v\in V}f_{vu}=\sum_{v\in V}f_{uv},f_{uv}\geq 0
  • Minimum-cost Flow
    • Minimize ∑(u,v)∈Ea(u,v)fuv\sum_{(u,v)\in E}a(u,v)f_{uv}
    • subject to fuv≤c(u,v),∑v∈Vfvu−∑v∈Vfuv=0,fuv≥0,∑v∈Vfsv−∑v∈Vfvs=df_{uv}\leq c(u,v), \sum_{v\in V}f_{vu}-\sum_{v\in V}f_{uv}=0,f_{uv}\geq 0,\sum_{v \in V}f_{sv}-\sum_{v\in V}f_{vs}=d
  • Multicommodity Flow
    • Minimize 00
    • subject to ∑i=1kfiuv≤c(u,v),∑v∈Vfiuv−∑v∈Vfivu=0,∑v∈Vfisiv−∑v∈Vfivsi=di,fiuv≥0\sum_{i=1}{k}f_{iuv}\leq c(u,v),\sum_{v\in V}f_{iuv}-\sum_{v\in V}f_{ivu} = 0,\sum_{v\in V}f_{is_iv}-\sum_{v\in V}f_{ivs_i}=d_i,f_{iuv}\geq 0
  • vertex cover

min⁡∑v∈Vxvs.t.∑v∈exv≥1,e∈Exv∈{0,1},v∈V\min \sum_{v\in V}x_v\newline s.t. \sum_{v\in e}x_v\geq 1,e\in E\newline x_v\in \{0,1\},v\in V

  • System of difference contraints
    • subject to: xi−xj≤ckx_i-x_j\leq c_k (mm pairs)

Duality

  • Prime

min⁡cTxs.t. Ax≥bx≥0\min c^Tx\newline s.t.\ Ax\geq b\newline x\geq 0

  • Dual

max⁡bTys.t. yTA≤cTy≥0\max b^Ty\newline s.t.\ y^TA\leq c^T\newline y\geq 0

primedual
max⁡c1x1+⋯+cnxn\max c_1x_1+\cdots+c_nx_nmin⁡b1y1+⋯+bmym\min b_1y_1+\cdots+b_my_m
aTx≥ba^Tx\geq byi≤0y_i\leq 0
aTx=ba^Tx=b-
aTx≤ba^Tx\leq byi≥0y_i\geq 0
-yi=0y_i=0
xi≥0x_i\geq 0aTy≥ca^Ty\geq c
xi≤0x_i\leq 0aTy≤ca^Ty\leq c
-aTy=ca^Ty=c
xi=0x_i=0-
  • Weak Duality Theorem: ∀\forall feasible primal solution xx and dual solution yy

yTb≤yTAx≤cTxy^Tb\leq y^TAx\leq c^Tx

  • Strong Duality Theorem: Primal LP has finite optimal solution x∗x^* iff dual LP has finite optimal solution y∗Tb=cTx∗y^{*T}b=c^Tx^*
  • Complementary Slackness Condition: ∀\forall feasible primal solution xx and dual solution yy, both xx and yy are optimal iff

∀i:Ai⋅x=bi∨yi=0∀j:yTA⋅j=cj∨xj=0\forall i:A_{i\cdot}x=b_i\vee y_i=0\newline \forall j:y^TA_{\cdot j}=c_j\vee x_j=0

  • Relaxed Complementary Slackness: ∀\forall feasible primal solution xx and dual solution yy, for α,β≥1\alpha,\beta\geq 1

∀i:Ai⋅x≤αbi∨yi=0∀j:yTA⋅j=cjβ∨xj=0⇒cTx≤αβbTy≤αβOPTIP\forall i:A_{i\cdot}x\leq \alpha b_i\vee y_i=0\newline \forall j:y^TA_{\cdot j}=\frac{c_j}{\beta}\vee x_j=0\newline \Rightarrow c^Tx\leq\alpha\beta b^Ty\leq\alpha\beta\text{OPT}_{\text{IP}}

  • Fundamental theorem of linear programming: Any linear program L, given in standard form, either:
    • has an optimal solution with a finite objective value
    • infeasible
    • unbounded

Primal-Dual Schema

  • The Primal-Dual Schema
    • Write down an LP-relaxation and its dual
    • Start with a primal infeasible solution xx and a dual feasible solution yy (usually x=0,y=0x=0,y=0)
    • Raise xx and yy until xx is feasible:
      • raise yy until some dual constrints gets tight yTA⋅j=cjy^TA_{\cdot j}=c_j
      • raise xix_i (integrally) corresponding to the tight dual constraints
    • Show the complementary slackness conditions
      • ∀i,Ai⋅x≤αbi\forall i, A_{i\cdot}x\leq\alpha b_i or yi=0y_i=0
      • ∀j,yTA⋅j=cj\forall j,y^TA_{\cdot j}=c_j or xj=0x_j=0
      • cTx≤αbTy≤αOPTc^Tx\leq\alpha b^Ty\leq\alpha\text{OPT}
  • Integrality Gap: sup⁡IOPT(I)OPTLP(I)\sup_I\frac{\text{OPT}(I)}{\text{OPT}_{\text{LP}}(I)}

Vertex Cover

  • Primal

min⁡∑v∈Vxvs.t. ∑v∈exv≥1,∀e∈Exv∈{0,1},∀v∈V\min \sum_{v\in V}x_v\newline s.t.\ \sum_{v\in e}x_v\geq 1,\forall e\in E\newline x_v\in\{0,1\},\forall v\in V

  • Dual

max⁡∑e∈Eyes.t. ∑e∋vye≤1,∀v∈Vye≥0,∀e∈E\max \sum_{e\in E}y_e\newline s.t.\ \sum_{e\owns v}y_e\leq 1,\forall v\in V\newline y_e\geq 0,\forall e\in E

  • Initially x=0,y=0x=0,y=0
  • Raise xx and yy until xx is feasible
    • pick an e∈Ee\in E and raise yey_e to 1, set xv=1x_v=1 for v∈ev\in e and delete all e∋ve\owns v from EE
    • Find a maximal matching and return the set of matched vertices
  • Integrality Gap: 22

Facility Location

  • Facility location ∈NPH\in\text{NPH}
    • Instance
      • FF: Facilities
      • CC: clients
      • f:F→[0,∞)f: F\rightarrow[0,\infty): Facility opening costs
      • c:F×C→[0,∞)c: F\times C\rightarrow [0,\infty): Facility connecting cost
    • total cost: ∑j∈Ccϕ(j),j+∑i∈Ifi\sum_{j\in C}c_{\phi(j),j}+\sum_{i\in I}f_i
    • Find I⊂FI\subset F and ϕ:C→I\phi:C\rightarrow I minimize total cost
  • Metric Facility Location: cϕ(j),j=dϕ(j)jc_{\phi(j),j}=d_{\phi(j)j}
    • triangle inequality: di1j1+di2j1+di2j2≥di1j2d_{i_1j_1}+d_{i_2j_1}+d_{i_2j_2}\geq d_{i_1j_2}
  • Primal

min⁡∑i∈F,j∈Cdijxij+∑i∈Ffiyis.t. yi−xij≥0,∀i∈F,j∈C∑i∈Fxij≥1,∀j∈Cxij,yi∈{0,1},∀i∈F,j∈C\min \sum_{i\in F,j\in C}d_{ij}x_{ij}+\sum_{i\in F}f_iy_i\newline s.t.\ y_i-x_{ij}\geq0,\forall i\in F,j\in C\newline \sum_{i\in F}x_{ij}\geq 1,\forall j\in C\newline x_{ij},y_i\in\{0,1\},\forall i\in F,j\in C

  • Dual

max⁡∑j∈Cαjs.t. αj−βij≤dij,∀i∈F,j∈C∑j∈Cβij≤fi,∀i∈Fαj,βij≥0,∀i∈F,j∈C\max\sum_{j\in C}\alpha_j\newline s.t.\ \alpha_j-\beta_{ij}\leq d_{ij},\forall i\in F,j\in C\newline \sum_{j\in C}\beta_{ij}\leq f_i,\forall i\in F\newline \alpha_j,\beta_{ij}\geq 0,\forall i\in F,j\in C

  • Initially α=0,β=0\alpha=0,\beta=0
  • raise αj\alpha_j for all client jj simultaneously at a uniform continous rate
    • upon αj=dij\alpha_j=d_{ij} for a closed facility ii: edge (i,j)(i,j) is paid, fix βij=αj−dij\beta_{ij}=\alpha_j-d_{ij}
    • upon ∑j∈Cβij=fi\sum_{j\in C}\beta_{ij}=f_i: tentatively open facility ii; all unconnected clients jj with paid edge (i,j)(i,j) to facility ii are declared connected to facility ii and stop raising αj\alpha_j
    • upon αj=dij\alpha_j=d_{ij} for an unconnected client jj and tentatively open facility ii: client jj is declared connected to facility ii and stop raising α\alpha
  • Integrality Gap: 33

LP Relaxation & Rounding

  • Represent problem as Integer Linear Program(ILP)
  • Relaxation: relax ILP to LP
  • Find the optimal fractional solution x∗x^* of LP
    • ellipsoid
    • interior-point
  • Rounding: round the solution to a feasible integral solution x^\hat x
  • Integrality Gap = sup⁡IOPT(I)OPTLP(I)\sup_I\frac{\text{OPT}(I)}{\text{OPT}_{\text{LP}}(I)}

Vertex Cover

Rounding

x^v={1xv∗≥0.50o.w.\hat x_v=\begin{cases}1&x_v^*\geq 0.5\newline 0&o.w.\end{cases}

Integrality Gap: 22

MAX-SAT

Random solution

P(Cj is satisfied)≥(1−2−k)yj∗P(C_j\text{ is satisfied})\geq(1-2^{-k})y_j^*

12\frac{1}{2}-approximation

LP relaxation and randomized roudning

max⁡∑j=1myjs.t.∑i∈Sj+xi+∑i∈Sj−(1−xi)≥yjxi∈{0,1},yj∈{0,1}\max \sum_{j=1}^my_j\newline s.t. \sum_{i\in S_j^+}x_i+\sum_{i\in S_j^-}(1-x_i)\geq y_j\newline x_i\in\{0,1\},y_j\in\{0,1\}

Random Rounding

x^i={1w.p. xi∗0w.p. 1−xi∗\hat x_i=\begin{cases}1& w.p.\ x_i^*\newline 0& w.p.\ 1-x_i^*\end{cases}

Analysis

P(Cj is satisfied)≥(1−(1−1k)k)yj∗≥(1−1e)yj∗E[# of satisfied clauses]≥(1−1e)OPTP(C_j\text{ is satisfied})\geq(1-(1-\frac{1}{k})^k)y_j^*\geq(1-\frac{1}{e})y_j^*\newline E[\text{\# of satisfied clauses}]\geq(1-\frac{1}{e})\text{OPT}

(1−1e)(1-\frac{1}{e})-approximation

Combination

average

Sample random solution, satisfy m1m_1 clauses
Randomized rounding LP-relaxation, satisfy m2m_2 clauses

E[max⁡(m1,m2)]≥E[m1+m22]≥34OPTE[\max(m_1,m_2)]\geq E[\frac{m_1+m_2}{2}]\geq\frac{3}{4}\text{OPT}

Integrality gap: 34\frac{3}{4}
MAX-3SAT has a 78\frac{7}{8}-approximation algorithm by semidefinite programming and cannot have >78>\frac{7}{8}-approx unless NP=P