An Introduction to Constraint Programming in JChoco.

Slides:



Advertisements
Similar presentations
Examples for Discrete Constraint Programming
Advertisements

Maximal Independent Sets of a Hypergraph IJCAI01.
PROLOG MORE PROBLEMS.
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
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.
CP2014: Teaching CP. Context Final Year 120 credits (1 credit approx 10 hours) 30 credit project 4 modules in semester 1 4 modules in semester 2.
Albrecht Dürer And his magic square. On the wall to the right hangs the magic square Dürer created.
Mathematics. Matrices and Determinants-1 Session.
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
Elementary Linear Algebra
1 Constraint Programming: An Introduction Adapted by Cristian OLIVA from Peter Stuckey (1998) Ho Chi Minh City.
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Review for Chapter 4 Important Terms, Symbols, Concepts 4.1. Systems of Linear Equations in Two Variables.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
A simple assessed exercise Ciaran McCreesh & Patrick Prosser + 21.
Chapter 4 Matrices By: Matt Raimondi.
Lesson 13-1: Matrices & Systems Objective: Students will: State the dimensions of a matrix Solve systems using matrices.
© J. Christopher Beck Lecture 13: Modeling in Constraint Programming.
Constraint Satisfaction Basics strongly influenced by Rina Dechter, “Constraint Processing”, 2003.
2D-Arrays Quratulain. Learning Objectives Two-dimensional arrays Declaration Initialization Applications.
Magic square An example of how to represent a problem An idea from Chris Beck.
CP Summer School Modelling for Constraint Programming Barbara Smith 4. Combining Viewpoints, Modelling Advice.
Data Structure CS 322. What is an array? Initializing arrays Accessing the values of an array Multidimensional arrays LAB#1 : Arrays.
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
SRINIVASA RAMANUJAN AND HIS MAGIC SQUARE.
Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers.
Section 9-1 An Introduction to Matrices Objective: To perform scalar multiplication on a matrix. To solve matrices for variables. To solve problems using.
Car Sequencing Problem Assessed exercise 2 15% 26/11/2010.
Arrays and variables 1.Representing tables as arrays in MATLAB 2.Concept of array dimension 3.Correspondence of array dimension to rows and columns 4.Picking.
Introduction Types of Matrices Operations
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays Outline 1 Introduction 2 Arrays 3Declaring Arrays 4Processing Array Contents 5 Multiple-Subscripted.
LESSON 8: INTRODUCTION TO ARRAYS. Lesson 8: Introduction To Arrays Objectives: Write programs that handle collections of similar items. Declare array.
CS162 Week 5 Kyle Dewey.
Computer Science 210 Computer Organization
CSC5240 Combinatorial Search and Optimization with Constraints
Constraint Satisfaction Problem
CSC 142 Computer Science II
Lesson 4.2 Adding and Subtracting Decimals
Lesson 4.2 Adding and Subtracting Decimals
Adding and Subtracting Decimals
Eight-QueenS Problem: Fuzzy Constraint Satisfaction Problem Using Soar
Adding and Subtracting Decimals
Multiplying Matrices.
Objective: Today we will investigate the ‘magic’ in magic squares.
Chapter 3: Finite Constraint Domains
How to complete a ‘Diamond 9’ exercise
Lesson 35 Adding and Subtracting Decimals
Albrecht Dürer And his magic square.
Magic Squares   10   X.
Number partitioning.
Constraints and Search
Albrecht Dürer And his magic square.
Adding and Subtracting Decimals
An example of how to represent a problem
Adding and Subtracting Decimals
© T Madas.
Magical Hexagons (Teachers notes):
Albrecht Dürer And his magic square.
Constraint Satisfaction Problems
Adding and Subtracting Decimals
Lesson 37 Adding and Subtracting Decimals
Constraint Satisfaction Problems (CSP)
Albrecht Dürer And his magic square.
Presentation transcript:

An Introduction to Constraint Programming in JChoco

Constraint satisfaction Constraint satisfaction problem (CSP) is a triple where: –V is set of variables –Each X in V has set of values, D_X Usually assume finite domain {true,false}, {red,blue,green}, [0,10], … –C is set of constraints Goal: find assignment of values to variables to satisfy all the constraints

Di = {1,2,3,4,5} V1 V3 V2 V4 V4  V3 V1  V4  1 V4 + V2 = 5 V1  V2 V2  V3  6 AR33 figure 18, page 35 What can you infer?

Di = {1,2,3,4,5} V1 V3 V2 V4 V4  V3 V1  V4  1 V4 + V2 = 5 V1  V2 V2  V3  6 D1 = {1,2} D2 = {2,3} D3 = {4,5} D4 = {2,3} Do you agree? Was that easy?

A program that models csp6

With print statements and search

Packages used

Can throw an exception

Create a problem

Create variables

Post constraints

Establish AC

Magic code to get all solutions

Code to count solutions

output/trace Problem with no V or C

variables

Variables and constraints

Made AC

All solutions

2 colour K 3 The difference allDifferent makes Just how weak/powerful is AC processing?

Prop0.java Run it Make it AC

allDifferent Prop1.java Run it

X + Y + Z = 20 X,Y,Z  {1..10} See Test.java How many solutions? AF2 assessed exercise One of 5 questions

Test.java Count number of solutions

As a decision problem: is there a glomb ruler with n ticks with length no more than m units?

How many n digit numbers are there where the number must contain at least 0ne number 3 and at least one number 5? n = … See ThreesAndFives.java AF2 assessed exercise

Magic square An example of how to represent a problem An idea from Chris Beck

put a number in each square each number is different a number is in the range 1 to 16 the sum of a column is the same as a sum of a row the same as the sum of a main diagonal

put a number in each square each number is different a number is in the range 1 to 16 the sum of a column is the same as a sum of a row the same as the sum of a main diagonal 1st stab Use sum(x) = sum(y) where x and y are - different rows - different columns - different diagonals Every element of the array is different - represent as a clique of not equals How does it go? For propagation and search?

put a number in each square each number is different a number is in the range 1 to 16 the sum of a column is the same as a sum of a row the same as the sum of a main diagonal 2nd stab But what is k? How does model perform?

Magic square on the web

Thanks to Chris Beck

Thanks to Bouygues