0% found this document useful (0 votes)
55 views32 pages

Module 3

Module 3 discusses informed search strategies, particularly focusing on algorithms like A* and Greedy Best-First Search, which utilize heuristics to optimize the search process. It also covers knowledge-based agents, their structure, and operations, emphasizing the importance of a knowledge base and inference system for intelligent decision-making. Additionally, the document introduces the Wumpus World environment, detailing its PEAS specifications and the agent's navigation and decision-making based on percepts.

Uploaded by

dr9741372168
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Topics covered

  • A* Search Algorithm,
  • Agent Knowledge Update,
  • Logical Entailment,
  • Greedy Best-First Search,
  • Knowledge Level,
  • Knowledge-Based Agents,
  • Complex Problem Solving,
  • Decision Making,
  • Search Strategies,
  • Agent Actions
0% found this document useful (0 votes)
55 views32 pages

Module 3

Module 3 discusses informed search strategies, particularly focusing on algorithms like A* and Greedy Best-First Search, which utilize heuristics to optimize the search process. It also covers knowledge-based agents, their structure, and operations, emphasizing the importance of a knowledge base and inference system for intelligent decision-making. Additionally, the document introduces the Wumpus World environment, detailing its PEAS specifications and the agent's navigation and decision-making based on percepts.

Uploaded by

dr9741372168
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Topics covered

  • A* Search Algorithm,
  • Agent Knowledge Update,
  • Logical Entailment,
  • Greedy Best-First Search,
  • Knowledge Level,
  • Knowledge-Based Agents,
  • Complex Problem Solving,
  • Decision Making,
  • Search Strategies,
  • Agent Actions

Module 3

Informed Search Strategies

• Informed Search Algorithms use problem-specific knowledge,


called a heuristic, to guide the search process more efficiently.

• A heuristic is an estimate of the cost to reach the goal from a


given node. It provides a guiding function that helps the
algorithm make intelligent decisions about which path to explore
next.
Uniformed Vs Informed

Greedy Best-First Search:


Step1:

Step 2:
Step 3:

Step 4:

Path Cost = A-E-F-I = 140+99+211 = 450


Is it Optimal?
A* Search (A Star Search Algorithm):
• A* Search algorithm is a informed search algorithm.
• Used to find the optimal path from initial state to the goal state.
• A* Search algorithm evaluates the nodes by using the function.
F(n) = g(n) + h(n)
• g(n) is the cost from the initial state to the state at the current
node.
• H(n) is the estimated cost from the state at node n to the goal
state.
Path: A→B→D→F→G
Path Cost = 7
Algorithm:
• Initialize the open list (nodes to be explored) and closed list
(explored nodes)
• Start with the initial node, calculate f(n), and add it to the open
list
• Select the node with the lowest f(n), move it to the closed list,
and expand its neighbours.
• For each neighbour
o Calculate h(n)+g(n) and update f(n)
• If it is a better path, update & continue
• Repeat until the goal node is reached.

Advantages
• Best searching algorithm
• Optimal & complete
• It is solving complex problems
Disadvantages
• Complexity issue
• Requires memory
Heuristic Functions:
A* Search Algorithm for 8-Puzzle problem:
Logical Agents
Knowledge based Agents:
An intelligent agent needs knowledge about the real world for taking decisions
and reasoning to act efficiently.
• Knowledge-based agents are those agents who have the capability of
maintaining an internal state of knowledge, reason over that knowledge, update
their knowledge after observations and take actions. These agents can represent
the world with some formal representation and act intelligently.
• Knowledge-based agents are composed of two main parts:
Knowledge-base and
Inference system.

A knowledge-based agent must able to do the following:


1. An agent should be able to represent states, actions, etc.
2. An agent Should be able to incorporate new percepts
3. An agent can update the internal representation of the world
4. An agent can deduce the internal representation of the world
5. An agent can deduce appropriate actions

Knowledge base: It is a collection of sentences (here 'sentence' is a technical


term and it is not identical to sentence in English). These sentences are
expressed in a language which is called a knowledge representation language.
The Knowledge-base of KBA stores fact about the world.
Why use a knowledge base?
Knowledge-base is required for updating knowledge for an agent to learn with
experiences and take action as per the knowledge.

Inference system
Inference means deriving new sentences from old. Inference system allows us
to add a new sentence to the knowledge base. A sentence is a proposition about
the world. Inference system applies logical rules to the KB to deduce new
information. Inference system generates new facts so that an agent can update
the KB.

Operations Performed by KBA.


Following are two operations which are performed by KBA in order to show the
intelligent behavior:

• TELL: This operation tells the knowledge base what it perceives from the
environment.
• ASK: This operation asks the knowledge base what action it should
perform.
A generic knowledge-based agent. Given a percept, the agent adds the percept
to its knowledge base, asks the knowledge base for the best action, and tells the
knowledge base that it has in fact taken that action.

function KB-AGENT( percept ) returns an action


persistent: KB , a knowledge base
t , a counter, initially 0, indicating time Tell(KB, Make-Percept-Sentence( percept
, t )) action ← Ask(KB, Make-Action-Query(t )) Tell(KB, Make-Action-
Sentence(action, t ))
t←t+1
return action

Each time when the function is called, it performs its three operations:
Firstly, it TELLs the KB what it perceives.
Secondly, it asks KB what action it should take
Third agent program TELLS the KB that which action was chosen.
The MAKE-PERCEPT-SENTENCE generates a sentence as setting that the agent
perceived the given percept at the given time.
The MAKE-ACTION-QUERY generates a sentence to ask which action should be
done at the current time.
MAKE-ACTION-SENTENCE generates a sentence which asserts that the chosen
action was executed.

Various levels of knowledge-based agent:

A knowledge-based agent can be viewed at different levels which are given


below:

• Knowledge level Knowledge level is the first level of knowledge-based


agent, and in this level, we need to specify what the agent knows, and
what the agent goals are. With these specifications, we can fix its
behaviour. For example, suppose an automated taxi agent needs to go
from a station A to station B, and he knows the way from A to B, so this
comes at the knowledge level.

• Logical level: At this level, we understand that how the knowledge


representation of knowledge is stored. At this level, sentences are
encoded into different logics. At the logical level, an encoding of
knowledge into logical sentences occurs. Example: Links
(GoldenGateBridge, SanFrancisco, MarinCounty).
• Implementation level: This is the physical representation of logic and
knowledge. At the implementation level agent perform actions as per
logical and knowledge level. At this level, an automated taxi agent actually
implements his knowledge and logic so that he can reach to the
destination.

The Wumpus World:


PEAS Description of Wumpus World

Performance:
• +1000 reward points if the agent comes out of the cave with the gold
• -1000 reward points penalty for being eaten by the Wumpus or falling
into the pit.
• -1 for each action, and -10 for using an arrow.
• Game ends if either agent dies or came out of the cave.

Environment:

Action/Actuators
• The agent can move Forward, TurnLeft by 90o or
TurnRight by 90o
• The action Grab can be used to pick up the gold if it
is in the same square as the agent.
• The action Shoot can be used to fire an arrow in a
straight line in the direction the agent is facing.
• The Action Climb can be used to climb out of the cave, but only from the
square [1,1]
Sensors: The agent has 5 sensors:
• In the square containing the Wumpus and in the
directly (not diagonally) adjacent squares, the
agent will perceive a Stench.
• In the squares directly adjacent to a pit, the agent
will perceive a breeze.
• In the square where the gold is, the agent will
perceive a Glitter.
• When an agent walks into a wall, it will perceive a Bump,
• When the Wumpus is killed, it emits a woeful scream that can be
perceived anywhere in the cave.
• The precepts will be given to the agent program in the form of a list of
five symbols.
Example:
If there is a stench and a breeze, but no glitter, bump or scream,
The agent program will get
[Stench, Breeze, None, None, None]

The Wumpus agent’s first step:

After One move with percept [None, Breeze, None, None, None]
LOGIC:
• Knowledge bases consist of sentences.
• Sentences are expressed according to the syntax of logic.
• Example: “x+Y = 4” is a well-formed sentence, where as “x4y+=’ is not
• The semantics defines the truth of each sentence with respect to each
possible world (Model).
Example: for the sentence ‘x+y = 4” where 0<x, y<=3
• The possible models are just all possible assignments of numbers to the
variable x and y.α
(1,1), (1,2), (1,3), (2,1) ,(2,3), (3,1), (3,2), (3,3)
The sentence is true in a world were
- X is 1 and y is 3
- X is 2 and y is 2 and
- X is 3 and y is 1.
- But false in all other cases.
• Logical entitlement between sentences is that a sentence follows
logically from another sentence.
• Mathematical notation: α|=β (sentence α entails sentence β)
• The formal definition of entailment is this: α|=β if and only if, in every
model in which α is true and β is also true.
• α|=β if and only if M(α) M(β)
• α: x+y = 4
• β: x * y ≥ 2
• for all x & y ≤ 3
(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3)
α is true when
x is 1 and y is 3
X is 2 and y is 2
X is 3 and y is 1
Β is also true for the above combinations of x and y values.
Therefore, we can say that α is logically entails β.
• These precepts, combined with the agent knowledge of the rules
of the Wumpus world constitute the KB.
• The agent is interested in whether the adjacent squares [1,2],
[2,2] and [3,1] contain pits.
• Each of the 3 squares might or might not contain pit.
• So there are 23 = 8 possible models.

Let us consider the two possible conclusions:


- α 1 = there is no pit in [1,2]
- α 2 = there is no pit in [2,2]
- KB |= α 1
- KB |= α 2
First Condition:
α 1 = there is no pit in [1,2]
KB |= α 1
Is a true statement.

Second Condition:
α 2 = there is no pit in [2,2]
KB |= α 2
Is a false statement
Propositional Logic:

Propositional Logic – Syntax


Formal Grammar of Propositional Logic

Propositional Logic - Semantics:


Truth table of five logical connectives
A Simple Knowledge Base:
Sound & Complete:

Reasoning Pattern in Propositional Logic:


Inference Rule – AND Elimination:

Inference Rules – Modus ponens

Inference Rule – Biconditional Elimination


Example Proof by Deduction: Wumpus World

-----------------------

Question Bank
Module 3
1. Outline the generic knowledge-based agent’s program and discuss the
difference between the declarative & procedural approaches in the
contest of knowledge-based agents.

2. Apply a A* algorithm to find the solution path from the start node(S) to
the goal node(G). The heuristic values(h) are provided with the nodes and
the travel cost ( C ) are provided with the edges as shown in the figure
below.
3. Discuss the Wumpus world environment and the PEAS specification for
the knowledge-based agent. Explain how does the agent navigate and
make decisions based on precepts in this environment.

4. Solve the following 8 – puzzle using the heuristic approach and the tree
diagram considering the initial and final states as specified.

5. Apply Greedy Best First search to find the solution path from S to G. Write
all steps as well as open and closed lists for full marks.
S(h=7), A(h=9), B(h=4), C(h=2), D(h=5), E(h=3), G(h=0)

6. Outline a generic knowledge-based agent program. Write PEAS


description of Wumpus World.

7. Explain Modus ponens and theory of resolution with examples.

8. Apply the A* search to find the solution path from a to z. Heuristics are
with the nodes and the cost is with the edges. Write all steps as well as
open and closed lists for full marks.
9. Explain contraposition, double implication elimination, demorgan’s rule
with examples. Prove logically that there is no pit in [1,2].
10.Differentiate backward and forward chaining with example.

11. Explain A* search to minimize the total estimated cost.

12.Write an algorithm for hill climbing search and explain in detail.

13.In the below graph, find the path from A to G, using Greedy Best First
Search A* Search algorithms. The values in the table represents the
heuristic values of reaching the goal node G pass current node.

14.Explain the syntax and semantics of positional logic.

15. In the fig below find the path from A to G, using Greedy Best First search
algorithm. The values given is the heuristic values to reach goal node from
the current node.
--------------------------

You might also like