combinatorial optimisation and related algorithms part ii · optimization problems de nition...

80
Combinatorial optimisation and related algorithms Part II Sophie Pinchinat [email protected] IRISA, Universit´ e de Rennes 1 2020 S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 1/73

Upload: others

Post on 30-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Combinatorial optimisation and related algorithms

Part II

Sophie [email protected]

IRISA, Universite de Rennes 1

2020

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 1/73

Page 2: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Course outine

1. Optimization and Decision problems

2. Principles of intelligent search:I BacktrackingI Branch-and-Bound

3. Approximation Algorithms and Non-Approximability

4. If time left: Local Search

Material http://people.irisa.fr/Sophie.Pinchinat/COBRA.html

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 2/73

Page 3: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Optimization problems

Definition

An optimization problem P can be represented by a 4-tuple (IP ,FP , fP , goalP)where

I IP is the collection of all instances of PI FP with domain IP provides candidate solutions: for X ∈ IP ,

FP(X ) is the family of feasible solutions of the instance X .

I fP is the measure function which is used to compare two candidatesolutions.Let P = {(X , S) |X ∈ IP and S ∈ FP(X )}, then fP : P → ZZ.

I goalP indicates whether the optimization problem is a minimizationproblem or a maximization problem.

We are primarily concerned with minimization problems.We simply consider (IP ,FP , fP) where goalP is implicit.Also we may drop the subscribe P when the context is obvious.Given an instance X ∈ I , S∗ ∈ F (X ) is an optimal solution of X if

f (X ,S∗) ≤ f (X ,S) for all S ∈ F (X )

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 3/73

Page 4: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Optimization problems

A classic optimization problem:

Example (Symmetric TSP)

Let G = (V ,E) be a complete graph with a prescribed cost de for each edgee ∈ E . Then the symmetric traveling salesman problem (TSP) is to find aleast cost hamiltonian cycle in G . This problem is characterized by the triplet(ITSP,FTSP, fTSP, goalTSP) where

IITSP = {G = (V ,E) |

G is a complete graph with prescribed cost we for each e ∈ E}I FTSP(G) = {H |H is a hamiltonian cycle in G};I fTSP(G ,H) =

∑e∈H we , for any H ∈ FTSP(G).

I goalTSP is to minimize fTSP.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 4/73

Page 5: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Decision problems

A decision problem is a ’yes/no’ question.

Example

problem: Hamiltonian cycle (HC)

Input : A graph G = (V ,E).Output : Is there a cycle that visits each vertex exactely once?

Let P be a decision problem and IP be the collection of all instances of P.Then IP can be partitioned into two classes YP and NP , where

I YP contains all instances with answer yes, and

I NP contains all instances with answer no.

Thus given an instance X ∈ IP , the decision problem is to determine if X ∈ YP .

The natural decision problem associated to P = (IP ,FP , fP) is:problem: Pd

Input : An instance X ∈ IP and an integer k ∈ ZZ.Output : Does there exist S ∈ FP(X ) such that fP(X , S) ≤ k?

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 5/73

Page 6: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Constraints problems, SAT

problem: Satisfiability (SAT)

Input : A set C1, . . . ,Cn of n clauses.Output : Is there an assignment of the variables that satisfies all the clauses?

For you: What would it be useful for?

problem: 3Satisfiability (3SAT)

Input : A set C1, . . . ,Cn of n clauses with 3 literals in each clause.Output : An assignment of the variables that satisfies all the clauses.

problem: Maximum Satisfiability (MAXSAT)

Input : A set C1, . . . ,Cn of n clauses and an integer g .Output : Is there an assignment of the variables that satisfies at least g clauses.

For you: What would it be useful for?

Have a look atPractical Applications of Boolean Satisfiability, by Joao Marques-Silva

http://eprints.soton.ac.uk/265340/1/jpms-wodes08.pdf

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 6/73

Page 7: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Problems on graphs: Rudrata, also known as Hamiltonian cycle

A Kashmiri poet named Rudrata had asked this question: Can one visit all thesquares of the chessboard, without repeating any square, in one long walk thatends at the starting square and at each step makes a legal knight move?https://en.wikipedia.org/wiki/Rudrata

https://en.wikipedia.org/wiki/Knight’s_tour

problem: Rudrata (Rudrata)

Input : A graph G = (V ,E)Output : A cycle that passes through every vertex exactly once.

For you: What would it be useful for?

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 7/73

Page 8: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Problems on graphs: Independent set, vertex cover, and clique

problem: Independent Set (IndepSet)

Input : A graph G = (V ,E) and a bound bOutput : Does there exist an independent set S in G of cardinal at least b?

For you: What would it be useful for?

problem: Vertex Cover (VerCov)

Input : An undirected graph G = (V ,E) and k > 0.Output : Does there exist a subset of vertices S ⊆ V with |S | ≤ kthat touches every edge.

For you: What would it be useful for?

problem: Clique (CLIQUE)

Input : A graph G = (V ,E) and an integer g .Output : Is there a subset of g vertices such that all possible edges betweenthem are present?

For you: What would it be useful for?

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 8/73

Page 9: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The Traveling Salesman Problem

problem: Travelling Salesman (TSP)

Input : A graph G = (V ,E), for each e ∈ E , an integer we > 0.Output : A cycle that passes through every vertex exactly oncewith minimal cost.

problem: Symmetric Travelling Salesman (SymTSP)

Input : A undirected graph G = (V ,E), for each e ∈ E , an integer de > 0.Output : A cycle that passes through every vertex exactly oncewith minimal cost.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 9/73

Page 10: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Numerical problems: Subset Sum and Knapsack problems

problem: Subset Sum (SubsetSum)

Input : Natural numbers w1, ..., wn and an integer WOutput : Is there a subset that adds up to exactly W ?

problem: Knapsack (KP)

Input : n items, for each item i two values wi (≥ 0 its weight) et pi (its profit),a constant K ≥ 0.Output : An assignement of the variables x1, x2, . . . , xn in {0, 1} such thatΣn

i=1wi .xi ≤ K and which maximizes the total profit Σni=1pi .xi .

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 10/73

Page 11: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

From decision problems to optimization problems

Each solution has a cost that we want to minimize/maximize.

problem: Maximum Independent Set problem

Input : A graph G = (V ,E)Output : A largest possible independent set S of G .

problem: Minimum Vertex Cover Problem

Input : An undirected graph G = (V ,E).Output : The minimum vertex cover of G .

problem: Maximum Satisfiability Problem

Input : A set C1, . . . ,Cn of n clause.Output : A assignment of the variables that satisfies as many of them as possible.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 11/73

Page 12: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Complexity classes

Definition

An algorithm A for a computational problem P (optimization or decision version)is a polynomial time (space) algorithm if any X ∈ IP can be solved in time(memory space) O(nd) for some constant d , where n is the input size of X .

Definition

The collection of decision problems that can be solved by a polynomial timealgorithm constitutes the class PTIME (Its elements are PTIME-easy problems).

Definition

A superclass of PTIME, called NPTIME, is defined as the class of decisionproblems P where every X ∈ YP has a concise certificate the validity of whichcan be verified in polynomial time (Its elements are NPTIME-easy problems).

For a decision problem P we may write P ∈ PTIME, P ∈ NPTIME, etc.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 12/73

Page 13: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

An example for NPTIME-easiness

problem: Travelling Salesman (TSP)

Input : A graph G = (V ,E) with for each e ∈ E , an integer we > 0,and an integer k ∈ ZZ.Output : A cycle that passes through every vertex exactly once with cost ≤ k.

Proposition

TSP ∈ NPTIME.

Proof.For an ’yes’ instance of this problem a concise certificate would be a collectionof edges that form a hamiltonian cycle in G with cost less than or equal to k.Clearly, whether this collection of edges forms a hamiltonian cycle in G and itscost is less than or equal to K can be verified in O(n) time, where n = |V |.Thus the decision version of TSP ∈ NPTIME.

Exercise

Recallproblem: Satisfiability (SAT)

Input : A set C1, . . . ,Cn of n clauses.Output : Is there an assignment of the variables that satisfies all the clauses?

Show that SAT is NPTIME-easy.S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 13/73

Page 14: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

An example likely not in NPTIME

The following problem

Input : A graph G = (V ,E) and k ∈ IN+.

Output : Do there exist d |V |ke! hamiltonian cycles in G?

is not known to be in NPTIME since we do not know a concise certificate fora ’yes’ instance of this problem, the validity of which can be verified inpolynomial time.

I One possible certificate is a list of d |V |ke! hamiltonian cycles.

I Even though verifying each member of this list is indeed a hamiltoniancycle can be done in polynomial time, counting that there are d |V |

ke! of

them takes time exponential in |V | and hence the certificate is not concise.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 14/73

Page 15: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Reductions

Definition

A decision problem P1 is reducible to a decision problem P2 if there exists analgorithm A whose input is any instance X ∈ IP1 , and returns A(X ) ∈ IP2

X ∈ IP1 Algorithm A A(X ) ∈ IP2

such that X ∈ YP1 if, and only if, A(X ) ∈ YP2 .

Algorithm A is a reduction from P1 to P2.If moreover A is polynomial time, we say that P1 is polynomially reducible to P2

and denote this by P1 ≤PTIME P2.

Algorithm for P1

Algorithm for P2Algorithm AX ∈ IP1 yes/no

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 15/73

Page 16: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

NPTIME-complete problems

Definition

A decision problem P is said to be NPTIME-hard if

for any P ′ ∈ NPTIME, P ′ ≤PTIME P.

Definition

The class of NPTIME-complete problems is the class of problems that are bothNPTIME-easy and NPTIME-hard.

Do have a look at Computers and Intractability, by M.R. Garey and D.S.Johnson.

Theorem (Cook-Levin 1978)

SAT is an NPTIME-complete problem.

Example

The problems SAT, 3SAT, CLIQUE, HC(Rudrata), IndepSet and VerCov areNPTIME-complete problems.

Garey and Johnson. Computers and Intractability.

・Appendix includes over 300 NP-complete problems.

・Most cited reference in computer science literature.

More hard computational problems

39

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 16/73

Page 17: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Bibliography

I Conception d’algorithmes Principes et 150 exercices non corriges., byBosc, P., Guyomard, M., and Miclet, L. EYROLLES 2016.

I Combinatorial Optimization: Algorithms and Complexity, by ChristosH. Papadimitriou, Kenneth Steiglitz. Dover publications, 1998.

I Computers and Intractability, by M.R. Garey and D.S. Johnson. W.H.Freeman, San Francisco, CA, 1979.

I Computational Complexity by C.H. Papadimitriou. Addison-Wesley, NewYork, 1994.

I Algorithms, by Sanjoy Dasgupta, Christos Papadimitriou, Umesh Vazirani.McGraw-Hill Education (India) Pvt Limited, 2006.

I Algorithm Design, by J. Kleinberg and E. Tardos. Addison Wesley, 2005.

I Travelling Salesman Problem: A Guided Tour of CombinatorialOptimization, E.L. Lawler, J.K. Lenstra, A.H.G. Rinooy Kan, and D.B.Shmoys, editors. Wiley. Chichester, 1985.

I The Traveling Salesman Problem and Its Variations, G. Gutin and A.Punnen. Kluwer Academic Publishers, 2002.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 17/73

Page 18: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Principles of intelligent search:

Backtracking / Essais Successifs

Branch-and-Bound / Evaluation et Separation

Progressive

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 18/73

Page 19: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The backtracking paradigm: The zero-sum subset problem

Consider the following problem.

problem: Zero-sum subset problem

Input : A set E with n (≥ 0) elements in ZZ.Output : The list of all the subsets of E that sum up to zero.

The set C of candidates is the powerset P(E), we have to go through all the2n candidates.

The selection predicate is “the sum of all elements equals zero”.

Bibliography “Conception d’algorithmes: Principes et 150 exercices corriges”by Guyomard, Bosc et Miclet.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 19/73

Page 20: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The zero-sum subset problem

We assume that the set E is represented by an array A[1..n] of integer.

Example (where n = 6)

E = {10, 0,−3,−7, 5,−5} represented by A = [10, 0,−3,−7, 5,−5]

Each candidate is represented by its characteristic vector.

Example

Vector [1, 0, 0, 0, 0, 0] represents {10}, and vector [1, 1, 1, 1, 1, 1] represents E .

We alternatively may identify the characteristic vectors with functions fromfrom {1, . . . , n} to {0, 1}.

Given a characteristic vector X , the sum of the elements of the subset itdenotes is given by: ∑

i=1,...,n

X [i ] ∗ A[i ]

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 20/73

Page 21: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Enumerate characteristic vectors

First we need to find a way to enumerate the 2n candidates.We use a recursion tree whose leaves are characterictic vectors.

Example (where n = 3)

∗ ∗ ∗

0 ∗ ∗

00∗

000

0

001

1

0

01∗

010

0

011

1

1

0

1 ∗ ∗

10∗

100

0

101

1

0

11∗

110

0

111

1

1

1

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 21/73

Page 22: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The skeleton algorithm to enumerate characteristic vectors

We perform a traversal of the recursion tree.

Algorithm Subsets1(i)

Require: i ∈ 1..n1: for j in 0..1 do2: X [i ]← j3: if i = n then4: Print(X )5: else6: Subsets1(i + 1)7: end if8: end for

Initial call:

1: Constants n ∈ IN and n = ... and A ∈ [1..n]→ ZZ2: Variables X ∈ [1..n]→ [0..1]3: begin4: Subsets1(1)5: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 22/73

Page 23: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Correction of Algorithm Subsets1(i)

Algorithm Subsets1(i)

Require: i ∈ 1..n1: for j in 0..1 do2: X [i ]← j3: if i = n then4: Print(X )5: else6: Subsets1(i + 1)7: end if8: end for

Exercise

Show that Subsets1 is correct.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 23/73

Page 24: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Selection of the zero-sum subsets

Algorithm Subsets2 is like Subsets1 but filters according to the zero sumpredicate.

Algorithm Subsets2(i)

Require: i ∈ 1..n1: for j in 0..1 do2: X [i ]← j

3: if i = n and ZeroSum then4: Print(X )5: else6: Subsets2(i + 1)7: end if8: end for

Initial call:

1: Constants n ∈ IN and n = ... and A ∈ [1..n]→ ZZ and ZeroSum ∈ Bool2: Variables X ∈ 1..n→ 0..13: begin

4: ZeroSum← false ; Subsets2(1)5: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 24/73

Page 25: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Optimization of Subsets2(i)

Compute the sum on-the-fly:

Algorithm Subsets3(i)

Require: i ∈ 1..n1: for j in 0..1 do

2: X [i ]← j ; CurrentSum← CurrentSum + j ∗ A[i ]

3: if i = n and CurrentSum = 0 then4: Print(X )5: else6: if i 6= n then7: Subsets3(i + 1)8: end if9: end if

10: CurrentSum← CurrentSum − j ∗ A[i ]

11: end for

Initial call:

1: Variables X ∈ 1..n→ 0..1 et CurrentSum ∈ ZZ2: begin

3: CurrentSum← 0 ; Subsets3(1)4: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 25/73

Page 26: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Complexity

∗ ∗ ∗

0 ∗ ∗

00∗

000

0

001

1

0

01∗

010

0

011

1

1

0

1 ∗ ∗

10∗

100

0

101

1

0

11∗

110

0

111

1

1

1

The number of recursive calls corresponds to the number of internal nodes ofthe recursion tree, namely 2n − 1.

Can we avoid this brute force approach?

More generally, we will see that it is not always necessary to enumerate all thecandidates: some of them may be discarded at an early stage.

This principle is called the pruning.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 26/73

Page 27: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The pruning criterion for the zero-sum subsets problem

We may remark the following: if at a given time of the computation, theabsolute value |CurrentSum| is strictly greater than absolute value of theextremum of A (written AbsExtA) multiplied by the number of remainingvalues in A, then this node need not be developed further.

Exercise

Give an example.

Exercise

Find another criterion that is smarter.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 27/73

Page 28: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Improvement of Subsets3(i) by pruning

Algorithm Subsets4(i)

Require: i ∈ 1..n1: for j in 0..1 do2: CurrentSum← CurrentSum + j ∗ A[i ]

3: if |CurrentSum| ≤ (n − i) ∗ AbsExtA then

4: X [i ]← j5: if i = n and CurrentSum = 0 then6: Print(X )7: else8: if i 6= n then9: Subsets4(i + 1)

10: end if11: end if12: end if13: CurrentSum← CurrentSum − j ∗ A[i ]14: end for

Initial call: AbsExtA← max{|max(A)|, |min(A)|}; Subsets4(1)

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 28/73

Page 29: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Functions and skeleton

We consider a more general/abstract situation where we seek for functionsfrom I = 1..n to F = 1..m.

We will consider:

I the total functions;

I the surjective total functions;

I the injective total functions;

Cases of partial functions will be considered in supervised exercises (TD).

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 29/73

Page 30: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Enumeration of all total functions

from interval I = 1..n to interval F = 1..m.

Algorithm T (i)

Require: i ∈ 1..n1: for j in 1..m do2: X [i ]← j3: if i = n then4: Print(X )5: else6: T (i + 1)7: end if8: end for

Initial call:

1: Constants n ∈ IN and m ∈ IN.2: Variables X ∈ 1..n→ 1..m3: begin4: T (1)5: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 30/73

Page 31: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Complexity of Algorithm T (1)

Algorithm T (i)

Require: i ∈ 1..n1: for j in 1..m do2: X [i ]← j3: if i = n then4: Print(X )5: else6: T (i + 1)7: end if8: end for

There are∑i=n

i=1 mi recursive calls, namely O((mn+1 − 1)/(m − 1)).

Because (mn+1 − 1))/(m − 1) is exponenetial in n, this prevents us from usingthis algorithm in practice.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 31/73

Page 32: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Total functions over a cartesian product

How can we adapt the previous approach if I is 2-dimensional,say I = [1..n]× [1..q]?Now, vector X is a matrix, and we get Algorithm is T 2D(`, c) as follows.

Algorithm T 2D(`, c)

Require: ` ∈ 1..n et c ∈ 1..q1: for j in 1..m do2: X [`, c]← j3: if ` = n and c = q then4: Print(X )5: else6: if c = q then7: T 2D(` + 1, 1)8: else9: T 2D(`, c + 1)

10: end if11: end if12: end for

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 32/73

Page 33: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Recursion tree for surjective total functions from 1..3 to 1..2.

∗ ∗ ∗

1 ∗ ∗

11∗

111

1

112

2

1

12∗

121

1

122

2

2

1

2 ∗ ∗

21∗

211

1

212

2

1

22∗

221

1

222

2

2

2

Total functionscorrespond togreen leaves.

Algorithm TS(i)

Require: i ∈ 1..n1: for j in 1..m do

2: X [i ]← j ; previousB ← B[j ] ; B[j ]← vrai

3: if i = n and for all k ∈ 1..m, B[k] then

4: Print(X )5: else6: TS(i + 1)7: end if8: B[j ]← previousB

9: end for

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 33/73

Page 34: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Surjective total functions

Enumerate all surjective total functions between intervals I et F.

Algorithm TS(i)

Require: i ∈ 1..n1: for j in 1..m do

2: X [i ]← j ; previousB ← B[j ] ; B[j ]← vrai

3: if i = n and for all k ∈ 1..m, B[k] then

4: Print(X )5: else6: TS(i + 1)7: end if8: B[j ]← previousB

9: end for

Initial call:

1: Variables X ∈ [1..n] → [1..m] and

previousB ∈ Bool and B ∈ [1..m]→ Bool

2: begin

3: B ← (1..m)× {false} ; TS(1)

4: endS. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 34/73

Page 35: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Enumerate all injective total functions

We extend the Algorithm T (1) as IT (1) in order to enumerate all injectivetotal functions from I = 1..n to F = 1..m.For the call of order i , we discard from set F all elements that have alreadybeen selected in previous choices (i.e. in X [1..i − 1]).

Algorithm IT (i)

Require: i ∈ 1..n1: for j in 1..m \ codom(X [1..i − 1]) do2: X [i ]← j3: if i = n then4: Print(X )5: else6: IT (i + 1)7: end if8: end for

Exercise

Draw the recursion tree for the case I = 1..3 and F = 1..4.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 35/73

Page 36: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Injective and bijective total functions, permutations

Exercise

How many injective total functions are there from I = 1..n to F = 1..m?How many recursive calls of IT are there?

There are Anm = m!/(m − n)!, whenever m ≥ n.

Algorithm IT (i)

Require: i ∈ 1..n1: for j in 1..m \ codom(X [1..i − 1]) do2: X [i ]← j3: if i = n then4: Print(X )5: else6: IT (i + 1)7: end if8: end for

Remark that for I = 1..n = F, Algorithm IT (1) enumerates all bijections orequivalently all permutations over n elements.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 36/73

Page 37: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Injective and bijective total functions, permutations

Exercise

How many injective total functions are there from I = 1..n to F = 1..m?How many recursive calls of IT are there?

There are Anm = m!/(m − n)!, whenever m ≥ n.

Algorithm IT (i)

Require: i ∈ 1..n1: for j in 1..m \ codom(X [1..i − 1]) do2: X [i ]← j3: if i = n then4: Print(X )5: else6: IT (i + 1)7: end if8: end for

Remark that for I = 1..n = F, Algorithm IT (1) enumerates all bijections orequivalently all permutations over n elements.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 36/73

Page 38: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Injective and bijective total functions, permutations

Exercise

How many injective total functions are there from I = 1..n to F = 1..m?How many recursive calls of IT are there?

There are Anm = m!/(m − n)!, whenever m ≥ n.

Algorithm IT (i)

Require: i ∈ 1..n1: for j in 1..m \ codom(X [1..i − 1]) do2: X [i ]← j3: if i = n then4: Print(X )5: else6: IT (i + 1)7: end if8: end for

Remark that for I = 1..n = F, Algorithm IT (1) enumerates all bijections orequivalently all permutations over n elements.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 36/73

Page 39: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Template for backtracking algorithms

We study templates for

I “AllSolutions”

I “OneSolution”

I “OptimalSolution”, for some optimality criterion

Example (Zero-sum subset problems)

Instead of enumerating all solutions, we may ask for:

I “OneSolution”: i.e. is there one zero-sum subset?

I “OptimalSolution”: e.g. a maximal zero-sum subset, if any.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 37/73

Page 40: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Templates for “AllSolutions”

Algorithm AllSol(i)

Require: i ∈ 1..n1: for j in 1..m do2: if Admissible(i , j) then3: X [i ]← j ; Update(i , j)4: if i = n and then SolutionFound then5: Sol ← Sol ∪ {X}6: else7: if i 6= n then8: AllSol(i + 1)9: end if

10: end if11: Undo(i , j)12: end if13: end for

I Admissible(i , j) is used to prune,

I Modify et Undo go in pairs: they are needed to propagate the context ofthe current choice and to release this context, respectively.

I Condition SolutionFound (which may be useless) expresses that thestructure X satisfies the contraints given by the very problem to be solved.

I Notice that condition (i 6= n) is needed only when we use SolutionFound ,since the current structure X might be incomplete and the search muststill go on.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 38/73

Page 41: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Templates for “OptimalSolution: a total ordering betweencandidates and we assume there is at leas one solution

(1) Y is a global variable that hosts an optimal solution, (2)StoreCurrentContext stores in global variables information to compare thesolutions in order to evaluate BetterSolution.

Algorithm OptSol(i)

Require: i ∈ 1..n1: for j in 1..m do2: if Admissible(i , j) then3: X [i ]← j ; Modify(i , j)4: if i = n and then SolutionFound(i , j) then5: if BetterSolution(X ) then6: Y ← X7: StoreCurrentContext8: end if9: else

10: if i 6= n then11: OptSol(i + 1)12: end if13: end if14: Undo(i , j)15: end if16: end for

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 39/73

Page 42: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Templates for “OptimalSolution”

Exercise

Write the context for the call of OptSol .

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 40/73

Page 43: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Templates for “OptimalSolution”

Exercise

Write the context for the call of OptSol .

1: Constants n ∈ IN and n = ... and T ∈ n→ ZZ and T = [...]2: Variables X ∈ 1..n → 1..m, Found ∈ Bool (for found a solution),

and X ∗ ∈ 1..n→ 1..m (best solution so far)3: begin4: X ∗ ←⊥ ; OptSol(1) ; Print(X ∗)5: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 40/73

Page 44: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Templates for “OptimalSolution”

Exercise

What should we write if we do not assume there is a solution?

Algorithm OptSol(i)

Require: i ∈ 1..n1: for j in 1..m do2: if Admissible(i , j) then3: X [i ]← j ; Modify(i , j)4: if i = n and then SolutionFound(i , j) then5: Found ← true6: if BetterSolution(X ) then7: X ∗ ← X8: StoreCurrentContext9: end if

10: else11: if i 6= n then12: OptSol(i + 1)13: end if14: end if15: Undo(i , j)16: end if17: end for

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 41/73

Page 45: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Templates for “OptimalSolution”

Exercise

What should we write if we do not assume there is a solution?

Algorithm OptSol(i)

Require: i ∈ 1..n1: for j in 1..m do2: if Admissible(i , j) then3: X [i ]← j ; Modify(i , j)4: if i = n and then SolutionFound(i , j) then5: Found ← true6: if BetterSolution(X ) then7: X ∗ ← X8: StoreCurrentContext9: end if

10: else11: if i 6= n then12: OptSol(i + 1)13: end if14: end if15: Undo(i , j)16: end if17: end for

1: Constants n ∈ IN and n = ... and T ∈ n→ ZZ and T = [...]2: Variables X ∈ 1..n→ 1..m and Found ∈ Bool3: begin4: Found ← false ; OptSol(1)5: if Found then6: Print(X ∗)7: end if8: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 41/73

Page 46: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Template for “OneSolution”

Exercise

Your job!

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 42/73

Page 47: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Branch-and-Bound≡

Programmation par Separation et EvaluationProgressive

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 43/73

Page 48: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Context

I A set C of candidates;

I Each element of C is given a cost : C → IR+;

I We look for a solution, that is any candidate c∗ such that

cost(c∗) = minc∈C

cost(c)

If the set of candidates C is big, it is not tractable to enumerate its elements.

This is typically the case for NPTIME-complete problems.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 44/73

Page 49: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Principles of Branch-and-Bound

I Let {C1,C2, . . .Cn} be a partition of C, the set of candidates.

I We assume that we have a function, called a heuristics, thatunder-approximates the cost of all candidates in Ci :

f (Ci ) ≤ minc∈Ci

cost(c)

{a, b, c, d , e, f , g , h, i , j , k} 3

{a, b, c} 7 {d , e, f , g} 3

{d , e} 3 {f , g} 3

{h, i , j , k} 8

OPEN

“Current” partition is {{a, b, c}, {d , e}, {f , g}, {h, i , j , k}}

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 45/73

Page 50: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Principles of Branch-and-Bound

The algorithm principle: Start with partition OPEN = {C}.

1. Branching step:take C in OPEN with minimal f (C); OPEN.renove(C)if C with minimal f (C) in OPEN is a singleton {c}then return c,otherwise split C into non-empty sets Ci1 ,Ci2 , . . .Cim

2. Bounding step: for each Cik , compute f (Cik ); OPEN.add(Cik ); go to 1.

{a, b, c, d , e, f , g , h, i , j , k} 4

{a, b, c} 3

{a, b} 5

{a}5

{b}7

{c} 9

{d , e, f , g} 4

{d , e} 8

{d}8

{e}9

{f , g} 4

{f }4

{g}8

{h, i , j , k} 10

{h, i} 10

{h}10

{i}12

{j , k} 11

{j}11

{k}14

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 46/73

Page 51: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The two steps of Branch-and-Bound

We rely on the duality between partition and the search tree.

A Branch-and-Bound algorithm virtually searches through a part of the tree.

1. the branching step uses fonction f to select in OPEN the most promisingsubset of candidates.⇒ the tree expansion is not fixed in advance, as opposed to backtracking.

2. the bounding step: each new set C is given its value f (C) before it isadded to OPEN.

{a, b, c, d , e, f , g , h, i , j , k} 4

{a, b, c} 3

{a, b} 5

{a}5

{b}7

{c} 9

{d , e, f , g} 4

{d , e} 8

{d}8

{e}9

{f , g} 4

{f }4

{g}8

{h, i , j , k} 10

{h, i} 10

{h}10

{i}12

{j , k} 11

{j}11

{k}14

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 47/73

Page 52: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The two issues of the branching step

1. How to split a set C?

2. How to efficiently represent each node?

The answer depends on the problem to solve.In many cases, we find an adaptation of the backtracking approach to expand anode:

I The partially-filled vector X [1..i ] is seen as the set of all its completionsi.e. all vectors Y [1..n] such Y [1..i ] = X [1..i ];

I The branching step amounts to instanciating component X [i ] in allpossible manner.

∗ ∗ ∗

1 ∗ ∗

11∗

111 112

12

2 ∗ ∗

21

211 212

22

221 222

3 ∗ ∗

31∗

311 312

32∗

321 322

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 48/73

Page 53: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The branching step

The set OPEN is implemented as a priority queue .

The node to expend next is OPEN.first.

{a, b, c, d , e, f , g , h, i , j , k} 3

{a, b, c} 7 {d , e, f , g} 3

{d , e} 3

{d}7

{e}6

{f , g} 3

{h, i , j , k} 8

OPEN

The Branch-and-Bound boundaries lie in the size of OPEN

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 49/73

Page 54: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The bounding step

Before a new node is added to OPEN, we must compute its priority.

Definition

Let f ∗ : P(C) \ ∅ → IR be defined by:{f ∗({c}) = cost(c) for every candidate c ∈ Cf ∗(C) = minc∈C f ∗({c}) for n > 1

By definition, f ∗(C) is the cost of a solution. Also function f ∗ increases whilewe go down a branch of the tree: C ′ ⊆ C implies f ∗(C) ≤ f ∗(C ′)

Since function f ∗ is unknown, we use an evaluation function f , called aheuristics, well-chosen by the designer of the Branch-and-Bound algorithm.

Theorem

If the evaluation function f satisfies the following two conditions:

(a) f is positive and remains below f ∗ : for all C ⊆ C, 0 ≤ f (C) ≤ f ∗(C);

(b) for every candidate c ∈ C, f ({c}) = f ∗(c) (= cost(c)).

then the Branch-and-Bound algorithm is admissible, i.e. it computes an optimalsolution.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 50/73

Page 55: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Template for Branch-and-Bound

We let f (C) be an under estimation of f ∗(C) for each node C .

Algorithm Branch-and-Bound

1: constants/types2: type: set C = {...} and set ElmtPQ = {(C , p) | ∅ ⊂ C ⊆ C and p ∈ IR+}3: variables4: OPEN is a priority queue over ElmtPQ5: begin6: OPEN.new ; OPEN.add(C, f (C)))7: while not(IsSingleton(OPEN.first)) do8: (C , p)← OPEN.get;9: for C ′ ∈ Branch(C) do

10: OPEN.add(C ′, f (C ′))11: end for12: end while13: Print(OPEN.get)14: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 51/73

Page 56: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Correctness of Algorithm Branch-and-Bound

Algorithm Branch-and-Bound

1: constants/types2: type: set C = {...} and set ElmtPQ = {(C , p) | ∅ ⊂ C ⊆ C and p ∈ IR+}3: variables4: OPEN is a priority queue over ElmtPQ5: begin6: OPEN.new ; OPEN.add(C, f (C)))7: while not(IsSingleton(OPEN.first)) do8: (C , p)← OPEN.get;9: for C ′ ∈ Branch(C) do

10: OPEN.add(C ′, f (C ′))11: end for12: end while13: Print(OPEN.get)14: end

Lemma

Algorithm Branch-and-Bound terminates.

Lemma

Loop invariant of line 7: “the priority queue OPEN contains a partition of setC”.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 52/73

Page 57: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Remarks on Branch-and-Bound algorithm

1. The current version of Branch-and-Bound puts all the candidates inOPEN, but it might be the case that some elements of C are not evencandidates. Think of TSP when no Hamiltonian cycle exists in the graph.

Exercise

What would you add in the algorithm ?

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 53/73

Page 58: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Remarks on Branch-and-Bound algorithm

1. The current version of Branch-and-Bound puts all the candidates inOPEN, but it might be the case that some elements of C are not evencandidates. Think of TSP when no Hamiltonian cycle exists in the graph.

Exercise

What would you add in the algorithm ?

Algorithm Branch-and-Bound

1: constants/types2: types: set C = {...} and set ElmtPQ = {(C , p) | ∅ ⊂ C ⊆ C and p ∈ IR+}3: variables4: OPEN is a priority queue over ElmtPQ5: begin6: OPEN.new ; OPEN.add(C, f (C)))7: while not(OPEN.isEmpty or then IsSingleton(OPEN.first)) do8: (C , p)← OPEN.get;9: for C ′ ∈ Branch(C) do

10: OPEN.add(C ′, f (C ′))11: end for12: end while13: if OPEN.isEmpty then14: Print(“No solution”)15: else // IsSingleton(OPEN.first)16: Print(OPEN.get)17: end if18: end

What would the loop invariant become ?

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 53/73

Page 59: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Remarks on Branch-and-Bound algorithm

1. The current version of Branch-and-Bound puts all the candidates inOPEN, but it might be the case that some elements of C are not evencandidates. Think of TSP when no Hamiltonian cycle exists in the graph.

Exercise

What would you add in the algorithm ?

Algorithm Branch-and-Bound

1: constants/types2: types: set C = {...} and set ElmtPQ = {(C , p) | ∅ ⊂ C ⊆ C and p ∈ IR+}3: variables4: OPEN is a priority queue over ElmtPQ5: begin6: OPEN.new ; OPEN.add(C, f (C)))7: while not(OPEN.isEmpty or then IsSingleton(OPEN.first)) do8: (C , p)← OPEN.get;9: for C ′ ∈ Branch(C) do

10: OPEN.add(C ′, f (C ′))11: end for12: end while13: if OPEN.isEmpty then14: Print(“No solution”)15: else // IsSingleton(OPEN.first)16: Print(OPEN.get)17: end if18: end

What would the loop invariant become ?

2. We may use a cleaning heuristic to shrink the cardinal of OPEN as muchas possible: if candidate {c} is introduced in OPEN, then we may discardall other candidates with a highest priority.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 53/73

Page 60: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Remarks on Branch-and-Bound algorithm

1. The current version of Branch-and-Bound puts all the candidates inOPEN, but it might be the case that some elements of C are not evencandidates. Think of TSP when no Hamiltonian cycle exists in the graph.

Exercise

What would you add in the algorithm ?

2. We may use a cleaning heuristic to shrink the cardinal of OPEN as muchas possible: if candidate {c} is introduced in OPEN, then we may discardall other candidates with a highest priority.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 53/73

Page 61: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Algorithm Branch-and-Bound with pruning

We may exploit value f (C) to prune the tree.

Exercise

Do modify Algorithm Branch-and-Bound to take pruning into account.

Algorithm Branch-and-Bound

1: constants/types2: types: set C = {...} and set ElmtPQ = {(C , p) | ∅ ⊂ C ⊆ C and p ∈ IR+}3: variables4: OPEN is a priority queue over ElmtPQ5: begin6: OPEN.new ; OPEN.add(C, f (C)))7: while not(OPEN.isEmpty or then IsSingleton(OPEN.first)) do8: (C , p)← OPEN.get;9: for C ′ ∈ Branch(C) do

10: OPEN.add(C ′, f (C ′))11: end for12: end while13: if OPEN.isEmpty then14: Print(“No solution”)15: else // IsSingleton(OPEN.first)16: Print(OPEN.get)17: end if18: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 54/73

Page 62: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

f ∗ vs. f : an interesting case

It may happen that each node of the tree has a value such that the costcost(c) of a candidate corresponds to the sum of the edge cost from the rootnode C to the leaf node {c}.Think of the shortest path problem.

Then f ∗(C) can be written for each node C as:

f ∗(C) = g∗(C) + h∗(C)

where

I g∗(C) is the cost of the path from C to C (past+present), and

I h∗(C) is the cost of the best path below C in the tree (future).

Notice that this particular case of f ∗ is compatible with the generic version ofthe Branch-and-Bound algorithm.

For the evaluation fonction, we take

f (C) = g∗(C) + h(C)

where h is called a heuristic function that estimates what can be expected “inthe future”.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 55/73

Page 63: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Heuristic functions: Branch-and-Bound admissibility

Theorem (Sufficient conditions for Branch-and-Bound admissibility)

Let f be an evaluation function defined by:

f (C) = g∗(C) + h(C)

where g∗(C) is the cost of the path to C . If the heuristic function satisfies:

0 ≤ h(C) ≤ h∗(C), for all C ⊆ C

then Branch-and-Bound is admissible.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 56/73

Page 64: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Heuristic function: an example

with f ∗ at the leaves equal to the sum of the edge values. RunBranch-and-Bound.

{a, b, c, d , e, f , g , h, i , j , k}

{a, b, c}

{a, b}

{a}5

1

{b}7

3

2

{c}9

7

2

{d , e, f , g}

{d , e}

{d}7

3

{e}6

4

3

{f , g}

{f }4

1

{g}8

5

1

2

{h, i , j , k}

{h, i}

{h}10

7

{i}12

5

3

{j , k}

{j}11

7

{k}14

10

2

2

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 57/73

Page 65: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Heuritic functions: impact on Branch-and-Bound algorithm

If we write v(C ,C ′) for the value of edge (C ,C ′) in the tree, the template forAlgorithm Branch-and-Bound is as follows.

Algorithm Branch-and-Bound

1: constants2: C = {...} and ElmtPQ = {(C , past, past + future) | ∅ ⊂ C ⊆ C and past ∈

IR+ and future ∈ IR+}3: variables4: OPEN ∈ PQ(ElmtPQ)5: begin6: OPEN.new ; OPEN.add(C, 0, 0 + h(C))7: while not(OPEN.isEmpty or then IsSingleton(OPEN.first)) do8: (C , past, past + future)← OPEN.get;9: for C ′ ∈ Branch(C) do

10: OPEN.add(C ′, past + v(C ,C ′), past + v(C ,C ′) + h(C ′))11: end for12: end while13: if OPEN.isempty then14: Print(“No solution”)15: else // IsSingleton(OPEN.first)16: Print(OPEN.get)17: end if18: end

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 58/73

Page 66: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Heuristic functions: comparison

The more the value h is closed to h∗, the more efficient is the algorithm.

Lemma

Let h1 and h2 be two heuristic functions such that for all C ⊆ C,

h1(C) ≤ h2(C) ≤ h∗(C)

and let A1 (resp. A2) be a version of Branch-and-Bound that uses heuristic h1

(resp. h2).

Then, if node C is not chosen by A1, neither it will be by A2.

A trivial but ineffective choice is to take h = 0, namely we cannot tell anythingabout the future.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 59/73

Page 67: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

How do you choose the heuristic function?

I It must satisfyh(C) ≤ h∗(C), for all C ⊆ C

I It should be computed efficiently, say polynomial;

I Very powerful techniques rely on a relaxation of the original problem sothat a greedy algorithm exists.problem: Knapsack (KP)

Input : n items, for each item i two values wi (≥ 0 its weight) et pi (its profit),a constant K ≥ 0.Output : An assignement of the variables x1, x2, . . . , xn in {0, 1} such thatΣn

i=1wi .xi ≤ K and which maximizes the total profit Σni=1pi .xi .

andproblem: Fractional Knapsack (KPfrac)

Input : n items, for each item i two values wi (≥ 0 its weight) et pi (its profit),a constant K ≥ 0.Output : An assignement of the variables x1, x2, . . . , xn in [0, 1] such thatΣn

i=1wi .xi ≤ K and which maximizes the total profit Σni=1pi .xi .

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 60/73

Page 68: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Example of the Job Assignment Problem

Let there be N workers and N jobs. Any worker can be assigned to perform anyjob, incurring some cost that may vary depending on the work-job assignment.It is required to perform all jobs by assigning exactly one worker to each joband exactly one job to each agent in such a way that the total cost of theassignment is minimized.

Take a look at https://www.youtube.com/watch?v=F4vI_qc_u0Q

Exercise

Formalize everything that this video presents.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 61/73

Page 69: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Other kind of heuristics

Which branch should be developped first can be decided very locally.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 62/73

Page 70: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Again: Job Assignement problem

Let there be N workers and N jobs. Any worker can be assigned to perform anyjob, incurring some cost that may vary depending on the work-job assignment.It is required to perform all jobs by assigning exactly one worker to each joband exactly one job to each agent in such a way that the total cost of theassignment is minimized.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 63/73

Page 71: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Job Assignment Problem using Branch And Bound

I The search for an optimal solution can often be speeded by using an“intelligent” ranking function, a heurostics, that approximates the costfunction to avoid searching in sub-trees that do not contain an optimalsolution.

I It is similar to bactracking-like search but with one major optimization:instead of following a FIFO order, we choose a live node with least cost.

I We may not get optimal solution by following node with least promisingcost, but it will provide very good chance of getting the search to ananswer node quickly.

For the Job Assignment Problem, there are two approaches to calculate thecost function:

1. For each worker, we choose job with minimum cost from list of unassignedjobs (take minimum entry from each row).

2. For each job, we choose a worker with lowest cost for that job from list ofunassigned workers (take minimum entry from each column).

see https://www.geeksforgeeks.org/

job-assignment-problem-using-branch-and-bound/

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 64/73

Page 72: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Job Assignment Problem using Branch And Bound

For each worker, we choose job with minimum cost from list of unassigned jobs(take minimum entry from each row).

Recall that a best solution had cost 13.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 65/73

Page 73: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Videos to watch

Applications of Branch-and-Bound

I Integer linear programminghttps://www.youtube.com/watch?v=F-jFk1BczYg

I Job assignement https://www.geeksforgeeks.org/job-assignment-problem-using-branch-and-bound/

https://www.youtube.com/watch?v=F4vI_qc_u0Q

I Knapsack problemhttps://fr.coursera.org/learn/discrete-optimization/lecture/

66OlO/knapsack-5-relaxation-branch-and-bound (incomplete)

I A* https://duckduckgo.com/?q=branch+and+bound&t=h_&ia=videos&

iax=videos&iai=gGQ-vAmdAOI

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 66/73

Page 74: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Approximation Algorithms

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 67/73

Page 75: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Main bibliography

Readings:

I Chapter 11 of “Algorithm Design” by J. Kleinberg and E. Tardos [?].

I Sections 1-2, Chapter 9 of “Algorithms” by S. Dasgupta, C.H.Papadimitriou, and U. Vazirani [?].

How should we design algorithms for problems where polynomial time seemshopeless?

We may use approximation algorithms, which run in polynomial time and findsolutions that are guaranteed to be close to optimal.

At the same time, we will be interested in proving that our algorithms findsolutions that are guaranteed to be close to the optimum.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 68/73

Page 76: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Chapter 11 of Kleinberg and Tardos

We will consider four general techniques for designing approximationalgorithms.

1. Greedy algorithms. These algorithms are simple and fast with thechallenge being to find a greedy rule that leads to solutions provably closeto optimal.

2. Pricing method. This approach is motivated by an economic perspective;we consider a price one has to pay to enforce each constraint of theproblem. The pricing method is often referred to as the primal-dualtechnique, a term inherited from the study of linear programming.

3. Linear programming and rounding. We exploit the relationship betweenthe computational feasibility of linear programming and the expressivepower of its more difficult cousin, integer programming.

4. Dynamic programming on a rounded version of the input. This techniquecan lead to extremely good approximations.

We now use slides from Kleinberg and Tardos at http://www.cs.princeton.edu/~wayne/kleinberg-tardos/pdf/11ApproximationAlgorithms.pdf.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 69/73

Page 77: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

The approximability hierarchy

Given any NPTIME-complete optimization problem, we seek the bestapproximation algorithm possible.Failing this, we try to prove lower bounds on the approximation ratios that areachievable in polynomial time (we carried out such a proof for the generalTSP).NPTIME-complete optimization problems are classified as follows:

1. Those for which, like the TSP, no finite approximation ratio exists.

2. Those for which an approximation ratio exists, but there are limits to howsmall this can be. VerCov, k-cluster (Center Selection), and the TSPwith triangle inequality belong here.For such problems we have not established limits to their approximability,but these limits do exist, and their proofs constitute some of the mostsophisticated results in this field.

3. Those for which approximability has no limit, and polynomialapproximation algorithms with error ratios arbitrarily close to zero exist,KP resides here.

4. Finally, there is another class of problems, between the first two givenhere, for which the approximation ratio is about log(n).SetCov is an example (find out how this works).

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 70/73

Page 78: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Final remarks on approximation algorithms

I All these results on approximation algorithms is contingent upon theassumption PTIME 6= NPTIME.

Failing this, the hierarchy collapses down to PTIME, and allNPTIME-complete optimization problems can be solved exactly inpolynomial time.

I Often these approximation algorithms, or their variants, perform muchbetter on typical instances than their worst-case approximation ratio.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 71/73

Page 79: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

Local Search

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 72/73

Page 80: Combinatorial optimisation and related algorithms Part II · Optimization problems De nition Anoptimization problem Pcan be represented by a 4-tuple (I P;F P;f P;goal P) where I I

What is Local Search?

Local search is a very general technique.

I It describes any algorithm that “explores” the space of possible solutionsin a sequential fashion, moving in one step from a current solution to a“nearby” one.

I The generality and flexibility of this notion has the advantage that it is notdifficult to design a local search approach to almost any computationallyhard problem.

I The counterbalancing disadvantage is that it is often very difficult to sayanything precise or provable about the quality of the solutions that a localsearch algorithm finds, and consequently very hard to tell whether one isusing a good local search algorithm or a poor one.

Readings [?, Chapter 12] and [?, Section 3 of Chapter 9]

We now use slides from Kleinberg and Tardos.

S. Pinchinat Combinatorial optimisation and related algorithms Part II COBRA – 2020 73/73