Download presentation
Presentation is loading. Please wait.
1
1 General Principles of Constraint Programming Jean-Charles REGIN Director of Constraint Programming ILOG, Sophia Antipolis, France regin@ilog.fr
2
2 Plan o General Principles o CP vs other techniques o Filtering algorithms o An example: sports scheduling o Strength of CP o Weakness of CP o New research Area o Recent advances in CP at ILOG o Conclusion
3
3 History o General Problem Solvers in 70’s m ALICE [J-F Lauriere, AIJ 78], phD in Paris VI, 76 o Prolog: CHIP, ECRC Munich 86 (Alice in Prolog) m Colmerauer, Gallaire, Van Hentenryck o Constraint Satisfaction Problems m Waltz 72, Mackworth 74, Freuder 76 o Industry: Bull (Charme), ILOG (Solver) 92
4
4 Constraint Programming o In CP a problem is defined from: - variables with possible values (domain) - constraints o Domain can be discrete or continuous, symbolic values or numerical values o Constraints express properties that have to be satisfied
5
5 Problem = conjunction of sub- problems o In CP a problem can be viewed as a conjunction of sub-problems that we are able to solve o A sub-problem can be trivial: x < y or complex: search for a feasible flow o A sub-problem = a constraint
6
6 Constraints o Predefined constraints: arithmetic (x k, alldiff, cardinality, sequence … o Constraints given in extension by the list of allowed (or forbidden) combinations of values o user-defined constraints: any algorithm can be encapsulated o Logical combination of constraints using OR, AND, NOT, XOR operators. Sometimes called meta-constraints
7
7 Filtering o We are able to solve a sub-problem: a method is available o CP uses this method to remove values from domain that do not belong to a solution of this sub-problem: filtering or domain-reduction o E.g: x D(x)=[10,14], D(y)=[11,15]
8
8 Filtering o A filtering algorithm is associated with each constraint (sub-problem). o Can be simple (x < y) or complex (alldiff) o Theoretical basics: arc consistency, remove all the values that do not belong to a solution of the underlined sub-problem.
9
9 Propagation o Domain Reduction due to one constraint can lead to new domain reduction of other variables o When a domain is modified all the constraints involving this variable are studied and so on...
10
10 Propagation o D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6} o Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6
11
11 Propagation o D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6} o Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6 Alldiff({x,y,z}): FA=> z=2
12
12 Propagation o D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6} o Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6 Alldiff({x,y,z}): FA=> z=2 o u=z+3: FA=> u=5
13
13 Propagation o D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6} o Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6 Alldiff({x,y,z}): FA=> z=2 o u=z+3: FA=> u=5 o v>u: FA=> v=6
14
14 Propagation o D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6} o Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6 Alldiff({x,y,z}): FA=> z=2 o u=z+3: FA=> u=5 o v>u: FA=> v=6 o |z-v| y=1
15
15 Propagation o D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6} o Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6 Alldiff({x,y,z}): FA=> z=2 o u=z+3: FA=> u=5 o v>u: FA=> v=6 o |z-v| y=1 o Alldiff({x,y,z}): FA=> x=0 o Solution: x=0, y=1, z=2, u=5, v=6
16
16 Why Propagation? o Idea: problem = conjunction of easy sub-problems. o Sub-problems: local point of view. Problem: global point of view. Propagation tries to obtain a global point of view from independent local point of view o The conjunction is stronger that the union of independent resolution
17
17 Search o Backtrack algorithm with strategies: try to successively assign variables with values. If a dead-end occurs then backtrack and try another value for the variable o Strategy: define which variable and which value will be chosen. o After each domain reduction (I.e assignement include) filtering and propagation are triggered
18
18 Constraint Programming o 3 notions: - constraint network: variables, domains constraints + filtering (domain reduction) - propagation - search procedure (assignments + backtrack) o The structure of every constraint is exploited
19
19 Plan o General Principles o CP vs other techniques o Filtering algorithms o An example: sports scheduling o Strength of CP o Weakness of CP o New research Area o Recent advances in CP at ILOG o Conclusion
20
20 CP vs other techniques o CP vs greedy algorithms o CP vs local search o CP vs inference engines o CP vs MIP
21
21 CP vs greedy algorithm o Greedy algorithm = a search strategy which guarantees that there is no backtrack o CP is a generalization: your strategy can be non necessarily greedy. Solver manages for you the “errors” of your strategy o Some problems are solved with few backtracks
22
22 CP vs local search o Local search: it is hard to respect hard constraints. With CP no problem o Combination of CP and local search is used quite often to solve problems: find a first solution with CP then re-optimize it iteratively.
23
23 CP vs Inference engines o (A implies B) represented by (NOT A OR B) o (x 4) o Propagation from Left to Right: if x 4 o Propagation from Right to Left: if z 4
24
24 CP vs MIP MIP approachCP approach
25
25 CP vs MIP o Relax the problem: floats instead of integers o 1) Use the Simplex algorithm (“polynomial”) o 2) Set float to integer value. Go to 1) and backtrack if necessary MIP approachCP approach
26
26 CP vs MIP o Relax the problem: floats instead of integers o 1) Use the Simplex algorithm (“polynomial”) o 2) Set float to integer value. Go to 1) and backtrack if necessary o Identify sub-problems that are easy (called constraints) o 1) Use specific algorithm for solving these sub-problems and for performing domain-reduction o 2) Instantiate variable. Go to 1) and backtrack if necessary MIP approachCP approach
27
27 CP vs MIP o Relax the problem: floats instead of integers o 1) Use the Simplex algorithm (“polynomial”) o 2) Set float to integer value. Go to 1) and backtrack if necessary o Global point of view on a relaxation of the problem o Identify sub-problems that are easy (called constraints) o 1) Use specific algorithm for solving these sub-problems and for performing domain-reduction o 2) Instantiate variable. Go to 1) and backtrack if necessary o Local point of view on sub- problems. “Global” point of view by propagation of domain reductions MIP approachCP approach
28
28 CP vs MIP o In CP constraints can be non-linear o Structure of the problem is used in CP o Semantic of the constraints are used: much easier to add a global constraint with a filtering algorithm than defining a new cut o First solution given by CP is generally good
29
29 Plan o General Principles o CP vs other techniques o Filtering algorithms o An example: sports scheduling o Strength of CP o Weakness of CP o New research Area o Recent advances in CP at ILOG o Conclusion
30
30 Arc consistency o All the values which do not belong to any solution of the constraint are deleted. o Example: Alldiff({x,y,z}) with D(x)=D(y)={0,1}, D(z)={0,1,2} the two variables x and y take the values 0 and 1, thus z cannot take these values. FA by AC => 0 and 1 are removed from D(z)
31
31 Alldiff constraint x1 x2 x3 x4 x5 x6 12345671234567 The value graph: D(x1)={1,2} D(x2)={2,3} D(x3)={1,3} D(x4)={3,4} D(x5)={2,4,5,6} D(x6)={5,6,7}
32
32 Value network x1 x2 x3 x4 x5 x6 12345671234567 ts (6,6) (0,1) (1,1) Default orientation
33
33 A feasible flow x1 x2 x3 x4 x5 x6 12345671234567 ts (6,6) (0,1) (1,1) Default orientation
34
34 Residual graph x1 x2 x3 x4 x5 x6 12345671234567 s orientation
35
35 Residual graph x1 x2 x3 x4 x5 x6 12345671234567 s orientation
36
36 Arc consistency x1 x2 x3 x4 x5 x6 12345671234567 The value graph: D(x1)={1,2} D(x2)={2,3} D(x3)={1,3} D(x4)={4} D(x5)={5,6} D(x6)={5,6,7}
37
37 Alldiff constraint o Compute a feasible flow o Compute the strongly connected components o Remove every arc of flow value 0 for which the ends belong to two different components o Linear algorithm achieving arc consistency o Idem for global cardinality constraints o work well due to (0,1) arcs
38
38 Plan o General Principles o CP vs other techniques o Filtering algorithms o An example: sports scheduling o Strength of CP o Weakness of CP o New research Area o Recent advances in CP at ILOG o Conclusion
39
39 The problem n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week no team plays more than twice in the same period
40
40 The problem n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week no team plays more than twice in the same period Problem 10teams of the MIPLIB (n=10 and the objective function is dummy) MIP is not able to find a solution for n=14 CP finds a solution for n=10 in 0.06s, n=14 in 0.2, n=40 in 6h
41
41 The problem n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week no team plays more than twice in the same period For 40 teams: 800 variables with 39 possible values for each variable.
42
42 CP model: variables For each slot: 2 variables represent the teams and 1 variable represents the match are defined 1 vs 6 T33a variable (T33a=6) T33h variable (T33h=1) M33 variable (M33=12) Mij=1 0 vs 1 or 1 vs 0 Mij=12 1 vs 6 or 6 vs1
43
43 CP model: T variables D(Tija)=[1,n-1] D(Tijh)=[0,n-2] Tijh < Tija
44
44 CP model: M variables D(Mij)=[1,n(n-1)/2]
45
45 CP model: constraints n teams and n-1 weeks and n/2 periods n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week every team plays one game in each week no team plays more than twice in the same period no team plays more than twice in the same period
46
46 CP model: constraints n teams and n-1 weeks and n/2 periods n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week every team plays one game in each week no team plays more than twice in the same period no team plays more than twice in the same period Alldiff constraints defined on M variables
47
47 CP model: constraints n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week no team plays more than twice in the same period
48
48 CP model: constraints n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week no team plays more than twice in the same period For each week w: Alldiff constraint defined on {Tpwh, p=1..4} U {Tpwa, p=1..4}
49
49 CP model: constraints n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week no team plays more than twice in the same period
50
50 CP model: constraints n teams and n-1 weeks and n/2 periods every two teams play each other exactly once every team plays one game in each week no team plays more than twice in the same period For each period p: Global cardinality constraint defined on {Tpwh, w=1..7} U {Tpwa, w=1..7} every team t is taken at most 2
51
51 CP model: constraints o For each slot the two T variables and the M variable must be linked together; example: M12 = game T12h vs T12a
52
52 CP model: constraints o For each slot the two T variables and the M variable must be linked together; example: M12 = game T12h vs T12a o For each slot we add Cij a ternary constraint defined on the two T variables and the M variable; example: C12 defined on {T12h,T12a,M12}
53
53 CP model: constraints o For each slot the two T variables and the M variable must be linked together; example: M12 = game T12h vs T12a o For each slot we add Cij a ternary constraint defined on the two T variables and the M variable; example: C12 defined on {T12h,T12a,M12} o Cij are defined by the list of allowed tuples: for n=4: {(0,1,1),(0,2,2),(0,3,3),(1,2,4),(1,3,5),(2,3,6)} (1,2,4) means game 1 vs 2 is the game number 4
54
54 CP model: constraints o For each slot the two T variables and the M variable must be linked together; example: M12 = game T12h vs T12a o For each slot we add Cij a ternary constraint defined on the two T variables and the M variable; example: C12 defined on {T12h,T12a,M12} o Cij are defined by the list of allowed tuples: for n=4: {(0,1,1),(0,2,2),(0,3,3),(1,2,4),(1,3,5),(2,3,6)} (1,2,4) means game 1 vs 2 is the game number 4 o All these constraints have the same list of allowed tuples o Efficient arc consistency algorithm for this kind of constraint is known
55
55 First model Introduction of a dummy column
56
56 First model Introduction of a dummy column We can prove that: each team occurs exactly twice for each period
57
57 First model Introduction of a dummy column We can prove that: each team occurs exactly twice for each period
58
58 First model Introduction of a dummy column We can prove that: each team occurs exactly twice for each period
59
59 First model Introduction of a dummy column We can prove that: each team occurs exactly twice for each period each team occurs exactly once in the dummy column
60
60 First model Introduction of a dummy column The problem is exactly the same The solver is helped by such constraint. It can deduce some inconsistencies more quickly
61
61 First model: strategies o Break symmetries: 0 vs w appears in week w
62
62 First model: strategies o Break symmetries: 0 vs w appears in week w o Teams are instantiated: - the most instantiated team is chosen - the slots that has the less remaining possibilities (Tijh or Tija is minimal) is instantiated with that team
63
63 First model: results MIPLIB MIP solver limit
64
64 Second model o Break symmetry: 0 vs 1 is the first game of the dummy column
65
65 Second model o Break symmetry: 0 vs 1 is the first game of the dummy column o 1) Find a round-robin. Define all the games for each column (except for the dummy) - Alldiff constraint on M is satisfied - Alldiff constraint for each week is satisfied
66
66 Second model o Break symmetry: 0 vs 1 is the first game of the dummy column o 1) Find a round-robin. Define all the games for each column (except for the dummy) - Alldiff constraint on M is satisfied - Alldiff constraint for each week is satisfied o 2) set the games in order to satisfy constraints on periods. If no solution go to 1)
67
67 Second model: strategy M variables are instantiated
68
68 Second model: strategy M variables are instantiated
69
69 Second model: strategy M variables are instantiated
70
70 Second model: strategy M variables are instantiated
71
71 Second model: strategy M variables are instantiated
72
72 Second model: results MIPLIB MIP limit First model limit
73
73 Assume P ≠ NP o Ok, we cannot avoid an exponential behavior o For some instances, an NP Complete Problem will required an exponential time to be solved o So, our only hope is to shift the exponential such that the problem is solvable for a size and a time that are acceptable
74
74 Shifting the exponential
75
75 Shifting the exponential
76
76 Why does CP perform well? o Pure discrete problem. You can give any number to the teams o This is a feasibility problem (no objective function). o No arithmetic symbol: +, -, = is used o A global point of view on the global cardinality constraints (i.e. group these constraints into only one) does not help
77
77 Plan o General Principles o CP vs other techniques o Filtering algorithms o An example: sports scheduling o Strength of CP o Weakness of CP o New research Area o Recent advances in CP at ILOG o Conclusion
78
78 Strength of CP o Very flexible (easy to take into account new constraints) o The system is open: you can define you own constraints, your own search mechanism. o CP allows the use of sophisticated strategies, you can use the knowledge of the domain of application. o You just have to respect a protocol given by a solver. The solver manages the propagation and provides you with a lot of predefined things
79
79 Strength of CP o CP is exact: no solution is lost even for float variables o Any existing algorithm can be integrated in CP as a filtering algorithm of a constraints o Concepts are simple o A first model can be defined and tested quickly o For optimization problems: the first solution is a good one o Easy to introduce your new “idea” in the system o Cooperation is easy thanks to constraints
80
80 Plan o General Principles o CP vs other techniques o Filtering algorithms o An example: sports scheduling o Strength of CP o Weakness of CP o New research Area o Recent advances in CP at ILOG o Conclusion
81
81 Weakness of CP o Must be improved for optimization problems: spend too much time in proving sub-optimality m First step: integration of cost in the constraints o Sometimes lack of global point of view o Dark zones: press Enter key then ? o Relaxation is not good for CP. We learn relaxation at school!
82
82 Plan o General Principles o CP vs other techniques o Filtering algorithms o An example: sports scheduling o Strength of CP o Weakness of CP o New research Area o Recent advances in CP at ILOG o Conclusion
83
83 New research areas o New point of view: CP is based on filtering algorithm, i.e. : Given a property P defining a necessary condition for an element to be in a solution Find as quickly as possible ALL elements that do not satisfy P o Ex: alldiff constraint and matching, cardinality constraint and flows etc… o Close to sensitivity analysis, but also different (for instance we only have monotonic modifications).
84
84 New research areas o Consider a Minimization problem, and OBJ the objective. Suppose that we found a “solution” with OBJ=25. o We will reject any “solution” with OBJ > 24. So if x=a leads to an OBJ > 24 then value a must be removed from D(x). o If we have a lower bound of OBJ then we can use it: if lb(OBJ,x=a) > 24 then remove a from D(x) o Problem: literature mainly gives upper bound for minimization problems and lower bound for maximization problems. o Not always easy to get lb of good quality
85
85 New research areas o The very same algorithm is called thousand times (million sometimes) o The incremental aspect of the algorithm becomes really important.
86
86 Plan o General Principles o CP vs other techniques o Filtering algorithms o An example: sports scheduling o Strength of CP o Weakness of CP o New research Area o Recent advances in CP at ILOG o Conclusion
87
87 Recent advances in CP at ILOG o Let’s start with a real world example that involved a lot of people in ILOG: The ROCOCO project o From this project we learnt a lot of things
88
88 The ROCOCO Problem (1) o Routing of Communications m Mono-routing: each demand from a point p to a point q must follow a unique path o Dimensioning of Links m The capacity of each link must exceed the sums of the demands going through the link o Additional Constraints m Depend on the customer for whom the network is designed
89
89 The ROCOCO Problem (2) Data: Customer traffic demands Possible links, capacities and costs S1 S2 S3 S4 S1 S2 S3 S4 Result: m Minimal cost network able to simultaneousl y respond to all the demands m Route for each demand 27Kb/s 115Kb/s Rented capacity 256Kb/s
90
90 The ROCOCO Problem (3) o Cost minimization principle m Traffic demands share link capacities S1 S2 S3 512Kb/s 128Kb/s 115Kb/s 256Kb/s
91
91 The Problem (4) Demands share links m demands i j capacity i j m Technological constraints 256Kb/s 64Kb/s 128Kb/s 64Kb/s 128Kb/s
92
92 The Problem (5) o Side constraints m Quality of service m Reuse of existing equipment (limit on the number of ports, maximal traffic at a node) m Commercial and legal constraints m Possible future network evolution m Network management (e.g., traffic concentration) 64Kb/s
93
93 Optional Constraints o Security: some commodities to be secured cannot go through unsecured nodes and links o No line multiplication: at most one line per arc. o Symmetric routing: demands from node p to node q and demands from node q to node p are routed on symmetric paths. o Number of bounds (hops): the number of arcs of the path used to route a given demand is limited. o Number of ports: the number of links entering into or leaving from a node is limited. o Maximal traffic: the total traffic managed by a given node is limited. 64Kb/s
94
94 Numerical Characteristics (1)
95
95 We worked a lot!
96
96 The key idea: path variable!
97
97 General considerations o When solving a problem in CP: o Potential performance gain: m data structure optimization (code): x 10 m search strategies: x 1 000 m model : x 1 000 000 o Repartition of effort for ROCOCO m data structure optimization (code): 65 % m search strategies: 25 % m model: 10 %
98
98 General considerations o When solving a problem in CP: o Potential performance gain: m data structure optimization (code): x 10 m search strategies: x 1 000 m model : x 1 000 000 o Repartition of effort for ROCOCO m data structure optimization (code): 65 % m search strategies: 25 % m model: 10 % o Objective of CP Optimizer m data structure optimization (code): 0 % m search strategies: 10 % m model: 90 %
99
99 o Our current focus is on simplifying the solving process for the user o The user can then concentrate on modeling o Why? m Huge ROI: a good model may lead to x1000000 improvement m The goal of CP is to be close to the natural description of the problem m Usability of our product will be improved Focus CP at ILOG
100
100 o Our current focus is on simplifying the solving process for the user o The user can then concentrate on modeling o How? m Introduce a built-in intelligent search strategy o Control the strategy only through higher-level mechanisms m Increase speed of the search o Increase inference strength (constraint propagation) o Increase efficiency of the engine Focus CP at ILOG
101
101 o ILOG Solver is a mature product which has been on the market for fifteen years o We are embarking on a new product with a redesigned engine which we call ILOG CP ILOG CP
102
102 Conclusion o CP is a general technique: can encapsulate a lot of work o CP is an efficient method for solving some combinatorial problems: small or large o Filtering algorithms are quite important for non binary constraints o CP allows the use of sophisticated strategies o If you want to use CP: think CP (avoid Boolean (0-1) variables). CP allows the use of symbolic representation
103
103 More information o Go to www.ilog.comwww.ilog.com o Go to my webpage: www.constraint-programming.com/people/regin or google my name: Jean Charles Regin www.constraint-programming.com/people/regin
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.