In this section, we describe an approach of finding and canceling negative cycles in order to solve WCP heuristically. The main idea of our heuristic is to repeatedly set up a residual graph from a flow, finding a negative cycle, and cancel negative cycles in the residual graph. Every cancellation yields a better solution to WCP. In the first part, we give an overview of our heuristic. Whereas in the second part, we describe the components used in the heuristic in more detail.
Algorithmic overview
Before we describe the algorithm, we introduce essential graph theoretical terms. We define a walk from u to w as a sequence of—not necessarily distinct—edges ((u,v1)=:e0,e1,…,ek:=(vk,w)) such that the end vertex of ei−1 is the same as the start vertex of ei for i∈{1,…,k}. A walk is closed if u=w and it is side-trip free if ei is not the reverse edge of ei−1 for all i∈{1,…,k}, i.e., the walk does not contain a closed subwalk of length 2. Closed walks where the end vertices of all edges are distinct are called cycles.
Given a wind farm \(\mathcal {N}\) we first compute an initial feasible flow f (Lines 2–4; all line references in this section refer to Algorithm 1). For each turbine u∈VT we perform a breadth-first search from u ignoring all edges and substations without free capacity. When the search finds a substation for the first time, the flow on the path from u to the substation is increased by 1. Starting with this initial flow, we iteratively identify simple changes of the flow that decrease the costs.
In each iteration of the heuristic, we set up the residual graph R (Line 8), which we define as follows. We denote the underlying directed graph of the wind farm \(\mathcal {N}\) by G as defined in the “Model” section. We set V(R)=V(G)∪{s} and E(R)=E(G)∪{(u,v):(v,u)∈E(G)}∪{(u,s),(s,u):u∈VS}, where s is a special vertex representing a super substation.
Let f be the flow computed in the previous iteration and \(\Delta \in \mathbb {N}\) with initialization shown in Lines 5 and 7. In addition, we define the cost function \(\gamma \colon E (R) \to \mathbb {R}\) as explained below. We then search for a closed side-trip-free walk with negative total costs in R (Line 9). To this end, we use a slight adaptation of the Bellman-Ford Algorithm. If there is no such walk, we increment Δ and set up a new residual graph. Otherwise, if there is such a walk W in R, we split W into cycles C1,…,Cl. Figure 1 shows an example of this decomposition into cycles. We check for each cycle Ci whether its total costs are negative and whether Ci has length at least 3 (Line 11). If both conditions hold, we cancel Ci (see Eq. 6 and Line 12). Note that the cost function γ is defined in such a way that cycles that decrease the cost have negative total costs. We cancel C by changing the flow f by Δ along C. More formally, we define a new flow f′ for all (u,v)∈E(G) by
$$ f^{\prime} (u, v) = \left\{ \begin{array}{ll} f(u, v) + \Delta, & \text{if}\ (u, v) \in E(C)\text{,} \\ f(u, v) - \Delta, & \text{if}\ (v, u) \in E(C), \\ f(u, v), & \text{if}\ (u, v),(v, u) \not\in E(C). \end{array}\right. $$
(6)
Here, E(C) denotes the set of edges that form the cycle C; see Fig. 2 for an example of canceling a cycle.
Note that if a cycle has length exactly 2, it consists of an edge (u,v) and its reverse (v,u). Hence, canceling it means sending Δ units in both directions specified by (u,v) and (v,u), which does not change the flow. Canceling it would result in an infinite loop in Line 10.
Finally, if at least one cycle Ci in W was canceled, we reset Δ to 1 and build a new residual graph based on the new flow after the cycle cancellation in the current iteration. The heuristic terminates once it does not cancel a negative cycle in the residual graphs of the currently cheapest feasible flow for all values of Δ.
The residual costs
The description above assumes a cost function γ on the residual graph R such that negative cycles in R correspond to cycles that decrease the costs of the flow if they are canceled. We define γ in this section.
Let f be a feasible flow in \(\mathcal {N}\) and \(\Delta \in \mathbb {N}\). We define \(\gamma \colon E (R) \to \mathbb {R} \cup \{\infty \}\) such that canceling a cycle with negative costs, i.e., a cycle C with \(\sum _{e\in E(C)}\gamma (e) < 0\), preserves feasibility and reduces the total costs. Consider an edge (u,v)∈E(G). Intuitively, γ(u,v) represents the change of costs for the original flow f(u,v) if additional Δ units are sent from u to v. More formally, if both u and v are turbines, the costs of the corresponding edges in the residual network R are defined by
$$\begin{array}{*{20}l} \gamma(u, v) &= \Big(\mathrm{c}\big(f(u, v) + \Delta \big)-\mathrm{c}\big(f(u, v)\big)\Big) \cdot \text{len}(u, v), \end{array} $$
(7)
$$\begin{array}{*{20}l} \gamma(v, u) &= \Big(\mathrm{c}\big(f(u, v) - \Delta \big)- \mathrm{c}\big(f(u, v)\big)\Big) \cdot \text{len}(u, v). \end{array} $$
(8)
Note that by this definition if f(u,v)+Δ or −f(v,u)+Δ exceeds the largest non-trivial cable capacity, we define γ(u,v)=∞ or γ(v,u)=∞, respectively. If one of the vertices, say v, is a substation, we define the costs in the same way unless f(u,v)<Δ. In this case, we define γ(v,u)=∞ to ensure that no flow leaves the substation (see Eq. 4). Therefore, we have γ(v1,u1)=∞ in Fig. 2. For the edges between a substation w and the super substation s we define γ(w,s)=0 if fnet(w)+Δ≤capsub(w), and γ(w,s)=∞ otherwise. This ensures that the substation capacity will not be exceeded (see Eq. 3). In Fig. 2 the substation v2 has reached its capacity and hence we set γ(v2,s)=∞. For the reverse edge, we set γ(s,w)=0 if Δ≤fnet(w) and γ(s,w)=∞ otherwise, which makes sure that w has a non-negative net flow. As v1 has no incoming flow in Fig. 2, the residual cost γ(s,v1) is set to ∞.
Clearly, the cost function γ on R can have negative values since it is possible that after a change of flow by Δ a cheaper cable type suffices for the new flow. Hence, cycles of negative total costs can exist in R. By the definition of γ, it holds for any cycle C in R with finite costs that the flow f′ obtained from f by canceling C is feasible. Moreover, we have
$$ \text{cost}(\mathcal{N}, f^{\prime}) = \text{cost}(\mathcal{N}, f) + \sum_{e \in E(C)} \gamma(e). $$
(9)
Hence, if C has negative total costs, f′ incurs less cost than the previous flow f.