CP Solvers Gecode Marco Chiarandini Department of Mathematics - - PowerPoint PPT Presentation

cp solvers gecode
SMART_READER_LITE
LIVE PREVIEW

CP Solvers Gecode Marco Chiarandini Department of Mathematics - - PowerPoint PPT Presentation

DM826 Spring 2014 Modeling and Solving Constrained Optimization Problems Lecture 4 CP Solvers Gecode Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark [ The slides on Gecode are by Christian


slide-1
SLIDE 1 DM826 – Spring 2014 Modeling and Solving Constrained Optimization Problems Lecture 4

CP Solvers Gecode

Marco Chiarandini

Department of Mathematics & Computer Science University of Southern Denmark [The slides on Gecode are by Christian Schulte, KTH Royal Institute of Technology]
slide-2
SLIDE 2 Constraint Languages Gecode

Outline

  • 1. Constraint Languages
  • 2. Gecode
2
slide-3
SLIDE 3 Constraint Languages Gecode

Constraint Programming Systems

Expressiveness language stream (modelling) + (efficient solvers) Algorithm stream CP systems typically include general purpose algorithms for constraint propagation (arc consistency on finite domains) built-in constraint propagation for various constraints (eg, linear, boolean, global constraints) built-in for constructing various forms of search

3
slide-4
SLIDE 4 Constraint Languages Gecode

Logic Programming

Logic programming is the use of mathematical logic for computer programming. First-order logic is used as a purely declarative representation language, and a theorem-prover or model-generator is used as the problem-solver. Logic programming supports the notion of logical variables Syntax – Language

Alphabet Well-formed Expressions E.g., 4X + 3Y = 10; 2X - Y = 0

Semantics – Meaning

Interpretation Logical Consequence

Calculi – Derivation

Inference Rule Transition System 4
slide-5
SLIDE 5 Constraint Languages Gecode

Logic Programming

Example: Prolog A logic program is a set of axioms, or rules, defining relationships between objects. A computation of a logic program is a deduction of consequences of the program. A program defines a set of consequences, which is its meaning. Sterling and Shapiro: The Art of Prolog, Page 1. To deal with the other constraints one has to add other constraint solvers to the language. This led to Constraint Logic Programming

5
slide-6
SLIDE 6 Constraint Languages Gecode

Prolog Approach

Prolog II till Prolog IV [Colmerauer, 1990] CHIP V5 [Dincbas, 1988] http://www.cosytec.com (commercial) CLP [Van Hentenryck, 1989] Ciao Prolog (Free, GPL) GNU Prolog (Free, GPL) SICStus Prolog ECLiPSe [Wallace, Novello, Schimpf, 1997] http://eclipse-clp.org/ (Open Source) Mozart programming system based on Oz language (incorporates concurrent constraint programming) http://www.mozart-oz.org/

[Smolka, 1995] 6
slide-7
SLIDE 7 Constraint Languages Gecode

Other Approaches

Libraries: Constraints are modelled as objects and are manipulated by means of special methods provided by the given class. CHOCO (free) http://choco.sourceforge.net/ Kaolog (commercial) http://www.koalog.com/php/index.php ILOG CP Optimizer www.cpoptimizer.ilog.com (ILOG, commercial) Gecode (free) www.gecode.org C++, Programming interfaces Java and MiniZinc G12 Project http://www.nicta.com.au/research/projects/constraint_ programming_platform

7
slide-8
SLIDE 8 Constraint Languages Gecode

Other Approaches

Modelling languages: OPL [Van Hentenryck, 1999] ILOG CP Optimizer www.cpoptimizer.ilog.com (ILOG, commercial) MiniZinc [] (open source, works for various systems, ECLiPSe, Geocode) Comet AMPL

8
slide-9
SLIDE 9 Constraint Languages Gecode

CP Languages

Greater expressive power than mathematical programming constraints involving disjunction can be represented directly constraints can be encapsulated (as predicates) and used in the definition of further constrains However, CP models can often be translated into MIP model by eliminating disjunctions in favor of auxiliary Boolean variables unfolding predicates into their definitions

9
slide-10
SLIDE 10 Constraint Languages Gecode

CP Languages

Fundamental difference to LP

language has structure (global constraints) different solvers support different constraints

In its infancy Key questions:

what level of abstraction? solving approach independent: LP, CP, ...? how to map to different systems? Modelling is very difficult for CP requires lots of knowledge and tinkering 10
slide-11
SLIDE 11 Constraint Languages Gecode

Summary

Model your problem via Constraint Satisfaction Problem Decalre Constraints + Program Search Constraint Propagation Languages

11
slide-12
SLIDE 12 Constraint Languages Gecode

Outline

  • 1. Constraint Languages
  • 2. Gecode
12
slide-13
SLIDE 13

Gecode

an open constraint solving library

Christian Schulte

KTH Royal Institute of Technology, Sweden

slide-14
SLIDE 14

Gecode People

Core team

Christian Schulte, Guido Tack, Mikael Z. Lagerkvist.

Code

  • contributions: Christopher Mears, David Rijsman, Denys Duchier, Filip Konvicka, Gabor

Szokoli, Gabriel Hjort Blindell, Gregory Crosswhite, Håkan Kjellerstrand, Joseph Scott, Lubomir Moric, Patrick Pekczynski, Raphael Reischuk, Stefano Gualandi, Tias Guns, Vincent Barichard.

  • fixes: Alexander Samoilov, David Rijsman, Geoffrey Chu, Grégoire Dooms, Gustavo

Gutierrez, Olof Sivertsson, Zandra Norman.

Documentation

  • contributions: Christopher Mears.
  • fixes: Seyed Hosein Attarzadeh Niaki, Vincent Barichard, Pavel Bochman, Felix Brandt,

Markus Böhm, Roberto Castañeda Lozano, Gregory Crosswhite, Pierre Flener, Gustavo Gutierrez, Gabriel Hjort Blindell, Sverker Janson, Andreas Karlsson, Håkan Kjellerstrand, Chris Mears, Benjamin Negrevergne, Flutra Osmani, Max Ostrowski, David Rijsman, Dan Scott, Kish Shen.

Gecode, Christian Schulte

2

September 2013

slide-15
SLIDE 15

Gecode

Generic Constraint Development Environment

  • pen

easy interfacing to other systems supports programming of: constraints, branching strategies, search engines, variable domains

comprehensive

constraints over integers, Booleans, sets, and floats

  • different ¡propagation ¡strength, ¡half ¡and ¡full ¡reification, ¡… ¡

advanced branching heuristics (accumulated failure count, activity) many search engines (parallel, interactive graphical, restarts) automatic symmetry breaking (LDSB) no-goods from restarts MiniZinc support

Gecode, Christian Schulte

3

September 2013

slide-16
SLIDE 16

Gecode

Generic Constraint Development Environment

efficient

all gold medals in all categories at all MiniZinc Challenges

documented

tutorial (> 500 pages) and reference documentation

free

MIT license, listed as free software by FSF

portable

implemented in C++ that carefully follows the C++ standard

parallel

exploits multiple cores of today's hardware for search

tested

some 50000 test cases, coverage close to 100%

Gecode, Christian Schulte

4

September 2013

slide-17
SLIDE 17

SOME BASIC FACTS

September 2013 Gecode, Christian Schulte

5

slide-18
SLIDE 18

Architecture

Small domain-independent kernel Modules

per variable type: variables, constraint, branchings, ¡… search, FlatZinc support, ¡…

Modeling layer

arithmetic, ¡set, ¡Boolean ¡operators; ¡regular ¡expressions; ¡matrices, ¡…

All APIs are user-level and documented (tutorial + reference)

September 2013 Gecode, Christian Schulte

6

integers sets floats search engines Gist

interactive search tool

modeling layer Gecode kernel

propagation loop backtracking for search memory management
slide-19
SLIDE 19

Openness

MIT license permits commercial, closed-source use

motivation: public funding, focus on research not a reason: attitude, politics, dogmatism

More than a license

license restricts what users may do code and documentation restrict what users can do

Modular, structured, documented, readable

complete tutorial and reference documentation new ideas from Gecode available as scientific publications

Equal rights: Gecode users are first-class citizens

you can do what we can do: APIs you can know what we know: documentation

  • n every level of abstraction

Gecode, Christian Schulte

7

September 2013

slide-20
SLIDE 20

Constraints in Gecode

Constraint families

arithmetics, Boolean, ordering, ¡…. alldifferent, count (global cardinality, …), ¡element, scheduling, table and regular, sorted, sequence, circuit, channel, bin-packing, lex, geometrical packing, nvalue, lex, ¡value ¡precedence, ¡…

Families

many different variants and different propagation strength

All global constraints from MiniZinc have a native implementation Gecode  Global Constraint Catalogue: > 70 constraints

abs_value, all_equal, alldifferent, alldifferent_cst, among, among_seq, among_var, and, arith, atleast, atmost, bin_packing, bin_packing_capa, circuit, clause_and, clause_or, count, counts, cumulative, cumulatives, decreasing, diffn, disjunctive, domain, domain_constraint, elem, element, element_matrix, eq, eq_set, equivalent, exactly, geq, global_cardinality, gt, imply, in, in_interval, in_intervals, in_relation, in_set, increasing, int_value_precede, int_value_precede_chain, inverse, inverse_offset, leq, lex, lex_greater, lex_greatereq, lex_less, lex_lesseq, link_set_to_booleans, lt, maximum, minimum, nand, neq, nor, not_all_equal, not_in, nvalue, nvalues, or, roots, scalar_product, set_value_precede, sort, sort_permutation, strictly_decreasing, strictly_increasing, sum_ctr, sum_set, xor

Gecode, Christian Schulte

8

September 2013

slide-21
SLIDE 21

History

2002

development started

1.0.0 43 kloc, 21 klod

December 2005

2.0.0 77 kloc, 41 klod

November 2007

3.0.0 81 kloc, 41 klod

March 2009

4.0.0 164 kloc, 69 klod

March 2013

4.2.0 (current) 168 kloc, 71 klod

July 2013

September 2013 Gecode, Christian Schulte

9

34 releases

slide-22
SLIDE 22

Tutorial Documentation

2002

development started

1.0.0 43 kloc, 21 klod

December 2005

2.0.0 77 kloc, 41 klod

November 2007

3.0.0 81 kloc, 41 klod

March 2009

4.0.0 164 kloc, 69 klod

March 2013

4.2.0 (current) 168 kloc, 71 klod

July 2013

September 2013 Gecode, Christian Schulte

10

Modeling with Gecode (98 pages) Modeling & Programming with Gecode (522 pages)

slide-23
SLIDE 23

Future

Large neighborhood search and other meta-heuristics

contribution expected

Simple temporal networks for scheduling

contribution expected

More expressive modeling layer on top of libmzn Grammar constraints

contribution expected

Propagator groups … Contributions anyone?

Gecode, Christian Schulte

11

September 2013

slide-24
SLIDE 24

Deployment & Distribution

Open ¡source ¡≠ ¡Linux ¡only

Gecode is native citizen of: Linux, Mac, Windows

High-quality

extensive test infrastructure (around 16% of code base)

Downloads from Gecode webpage

software: between 25 to 125 per day (total > 40000) documentation: between 50 to 300 per day

Included in

Debian, Ubuntu, Fedora, OpenSUSE, Gentoo, ¡FreeBSD, ¡…

Gecode, Christian Schulte

18

September 2013

slide-25
SLIDE 25

Integration & Standardization

Why C++ as implementation language?

good compromise between portability and efficiency good for interfacing well demonstrated

Integration ¡with ¡XYZ…

Gecode empowers users to do it no ¡“Jack ¡of ¡all ¡trades, ¡master ¡of ¡none” well demonstrated

Standardization

any ¡user ¡can ¡build ¡an ¡interface ¡to ¡whatever ¡standard… systems are the wrong level of abstraction for standardization MiniZinc and AMPL are de-facto standards

September 2013 Gecode, Christian Schulte

19

slide-26
SLIDE 26

!"#$%&'()*)+,"(,-..&'(

slide-27
SLIDE 27
  • !"#$%&'#&("'
slide-28
SLIDE 28
  • !"#$%&'#&("'
slide-29
SLIDE 29

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< #=

>?9/?09@

Program model as script

declare variables post constraints (creates propagators) define branching

Solve script

basic search strategy Gist: interactive visual search

slide-30
SLIDE 30

!"#$"%&'(#)*+'%,'-."/01

slide-31
SLIDE 31

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< #=

56/0>2?,@A9/A09B

Script is class inheriting from class Space

  • members store variables regarded as solution

Script constructor

  • initialize variables
  • post propagators for constraints
  • define branching

Copy constructor and copy function

  • copy a Script object during search

Exploration takes Script object as input

  • returns object representing solution

Main function

  • invokes search engine
slide-32
SLIDE 32

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< #=

56/0>2,?@/,5AAB,52/7627/9

!"#$%&'()*+($,'(-"#./001 !"#$%&'()*+($,'(-2(34$0/001 &2"#+)#35(263$()7($,'(8 $%322)9(#':,4(:,#(; <)6&=%"$)963$()> 64,.($.('< ?#.@34A443; %8)--)B"+".2)C,4).0()%(..(42 6&=%"$<

  • -)D,#2.4&$.,4)C,4)2$4"6.

9(#':,4(:,#(;

  • -)D,#2.4&$.,4)C,4)$%,#"#+

9(#':,4(:,#(;E=,,% 2034(F)9(#':,4(:,#(;

  • -)G(4C,45)$,6;"#+)'&4"#+)$%,#"#+

H"4.&3%)963$(I)$,6;E=,,%

  • -)G4"#.)2,%&.",#
  • J8
slide-33
SLIDE 33

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !"

56/0=2,>?/,5@@A,52/7627/9

!"#$%&'()*+($,'(-"#./001 !"#$%&'()*+($,'(-2(34$0/001 &2"#+)#35(263$()7($,'(8 $%322)9(#':,4(:,#(; <)6&=%"$)963$()> 64,.($.('< ?#.@34A443; %8)--)B"+".2)C,4).0()%(..(42 6&=%"$<

  • -)D,#2.4&$.,4)C,4)2$4"6.

9(#':,4(:,#(;

  • -)D,#2.4&$.,4)C,4)$%,#"#+

9(#':,4(:,#(;E=,,% 2034(F)9(#':,4(:,#(;

  • -)G(4C,45)$,6;"#+)'&4"#+)$%,#"#+

H"4.&3%)963$(I)$,6;E=,,%

  • -)G4"#.)2,%&.",#
  • J8
  • array of integer variables

stores solution

slide-34
SLIDE 34

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !#

56/0=2,>?/,5@@A,52/7627/9

!"#$%&'()*+($,'(-"#./001 !"#$%&'()*+($,'(-2(34$0/001 &2"#+)#35(263$()7($,'(8 $%322)9(#':,4(:,#(; <)6&=%"$)963$()> 64,.($.('< ?#.@34A443; %8)--)B"+".2)C,4).0()%(..(42 6&=%"$<

  • -)D,#2.4&$.,4)C,4)2$4"6.

9(#':,4(:,#(;

  • -)D,#2.4&$.,4)C,4)$%,#"#+

9(#':,4(:,#(;E=,,% 2034(F)9(#':,4(:,#(;

  • -)G(4C,45)$,6;"#+)'&4"#+)$%,#"#+

H"4.&3%)963$(I)$,6;E=,,%

  • -)G4"#.)2,%&.",#
  • J8
  • constructor: initialize

variables, post constraints, define branching

slide-35
SLIDE 35

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !!

56/0=2,>?/,5@@A,52/7627/9

!"#$%&'()*+($,'(-"#./001 !"#$%&'()*+($,'(-2(34$0/001 &2"#+)#35(263$()7($,'(8 $%322)9(#':,4(:,#(; <)6&=%"$)963$()> 64,.($.('< ?#.@34A443; %8)--)B"+".2)C,4).0()%(..(42 6&=%"$<

  • -)D,#2.4&$.,4)C,4)2$4"6.

9(#':,4(:,#(;

  • -)D,#2.4&$.,4)C,4)$%,#"#+

9(#':,4(:,#(;E=,,% 2034(F)9(#':,4(:,#(;

  • -)G(4C,45)$,6;"#+)'&4"#+)$%,#"#+

H"4.&3%)963$(I)$,6;E=,,%

  • -)G4"#.)2,%&.",#
  • J8
  • copy constructor and

copy function

slide-36
SLIDE 36

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !%

56/0=2,>?/,5@@A,-?412/762?/

!"#$%&'"%&#"()*&+$,-.-/)012+34-54-64-7,-8 9#1:;' 3)/<6=,4-")/<>=,4-#)/<?=,4-$)/<@=,4 A)/<B=,4-&)/<C=,4-')/<D=,4-()/<E=,F GG-H&31-I&#31';+#13

  • GG-H&31-J';#I2+#K3
  • L
slide-37
SLIDE 37

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !)

56/0=2,>?/,5@@A,-?412/762?/

!"#$%&'"%&#"()*&+$,-.-/)012+34-54-64-7,-8 9#1:;' 3)/<6=,4-")/<>=,4-#)/<?=,4-$)/<@=,4 A)/<B=,4-&)/<C=,4-')/<D=,4-()/<E=,F GG-H&31-I&#31';+#13

  • GG-H&31-J';#I2+#K3
  • L

variables created in this script (space)

slide-38
SLIDE 38

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !&

56/0=2,>?/,5@@A,-?412/762?/

!"#$%&'"%&#"()*&+$,-.-/)012+34-54-64-7,-8 9#1:;' 3)/<6=,4-")/<>=,4-#)/<?=,4-$)/<@=,4 A)/<B=,4-&)/<C=,4-')/<D=,4-()/<E=,F GG-H&31-I&#31';+#13

  • GG-H&31-J';#I2+#K3
  • L

8 variables

slide-39
SLIDE 39

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !=

56/0>2,?@/,5AAB,-@412/762@/

!"#$%&'"%&#"()*&+$,-.-/)012+34-54-64-7,-8 9#1:;' 3)/<6=,4-")/<>=,4-#)/<?=,4-$)/<@=,4 A)/<B=,4-&)/<C=,4-')/<D=,4-()/<E=,F GG-H&31-I&#31';+#13

  • GG-H&31-J';#I2+#K3
  • L

take values between 0 and 9 (digits)

slide-40
SLIDE 40

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !=

56/0>2,?@/,5AAB,-@412/762@/

!"#$%&'"%&#"()*&+$,-.-/)012+34-54-64-7,-8 9#1:;' 3)/<6=,4-")/<>=,4-#)/<?=,4-$)/<@=,4 A)/<B=,4-&)/<C=,4-')/<D=,4-()/<E=,F GG-H&31-I&#31';+#13

  • GG-H&31-J';#I2+#K3
  • L

refer to variables by their letters

slide-41
SLIDE 41

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !=

56/0>2,?@/,5AAB,-@412/762@/

!"#$%&'"%&#"()*&+$,-.-/)012+34-54-64-7,-8 9#1:;' 3)/<6=,4-")/<>=,4-#)/<?=,4-$)/<@=,4 A)/<B=,4-&)/<C=,4-')/<D=,4-()/<E=,F GG-H&-/";$+#I-J"'&3-)9KL.-+#1"I"'-'"/;1+&#-1(M", '"/)012+34-34-9KLNHO4-6,F- '"/)012+34-A4-9KLNHO4-6,F GG-P//-/"11"'3-AQ31-1;R"-$+31+#S1-$+I+13 $+31+#S1)012+34-/,F GG-L2"-/+#";'-"TQ;1+&#-AQ31-2&/$

  • GG-U';#S2-&*"'-12"-/"11"'3
  • V
slide-42
SLIDE 42

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< !=

>?1204@,-?412/30421

Defined in namespace !"#$%" Check documentation for available

constraints

Take script reference as first argument

where is the propagator for the constraint to be posted! script is a subclass of Space (computation space)

slide-43
SLIDE 43

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %"

*0493/,=>7320?41,34@,*0493/,-?412/30421

Equations of the form

c1x1 cnxn = d

  • integer constants:

ci and d

  • integer variables:

xi

In Gecode specified by arrays

  • integers

(!"#$%&'( ci

  • variables

(!"#)*%$%%*+,-!"#)*%$%&'( xi

Not only equations

  • !./012,-!./032,-!./041,-!./05.,-!./042,-!./052
  • equality, disequality, inequality (less, greater, less or equal, greater or

equal)

slide-44
SLIDE 44

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %#

56/0=2,>?/,5@@A,-?412/762?/

!"#$%&'"%&#"()*&+$,-.-/)012+34-54-64-7,-8

  • 99-:2"-/+#";'-"<=;1+&#->=31-2&/$

?#1@'A3 B)CDCDE,F-?#1G;'@'A3 H)CDCDE,F BI6JKL666F-BILJKL66F-BIMJKL6F-BINJKLF HI6JK3F----HILJK"F---HIMJK#F--HINJK$F BICJKL666F-BIEJKL66F-BIOJKL6F-BIPJKLF HICJK>F----HIEJK&F---HIOJK'F--HIPJK"F BI5JKQL6666F-BI7JKQL666F-BIL6JKQL66F-BILLJKQL6F-BILMJKQLF HI5JK>F------HI7JK&F-----HIL6JK#F----HILLJK"F---HILMJK(F /+#";')012+34-B4-H4-?R:STU4-6,F 99-V';#B2-&*"'-12"-/"11"'3

  • W
slide-45
SLIDE 45

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %!

*0493/,=>?/9110@41

Other options for posting linear constraints

are available: minimodeling support

linear expressions Boolean expressions matrix classes

See the examples that come with Gecode

slide-46
SLIDE 46

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %%

56/0=2,>?/,5@@A,-?412/762?/

  • !"#$%&'()*+($,'(-."#".,'(%/001
  • 2(#'3,4(3,#(567,"'8)9)%6:;0"<=)>=)?=)@8)A
  • -)B0()%"#(C4)(D&C;",#).&<;)0,%'

E,<;6:;0"<=)))))))))))))F???:<)G)F??:()G)F?:#)G)' G)F???:.)G)F??:,)G)F?:4)G)( HH)F????:.)G)F???:,)G)F??:#)G)F?:()G)58I

  • -)J4C#$0),7(4);0()%(;;(4<
  • K
slide-47
SLIDE 47

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %)

56/0=2,>?/,5@@A,-?412/762?/

!"#$%&'"%&#"()*&+$,-.-/)012+34-54-64-7,-8

  • 99-:';#<2-&*"'-12"-/"11"'3

=';#<2)012+34-/4->?@ABCDA!>EFA%>?4->?@ABCGA%>?,H I

slide-48
SLIDE 48

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %&

=/346.04>

Which variable to choose

given order

!"#$%&'$"(")

smallest size

!"#$%&'$*!+)$,!"

smallest minimum

!"#$%&'$,!"$,!"

How to branch: which value to choose

try smallest value

!"#$%&-$,!"

split (lower first)

!"#$%&-$*.-!#$,!"

slide-49
SLIDE 49

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %=

56/0>2,?@/,5AAB,-@>C04D

!!"#$%&'()*'$("+$("*,$%-%. /0%12$(02$%0345$$, &67(08"/0%12$(02$%039"&:";"/<7*04&67(08"&:"= ,>)<17'04?'6-&8"&67(08"&>,:@ A !!"B0(+$(C"*$<3-%."1)(-%."*,$%-%. D-(')7,"/<7*0?"*$<345$$, &67(0:"= (0')(%"%0E"/0%12$(02$%034&67(08?'6-&:@ A

slide-50
SLIDE 50

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %=

56/0>2,?@/,5AAB,-@>C04D

!!"#$%&'()*'$("+$("*,$%-%. /0%12$(02$%0345$$, &67(08"/0%12$(02$%039"&:";"/<7*04&67(08"&:"= ,>)<17'04?'6-&8"&67(08"&>,:@ A !!"B0(+$(C"*$<3-%."1)(-%."*,$%-%. D-(')7,"/<7*0?"*$<345$$, &67(0:"= (0')(%"%0E"/0%12$(02$%034&67(08?'6-&:@ A

update all variables needed for solution

slide-51
SLIDE 51

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %=

56/0>2,?@/,5AAB,-@>C04D

!!"#$%&'()*'$("+$("*,$%-%. /0%12$(02$%0345$$, &67(08"/0%12$(02$%039"&:";"/<7*04&67(08"&:"= ,>)<17'04?'6-&8"&67(08"&>,:@ A !!"B0(+$(C"*$<3-%."1)(-%."*,$%-%. D-(')7,"/<7*0?"*$<345$$, &67(0:"= (0')(%"%0E"/0%12$(02$%034&67(08?'6-&:@ A

create a new copy

  • f the space

during cloning

slide-52
SLIDE 52

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< %=

  • >?@04A

Required during exploration

before starting to guess: make copy when guess is wrong: use copy discussed later

Copy constructor and copy function needed

copy constructor is specific to script updates (copies) variables in particular

slide-53
SLIDE 53

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< )"

  • =>?,-=412/762=/,@4A,-=>?,B74620=4

Always same structure Important!

must update the variables of a script!

slide-54
SLIDE 54

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< )#

56/0=2,>?/,5@@A,B/042,C74620?4

  • !!"#$%&'"()*+'%)&

,)%-".$%&'/,)%-0"1 ('-223)+' 44"*"44"('-225&-*6 7

slide-55
SLIDE 55

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< )!

57==3/>?,56/0@2

Variables

declare as members initialize in constructor update in copy constructor

Posting constraints Create branching Provide copy constructor and copy function

slide-56
SLIDE 56

!"#$%&'(!)*%+,-

slide-57
SLIDE 57

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< ))

=>3083?89,593/6.,@4A0491

Returning solutions one by one for script

!"#

depth-first search

$%$

branch-and-bound

&'()*+),-.!#

Interactive, visual search

/0()

slide-58
SLIDE 58

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< )&

=304,=92.>?@,A0/12,5>8720>4

  • !"# $%!"&!"# %'()*+),%'-+%'(./01+2

34"567'467"48-+$+9+"4:+34"567'467"48; <=3>34"567'467"48?+4&$1; 54@4#4+$; !A+&34"567'467"48-+B+9+4C"4D#&11+2 BE?F'!"#&1;+54@4#4+B; G '4#H'"+I; G

slide-59
SLIDE 59

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< )=

>304,>92.?@A,B0/12,5?8720?4

  • !"# $%!"&!"# %'()*+),%'-+%'(./01+2

34"567'467"48-+$+9+"4:+34"567'467"48; <=3>34"567'467"48?+4&$1; 54@4#4+$; !A+&34"567'467"48-+B+9+4C"4D#&11+2 BE?F'!"#&1;+54@4#4+B; G '4#H'"+I; G

create root space for search

slide-60
SLIDE 60

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< )=

>304,>92.?@A,B0/12,5?8720?4

  • !"# $%!"&!"# %'()*+),%'-+%'(./01+2

34"567'467"48-+$+9+"4:+34"567'467"48; <=3>34"567'467"48?+4&$1; 54@4#4+$; !A+&34"567'467"48-+B+9+4C"4D#&11+2 BE?F'!"#&1;+54@4#4+B; G '4#H'"+I; G

create search engine (takes clone of $)

slide-61
SLIDE 61

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< )=

>304,>92.?@A,B0/12,5?8720?4

  • !"# $%!"&!"# %'()*+),%'-+%'(./01+2

34"567'467"48-+$+9+"4:+34"567'467"48; <=3>34"567'467"48?+4&$1; 54@4#4+$; !A+&34"567'467"48-+B+9+4C"4D#&11+2 BE?F'!"#&1;+54@4#4+B; G '4#H'"+I; G

root space not any longer needed

slide-62
SLIDE 62

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< )=

>304,>92.?@A,B0/12,5?8720?4

  • !"# $%!"&!"# %'()*+),%'-+%'(./01+2

34"567'467"48-+$+9+"4:+34"567'467"48; <=3>34"567'467"48?+4&$1; 54@4#4+$; !A+&34"567'467"48-+B+9+4C"4D#&11+2 BE?F'!"#&1;+54@4#4+B; G '4#H'"+I; G

search first solution and print it

slide-63
SLIDE 63

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< &"

=304,=92.>?@,A88,5>8720>41

  • !"# $%!"&!"# %'()*+),%'-+%'(./01+2

34"567'467"48-+$+9+"4:+34"567'467"48; <=3>34"567'467"48?+4&$1; 54@4#4+$; :,!@4+&34"567'467"48-+A+9+4B"4C#&11+2 AD?E'!"#&1;+54@4#4+A; F '4#G'"+H; F

slide-64
SLIDE 64

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< &#

=96>?9,=012

A graphical tool for exploring the search tree

explore tree step by step tree can be scaled double-clicking node prints information: inspection search for next solution, all solutions

Best to play a little bit by yourself

hide and unhide failed subtrees

slide-65
SLIDE 65

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< &!

=304,>74620?4@,A012

!"#$%&'()*+($,'(-+"./0112 "#/ 34"#5"#/ 46+$7)$1468)46+9:;<)= >(#'?,6(?,#(@8)3)A)#(B)>(#'?,6(?,#(@C D"./EE'F.53<C '(%(/()3C 6(/&6#)GC H

slide-66
SLIDE 66

!"#$%&'())*#+,$

  • ./.0.10-2

34--.506.-7%8+("#$"9*%&'+:;$)7%38<7%=<> 21

slide-67
SLIDE 67

!"#$%&'()$*'+%&",-./

slide-68
SLIDE 68

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< &&

=9>04?9/@,5AABB

Find distinct digits for letters, such that

and !"#$% maximal

&$#' ( !"&) * !"#$%

slide-69
SLIDE 69

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< &=

56/0>2,?@/,5AABB

Similar, please try it yourself at home In the following, referred to by

!"#$%&'(%&#")

slide-70
SLIDE 70

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< &=

5>8?04@,5AABBC,D/E9/

Principle

  • for each solution found, constrain remaining search for better

solution

Implemented as additional method

!"#$%&'(!)"*(+),-$#&",.+),-$(/0&+12(34(5

  • 6

Argument 3 refers to so far best solution

  • nly take values from 3
  • never mix variables!

Invoked on object to be constrained

slide-71
SLIDE 71

!""#$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< &=

>/?9/,@A/,5BBCC

!"#$%&'(!)"*(+),-$#&",.+),-$(/0&+12(345(6 +),-$(/1,*7)-$7),182(4(9(

  • $&$"+3+&-$:+),-$(/1,*7)-$7),182;.345<

=,$>&# 1.'?@A5B(,.'?CA5B(D.'?EA5B().'?FA5B(8.'?GA5< =,$>&# 431.4H'?@A5B(43,.4H'?CA5B(43D.4H'?EA5B( 43).4H'?FA5B(438.4H'?GA5< ",$ D),18(9(.@IIIIJ43DH!&'.5K@IIIJ43)H!&'.5K@IIJ43,H!&'.5K @IJ431H!&'.5K438H!&'.55< 0)-$.J$L"-B(@IIIIJDK@IIIJ)K@IIJ,K@IJ1K8 ;(D),185< M

value of any next solution value of current best solution b

slide-72
SLIDE 72

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< &=

>304,>92.?@A,B88,5?8720?41

  • !"# $%!"&!"# %'()*+),%'-+%'(./01+2

34"5678#67"49-+$+:+"4;+34"5678#67"49< =>=?34"5678#67"49@+4&$1< 54A4#4+$< ;,!A4+&34"5678#67"49-+8+:+4B"4C#&11+2 8D@E'!"#&1<+54A4#4+8< F '4#G'"+H< F

slide-73
SLIDE 73

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< ="

>304,?74620@4A,B012

!"#$%&'()*+($,'(-+"./0112 "#/ 34"#5"#/ 46+$7)$1468)46+9:;<)= >(#'?,./?,#(@8)3)A)#(B)>(#'?,./?,#(@C D"./EEF4F53<C '(%(/()3C 6(/&6#)GC H

slide-74
SLIDE 74

!"#"$"%$!& '(!!")$*"!+,-./012034,56.7829+,'-:+,;:< =#

57>>3/?@,5A8B04C

Result-only search engines

  • !"#$%&'&

Interactive search engine

  • ()*+

Best solution search uses constrain-method for

posting constraint

Search engine independent of script and constrain-

method