Download presentation

Presentation is loading. Please wait.

Published byCody Hudson Modified over 2 years ago

1
Solve Your Problem Faster - by changing the model Barbara Smith

2
ERCIM/CologNet Workshop Background Assumptions A constraint programming tool providing: a systematic search algorithm combined with constraint propagation a set of pre-defined constraints A problem that can be represented as a finite domain constraint satisfaction or optimization problem Caveat: the experiences described are based on ILOG Solver

3
ERCIM/CologNet Workshop What do I mean by Faster? e.g.`Peaceable Armies of Queens problem place m black & m white queens on a chessboard so that the black queens dont attack the white queens, and maximize m Optimal solution for an 11 x 11 board:

4
ERCIM/CologNet Workshop Results for 8 x 8 board Backtracks to find optimal Backtracks to prove optimality Time (sec.) Basic model527012,002, Eliminate symmetry , New model ,01272 Variable order- ing heuristic ,27612 Just changing the model makes a huge difference to the time to solve the problem

5
ERCIM/CologNet Workshop What are the options? Given a CSP representation of the problem: if there is symmetry in the CSP, eliminate it find a related representation to use instead/as well add variables – to express different aspects of the problem add constraints to relate new variables to old to prune dead-ends earlier change the search strategy (other possibilities wont be considered)

6
ERCIM/CologNet Workshop Symmetry in the CSP A symmetry transforms any (full or partial) assignment into another so that consistency/inconsistency is preserved Symmetry causes wasted search effort: after exploring choices that dont lead to a solution, symmetrically equivalent choices will be explored Especially difficult if there is no solution, or if all solutions are wanted, or in optimization problems

7
ERCIM/CologNet Workshop Symmetry Breaking During Search (SBDS) See Gent & Smith, ECAI2000 A = set of assignments made so far var = valvar != val + g(var!= val) for any unbroken symmetry g, i.e. if g(A) is (or will be) true On backtracking to a choice point, add symmetry breaking constraints to the 2 nd branch explored

8
ERCIM/CologNet Workshop Symmetries of armies of queens Variable s[i,j] represents the square i, j The values are b, w or e (black, white or empty) 7 chess board symmetries: x (horizontal reflection), y, d1, d2, r90, r180, r270 + bw (swap black & white queens) + 7 combinations x(s[i,j]=v) s[n-i+1,j]=v bw(s[i,j] = v) s[i,j] = v, (v = b if v = w, w if v = b, e if v = e ) bw_x(s[i,j]=v) s[n-i+1,j]=v, etc. 15 symmetry functions are needed in all each takes a constraint as input, e.g. s[i,j]=v, and returns the symmetric constraint, e.g. s[i,j] = v

9
ERCIM/CologNet Workshop Armies of Queens – 8 x 8 Board All symmetries swapping colours now broken on this branch s[1,2]=w s[1,2] != w s[1,1]=w s[1,1] != w d1: s[1,1]!=w bw_x: s[8,1]!=b, etc. x: s[8,1]!=w bw: s[1,1]!=b r90: s[1,8]!=w x: if s[8,1]=w then s[8,2]!=w, etc.

10
ERCIM/CologNet Workshop Results for 8 x 8 board Fails to find optimal Fails to prove optimality Time (sec.) Basic model527012,002, Eliminate symmetry ,652240

11
ERCIM/CologNet Workshop Optimizing SONET Rings See Sherali & Smith*, Improving Discrete Model Representations via Symmetry Considerations (*no relation) Transmission over optical fibre networks Known traffic demands between pairs of client nodes A node is installed on a SONET ring using an ADM (add-drop multiplexer) If there is traffic demand between 2 nodes, there must be a ring that they are both on Rings have capacity limits (number of ADMs, i.e. nodes, & traffic) Satisfy demands using the minimum number of ADMs

12
ERCIM/CologNet Workshop Example & Optimal Solution Up to 7 rings, maximum capacity 5 ADMs Ignore traffic capacity (for now)

13
ERCIM/CologNet Workshop A CSP Model Variables: x ij = 1 if node i is on ring j At most 5 nodes on any ring: If there is a demand between nodes k and l : Minimize

14
ERCIM/CologNet Workshop Symmetry in the SONET CSP The rings are indistinguishable (only numbered for the purposes of the CSP model) We can eliminate the symmetry using SBDS just by describing all transpositions of pairs of rings: e.g. r12(x[i,j] = v) x[i,2]=v if j =1 x[i,1]=v if j =2 x[i,j]=v otherwise Thats all – we can forget about symmetry (e.g. when choosing the variable ordering)

15
ERCIM/CologNet Workshop Three Alternative Models Whether a given node is on a given ring: x ij = 1 if node i is on ring j Which ring(s) each node is on: N i = set of rings node i is on Which nodes are on each ring R j = set of nodes on ring j In principle, any of these 3 sets of variables could be the basis of a complete CSP model

16
ERCIM/CologNet Workshop Dual Models from Boolean Variables Given a CSP with Boolean variables x ijkl… we can form a new set of variables with one less subscript: e.g. x ijkl… = 1 corresponds to y jkl… = i (an integer variable) or i Y jkl… (a set variable), depending on whether one or several possible values i are associated with each combination of j,k,l,… if the Boolean variables have n subscripts, we can derive n sets of dual variables

17
ERCIM/CologNet Workshop Which Model to Choose? We dont need to choose just one set of variables – we can use them all at once We then need new channelling constraints to link the sets of variables: (x ij = 1) = (i R j ) = (j N i ) (see Cheng, Choi, Lee & Wu, Constraints, 1999) But we should not combine all 3 complete models Adding variables & channelling constraints doesnt cost much – duplicated constraints do

18
ERCIM/CologNet Workshop Why add more variables? Express each problem constraint in whichever way is easiest /most natural/ propagates best e.g. gives better results than (Often easiest /most natural/ propagates best are the same thing) We can observe effects of search on different aspects of the model, & express them develop implied constraints, search strategies, etc.

19
ERCIM/CologNet Workshop Possible Variables in the SONET Problem Whether a given node is on a given ring Which ring(s) each node is on Which nodes are on each ring How many nodes are on each ring How many rings each node is on The total number of nodes on all rings The total of the number of rings each node is on Which demand pairs are on each ring Which ring(s) each demand pair is on How many rings are used ………

20
ERCIM/CologNet Workshop Choosing the Search Variables We need to choose a set of variables such that an assignment to each one, satisfying the constraints, is a complete solution to the problem Assume we pass the search variables to the search algorithm in a list or array the order determines a static variable ordering

21
ERCIM/CologNet Workshop Possible Choices Use just one set of variables, e.g. x ij – the others are just for constraint propagation Use two (or more) sets of variables (of the same type) e.g. R j,N i interleave them in a sensible (static) order or use a dynamic ordering applied to both sets of variables Use an incomplete set of variables first, to reduce the search space before assigning a complete set e.g. decide how many rings each node is on (search variables |N i |) and then which rings each node is on (x ij ) All three possibilities are useful – the first will be used in the SONET problem (and later the third)

22
ERCIM/CologNet Workshop Implied Constraints Constraints which can be derived from the existing constraints, and so dont eliminate any solutions We only want useful implied constraints: they reduce search: i.e. at some point during search, a partial assignment must be tried which is inconsistent with the implied constraint but would otherwise not fail immediately they reduce running time – the overhead of propagating extra constraints must be less than the savings in search

23
ERCIM/CologNet Workshop How to Find Useful Implied Constraints Identify obviously wrong partial assignments that may/do occur during search Try to predict them by contemplation/intuition Observe the search in progress Having many variables in the model enables observing/thinking about many possible aspects of the search But we still need to check empirically that new constraints do reduce both search and running time

24
ERCIM/CologNet Workshop Implied Constraints: SONET A node with degree in the demand graph > 4 must be on more than 1 ring (|N i | > 1) If a pair of connected nodes have more than 3 neighbours in total, at least one of the pair must be on more than 1 ring (|N k |+|N l | > 2)

25
ERCIM/CologNet Workshop Optimality Constraints In optimizing, if we know that for any solution with a particular characteristic, there must be another solution at least as good, we can add constraints forbidding it e.g. no ring should have just one node on it any two rings must have more than 5 nodes in total (otherwise we could merge them) Derive these in the same way as implied constraints

26
ERCIM/CologNet Workshop Variable Ordering Heuristics Armies of Queens: Place a white queen next where it will attack fewest additional squares SONET problem: add a node to a ring with spare capacity; choose the node connected to most nodes already on the ring; of those, the node connected to most nodes still to be placed

27
ERCIM/CologNet Workshop Finding a Good Solution v. Proving Optimality Armies of Queens the heuristic finds an optimal solution for every case where this is known but… its hopeless for proving optimality the `anti-heuristic (place a white queen where it will attack most additional squares) is much better!

28
ERCIM/CologNet Workshop Finding a Good Solution v. Proving Optimality: SONET The heuristic finds near-optimal solutions quite quickly, but is no good for proving optimality How could we prove this solution is optimal: {2,3,4,9,12}, {1,3,7,8,10}, {4,5,6,7,10}, {1,8,11,12,13} ? e.g. show that we cannot reduce the number of times that any of 3, 4, 7, 8, 12 appear without having another node appear twice instead Introduce variables n i = |N i | i.e. the number of rings that node i is on Two-stage search: find a good solution, then start search again, assigning n i variables first and then x ij variables

29
ERCIM/CologNet Workshop What do I mean by Faster? The basic model (just the x ij variables, no symmetry- breaking) can only solve small problems (7 nodes, 8 demand pairs) The final model can solve the problems in the Sherali & Smith paper (13 nodes, 24 demand pairs) 3 full sets of variables + others SBDS implied constraints variable ordering heuristic two-stage search process

30
ERCIM/CologNet Workshop Some Advice Eliminate symmetry Use lots of variables, with channelling constraints But dont express the same problem constraints twice Add constraints that make explicit what you know about satisfying/optimal solutions But only if they reduce search and running time Learn from solving the problem by hand and observing the search If finding good solutions is easy and proving optimality is hard, consider using a different strategies for each stage

31
ERCIM/CologNet Workshop Conclusions Can we list 10 Steps to Successful Modelling? New problems still often lead to new ideas about modelling But some patterns do recur frequently e.g. models representing dual viewpoints We are beginning to automate some aspects of modelling e.g. symmetry, implied constraints Still a long way to go before building a good model of a problem is straightforward e.g. we often cant tell if model A is better than model B without trying them both More research is still needed...

32
ERCIM/CologNet Workshop Selected References Symmetry Breaking During Search in Constraint Programming, I. P. Gent and B. M. Smith, Proceedings ECAI'2000, pp , Models and Symmetry Breaking for `Peaceable Armies of Queens, K.E Petrie, B. M. Smith & I. P. Gent, APES Report APES , May I mproving Discrete Model Representations via Symmetry Considerations, H. D. Sherali & J. C. Smith, Man.Sci. (47) pp , Increasing Constraint Propagation by Redundant Modeling: an Experience Report, B. M. W. Cheng, K. M. F. Choi, J. H. M. Lee & J. C. K. Wu, Constraints (4) pp , 1999.

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google