20
Software Development Developing a MAX-CSP Solver Karl Lieberherr

Software Development Developing a MAX-CSP Solver Karl Lieberherr

Embed Size (px)

Citation preview

Page 1: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Software DevelopmentDeveloping a MAX-CSP Solver

Karl Lieberherr

Page 2: Software Development Developing a MAX-CSP Solver Karl Lieberherr

General solver

• Based on transition system

• Correctness of solver– Does it find maximum?

– Does it find a assignment satisfying tG?

Page 3: Software Development Developing a MAX-CSP Solver Karl Lieberherr

General Theme

• The average over a set of assignments is f.

• We want to derive an algorithm that finds an assignment ≥ f.

• Two choices:– randomized algorithm (very simple but has

failure probability)– derandomized algorithm (more complex)

Page 4: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Derandomized algorithm

• Need a correctness proof

• For each variable x in H

if averageH(k=1) > averageH(k=0)

• Need: averageH ≥

max(averageH(k=1) , averageH(k=0) )

Page 5: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Polynomials based on Averages

• meanH(n,k)= average fraction of satisfied constraints in H among all assignments to the n variables of H that set k variables to true.

• appmeanH(x) = average fraction of satisfied constraints in H among all assignments that are generated with a bent coin of probability x.– The averaging includes all assignments but they have

different weights based on the Binomial Distribution.– We generate the assignments following the binomial

distribution and appmean gives the expected value of a random variable: the fraction of satisfied constraints.

– expected value = mean

Page 6: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Look-ahead polynomial

• lapF,N (x) = appmean n-map(F,N) (x)

Page 7: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Binomial Distribution

• X ~ B(n,p)

• The probability of getting exactly k successes: C(n,k)*pk*(1-p)n-k

• E(X) = np

• The most likely value: largest integer ≤ (n+1)*p

Page 8: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Start with a simple case

• meanallH= average fraction of satisfied constraints in H among all assignments to the variables of H.

• meanallH=

1/2 (meanallH(k=1) + meanallH(k=0))

• meanallH= Sum all relations R in H tR(H) mR 2–r(R)

– mR is the number of satisfying rows in truth table of R.

– check: relation 22: 3/8

– max 0 ≤ k ≤ n meanH(n,k) = 4/9 + h(n)

Page 9: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Start with a simple case

• meanallH=

1/2 (meanallH(k=1) + meanallH(k=0))

• Proof: Consider all 2^n assignments. Half set k=1 and half set k=0. We compute the average for the two halves separately and then average the two averages to get the overall average.

Page 10: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Start with a simple case

• Algorithm MEANALL

• Input: H = CSP(G)-formula

• Output: An assignment which satisfies meanallH

• if meanallH(k=1) > meanallH(k=0)

Page 11: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Next more complicated case

• meanH(n,k)

• Want an algorithm for finding an assignment at least as good as meanH(n,k)

Page 12: Software Development Developing a MAX-CSP Solver Karl Lieberherr

mean polynomials

• meanH(n,k)=

k/n * meanH(k=1)(n-1,k-1) +

(n-k)/n * meanH(k=0)(n-1,k)

• C(n,k) = C(n-1,k-1)+C(n,k)

Page 13: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Example

• C(5,2) = C(4,1) + C(4,2)• 10 = 4 + 6• mean(5,2) = C(4,1)/C(5,2) * mean(4,1) + C(4,2)/C(5,2) * mean(4,2) • mean(n,k) = C(n-1,k-1)/C(n,k) * mean(n-1,k-1) + C(n-1,k)/C(n,k) * mean(n-1,k)

Page 14: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Ahmed’s and Christine’s conjecture

For all assignments M:

max 0 ≤ x ≤ 1 appmeann-map(H,M)(x) ≥ fsat(H,M)

An assignment M is maximal if

max 0 ≤ x ≤ 1 appmeann-map(H,M)(x) = fsat(H,M)

Intuition: an assignment is maximal if the polynomials don’t help.

Page 15: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Question

• Does it matter in the definition of maximal whether we use appmean or mean?

Page 16: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Proofs or Counterexamples

• Using Daniel’s programs, we can easily find counterexamples.

• If we cannot find counterexamples, we should find proofs.

Page 17: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Which ones are correct?

• meanH(n,k)=

k/n meanH(k=1)(n-1,k-1) +

(n-k)/n meanH(k=0)(n-1,k)• meanH(n,k) ≤ max(

meanH(k=1)(n-1,k-1),

meanH(k=0)(n-1,k))• appmeanH(x) ≤ max(

appmeanH(k=1)(x), appmeanH(k=0)(x))

Page 18: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Which ones are correct?

• Def: maxappmeanH(x) =

max 0 ≤ x ≤ 1 appmeanH(x)

• maxappmeanH(x) ≤ max(

maxappmeanH(k=1)(x),

maxappmeanH(k=0)(x))

Page 19: Software Development Developing a MAX-CSP Solver Karl Lieberherr

By Analogy

• meanH(n,k)=k/n meanH(k=1)(n-1,k-1) +(n-k)/n meanH(k=0)(n-1,k)

• For 1 ≤ k ≤ n: appmeanH(k/n)=k/n appmeanH(k=1)((k-1)/(n-1)) +(n-k)/n appmeanH(k=0)(k/(n-1))

Page 20: Software Development Developing a MAX-CSP Solver Karl Lieberherr

Example

• Relation = 22

• appmean(x) = 3 x (1-x)2

• mean(n,k) = (3 / C(3,1)) * k * C(n-k,2) / C(n,3) = k * C(n-k,2) / C(n,3)

• rough approximation: – k/n * ((n-k)/n)2 * 1/2 * 6 = 3 x (1-x)2