Goal-Based and Utility-Based Agents

Planning, Optimization, and Decision-Making Agents

Goal-Based Agents
Plan sequences of actions to achieve specific goals using search algorithms and planning techniques.
Architecture Flow:
Goals + Current State → Planning Algorithm → Action Sequence

plan = search(current_state, goal_state)
execute(plan[next_step])
Planning Algorithms
  • A* Search for optimal pathfinding
  • STRIPS for classical planning
  • Hierarchical Task Networks (HTN)
  • Monte Carlo Tree Search
class GoalBasedAgent: def __init__(self, planner, goal): self.planner = planner self.goal = goal self.plan = [] self.current_step = 0 def act(self, state): if not self.plan or self.goal_achieved(state): self.plan = self.planner.search(state, self.goal) self.current_step = 0 if self.current_step < len(self.plan): action = self.plan[self.current_step] self.current_step += 1 return action return None def goal_achieved(self, state): return self.goal.satisfied(state) # Example: Route planning goal = Location(lat=37.7749, lng=-122.4194) # San Francisco agent = GoalBasedAgent(AStarPlanner(), goal)
Utility-Based Agents
Optimize decisions based on utility functions that measure the desirability of different outcomes and trade-offs.
Architecture Flow:
State + Actions → Utility Function → Expected Utility → Best Action

best_action = argmax(expected_utility(action, state))
Optimization Techniques
  • Expected Utility Maximization
  • Multi-Objective Optimization
  • Markov Decision Processes
  • Game Theory Applications
class UtilityBasedAgent: def __init__(self, utility_function, actions): self.utility_function = utility_function self.actions = actions def act(self, state): best_action = None best_utility = float('-inf') for action in self.actions: expected_utility = self.calculate_expected_utility( action, state ) if expected_utility > best_utility: best_utility = expected_utility best_action = action return best_action def calculate_expected_utility(self, action, state): # Calculate expected utility considering uncertainty total_utility = 0 for outcome, probability in self.get_outcomes(action, state): utility = self.utility_function(outcome) total_utility += probability * utility return total_utility # Example: Investment portfolio optimization def portfolio_utility(portfolio): return portfolio.expected_return - 0.5 * portfolio.risk

Planning and Decision-Making Process

Perceive
Analyze
Plan
Optimize
Execute

Goal-Based Focus

  • Binary goal satisfaction (achieved/not achieved)
  • Optimal path finding to goal state
  • Clear success/failure criteria

Utility-Based Focus

  • Continuous optimization of outcomes
  • Trade-off analysis between competing objectives
  • Handles uncertainty and probabilistic outcomes

Real-World Implementation Examples

Goal-Based: Automated Testing
Agent plans test execution sequence to achieve 100% code coverage goal. Uses dependency analysis to determine optimal test order.
Technologies: pytest, coverage.py, dependency graphs
Goal-Based: CI/CD Pipeline
Orchestrates build, test, and deployment steps to achieve successful release goal. Handles rollbacks and retry logic.
Technologies: Jenkins, GitHub Actions, Docker
Utility-Based: Resource Allocation
Optimizes cloud resource allocation balancing cost, performance, and reliability. Considers multiple competing objectives.
Technologies: Kubernetes, AWS Auto Scaling, cost optimization
Utility-Based: A/B Testing
Dynamically allocates traffic between variants to maximize conversion while minimizing statistical uncertainty.
Technologies: statistical analysis, multi-armed bandits