Less Carbon Footprint in Edge Computing by Joint Task Offloading and Energy Sharing

We address reducing carbon footprint (CF) in the context of edge computing. The carbon intensity of electricity supply largely varies spatially as well as temporally. We consider optimal task scheduling and offloading, as well as battery charging to minimize the total CF. We formulate this optimization problem as a mixed integer linear programming model. However, we demonstrate that, via a graph-based reformulation, the problem can be cast as a minimum-cost flow problem, and global optimum can be admitted in polynomial time. Numerical results using real-world data show that optimization can reduce up to 83.3% of the total CF.


I. INTRODUCTION
The current carbon footprint (CF) in information and communications technology (ICT) sector could be as high as 2.1% to 3.9% of the total figure [1].For Europe, for example, the baseline is 2% [2].The authors of [3] list four potential measures that can significantly help reduce the CF due to ICT, one of which is edge computing.
The edge servers consume substantially less energy than conventional cloud data centers, though they need to be densely deployed.For green edge computing, research has been conducted for better design of networks [4], including dynamic right-sizing, geographical load balancing, and the use of renewable energy.However, most works with respect to green edge computing consider energy consumption or efficiency as the objective function, rather than CF explicitly.
Lower energy consumption contributes to reducing CF, however they are not equivalent.For example, in an edge computing network consisting of uniform servers and task distribution, considering only energy consumption would render task offloading useless (which itself would cost energy).However, as the CF intensity differs by time and space, offloading does help.We show a US domestic carbon intensity (CI) data set and another data set for three counties in Europe in Table I [5].As we can see, there are large differences between spaces and time.For example, the CI in Oregon is five times higher than that in Washington.Also, The CI in Oregon at 24:00 is 31.7%less than that at 08:00.The variation is due to the difference in the availability of various power sources over time and space.This motivates us to use the spatial and temporal information of CI to reduce CF by optimal task offloading and scheduling.Examining the current literature, we highlight the following contributions.The studies in [6]- [11] have addressed CF in edge computing or fog computing.The authors of [6] provide a model that can estimate the CF in distributed data centers.Their results show that the total CF of a set of distributed small data centers is less than that from a big data center with equivalent compute capability.The authors of [7] provide a Lyapunov-based algorithm for a distributed data center to minimize electricity cost subject to CF limit.In [8], the authors consider minimizing the CF for video streaming in fog computing networks.In addition, the studies in [9] and [10] provide application placement methods to minimize the CF in fog computing networks.The authors of [11] examine task scheduling policies to minimize the CF of edge computing networks via the drift-plus-penalty methodology in Lyapunov optimization.Table II lists the features of our paper and the related works in [6]- [11].Note that the works in [6]- [10] only consider optimizing either the spatial or temporal dimension instead of joint spatio-temporal optimization.
To the best of our knowledge, the work in [11] is the closest to ours, yet the differences are significant.The system model in our paper considers battery charging on top of task offloading and scheduling, making our scenario more comprehensive.To be more exact, our paper considers task scheduling and  offloading, as well as energy sharing with battery charging to minimize the CF, utilizing temporal and spatial information of CI.The main contributions of this paper are as follows.
• We consider an edge computing network with renewable energy sources and batteries, and model the CF for the resulting scenario.We consider task offloading and scheduling, as well as battery charging with energy sharing, with the objective of CF minimization.• Due to the discrete nature of task offloadling, the CF minimization problem leads to an integer linear programming (ILP) model.However, we reveal that the problem structure admits a reformulation using minimum-cost flow, implying that its global optimum can be computed in polynomial time.Thus our optimization approach is scalable.• We use real-world CI data to evaluate the performance.
The numerical results show that, by optimal CF-aware task offloading and scheduling along with energy sharing, we can reduce up to 83.3% of the total CF.
Each site consists of an edge computing server, a battery, a local renewable energy source, and the local power grid.The servers have the same specification and computing power.The batteries are connected to each other via a battery management system (BMS), hence the energy in a battery can be shared with the servers on the other sites 1 .In this paper, we use the index of the site to refer to its components, e.g., server s, battery s, etc.More specifics of the system model are as follows; • A server can be powered by its local grid, its renewable energy source, and all the batteries.• A local battery can be charged by the local grid and the local renewable energy source.Additionally, the battery can provide energy to any other server.However, this comes with an energy transfer loss.

B. Time Horizon
We consider a scheduling horizon of T time slots, denoted by T = {1, 2, ..., T }.The set of tasks over the entire time horizon is represented by N = {1, 2, ..., N }.In this paper, the tasks are assumed to be of the same type, i.e., the amount of energy to complete them is uniform, denoted by E. Without loss of generality, we use E as our energy unit, and the relevant parameters (e.g., parameters R, I, α, β, L, and H to be introduced next) are all normalized by E, i.e., they are specified in multiples of E.
Task n is represented by a tuple • o n is the time slot when the task is generated; • d n is the deadline of completing the task; • s n is the server that the task is initially associated with; • S n represents the set of candidate servers2 that can perform task n.A task is to be completed in some time slot in the interval Denote by π nst a binary variable that is one if and only if task n is completed by server s in time slot t.For any task, it needs to be completed once, thus we have s∈S dn t=on Due to normalization, a task requires one unit of energy.Thus in time slot t, the amount of energy consumed for task completion by server s is n∈N π nst .Of the energy consumed, we use variables x st , y ss ′ t , and z st to represent the amount of energy (again normalized by E) by server s from the local grid, battery s ′ , and the local renewable source, respectively, in time slot t.Then we have In addition, the maximum number of tasks that a server can perform in a time slot is constrained by the computing capacity, denoted by H.As a task amounts to one energy unit, we have the following constraint: We use variables u st and v st to represent the amount of energy from the local grid and the renewable source for charging, respectively.In addition, denote by variable w st the amount of remaining energy of battery s at the end of time slot t.We use L to denote the battery capacity.In time slot t, we have the following battery capacity constraint: By the end of time slot t, the remaining energy w st is given by We use R st to denote the amount of renewable energy 3 available from source s in time slot t.The renewable energy is used for charging the local battery and supplying the local server, thus we have

C. Carbon Footprint and Mathematical Formulation
In the system model, CF occurs in three processes related to the grids.Denote by I st the CI of local grid s in time slot t.The three types of CF can be calculated as follows.
1) Task completion: CF will occur when a server consumes the energy from the local grid to complete some task.The total amount of CF of this can be expressed as 2) Battery charging: The total amount of CF due to battery charging via the local grid can be calculated by 3) Task offloading: In this paper, we consider the worst-case CF in task offloading, i.e., we assume that the energy used for task offloading is entirely from the grid.We use α sns to represent the required amount of the energy for transferring task n from its initial server s n to s (α sns = 0 if s n = s).The total CF of task offloading in the network is given by In addition, there will be some loss in energy transfer between a battery and the servers of other sites.We convert this loss into an equivalent amount of CF.Denote the loss per unit of energy from battery s ′ to server s by β s ′ s (β s ′ s = 0 if s ′ = s).
3 Renewable energy can be predicted via for examples methods in [14].
We assume that local grid s provides energy to make up for the loss, and the total amount of the equivalent CF is thus We consider minimizing the total CF in the edge computing network.The CF minimization problem can be formulated by integer linear programming (ILP) as follows, min π∈{0,1}, x,y,z,u,v,w≥0 where the objective function (11a) is the overall system CF.

III. PROBLEM SOLVING
Although the CF minimization problem is formulated as ILP in (11), we will demonstrate that the global optimum can be computed in polynomial time.The idea is to construct a graph, along with entities for nodes and arcs, such that the problem maps to finding a minimum-cost flow in the graph.The graph construction, however, is non-trivial.We illustrate the concept in Fig. 2 and detail the construction below.

A. Overview
A minimum-cost flow problem is an optimization problem of finding the cheapest possible way to route flow from supply node(s) to demand node(s) in a directed graph.In the graph, every arc has two attributes: 1) the per-unit flow cost, and 2) flow capacity.A feasible flow solution has to satisfy 1) Flow balance constraint: The total incoming flow to a node plus the node's supply, if any, equals the total outgoing flow of the node plus the node's demand, if any. 2) Capacity constraint: The flow on every arc does not exceed the arc's capacity.In our graph shown in Fig 2, the green and yellow nodes are nodes with supply and demand, respectively; the other nodes are all transshipment nodes with no supply nor demand.In the graph, green θ-nodes and node δ, red (κ, ρ) node pairs, blue (λ, ε) node pairs, and yellow τ -nodes represent the renewable sources, the merge of all the local power grids, batteries, servers, and tasks, respectively.The flows in the graph represent the amount of energy, and the per-unit cost of an arc is used for accounting for the CF.
Note that the per-unit costs and capacities of arcs default to zero and infinite, respectively, if we do not specify them.Also, we use (a → b) to represent the arc from node a to node b.As can be seen, the graph consist in a number of sections, and in the following we detail each of them.

B. The Entities in a Time Slot
There are T sections indexed by time slot t (t ∈ T ) in the graph.For each of them, there are three types of entities, namely the θ-nodes, (κ, ρ) node pairs, and (λ, ε) node pairs.1) Green node θ t s represents renewable source s in time slot t.Its supply in the graph is set to be R st , i.e., the amount of energy available from source s in time slot t.The meaning Time slot 1 of the flows on arcs (θ t s → λ t s ) and (θ t s → κ t s ) are the same as those of the variables z st and v st , respectively.By graph construction, the two flows adhere to constraint (6).Note that node θ t s also connects to the yellow demand node µ used for receiving the surplus flows (i.e., surplus energy) in the graph to guarantee the feasibility of the minimum-cost flow problem.
2) A red node pair (κ t s , ρ t s ) represents battery s in time slot t.The capacity of arc (κ t s → ρ t s ) is set to be the capacity of battery s, i.e., L. The flows on arcs (δ → κ t s ), (θ t s → κ t s ), and (ρ t−1 s → κ t s ) correspond to variables u st , v st , and w s(t−1) , respectively, and they satisfy constraint (4) due to flow balance.3) A blue node pair (λ t s , ε t s ) represents server s in time slot t.The flows on arcs (δ → λ t s ), (ρ t s ′ → λ t s ), and (θ t s → λ t s ) represent variables x st , y ss ′ t , and z st , respectively.The flows submit to constraint (2) by flow balance.In addition, the capacity of arc (λ t s → ε t s ) is set to be the server capacity H, to model constraint (3).Note that the flow through arc (ρ t s ′ → λ t s ) represents that battery s ′ provides energy to server s in time slot t, therefore the per-unit cost of the arc is set to be β s ′ s I st , and it accounts for the energy loss in task offloading.Clearly, the total flow cost of these arcs equals (10).

C. Battery Level Evolution
Between any two neighboring time slots t and t + 1 in the graph, there are S arcs, i.e., (ρ t s → κ t+1 s ), ∀s ∈ S. The arcs model the evolution of the battery energy between time slots t and t+1.The flow on arc (ρ t s → κ t+1 s ) is the remaining energy in battery s at the end of t.By flow balance, the flow on arc (ρ t s → κ t+1 s ) equals that the flow entering node ρ t s minus the flows representing energy sharing on arcs (ρ t s → λ t s ′ ), ∀s ′ ∈ S, and this flow balance implies constraint (5).

D. The Grid
The local power grids are merged into a green node δ, and we identify the individual local grids via the arcs to the nodes corresponding to batteries and servers: 1) Flow can be sent through arc (δ → κ t s ), and this represents that local grid s charges battery s in time slot t.Clearly, its per-unit cost is I st to account for CF in battery charging, and the total flow cost of these arcs equals (8).
2) We use the flow through arc (δ → λ t s ) to represent that local grid s provides energy to server s in time slot t, and the unit flow cost of arc (δ → λ t s ) is set to be I st .The sum of flow costs of these arcs is equivalent to (7).Arc (δ → µ) is used for routing the surplus flows from the grid.The flow on the arc represents the amount of grid energy not used by the edge computing network.The amount of supply of node δ is set to be a sufficiently large value, e.g., N .

E. The Tasks
In the task section of the graph, a yellow demand node τ n represents task n.The demand of node τ n is one.The arcs between the ε-nodes and τ -nodes are introduced based on the information of the tasks.Specifically, the presence of arc (ε t s → τ n ) represents that server s can complete task n in time slot t (o n ≤ t ≤ d n ).Thus, the flow on this arc represents variable π nst , and the flow balance constraint for the task node is equivalent to constraint (1).The per-unit cost of arc (ε t s → τ n ) is set to be α sns I snt , and the sum of flow costs on these arcs is equivalent to (9).

F. Integrality and Complexity
With the graph constructed, the minimum-cost flow problem can be solved to the optimum by the network simplex algorithm [15], and we can obtain the optimal solution to (11) by tracing the corresponding flows.Note that the potential difficulty of ( 11) is that π is binary.Although the flows are not required to be integer, the integrality theorem of minimum-cost flow problems guarantees that there always exists an integer optimal solution [15,Theorem 11.5].Given an integer optimal solution, for each task node, only one unit of flow will be routed from some ε-node as the demand of a task node is one, i.e., a task will not be split between multiple servers at optimum.
In addition, we have the following theorem with respect to the complexity of our optimization approach.
Theorem 1. CF minimization problem (11) can be solved in polynomial time.
Proof.The graph has in total O(ST + N ) nodes and O(S 2 + N ST ) arcs, hence the graph constructing can be completed in polynomial time.The complexity of the network simplex algorithm using dynamic trees [16] for solving the problem of the graph is O((S 3 T + N S 2 T 2 + N 2 ST ) log(ST + N ) log(ST C + N C)), where C is the maximum cost of any arcs.Hence the conclusion.

IV. PERFORMANCE EVALUATION
In this section, we use a 24-hour CI data set of Sweden, Germany, and Poland from [5]; part of this data set is shown in Table I, for performance evaluation.In our simulation, the length of a time slot is an hour.The amount of renewable energy follows a binomial distribution B(5, 0.5) [17] during daytime (7 am to 7 pm), and is zero otherwise.For any task n, o n , d n (o n ≤ d n ), and s n all follow a discrete uniform distribution.In addition, we set S n = S ∀n ∈ N , i.e., a task can be offloaded to any server.The other simulation parameters are specified in Table III.Note that the values of CF in our results are all normalized by E.

Parameter Value
The number of time slots (T ) 24 The number of servers (S) 3 The number of tasks (N ) 100 The energy for transferring one task (α) 0.1 Loss for transferring one energy unit (β) 0.2 Fig. 3 shows the performance results of our proposed scheme with respect to battery capacity L and server capacity H.As we can see, there is a dramatic reduction of CF when the battery capacity goes from zero (i.e., no battery) to 5 units.Thus the importance of battery (and BMS) to create an energy buffer for pursuing low CF is apparent.When L > 5, the total CF is hardly improved because such a capacity level can store all the energy required by the tasks.In addition, when the server capacity increases, the total CF decreases as more tasks can be offloaded to servers in low-CI regions.
We are curious about the impact of task offloading and energy sharing, respectively, hence we compare the performance of four schemes: • S1: This is the proposed scheme considering both task offloading and energy sharing via BMS in the network.• S2: This scheme allows task offloading but the BMS is disabled, i.e., a battery can only provide energy to its local server.
• S3: This is the opposite to S2, namely energy sharing is enabled, but the tasks can not be offloaded among the servers.• S4: In the last scheme, task offloading and energy sharing are both disabled; this corresponds to the most basic benchmark for comparison.In the simulation, we obtain the performance of the four schemes by solving the corresponding minimum-cost flow problems.Figs. 4 and 5 show the performance results with respect to battery capacity L and server capacity H, where we use w/ and w/o to represent with and without, respectively.Overall, compared with the conventional network (scheme S4), task offloading and energy sharing can help significantly reduce the total CF, up to 83.3% by Fig. 5 for L = 5 and H = 16.
In Fig. 4, the comparison between S1 and S2 reveals that, when the battery capacity is either very low or very high, energy sharing is of little use.For the former case, it is because there is very little surplus energy available for sharing.For the latter case, the tasks can be offloaded to servers for which the local batteries are charged with low-CI energy.From the results of S1 and S2 in Fig. 5, energy sharing is not crucial when the server capacity is large.With high-capacitied servers, the tasks can be offloaded as much as possible to low-CI regions such that we do not need energy sharing for lower CF.In addition, the curves of S2 and S3 in Fig. 4 show that task offloading and energy sharing almost give the same effect if the battery capacity is high.This is expected, as the operations of offloading a task to a low-CI region and obtaining some energy from that region achieve the same effect.Thus, joint optimization of offloading and energy sharing is of significance mainly if the server and battery capacities are moderate with respect to the number of tasks.
The performance of S3 and S4 in Fig. 5 hardly change with increasing server capacity H, and this observation shows that optimizing only task scheduling in the time dimension without task offloading leads to a limited reduction of CF.The reason is that the difference of CI in the temporal dimension is typically not so large as that in the spatial dimension.

V. CONCLUSION
We have considered a CF minimization problem for edge computing by joint task offloading and energy sharing.We have formulated the problem as an integer linear programming model.Making the use of the structure of the problem, we have proposed a graph-based reformulation that enables to solve the problem to global optimum in polynomial time.The numerical results demonstrate the large potential of the use of spatial and temporal information of CI for reducing the CF, and joint task offloading and energy sharing does help significantly.Moreover, we can achieve the potential by either improving the energy storage capacity or computing capability.Future work includes, among other things, the extension of non-uniform energy consumption of tasks.

Fig. 1 .
Fig. 1.The figure shows the system model, where the arrows represent the directions of energy flow.
Fig. 2. The graph for which finding the minimum-cost flow gives the global optimum.

Fig. 3 .
Fig.3.The 3D plot shows the total CF with respect to battery capacity L and server capacity H.

Fig. 4 .
Fig. 4. The total CF as function of the battery capacity L with H = 10.

Fig. 5 .
Fig. 5.The total CF as function of the server capacity H with L = 10.

TABLE I TWO
REAL-WORLD DATA SETS OF CARBON INTENSITY.

TABLE II THE
DIFFERENCE AMONG OUR PAPER AND THE RELATED WORKS.