4. Algorithms applied to the ANDP

This chapter presents the Dynamic Programming approach as alternative methodology to find a global optimal solution cost for the ANDP(≤1) and ANDP(≤2). After we introduce the Dynamic Programming with State-Space Relaxation as a method to obtain lower bounds for the original problem.

#### 4.1 Dynamic Programming

Proposition 4. Given an ANDP ðS; E<sup>1</sup> ∪ E2; AÞ, the cost of a global optimal solution of ΓANDP <sup>≤</sup><sup>1</sup> is given by <sup>f</sup>ðST;Z;A<sup>Q</sup> <sup>Þ</sup>, with <sup>f</sup> <sup>ð</sup>:;:;:<sup>Þ</sup> defined by the following expression of Dynamic Programming:

$$f\_{S\_C}(\mathbf{S}\_T, Z, A^{\mathcal{Q}}) = \left\{ \min\_{\boldsymbol{\mathfrak{s}}\_t \in \mathcal{S}\_T} \left\{ \min\_{\boldsymbol{\mathfrak{s}}\_t \in \mathcal{S}\_T} \left\{ \begin{aligned} \text{COST}(\boldsymbol{\mathfrak{s}}\_t, Z) &+ f\_{\mathcal{S}\_C}(\mathbf{S}\_T[\boldsymbol{\mathfrak{s}}\_t], Z, A^{\mathcal{Q}}), \\ \min\_{\boldsymbol{\mathfrak{s}}\_t \in \mathcal{S}\_C} \left\{ \begin{aligned} \text{COST}(\boldsymbol{\mathfrak{s}}\_t, \boldsymbol{\mathfrak{s}}\_t) + \text{COST}(\boldsymbol{\mathfrak{s}}\_t, Z) + \\ \boldsymbol{f}\_{\mathcal{S}\_C}(\mathbf{S}\_T[\boldsymbol{\mathfrak{s}}\_t], Z, A^{\mathcal{Q}\cup\{\{\boldsymbol{\mathfrak{s}}\_t, Z\}}) \right\} \end{aligned} \right\} \right\} \right\} \tag{3}$$

� � where COSTðs; Z COSTðs; z , sð ; Z and the matrix of connection costs <sup>A</sup><sup>Q</sup> <sup>¼</sup> ai,j is defined by i,j∈E<sup>1</sup> <sup>∪</sup> <sup>E</sup><sup>2</sup> Þ ¼ min<sup>z</sup> <sup>∈</sup><sup>S</sup> COSTðs; z <sup>D</sup> f Þg Þ ¼ argmin f Þg <sup>z</sup> <sup>∈</sup>SD

$$a\_{i,j} = \begin{cases} \text{COST}(i,j) & \text{if } (i,j) \notin \mathcal{Q} \\ \mathbf{0} & \text{otherwise} \end{cases} \tag{4}$$

Proposition 5. Given an ANDP ðS; E<sup>1</sup> ∪ E2; AÞ, the cost of a global optimal solution of ΓANDP <sup>≤</sup><sup>2</sup> is given by <sup>f</sup>ðST;Z;A<sup>Q</sup> <sup>Þ</sup>, with <sup>f</sup> <sup>ð</sup>:;:;:<sup>Þ</sup> defined by the following expression of Dynamic Programming

Applied Mathematics

 8 >>>>>>>>>>>>>>>>>>< 8 >>>>>>>>>>>>>>>< , 9 >>>>>>>>>>>>>>>= , Z, A<sup>Q</sup> COSTðst; <sup>Z</sup>Þ þ <sup>f</sup> SC STf gst , 8 <sup>&</sup>lt; <sup>9</sup> COSTðst; scÞ þ COSTðsc; <sup>Z</sup>Þþ <sup>=</sup> min <sup>ð</sup>sc;<sup>Z</sup> , Z, A sc <sup>∈</sup>SC : <sup>f</sup> <sup>Q</sup> <sup>∪</sup> <sup>f</sup> <sup>Þ</sup> ; SC STf gst <sup>g</sup> min <sup>8</sup>if ST 6¼ <sup>∅</sup> >>>>< 9 >>>>= ST; <sup>Z</sup>; AQ <sup>f</sup> (5) SC <sup>¼</sup> COST st; <sup>s</sup> u <sup>c</sup> st <sup>∈</sup> SC >>>>>>>>>>>>>>>: >>>>>>>>>>>>>>>; <sup>þ</sup> >>>>>>>>>>>>>>>>>>: COST s <sup>u</sup>; s <sup>v</sup> <sup>þ</sup> COST <sup>s</sup> <sup>v</sup> min c c <sup>c</sup>; <sup>Z</sup> <sup>þ</sup> su;sv ð Þ c c <sup>∈</sup>E<sup>2</sup> >>>>: <sup>f</sup> f g, Z, <sup>A</sup><sup>Q</sup> <sup>∪</sup> fð<sup>s</sup> u c c ;s v Þ;ð Þ sc <sup>v</sup>;<sup>Z</sup> g >>>>; SC ST st 0 otherwise

COSTðs; z and the matrix of connection costs <sup>A</sup><sup>Q</sup> <sup>¼</sup> ai,j where COSTðs; Z Þg, sð ; Z Þ ¼ argmin<sup>z</sup> <sup>∈</sup>SD Þ ¼ min<sup>z</sup> <sup>∈</sup><sup>S</sup> fCOSTðs; z <sup>D</sup> f Þg is defined by i,j∈E<sup>1</sup> <sup>∪</sup> <sup>E</sup><sup>2</sup>

$$a\_{i,j} = \begin{cases} \text{COST}(i,j) & \text{if } (i,j) \not\in Q \\ 0 & \text{otherwise} \end{cases} \tag{6}$$

#### 4.2 Dynamic programming with state-space relaxation

 ST; <sup>Z</sup>; <sup>A</sup><sup>Q</sup> In order to find <sup>a</sup> lower bound of <sup>f</sup> SC , the Dynamic Programming with State-Space Relaxation is now applied. It is a general relaxation procedure applied to a number of routing problems [8]. The motivation for this methodology stems from the fact that very few combinatorial optimization problems can be solved by Dynamic Programming alone due to the dimensionality of their statespace. To overcome this difficulty, the number of states is reduced by mapping the state-space associated with a given Dynamic Programming recursion to a smaller cardinality space. This mapping, denoted by g, must associate to every transition from a state S<sup>1</sup> to a state S<sup>2</sup> in the original state-space, a transition g Sð Þ<sup>1</sup> to g Sð Þ<sup>2</sup> in the new state-space. To be effective, the function g must give rise to a transformed recursion over the relaxed state-space which can be computed in polynomial time. Furthermore, this relaxation must generate a good lower bound for the original problem.

With the aim of illustrating this methodology, we present this approach in the context of the minimization of the total schedule time for the Traveling Salesman Problem with Time Window (TSPTW), after we apply it to the Dynamic Programming recursion presented in Proposition 5. The objective of the TSPTW is to find an optimal tour where a single vehicle is required to visit each of a given set of locations (customers) exactly once and then return to its starting location. The vehicle must visit each location within a specified time window, defined by an earliest service start time and latest service start time. If the vehicle arrives at a service location before the earliest service start time, it is permitted to wait until the earliest service start time is reached. The vehicle conducts its service for a known period of time and immediately departs for the location of the next scheduled customer. Assume that the time constrained path starts at fixed time value ao. Define F Sð ; iÞ as the shortest time it takes for a feasible path starting at node o, passing through every node of S⊆N exactly once, to end at node i∈ S. Note that optimization of the total arc cost would involve an additional dimension to account for the arrival time at a node. The function F Sð ; iÞ can be computed by solving the following recurrence equations:

$$F(\mathcal{S}, j) = \min\_{(ij) \in E} \left\{ F(\mathcal{S} - \{j\}, i) + t\_{\vec{\eta}} \middle| i \in \mathcal{S} - \{j\} \right\} \forall \mathcal{S} \subseteq \mathcal{N}, j \in \mathcal{S} \tag{7}$$

Topological Properties and Dynamic Programming Approach for Designing the Access Network DOI: http://dx.doi.org/10.5772/intechopen.86223

The recursion formula is initialized by

$$F(\{j\}, j) = \begin{cases} \max\{a\_j, a\_o + t\_{oj}\} & \text{if } (o, j) \in E \\ & +\infty & \text{otherwise} \end{cases} \tag{8}$$

The optimal solution to the TSPTW is given by

$$\min\_{j \in N} \left\{ F(N, j) + t\_{jd} \right\} \tag{9}$$

Note that Eq. (7) is valid if aj ≤F Sð ; jÞ≤ bj: If however F Sð ; jÞ<aj, then F Sð ; jÞ ¼ aj; if F Sð ; jÞ>bj, F Sð ; jÞ ¼ ∞. Equations (7) and (9) define a shortest path algorithm on a state graph whose nodes are the states ðS; iÞ and whose arcs represent transitions from one state to another. This algorithm is a forward Dynamic Programming algorithm where at step s, with s ¼ 1, …, n þ 1, a path of length s is generated. The state ðS; iÞ of cost F Sð ; iÞ are defined as follows: S is an unordered set of visited nodes and i is the last visited node, i ∈S.

Several alternatives for the mapping g have been suggested [9]. Here is presented the shortest r-path relaxation, i.e., g Sð Þ ¼ r ¼ ∑<sup>i</sup> <sup>∈</sup><sup>S</sup>ri, where ri ≥1 is an integer associated with node i∈ N; then g Sð f gi Þ ¼ g Sð Þ � ri. Define R ¼ ∑<sup>i</sup>∈<sup>S</sup>ri. Hence the transformed recursion equations are

$$F(r,j) = \min\_{(i,j)\in E} \left\{ F(r - r\_j, i) + t\_{\vec{\eta}} \middle| r - r\_j \ge r\_i \right\}, r \in \{1, \ldots, R\}, j \in N \tag{10}$$

Recursion (10) holds if aj ≤F rð ; jÞ≤bj. Otherwise, if F rð ; jÞ<aj, then F rð ; jÞ ¼ aj; if F rð ; jÞ>bj, Fðr; jÞ ¼ ∞. The recursion formula is initialized by

$$F(\{j\}, j) = \begin{cases} \max\{a\_j, a\_o + t\_{\neq}\} & \text{if } (o, j) \in E \text{ and } q = q\_j \\ & + \text{inyty} \\ \end{cases} \tag{11}$$

The lower bound is given by

$$\min\_{j \in N} \left\{ F(R, j) + t\_{jd} \right\} \tag{12}$$

� � The complexity of the bounding procedure is O n<sup>ð</sup> <sup>2</sup> � <sup>Q</sup><sup>Þ</sup> for <sup>a</sup> <sup>n</sup>-node problem. Now, we present this approach in the context of finding a "good" lower bound for the solution of ANDP(≤2) presented in Proposition 5 (the optimum value of the ANDP(≤2)). . The following proposition gives a lower bound for the ST; <sup>Z</sup>; AQ <sup>f</sup> SC

� � ST; <sup>Z</sup>; AQ Proposition 6. Given an ANDP <sup>ð</sup>S; <sup>E</sup><sup>1</sup> <sup>∪</sup> <sup>E</sup>2;CÞ, <sup>a</sup> lower bound of <sup>f</sup> SC is derived from the following expression of Dynamic Programming with State-Space Relaxation

� � � � � � � � � � � � � � � � � � � � 8 >>>>>>>>>>>>>>>>>>< 9 >>>>>>>>>>>>>>>>>>= <sup>þ</sup> gSC <sup>r</sup> � ri; <sup>Z</sup>; <sup>A</sup><sup>Q</sup> , <sup>8</sup> >>>>>>>>>>>>>>>>>>>>< i <sup>t</sup> COST s ; Z <sup>i</sup> <sup>j</sup> <sup>j</sup> COST st ; sc <sup>þ</sup> COST sc; <sup>Z</sup> <sup>þ</sup> <sup>8</sup> >< 9 >= min , <sup>j</sup> <sup>c</sup> <sup>∈</sup>SC >: fð Þ <sup>j</sup> <sup>c</sup>;<sup>Z</sup> >; <sup>r</sup> � ri; <sup>Z</sup>; <sup>A</sup> <sup>s</sup> <sup>Q</sup> <sup>∪</sup> <sup>g</sup> <sup>∣</sup><sup>r</sup> � <sup>R</sup>^ � ri <sup>≥</sup>rj <sup>s</sup> gSC min if ST 6¼ <sup>∅</sup> <sup>i</sup> t ; s j j <sup>c</sup>; s <sup>k</sup> <sup>k</sup> 8 >>>>>< 9 >>>>>= <sup>r</sup>; <sup>Z</sup>; <sup>A</sup> (13) <sup>Q</sup> <sup>¼</sup> <sup>s</sup> i ∈ST >>>>>>>>>>>>>>>>>>: >>>>>>>>>>>>>>>>>>; gSC <sup>t</sup> COST <sup>þ</sup> COST <sup>s</sup> <sup>þ</sup> COST sc <sup>&</sup>gt; <sup>s</sup> ; <sup>Z</sup> <sup>þ</sup> >>>>>>>>>>>>>>>>>>>: c c <sup>j</sup> ð Þk k <sup>c</sup> min ;<sup>s</sup> <sup>r</sup> � ri; <sup>Z</sup>; <sup>A</sup><sup>Q</sup> <sup>∪</sup> <sup>f</sup> <sup>s</sup> ;ð Þ <sup>s</sup> ;<sup>Z</sup> <sup>g</sup> <sup>g</sup> <sup>∣</sup> SC <sup>c</sup> <sup>c</sup> ju <sup>ð</sup><sup>s</sup> ;sk <sup>c</sup> <sup>c</sup> <sup>Þ</sup><sup>∈</sup>E<sup>2</sup> >>>>>: >>>>>; <sup>r</sup> � <sup>R</sup>^ � ri <sup>≥</sup>rj <sup>þ</sup> rk 0 otherwise

where <sup>1</sup>≤ri <sup>≤</sup><sup>R</sup> is an integer associated with the site <sup>i</sup> <sup>∈</sup>ST <sup>∪</sup> SC, <sup>R</sup> <sup>¼</sup> <sup>∑</sup><sup>i</sup>∈ST <sup>∪</sup> SC ri, ˜ ° <sup>R</sup>^ <sup>¼</sup> <sup>∑</sup><sup>j</sup>∈SC rj and the matrix of connection costs <sup>A</sup><sup>Q</sup> <sup>¼</sup> ai,j i,j∈E<sup>1</sup> <sup>∪</sup> <sup>E</sup><sup>2</sup> is defined by

$$\mathfrak{a}\_{i,j} = \begin{cases} \text{COST}(i,j) & \text{if } (i,j) \not\in \mathcal{Q} \\ \mathbf{0} & \text{otherwise} \end{cases} \tag{14}$$

The lower bound is given by <sup>g</sup> <sup>R</sup>;Z;A<sup>∅</sup> . ð Þ
