GNN (graph network)

How the Figures of Neighboring Stores Feed Into the Sales Forecast: Graph Neural Network

A graph neural network forecasts sales in a store network, with message passing between neighboring stores.

A graph neural network (GNN) works on data that is structured as a graph of nodes and connections. This page demonstrates it with ten stores in German cities, all of which sell the same T-shirt. A trained network with 317 parameters estimates sales for the next seven days, and a separate optimization method decides which store passes stock to which other store. The last step shows the net gain that the additional sales bring after freight.

GNN · trained 2 message-passing layers 317 parameters Min-cost flow Retail

At the top, choose the store whose numbers the matrices show, switch on a promotion, and set the selling price and the freight rate. You can also change the store by clicking a node in the graph. “Play” runs the calculation on its own, and the step list takes you to any point.

All computations run in your browser. Teaching example, not a production forecast.

What the Walkthrough Shows and Where It Ends

The walkthrough combines two methods with separate tasks. The graph neural network predicts how many T-shirts each store will sell over the next seven days. It uses the store’s own figures and those of its neighbors in the store network, weighted by distance. A classical optimization method then decides on the stock transfer. The network forecasts, and the optimization method decides.

The network has two layers and 317 parameters. Each layer collects the states of the neighbors, joins them with the store’s own state, and passes both through a learned mapping that sets negative results to zero (ReLU). After two layers, a store also knows the neighbors of its neighbors. The network was trained with PyTorch and AdamW in 2,400 steps on 5,000 synthetically generated scenarios and tested on 1,000 more. Your browser carries out the calculation steps on this page with the trained weights. The training and test metrics come from the training run.

The store data is invented, and the synthetic demand contains the influence of neighboring stores by design. The page therefore does not show that such influences exist in a real store network. The optimization method considers only direct deliveries between connected stores and only variable costs per unit. It does not take safety stock into account. The selling price and cost price of the highest price tier rest on published figures. The freight per unit and the surcharge per kilometer, by contrast, are assumed values without a source. A real store network requires historical sales data, a comparison with simple forecasting methods, and the actual transport conditions.