• No results found

4.2 Unit Case

4.2.1 Feasibility graph Algorithm

We solve the GRID problem with a special input set J where each job has unit power request and unit time duration by using feasibility graph to represent alternative assign- ments. The basic idea is similar to the residual network in network flows; after scheduling a job, we can look for improvement via this feasibility graph. We show that each time a job is scheduled, the optimality can be maintained in polynomial time. For the analysis, we compare our schedule with an optimal schedule via the notion of agreement graph, which captures the differences of our schedule and an optimal schedule. We then show that we can transform our schedule stepwise to improve the agreement with the optimal schedule, without increasing the cost, thus proving the optimality of our algorithm.

Feasibility graph. Given a particular job assignment S, we define a feasibility graph Gf = {Vf, Ef} to be a directed multi-graph that shows the potential allocation of

each job in alternative assignments. Recall that the time is divided into set of timeslots |T | = {1, 2, · · · , τ }, there are |T | vertices in Vf = {v1, v2, · · · , vτ} and each vertex vt∈ Vf

corresponds to the timeslot t ∈ T . Moreover, each vertex vt associates with a positive

weight ω(vt), denotes the load of the corresponding timeslot t, i.e., ω(vt) = `oad(t). On

the other hand, Efcaptures all other possible assignments of each assigned job. If job Jj

is assigned to timeslot t in S, then for all t0 ∈ I(Jj)\{t} we add a directed arc (vt, vt0)

to Ef with Jj as its label.

A feasibility graph Gf corresponds to an assignment S. If a job J is assigned to

timelsot t in S, we also say that J is assigned to vt for short.

Legal-path in a feasibility graph. A path [vs, · · · , vt] in a feasibility graph Gf

is a legal-path if and only if the weight of the starting point vs is at least 2 more than

the weight of the ending point vt, i.e., `oad(s) − `oad(t) ≥ 2.

Example 4.1 is an example of the feasibility graph corresponds to an input set and a legal-path in the feasibility graph. We will explain later that if there is a legal-path in the feasibility graph Gf, the corresponding job assignment is not optimal.

Example 4.1. We now give an example of the notions feasibility graph and legal-path. Let J = {J1, J2, J3}, T = {1, 2, 3, 4}, I(J1) = {1, 2}, I(J2) = {1, 4}, and I(J3) =

{1, 2, 3}. Figure 4.1a shows a schedule where J1 and J2 are both assigned to timeslot 1,

and J3 is assigned to timeslot 2. Figure 4.1b shows the feasibility graph Gf for an job

1 2 3 4

J3

J2

J1

(a) An illustration of the assignment S. 2 1 0 V1 J1 J2 J3 0 J3 V2 V4 V3

(b) The feasibility graph for S.

2 1 0 V1 J1 J2 J3 0 J3 V2 V4 V3

(c) Two legal-paths for S. Figure 4.1: The feasibility graph and two legal-paths with respect to Example 4.1

Observation 2. Moving J from timeslot s to timeslot t may result in decrease/in- crease/same cost depending on the loads of s and t. More formally, the overall energy cost (i) decreases if `oad(s) > `oad(t) + 1, (ii) remains the same if `oad(s) = `oad(t) + 1, and (iii) increases if `oad(s) < `oad(t)) + 1.

Shifting. By Observation 2, the existence of a legal-path implies that the corre- sponding assignment is not optimal and we can execute a “shift” and decrease the total cost of the assignment. Given a path P = [u1, u2, · · · , un] where (ui, ui+1) ∈ Ef for

each i, a shift moves each job corresponding to an arc (ui, ui+1) along P from the origi-

nal assigned timeslot ui to the timeslot ui+1. More precisely, if the path contains an arc

(ui, ui+1) with Jj as its label, then job Jj is moved from ui to ui+1. If there are more

than one arc between ui and ui+1, we break ties arbitrarily. Note that after shifting, the

load of vertices in P remains unchanged except u1and un. Moreover, `oad(u1) decreases

by one and `oad(un) increases by one.

Figure 4.2 shows an illustration of shifting a legal-path referring to Example 4.1. Originally, the jobs J1, J2, and J3 are assigned at timeslot 1, 1, and 2, respectively. The

shifting is along the legal-path [v1, v2, v3].

2 1 0 V1 J1 J2 J3 0 J3 V2 V4 V3

(a) The feasibility graph Gf.

Legal-path [v1,v2,v3]. 1 2 0 V1 J1 J2 J3 0 J3 V2 V4 V3 (b) Gfafter shifting job J1to timeslot 2. 1 1 1 V1 J1 J2 J3 0 J3 V2 V4 V3 (c) Gf after shifting job J3 timeslot 3.

Figure 4.2: Example of shifting along a legal-path referring to Example 4.1.

From Observation 2 that such a shift along a legal-path decreases the cost, implying that the original assignment is not optimal. On the other hand, when there is no legal- path, it is not as straightforward to show that the assignment is optimal. Nevertheless, we will prove this is the case in Lemma 4.10.

Feasibility graph algorithm AFG. We propose a polynomial time offline al-

gorithm that minimizes the total cost for the GRID problem. The algorithm arranges the jobs in J in arbitrary order, and works in stages. In each stage, one new job joins and is considered. First the new job is greedily assigned to one of its feasible timeslots with lowest load. Then the corresponding feasibility graph is updated and shifting is executed along a legal-path (if there exists at least one legal-path.)

More formally, at any Stage j we have three steps (also see Algorithm 1): (1) Assign Jj to a feasible timeslot with minimum load, breaking ties arbitrarily;

(2) Suppose Jj is assigned to timeslot r. We update the feasibility graph Gf to reflect

this assignment in the following way. If applicable, we add arcs from vr labelled

by Jj to any other feasible timeslots (vertices) of Jj;

(3) If there exists any legal-path in Gf from r to any other vertex t, the algorithm

executes a shift along the legal-path (Figure 4.2 shows an illustration). At the end, the algorithm updates the feasibility graph Gf to reflect this shift.

Note that when searching for legal-paths (Step (3)), we focus on those starting from vr, where r is the only timeslot of which the load is changed. We need to prove

that if there is any legal-paths after assigning the new job to r, there must be at least one which is start from vr or they existed before the assigning step (Lemma 4.4). On

the other hand, if there is no legal-paths before assigning the new job, the assignment is optimal or there must be at least one legal-path starting from vr (Lemma 4.10).

Algorithm 1 The feasibility graph algorithm AFG

Input: a set of jobs J = J1, J2, · · · , Jn

Output: an optimal schedule of J for i from 1 to n do

r ← arg mint∈I(Ji)`oad(AFG, t)

Assign Ji to r

Update the feasibility graph according to the assignment if there exists a legal-path P starting from r then

Shift the jobs along P

Update the feasibility graph according to the shifting return the schedule corresponding to the final feasibility graph

Additional notations. To ease the discussion, in the remainder of this section, we use `oad0j(t) to represent the load of timeslot t after assigning Jj (but before the shift),

`oadj(t) to represent the load of timeslot t at the end of Stage j, and `oad0j(s, t) and

`oadj(s, t) to represent `oad0j(s) − `oad0j(t) and `oadj(s) − `oadj(t), respectively.