Presentation is loading. Please wait.

Presentation is loading. Please wait.

Soft constraints. Classical (hard) Constraints Variables {X 1,…,X n }=X Variables {X 1,…,X n }=X Domains {D(X 1 ),…,D(X n )}=D Domains {D(X 1 ),…,D(X.

Similar presentations


Presentation on theme: "Soft constraints. Classical (hard) Constraints Variables {X 1,…,X n }=X Variables {X 1,…,X n }=X Domains {D(X 1 ),…,D(X n )}=D Domains {D(X 1 ),…,D(X."— Presentation transcript:

1 Soft constraints

2 Classical (hard) Constraints Variables {X 1,…,X n }=X Variables {X 1,…,X n }=X Domains {D(X 1 ),…,D(X n )}=D Domains {D(X 1 ),…,D(X n )}=D Constraints: each constraint c connects a subset of X and is a subset of the Cartesian product of the domains of its variables (allowed combinations) Constraints: each constraint c connects a subset of X and is a subset of the Cartesian product of the domains of its variables (allowed combinations) Example: graph coloring Example: graph coloring Variables: nodes of the graph Variables: nodes of the graph Domains: sets of colours Domains: sets of colours Constraints: two variables, set of pairs of colours (different colours) Constraints: two variables, set of pairs of colours (different colours)  

3 Classical constraints are useful for... resource allocation resource allocation scheduling scheduling vehicle routing vehicle routing car sequencing car sequencing timetabling timetabling graph coloring graph coloring VLSI design VLSI design vision vision Robotics Robotics...... However, in most real-life situations we need to express fuzziness, possibilities, preferences, probabilities, costs,...

4 Why is this not enough? Over-constrained problems Over-constrained problems it does not make sense to just say that there is no solution it does not make sense to just say that there is no solution Optimization problems Optimization problems Also multi-criteria Also multi-criteria Problems with both preferences and hard statements Problems with both preferences and hard statements ex.: time-tabling (hard constraints about space and time, soft constraints about teachers) ex.: time-tabling (hard constraints about space and time, soft constraints about teachers) Problems with uncertainty Problems with uncertainty

5 A problem with preferences The problem: to decide what to eat at a restaurant, given some choices for drinks and dishes The problem: to decide what to eat at a restaurant, given some choices for drinks and dishes The client has some preferences over drinks, dishes, and their combinations The client has some preferences over drinks, dishes, and their combinations Examples: Examples: White wine is the most preferred drink White wine is the most preferred drink Pizza is the most preferred dish Pizza is the most preferred dish Fish is less preferred Fish is less preferred white wine and fish is the most preferred combination white wine and fish is the most preferred combination red wine and meat is less preferred red wine and meat is less preferred We look for a combination which “maximizes” the overall preference of the client We look for a combination which “maximizes” the overall preference of the client

6 Soft Constraints: the C-semiring framework Variables {X 1,…,X n }=X Variables {X 1,…,X n }=X Domains {D(X 1 ),…,D(X n )}=D Domains {D(X 1 ),…,D(X n )}=D C-semiring : C-semiring : A set of preferences A set of preferences + additive operator, inducing the ordering: a≥b iff a+b=a (idempotent, commutative, associative, unit element 0); + additive operator, inducing the ordering: a≥b iff a+b=a (idempotent, commutative, associative, unit element 0); x multiplicative operator: combines preferences (commutative, associative, unit element 1, absorbing element 0) x multiplicative operator: combines preferences (commutative, associative, unit element 1, absorbing element 0) 0,1 respect. bottom and top element 0,1 respect. bottom and top element x distributes over + x distributes over + [Bistarelli, Montanari, Rossi, IJCAI 1995]

7 Soft Constraints: the C-semiring framework + and x monotone on ≤ + and x monotone on ≤ for all a,b in A, a x b ≤ a for all a,b in A, a x b ≤ a for all a in A, 0 ≤ a ≤ 1 for all a in A, 0 ≤ a ≤ 1 Lattice Lattice + is lub + is lub x glb if x idempotent x glb if x idempotent When ≤ is a total order and x idempotent: When ≤ is a total order and x idempotent: if a ≤ b, then a + b = b and a x b = a, thus +=max and x=min if a ≤ b, then a + b = b and a x b = a, thus +=max and x=min

8 Soft constraints Soft constraint: a pair c= where: Soft constraint: a pair c= where: Scope: con={X c 1,…, X c k } subset of X Scope: con={X c 1,…, X c k } subset of X Preference function : Preference function : f: D(X c 1 )x…xD(X c k ) → A f: D(X c 1 )x…xD(X c k ) → A tuple (v 1,…, v k ) → p preference tuple (v 1,…, v k ) → p preference Hard constraint: a soft constraint where for each tuple (v 1,…, v k ) Hard constraint: a soft constraint where for each tuple (v 1,…, v k ) f (v 1,…, v k )=1 the tuple is allowed f (v 1,…, v k )=1 the tuple is allowed f (v 1,…, v k )=0 the tuple is forbidden f (v 1,…, v k )=0 the tuple is forbidden

9 Instances of soft constraints Each instance is characterized by a c-semiring Each instance is characterized by a c-semiring Classical constraints: Classical constraints: Fuzzy constraints: Fuzzy constraints: Lexicographic CSPs: Lexicographic CSPs: Weighted constraints (N): Weighted constraints (N): Weighted constraints (R): Weighted constraints (R): Max CSP: weight =1 when constraint is not satisfied and 0 is satisfied Max CSP: weight =1 when constraint is not satisfied and 0 is satisfied Probabilistic constraints: Probabilistic constraints: Valued CSPs: any semiring with a total order Valued CSPs: any semiring with a total order Multicriteria problems: Cartesian product of semirings Multicriteria problems: Cartesian product of semirings

10 Example of hard constraint The fast VGA is compatible only with at least 512MB of memory VGAMB {s=slow, f=fast} {256, 512, 1024} → 0 → 1

11 Example of soft (fuzzy) constraint The VGA performs better with more memory VGAMB {s=slow, f=fast} {256, 512, 1024} → 0.1 → 0.9 → 1 → 0.9 → 0.7 → 0.6  Soft constraints are a quantitative formalism

12 Solution ordering A soft CSP induces an ordering over the solutions, from the ordering of the semiring A soft CSP induces an ordering over the solutions, from the ordering of the semiring Totally ordered semiring  total order over solutions (possibly with ties) Totally ordered semiring  total order over solutions (possibly with ties) Partially ordered semiring  total or partial order over solutions (possibly with ties) Partially ordered semiring  total or partial order over solutions (possibly with ties) Any ordering can be obtained Any ordering can be obtained

13 Expressive power A B iff from a problem P in A it is possible to build in polynomial time a problem P’ in B s.t. the optimal solutions are the same (but not necessarily the solution ordering!) A B iff from a problem P in A it is possible to build in polynomial time a problem P’ in B s.t. the optimal solutions are the same (but not necessarily the solution ordering!) A B iff from a problem P in A it is possible to build in polynomial time a problem P’ in B s.t. opt(P’)  opt(P) A B iff from a problem P in A it is possible to build in polynomial time a problem P’ in B s.t. opt(P’)  opt(P)

14 Expressive power weighted R Prob weighted N Valued Semiring-based Classical FuzzyLexicographic

15 Projection If c=, then c| I = If c=, then c| I = f'(t') = + (f(t)) over tuples of values t s.t. t| I  con = t’ f'(t') = + (f(t)) over tuples of values t s.t. t| I  con = t’ VGAMB {s=slow, f=fast} {256, 512, 1024} → 0.1 → 0.9 → 1 → 0.9 → 0.7 → 0.6 Projection over VGA: s  max(0.6,0.7,0.9) = 0.9 f  max(0.1,0.9,1) = 1 Fuzzy constraints: Fuzzy constraints:

16 Combination If ci=, then c1 x c2 = c1 x c2 = f(t) = f1(t| con1 ) x f2(t| con2 ) f(t) = f1(t| con1 ) x f2(t| con2 ) VGAMB s=slow  0.2 f=fast  0.9 256  0.5 512  0.8 1024  0.7 → 0.5 → 0.7 → 0.9 → 0.7 → 0.6 P P4  0.7 AMD  0.4 → 0.1 → 0.9 → 1 → 0.5 f(s,256,P4) = min(0.2,0.6,0.5,0.5) = 0.2 f(f,1024,P4)=min(0.9,1,0.7,0.9,0.7)=0.7

17 Solutions Sol(C) = X(C) Sol(C) = X(C) an element of A for each tuple of elements of D an element of A for each tuple of elements of D val(t) = f1(t| con1 ) x... x fk(t| conk ) val(t) = f1(t| con1 ) x... x fk(t| conk ) VGAMB s=slow  0.2 f=fast  0.9 256  0.5 512  0.8 1024  0.7 → 0.5 → 0.7 → 0.9 → 0.7 → 0.6 P P4  0.7 AMD  0.4 → 0.1 → 0.9 → 1 → 0.5 val(s,256,P4) = min(0.2,0.6,0.5,0.5) = 0.2 val(f,1024,P4)=min(0.9,1,0.7,0.9,0.7)=0.7

18 Multi-criteria problems Main idea: one semiring for each criteria Main idea: one semiring for each criteria Given n c-semirings S i =, we can build the c-semiring Given n c-semirings S i =, we can build the c-semiring, +,x,, >, +,x,, > + and x obtained by pointwise application of + i and x i on each semiring + and x obtained by pointwise application of + i and x i on each semiring A tuple of values associated with each variable instantiation A tuple of values associated with each variable instantiation A partial order even if all the criteria are totally ordered A partial order even if all the criteria are totally ordered

19 Example The problem: choosing a route between two cities The problem: choosing a route between two cities Each piece of highway has a preference and a cost Each piece of highway has a preference and a cost We want to both minimize the sum of the costs and maximize the preference We want to both minimize the sum of the costs and maximize the preference Semiring: by putting together one fuzzy semiring and one weighted semiring: Semiring: by putting together one fuzzy semiring and one weighted semiring: Best solutions: routes such that there is no other route with a better semiring value Best solutions: routes such that there is no other route with a better semiring value is better than is better than Two total orders, but the resulting order is partial: Two total orders, but the resulting order is partial: and are not comparable and are not comparable

20 Typical questions Find an optimal solution Find an optimal solution Difficult: NP-hard Difficult: NP-hard (branch and bound + constraint propagation) Is t an optimal solution? Is t an optimal solution? Difficult: NP-hard Difficult: NP-hard (we have to find the optimal preference level) Is t better than t’? Is t better than t’? Easy: Linear in the number of constraints Easy: Linear in the number of constraints (compute the two pref. levels and compare them)

21 How to find optimal solutions Classical constraints: Classical constraints: depth-first backtracking search depth-first backtracking search Constraint propagation Constraint propagation Variable elimination Variable elimination Local search Local search...... Is it possible to extend/adapt these techniques to soft constraints? Is it possible to extend/adapt these techniques to soft constraints?

22 Branch and bound Same scheme as for optimization CSPs Same scheme as for optimization CSPs Lower bound = preference of best solution so far (0 at the beginning) Lower bound = preference of best solution so far (0 at the beginning) Upper bound for each node Upper bound for each node If ub > lb  enter the subtree If ub > lb  enter the subtree

23 Upper bounds Based on preferences Based on preferences t = assignment to past variables (P) t = assignment to past variables (P) ub1= x c(t), with c already assigned by t ub1= x c(t), with c already assigned by t ub2 = x ub(cji), where xi in F, xj in P ub2 = x ub(cji), where xi in F, xj in P ub(cji) = +cji(vj,a) for a in Di ub(cji) = +cji(vj,a) for a in Di ub3 = x (+ cij(a,b)) ub3 = x (+ cij(a,b)) x over xi, xj in F x over xi, xj in F + over a in Di, b in Dj + over a in Di, b in Dj Ub = ub1 x ub2 x ub3 Ub = ub1 x ub2 x ub3

24 Upper bounds weighted constraints (min +) t = assignment to past variables t = assignment to past variables ub1= + c(t), with c already assigned by t ub1= + c(t), with c already assigned by t ub2 = + ub(cji), for xi in F, xj in P ub2 = + ub(cji), for xi in F, xj in P ub(cji) = min cji(vj,a) for a in Di ub(cji) = min cji(vj,a) for a in Di ub3 = + (min cij(a,b)) ub3 = + (min cij(a,b)) + over xi, xj in F + over xi, xj in F min over a in Di, b in Dj min over a in Di, b in Dj ub = ub1 + ub2 + ub3 ub = ub1 + ub2 + ub3

25 Upper bounds fuzzy constraints (max min) t = assignment to past variables t = assignment to past variables ub1= min c(t), with c already assigned by t ub1= min c(t), with c already assigned by t ub2 = min ub(cji), for xi in F, xj in P ub2 = min ub(cji), for xi in F, xj in P ub(cji) = max cji(vj,a) for a in Di ub(cji) = max cji(vj,a) for a in Di ub3 = min (max cij(a,b)) ub3 = min (max cij(a,b)) min over xi, xj in F min over xi, xj in F max over a in Di, b in Dj max over a in Di, b in Dj ub = min (ub1, ub2, ub3) ub = min (ub1, ub2, ub3)

26 Constraint propagation Constraint propagation (ex.arc-consistency): Constraint propagation (ex.arc-consistency): Deletes an element a from the domain of a variable x if, according to a constraint between x and y, it does not have any compatible element b in the domain of y Deletes an element a from the domain of a variable x if, according to a constraint between x and y, it does not have any compatible element b in the domain of y Iterate until stability Iterate until stability Polynomial time Polynomial time Very useful at each node of the search tree to prune subtrees Very useful at each node of the search tree to prune subtrees

27 Example No matter what the other constraints are, X=b cannot participate in any solution. So we can delete it without changing the set of solutions. XY abab abab a a b

28 Properties of GI algorithm Equivalence: each step preserves the set of solutions Equivalence: each step preserves the set of solutions Termination (with finite domains) Termination (with finite domains) Order-independence: no matter how constraints are chosen, when stability is achieved we always have the same problem Order-independence: no matter how constraints are chosen, when stability is achieved we always have the same problem

29 Soft constraint propagation Deleting a value means passing from 1 to 0 in the semiring Deleting a value means passing from 1 to 0 in the semiring In general, constraint propagation can change preferences to lower values in the ordering In general, constraint propagation can change preferences to lower values in the ordering Soft arc-consistency: given c x, c xy, and c y, compute c x := (c x x c xy x c y )| x Soft arc-consistency: given c x, c xy, and c y, compute c x := (c x x c xy x c y )| x Iterate until stability according to algorithm GI Iterate until stability according to algorithm GI

30 Example: fuzzy arc-consistency VGAMB s=slow  0.2 f=fast  0.9 256  0.5 512  0.8 1024  0.7 → 0.9 → 0.7 → 0.6 → 0.1 → 0.9 → 1 c x := (c x x c xy x c y )| x VGA=s  max(min(0.2,0.6,0.5),min(0.2,0.7,0.8),min(0.2,0.9,0.7))= max(0.2,0.2,0.2) = 0.2 VGA=f  max(min(0.9,0.1,0.5),min(0.9,0.9,0.8),min(0.9,1,0.7))= max(0.1,0.8,0.7)=0.8 Fuzzy semiring=  +=max an x=min

31 Properties of soft GI If x idempotent (ex.:fuzzy,classical): If x idempotent (ex.:fuzzy,classical): Equivalence Equivalence Termination Termination Order-independence Order-independence If x not idempotent (ex.: weighted CSPs, prob.), we could count more than once the same constraint  we need to compensate by subtracting appropriate quantities somewhere else  we need an additional property (fairness=presence of -) If x not idempotent (ex.: weighted CSPs, prob.), we could count more than once the same constraint  we need to compensate by subtracting appropriate quantities somewhere else  we need an additional property (fairness=presence of -) Equivalence Equivalence Termination Termination Not order-independence Not order-independence

32 Branch and bound with soft constraint propagation Soft constraint propagation lowers the preferences Soft constraint propagation lowers the preferences ub1, ub2, ub3 can be lower ub1, ub2, ub3 can be lower more probable that ub < lb more probable that ub < lb more probable to prune more probable to prune

33 Cuts Given P soft, and given  in the semiring, build P  : Given P soft, and given  in the semiring, build P  : Same graph as P Same graph as P In each constraint, only the tuples with preference >  In each constraint, only the tuples with preference > 

34 Example VGAMB s=slow  0.2 f=fast  0.9 256  0.5 512  0.8 1024  0.7 →0.9 → 0.7 → 0.6 → 0.1 → 0.9 → 1 P 0.5 : VGAMB s  0 f  1 256  0 512  1 1024  1 → 1 → 0 → 1

35 Properties t optimal solution of P with preference v t optimal solution of P with preference v For each  <v, P  consistent and t solution of P  For each  <v, P  consistent and t solution of P  For each  ≥ v, P  inconsistent For each  ≥ v, P  inconsistent Hold if x idempotent Hold if x idempotent

36 Solution method To find the optimal solutions of P: To find the optimal solutions of P: Find the consistent P  such that, for each  > , P  inconsistent Find the consistent P  such that, for each  > , P  inconsistent The solutions of P  are the optimal solutions of P The solutions of P  are the optimal solutions of P Just check the P  with  occurring in P  O(kd 2 ) calls to a classical constraint solver Just check the P  with  occurring in P  O(kd 2 ) calls to a classical constraint solver k= number of constraints k= number of constraints d = domain size d = domain size Binary search  O(log(kd 2 )) calls Binary search  O(log(kd 2 )) calls

37 Example VGAMB s=slow  0.2 f=fast  0.9 256  0.5 512  0.8 1024  0.7 →0.9 → 0.7 → 0.6 → 0.1 → 0.9 → 1 P 0.5 : VGAMB s  0 f  1 256  0 512  1 1024  1 → 1 → 0 → 1 VGA=f,MB=512 is a solution, but also VGA=f,MB=1024 is a solution Optimal solution: VGA=f,MB=512 (val=0.8)

38 Example VGAMB s=slow  0.2 f=fast  0.9 256  0.5 512  0.8 1024  0.7 →0.9 → 0.7 → 0.6 → 0.1 → 0.9 → 1 P 0.6 : VGAMB s  0 f  1 256  0 512  1 1024  1 → 1 → 0 → 1 VGA=f,MB=512 is a solution, but also VGA=f,MB=1024 is a solution Optimal solution: VGA=f,MB=512 (val=0.8)

39 Example VGAMB s=slow  0.2 f=fast  0.9 256  0.5 512  0.8 1024  0.7 →0.9 → 0.7 → 0.6 → 0.1 → 0.9 → 1 P 0.7 : VGAMB s  0 f  1 256  0 512  1 1024  0 → 1 → 0 → 1 Only VGA=f,MB=512 is a solution Optimal solution: VGA=f,MB=512 (val=0.8)

40 Example VGAMB s=slow  0.2 f=fast  0.9 256  0.5 512  0.8 1024  0.7 →0.9 → 0.7 → 0.6 → 0.1 → 0.9 → 1 P 0.8 : VGAMB s  0 f  1 256  0 512  0 1024  0 → 1 → 0 → 1 No solution Optimal solution: VGA=f,MB=512 (val=0.8)

41 Variable elimination Choose a variable, x Choose a variable, x x is connected via constraints C to the set of variables Y x is connected via constraints C to the set of variables Y Compute x(C) and project over Y, and add the new constraint over Y (we need idempotent x) Compute x(C) and project over Y, and add the new constraint over Y (we need idempotent x) Forget about x and C Forget about x and C The same for all other variables The same for all other variables When just one variable, its highest preference is the preference of optimal solutions When just one variable, its highest preference is the preference of optimal solutions To find an optimal solution, instantiate the variables in the order opposite to elimination, always taking the value with the highest preference To find an optimal solution, instantiate the variables in the order opposite to elimination, always taking the value with the highest preference

42 Example 2 1 4 65 3 We eliminate the variables from 1 to 6

43 Example 2 1 4 65 3

44 Example 24 65 3

45 Example 4 65 3

46 Example 4 65

47 Example 4 65

48 Example 65

49 Example 6

50 Example 6 Instantiate variables from 6 to 1 At each step, choose the best value for the variable in its domain, given the assignments already made

51 Complexity As many steps as the number of variables (n) As many steps as the number of variables (n) At each step, time exponential in the size of Y plus 1 (and space exponential in size of Y) At each step, time exponential in the size of Y plus 1 (and space exponential in size of Y) n steps to find an optimal solution n steps to find an optimal solution Time: O(n x exp(|Y|) +n) Time: O(n x exp(|Y|) +n) But space is the main problem with this method But space is the main problem with this method


Download ppt "Soft constraints. Classical (hard) Constraints Variables {X 1,…,X n }=X Variables {X 1,…,X n }=X Domains {D(X 1 ),…,D(X n )}=D Domains {D(X 1 ),…,D(X."

Similar presentations


Ads by Google