# Constraint-based problem solving n Model problem ä specify in terms of constraints on acceptable solutions ä define variables (denotations) and domains.

## Presentation on theme: "Constraint-based problem solving n Model problem ä specify in terms of constraints on acceptable solutions ä define variables (denotations) and domains."— Presentation transcript:

Constraint-based problem solving n Model problem ä specify in terms of constraints on acceptable solutions ä define variables (denotations) and domains ä define constraints in some language n Solve model ä define search space / choose algorithm –incremental assignment / backtracking search –complete assignments / stochastic search ä design/choose heuristics n Verify and analyze solution

n Model problem ä specify in terms of constraints on acceptable solutions ä define variables (denotations) and domains ä define constraints in some language n Solve model ä define search space / choose algorithm –incremental assignment / backtracking search –complete assignments / stochastic search ä design/choose heuristics n Verify and analyze solution Constraint-based problem solving Constraint Satisfaction Problem

Constraint satisfaction problem n A CSP is defined by ä a set of variables ä a domain of values for each variable ä a set of constraints between variables n A solution is ä an assignment of a value to each variable that satisfies the constraints

Example: Crossword puzzles

CSP, binary CSP, SAT, 3-SAT, ILP,... n Model and solve in one of these languages n Model in one language, translate into another to solve Options

Article of faith Constraints arise naturally in most areas of human endeavor. They are the natural medium of expression for formalizing regularities that underlie the computational and physical worlds and their mathematical abstractions. P. Van Hentenryck and V. Saraswat Constraint Programming: Strategic Directions

Reducibility NP-Complete 3-SAT ILP CSP binary CSP (0,1)-ILP

CSP, binary CSP, SAT, 3-SAT, ILP,... n Model and solve in one of these languages n Model in one language, translate into another to solve Options

Importance of the model In integer programming, formulating a good model is of crucial importance to solving the model. G. L. Nemhauser and L. A. Wolsey Handbook in OR & MS, 1989 Same for constraint programming. Folk Wisdom, CP practitioners

Measures for comparing models n How easy is it to –write down, –understand, –modify, debug, –communicate? n How computationally difficult is it to solve?

Constraint systems/languages

Abstractions n Capture commonly occurring constraints ä special propagation algorithms ä e.g. alldifferent, cardinality, cumulative,... n User-defined constraints ä full power of host language

CSP versus ILP n OO databases versus Relational databases n C++ versus C n C++ versus Fortran n C++ versus Assembly language

Computational difficulty? n What is a good model depends on algorithm n Choice of variables defines search space n Choice of constraints defines ä how search space can be reduced ä how search can be guided

Improving model efficiency Given a model: n Add/remove variables, values, constraints (keep the denotation of the variables) n Use/translate to a different representation (change the denotation of the variables)

Adding redundant constraints n Improve computational efficiency of model by adding right constraints ä symmetries removed ä dead-ends encountered earlier in search process n Three methods: ä add hand-crafted constraints during modeling ä apply a consistency algorithm before solving ä learn constraints while solving

Examples: n Adding hand-crafted constraints: ä crossword puzzles n Applying a consistency algorithm: ä dual representation

Adding redundant variables n Variables that are abstractions of other variables ä e.g, decision variables Suppose x has domain {1,…,10} Add Boolean variable to represent decisions (x < 5), (x 5) n Variables that represent constraints

Translations between models n Improve computational efficiency by completely changing the model ä change denotation of variables –e.g, convert from non-binary to binary ä aggregate variables –e.g, timetabling multiple sections of a course n Not much as has been done on either the theory or the practice side

Conversion to binary n Any CSP can be converted into one with only binary constraints n Two techniques known ä dual graph method (Dechter & Pearl, 1989) ä hidden variable method (Peirce, 1933; Dechter 1990) n Translations are polynomial if constraints are represented extensionally

( x 1 x 2 x 6 ) ( x 1 x 3 x 4 ) ( x 4 x 5 x 6 ) ( x 2 x 5 x 6 ) n Non-binary CSP: ä Boolean variables: x 1, …, x 6 ä constraints: one for each clause 3-SAT example C 1 (x 1, x 2, x 6 ) = {(0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1)} C 2 (x 1, x 3, x 4 ) =...

Dual graph representation y 1 = ( x 1, x 2, x 6 ) y 4 = ( x 2, x 5, x 6 ) y 2 = ( x 1, x 3, x 4 ) y 3 = ( x 4, x 5, x 6 ) x 2, x 6 x 5, x 6 x4x4 x6x6 x1x1

Hidden variable representation x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 h1h1 h2h2 h3h3 h4h4

n Non-binary constraint: n Augmented constraint: n Binary constraints: Hidden variable representation C 1 (x 1, x 2, x 6 ) = {(0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1)} C 1 (x 1, x 2, x 6, h 1 ) = {(0,0,1,0), (0,1,0,1), (0,1,1,2), (1,0,0,3), (1,0,1,4), (1,1,0,5), (1,1,1,6)} R 1 (x 1, h 1 ) = {(0,0), (0,1), (0,2), (1,3), (1,4), (1,5), (1,6)} R 2 (x 2, h 1 ) = {(0,0), (1,1), (1,2), (0,3), (0,4), (1,5), (1,6)} R 3 (x 6, h 1 ) = {(1,0), (0,1), (1,2), (0,3), (1,4), (0,5), (1,6)}

x1 x1 x2x2 x3 x3 h1 h1 h2h2 h3 h3 Dual exponentially worse FC on non-binary: O(n) consistency checks FC on dual: O(2 n ) consistency checks x 1, x 1 x 2, x 1 x 2 x 3,..., x 1 … x n-1 x n

x1 x1 x2x2 x3 x3 h1 h1 h2h2 h3 h3 Dual exponentially better FC on non-binary: O(n2 n ) consistency checks FC on dual: O(n 2 ) consistency checks x 1 … x n-1, x 1 … x n-2 x n, …, x 2 … x n

n Worst case: n Best case: Bounds on performance FC(non-binary) FC + (hidden) d k FC + (hidden) FC (non-binary) d n

Crossword puzzles 123 6 4 7 5 8 10 9 20 11 22 12 21 13 17 14 181615 2319 a aardvark aback abacus abaft abalone abandon... Mona Lisa monarch monarchy monarda... zymurgy zyrian zythum

Crossword puzzles

Model of random non-binary CSP n n variables ä each with domain size d n m constraints ä each with k variables, chosen at random ä each with t tuples, chosen at random

Order of magnitude curves (number of constraints) / (number of variables) (number of tuples in constraints) / (maximum tuples) n = 20 d = 2 k = 3 n = 20 d = 10 k = 3 n = 20 d = 10 k = 5 n = 20 d = 2 k = 5

Random 3-SAT

n Given start state, goal state, and actions: determine a plan (a sequence of actions) Box1 Project: Planning Box2

Contrasts n CP philosophy/methodology ä emphasis on modeling, domain knowledge ä general purpose search algorithm –backtracking with constraint propagation n Successful ä e.g., can solve practical scheduling problems

Contrasts n Planning philosophy/methodology ä emphasis on minimal model –just representation of actions ä special-purpose search algorithms n Not as successful ä has not solved many practical problems

Tradeoffs n Robust CSP model needed for each new domain ä can require much intellectual effort n Less work needs to be done on algorithms ä many general purpose constraint solvers available

CSP model of planning n State-based model ä model each state by a collection of variables ä constraints enforce valid transitions between states n Example: logistics world ä variable for each package, truck, plane ä domains of packages: all locations, trucks, planes ä domains of trucks, planes: all locations

CSP model: constraints (I) n Action constraints ä model the effects of actions ä patterned after explanation closure axioms n State constraints ä variables within a state must be consistent

Improving model efficiency n Can add/remove/aggregate/decompose ä variables ä domain values ä constraints n Here: ä added hidden variables ä added redundant & symmetry-breaking constraints

CSP model: constraints (II) n Symmetric values constraints ä break symmetries on values variables can be assigned n Action choice constraints ä break symmetries on equivalent permutations of actions

CSP model: constraints (III) n Domain constraints ä restrictions on original domains of variables n Capacity constraints ä bounds on resources n Distance constraints ä bounds on steps needed for a variable to change from one value to another

Solving the CSP model n Given an instance of a planning problem ä generate a model with one step in it ä instantiate variables in the initial and goal states ä search for a solution (GAC+CBJ) ä repeat, incrementing number of steps, until plan is found n Properties: ä forwards, backwards, or middle out planner ä sound, complete, guaranteed to terminate

Experiments n Five test domains from AIPS98 n Five planners: ä CPlan ä Blackbox (Kautz & Selman) ä HSP (Bonet & Geffner) ä IPP (Koehler & Nebel) ä TLPlan (Bacchus & Kabanza) n Setup: ä machines: 400MHz Pentium IIs ä resources: 1 hour CPU time, 256 Mb memory

Gripper problems

Logistics problems

Mystery problems

MysteryPrime problems

Grid problems

Related work n Planning as a CSP ä satisfiability (Kautz & Selman) ä ILP (e.g., Bockmayr & Dimopoulos) n Adding declarative knowledge to improve efficiency ä hand-coded (e.g, Kautz & Selman, Bacchus & Kabanza) ä automatically derived (e.g., Fox & Long, Nebel et al.)

Project: Resource-constrained instruction scheduling (I) n Modern architectures (VLIW) allow instruction level parallelism ä multiple functional units n Compiler to generate code that takes advantage of parallelism ä resource-constrained scheduling task a: j i + h b: k i + g c: l j + 1 1: a, b 2: c

Project: Resource-constrained instruction scheduling (II) n Current methods: ä heuristic ä recent: integer linear programming approach n Project: ä investigate constraint programming approach ä GNU compiler, MERCED chip

Project: Theoretical analysis of alternative models n Improve computational efficiency by completely changing the model ä change denotation of variables –e.g, convert from non-binary to binary ä aggregate variables –e.g, timetabling multiple sections of a course n Not much as has been done on either the theory or the practice side

Conclusions n Importance of the model ä ease of modeling is important ä form of model is important n Constraint programming advantages ä succinctness, declarativeness of models ä flexibility in specifying model ä on some classes of problems: speed

Conclusions n Advantages shared with CSP-like approaches ä expressiveness of modeling language ä declarativeness of models ä independence of model and solving algorithm n Advantages over other CSP-like approaches ä succinctness of models ä robustness: scales well, not as brittle ä speed

Future Work n Approximate planning ä heuristic CSP models ä solve same CSP models using local search n Alternative CSP models ä action-based models vs state-based models ä finding the right model can be key to solving difficult combinatorial problems

Download ppt "Constraint-based problem solving n Model problem ä specify in terms of constraints on acceptable solutions ä define variables (denotations) and domains."

Similar presentations