Download presentation

Presentation is loading. Please wait.

Published byEfrain Dingley Modified over 3 years ago

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

2
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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

Similar presentations

Presentation is loading. Please wait....

OK

David Luebke 1 6/7/2014 ITCS 6114 Skip Lists Hashing.

David Luebke 1 6/7/2014 ITCS 6114 Skip Lists Hashing.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on power system stability using facts devices Ppt on private public and global enterprises Ppt on carburetor diagram Ppt on eye os glasses Ppt on finance commission of india Ppt on content addressable memory structure Ppt on spot welding Ppt on junk food and its effects Ppt on power sharing in democracy the will of the majority Ppt on production function