Alan M. Frisch Ian Miguel Joint work with Matt Grum, Chris Jefferson & Bernadette Martinez Hernandez The Rules of Modelling Automatic Generation of Constraint.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

CommUnity, Tiles and Connectors joint work with Roberto Bruni José Luiz Fiadeiro Antónia Lopes Ugo Montanari Ivan Lanese Dipartimento di Informatica Università.
1 CMSC 471 Fall 2002 Class #6 – Wednesday, September 18.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Section 4.1: The Basics of Counting As we have seen, one way to count the number of objects in a finite set S is to produce a one-to-one correspondence.
Leeds: 6 June 02Constraint Technology for the Masses Alan M. Frisch Artificial Intelligence Group Department of Computer Science University of York Collaborators:
Section 7.4: Closures of Relations Let R be a relation on a set A. We have talked about 6 properties that a relation on a set may or may not possess: reflexive,
© 2005 Prentice Hall6-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
1.2 Row Reduction and Echelon Forms
Linear Equations in Linear Algebra
Transforming and Refining Abstract Constraint Specifications Alan Frisch, Brahim Hnich*, Ian Miguel, Barbara Smith, and Toby Walsh *Cork Constraint Computation.
Maths of Constraint Satisfaction, Oxford, March 2006 Constraint Programming Models for Graceful Graphs Barbara Smith.
Symmetry as a Prelude to Implied Constraints Alan Frisch, Ian Miguel, Toby Walsh University of York.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Alan M. Frisch Artificial Intelligence Group Department of Computer Science University of York Extending the Reach of Constraint Technology through Reformulation.
CGRASS A System for Transforming Constraint Satisfaction Problems Alan Frisch, Ian Miguel AI Group University of York Toby Walsh 4C.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University.
Alan M. Frisch Artificial Intelligence Group Department of Computer Science University of York Co-authors Ian Miguel, Toby Walsh, Pierre Flener, Brahim.
CGRASS A System for Transforming Constraint Satisfaction Problems Alan Frisch, Ian Miguel (York) Toby Walsh (Cork)
Fundamental Techniques
Describing Syntax and Semantics
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)
Modelling a Steel Mill Slab Design Problem Alan Frisch, Ian Miguel, Toby Walsh AI Group University of York.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
An Information Theory based Modeling of DSMLs Zekai Demirezen 1, Barrett Bryant 1, Murat M. Tanik 2 1 Department of Computer and Information Sciences,
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
A Z Approach in Validating ORA-SS Data Models Scott Uk-Jin Lee Jing Sun Gillian Dobbie Yuan Fang Li.
Empirical Explorations with The Logical Theory Machine: A Case Study in Heuristics by Allen Newell, J. C. Shaw, & H. A. Simon by Allen Newell, J. C. Shaw,
Symmetry Breaking Ordering Constraints Zeynep Kiziltan Department of Information Science Uppsala University, Sweden A progress.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
Section 1.8. Section Summary Proof by Cases Existence Proofs Constructive Nonconstructive Disproof by Counterexample Nonexistence Proofs Uniqueness Proofs.
Introduction to Job Shop Scheduling Problem Qianjun Xu Oct. 30, 2001.
1 1.3 © 2012 Pearson Education, Inc. Linear Equations in Linear Algebra VECTOR EQUATIONS.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
© J. Christopher Beck Lecture 13: Modeling in Constraint Programming.
Temperature Readings The equation to convert the temperature from degrees Fahrenheit to degrees Celsius is: c(x) = (x - 32) The equation to convert the.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
CP Summer School Modelling for Constraint Programming Barbara Smith 4. Combining Viewpoints, Modelling Advice.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Copyright © Cengage Learning. All rights reserved.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Mathematical Preliminaries
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
NP-Complete problems.
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
System To Generate Test Data: The Analysis Program Syed Nabeel.
Roman Barták (Charles University in Prague, Czech Republic) ACAT 2010.
Interface specifications At the core of each Larch interface language is a model of the state manipulated by the associated programming language. Each.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
CS5205: Foundation in Programming Languages Type Reconstruction
Lecture 7: Constrained Conditional Models
Functions of Complex Variable and Integral Transforms
Introduction to Logic for Artificial Intelligence Lecture 2
VCU, Department of Computer Science CMSC 302 Sequences and Summations Vojislav Kecman 9/19/2018.
CS 188: Artificial Intelligence
Linear Equations in Linear Algebra
Linear Equations in Linear Algebra
Artificial Intelligence
Background In his classic 1972 paper on definitional interpreters, John Reynolds introduced two key techniques: Continuation-passing style - Makes.
Generic SBDD using Computational Group Theory
CS 8520: Artificial Intelligence
Linear Equations in Linear Algebra
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

Alan M. Frisch Ian Miguel Joint work with Matt Grum, Chris Jefferson & Bernadette Martinez Hernandez The Rules of Modelling Automatic Generation of Constraint Programs through Refinement Artificial Intelligence Group Dept of Computer Science University of York School of Computer Science University of St Andrews

Allocating a Divisible Resource: An Application to Grid Computing Alan Frisch Artificial Intelligence Group Dept. Computer Science University of York 4pm, CS103

Modelling Bottleneck Useful for solving a wide range of important, complex problems including scheduling, allocation, layout, configuration,… Modelling a problem as a constraint program requires moderate/great expertise. Major barrier to widespread use of CP.

What are CP researchers doing? Model Generation: –Done in private. Model Selection: –Case studies –Some generalisations from analysis & experiments

Reducing the Modelling Bottleneck: Automated Modelling 2 to 3 years: We have been generating models more and more systematically. Embed systematic viewpoint in automated system (C ONJURE ). –Takes specification in high-level language (E SSENCE ). –Reformulates specification into a set of correct constraint programs. Ongoing: add heuristics for model selection.

Outline Reduced constraint programming. E SSENCE. C ONJURE. The big picture.

Part I Reduced Constraint Programming

What is Constraint Programming? Broad view: programming in which constraints play a central role. Narrow view: solve combinatorial (optimisation) problem by mapping it to a constraint satisfaction problem solving the constraint satisfaction problem mapping solution back to original problem

What is the (finite domain) CSP? An instance comprises: Finite set of variables Each associated with a finite domain Finite set of constraints on the values taken by the variables (Objective function) Solution is assignment of values to variables that satisfies the constraints (and optimises objective function)

Modelling: Just Do It! Find 3 distinct non-zero digits that sum to 9.

Just Do It! Find 3 distinct non-zero digits that sum to 9. Variables: X, Y, Z

Just Do It! Find 3 distinct non-zero digits that sum to 9. Variables/Domains: X, Y, Z::{1,..9}

Just Do It! Find 3 distinct non-zero digits that sum to 9. Variables/Domains: X, Y, Z::{1,..9} Constraints: X  Y, Y  Z, X  Z, X+Y+Z=9

Just Do It! Find 3 distinct non-zero digits that sum to 9. Variables/Domains: X, Y, Z :: {1..9} Constraints: X  Y, Y  Z, X  Z, X+Y+Z=9 X  Y  Z

Just Do It! Find 3 non-zero digits that sum to 9. Variables/Domains: X, Y, Z :: {1..9} Constraints: X  Y, Y  Z, X  Z, X+Y+Z=9 X  Y  Z X < Y < Z

Just Do It for a Problem Given n and s, find n distinct non-zero digits that sum to s.

Model: Explicit Representation Given n and s, find n distinct non-zero digits that sum to s. given find such that n:nat, s:nat X: matrix (indexed by 1.. n) of 1..9 ? 1 n X … … AllDiff(X)  i  1..n X[i] = s

Model: Occurrence Representation given find such that n:nat, s:nat D: matrix (indexed by 1..9) of 0..1 ? Given n and s, find n distinct non-zero digits that sum to s. 1 0/1 … 9 D 23 … D[1] + 2D[2] + … + 9D[9] = s D[1] + D[2] + … + D[9] = n

The SONET Problem Given nrings rings, nnodes nodes, a set of pairs of nodes (communication demand) and an integer capacity (of each ring). Install nodes on rings satisfying demand and capacity constraints. Minimise installations. nrings=2, nnodes=5, capacity = 4 demand: n 1 & n 3, n 1 & n 4, n 2 & n 3, n 2 & n 4, n 3 & n 5 Specification Instance Solution n2n2 n1n1 n3n3 n4n4 n5n5 n3n3

A Model of SONET Problem 0..1 Nodes Rings rings-nodes rings-nodes[r,n] = 1 iff node n is installed on ring r.

A Model of SONET Problem 0..1 Nodes Rings rings-nodes   c ScalarProduct > 0   c … Minimise:   rings-nodes[r,n] r  Rings n  Nodes

Part II Abstract Problem Specifications The E SSENCE Language

E SSENCE The language enables problems to be specified at a level of abstraction above that at which modelling decisions are made. This requires features not found in current constraint programming languages.

SONET Specification given letting given find minimising such that nrings:nat, nnodes:nat, capacity:nat Nodes be 1..nnodes demand: set of set (size 2) of Nodes rings: mset (size nrings) of set (maxsize capacity) of Nodes  r  rings.|r|  pair  demand.  r  rings. pair  r

E SSENCE Provides Abstract Types Sets, Multisets, Partitions, Range Types, Unnamed Types Functions, Relations, Enumerated Types, Sequences… given letting given find minimising such that nrings:nat, nnodes:nat, capacity:nat Nodes be 1..nnodes demand: set of set (size 2) of Nodes rings: mset (size nrings) of set (maxsize capacity) of Nodes  r  rings.|r|  pair  demand.  r  rings. pair  r Abstract types

E SSENCE Supports Arbitrarily-Nested Types given letting given find minimising such that nrings:nat, nnodes:nat, capacity:nat Nodes be 1..nnodes demand: set of set (size 2) of Nodes rings: mset (size nrings) of set (maxsize capacity) of Nodes  r  rings.|r|  pair  demand.  r  rings. pair  r Arbitrary nesting of types

E SSENCE Supports Quantification over Decision Variables given letting given find minimising such that nrings:nat, nnodes:nat, capacity:nat Nodes be 1..nnodes demand: set of set (size 2) of Nodes rings: mset (size nrings) of set (maxsize capacity) of Nodes  r  rings.|r|  pair  demand.  r  rings. pair  r Quantifying Over Decision Variables

How Usable is E SSENCE ? Specifications of ~50 problems found in the CSP literature written by an undergraduate with no background in constraint programming. URL:

E SSENCE ’ E SSENCE’ has a similar level of abstraction to existing constraint languages. E SSENCE ’ = E SSENCE - Abstract types Arbitrary nesting of types Quantifying Over Decision Variables

Model Generation: Informal Given n and s, find n distinct non-zero digits that sum to s. given find such that n:nat, s:nat X: matrix (indexed by 1.. n) of 1..9 AllDiff(X)  i  1..n X[i] = s given find such that n:nat, s:nat D: matrix (indexed by 1..9) of 0..1 D[1] + 2D[2] + … + 9D[9] = s D[1] + D[2] + … + D[9] = n ESSENCE’

given find n:nat, s:int X: set (size n) of 1..9  x = s x  X such that Formalisation of Model Generation given find such that n:nat, s:nat X: matrix (indexed by 1.. n) of 1..9 AllDiff(X)  i  1..n X[i] = s given find such that n:nat, s:nat D: matrix (indexed by 1..9) of 0..1 D[1] + 2D[2] + … + 9D[9] = s D[1] + D[2] + … + D[9] = n ESSENCE’

Part III Generating Models: The C ONJURE System

A Theory of Model Generation Must Account for Representing complex decision variables. SONET involves finding a multiset of sets. Exploiting channelling. Generate, maintain multiple representations. Identifying and breaking symmetries. X+Y+Z = c  X <= Y <= Z Performing transformations to improve efficiency. X<=Y<=Z, AllDiff(X,Y,Z)  X < Y < Z

C ONJURE C ONJURE automatically generates a set of alternative E SSENCE ’ models from E SSENCE specifications. Core: set of refinement rules. Refine an E SSENCE expression into a set of E SSENCE ’ expressions. Produce a set because often many alternative refinements of an E SSENCE expression.

Rules Must be Compositional Compositional refinement: Refinement of an expression is composed of the refinements of its sub-expressions. Necessary to handle: Unbounded nesting of constraints (usual) |A  (B  C) | < X Unbounded nesting of types (unique) set, set of sets, set of set of sets, …

Challenge: Compositionality is Difficult Complex variables: can have multiple refinements. Not all support all operations. Nested variables: refinement of outer type must be determined without looking arbitrarily deep into the nesting. Operators: refinement depends on refinement of operands. Operators: recursion needed to handle arbitrary nesting of operands, e.g. 

Refinement via  Operator Function mapping E SSENCE expression to a set of E SSENCE ’ expressions. Defined by set of equalities. One per syntactic construct. For easy presentation, each equation broken into clauses: RuleName 1  (e)  e 1 ’ RuleName 2  (e)  e 2 ’ … RuleName n  (e)  e n ’

Refining a Specification Refine constraints & objective function in turn. Compose results to form final model. Multiple refinements composed = multiple models. given letting find such that nnodes:nat, capacity:nat Nodes be 1..nnodes 4  ring MicroSonet: 4  ring : set (maxsize capacity) of Nodes ring : set (size capacity) of Nodes

Refining MicroSonet Refinement begins with  (4  ring): Relevant clause of Element rule refines both sides, composes the results. given letting find such that nnodes:nat, capacity:nat Nodes be 1..nnodes ring : set (size capacity) of Nodes 4  ring  (ring)  (4) = {4}  Compositionality at work

FixedSizeSet 1 : Occurrence Rep FixedSizeSet 1   (S: set (size n) of lb..ub )   = n such that sum(S’ ) = n { | } Generates a 1-d matrix, S’ Indexed by lb..ub 0/1 … S’ = genSym(S, matrix (indxd by lb..ub) of bool) S’S’ true Associate an axiom schema with this rule:  i  . i  S  S’ [i]

E SSENCE ’ Occ Model: MicroSonet given letting find such that nnodes:nat, capacity:nat Nodes be 1..nnodes ring’ : matrix (indexed by Nodes) of bool sum(ring’ ) = capacity ring’ [4]=1 0/1 …ring’ 123nnodes given letting find such that nnodes:nat, capacity:nat Nodes be 1..nnodes ring :set (size capacity) of Nodes 4  ring E SSENCE ’ E SSENCE

FixedSizeSet 2 : Explicit Rep FixedSizeSet 2  (S: set (size n) of  )  { } | S’ refined to give fully refined matrix S’’ S’’ S’’    (S’ ) S’’ : matrix (indexed by 1..n) of _ such that      (AllDiff(S’ )) All-different constraint refined, added to local model. AllDiff(S’ ) S’ = genSym(S, matrix (indexed by 1..n) of  ) Generates intermediate 1-d matrix, S’ : 1 n S’S’ 23  …    … Axiom schema:  i  . i  S   j  1..n (S’ [j]=i ) NB  could be arbitrarily complex

E SSENCE ’ Explicit Model: MicroSonet nnodes:nat, capacity:nat Nodes be 1..nnodes ring’:matrix (indexed by 1..capacity) of Nodes AllDifferent(ring’ ) ring’ [1] = 4 OR ring’ [2] = 4 OR… 1 Nodes capacity 2 ring’ Nodes … given letting find such that nnodes:nat, capacity:nat Nodes be 1..nnodes ring :set (size capacity) of Nodes 4  ring E SSENCE given letting find such that E SSENCE ’

Channelling Models Good constraint models often contain multiple representations of same abstract variable. Different constraints can often be stated most effectively on different representations. We use channelling constraints to maintain consistency between the representations. C ONJURE can generate these constraints automatically.

Automatically Generating Channelling Models S:set (size n) of  S 1 ’ :matrix (indxd by  ) of bool S 2 ’ :matrix (indxd by 1..n) of  (1)  i   (i  S  S 1 ’ [i]) (2)  i   (i  S   j  1..n (S 2 ’ [j]=i )) (1)(2) (3)  i   (S 1 ’ [i]   j  1..n (S 2 ’ [j]=i )) (3) FixedSizeSet 1 FixedSizeSet 2

(Some) Symmetry Detection is Free! Some refinements, whether manual or automatic, introduce symmetry. Some rule clauses introduce symmetry every time they are used. The clause can annotate the refined expression with a description of the symmetry. E.g. explicit representation of a set of 3 integers drawn from 1..n. 1..n 123 Have named the indices, where the set did not. Introduced index symmetry. 1..n

Part IV Conclusion: The Big Picture

What we Hope to Achieve Much of modelling can be formalised as refining E SSENCE to E SSENCE ’ Reduce modelling bottleneck with C ONJURE. Ongoing work: Develop heuristics to select among competing models.

E Why Might we Fail to Build a Competent Automatic Modeller? Can’t get compositionality to work. Some/much of modelling is involved in writing E SSENCE specs. M4M4 M3M3 E2E2 M2M2 M1M1 E1E1

Why Might we Fail to Build a Competent Automatic Modeller? Can’t get compositionality to work. Some/much of modelling is involved in writing E SSENCE specs. Failure to reach closure: –Endless list of new modelling steps to encapsulate in rules. General mathematical reasoning needed to perform transformations: –Adding implied constraints. –Obtaining rule applicability. –Obtaining more effective models.

Benefits other than Automation A more systematic approach to modelling. –We’ve noticed missing combinations. –Reveal gaps in understanding. Generalisation/Patterns. –See a technique used in generating one model and recognise its general usefulness. Pedagogical purposes. –Modelling almost absent from existing textbooks. E SSENCE could prove useful. We look at modelling differently. –Eventually, so will others.

E SSENCE specifications and C ONJURE paper: –