5. Problem Solving Approch in AI
5. Problem Solving Approch in AI
Typical AI problems
Refreshing Time
Quiz
• “a problem-solving refers to a state where we wish to reach to a definite goal from a present state or condition.”
• According to computer science, a problem-solving is a part of artificial intelligence which encompasses a
number of techniques such as algorithms, heuristics to solve a problem.
• Therefore, a problem-solving agent is a goal-driven agent and focuses on satisfying the goal.
Steps performed by Problem-solving agent
• Goal Formulation- the first and simplest step in problem-solving. It organizes the steps/sequence required
to formulate one goal out of multiple goals as well as actions to achieve that goal. Goal formulation is based
on the current situation and the agent’s performance measure
• Problem Formulation: It is the most important step of problem-solving which decides what actions should
be taken to achieve the formulated goal.
• There are following five components involved in problem formulation:
• Initial State: It is the starting state or initial step of the agent towards its goal(Starting location of
agent)
• Actions: It is the description of the possible actions available to the agent.(Legal moves – Chess)
• Transition Model: It describes what each action does.(Puzzle - Moving a piece to an empty spot)
• Goal Test: It determines if the given state is a goal state.
• Path cost: It assigns a numeric cost to each path that follows the goal. The problem-solving agent selects
a cost function, which reflects its performance measure. Remember, an optimal solution has the
lowest path cost among all the solutions.(Delivery routing problem - total time taken/distance
travelled)
Example Problems
• Basically, there are two types of problem approaches:
• Toy Problem:
It is intended to illustrate or exercise various problem solving methods. It can
be given a concise and exact description of the problem which is used by the
researchers to compare the performance of algorithms.
simplified versions, educational/theoretical purpose
Ex: 8 Puzzle Problem, Water-Jug Problem to convert the current state into goal state by sliding
digits into the blank space
• Real-world Problem:
It is real-world based problems which require solutions- problem whose
solutions people actually care about, they tend not to have a single agreed
upon description, but we will attempt to give the general flavor of their
formulations.
Complex problem, Real world application
Unlike a toy problem, it does not depend on descriptions, but we can have a
general formulation of the problem.
Ex: Traveling salesperson problem(TSP)
Problems,
Problem Spaces and Search
15
To build a system to solve a particular problem
• To solve the problem of building a system, you should take the following steps:
• 1. Define the problem accurately -including detailed specifications and
what constitutes a suitable solution(Position – pieces, no of moves
Chess)
• 2. Analyze the problem carefully, for some features may have a central
affect on the chosen method of solution(Initial position analyzed,
pieces move)
• 3. Segregate and represent the background knowledge needed to solve the
problem.
• 4. Choose the best problem-solving techniques and apply it to the
particular problem.
Problem solving
• We want:
• To automatically solve a problem
• We need:
• A representation of the problem
• Algorithms that use some strategy to solve the problem defined in that representation
Defining the Problem as a State Space Search
• General:
– State space: a problem is divided into a set of resolution steps from the initial state to the goal
state(Initial state(board set up, legal moves, Goal – black checkmate)
– Reduction to sub-problems: a problem is arranged into a hierarchy of sub-problems(Find a move
that puts black in
checkmate)
• Specific:
• Game resolution
• Constraints satisfaction
State Space Search
• Initial state, actions, and transition model together define
the state-space of the problem implicitly.
• State-space of a problem is a set of all states which can be
reached from the initial state followed by any sequence of
actions.
• The state-space forms a directed map or graph where nodes are
the states, links between the nodes are actions, and the path is a
sequence of states connected by the sequence of actions.
• Search: It identifies all the best possible sequence of actions to
reach the goal state from the current state. It takes a problem as
an input and returns solution as its output.
• Solution: It finds the best algorithm out of various algorithms,
which may be proven as the best optimal solution.
State Space representation - Ex 1 Water Jug problem
Water Jug problem & Solution
Water Jug problem &
Solution II with rules applied
22
Ex 2: 8 Puzzle Problem:
• Here, we have a 3×3 matrix with movable tiles numbered from 1 to 8 with a blank
space. The tile adjacent to the blank space can slide into that space.
• our task is to convert the current state into goal state by sliding digits into the blank
space.
State Space
representation –
8 Puzzle Problem
Draw the state space for the given problem
Problem definitions
• A problem is defined by its ‘elements’ and their ‘relations’.
• To provide a formal description of a problem, we need to do the following:
• a. Define a state space that contains all the possible configurations of the relevant objects, including
some impossible ones.
• b. Specify one or more states that describe possible situations, from which the problem solving
process may start. These states are called initial states.
• c. Specify one or more states that would be acceptable solution to the problem- goal states.
• D Specify a set of rules that describe the actions (operators) available, in combination with an
appropriate control strategy, to move through the problem space until a path from an initial state to a
goal state is found. This process is known as ‘search’.
States
• A problem is defined by its elements and their relations.
• In each instant of the resolution of a problem, those elements have specific
descriptors (How to select them?) and relations.
• A state is a representation of those elements in a given moment.
• Two special states are defined:
– Initial state (starting point)
– Final state (goal state)
State space
• The state space is the set of all states reachable from the initial state.
• It forms a graph (or map) in which the nodes are states and the arcs between
nodes are actions.
• A path in the state space is a sequence of states connected by a sequence of
actions.
• The solution of the problem is part of the map formed by the state space.
State modification: successor function
• A successor function is needed to move between different states.
• A successor function is a description of possible actions, a set of operators
. It is a transformation function on a state representation, which convert it
into another state.
• The successor function defines a relation of accessibility among states.
• Representation of the successor function:
• Conditions of applicability
• Transformation function
Problem solution
• A solution in the state space is a path from the initial state to a goal state or,
sometimes, just a goal state.
• Path/solution cost: function that assigns a numeric cost to each path, the cost of
applying the operators to the states
• Solution quality is measured by the path cost function, and an optimal solution
has the lowest path cost among all solutions.
• Solutions: any, an optimal one, all. Cost is important depending on the problem
and the type of solution sought.
More concrete problem definition
A state space Choose a representation
Choose an element from the
An initial state representation
Create goal_function(state) such
A goal state that TRUE is returned upon reaching
goal
successor_function(statei) =
A function defining state
{<actiona, statea>, <actionb, stateb>,
transitions …}
33
Search strategies
• A strategy is defined by picking the order of node expansion
• Open nodes:
• Generated, but not yet explored
• Explored, but not yet expanded
• Closed nodes:
• Explored and expanded
• Strategies are evaluated along the following dimensions:
• Completeness – does it always find a solution if one exists?
• Time complexity – number of nodes generated/expanded