Intelligence Artificial Intelligence Ian Gent Practical 2: Forward Checking.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Addition Facts
Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab.
Chapter 7. Binary Search Trees
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
Constraint Satisfaction Patrick Prosser. An Example, Exam Timetabling Someone timetables the exams We have a number of courses to examine how many? Dept.
1 The tiling algorithm Learning in feedforward layered networks: the tiling algorithm writed by Marc M é zard and Jean-Pierre Nadal.
Heuristic Search techniques
Pointers and Data Structures 1 Yinzhi Cao Modified from slides made by Prof Goce Trajcevski.
Singly Linked Lists What is a singly-linked list? Why linked lists?
David Luebke 1 6/7/2014 ITCS 6114 Skip Lists Hashing.
Data Structures ADT List
Arrays Dr. Jey Veerasamy July 31 st – August 23 rd 9:30 am to 12 noon 1.
1 Designing Hash Tables Sections 5.3, 5.4, Designing a hash table 1.Hash function: establishing a key with an indexed location in a hash table.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Hash Tables,
Intelligence Artificial Intelligence Ian Gent Search: 2.
Backward Checking Search BT, BM, BJ, CBJ. An example problem Colour each of the 5 nodes, such that if they are adjacent, they take different colours 12.
Intelligence Artificial Intelligence Ian Gent Search: 1.
Intelligence Artificial Intelligence Ian Gent Constraint Programming 1.
Addition 1’s to 20.
Fc. Consider the following problem (csp5) variables V[1] to V[10] uniform domains D[1] to D[10] = {1,2,3} constraints V[1] = V[4] V[4] > V[7] V[7] = V[10]
Week 1.
Dantzig-Wolfe Decomposition
Local Search Jim Little UBC CS 322 – CSP October 3, 2014 Textbook §4.8
CPSC 322, Lecture 14Slide 1 Local Search Computer Science cpsc322, Lecture 14 (Textbook Chpt 4.8) Oct, 5, 2012.
Introduction to Recursion and Recursive Algorithms
Order of Operations And Real Number Operations
Lecture Roger Sutton CO331 Visual Programming 13: Multi-dimensional Arrays 1.
1 Today’s class Interleaving backtracking and consistency checking Variable-ordering heuristics Value-ordering heuristics Intelligent backtracking Marie.
Backward Checking Search BT, BM, BJ, CBJ. An example problem Colour each of the 5 nodes, such that if they are adjacent, they take different colours.
Distributed Constraint Satisfaction Problems M OHSEN A FSHARCHI.
1 Review Lecture: Guide to the SSSII Assignment Gwilym Pryce 5 th March 2006.
Constraint Satisfaction Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
This lecture topic (two lectures) Chapter 6.1 – 6.4, except 6.3.3
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Recursion vs. Iteration The original Lisp language was truly a functional language: –Everything was expressed as functions –No local variables –No iteration.
Intelligence Artificial Intelligence Ian Gent Constraint Programming 2.
Constraint Processing Techniques for Improving Join Computation: A Proof of Concept Anagh Lal & Berthe Y. Choueiry Constraint Systems Laboratory Department.
Foundations of Constraint Processing, Spring 2008 Evaluation to BT SearchApril 16, Foundations of Constraint Processing CSCE421/821, Spring 2008:
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Foundations of Constraint Processing Evaluation to BT Search 1 Foundations of Constraint Processing CSCE421/821, Spring
Constraint Satisfaction Problems
Register Allocation and Spilling via Graph Coloring G. J. Chaitin IBM Research, 1982.
I am Patrick Prosser I am a senior lecturer at Glasgow (and Strathclyde till mid April) I teach algorithms & data structures in java I am a member of.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
1 CS B551: Elements of Artificial Intelligence Instructor: Kris Hauser
Edge and Boundary interpretation Consistent line drawing labeling via backtracking Presented by Guy Shtub.
Chapter 5 Constraint Satisfaction Problems
An Introduction to Artificial Intelligence Lecture 5: Constraint Satisfaction Problems Ramin Halavati In which we see how treating.
Arc Consistency CPSC 322 – CSP 3 Textbook § 4.5 February 2, 2011.
CS 171: Intro to AI Discussion Week 2 Jan 15 th 2016.
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Computer Science cpsc322, Lecture 13
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Constraint Satisfaction
Empirical Comparison of Preprocessing and Lookahead Techniques for Binary Constraint Satisfaction Problems Zheying Jane Yang & Berthe Y. Choueiry Constraint.
CS B551: Elements of Artificial Intelligence
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Computer Science cpsc322, Lecture 13
Algorithms (2IL15) – Lecture 2
Evaluation of (Deterministic) BT Search Algorithms
Artificial Intelligence
Constraints and Search
Evaluation of (Deterministic) BT Search Algorithms
at Glasgow (and Strathclyde till mid April)
Artificial Intelligence
Evaluation of (Deterministic) BT Search Algorithms
CS 8520: Artificial Intelligence
Presentation transcript:

Intelligence Artificial Intelligence Ian Gent Practical 2: Forward Checking

Intelligence Artificial Intelligence Part I :Overview Part II: Three ways to implement FC Part III: Other parts of the practical Part IV: What I’m looking for Practical 2: Forward Checking

3 zWrite a program to implement the two algorithms BT (Backtracking) and FC (Forward Checking.) Perform an empirical comparison of the two algorithms. zSome practical stuff: yThis is practical 2 of 2. yEach will carry equal weight, I.e. 10% of total credit yYou may use any implementation language you wish yDeadline(s) are negotiable (can be decided after vacation)

4 Aims and Objectives zAims: yto give experience in implementing important AI search algorithms yto give experience in comparing AI techniques empirically zObjectives: yafter completing the practical, you should have: ximplemented the algorithms BT and FC xgained an appreciation of some of the basic techniques necessary xperformed and reported on an empirical comparison of different algorithms

5 What you need to do zImplement BT and FC for binary CSP’s yif you can do FC you can do BT yFC is the hard bit yimplement at least two (static) heuristics for each zImplement a reader to read in benchmark CSP’s yformat of problems will be provided yuse benchmarks for testing zPerform empirical comparison of algorithms yrun on benchmark problems yreport on comparative success of algorithm/heuristic combinations

6 What you can get away with zImplement BT binary CSP’s yimplement at least one heuristics zImplement a reader to read in benchmark CSP’s yformat of problems will be provided yuse benchmarks for testing zPerform empirical comparison of algorithms yrun on benchmark problems yreport on success or otherwise zDon’t expect too many marks for doing the above ybut don’t expect zero either

7 Three Ways to Implement FC zYou only need one implementation! zChoose the style that suits you and the language you like using zThree ways are: yusing the general search algorithm yrecursive yfrom pseudocode using specific data structures

8 Implementing FC (1) zYou can implement FC using the generic search algorithm presented earlier zSearch states = some representation of current assignment of values to variables, and current domains for each variable zForward checking done when new states created zDo search by depth-first zMain problem is memory management ynot letting space expand endlessly/overwriting existing states yeasier if you’ve got GC built in zAppropriate for languages with non destructive data structures (e.g. Lisp, Haskell)

9 FC via general search algorithm z1. Form a one element list with null state null state = state with no decisions = original CSP z2. Loop Until (either list empty or we have a solution) yRemove the first state S from the list yChoose the next decision to make which variable x to assign next yCreate a new state for each possible choice of decision decisions are all remaining values v in D x to create each new state, assign x=v and forward check yMERGE the set of new states into the list z3. If (solution in list) succeed and report solution y else list must be empty, so fail

10 Implementing FC (2) zFunctional languages are good for search ye.g. Lisp, Haskell zWrite propagator for forward checking which makes non destructive changes. yI.e. original state still exists, but we get a new one for free yGC done for you zWrite search function recursively yhandles the manipulation of the list for you via the function calling stack

11 Implementing FC (2) zSearch (CSP): ychoose var ywhile (value remains in CD var ) xCall Search( fc-propagate(CSP[var = value])) xIf call succeeds with solution, return solution yIf all calls failed, return failure

12 Implementing FC(3) zFollow implementation outlined by Prosser zAvoids most memory management problems zExplicit data structures initially set up ywhen we remove values from v i to v j we modify them yreductions[j] contains sequence of sequence xeach one a sequence of values disallowed by past var ypast-fc[j] is a set of variables xset of variables i which caused value removals from v j yfuture-fc[i] is another set xset of variables in which the current value of v i causes value removals

13 General pseudocode for bcssp zProcedure bccsp (n, status) yconsistent := true, status := unknown, ii := 1 ywhile (status = unknown) xif (consistent) ii := label(ii,consistent) –need special purpose function fc-label here else ii := unlabel(ii,consistent) –and fc-unlabel here xif (ii > n) status := solution else if (ii = 0) –status := impossible

14 Implementing FC(3.2) zUse data structure suggested by Bacchus/van Run zHave a 2D array Domain[ii,k] yfirst dimension is variables, second dimension values yDomain[ii,k] = 0 if value k still possible for variable ii xI.e. if k still belongs to CD[ii] yIf value k impossible, removed from CD[ii] xDomain[ii,k] = j, where j is variable that caused removal zOn backtracking, to undo effect of assigning j yif Domain[ii,k] = j, reset it so that Domain[ii,k] = 0 yeither store all changes made by j, or just iterate over 2D array looking for those equal to j ywhen we remove values from v i to v j we modify them yreductions[j] contains sequence of sequence xeach one a sequence of values disallowed by past var ypast-fc[j] is a set of variables xset of variables i which caused value removals from v j yfuture-fc[i] is another set xset of variables in which the current value of v i causes value removals

15 Other parts of the practical zInput format: ythe APES group has a standard format for sharing binary CSP’s. yAllows sharing of benchmarks yValuable for testing (all programs should give same results) zWrite a reader for this format ytranslate input to your internal format for CSP xyour representation of variables, domains, constraints ycreate small test problems for yourself xand if you want, share them for others

16 Heuristics zI am only looking for static variable ordering heuristics yimplement dynamic ones if you wish yheuristics are harder in Prosser’s version xsee paper by Bacchus & van Run for pointers zHeuristics you might consider ylexicographic, v1, v2, v3… yrandom, v17, v16, v2, v19 … ymin degree: var involved in least constraints first ymax degree: var involved in most constraints first yother heuristics you find/can think of

17 Empirical Report zRun your program(s) against benchmark instances I will provide, and others you might want to try zFrom empirical evidence, how do the techniques perform? yIs FC better than BT? Worse? varies across problems? yAre there some problems that you can’t solve in reasonable cpu time? yIs min degree better than max degree? yAre some problems harder than others?

18 Empirical Report zWrite a report on your experiments zDescribe the purpose of each experiment, the results, and conclusions you draw zTry to make it a good piece of empirical AI! zInclude results as e.g. tables or graphs yas appendix if too many results zProbably a few pages

19 What I am looking for zA correct functioning program yspeed is not important (within reason) yshould implement at least 4 combinations of algorithm/heuristic zA report summarising program and empirical work yno set word limit, probably needs a few pages to present good empirical work well yevidence that your code is correct xe.g. sample output, correct result on benchmarks yconclusions on your empirical result ycode (electronically if it’s HUGE)

20 Additional Issues zSome ways to get more credit … ycreate/find problems for which usually worse algorithm/heuristic does better ythink of different heuristics ythink of interesting hypotheses and test them yimplement FC so that propagation causes a chain reaction. xI.e. if you get domain size = 1, redo FC from there xSince I’ve asked for static heuristics, we may search on variable x, domain size 4, when variable y has d.s. = 1 yimplement dynamic variable ordering heuristics

21 Some pointers zA tutorial on constraint programming yBarbara Smith yLeeds University, 1995 zHybrid Algorithms for the Constraint Satisfaction Problem yPatrick Prosser yComputational Intelligence, 1993 zDynamic Variable Ordering in CSPs yBacchus & van Run yCP95, 1995