3.7.151. Metro

modelling: metro A constraint that can be used for modelling the metro problem, i.e., finding the shortest distance from a given metro station to all other stations of the network.

Given an undirected graph G=(V,E), with a non-negative distance attached to each edge of E, a conjunction of 𝚕𝚎𝚚_𝚌𝚜𝚝 constraints was used by H. Simonis in order to illustrate how propagation for such a conjunction simulates a naïve version of Dijsktra algorithm for computing the shortest distance from a given vertex v s of V to all other vertices. The potential source of inefficiency comes from the fact that, depending on the scheduling policy of the underlying constraint engine, an inequality constraint can be reconsidered several times before reaching the fixed point. The problem was modelled in the following way:

  • To each vertex v i V we associate a distance variable D i , which represents the domain range of the distance between vertex v i and vertex v s .

  • To each edge (v i ,v j )E we impose two inequality constraints D i D j +d i,j and D j D i +d i,j , where d i,j corresponds to the distance attached to edge (v i ,v j ). This restricts the maximum difference between the distances variables associated with the two extremities of edge (v i ,v j ).

  • Finally, we set the distance variable attached to vertex v s to 0. Propagating the inequalities constraints by using arc-consistency enforces the maximum value of each distance variable D i to be equal to the shortest distance from vertex v i to v s when the fixed point is reached.

Figure 3.7.41. A metro map composed of four lines (a blue, a pink, a green and a yellow line) and the corresponding minimum and maximum values of the distance variables attached to each station, under the assumptions (1) that the distance attached to each connection is equal to 1 and (2) that we compute the shortest path from station i (in red); the font size used for displaying the bounds of a distance variable is inversely proportional to the length of the shortest path to station i.

Figure 3.7.41 illustrates this problem on a metro map composed of four lines and 18 stations respectively labelled by a, b, , r. Its assumes that the distance associated with each connection is equal to 1. The figure displays the status (i.e., the minimum and maximum values) of the distance variables under the assumption that we want to compute the shortest path from station i. The inequalities constraints between the distance variables D a ,D b ,,D r corresponding to this metro map are:

  • (constraints attached to the connections of the blue metro line)

    •   D a D b +1,

    •   D b D c +1,

    •   D c D d +1,

    •   D d D e +1,

    •   D e D f +1,

    •   D f D a +1,

    •   D b D a +1,

    •   D c D b +1,

    •   D d D c +1,

    •   D e D d +1,

    •   D f D e +1,

    •   D a D f +1.

  • (constraints attached to the connections of the pink metro line)

    •   D g D f +1,

    •   D f D h +1,

    •   D h D c +1,

    •   D c D i +1,

    •   D i D j +1,

    •   D f D g +1,

    •   D h D f +1,

    •   D c D h +1,

    •   D i D c +1,

    •   D j D i +1.

  • (constraints attached to the connections of the green metro line)

    •   D p D q +1,

    •   D q D r +1,

    •   D r D a +1,

    •   D a D h +1,

    •   D h D d +1,

    •   D q D p +1,

    •   D r D q +1,

    •   D a D r +1,

    •   D h D a +1,

    •   D d D h +1.

  • (constraints attached to the connections of the yellow metro line)

    •   D k D l +1,

    •   D l D m +1,

    •   D m D a +1,

    •   D a D n +1,

    •   D n D o +1,

    •   D o D i +1,

    •   D l D k +1,

    •   D m D l +1,

    •   D a D m +1,

    •   D n D a +1,

    •   D o D n +1,

    •   D i D o +1.