Conquering all metro stations using Pyomo

Conquering all metro stations using Pyomo

Metro-hopping refers to the act of traveling on a metro system, visiting different stations in a quick and efficient manner. It is like a game or challenge where the goal is to visit as many stations as possible in a short amount of time. Metro-hopping can be seen as an adventure or a way to explore different parts of a city. It is a fun and exciting activity for those who enjoy public transportation and want to experience the thrill of navigating through a metro network.

I was thinking about how to use mathematical optimization to do this as fast as possible. For this reason, I chose Budapest's metro network (not hard to guess why).

No alt text provided for this image

The idea is to start from one station and visit all stations in a continious tour (no need to return to the starting station).

Mathematical formulation

No alt text provided for this image

  1. Defines the objective function as the total travelled distance
  2. Just one stations should be selected as the starting station
  3. At each step k, only one move should happen
  4. out_ik shows if it moves out of node i in step k
  5. ent_ik shows if it moves into the node i in step k
  6. Every node should be either starting node or should be visited at ant step
  7. we can go out of node i in step k only if we entered the same node in step k-1
  8. in step k=1 we go out of starting node

  • U_ijk is a binary variable indicating the move from node i to node j in step k
  • Start_i is a binary variable indicating if the node i is the starting node
  • out_ik a real variable indicating if we move out of node i in step k
  • ent_ik a real variable indicating if we move into node i in step k
  • i,j are the set of nodes
  • k is the set of steps

Pyomo Code

No alt text provided for this image

Results

No alt text provided for this image

There are several observations in this problem :

  • This is not a TSP model. Some nodes will be visited more than once. This will stop us from using famous MTZ formulation
  • The number of required steps for creating the countinious tour is not know in advance. Considering a small k will result in infeasibility and considering it so big will cause computation burden.
  • The starting point is important in finding the optimal shortest path problem (it's better to be determined by the model)
  • Equation 3 can be expressed as follows:
  • forall k <=N ----->. sum_ij Uijk = 1
  • forall k > N ----->. sum_ij Uijk <= 1
  • This is because we already know that at least N steps are required for creating this tour

The Pyomo code is available on the?Github?, you can support this newsletter by giving a star to it.

Sayyed Mohammadreza Sadatian

Electrical Engineer at IGTC

1 年

PyomoChannel

Mark L. Stone

Optimal Decision Analytics Expert

1 年

The high level objective description seems to be based on overall time, but the MILP formulation is based on distance. Overall time may have a large component of waiting time, which may be stochastic, and dynamic (probability distribution depending on time of day), with the travel tmes on various parts of the network being probabiilisticlaly dependent. The data gathering and problem formulation will be more challenging than for distance objective, but more meaningful to the problem nominally being addressed. if your route saves some distance, but incurs large waiting times between legs, that might not be "optimal".

samira salahi

PHD Candidate at univercity of kurdistan

1 年

PyomoChannel

Manfred Weis

Dipl.Math., Data Scientist at Garmin Würzburg GmbH, Germany

1 年

I always appreciate your nice stories related tosolving combinatorial problems with pyomo. Just as a remark: the current problem can be reduced to the TSP essentially by using directed connections between subsequent stations, e.g. connecting station A to station B, as nodes (AB in a different graph; the edges in that graph corespond to triplets of stations (AB,BC); if B is a dead end station, then we add (AB,BA) as an edge.

Christian D. Dinga

PhD candidate at TU Delft

1 年

Absolutely interesting! I would love to see you implement an example of GDP in pyomo (e.g., Unit commitment problem of generators)

要查看或添加评论,请登录

Alireza Soroudi, PhD的更多文章

社区洞察

其他会员也浏览了