Overview

7 Monte Carlo Tree Search: Searching with Reinforcement Learning Principles

Monte Carlo Tree Search is presented as a practical way to make sequential decisions when the full search space is far too large to inspect exhaustively. The chapter frames decisions like vehicle routing as a branching tree, where each state leads to new choices and each complete path represents a candidate solution. It first builds the intuition for trees as hierarchical structures that capture planning problems, then shows how basic search methods such as breadth-first and depth-first search work, along with their strengths and limitations. These classical methods help explain why a smarter, sampling-based approach is needed for complex optimization problems.

The core of the chapter is the MCTS framework, which combines ideas from Monte Carlo simulation, planning, and reinforcement learning. Instead of exploring every branch equally, MCTS repeats a four-step loop: selection, expansion, simulation, and backpropagation. Selection uses the UCB1 rule to balance exploration and exploitation, expansion adds one new branch at a time, simulation completes the partial solution with a rollout policy, and backpropagation updates statistics so future choices improve. This creates a search process that concentrates computation on the most promising parts of the tree while still keeping weaker or less visited options in play.

The chapter then applies MCTS to the capacitated vehicle routing problem, where multiple vehicles must serve customers without exceeding capacity constraints while minimizing total travel distance. It shows how to represent the problem state, define legal actions, compute route cost, and integrate heuristic improvements such as a greedy rollout policy and 2-opt local search. The implementation demonstrates how MCTS can gradually improve solutions over many iterations, achieving strong practical results on a difficult combinatorial problem. Overall, the chapter emphasizes that effective reinforcement learning for business problems often comes from combining several paradigms rather than relying on one method alone.

Tree data structure in vehicle route planning problem
Breadth-First Search (BFS) algorithm and flow.
Depth-First Search (DFS) algorithm and flow.
The four-phase cycle of Monte Carlo Tree Search.
UCB1 algorithm for node selection in MCTS.
Capacitated Vehicle Routing Problem (CVRP) schema.
Results of running MCTS for CVRP problem.

Summary

  • Trees are hierarchical data structures where each node connects to children through parent-child relationships.
  • A tree is, mathematically, a connected, directed acyclic graph with no loops, ensuring a unique path exists from root to any node.
  • Breadth-First Search (BFS) explores trees level by level using a FIFO queue, guaranteeing the shortest path but consuming significant memory.
  • Depth-First Search (DFS) explores one branch completely before backtracking using a LIFO stack (often implemented via recursion), using less memory but not guaranteeing shortest paths.
  • Both BFS and DFS struggle with exponential growth in routing problems—with 10 customers there are 3.6 million possible routes, making exhaustive search infeasible.
  • MCTS intelligently balances exploration (trying new branches) and exploitation (focusing on promising paths) rather than exhaustively searching every possibility.
  • MCTS blends sampling from Monte Carlo simulation, state-action-value structure from MDPs, planning discipline from dynamic programming, and incremental updates from temporal-difference learning.
  • MCTS operates in four phases iteratively: Selection (navigate tree), Expansion (add new node), Simulation (complete solution), and Backpropagation (update statistics).
  • Selection navigates down the tree using UCB1 at each level until reaching a node with unexplored actions or a terminal state.
  • Expansion adds one new child node per iteration by trying an untried action, building the tree incrementally guided by selection.
  • Simulation completes a partial solution from the expanded node using a rollout policy (often random or greedy), providing an outcome estimate without perfect planning.
  • Backpropagation walks from the expanded node to root, updating visit counts and total rewards at each node along the path, enabling statistical learning.
  • Modern practitioners don't dogmatically choose one paradigm but understand when each fits and how to combine them, as MCTS itself demonstrates by synthesizing multiple approaches.
  • MCTS represents pragmatic reinforcement learning—embracing both computational power and limitations, using intelligent exploration with simulation-based evaluation to find high-quality solutions in reasonable time.

FAQ

What is Monte Carlo Tree Search (MCTS) in simple terms?MCTS is a search algorithm that builds a decision tree incrementally by repeatedly selecting promising branches, expanding new nodes, simulating outcomes, and backpropagating the results. It balances exploration of new options with exploitation of options that already look good.
Why is a tree data structure useful for planning problems?A tree represents decisions as branches from a root state to possible future states. This makes it easier to model, analyze, and search through sequential choices such as routing, scheduling, and game moves.
How do BFS and DFS differ in tree search?BFS explores the tree level by level using a queue, while DFS explores one branch deeply before backtracking using a stack or recursion. BFS is complete and can find shortest paths in unweighted settings, but it uses more memory; DFS uses less memory but may find a poor solution first.
Why do BFS and DFS struggle on large vehicle routing problems?Both methods grow exponentially as the number of customers increases. BFS becomes memory-heavy because it stores many partial routes, while DFS may explore deep but suboptimal paths before finding a good solution. Neither scales well for large CVRP instances.
What are the four phases of MCTS?The four phases are Selection, Expansion, Simulation, and Backpropagation. Selection chooses a promising path, Expansion adds a new node, Simulation completes a rollout to estimate quality, and Backpropagation updates the statistics along the path.
What is the role of UCB1 in MCTS?UCB1 is used during selection to balance exploitation and exploration. It favors nodes with high observed reward while also giving a bonus to less-visited nodes, so promising but underexplored branches still get tested.
How does MCTS apply to the Capacitated Vehicle Routing Problem (CVRP)?In CVRP, each tree node represents a partial routing solution. MCTS chooses which customer to add next or when to switch vehicles, checks capacity constraints, simulates a full route, and uses the result to improve future decisions.
Why does MCTS use simulation instead of exhaustive search?Exhaustive search is impractical because the number of possible routes grows factorially. MCTS instead samples a small number of rollouts from promising states, which gives useful feedback without evaluating every possible route.
What is backpropagation in MCTS?Backpropagation is the step where the reward from a simulation is propagated back up the tree. Each node on the selected path updates its visit count and total reward, helping future selections make better choices.
Why is MCTS often combined with heuristics like greedy rollout or 2-opt local search?Heuristics improve the quality of simulated solutions and final routes. A greedy rollout quickly produces decent completions, and 2-opt can refine routes by removing inefficient crossings, making MCTS both globally exploratory and locally effective.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Applied Reinforcement Learning ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Applied Reinforcement Learning ebook for free