1 Figaro Yet Another Constraint Programming Library Martin Henz, Ka Boon Ng National University of Singapore Tobias Müller Universität des Saarlandes.

Slides:



Advertisements
Similar presentations
The GDSE Framework A Meta-Tool for Automated Design Space Exploration Tripti Saxena Graduate Student Vanderbilt University 1.
Advertisements

A Program Transformation For Faster Goal-Directed Search Akash Lal, Shaz Qadeer Microsoft Research.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
Introduction. IC-Parc2 ECLiPSe Components Constraint Logic Programming system, consisting of  A runtime core Data-driven computation, backtracking, garbage.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
G53CLP Constraint Logic Programming Modeling CSPs – Case Study I Dr Rong Qu.
Dynamic Programming.
Dynamic Restarts Optimal Randomized Restart Policies with Observation Henry Kautz, Eric Horvitz, Yongshao Ruan, Carla Gomes and Bart Selman.
Garbage Collection CSCI 2720 Spring Static vs. Dynamic Allocation Early versions of Fortran –All memory was static C –Mix of static and dynamic.
© J. Christopher Beck Lecture 15: CP Search.
Factorial Recursion stack Binary Search Towers of Hanoi
Best-First Search: Agendas
CPSC 322, Lecture 13Slide 1 CSPs: Arc Consistency & Domain Splitting Computer Science cpsc322, Lecture 13 (Textbook Chpt 4.5,4.6) February, 01, 2010.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
CPSC 322, Lecture 13Slide 1 CSPs: Arc Consistency & Domain Splitting Computer Science cpsc322, Lecture 13 (Textbook Chpt 4.5,4.8) February, 02, 2009.
Computational Methods for Management and Economics Carla Gomes
Constraint Satisfaction Problems
A Hospital Placements Allocation Problem Stephen Cresswell and Lee McCluskey (paper to be presented at PlanSIG 2005)
Andreas Bauer, Viorica Botea, Mark Brown, Matt Gray, Daniel Harabor & John Slaney CP 2010, 522—536 Presented by Heath Roehr.
Another example p := &x; *p := 5 y := x + 1;. Another example p := &x; *p := 5 y := x + 1; x := 5; *p := 3 y := x + 1; ???
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
CS350/550 Software Engineering Lecture 1. Class Work The main part of the class is a practical software engineering project, in teams of 3-5 people There.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Solving problems by searching
1 Combinatorial Problems in Cooperative Control: Complexity and Scalability Carla Gomes and Bart Selman Cornell University Muri Meeting March 2002.
Knight’s Tour Distributed Problem Solving Knight’s Tour Yoav Kasorla Izhaq Shohat.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
Copyright R. Weber Search in Problem Solving Search in Problem Solving INFO 629 Dr. R. Weber.
Slide 1 CSPs: Arc Consistency & Domain Splitting Jim Little UBC CS 322 – Search 7 October 1, 2014 Textbook §
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Artificial Intelligence Lecture 9. Outline Search in State Space State Space Graphs Decision Trees Backtracking in Decision Trees.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.
Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
Motivation & Goal SAT and Constraint Processing (CP) are fundamental areas of Computer Science that address the same computational questions. Compare SAT.
© J. Christopher Beck Lecture 13: Modeling in Constraint Programming.
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
Contents of Chapter 7 Chapter 7 Backtracking 7.1 The General method
“Planning is bringing the future into the present so that you can do something about it now.” – Alan Lakein Thought for the Day.
Parallelizing MiniSat I-Ting Angelina Lee Justin Zhang May 05, Final Project Presentation.
CP Summer School Modelling for Constraint Programming Barbara Smith 4. Combining Viewpoints, Modelling Advice.
Applications of Dynamic Programming and Heuristics to the Traveling Salesman Problem ERIC SALMON & JOSEPH SEWELL.
Design Patterns Yonglei Tao. Design Patterns  A design pattern describes a recurring design problem, a solution, and the context in which that solution.
15.053Tuesday, April 9 Branch and Bound Handouts: Lecture Notes.
Conformant Probabilistic Planning via CSPs ICAPS-2003 Nathanael Hyafil & Fahiem Bacchus University of Toronto.
Automated Patch Generation Adapted from Tevfik Bultan’s Lecture.
Scheduling with Constraint Programming February 24/25, 2000.
Learning Symbolic Interfaces of Software Components Zvonimir Rakamarić.
Chapter 2) CSP solving-An overview Overview of CSP solving techniques: problem reduction, search and solution synthesis Analyses of the characteristics.
Problem Reduction So far we have considered search strategies for OR graph. In OR graph, several arcs indicate a variety of ways in which the original.
Dynamic Symmetry breaking with AI and Algebra. Iain McDonald Dynamic Symmetry breaking with AI and Algebra.
Spring, 2011 –– Computational Thinking – Dennis Kafura – CS 2984 Data Structures Mapping complex structures to linear memory.
1 2 2 Call The Project Dynamic-Memory 4 4 # include "Utilities.hpp" int main(int argc, char * argv[]) { short int *PtrNo; (*PtrNo) = 5; printf ("(*PtrNo)
Recursion ITI 1121 N. El Kadri. Reminders about recursion In your 1 st CS course (or its equivalent), you have seen how to use recursion to solve numerical.
CSE 2341 Object Oriented Programming with C++ Note Set #4
Windows Programming Lecture 03. Pointers and Arrays.
Ning Jin, Wei Wang ICDE 2011 LTS: Discriminative Subgraph Mining by Learning from Search History.
Scheduling with Constraint Programming
CSC Modeling with FD Constraints
Computer Science cpsc322, Lecture 13
Computer Science cpsc322, Lecture 13
Depth-First Searches Introduction to AI.
Constraints and Search
A QUICK START TO OPL IBM ILOG OPL V6.3 > Starting Kit >
Presented By: Darlene Banta
Programming Languages and Paradigms
Depth-First Searches.
Presentation transcript:

1 Figaro Yet Another Constraint Programming Library Martin Henz, Ka Boon Ng National University of Singapore Tobias Müller Universität des Saarlandes

2 Finite Domain Constraint Programming A technique for solving combinatorial search and optimization problems.

3 S E N D + M O R E = M O N E Y

4 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y Modeling

5 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y S  N E  N N  N D  N M  N O  N R  N Y  N

6 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y S  {0..9} E  {0..9} N  {0..9} D  {0..9} M  {0..9} O  {0..9} R  {0..9} Y  {0..9} Propagate

7 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y S  {1..9} E  {0..9} N  {0..9} D  {0..9} M  {1..9} O  {0..9} R  {0..9} Y  {0..9} Propagate

8 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} Propagate

9 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 Labeling

10 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 Propagate

11 S E N D + M O R E = M O N E Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 Labeling S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 5 E  5 S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8}

12 S E N D + M O R E = M O N E Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 Propagate S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1} O  {0} R  {8} Y  {2}

13 S E N D + M O R E = M O N E Y Complete Search Tree S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1} O  {0} R  {8} Y  {2} E = 6 E  6

14 Is That All? Complex symbolic constraints Programmable search Trailing vs copying Design patterns for constraint programming Integration of other search techniques S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1}... S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1}... E = 4 E  4 S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1}... E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1}.. E = 6 E  6

15 FD(CP) Languages and Libraries Languages –CLP(FD) –Eclipse, CHIP –CLAIRE new language –Oznew language Libraries –PECOSLISP –Ilog SolverC++ –FigaroC++, under development Prolog based

16 Design Issues Languages –CLP(FD) –Eclipse, CHIP –CLAIRE –Oz Libraries –PECOS –Ilog Solver Syntax Integration with application programming Programming propagation algorithms Programming search strategies Programming search algorithms

17 Representing the Constraint Store class store { public: store(); var newvar(int lo, int hi); var getlo(var v); var gethi(var v);... }

18 Representing the Constraint Store class store { public: store(); var newvar(int lo, int hi); var getlo(var v); var gethi(var v);... } int main(...) { store*st=new store();...}

19 Representing the Constraint Store class store { public: store(); var newvar(int lo, int hi); var getlo(var v); var gethi(var v);... } int main(...) { store*st=new store(); s = st -> newvar(0,9);... y = st -> newvar(0,9);...}

20 Representing the Constraint Store class store { public: store(); var newvar(int lo, int hi); var getlo(var v); var gethi(var v);... } int main(...) { store*st=new store(); s = st -> newvar(0,9);... y = st -> newvar(0,9); all_different(st, s,..,y);...}

21 Representing Search Trees class node { public: virtual node* child(store *,int)=0; } S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1}... S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1}... E = 4 E  4 S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1}... E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1}.. E = 6 E  6

22 Representing Search Trees class naive : public node { private: int idx;vector vars;node*subtree; public : naive(vector vs,int i,node*t) :... {} node* child(store*st, int i) { if (i==0) { st->tell(vars[idx],st->getlo(vars[idx])); return (idx+1==var.size() ? subtree : new naive(vars,idx+1,subtree)); } else { st->tell(vars[idx],st->getlo(vars[idx])+1, st->gethi(vars[idx])); return new naive(vars,idx,subtree); }}};

23 Backtracking mark store::mark(); void store::backtrack(mark m); S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1}... S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1}... E = 4 E  4 S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1}... E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1}.. E = 6 E  6

24 Depth-first Search (backtracking) node * solve_one(store * s,node * t) { if (t == NULL) return t; mark m = s->mark(); try {return solve_one(s,t->child(s,0));} catch (Failure) { s->backtrack(m); return solve_one(s,t->child(s,1)); }

25 Stepping Back Nothing new so far; Oz has programmable search algorithms through spaces (Schulte, ICLP’97); Ilog Solver has IlcManager objects. But: –“lean” stores –nodes as an abstraction for programming search strategies more on the basic data structures in the proceedings moving on: Trailing vs. Copying (Schulte, ICLP’99)

26 Trailing vs Copying Trail and backtrack Copy and abandon S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1}... S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1}... E = 4 E  4 S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1}... E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1}.. E = 6 E  6

27 Copying Stores Simply copy the store with all variables and constraints: store::store(const store*); But: nodes refer to variables; their addresses change!

28 Labeling Refers to Variables class naive : public node { private: int idx;vector vars;node*subtree; public : naive(vector vs,int i,node*t) :... {} node* child(store*st, int i) { if (i==0) { st->tell(vars[idx],st->getlo(vars[idx])); return (idx+1==vars.size() ? subtree : new naive(vars,idx+1,subtree)); } else { st->tell(vars[idx],st->getlo(vars[idx])+1, st->gethi(vars[idx])); return new naive(vars,idx,subtree); }}};

29 Search Refers to Marks node * solve_one(store * s,node * t) { if (t == NULL) return t; mark m = s->mark(); try {return solve_one(s,t->child(s,0));} catch (Failure) { s->backtrack(m); return solve_one(s,t->child(s,1)); }

30 Indirect Addressing only use indices in arrays to address variables, propagators and marks Now nodes don’t need to care, whether they work on original or copy varspropstrail store

31 Depth-first Search (copying) node * solve_one(store * s,node * t) { if (t == NULL) return t; store s2 = new store(s); try {return solve_one(s,t->child(s,0));} catch (Failure) { return solve_one(s2,t->child(s,1)); }

32 Stepping Back Indirect addressing allows copy and trailing- based search Possibly interesting combinations of the two to be explored Moving on: Memory policy just one dimension in the “design space” for search algorithms.

33 Dimensions in the Design Space for Search Algorithms Exploration: depth-first search, limited- discrepancy search,... Memory policy: copying, trailing,... Optimization: branch-and-bound, restart optimization,... Interaction: first, last, all solution search, tracing,... Visualization: “Oz Explorer” like search tree visualization

34 STK: Software Engineering of Inference Engines STK originally developed for Oz Allows to separate design dimensions into modules Software architecture ensures reusability of components STK ideas will be at the heart of Figaro

35 Example: Exploration and Interaction Exploration is defined by a class that extends the abstract class exploration. class exploration { public: virtual node * one_step()=0; }

36 Example: Exploration and Interaction Exploration is defined by a class that extends the abstract class exploration. class exploration { public: virtual node * one_step()=0; } Interaction calls one_step according to the desired mode of interaction. node * first(exploration * e) { node * n; while (n = e->one_step()) if (n==success_node) break; return n; }

37 Stepping Back Design patterns for tree search More in paper: A Search Toolkit for Constraint Programming (PADL’00) Moving on: Constraint programming is just one technique: local search?

38 Global Search v 1  v 2,v 1  v 2,v 1  v 2 FF FT TF TT F? ?T T? ?F ??

39 Global Search v 1  v 2,v 1  v 2,v 1  v 2 FF FT TF TT F? ?T T? ?F ?? v 1 =F v 1 =T

40 Global Search v 1  v 2,v 1  v 2,v 1  v 2 FF FT TF TT F? ?T T? ?F ?? v 1 =F v 1 =T v 2 =F v 2 =T

41 Global Search v 1  v 2,v 1  v 2,v 1  v 2 FF FT TF TT F? ?T T? ?F ?? v 1 =F v 1 =T v 2 =F v 2 =T v 2 =F v 2 =T solution Search Tree

42 Local Search v 1  v 2,v 1  v 2,v 1  v 2 FF FT TF TT F? ?T T? ?F ?? v 1 =F v 1 =T v 2 =F v 2 =T v 2 =F v 2 =T solution consider only full assignments of variables to values

43 Local Search FF FT TF TT Search Space v 1  v 2,v 1  v 2,v 1  v 2

44 Local Search v 1  v 2,v 1  v 2,v 1  v 2 FF FT TF TT initial assignment neighborhood

45 Local Search local move FF FT TF TT v 1  v 2,v 1  v 2,v 1  v 2

46 Local Search v 1  v 2,v 1  v 2,v 1  v 2 local move FF FT TF TT

47 Local Search v 1  v 2,v 1  v 2,v 1  v 2 solution found FF FT TF TT

48 Observations Data structures needed for constraint programming are the same as in local search. Integration of CP and LS has been approached before. –Stephen Won, MS thesis supervised by Jimmy Lee (1997)

49 Stepping Back (for good) Viewing constraint programming as a collection of design patterns. Flexible memory policy through indirect addressing Figaro initiative: –library for discrete problem solving and optimization –local search and constraint programming (LP,IP?) –designed by researchers for researchers –open source, current contributors: N U Singapore, partners: CUHK, PSL

50 Figaro (very last slide) Figaro, an offspring of Mozart F I nite domain GA dget for combinatorial p RO blem solving