Shortest path resolution with Excel

Let's use the solver in Excel to find the shortest path from node S to node T in an undirected network (there will be less constraints in a directed network).

Formulate the shortest path problem with Excel

To formulate this shortest way problem with Excel, let's answer the following three questions.

  • What are the decisions to be made? For this problem, we need Excel to find out if an arc is on the shortest path or not (Yes = 1, No = 0). For example, if SB is part of the shortest path, cell F5 is equal to 1. Otherwise, cell F5 is equal to 0. (in yellow)
  • What are the constraints on these decisions? The net flow (Outbound - Inbound) of each node must equal the supply - demand at that node. Node S should only have one outgoing arc (net flow = 1). Node T must have only one incoming arc (net flow = -1). All other nodes must have an outgoing arc and an incoming arc if the node is on the shortest path (net flow = 0) or without flow (net flow = 0). (in light blue)
  • What is the overall measure of performance for these decisions? The overall measure of performance is the total distance of the shortest path, so the goal is to minimize this amount. (in dark blue)
résolution plus court chemin avec excel

Let's name the following ranges:

Beach nameCells
FromB4: B21
ToC4: C21
DistanceD4: D21
GoF4: F21
NetFlowI4: I10
SupplyDemandK4: K10
TotalDistanceF23

And let's insert the following functions:

résolution plus court chemin avec excel

Solve the model

Let’s enter the solver parameters:

résolution plus court chemin avec excel

The optimal solution is:

résolution plus court chemin avec excel
To share
en_GBEN
%d bloggers like this: