Exploration through Generation: Applying GFlowNets to Structured Search
Mark Phillip Matovic
TL;DR
This work investigates the applicability of Generative Flow Networks (GFlowNets) to canonical graph optimization problems—Shortest Path, Minimum Spanning Tree, and Traveling Salesperson—by learning sequential policies trained with Trajectory Balance. A unified GFlowNet framework is proposed, combining problem-specific state representations, action masking, and a TB loss to ensure generated complete solutions have probability proportional to their inverse cost, yielding optimal solutions on benchmark instances. Key contributions include demonstrating a single architecture across problems of varying complexity, effectively enforcing combinatorial constraints, and analyzing the trade-offs between upfront training and amortized inference. The findings show that GFlowNets can recover classical optima on small instances and highlight scalability challenges and the need for graph-aware architectures to extend to larger, real-world problems. Overall, the work positions GFlowNets as a promising, complementary approach to classical algorithms for scalable combinatorial optimization under sufficient computational resources.
Abstract
This work applies Generative Flow Networks (GFlowNets) to three graph optimization problems: the Traveling Salesperson Problem, Minimum Spanning Tree, and Shortest Path. GFlowNets are generative models that learn to sample solutions proportionally to a reward function. The models are trained using the Trajectory Balance loss to build solutions sequentially, selecting edges for spanning trees, nodes for paths, and cities for tours. Experiments on benchmark instances of varying sizes show that GFlowNets learn to find optimal solutions. For each problem type, multiple graph configurations with different numbers of nodes were tested. The generated solutions match those from classical algorithms (Dijkstra for shortest path, Kruskal for spanning trees, and exact solvers for TSP). Training convergence depends on problem complexity, with the number of episodes required for loss stabilization increasing as graph size grows. Once training converges, the generated solutions match known optima from classical algorithms across the tested instances. This work demonstrates that generative models can solve combinatorial optimization problems through learned policies. The main advantage of this learning-based approach is computational scalability: while classical algorithms have fixed complexity per instance, GFlowNets amortize computation through training. With sufficient computational resources, the framework could potentially scale to larger problem instances where classical exact methods become infeasible.
