Login

Sign Up

Artificial Intelligence : Searching
Ujjwal Paliwal

Posted on Dec 24, 2024 | AIML

Artificial Intelligence : Searching

Search problems are everywhere, powering applications that need to make decisions or find optimal solutions. One classic example is a navigator app, which calculates the best path from your current location to your desired destination. Let’s dive into the key concepts that make up a search problem in simple terms.

Core Components of a Search Problem

1. Agent

An agent is an entity that perceives its surroundings and acts upon them. For example:

In a navigator app, the agent could be seen as the car. It evaluates possible moves (turn left, go straight, etc.) to reach the destination.


2. State

A state is a snapshot of the agent's configuration within the environment.

  • For instance, in a 15-puzzle game, a state represents how the tiles are arranged at any given time.

3. Initial State

The initial state marks the starting point of the search process.

  • In a navigator app, the initial state is your current location.

4. Actions

Actions are the possible choices the agent can take in a given state.

  • In a 15-puzzle, the actions might include sliding a tile up, down, left, or right, depending on the empty square’s position.

  • In a navigator app, actions represent moves, like driving to an adjacent road or making a turn.


5. Transition Model

The transition model describes what happens when an action is taken in a specific state. It defines how one state leads to another.

  • For example, in a 15-puzzle, if you slide a tile into the empty space (action), the resulting arrangement of tiles forms a new state.

  • In a navigator app, taking a left turn (action) transitions you to a new road (state).


Transition States


6. State Space

The state space includes all the states that can be reached from the initial state through any sequence of actions.

  • In a 15-puzzle, this comprises all valid tile arrangements you can achieve through a series of moves.

  • You can think of state space as a network of nodes (states) connected by arrows (actions).


7. Goal Test

A goal test checks if the agent has reached the desired state.

  • In a navigator app, the goal test is whether your current location matches your destination.

  • If it does, the problem is solved. If not, the search continues.


8. Path Cost

Path cost is a numerical value associated with a path from the initial state to a specific state. It measures efficiency.

  • In a navigator app, path cost might include time, distance, or even fuel consumption. The goal isn’t just to reach the destination but to do so optimally (e.g., fastest route).

Bringing It All Together

A navigator app provides a perfect example of a search problem:

Agent: The representation of your vehicle in the app.

State: Your vehicle’s current location.

Initial State: Where your journey starts.

Actions: Possible moves like turning left, right, or continuing straight.

Transition Model: How taking an action (e.g., turning left) leads to a new location.

State Space: All the places you could potentially travel to from your initial location.

Goal Test: Whether your current location is the same as the destination.

Path Cost: Optimizing for the fastest or shortest route.


Solving Search Problems:


  • Solution

A sequence of actions that leads from the initial state to the goal state.

  • Optimal Solution

    A solution that has the lowest path cost among all solutions.
    In a search process, data is often stored in a node, a data structure that contains the following data:

  • A state

  • Its parent node, through which the current node was generated

  • The action that was applied to the state of the parent to get to the current node

  • The path cost from the initial state to this node
    Nodes contain information that makes them very useful for the purposes of search algorithms. They contain a state, which can be checked using the goal test to see if it is the final state. If it is, the node’s path cost can be compared to other nodes’ path costs, which allows choosing the optimal solution. Once the node is chosen, by virtue of storing the parent node and the action that led from the parent to the current node, it is possible to trace back every step of the way from the initial state to this node, and this sequence of actions is the solution.

However, nodes are simply a data structure — they don’t search, they hold information. To actually search, we use the frontier, the mechanism that “manages” the nodes. The frontier starts by containing an initial state and an empty set of explored items, and then repeats the following actions until a solution is reached:
Repeat:

1.If the frontier is empty,

  • Stop. There is no solution to the problem.

2.Remove a node from the frontier. This is the node that will be considered.

3.If the node contains the goal state,

  • Return the solution. Stop.
    Else,
* Expand the node (find all the new nodes that could be reached from this node), and add resulting nodes to the frontier.
* Add the current node to the explored set.

Thanks for Reading Part 1 ~ Ujjwal Paliwal


5 Reactions

1 Bookmarks

Read next

Ujjwal Paliwal

Ujjwal Paliwal

Dec 14, 24

4 min read

|

Building an Own AI Chatbot: Integrating Custom Knowledge Bases

Ujjwal Paliwal

Ujjwal Paliwal

Dec 15, 24

9 min read

|

Exploratory data analysis with Pandas:Part 1