Artificial Intelligence

Slides:



Advertisements
Similar presentations
Heuristic Search techniques
Advertisements

Intelligence Artificial Intelligence Ian Gent Practical 2: Forward Checking.
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
Recursion vs. Iteration The original Lisp language was truly a functional language: –Everything was expressed as functions –No local variables –No iteration.
Best-First Search: Agendas
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
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 Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
Chapter 5 Constraint Satisfaction Problems
An Introduction to Artificial Intelligence Lecture 5: Constraint Satisfaction Problems Ramin Halavati In which we see how treating.
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.
1 Recursive algorithms Recursive solution: solve a smaller version of the problem and combine the smaller solutions. Example: to find the largest element.
1 CSC 384 Lecture Slides (c) , C. Boutilier and P. Poupart CSC384: Lecture 16  Last time Searching a Graphplan for a plan, and relaxed plan heuristics.
Recursion Version 1.0.
Knowledge Representation
Recursion Topic 5.
Integer Programming An integer linear program (ILP) is defined exactly as a linear program except that values of variables in a feasible solution have.
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
The Design and Analysis of Algorithms
Analysis of Algorithms
I am a senior lecturer at Glasgow
Computer Science cpsc322, Lecture 13
Data Structures and Algorithms
GC211Data Structure Lecture2 Sara Alhajjam.
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Constraint Satisfaction
13 Text Processing Hongfei Yan June 1, 2016.
Empirical Comparison of Preprocessing and Lookahead Techniques for Binary Constraint Satisfaction Problems Zheying Jane Yang & Berthe Y. Choueiry Constraint.
CS 188: Artificial Intelligence
Nondeterministic Evaluation
I am a senior lecturer at Glasgow
Some Basics for Problem Analysis and Solutions
CS B551: Elements of Artificial Intelligence
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Computer Science cpsc322, Lecture 13
Lesson 16: Functions with Return Values
Algorithms (2IL15) – Lecture 2
CSP Search Techniques Backtracking Forward checking
Coding Concepts (Basics)
Intelligent Backtracking Algorithms: A Theoretical Evaluation
Evaluation of (Deterministic) BT Search Algorithms
Artificial Intelligence
Artificial Intelligence
Constraints and Search
Evaluation of (Deterministic) BT Search Algorithms
Intelligent Backtracking Algorithms: A Theoretical Evaluation
Intelligent Backtracking Algorithms: A Theoretical Evaluation
at Glasgow (and Strathclyde till mid April)
Artificial Intelligence
Constraint satisfaction problems
Intelligent Backtracking Algorithms: A Theoretical Evaluation
Intelligent Backtracking Algorithms: A Theoretical Evaluation
Knowledge Representation
Data Structures & Algorithms
Evaluation of (Deterministic) BT Search Algorithms
Domain Splitting CPSC 322 – CSP 4 Textbook §4.6 February 4, 2011.
State-Space Searches.
Hashing.
State-Space Searches.
CS 8520: Artificial Intelligence
Intelligent Backtracking Algorithms: A Theoretical Evaluation
Implementation of Learning Systems
State-Space Searches.
Constraint satisfaction problems
Presentation transcript:

Artificial Intelligence Practical 2: Forward Checking Ian Gent ipg@cs.st-and.ac.uk

Artificial Intelligence Practical 2: Forward Checking 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 Write a program to implement the two algorithms BT (Backtracking) and FC (Forward Checking.) Perform an empirical comparison of the two algorithms. Some practical stuff: This is practical 2 of 2. Each will carry equal weight, I.e. 10% of total credit You may use any implementation language you wish Deadline(s) are negotiable (can be decided after vacation)

Aims and Objectives Aims: Objectives: to give experience in implementing important AI search algorithms to give experience in comparing AI techniques empirically Objectives: after completing the practical, you should have: implemented the algorithms BT and FC gained an appreciation of some of the basic techniques necessary performed and reported on an empirical comparison of different algorithms

What you need to do Implement BT and FC for binary CSP’s if you can do FC you can do BT FC is the hard bit implement at least two (static) heuristics for each Implement a reader to read in benchmark CSP’s format of problems will be provided use benchmarks for testing Perform empirical comparison of algorithms run on benchmark problems report on comparative success of algorithm/heuristic combinations

What you can get away with Implement BT binary CSP’s implement at least one heuristics Implement a reader to read in benchmark CSP’s format of problems will be provided use benchmarks for testing Perform empirical comparison of algorithms run on benchmark problems report on success or otherwise Don’t expect too many marks for doing the above but don’t expect zero either

Three Ways to Implement FC You only need one implementation! Choose the style that suits you and the language you like using Three ways are: using the general search algorithm recursive from pseudocode using specific data structures

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

FC via general search algorithm 1. Form a one element list with null state null state = state with no decisions = original CSP 2. Loop Until (either list empty or we have a solution) Remove the first state S from the list Choose the next decision to make which variable x to assign next Create a new state for each possible choice of decision decisions are all remaining values v in Dx to create each new state, assign x=v and forward check MERGE the set of new states into the list 3. If (solution in list) succeed and report solution else list must be empty, so fail

Implementing FC (2) Functional languages are good for search e.g. Lisp, Haskell Write propagator for forward checking which makes non destructive changes. I.e. original state still exists, but we get a new one for free GC done for you Write search function recursively handles the manipulation of the list for you via the function calling stack

Implementing FC (2) Search (CSP): choose var while (value remains in CDvar) Call Search( fc-propagate(CSP[var = value])) If call succeeds with solution, return solution If all calls failed, return failure

Implementing FC(3) Follow implementation outlined by Prosser Avoids most memory management problems Explicit data structures initially set up when we remove values from vi to vj we modify them reductions[j] contains sequence of sequence each one a sequence of values disallowed by past var past-fc[j] is a set of variables set of variables i which caused value removals from vj future-fc[i] is another set set of variables in which the current value of vi causes value removals

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

Implementing FC(3.2) Use data structure suggested by Bacchus/van Run Have a 2D array Domain[ii,k] first dimension is variables, second dimension values Domain[ii,k] = 0 if value k still possible for variable ii I.e. if k still belongs to CD[ii] If value k impossible, removed from CD[ii] Domain[ii,k] = j, where j is variable that caused removal On backtracking, to undo effect of assigning j if Domain[ii,k] = j, reset it so that Domain[ii,k] = 0 either store all changes made by j, or just iterate over 2D array looking for those equal to j when we remove values from vi to vj we modify them reductions[j] contains sequence of sequence each one a sequence of values disallowed by past var past-fc[j] is a set of variables set of variables i which caused value removals from vj future-fc[i] is another set set of variables in which the current value of vi causes value removals

Other parts of the practical Input format: the APES group has a standard format for sharing binary CSP’s. Allows sharing of benchmarks Valuable for testing (all programs should give same results) Write a reader for this format translate input to your internal format for CSP your representation of variables, domains, constraints create small test problems for yourself and if you want, share them for others

Heuristics I am only looking for static variable ordering heuristics implement dynamic ones if you wish heuristics are harder in Prosser’s version see paper by Bacchus & van Run for pointers Heuristics you might consider lexicographic, v1, v2, v3… random, v17, v16, v2, v19 … min degree: var involved in least constraints first max degree: var involved in most constraints first other heuristics you find/can think of

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

Empirical Report Write a report on your experiments Describe the purpose of each experiment, the results, and conclusions you draw Try to make it a good piece of empirical AI! Include results as e.g. tables or graphs as appendix if too many results Probably a few pages

What I am looking for A correct functioning program speed is not important (within reason) should implement at least 4 combinations of algorithm/heuristic A report summarising program and empirical work no set word limit, probably needs a few pages to present good empirical work well evidence that your code is correct e.g. sample output, correct result on benchmarks conclusions on your empirical result code (electronically if it’s HUGE)

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

Some pointers A tutorial on constraint programming Barbara Smith Leeds University, 1995 Hybrid Algorithms for the Constraint Satisfaction Problem Patrick Prosser Computational Intelligence, 1993 Dynamic Variable Ordering in CSPs Bacchus & van Run CP95, 1995