Problem Solving Agentscse.iitrpr.ac.in/ckn/courses/s2014/us.pdfΒ Β· might be faster than BFS, when...

Post on 12-Oct-2020

0 views 0 download

Transcript of Problem Solving Agentscse.iitrpr.ac.in/ckn/courses/s2014/us.pdfΒ Β· might be faster than BFS, when...

Problem Solving AgentsCSL 302 ARTIFICIAL INTELLIGENCE

SPRING 2014

Goal Based Agents

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 2

Representation Mechanisms (propositional/first order/probabilistic logic)

Search (blind and informed)PlanningInference

Learning Models

Example

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 3

Problem Solving AgentsGoal FormulationoOrganize behavior of the agent

oGoal – set of states in the world where the goal is satisfied

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 4

Example

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 5

Goal

Initial

Problem Solving AgentsGoal FormulationoOrganize behavior of the agent

oGoal – set of states in the world where the goal is satisfied

Problem FormulationoWhat are the actions?

oWhat are the states?

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 6

Assumptions about the Task EnvironmentObservable or partially observable?

Discrete or Continuous?

Deterministic or Stochastic?

Static or Dynamic?

Episodic or Sequential?

Multiple or Single Agent?

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 7

Assumptions about the Task EnvironmentObservable or partially observable?

Discrete or Continuous?

Deterministic or Stochastic?

Static or Dynamic?

Episodic or Sequential?

Multiple or Single Agent?

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 8

Assumptions about the Task EnvironmentObservable or partially observable?

Discrete or Continuous?

Deterministic or Stochastic?

Static or Dynamic?

Episodic or Sequential?

Multiple or Single Agent?

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 9

Finding a sequence of actions – Search!

Problem Solving AgentsGoal FormulationoOrganize behavior of the agent

oGoal – set of states in the world where the goal is satisfied

Problem FormulationoWhat are the actions?

oWhat are the states?

SearchoFinding the sequence of actions

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 10

Example

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 11

Goal

States

Operator/Action

Initial

What is the solution?

Problem TypesDeterministic and Fully Observable: Single state problemoSolution is sequence

Non-observable: Conformant problemoSolution (if any) is a sequence

Stochastic and/or Partially Observable: Contingency problemoSolution is a contingency plan or a policy

Unknown state space: Exploration problem

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 12

Problem Solving – Atomic Agents

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 13

Atomic AgentsoStates are indivisible

oSearching through the states to reach the goal.

Single State Problem Formulation

Problem can be defined by 5 components1. Initial State: the state the agent starts

2. Actions: the set of operators that can be executed at a state

3. Transition model: returns the state that results from doing an action in a state

4. Goal test: determines whether a given state is a goal state

5. Path Cost: function that assigns a numeric cost to a path

Step cost: cost of taking a single action

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 14

β€’ State Spaceβ€’ Graphβ€’ Path

Example

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 15

Initial State: AradActions: Drive(Sibiu),Drive(Timisora)Goal Test: In(Bucharest)Path Cost: ?

Example: Toy Vacuum Problem

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 16

State: Robot and Dirt Locations

Initial State: Any State

Actions: Left, Right Suck

Goal Test: No Dirt

Path Cost: cost 1 per action?

Example: Eight Puzzle Problem

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 17

State: Tile Locations

Initial State: A specific tile configuration

Actions: move the blank tile left, right, up or down

Goal Test: tiles are in the required configuration

Path Cost: cost 1 per move?

Note: Optimal solution for an n-puzzle family is NP hard.

Example: 8 Queens Problem

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 18

State: Configuration of the Queens

Initial State: Empty board

Actions: Add a queen to the board

Goal Test: configuration with 8 queens on the board with none attacking another

Path Cost: time taken to solve?

Example: Missionaries and Cannibals

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 19

State: number of missionaries and cannibals on the boat and each bank

Initial State: all objects one bank

Actions: move boat with x missionaries and y cannibals, no more cannibals than missionaries on the boat or the shore, a boat with a maximum capacity.

Goal Test: All objects on the opposite bank

Path Cost: 1 per river crossing

Example: Rubik’s Cube

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 20

State: List of colors on each face

Initial State: A specific color pattern

Actions: rotate a row or column or a face

Goal Test: configuration has the same color on all tiles on every face

Path Cost: cost 1 per move?

Example: Rubik’s Cube

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 21

Example: Real WorldTravelling Salesman Problem (TSP)

Robot Navigation

Protein folding

Graph Coloring

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 22

Uninformed Search21/1

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 23

Search - TreesBasic Principle:oOffline simulated exploration of search space

oGenerate successors of already explored states

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 24

Search Space as a Tree

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 25

Parent Root

Node

Children Children

Node

Initial StateActions

Solution

Goal State

State

Example

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 26

Search Strategies Strategies vary in the order in which nodes are picked for expansion

Evaluating search strategiesoCompleteness – Does it always find a solution if one exists?oOptimality – Does it always find a least cost solution?oSpace complexity – How much memory is needed to perform

search?oTime complexity – How long does it take to find a solution?

Time and Space complexities are measuredob – maximum branching factor of the search treeod – shallowest depth of the least cost solutionom- maximum depth of the search space

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 27

Uninformed search strategiesUse only the information available in the problem definition

Breadth-first search

Uniform-cost search

Depth-first search

Depth-limited search

Iterative deepening search

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 28

Breadth-first search (BFS)Expand shallowest unexpanded node

Implementation: FIFO Queue; successors at the end of the queue

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 29

BFS – AnalysisCompleteness: Yes (if b is finite)

Optimality: Not optimal; Yes- Uniform cost edges

Time Complexity: exponential in d1 + 𝑏 + 𝑏2 + 𝑏3 +β‹―+ 𝑏𝑑 + 𝑏 𝑏𝑑 βˆ’ 1 = 𝑂(𝑏𝑑+1)

Space Complexity: 𝑂(𝑏𝑑+1)

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 30

𝑏 = 10 106π‘›π‘œπ‘‘π‘’π‘  𝑠𝑒𝑐 103𝑏𝑦𝑑𝑒𝑠 π‘›π‘œπ‘‘π‘’

Uniform cost search (UCS)Expand least-cost (𝑔(𝑛))unexpanded node

Implementation: Priority queue – sort the nodes in the queue based on cost.

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 31

UCS - AnalysisCompleteness: Yes; if step cost β‰₯ πœ–

Optimality: Yes; nodes are expanded in increasing order of 𝑔(𝑛)

Time Complexity: # of nodes with 𝑔 ≀ cost of optimal solution(πΆβˆ—) - 𝑂(𝑏 πΆβˆ— πœ– )

Space Complexity: # of nodes with 𝑔 ≀ cost of optimal solution - 𝑂(𝑏 πΆβˆ— πœ– )

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 32

Large subtrees with inexpensive steps may be explored before useful paths with costly steps

Depth-first search (DFS)Expand deepest unexpanded node

Implementation: LIFO queue; successors at the front of the queue

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 33

DFS - AnalysisCompleteness: complete only in finite spaces; incomplete when there are loops and infinite spaces

Optimality: No

Time Complexity: 𝑂(π‘π‘š); terrible when π‘š ≫ 𝑑;might be faster than BFS, when solutions are dense.

Space Complexity: 1 + 𝑏 + 𝑏 +β‹―+ (π‘šπ‘‘β„Žπ‘™π‘’π‘£π‘’π‘™)𝑏 =𝑂(π‘π‘š); Linear space!!

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 34

Depth # nodes MemoryBFS

Memory DFS

16 1016 10Eb 156Kb

Depth-limited search (DLS)Depth-first search with depth limit 𝑙

Implementation: nodes at depth 𝑙 have no successors.

Only finite space to be explored.

Completeness: Yes/No???

Optimality: Yes/No???

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 35

Iterative deepening search(IDS)

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 36

π‘‘π‘’π‘π‘‘β„Ž = 0

π‘‘π‘’π‘π‘‘β„Ž = 1

π‘‘π‘’π‘π‘‘β„Ž =2

π‘‘π‘’π‘π‘‘β„Ž =3

π‘‘π‘’π‘π‘‘β„Ž =4

IDS- AnalysisCompleteness: Yes!

Optimality: Yes for uniform cost edges; can be modified to explore uniform cost tree

Time Complexity: 𝑑𝑏 + 𝑑 βˆ’ 1 𝑏2 +β‹―+1 𝑏𝑑 = 𝑂(𝑏𝑑)

Space Complexity: 𝑂(𝑏𝑑)

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 37

Asymptotic ratio of # nodes expanded by IDS vs DFS: (𝑏 + 1) 𝑏 βˆ’ 1 β‰ˆ 1for large values of 𝑏

Summary

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 38

Graph SearchBFS-?

DFS-?

IDDFS-?

1/21/2014 CSL 302 ARTIFICIAL INTELLIGENCE, INDIAN INSTITUTE OF TECHNOLOGY ROPAR 39