Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CP for the Sudoku Intolerant

Avatar for Alastair Alastair
September 14, 2016
64

CP for the Sudoku Intolerant

A talk for Edinburgh Tech Meetup on Wednesday the 14th September 2016. A large part of the talk was a live coding exercise.

Avatar for Alastair

Alastair

September 14, 2016

Transcript

  1. Talk Outline •  Why? •  Me? Alastair Andrew / Airts

    •  CP? – and its part in my downfall… •  MiniZinc •  Live Coding / Car Crash •  How it works. •  Next Steps / Links
  2. What’s It Good For? •  Solving Sudoku – NO! (well yeah,

    but NO!) •  Solving Discrete Decision Problems •  CSPs / COPs – Vehicle Routing – Bin Packing – Timetabling – Job Scheduling – Balancing
  3. MiniZinc •  Aspires to be the standard modeling language – Like

    OPL – Or Essence’ – Or XCSP – Or AMPL – Or JSR331 •  Insert obligatory XKCD slide…
  4. MiniZinc •  Aspires to be the standard modeling language – Like

    OPL – Or Essence’ – Or XCSP – Or AMPL – Or JSR331 •  Decent editor, under active development, decent learning resources.
  5. Ceci n’est pas un CP Solver •  .mzn -> .fzn

    -> ? – From academia (Gecode, Choco, OscaR, Minion) – From industry (ILOG, CHiP, Opturion) •  Flavours –  Prolog-y (ECLiPSe, SICTus) –  ILOG-y (OR-tools, Choco etc) •  Wheel reinvention is rife… – Different motivations
  6. Basic Concepts •  Parameters – immutable properties •  Variables –

    decisions we need to choose •  Domains – values variables need to choose from •  Constraints – Restrictions on valid choices •  Objective – Satisfaction or Optimisation
  7. The Polyglot Problem “Fran French, Geraldine German, Dudley Dutch, Spike

    Spanish, Polly Polish and Ron Romanian are six British interpreters at the EU. They each speak two European languages, as well as English, but none speaks the language indicated by their name. No two interpreters speak the same two foreign languages and each of the six foreign languages is spoken by only two of them. Spike speaks Dutch and German while his cousin speaks Dutch and Polish. Fran and Dudley speak all the four languages not indicated by their names. Of the two languages that Dudley is fluent in, both of their namesakes speak French. No German speaker knows any Polish.” Which two languages does Ron speak? -Alex Bellos – Guardian – July 4th 2016
  8. The Problem “Fran French, Geraldine German, Dudley Dutch, Spike Spanish,

    Polly Polish and Ron Romanian are six British interpreters at the EU. They each speak two European languages, as well as English, but none speaks the language indicated by their name. No two interpreters speak the same two foreign languages and each of the six foreign languages is spoken by only two of them. Spike speaks Dutch and German while his cousin speaks Dutch and Polish. Fran and Dudley speak all the four languages not indicated by their names. Of the two languages that Dudley is fluent in, both of their namesakes speak French. No German speaker knows any Polish.” Which two languages does Ron speak? -Alex Bellos – Guardian – July 4th 2016
  9. CP = Search + Inference •  Inference –  A.k.a. Propagation

    –  Constraint “knows” the variables it constrains –  Informed of changes to those variables’ domains –  Can then remove inconsistent values •  Our Polyglot.mzn model had: –  Unary constraints – card(languages[i]) = 2) –  Binary constraints - languages[i] != languages[j] •  No Global Constraints though… –  Sorry all_different. L
  10. Search •  Propagation only gets us so far. –  The

    Fix Point. •  We need to make some choices… –  Branching ( x = y | x != y ) –  Sometimes those are bad choices •  Domain wipeout! •  “When the fact’s change I change my mind” – Not Maynard Keynes •  Backtracking –  Restore the variables’ domains –  Assert the alternate branch –  Propagate. Rinse, Lather, Repeat. Or Restart...
  11. Steel Mill Slab Design •  First proposed in 1998 by

    IBM •  Problem 38 of the CSP Lib -111 orders, 88 colours, 20 slab sizes •  For about 10 years it was intractable •  Until Gargani & Refala [2007] –  Breakthrough. Or not. –  Smashed the largest instance < 3s –  Combined existing techniques… reified constraints, symmetry breaking, value selection, LNS, etc.
  12. Next Steps… •  Peter Stuckey’s Coursera Course “Modeling Discrete Optimization”

    –  Starts September 26th… •  Hakank’s CP Blog –  http://www.hakank.org/ –  The Rosetta Stone of CP. •  The MiniZinc modelling challenge –  http://www.minizinc.org/challenge.html •  The ROADEF Challenge (the French OR Society) –  http://challenge.roadef.org/2016/fr/ •  The Global Constraints Catalogue –  http://sofdem.github.io/gccat/ •  Helmut Simonis’ CP Applications Blog –  https://hsimonis.wordpress.com/
  13. CP landscape •  We’ve not even touched on other approaches

    •  Heuristic Search •  Mixed Integer Programming •  Genetic Algorithms •  Etc, etc. •  A whole world of fun awaits!