0% found this document useful (0 votes)
2 views

AI 2.1

A Constraint Satisfaction Problem (CSP) involves selecting values for variables under specific constraints, represented as a set of variables, constraints, and their domains. CSPs can be visualized using constraint graphs, where nodes represent variables and edges represent constraints, and can be approached as search problems. The Generate-and-Test search method is a heuristic approach to solving CSPs, improving efficiency by eliminating unlikely solutions and utilizing domain knowledge.

Uploaded by

shourishpaul417
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
0% found this document useful (0 votes)
2 views

AI 2.1

A Constraint Satisfaction Problem (CSP) involves selecting values for variables under specific constraints, represented as a set of variables, constraints, and their domains. CSPs can be visualized using constraint graphs, where nodes represent variables and edges represent constraints, and can be approached as search problems. The Generate-and-Test search method is a heuristic approach to solving CSPs, improving efficiency by eliminating unlikely solutions and utilizing domain knowledge.

Uploaded by

shourishpaul417
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
You are on page 1/ 3

Constraint Satisfaction Problems (CSP) and Constraint Graph

A Constraint Satisfaction Problem (CSP) involves choosing the best option from a set of available
choices while satisfying given constraints. Constraints can be negative (limitations) or positive
(desired elements).

Formally, a CSP consists of:

• A set of variables X1,X2,...,XnX_1, X_2, ..., X_n

• A set of constraints C1,C2,...,CmC_1, C_2, ..., C_m

• Each variable has a domain of possible values

• Each constraint defines allowable combinations of values for a subset of variables

A state in CSP is an assignment of values to variables. If an assignment satisfies all constraints, it is


consistent or legal. A complete assignment mentions every variable, and a solution satisfies all
constraints. Some CSPs may also maximize an objective function.

CSP as a Search Problem

A CSP can be formulated as a search problem with:

1. Initial state: An empty assignment where no variables are assigned values.

2. Successor function: Assigning values to unassigned variables while ensuring consistency.

3. Goal test: Checking if the assignment is complete.

4. Path cost: A constant cost per step.

Examples of CSPs

• Linear programming: Constraints are linear inequalities forming a convex region.

• Crypt arithmetic puzzles: Problems where letters represent digits.

• Map coloring problem: Assigning colors to regions while ensuring no two adjacent regions
have the same color.

Example of map coloring problem:

• Variables: Regions WA, NT, Q, NSW, V, SA, T

• Domain: {red, green, blue}

• Constraints: Neighboring regions must have different colors, e.g., WA ≠ NT.

• A possible solution: {WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T =
red}.

Constraint Graph

A CSP can be represented as an undirected graph, called a constraint graph:


• Nodes represent variables.

• Edges represent binary constraints between variables.

For example, in the map coloring problem, each region is a node, and edges represent adjacency
constraints.

Thus, CSPs are effectively solved using search algorithms with constraints ensuring valid solutions.

Generate-and-Test Search (Simplified Explanation)


Generate-and-Test is a heuristic search method based on Depth-First Search (DFS) with backtracking.
It guarantees finding a solution if done systematically and if a solution exists.

Key Concepts:
1. Process:
o Generate possible solutions.
o Test each solution to check if it’s correct.
o Stop if a solution is found; otherwise, repeat.
2. Why It’s Called British Museum Search?
o Similar to searching for an object in a large museum by wandering randomly.
3. Use of Heuristic Function:
o Helps eliminate unlikely paths, ranking better alternatives.
o Reduces unnecessary searches in large problem spaces.
4. Limitations & Improvements:
o Inefficient for complex problems.
o Can be improved by combining with other techniques (e.g., Constraint Satisfaction in
AI programs like DENDRAL).

Algorithm Steps:
1. Generate a possible solution (e.g., picking a point in the problem space).
2. Test if it meets the goal condition.
3. If correct, stop. If not, repeat from Step 1.

Properties of a Good Generator:


1. Complete: Must generate all possible solutions to guarantee finding the correct one.
2. Non-Redundant: Should not repeat solutions to save time.
3. Informed: Should use domain knowledge to reduce unnecessary searches.

Example: PIN Code Search


• Suppose we need to find a 3-number PIN (each number is 2-digit).
• Brute Force:
o Total possible PINs = 100³ = 1M (1 million)
o If checking 5 per minute, it takes 10 weeks!
• Using Heuristic (Prime Numbers Only):
o Possible PINs = 25³ = 15,000
o With the same search rate, the solution is found in less than 2 days.
Conclusion: Using heuristics reduces time complexity significantly.

Real-Life Example:
• Monkeys & Shakespeare: If monkeys type randomly for long enough, they could eventually
produce all of Shakespeare’s works.
• DENDRAL (AI System): Uses Generate-and-Test to determine organic compound structures
from NMR spectrograms.
Final Thought: A better generator = faster search with lower complexity! 🚀

You might also like