Linear, Integer Linear and Dynamic Programming

32
Linear, Integer Linear and Dynamic Programming Enrico Malaguti DEIS - University of Bologna November 10th, 2011 Linear, Integer Linear and Dynamic Programming (E. Malaguti ) 1 Outline 1 Optimization Problems 2 Linear Programming Complexity Algorithms for LP 3 Integer Linear Programming 4 Integer Linear Programming Modeling Separation Column Generation 5 Dynamic Programming Linear, Integer Linear and Dynamic Programming (E. Malaguti ) 2

Transcript of Linear, Integer Linear and Dynamic Programming

Page 1: Linear, Integer Linear and Dynamic Programming

Linear, Integer Linear and Dynamic Programming

Enrico Malaguti

DEIS - University of Bologna

November 10th, 2011

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 1

Outline

1 Optimization Problems2 Linear Programming

ComplexityAlgorithms for LP

3 Integer Linear Programming4 Integer Linear Programming Modeling

SeparationColumn Generation

5 Dynamic Programming

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 2

Page 2: Linear, Integer Linear and Dynamic Programming

Optimization Problems

Optimization Problems

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 3

Optimization Problems

x = (x1, . . . , xn) ∈ Rn: vector of decision variables

F ∈ Rn: set of feasible solutions

φ : Rn → R : objective function

Optimization Problem [P]

minφ(x)x ∈ F

Find x∗ ∈ F (global optimum) such that: φ(x∗) ≤ φ(x), ∀x ∈ F

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 4

Page 3: Linear, Integer Linear and Dynamic Programming

Optimization Problems

in general, φ and F can be whatever (non-continuos,non-differentiable, etc.)

x∗ may not exists (F = ∅) or may not be unique

there might be local and global minima

0

!

l " F

In general, an algorithm has only a”local” view of φ and F

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 5

Optimization Problems

y is a local optimum if it exists a neighborhood N ⊆ F :φ(y) ≤ φ(x), ∀x ∈ N

e.g. N(y) = x ∈ F : ||y − x || ≤ , > 0

[P] requires to find at least one global optimum

We call a feasible solution any z ∈ F

a heuristic algorithm produces feasible solutions z of ”good” quality,the quality of z is given by φ(z)

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 6

Page 4: Linear, Integer Linear and Dynamic Programming

Problems classification

Problems are classified depending on φ and F .

Generic φ and F : Non Linear Programming (NLP). Great capacity ofmodeling real-world, we do not know algorithms for general problems.Algorithms for specific problems converge to local optima.

φ and F convex: Convex Programming. We know algorithms forgeneral problems, we can compute global optima.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 7

Convex Programming

F is a convex set if: ∀x , y ∈ F , 0 ≤ θ ≤ 1, z = θx + (1− θ)y , wehave z ∈ F .

φ : Rn → R is a convex function if: dom(φ) is a convex set,∀x , y ∈ dom(φ), φ(θx + (1− θ)y) ≤ θφ(x) + (1− θ)φ(y).

Theorem - If [P] is a Convex Programming Problem, any local optimum isa global optimum.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 8

Page 5: Linear, Integer Linear and Dynamic Programming

Linear Programming

Linear Programming

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 9

Linear Programming

φ : Rn → R is a linear function: ∀x , y ∈ dom(φ), a, b ∈ R , we haveφ(ax + by) = aφ(x) + bφ(y).F ∈ Rn is defined by a set of linear inequalities:gi (x) ≥ 0, i = 1, . . . ,m (note that a linear inequality gi (x) ≥ 0defines a half-space in Rn, whose support is the hyper-planegi (x) = 0).

Linear programming is a special case of convex programming.

Notation: gi (x) = ai1x1 + ai2x2 + . . .+ ainxn − bi

LP is Standard Form:

min c x

Ax = b

x ≥ 0

where A ∈ Rm×n, c , x ∈ Rn, b ∈ Rm.Linear, Integer Linear and Dynamic Programming (E. Malaguti) 10

Page 6: Linear, Integer Linear and Dynamic Programming

Linear Programming - Example

Consider the following problem:

LP1 min − x1 − x2

2x2 ≥ 1

4x1 + 2x2 ≤ 11

4x1 − 2x2 ≥ 1

x1, x2 ≥ 0

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 11

LP: assumptions

min z = . . .+ chxh + . . .. . .+ aihxh + . . . ≤ bi

1 Proportionality. The effect of the h-th resource is proportional to itsamount xh:

2 Additivity. There is no interaction among the resources in theobjective function and constraints.

3 Divisibility. Decision variables can get non integer values.4 Determinism. All the model parameters are given constants, while,

in real-world, parameters are affected by incertitude.Sensitivity analysisStochastic OptimizationRobust Optimization

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 12

Page 7: Linear, Integer Linear and Dynamic Programming

Computational Complexity

Complexity of an algorithm: denotes the number of elementary operations

needed to run an algorithm.

always referred to the size of the input (number of bits needed tocode the input);

always referred to the worst case;

measured in term of order of magnitude through the notation O(.).

Polynomial Algorithm: its running time is bounded above (O(.)) by apolynomial expression in the size of the input;Exponential Algorithm: its running time is bounded below (Ω(.)) by anexponential expression in the size of the input;

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 13

Computational Complexity

Complexity of a problem (decision):

Class P - polynomial. Problems for which a polynomial timealgorithm exists belong to the complexity class P.

Class NP - Non deterministic polynomial - Intuitively, NP is the set ofall decision problems for which the instances where the answer is”yes” have efficiently verifiable proofs of the fact that the answer isindeed ”yes”. More precisely, these proofs have to be verifiable inpolynomial time by a deterministic Turing machine.

Class of NP complete problems. A problem [P] is NP-complete if anyproblem in NP can be transformed to [P] in polynomial time.

P = NP??

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 14

Page 8: Linear, Integer Linear and Dynamic Programming

Algorithms for LP

Theorem - LP is polynomially solvable.

Simplex Algorithm, non-polynomial, excellent practical behavior;

Ellipsoid Algorithm, used to prove that LP is polynomial, useless inpractice;

Interior Point Methods, polynomial, can solve convex problems ingeneral;

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 15

Simplex Algorithm (G. Dantzig, 1947)

Consider a generic Linear Program LP. We have that:

Linear Programming is convex ⇒ any local optimum is a globaloptimum;

The feasible region F is a polyhedron (intersection of half-spaces);

(Theorem) - If F has at least one vertex, then either LP is unboundedor there is an optimal solutions which is a vertex of the polyhedron F ;

So we have a problem (LP) with infinitely many solutions but, to solve it,it is enough to check a finite number of vertices, and to find a localoptimum (which is global).

Algorithm (geometric): start from a vertex of the polyhedron anditeratively select an improving (w.r.t. the objective function) adjacentvertex. When no adjacent vertex improves on the current one, this isoptimum.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 16

Page 9: Linear, Integer Linear and Dynamic Programming

Simplex Algorithm - Algebraic viewpoint

Consider a standard form LP (min c x , Ax = b, x ≥ 0) with A ∈ Rm×n

and x ∈ Rn (m + n constraints including non-negativity). It can be shownthat:

A vertex of a polyhedron corresponds to a feasible solution of the LPwhere n constraints are tight (=). We have m tight constraintsAx = b, so we need n −m tight constraints of the form xf = 0 todefine a vertex. The m variables xb not forced at 0 are called basic

variables (w.l.o.g., let be basic the first m).

The m columns of A corresponding to the xB variables are called abase B : A = [B |F ].Any vertex corresponds to a solution x = [xB |xF ], wherexF = [0, . . . , 0]. The value of the basic variables is xB = B−1b.

Two adjacent vertices x and y differ for 1 column in the bases:B = [A1, . . . ,Al, . . . ,Am]; B = [A1, . . . ,Al−1,Al+1, . . . ,Am,Aj]

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 17

Simplex Algorithm - Algebraic viewpoint

When moving from a feasible solution x towards a feasible direction d of aquantity θ > 0, we get to x + θd . For feasibility, it must be Ad = 0.Now consider to move from a vertex x to an adjacent vertex y . We havethat:

all the non basic variables remain at 0, with the exception of xj(which enters the basis), so di = 0, i /∈ B , dj = 1;

the basic variables xB change to xB + θdB :

0 = Ad = Bdb + Ajdj = BdB + Aj

i.e., dB = −B−1Aj .

The cost change along direction d is c d = cj + c BdB = cj − c BB−1Aj .

This coefficient is called reduce cost cj of the variable xj (and has value 0for basic variables).

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 18

Page 10: Linear, Integer Linear and Dynamic Programming

Simplex Algorithm - Algebraic viewpoint

Starting from a feasible solution x with associated base Bx , the SimplexAlgorithm moves to an adjacent solution y with associated base By suchthat c y < c x . This happens when ∃j : cj < 0 (j /∈ Bx otherwise cj = 0,j ∈ By )

Of course, optimality of a solution x means that there is no variable j withnegative reduced cost cj .

In the worst case, the Simplex Algorithm may visit all the exponentiallymany vertices of the polyhedron before getting to the optimal one, thus itis not a polynomial algorithm.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 19

interior point methods

Class of algorithms for the solution of convex problems (including LP).

Idea: consider a modified objective function φ, including a penaltywhich grows when the solution is close the the boundary of thefeasible set F . Let δ(x) denote the distance of x from the boundaryof F .

φ(x) = φ(x) + µ ln δ(x)

The algorithm starts from a solution (point) x in the interior of F . Ateach iteration, the algorithm moves along a direction of maximumdecrease of φ(x) (using Newton methods), and a new solution withinF is obtained. The algorithm converges to an optimal solution on theboundary of F .

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 20

Page 11: Linear, Integer Linear and Dynamic Programming

Simplex VS Interior Point Methods

Interior Point Methods are on average faster in solving LPs fromscratch;

The Simplex Algorithm allows a ”warm start”, so one can:modify the objective function coefficients;modify the right-hand-side;add variables;add constraints;

and re-optimize by starting from a previously computed solution.

The Simplex Algorithm provides several useful information in additionto the optimal solution, like reduced costs, dual variables, etc.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 21

Integer Linear Programming

Integer Linear Programming

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 22

Page 12: Linear, Integer Linear and Dynamic Programming

Integer Linear Programming - ILP

φ : Rn → R is a linear function.

the feasible region F is the intersection of a polyhedron P ∈ Rn

defined by a set of linear inequalities:P = x | gi (x) ≥ 0, i = 1, . . . ,m and the set of integer numbers Z .

min c x

Ax ≥ b

x ∈ Zn

We talk about Mixed-Integer Linear Programming (MILP) when only asubset of the variables are integer.

Theorem - Integer Linear Programming is NP-complete.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 23

ILP - Lower and Upper Bound

Relaxation of problem [P]: problem obtained by ”relaxing” some of therequirements of [P]. Relaxed problems are in general easier to solve (e.g.,original problem is NP-complete, relaxed problem is polynomial).

Continuous Relaxation: obtained by relaxing the integrality requirement forthe variables, provides a lower bound on the optimal solution value of [P].

Minimization Problem

- upper bound (integer feasible solution)

- optimal solution (integer optimal)

- lower bound (e.g., optimal solution of the continuous relaxation)

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 24

Page 13: Linear, Integer Linear and Dynamic Programming

Branch-and-Bound

Branch-and-Bound is a general method for solving optimization problemswith a finite number of solutions, which can be applied to combinatorialproblems and ILP. It consists in the implicit enumeration of all the possiblesolutions to the problem.Branch-and-Bound has two main component:

1 A splitting procedure (branching) that, given a set of candidatesolutions S , returns two or more subsets S1 and S2 such thatS = S1 ∪ S2. Each set Sj is associated with a problem [Pj ], that is,[P] solved on Sj .

2 An evaluating procedure (bounding) which relaxes the problem andcomputes a lower bound on any [Pj ], that is, a bound on the optimalvalue of the objective function φ on Sj .

The original problem [P] is iteratively split into smaller problems, and thesearch is represented through a decision tree.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 25

Branch-and-Bound

!"#$%$#&'"(!")*"+,-$&"./!+012"/10+34!+56"

7,,8"+,-$"

Branch-and-Bound has exponential complexity.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 26

Page 14: Linear, Integer Linear and Dynamic Programming

Branch-and-Bound: Algorithm

Initialization: LB = 0 (or LB = −∞), UB = +∞;Add [P] to the list of active problems;

1 Select an active problem Pj and compute a lower bound LB(Pj) bysolving a relaxation of Pj (bounding);

2 If LB(Pj) ≥ UB return (pruning). Includes the case when Pj isinfeasible (LB(Pj) = +∞);

3 If the solution of the relaxation is feasible we have a feasible solution(UB) to [P]. If the solution is better than UB , update UB , return;

4 If the solution of the relaxation is feasible, return;

5 Split the set Sj of candidate solutions for Pj in Sj1 and Sj2

(branching), add the associated problems Pj1 and Pj2 to the list ofactive problems (and remove Pj);

6 Go to 1.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 27

Branching

Branching is the split of the current problem (defined by the set ofcandidate solutions) in two or more subproblems.

combinatorial algorithm: select/forbid an item, arc, choice (e.g.,KP01);

ILP problem P : select the branching variable, e.g., the most fractionalvariable (let it be x1);

create the subproblems P1 and P2:

[P1] := [P], x1 ≤ x1 [P1] := [P], x1 ≥ x1

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 28

Page 15: Linear, Integer Linear and Dynamic Programming

Branch-and-Bound - Example

Consider the following problem:

ILP1 min − x1 − x2

2x2 ≥ 1

4x1 + 2x2 ≤ 11

4x1 − 2x2 ≥ 1

x1, x2 ≥ 0, integer

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 29

Search Strategy

Defines the way the next active problem (node) is selected during thesearch.

Depth first

!"

#"

$"

%"&"!'"!%"

("

)"*" +"!#" !!"!)" !$"

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 30

Page 16: Linear, Integer Linear and Dynamic Programming

Search Strategy

Best first

Select the problem (node) having the best (i.e., smallest) lower bound. Itrequires to solve the relaxation of all the active nodes (computationallyexpensive). It reduces the number of explored nodes (on average).

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 31

Integer Linear Programming Modeling

Integer Linear Programming Modeling

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 32

Page 17: Linear, Integer Linear and Dynamic Programming

Knapsack Problem - KP01

Given a set of m items, each item i = 1, . . . ,m having a positive profit piand a positive weight wi , and a knapsack of capacity C , select a subset ofitems of maximum profit without exceeding the knapsack capacity.

We use binary variables xi , i = 1, . . . ,m, taking value 1 when item i isselected and 0 otherwise. A possible ILP model reads:

maxm

i=1

pixi

m

i=1

wixi ≤ C

xi ∈ 0, 1, i = 1, . . . ,m

What is the value of the optimal solution of the continuos relaxation ofthe KP01? How would you solve the continuos relaxation of the KP01?

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 33

Bin Packing Problem

Given a set of m items, each item i = 1, . . . ,m having a positive weightwi , and n ≤ m identical bins of capacity C , pack all items in the minimumnumber of bins.We use binary variables xij , i = 1, . . . ,m, j = 1, . . . , n, taking value 1when item i is inserted into bin j ; and binary variables yj , j = 1, . . . , n,taking value 1 when bin j is used.

M1-BPP minn

j=1

yj

n

j=1

xij = 1, i = 1, . . . ,m

m

i=1

wixij ≤ Cyj , j = 1, . . . , n

xij , yj ∈ 0, 1, i = 1, . . . ,m; j = 1, . . . , n

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 34

Page 18: Linear, Integer Linear and Dynamic Programming

Bin Packing Problem

What is the value z of the optimal solution of the continuos relaxation ofthe M1− BPP?How would you solve the continuos relaxation of M1− BPP?

z =

mi=1 wi

C

yj = z/n, j = 1, . . . , n; xij = 1/n, i = 1, . . . ,m; j = 1, . . . , n

M1− BPP is a weak model: it provides a trivial (and far from the optimalinteger value) lower bound. In addition, the model is highly symmetric:given an integer solution to M1− BPP of value k , we can construct

nk

k!

equivalent solutions.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 35

Bin Packing Problem

Let consider the collection S of subsets of items which can fit in one bin:

S = S ⊆ 1, . . . ,m :

i∈Swi ≤ C

A binary variable xS is associated with each one of the exponentially manysets S , taking value one if the set is selected and 0 otherwise. Thecorresponding Set Partitioning model reads:

SP-BPP min

S∈S

xS

S∈S:i∈SxS = 1, i = 1, . . . ,m

xS ∈ 0, 1, S ∈ S

SP − BPP has O(2n) variables.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 36

Page 19: Linear, Integer Linear and Dynamic Programming

Bin Packing Problem

Let consider the collection S of maximal subsets of items which can fit inone bin:

S = S ⊆ 1, . . . ,m :

i∈Swi ≤ C ,

i∈S∪j

wi > C , ∀j /∈ S

The Set Covering model for the BPP reads:

SC-BPP min

S∈SxS

S∈S:i∈SxS ≥ 1, i = 1, . . . ,m

xS ∈ 0, 1, S ∈ S

Observation - Models SP − BPP and SC − BPP are equivalent.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 37

Bin Packing Problem

Consider the following example of BPP:n = 5, w = [7, 4, 1, 4, 4], C = 10.

How ”strong” is model SC − BPP?

For a given instance of BPP, Let z(LP(SC − BPP)) be the optimalvalue of the continuos relaxation of model SC − BPP , and z∗(BPP)the optimal value of the BPP (integer solution). How far are thesevalues in the worst case?

Conjecture - It does not exist an instance of BPP where:z(LP(SC − BPP))+ 1 < z∗(BPP).

Model SC − BPP is not symmetric with respect to bin selection.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 38

Page 20: Linear, Integer Linear and Dynamic Programming

Other problems with a set covering (set partitioning) formulation:

Selection;

Vehicle Routing Problems;

Vertex Coloring;

Crew Scheduling;

etc.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 39

(Asymmetric) Traveling Salesman Problem - ATSP

Given n cities and the distance dij between any pair (i , j) of them, find theshortest tour which goes trough all cities and back to the starting city.Formally, given a directed, complete graph G = (V ,A) and a positivedistance dij for each arc a = (i , j) ∈ A, find the shortest circuit of G whichvisits each vertex i ∈ V exactly once.

We use binary variables xa, a ∈ A, taking value 1 when arc a is selectedand 0 otherwise.

min

a∈Adaxa

a∈δ−(i)

xa = 1, i ∈ V

a∈δ+(i)

xa = 1, i ∈ V

xa ∈ 0, 1, a = 1 ∈ A

Is that enough?Linear, Integer Linear and Dynamic Programming (E. Malaguti) 40

Page 21: Linear, Integer Linear and Dynamic Programming

(Asymmetric) Traveling Salesman Problem - ATSP

In order to forbid solutions with subtours, we can impose the followingcondition: for any subset S of vertices, there must be at least one arcleaving the subset. Equivalently, there can be at most |S |− 1 arcs withinthe subset.

Subtour Eliminations Constrains, in exponential number, read:

a∈A(S)

xa ≤ |S |− 1, S ⊂ V , 1 < |S | < |V |− 1

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 41

Strong formulations for ILP

We have seen that different ILP formulations provide different continuousrelaxations, with a strong impact on the practical solvability of theproblem.

Theorem - For any ILP, it exists an LP formulation whose optimal solutionis integer (thus feasible and optimal for the ILP).

Unfortunately, this ideal formulation has in general exponentiallymany inequalities, and it is NP-complete to generate one of theseinequalities.

However, producing some ”strong” inequalities which improve the LBprovided by the continuous relaxation can be very useful for thesolution of generic ILPs. Modern ILP solvers are all based on aBranch-and-Cut framework: at each node of the B&B, the solvergenerates some inequalities (cuts) to improve the LB associated withthe node.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 42

Page 22: Linear, Integer Linear and Dynamic Programming

LP Models with ”too many” constraints

Solving an ILP with exponentially many constraints (like the TSP model)asks to solve an LP with the same constraints (and then apply B&B).Consider the generic LP:

min c x

Ax ≥ b

x ≥ 0

where A is too large to be explicitly given to an LP solver.

Key observation: not all the constraints are active at an optimal solution.Thus, consider a subset of them which are enough.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 43

Separation Algorithm

1 Initialize A, b with a subset of the constrains defined by A and b

2 Solve the corresponding LP and get x∗:

min c x

Ax ≥ b

x ≥ 0

3 If x∗ satisfies all the constraints Ax ≥ b then it is optimal for thecomplete problem, otherwise add the violated constrains and go to 2)

The crucial point is checking the condition (3) (separation).Theorem - (Grotschel, Lovasz, Schrijver, 1981) - If (3) can be solved inpolynomial time, the whole procedure converges in polynomial time.

Observation If we stop the Separation Algorithm before convergence, wehave a lower bound on the optimal solution value of the LP.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 44

Page 23: Linear, Integer Linear and Dynamic Programming

ATSP - Separation of the Subtour Elimination Constraints

Given x∗, we are looking for a violated constraint of the form:

a∈A(S)

xa ≤ |S |− 1, S ⊂ V , 1 < |S | < |V |− 1

That is, given x∗ we want to find, if it exists, a subset S∗ ⊂ V such that:

a∈A(S∗)

x∗a > |S∗|− 1

1 < |S∗| < |V |− 1

If such a subset does not exist, x∗ is feasible (i.e., there are no subtours inthe solution).

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 45

ATSP - Separation of the Subtour Elimination Constraints

To find S∗, we solve an associated ILP, where binary variables yi takevalue 1 if vertex i is in S∗; and binary variables za take value 1 if arc a is inA(S∗) (here x∗ is a parameter).S∗ exists if and only if there is a solution to the system:

a∈Ax∗a za >

i∈Vyi − 1

za=(i ,j) = 1 ⇔ yi = yj = 1, (i , j) ∈ A

1 <

i∈Vyi < |V |− 1

yi , za ∈ 0, 1, i ∈ V , a ∈ A

If such a subset does not exist, x∗ is feasible (i.e., there are no subtours inthe solution).

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 46

Page 24: Linear, Integer Linear and Dynamic Programming

ATSP - Separation of the Subtour Elimination Constraints

We can look for the set S∗, corresponding to the most violated constraintby solving:

min

i∈Vyi −

a∈Ax∗a za

za=(i ,j) = 1 ⇔ yi = yj = 1, (i , j) ∈ A

1 <

i∈Vyi < |V |− 1

yi , za ∈ 0, 1, i ∈ V , a ∈ A

If the optimal solution has value ≥ 1 then x∗ satisfies all subtourelimination constrains (i.e., there are no subtours in the solution),otherwise S∗ = i ∈ V : y = 1 defines the most violated constraint by x∗.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 47

ATSP - Separation of the Subtour Elimination Constraints

The logical condition

za=(i ,j) = 1 ⇔ yi = yj = 1, (i , j) ∈ A

can be expressed by:

zi ,j ≤ yi , (i , j) ∈ A

zi ,j ≤ yj , (i , j) ∈ A

zi ,j ≥ yi + yj − 1, (i , j) ∈ A

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 48

Page 25: Linear, Integer Linear and Dynamic Programming

LP Models with ”too many” variables

Solving an ILP with exponentially many variables (like the SC-BPP model)asks to solve an LP with the same variables (and then apply B&B).Consider the generic LP:

min c x

Ax ≥ b

x ≥ 0

where A has too many columns to be explicitly given to an LP solver.

Key observation: At most m basic variables have a value > 0 at anoptimal LP solution. The simplex algorithm explores a (hopefully) smallsubset of the polytope vertices to find the optimal solution. Thus, there isno need to explicitly consider all the problem variables.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 49

Column Generation Algorithm

1 Initialize A, b and x with a subset of the columns containing a feasiblesolution.

2 Solve the corresponding LP and get x∗ and an associated base B (ordual solution y∗ = cBB

−1):

min c x

Ax ≥ b

x ≥ 0

3 If (x∗, y∗) is optimal for the original problem, stop. Otherwise,compute a variable which would reduce the solution cost, add it to A

and go to (2)

The crucial point is checking optimality in (3) (column generation).Theorem - (Grotschel, Lovasz, Schrijver, 1981) - If (3) can be solved inpolynomial time, the whole procedure converges in polynomial time.

Observation - If we stop the Column Generation before convergence, wehave an upper bound on the optimal solution value of the LP (useless).Linear, Integer Linear and Dynamic Programming (E. Malaguti) 50

Page 26: Linear, Integer Linear and Dynamic Programming

Column Generation - Optimality Condition

Checking whether an optimal solution (x∗, y∗) to the reduced problem isoptimal for the complete problem, asks to check if there exists a variablexj with negative reduced cost: cj = cj − c BB

−1Aj < 0. Here Aj /∈ A,otherwise it would enter the base.

∃Aj : cj − cBB

−1Aj < 0?

i.e., since c BB−1 = y∗ (dual optimal solution),

∃Aj : cj − y∗Aj < 0?

Note that here y∗ is a parameter.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 51

Column Generation for the SC-BPP

In the case of the BPP we have that cj = 1 ∀j , so when checking theoptimality of a solution (x∗, y∗) we are looking for feasible (w.r.t. thecapacity C ) subset of items S∗ (to be encoded in column Aj) such that:

i∈S∗ y

∗i > 1 (negative reduced cost)

i∈S∗ wi ≤ C (feasibility)

S∗ is a maximal subset

If such a subset does not exist, (x∗, y∗) is optimal.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 52

Page 27: Linear, Integer Linear and Dynamic Programming

Column Generation for the SC-BPP

The column generation problem can be solved by introducing binaryvariables zi taking value 1 if item i is in S∗ and 0 otherwise, and checkingif the following system has a solution:

m

i=1

y∗i zi > 1

m

i=1

wizi ≤ C

zi ∈ 0, 1, i = 1, . . . ,m

If such a subset does not exist, (x∗, y∗) is optimal.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 53

Column Generation for the SC-BPP

We can directly look for the column having the largest negative reduced

cost by solving the following ILP:

maxm

i=1

y∗i zi

m

i=1

wizi ≤ C

zi ∈ 0, 1, i = 1, . . . ,m

Which is a KP01 with profits y∗i , i = 1, . . . ,m.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 54

Page 28: Linear, Integer Linear and Dynamic Programming

Dynamic Programming

Dynamic Programming

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 55

Dynamic Programming

To solve a problem, quite often we need to solve different parts of it(subproblems), then combine the subproblems solutions into an overallsolution.Dynamic Programming seeks to solve each subproblem only once, thusreducing the number of computations.

Simplify a decision by breaking it into a sequence of decision steps.

Define a sequence of value functions V1,V2, . . . ,Vn, with anargument y representing the state of the system at steps 1, . . . , n.Subsequent values of V (y) are computed from previous values, usinga recursive relations (Bellman equation).

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 56

Page 29: Linear, Integer Linear and Dynamic Programming

Dynamic Programming

Bellman principle of Optimality, 1957

An optimal policy has the property that whatever the initial state andinitial decision are, the remaining decisions must constitute an optimal

policy with regard to the state resulting from the first decision.

This principle results in the Bellman equation, which describes the value ofa decision problem at certain point in time in terms of the payoff fromsome initial choices and the value of the remaining decision problem thatresults from those initial choices.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 57

Dynamic Programming algorithm for the TSP

Sequential tour construction: we start from vertex 1, then, at each stage,we choose the next vertex to visit. At a given moment, we have visited asubset S ∈ V of vertices and are at current vertex k ∈ S .

Define: C (S , k) the minimum cost of a path starting from 1, visiting allvertices in S and ending in k . We call (S , k) a state, which can be reachedfrom any state (S \ k,m), with m ∈ S \ k, at transition cost cmk .

We have the recursion:

C (S , k) = minm∈S\k

(C (S \ k,m) + cmk), k ∈ S

and C (1, 1) = 0

The length of the optimal tour is:

mink(C (V , k) + ck1)

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 58

Page 30: Linear, Integer Linear and Dynamic Programming

Dynamic Programming algorithm for the TSP

C (S , k) = minm∈S\k

(C (S \ k,m) + cmk), k ∈ S

There are O(2n) choices for S and O(n) choices for k , and a total ofO(n2n) states (S , k). To evaluate C (S , k) we need O(n) operations (andsome smart data structure!), so the overall algorithm complexity isO(n22n).

This is still exponential but much better than enumeration (O(n!)).

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 59

Dynamic Programming algorithm for the KP01

Consider a KP01 with n items having weights w and profits c , andcapacity W . The problem is decomposed by considering, at each stage, anadditional item i = 1, . . . , n for inclusion.After i stages, we have decided about inclusion of the first i items. LetCi (w) be the maximum profit that can be obtained from the first i itemsand a capacity w ≤ W (state (i ,w)).

We have the recursion:

Ci+1(w) = maxCi (w),Ci (w − wi+1) + ci+1

The optimal solution value of the KP01 is Cn(W ).

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 60

Page 31: Linear, Integer Linear and Dynamic Programming

Dynamic Programming algorithm for the KP01

KP01(c,w,n,W)

for (w = 0 to W )C0(w) = 0

for (i = 0 to n − 1)for (w = 0 to W )

if (wi ≤ w)Ci+1(w) = maxCi (w),Ci (w − wi+1) + ci+1

elseCi+1(w) = Ci (w)

return Cn(W )

Complexity: O(nW ). This is exponential in the input size, actually theinput for the KP01 has size O(n(logcmax + logwmax ) + logW ).

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 61

Dynamic Programming algorithm for the KP01

Consider the following example of KP01:

n = 4, c = [10, 40, 30, 50], w = [5, 4, 6, 3], W = 10.

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 62

Page 32: Linear, Integer Linear and Dynamic Programming

Dynamic Programming algorithm for the KP01

The algorithm does not keep record of which subset S of items gives theoptimal solution.

To compute the actual subset associated with a state, we can use aflag f (i ,w) which is 1 if we keep item i at state (i ,w) and 0otherwise.

Initialize: i = n, K = W .

If f (i ,K ) = 1, then i ∈ S . Repeat for (i − 1,K − wi );If f (i ,K ) = 0, then i /∈ S . Repeat for (i − 1,K )

Linear, Integer Linear and Dynamic Programming (E. Malaguti) 63