1 State Space of a Problem Lecture 03 ITS033 – Programming & Algorithms Asst. Prof.

Slides:



Advertisements
Similar presentations
Uninformed Search in Prolog
Advertisements

Artificial Intelligence: Knowledge Representation
Algorithm Design Techniques
Heuristic Search techniques
Artificial Intelligence By Mr. Ejaz CIIT Sahiwal.
Problem Solving Well-formed predicate calculus expressions provide a means of describing objects and relations in a problem domain and inference rule.
Ch 4. Heuristic Search 4.0 Introduction(Heuristic)
BackTracking Algorithms
January 26, 2003AI: Chapter 3: Solving Problems by Searching 1 Artificial Intelligence Chapter 3: Solving Problems by Searching Michael Scherger Department.
Formal Description of a Problem
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.4) January, 14, 2009.
CSE 380 – Computer Game Programming Pathfinding AI
CSC 423 ARTIFICIAL INTELLIGENCE
Searching Algorithms Finding what you are looking for.
Use “Search” for Pathfinding FactorySchool Library Hospital Park Newsagent University church Example from Alison Cawsey’s book start finish.
Transform & Conquer Lecture 08 ITS033 – Programming & Algorithms
Slide 1 Heuristic Search: BestFS and A * Jim Little UBC CS 322 – Search 5 September 19, 2014 Textbook § 3.6.
State Spaces Introduction to Artificial Intelligence Dr. Robin Burke.
State-Space Searches. State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
1 Solving Problems by Searching. 2 Terminology State State Space Initial State Goal Test Action Step Cost Path Cost State Change Function State-Space.
Uninformed Search Reading: Chapter 3 by today, Chapter by Wednesday, 9/12 Homework #2 will be given out on Wednesday DID YOU TURN IN YOUR SURVEY?
Chapter 10: Algorithm Design Techniques
Backtracking.
Intro to AI, Fall 2004 © L. Joskowicz 1 Introduction to Artificial Intelligence LECTURE 3: Uninformed Search Problem solving by search: definitions Graph.
State-Space Searches. 2 State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
State-Space Searches.
Artificial Intelligence Course outline Introduction Problem solving Generic algorithms Knowledge Representation and Reasoning Expert Systems Uncertainty.
1 Shortest Path Problem Topic 11 ITS033 – Programming & Algorithms C B A E D F Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program,
Dr.Abeer Mahmoud ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information.
1 Minimum Spanning Tree Problem Topic 10 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing.
1 Decrease-and-Conquer Approach Lecture 06 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing.
Formal Description of a Problem In AI, we will formally define a problem as –a space of all possible configurations where each configuration is called.
Chapter 2 Problems, Problem Spaces, and Search?
Dr.Abeer Mahmoud ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information.
Today’s Topics FREE Code that will Write Your PhD Thesis, a Best-Selling Novel, or Your Next Methods for Intelligently/Efficiently Searching a Space.
Problems, Problem Spaces and Search
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 28, 2014.
Chapter 2 Problems, Problem Spaces, and Search?
1 Solving problems by searching 171, Class 2 Chapter 3.
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
PROBLEM SOLVING – BASIC SEARCH METHODS 12/8/2015Dr. Sunil Kumar 1.
Chapter 5 Constraint Satisfaction Problems
CSCI 4310 Lecture 2: Search. Search Techniques Search is Fundamental to Many AI Techniques.
1 Dynamic Programming Topic 07 Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information and Computer Technology.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
Knowledge Representation Fall 2013 COMP3710 Artificial Intelligence Computing Science Thompson Rivers University.
Introduction to State Space Search
Artificial Intelligence Lecture No. 8 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
G5AIAI Introduction to AI
Lecture 2: Problem Solving using State Space Representation CS 271: Fall, 2008.
CSCE 552 Fall 2012 AI By Jijun Tang. Homework 3 List of AI techniques in games you have played; Select one game and discuss how AI enhances its game play.
ARTIFICIAL INTELLIGENCE
Knowledge Representation
Brute Force Algorithms
Data Structures Lab Algorithm Animation.
Decrease-and-Conquer Approach
Introduction to Artificial Intelligence
STATE SPACE REPRESENTATION
Artificial Intelligence Problem solving by searching CSC 361
CS Fall 2016 (Shavlik©), Lecture 8, Week 5
4. Computational Problem Solving
Knowledge Representation
State-Space Searches.
ARTIFICIAL INTELLIGENCE
State-Space Searches.
Major Design Strategies
Chapter 2 Problems, Problem Spaces, and Search?
State-Space Searches.
Major Design Strategies
Presentation transcript:

1 State Space of a Problem Lecture 03 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information, Computer and Communication Technology (ICT) Sirindhorn International Institute of Technology (SIIT) Thammasat University X 2005

2 ITS033 Topic 01-Problems & Algorithmic Problem Solving Topic 01 - Problems & Algorithmic Problem Solving Topic 02 – Algorithm Representation & Efficiency Analysis Topic 03 - State Space of a problem Topic 04 - Brute Force Topic 05 - Divide and Conquer Topic 06-Decrease and Conquer Topic 06 - Decrease and Conquer Topic 07 - Dynamics Programming Topic 08-Transform and Conquer Topic 08 - Transform and Conquer Topic 09 - Graph Algorithms Topic 10 - Minimum Spanning Tree Topic 11 - Shortest Path Problem Topic 12 - Coping with the Limitations of Algorithms Power and

3 This Week Overview State of a Problem State Space Rules State Space Traversal State space and problem solving

4 State Space: A problem representation Lecture 02.1 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information, Computer and Communication Technology (ICT) Sirindhorn International Institute of Technology (SIIT) Thammasat University X

5 To solve a problem computationally, we have to translate the problem into something that computer can understand. To solve a problem computationally, we have to translate the problem into something that computer can understand. In other words, we have to define state of the problem. In other words, we have to define state of the problem. The states of a problem should be defined mathematically or with a specific data structure. The states of a problem should be defined mathematically or with a specific data structure. State of a problem

6 A possible state of a problem is one of the specific choices made for a solution’s components. A possible state of a problem is one of the specific choices made for a solution’s components. Or a specific combination from all possibilities. Or a specific combination from all possibilities. Or a possible step in the problem. Or a possible step in the problem. State of a problem

7 We have two empty containers (with no scale), one can hold 4 gallons of water, the other 3 and plenty of water. We have two empty containers (with no scale), one can hold 4 gallons of water, the other 3 and plenty of water. How can we have exactly 2 gallons of water in container A ? How can we have exactly 2 gallons of water in container A ? Write a program to solve this problem with user’s input of different size of containers ? Write a program to solve this problem with user’s input of different size of containers ? Example 1 : Water Jug Problem 3 Gal B 4 Gal A

8 Water Jug State A state in this problem could be define as (X, Y) Where X is a number of gallons in A, and Y is a number of gallons in B

9 Water Jug Problem: Possible States (0,0) (1,1)(2,1)(3,1) (0,2)(1,2)(3,2) (1,3)(2,3)(3,3) (4,0) (4,3)

10 Two important states in a problem Initial State is a first state given by the problem Initial State is a first state given by the problem Goal State is a solution state where the problem wants to reach. Goal State is a solution state where the problem wants to reach. State of a problem

11 Water Jug Problem The initial state is when both jugs are empty: (0,0) The goal state is any state that has 2 gallons in container A: (2,n) for any n

12 Water Jug States (0,0)(2,0) (2,1) (2,2) (2,3) Goal States Initial State

13 Example 2: Knight Traversal Problem On a 8 x 8 chess board, move a knight from any initial position to all position on the board. (see demo 1) + It would be best if the knight make minimum number of move to complete the journey. (see demo 2) + define State of the problem.

14 Knight Traversal What’s wrong with this state representation ? A state in this problem could be define as (X, Y) Where X is {1, 2, 3, 4, 5, 6, 7, 8} and Y is {1, 2, 3, 4, 5, 6, 7, 8}

15 The 8-puzzle - also known as the sliding- block/tile-puzzle - is one of the most popular instrument in the artificial intelligence (AI) studies. The 8-puzzle - also known as the sliding- block/tile-puzzle - is one of the most popular instrument in the artificial intelligence (AI) studies. Arrange the tiles so that all the tiles are in the correct positions. You do this by moving tiles. You can move a tile up, down, left, or right, so long as the following conditions are met: Arrange the tiles so that all the tiles are in the correct positions. You do this by moving tiles. You can move a tile up, down, left, or right, so long as the following conditions are met: A) there's no other tile blocking you in the direction of the movement; and A) there's no other tile blocking you in the direction of the movement; and B) you're not trying to move outside of the boundaries/edges. If you wish to try another picture, try this. B) you're not trying to move outside of the boundaries/edges. If you wish to try another picture, try this. Example Puzzle

16

17 A man finds himself on a riverbank with a wolf, a goat, and a head of cabbage. He needs to transport all three to the other side of the river in his boat. However, the boat has room for only the man himself and one other item. In his absence, the wolf would eat the goat, and the goat would eat the cabbage. The man is vegetarian who doesn’t like to eat cabbage. Define state for this problem. River-Crossing Puzzle Example 4 - River-Crossing Puzzle

18 State Space Lecture 02.2 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information, Computer and Communication Technology (ICT) Sirindhorn International Institute of Technology (SIIT) Thammasat University X

19 State Space of a problem is a space containing all possible states of the problem. State Space of a problem is a space containing all possible states of the problem. State Space

20 Water Jug State Space The state can be represented by 2 integers x and y: x = gallons in the 4 gallon jug y = gallons in the 3 gallon jug State Space = (x,y) such that x  {0,1,2,3,4}, y  {0,1,2,3}

21 Water Jug Problem: Possible States (0,0)(1,0)(2,0)(3,0) (0,1)(1,1)(2,1)(3,1) (0,2)(1,2)(2,2)(3,2) (0,3)(1,3)(2,3)(3,3) (4,0) (4,1) (4,2) (4,3)

22 It is usually not possible to list all possible states: It is usually not possible to list all possible states:  use abstractions to describe legal states.  It may be easier to describe the illegal states.  Sometimes it is useful to provide a general description of the state space and a set of constraints. State Space of a problem

23 Two types of states in a problem Legal States are possible states in the problem which can be reached and follow the rules of that problem. Legal States are possible states in the problem which can be reached and follow the rules of that problem. Illegal States are possible states in the problem that violate the rules of that problem. Illegal States are possible states in the problem that violate the rules of that problem. State of a problem

24 Example Problem - 3 Puzzle Sliding Tile game with 3 tiles: start stategoal state

25 State Space: Rules Lecture 02.3 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information, Computer and Communication Technology (ICT) Sirindhorn International Institute of Technology (SIIT) Thammasat University X

26 Solving a problem means searching for a path in the state space from a starting state to a goal state. Solving a problem means searching for a path in the state space from a starting state to a goal state. That’s why we need to devise a set of operations (rules) that changes from one state to another. That’s why we need to devise a set of operations (rules) that changes from one state to another. Rules

27 The problem solving system moves from one state to another according to well defined operations. The problem solving system moves from one state to another according to well defined operations. Typically these operations are described as rules. Typically these operations are described as rules. A control system decides which rules are applicable at any state, and resolves conflicts and/or ambiguities. A control system decides which rules are applicable at any state, and resolves conflicts and/or ambiguities. Rules or Operations

28 Water Jug Operations Rule 1 : Fill B from pump move from any state (x,y) to a state (x,3) Rule 2 : Fill A from pump move from any state (x,y) to a state (4,y) Rule 3 : Empty Bmove from any state (x,y) to a state (x,0) Rule 4 : Empty Amove from any state (x,y) to a state (0,y) Fill A from B Rule 5 : Fill A from Bmove from any state (x,y) to a state (x+y, 0) ………. if x+y <= 4 (x+y, 0) ………. if x+y <= 4 (4, x+y mod 4).. if x+y > 4 (4, x+y mod 4).. if x+y > 4 Fill B from A Rule 6 : Fill B from Amove from any state (x,y) to a state (0, x+y) ………. if x+y <= 3 (0, x+y) ………. if x+y <= 3 (x+y mod 3, 3).. if x+y > 3 (x+y mod 3, 3).. if x+y > 3

29 Relationship between states (0,0)(4,0) (4,3)(1,3)(0,0) (0,3)(4,3)(3,0)(0,0)

30 The search for a solution can be described by a tree - each node represents one state. The path from a parent node to a child node represents an operation Each node is a search tree has child nodes that represent each of the states reachable by the parent state. Each node is a search tree has child nodes that represent each of the states reachable by the parent state. Another way of looking at it: child nodes represent all available options once the search procedure reaches the parent node. Another way of looking at it: child nodes represent all available options once the search procedure reaches the parent node. There are a number of strategies for traversing a search tree. There are a number of strategies for traversing a search tree. Search Concepts Search Tree

31 River Crossing Problem: Relationship between states

32 Relationship between states

33 Rules: Knight Traversal Problem Defines rules for Knight Traversal Problem

34 State Space: Problem Solving with State Space Lecture 02.4 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information, Computer and Communication Technology (ICT) Sirindhorn International Institute of Technology (SIIT) Thammasat University X

35 State Space Problem Problem Solving Currently we have, Set of possible states. Set of possible states. Set of possible rules that change the state. Set of possible rules that change the state. Specification of a starting state(s). Specification of a starting state(s). Specification of a goal state(s). Specification of a goal state(s).

36 Simple Agent Algorithm Problem-Solving-Agent 1. Find an initial-state 2. Define a goal state 3. Define Rules 4. Find a path from Initial State to a Goal state 5. Done

37 Simple Algorithm (not very clever). Initial State Random a rule Change to a new state Check if it is a goal state done yes no

38 More complexed Algorithm. Initial State Pick a rule Change to a new state Check if it is a goal state done yes no Do something clever

39 Blind (or uninformed) strategies do not exploit any of the information contained in a state Blind (or uninformed) strategies do not exploit any of the information contained in a state Heuristic (or informed) strategies exploits such information to assess that one node is “more promising” than another Heuristic (or informed) strategies exploits such information to assess that one node is “more promising” than another Blind Search Heuristic Search Blind Search vs Heuristic Search

40 The blind search - a search for a solution at random. The blind search - a search for a solution at random. Blind search, also called uninformed search, works with no information about the search space, other than to distinguish the goal state from all the others. Blind search, also called uninformed search, works with no information about the search space, other than to distinguish the goal state from all the others. Pure blind search is usually simple to run, and therefore fast to realize. Pure blind search is usually simple to run, and therefore fast to realize. It often finds answers that are good enough for practical purposes, or at least can serve as the preliminary estimates. It often finds answers that are good enough for practical purposes, or at least can serve as the preliminary estimates. Blind State Space Search

41 Water Jug States (0,0)(1,0)(2,0)(3,0) (0,1)(1,1)(2,1)(3,1) (0,2)(1,2)(2,2)(3,2) (0,3)(1,3)(2,3)(3,3) (4,0) (4,1) (4,2) (4,3) Goal States Start State

42 Heuristic State Space Search The heuristic search - a search for the best answer by assigning a value to each state in the State Space The heuristic search - a search for the best answer by assigning a value to each state in the State Space

43 Heuristic State Space Search Score for a state is a value calculated by comparing the state with the goal state Score for a state is a value calculated by comparing the state with the goal state Such as a number of correct items, or a distance from a goal state. Such as a number of correct items, or a distance from a goal state. So the new rules will be chosen based on this values. So the new rules will be chosen based on this values.

Goal state N1 N2 STATE Score for a heuristic search Score = correct position = 1 points Score = correct position = 7 points

Goal state N1 N2 STATE For a blind strategy, N1 and N2 are just two nodes (at some depth in the search tree) For a heuristic strategy counting the number of misplaced tiles, N2 is more promising than N1 Search Concepts Blind Search Heuristic Search Search Concepts Blind Search vs Heuristic Search

46 Heuristic State Space Search In doing so, it is more likely to get to a goal state faster than blind search. In doing so, it is more likely to get to a goal state faster than blind search.

47 Conclusions To solve any problems using computer 1. We define State of a Problem 2. Limit the State Space 3. Create Rules that move states 4. State Space Traversal or move among states until Goal is found. Problem is solved!

48 ITS033 Topic 01-Problems & Algorithmic Problem Solving Topic 01 - Problems & Algorithmic Problem Solving Topic 02 – Algorithm Representation & Efficiency Analysis Topic 03 - State Space of a problem Topic 04 - Brute Force Topic 05 - Divide and Conquer Topic 06-Decrease and Conquer Topic 06 - Decrease and Conquer Topic 07 - Dynamics Programming Topic 08-Transform and Conquer Topic 08 - Transform and Conquer Topic 09 - Graph Algorithms Topic 10 - Minimum Spanning Tree Topic 11 - Shortest Path Problem Topic 12 - Coping with the Limitations of Algorithms Power and

49 End of Chapter 3 Thank You!