UNIT-2
UNIT-2
OPTIMIZATION PROBLEMS
In addition to finding goals, local search algorithms are useful for solving pure
optimization problems, in which the aim is to find the best state according to an
objective function.
The hill-climbing search algorithm, which is the most basic local search
technique.
At each step the current node is replaced by the best neighbor; in this
version, that means the neighbor with the highest VALUE, but if a
heuristic cost estimate h is used, we would find the neighbor with the
lowest h.
Local maxima : a local maximum is a peak that is higher than each of its
neighboring states,but lower than the global maximum. Hill-climbing
algorithms that reach the vicinity
of a local maximum will be drawn upwards towards the peak,but will then be
stuck with nowhere else to go
o Ridges : A ridge is shown in Figure below. Ridges results in a
sequence of local maxima that is very difficult for greedy algorithms to
navigate.
o Plateaux : A plateau is an area of the state space landscape where
the evaluation function is flat. All the neighboring states are same.
Figure : Ridges
SIMULATED ANNEALING
To avoid being stuck in a local maxima, it tries randomly (using a probability
function) to move to another state, if this new state is better it moves into it,
otherwise try another move… and so on.
❖ The problem with this approach is that the neighbors of a state are not
guaranteed to contain any of the existing better solutions which means
that failure to find a better solution among them does not guarantee that
no better solution exists.
❖ If it runs for an infinite amount of time, the global optimum will be found.
GENETIC ALGORITHMS
❖ Inspired by evolutionary biology and natural selection, such as inheritance.
Example
2. Analyze how game theory influences AI-based decision-making in
communication systems. Provide examples to support your analysis.
Cooperative game models apply when multiple entities work together to achieve
a common goal, often forming coalitions.
Problem: Cloud service providers (leaders) set prices for resources, and
users (followers) choose service plans accordingly.
Solution: AI applies Stackelberg game models to determine optimal
pricing strategies that balance profitability and user demand.
Real-World Use Case: AI-powered dynamic pricing in cloud-based
services like AWS and Google Cloud.
Here's a Python simulation using game theory and reinforcement learning for
network bandwidth allocation among multiple users. The AI agents (users)
decide how much bandwidth to request, while the network optimizes allocation
using Nash Equilibrium concepts.
import numpy as np
import random
class NetworkGame:
def __init__(self, users, total_bandwidth):
self.users = users # Number of users
self.total_bandwidth = total_bandwidth # Total bandwidth available
self.requests = np.zeros(users) # Bandwidth requested by each user
def random_request(self):
"""Each user makes an initial random bandwidth request."""
self.requests = np.random.randint(1, self.total_bandwidth // 2,
size=self.users)
def payoff(self):
"""Calculate the payoff for each user based on Nash Equilibrium."""
total_requested = np.sum(self.requests)
if total_requested <= self.total_bandwidth:
return self.requests # Users get what they request
else:
return (self.requests / total_requested) * self.total_bandwidth #
Proportional allocation
1. Game Setup:
o There are multiple users competing for limited bandwidth.
o Each user requests bandwidth randomly at the start.
3. AI Optimization:
o Users modify their requests based on previous outcomes.
o They gradually learn an optimal allocation that stabilizes.
Expected Output
Each user gets a fair share of the bandwidth based on learning and
competition. The allocation adjusts over iterations to reach a stable Nash
Equilibrium.
1. Introduction
Online search agents are intelligent computational entities designed to autonomously explore
and retrieve information from dynamic environments in real time. These agents play a crucial
role in decision-making systems, such as search engines, recommendation systems, and
cognitive radio networks (CRNs).
In unknown environments like Cognitive Radio Networks (CRNs), online search agents
must intelligently sense, learn, and adapt to changes to optimize spectrum utilization while
minimizing interference with primary users.
Cognitive Radio Networks are dynamic wireless communication systems that enable
secondary users to opportunistically access unused spectrum bands without interfering with
primary users. Online search agents in CRNs operate as follows:
1. Perception Phase: The agent senses the radio spectrum to detect available and
occupied channels.
2. Decision-Making Phase: Using machine learning models, the agent predicts the best
channels and power levels for communication.
3. Execution Phase: The agent switches to the selected channel, ensuring minimal
interference.
4. Learning Phase: The agent updates its knowledge base using feedback from its
actions and adjusts future decisions.
Partial Observability: The agent does not always have complete information about
spectrum availability.
Dynamic Environment: The spectrum occupancy changes due to unpredictable
primary user activities.
Exploration vs. Exploitation Dilemma: The agent must balance between learning
new strategies and using known best strategies.
Real-Time Constraints: Decisions must be made quickly to prevent spectrum
wastage.
5. Diagram of Online Search Agent in CRN
import numpy as np
import random
# Q-learning Algorithm
for episode in range(num_episodes):
if random.uniform(0, 1) < epsilon:
action = random.randint(0, num_channels - 1) # Explore
else:
action = np.argmax(Q_table) # Exploit (Best known action)
6. Conclusion
Online search agents are crucial for optimizing resource allocation in unknown
environments like CRNs. They enable efficient and intelligent spectrum access through real-
time sensing, learning, and adaptation. Despite challenges like uncertainty and real-time
decision-making, advanced AI techniques are making these agents more effective in
managing dynamic networks.
1. Introduction
Problem:
Example:
A → 1, B → 2, C → 3
This ensures that no two adjacent stations have the same frequency.
Problem:
Find the best path for data packets while avoiding congestion.
Constraints:
o Avoid overloaded network paths.
o Meet Quality of Service (QoS) requirements like low latency and high
throughput.
Example:
Consider a network with multiple paths between Node A (source) and Node B
(destination):
A CSP-based routing algorithm selects A → Z → B (since it has the lowest latency) but
considers congestion in real-time.
Problem:
Schedule sensor nodes to balance energy consumption and extend network lifetime.
Constraints:
o Only a subset of nodes can be active at a time.
o Coverage of all monitoring areas must be ensured.
Example:
The system uses CSP to activate only 20 sensors at a time, ensuring continuous
monitoring while conserving energy.
If one sensor fails, the CSP solver finds a replacement.
Problem:
Example:
4. Conclusion
1. Introduction
Problem:
Problem:
Find an optimal data routing path to minimize congestion and ensure fast delivery.
Constraints:
o Avoid overloaded network paths.
o Ensure minimum delay.
def path_cost(path):
cost = 0
for i in range(len(path) - 1):
cost += network_paths[path[i]].get(path[i+1], float('inf'))
return cost
🔹 Output Example: Optimized Routing Path: ['A', 'B', 'C', 'D'] with cost: 25
🔹 How It Works: The algorithm iteratively improves the routing path, ensuring minimum
congestion and delay.
5. Conclusion
Both Backtracking Search and Local Search play critical roles in AI-driven
communication systems:
1. Introduction
Problem:
BFS explores all possible routes level by level, ensuring the shortest path is found.
while queue:
path = queue.popleft()
node = path[-1]
if node == goal:
return path
🔹 Output Example: Optimal Routing Path (BFS): ['A', 'B', 'E', 'H']
🔹 Effectiveness: BFS guarantees the shortest path in an unweighted network.
Data packets need to travel from a source to a destination with minimal delay.
Constraint: Different links have different latencies.
Solution: The A* algorithm uses heuristics (e.g., estimated distance) to find the
optimal path.
Implementation Using A*
while queue:
cost, node, path = heapq.heappop(queue)
if node == goal:
return path + [node]
🔹 Output Example: Optimized Routing Path (A*): ['A', 'B', 'E', 'H']
🔹 Effectiveness: A* finds the optimal path efficiently by combining cost evaluation and
heuristics.
Approach Explores all paths level-wise Uses heuristics to guide the search
6. Conclusion
Both uninformed and informed search strategies play a crucial role in AI-driven
communication systems:
Uninformed Search (BFS) is useful for small-scale problems like local network
routing.
Informed Search (A)* is ideal for real-time decision-making in large-scale
networks like 5G and cloud computing.