Overview

7 Monte Carlo Tree Search: Searching with Reinforcement Learning Principles

Monte Carlo Tree Search is presented as a practical way to reason through complex sequential decisions by building and searching a tree of possible futures. The chapter starts with the idea that many real business problems, especially routing and planning tasks, naturally form branching decision structures: each choice creates new downstream possibilities, and trees provide a clear way to model those options. A simple routing example is used to show how nodes, branches, and leaf outcomes can represent operational states, candidate actions, and final costs, setting the stage for more intelligent search methods.

The chapter then explains why basic tree search methods are useful but limited. Breadth-first search systematically checks shallow possibilities first and can find short solutions, but it becomes memory-heavy and expensive as the number of routes grows. Depth-first search is more memory-efficient and dives deeply into one branch, but it can miss better alternatives and still struggles with large spaces. These limitations motivate Monte Carlo Tree Search, which avoids exhaustive enumeration by selectively exploring promising branches, using a balance of exploration and exploitation rather than trying every option equally.

MCTS is then developed as a four-step loop: selection, expansion, simulation, and backpropagation. Selection uses UCB1 to choose branches that either perform well or remain underexplored, expansion adds one new child at a time, simulation completes partial solutions with a rollout policy, and backpropagation updates visit counts and rewards along the path. The chapter applies this framework to the capacitated vehicle routing problem, showing how problem state, feasible actions, route cost, and local improvement can all be encoded in code. The result is a hybrid optimizer that combines global search with local refinement, producing strong practical solutions without needing to examine every possible route.

Tree data structure in vehicle route planning problem
Tree data structure in vehicle route planning problem
Breadth-First Search (BFS) algorithm and flow.
Breadth-First Search (BFS) algorithm and flow.
Depth-First Search (DFS) algorithm and flow.
Depth-First Search (DFS) algorithm and flow.
The four-phase cycle of Monte Carlo Tree Search.
The four-phase cycle of Monte Carlo Tree Search.
UCB1 algorithm for node selection in MCTS.
UCB1 algorithm for node selection in MCTS.
Capacitated Vehicle Routing Problem (CVRP) schema.
Capacitated Vehicle Routing Problem (CVRP) schema.
Results of running MCTS for CVRP problem.
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 method that builds a decision tree gradually by simulating possible futures. Instead of checking every option exhaustively, it focuses on promising branches while still exploring new ones. It combines sampling, planning, and learning to find strong solutions efficiently.
Why is a tree data structure useful for planning problems like vehicle routing?A tree helps represent decisions as branching choices. The root is the starting state, each child is a possible next action, and each leaf is a complete outcome. This makes complex sequential decisions easier to model, search, and compare.
How do BFS and DFS differ when searching a decision tree?BFS explores level by level, checking all shallow options before going deeper. DFS follows one branch as far as possible before backtracking. BFS is complete and finds shortest paths in equal-cost settings, while DFS uses less memory but may find suboptimal solutions first.
Why do BFS and DFS struggle on large routing problems?Because the number of possible routes grows exponentially as customers increase. BFS can become too memory-intensive, and DFS may take too long or miss better solutions early. Both become impractical for large combinatorial problems.
What are the four phases of MCTS?The four phases are Selection, Expansion, Simulation, and Backpropagation. Selection chooses a promising node, Expansion adds a new child, Simulation completes a rollout to estimate value, and Backpropagation updates statistics along the path.
How does MCTS balance exploration and exploitation?MCTS uses the UCB1 formula during selection. The exploitation term favors actions that already look good, while the exploration term gives a bonus to less-visited actions. This balance helps the algorithm avoid getting stuck and still learn from promising branches.
What is the role of simulation in MCTS?Simulation estimates the value of a partial solution by completing it with a fast rollout policy. In routing problems, this often means greedily or randomly selecting the remaining customers until a full route is formed. The result gives feedback about how promising that branch is.
How is backpropagation used in MCTS?After a simulation finishes, its reward is propagated back up the tree from the expanded node to the root. Each node on the path updates its visit count and accumulated reward. This lets future selections use more informed statistics.
How is the Capacitated Vehicle Routing Problem (CVRP) represented in this chapter?CVRP is represented as a state with routes for each vehicle, a set of unvisited customers, and the current vehicle being filled. The model also checks whether adding a customer respects vehicle capacity and computes total route distance as the objective.
Why is MCTS effective for CVRP and similar business optimization problems?MCTS is effective because it searches selectively instead of exhaustively. It can work with constraints, use simulation to estimate future outcomes, and improve solutions over time. This makes it suitable for large real-world planning problems where exact search is too expensive.

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


Close
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 Applied Reinforcement Learning ebook for free
Close
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 Applied Reinforcement Learning ebook for free