Solving Problems by Searching Final
Solving Problems by Searching Final
com
1
Learning objectives: at the end of the class, you
should be able to:
• What is a Problem?
• Searching
– Searching algorithm Evaluation
2
Types of problem
– Searching based on the
Strategies
What is a
• It is a gap betweenProblem?
what actually is and what is desired.
–A problem exists when an individual becomes aware of the
existence of an obstacle
which makes it difficult to achieve a desired goal or objective.
• A number of problems are addressed towards designing
intelligent agent:
– Toy problems:
@ are problems that are useful to test and demonstrate
methodologies and can be used by researchers to compare the
performance of different algorithms.
• may require little or no ingenuity, good for games design
• e.g. 8-puzzle, n-queens, vacuum cleaner world, towers of
Hanoi, river crossing…
– Real-life problems:
• E.g. Route finding, Traveling sales 3
• 8- Example
Puzzle
problems
– Given an initial configuration of 8 numbered
tiles on a 3 x 3 board, move the tiles so as to
produce a desired goal configuration of the
tiles.
• Missionaries and Cannibals
– There are 3 missionaries, 3 cannibals, & 1
boat that can carry up to two people on one
side of a river. Move all the missionaries &
4
cannibals across the river.
- Missionaries can never be outnumbered
by cannibals on either side of river, or
else the missionaries are killed.
• The Eight Queens Game
Some more real-world
problems
• Route finding Problem
• Traveling Salesman
Problem(TSP)
• VLSI layout
• Assembly sequencing
• Robot navigation
• Route Finding Problem- shortest Cont
– Defined
path …along
in terms of locations and transitions
problem
links between them.
– Applications: automated travel advisory systems,
airline travel planning systems, military
operations planning, routing in computer
networks,
General route finding
algorithm
1. identify initial state as origin
2. expand to all possible locations
3. choose location with smallest cost/fastest route
4. test goal function, is it the destiny?
5. if yes, return location
Cont
• Route-finding problem: ’d
– Consider the agent in the city of Gondar, toward the end of
touring holiday. Flight leaves tomorrow from city Addis Ababa
airport. The agent has a ticket to fly out the following day. The
ticket is non-refundable, the agent’s visa is about to expire after
tomorrow and there are no seats available for six weeks.
8
Road map of Romania
Cont
• Traveling Salesperson Problems(TSP)
…
– Visit each city on the map exactly once and returns
to the origin
city.
– Needs information about the visited cities
– The aim is used to find the shortest possible route
that visits
every city exactly once and return to the starting
point.
– Applications: vehicle routing
• VLSI Cont
layout
…
– Place cells on a chip so they don’t overlap and there is
room for
connecting wires to be placed between the cells
– A VLSI layout problem requires positioning millions
of components and connections on a chip to
minimize area, minimize circuit delays, minimize
stray capacitances, and maximize manufacturing
yield.
• Automatic Assembly Sequencing Cont
– Automatic assembly of complex objects
– The problem is to find an order in …
which to
assemble the parts of some object
Robot Navigation
– Generalization of the route finding
problem.
– Rather than discrete set of routes, a
robot can move in a continuous
space with an infinite set of possible
actions and states
– When the robot has arms and legs or
Solving a
Problem solving is a process of generating solutions from
observed problem
or
given data.
- Use direct or indirect(Model based) methods
A problem is characterized by – a stet of goals
- a set of objects and
- a set of operations.
To build a system, to solve a particular problem, we
need to
• Define the problem precisely
- Find input situations as well as final situations for acceptable
solution to the problem
• Analyze the problem
• Choose- find
thefewbest problem
important featuressolving technique(s)
that may have impact on the12
the particular
and apply to
appropriateness of
Solving a
problem…
Solution and Optimal Solution
• Solution is set of actions that leads from initial
state to goal
state,
• There may be many solution for a problem
solving agent. The quality of this solution is
measured by the path cost and the solution with
minimum path cost is called Optimal Solution.
13
Solving a
Components of a Problem
o Initial State
problem…
- defines where the agent starts or begins its task
o Actions
- defines description of possible actions given a
particular state
o Transition Model
- describes each action a with respect to state.
o Goal Test
- determines the given state is goal or not
o Path Cost
problem- A function
solving thatisassigns
agents their cost to each path. The cost
14
Solving a
• Problem Formulation is the process of deciding what
problem…
actions and states to consider, given a goal.
• Define states
– States describe distinguishable stages
during the problem-solving process
– Example- What are the various states in route finding
problem?
• The various places including the location of the agent
• Define operators/rules
– Identify the available operators for getting from
one state to the next
– Operators causean action that brings transitions
from one state to
another by applying on a current state
State Space of the
Problem
• The state space defines the set of all relevant states
reachable by (any)
sequence of actions from the initial state until the goal state
is reached.
• Statespace(alsocalled search space/problem
space) of the problem
includes the various states
– Initial state
• defines where the agent starts or begins its task
– Transition states
• other states in between initial and goal states
– Goal state
• defines the situation the agent attempts to achieve 16
• Our aim is building Goal-based
Problem Solving
• A Problem solving agent isAgent
a goal-based agent . It decide
what to do by finding sequence of actions that lead to
desirable states. The agent can adopt a goal and aim at
satisfying it.
• Goal formulation is the first step in problem solving.
17
Building Goal-Based
• An agent which
Agents
has a goal to reach by applying a
sequence of
actions starting the initial state.
– Driving from point A to point B
– Put 8 queens on a chess board such that no one attacks
another
• To build a goal-based agent we need to answer the
following questions:
– What is the goal to be achieved?
18
– What are the actions?
– What relevant information is necessary to encode about the
Initial Goal
world to describe the
state Actions state
state of the world, describe the available transitions, and solve
the problem?
Missionaries and
Cannibals
Initial State
20
Missionaries and
Cannibals
Goal State
21
Missionaries and
Cannibals
(3,3,1): Initial State
22
Missionaries and
Cannibals
A missionary and cannibal
cross
23
Missionaries and
Cannibals
(2,2,0)
24
Missionaries and
Cannibals
One missionary returns
25
Missionaries and
Cannibals (3,2,1)
Missionaries and
Cannibals
Two cannibals
cross
27
Missionaries and
Cannibals
(3,0,0)
28
Missionaries and
Cannibals
A cannibal
returns
29
Missionaries and
Cannibals
(3,1,1)
30
Missionaries and
Cannibals
Two missionaries
cross
31
Missionaries and
Cannibals (1,1,0)
32
Missionaries and
Cannibals
A missionary and cannibal
return
33
Missionaries and
Cannibals (2,2,1)
34
Missionaries and
Cannibals
Two Missionaries
cross
35
Missionaries and
Cannibals (0,2,0)
36
Missionaries and
Cannibals
A cannibal
returns
37
Missionaries and
Cannibals (0,3,1)
38
Missionaries and
Cannibals
Two cannibals
cross
39
Missionaries and
Cannibals (0,1,0)
40
Missionaries and
Cannibals
A cannibal
returns
41
Missionaries and
Cannibals (0,2,1)
42
Missionaries and
Cannibals
The last two cannibals cross
43
Missionaries and
Cannibals
(0,0,0) : Goal State
44
Missionaries and
Cannibals
Solution = the sequence of actions within
the path : [ (3,3,1)→ (2,2,0)→(3,2,1) →(3,0,0) →(3,1,1)
→(1,1,0) →(2,2,1) →(0,2,0) →(0,3,1) →(0,1,0) → (0,2,1)
→(0,0,0)]; Cost = 11 crossings
45
Exercise : River
Crossing
Goat, Wolf and CabbagePuzzles
problem
• A farmer returns from the market, where he bought a
goat, a cabbage and a wolf. On the way home he must
cross a river. His boat is small and unable to transport
more than one of his purchases. He cannot leave the
goat alone with the cabbage (because the goat would eat
it), nor he can leave the goat alone with the wolf
(because the goat would be eaten). How can the farmer
get everything safely on the other side?
Example: The 8 puzzle
problem
1 2 3 1 2 3
4 8 4 5 6
7 6 5 7 8
Initial state
Goal state
Operators: slide blank up, slide blank down, slide
blank
1 2 left,
3 slide
1 2 blank
3 1 2right
3 1 2 3 1 2 3 1 2 3
4 8 4 8 5 4 8 5 4 5 4 5 4 5 6
7 6 5 7 6 7 6 7 8 6 7 8 6 7 8
Informed search
Greedy search
A*-search
Iterative
improvement
Constraint
64
Types of Problems via
Knowledge
• Solving Level
a problem requires knowledge about:
– The states: are they fully accessible or inaccessible
– Effects of its action: deterministic or non-deterministic
• Thus, the 1st step in problem formulation for an agent is to see
– to what extent the state of the world is accessible or fully
observable to the
agent to update its knowledge
– the extent of knowledge it has to determine the effects of its
action on the environment
• This knowledge depends on how it is connected to the
and 65
environment via its percepts
Cont
’d
• Problems can be classified into four types based
on the level of knowledge that an agent can have
concerning its action and the state of the world
Increasing complexity
– Type 1: Single state problems
– Type 2: Multiple state problems
– Type 3: Exploration problems
– Type 4: Contingency Problems
66
Example: Vacuum world
To simplifyproblem
the problem (rather
than the
full version), let;
•The world has only two
locations
– Each location may or may
not contain dirt
– The agent may be in one
location or the
other
• Eight possible world states
• Three possible actions (Left,
Right,
Suck) 67
– Suck operator clean the dirt
Vacuum Cleaner state
Space
68
I. Single state
problem
• Fully observable: The world is accessible to the agent
– It can determine its exact state through its sensors
– The agent’s sensor knows which state it is in
• Deterministic: The agent knows exactly the effect of its actions
– It can then calculate exactly which state it will be in after any
sequence of actions
• Action sequence is completely planned
Example - Vacuum cleaner world
– Can the agent achieve its goal? Let say the agent is initially at
state 4?
– Agent •easily
Right &{6}
calculates formulates sequences of actions ([Left,
Suck])•andSuck get {8
knows that it will to a goal state
} 69
II. Multiple state
problems
• Partially observable: The agent has limited access to the world
state
– It might not have sensors to get full access to the environment states or
as an extreme, it can have no sensors at all (due to lack of percepts)
• Deterministic: The agent knows exactly what each of its actions do
– It can then calculate which state it will be in after any sequence of
actions
Example - Vacuum cleaner world
– Can the agent achieve its goal?
• If the agent has full knowledge of how its actions change the world, but
does not know of the state of the world, it can still solve the task
– Agent’s initial state is one of the 8 states: {1,2,3,4,5,6,7,8}
– Action sequence: {right, suck, left, suck}
Right what
– Because agent knows its actions do,Suck
[2.4.6.8.] {4,8} and
it candiscover
reach to goal state.
Left {3,7} Suck {7} 70
II Contingency
I. Problems
•Partially observable: The agent has limited access to the world
state
•Non-deterministic: The agent is ignorant of the effect of its
actions
– Sometimes ignorance prevents the agent from
finding a guaranteed solution sequence.
•Suppose the agent is in Murphy’s law world
– The agent has to sense during the execution phase, since things
might have changed while it was carrying out an action. This
implies that
• the agent has to compute a tree of actions, rather than a linear
sequence of
action 71
– Example - Vacuum cleaner world:
Cont
• ’d world
Example - Vacuum cleaner
– What will happen given initial state [1,2,3,4,5,6,7,8], and
action sequence: [Suck,
Right, Suck]?
{5, 4, 7, 2, 1, 8,3,6} {2,4,6,8} {4,2,8,6} (failure)
• Is there a way to solve this problem?
– Solving this problem requires local sensing, i.e. sensing the
execution phase,
– Start from one of the states {1,2,3,4,5,6,7,8}, and take
improved action sequence [Suck, Right, Suck (only if there is
dirt there)]
• Many problems in the real world are contingency
problems (exact prediction is impossible)
– For this reason many people keep their eyes open while 72
74