Similar presentations

2 Background AssumptionsA constraint programming tool providing:a systematic search algorithmcombined with constraint propagationa set of pre-defined constraintsA problem that can be represented as a finite domain constraint satisfaction or optimization problemCaveat: the experiences described are based on ILOG SolverERCIM/CologNet Workshop

3 ERCIM/CologNet WorkshopWhat do I mean by Faster?e.g.`Peaceable Armies of Queens’ problemplace m black & m white queens on a chessboard so that the black queens don’t attack the white queens, and maximize mOptimal solution for an 11 x board:ERCIM/CologNet Workshop

5 ERCIM/CologNet WorkshopWhat are the options?Given a CSP representation of the problem:if there is symmetry in the CSP, eliminate itfind a related representation to use instead/as welladd variables – to express different aspects of the problemadd constraintsto relate new variables to oldto prune dead-ends earlierchange the search strategy(other possibilities won’t be considered)ERCIM/CologNet Workshop

6 ERCIM/CologNet WorkshopSymmetry in the CSPA symmetry transforms any (full or partial) assignment into another so that consistency/inconsistency is preservedSymmetry causes wasted search effort: after exploring choices that don’t lead to a solution, symmetrically equivalent choices will be exploredEspecially difficult if there is no solution, or if all solutions are wanted, or in optimization problemsERCIM/CologNet Workshop

11 Optimizing SONET RingsSee Sherali & Smith*, ‘Improving Discrete Model Representations via Symmetry Considerations’ (*no relation)Transmission over optical fibre networksKnown traffic demands between pairs of client nodesA 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 onRings have capacity limits (number of ADMs, i.e. nodes, & traffic)Satisfy demands using the minimum number of ADMsERCIM/CologNet Workshop

13 ERCIM/CologNet WorkshopA CSP ModelVariables: xij = 1 if node i is on ring jAt most 5 nodes on any ring:If there is a demand between nodes k and l :MinimizeERCIM/CologNet Workshop

14 Symmetry in the SONET CSPThe 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 = x[i,1]=v if j = x[i,j]=v otherwiseThat’s all – we can forget about symmetry (e.g. when choosing the variable ordering)ERCIM/CologNet Workshop

15 Three Alternative ModelsWhether a given node is on a given ring:xij = 1 if node i is on ring jWhich ring(s) each node is on:Ni = set of rings node i is onWhich nodes are on each ringRj = set of nodes on ring jIn principle, any of these 3 sets of variables could be the basis of a complete CSP modelERCIM/CologNet Workshop

16 Dual Models from Boolean VariablesGiven a CSP with Boolean variables xijkl… we can form a new set of variables with one less subscript:e.g. xijkl… = 1 corresponds to yjkl… = i (an integer variable) or i  Yjkl… (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 variablesERCIM/CologNet Workshop

17 ERCIM/CologNet WorkshopWhich Model to Choose?We don’t need to choose just one set of variables – we can use them all at onceWe then need new channelling constraints to link the sets of variables:(xij = 1) = (i  Rj) = (j  Ni)(see Cheng, Choi, Lee & Wu, Constraints, 1999)But we should not combine all 3 complete modelsAdding variables & channelling constraints doesn’t cost much – duplicated constraints doERCIM/CologNet Workshop

19 Possible Variables in the SONET ProblemWhether 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 ringWhich ring(s) each demand pair is onHow many rings are used………ERCIM/CologNet Workshop

20 Choosing the Search VariablesWe need to choose a set of variables such that an assignment to each one, satisfying the constraints, is a complete solution to the problemAssume we pass the search variables to the search algorithm in a list or arraythe order determines a static variable orderingERCIM/CologNet Workshop

21 ERCIM/CologNet WorkshopPossible ChoicesUse just one set of variables, e.g. xij – the others are just for constraint propagationUse two (or more) sets of variables (of the same type) e.g. Rj ,Niinterleave them in a sensible (static) orderor use a dynamic ordering applied to both sets of variablesUse an incomplete set of variables first, to reduce the search space before assigning a complete sete.g. decide how many rings each node is on (search variables |Ni|) and then which rings each node is on (xij )All three possibilities are useful – the first will be used in the SONET problem (and later the third)ERCIM/CologNet Workshop

22 ERCIM/CologNet WorkshopImplied ConstraintsConstraints which can be derived from the existing constraints, and so don’t eliminate any solutionsWe 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 immediatelythey reduce running time – the overhead of propagating extra constraints must be less than the savings in searchERCIM/CologNet Workshop

23 How to Find Useful Implied ConstraintsIdentify obviously wrong partial assignments that may/do occur during searchTry to predict them by contemplation/intuitionObserve the search in progressHaving many variables in the model enables observing/thinking about many possible aspects of the searchBut we still need to check empirically that new constraints do reduce both search and running timeERCIM/CologNet Workshop

24 Implied Constraints: SONETA node with degree in the demand graph > 4 must be on more than 1 ring (|Ni| > 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 (|Nk|+|Nl| > 2)ERCIM/CologNet Workshop

25 Optimality ConstraintsIn 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 ite.g.no ring should have just one node on itany two rings must have more than 5 nodes in total (otherwise we could merge them)Derive these in the same way as implied constraintsERCIM/CologNet Workshop

26 Variable Ordering HeuristicsArmies of Queens:Place a white queen next where it will attack fewest additional squaresSONET 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 placedERCIM/CologNet Workshop

27 Finding a Good Solution v. Proving OptimalityArmies of Queensthe heuristic finds an optimal solution for every case where this is knownbut… it’s hopeless for proving optimalitythe `anti-heuristic’ (place a white queen where it will attack most additional squares) is much better!ERCIM/CologNet Workshop

28 Finding a Good Solution v. Proving Optimality: SONETThe heuristic finds near-optimal solutions quite quickly, but is no good for proving optimalityHow 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 insteadIntroduce variables ni = |Ni| i.e. the number of rings that node i is on Two-stage search: find a good solution, then start search again, assigning ni variables first and then xij variablesERCIM/CologNet Workshop

30 ERCIM/CologNet WorkshopSome AdviceEliminate symmetryUse lots of variables, with channelling constraintsBut don’t express the same problem constraints twiceAdd constraints that make explicit what you know about satisfying/optimal solutionsBut only if they reduce search and running timeLearn from solving the problem by hand and observing the searchIf finding good solutions is easy and proving optimality is hard, consider using a different strategies for each stageERCIM/CologNet Workshop

31 ERCIM/CologNet WorkshopConclusionsCan we list “10 Steps to Successful Modelling”?New problems still often lead to new ideas about modellingBut some patterns do recur frequentlye.g. models representing dual viewpointsWe are beginning to automate some aspects of modellinge.g. symmetry, implied constraintsStill a long way to go before building a good model of a problem is straightforwarde.g. we often can’t tell if model A is better than model B without trying them bothMore research is still needed...ERCIM/CologNet Workshop