to describe applications with if-then-else statements; in this case tasks represent pro- ... A node with more than one outgoing arc is said to be a branch if.
Scheduling Conditional Task Graphs Michele Lombardi and Michela Milano DEIS, University of Bologna V.le Risorgimento 2, 40136, Bologna, Italy
Abstract. This paper describes a complete and efficient solution to the scheduling of conditional task graphs whose nodes are activities and whose arcs can be labelled with a probability distribution. Tasks are executed if a set of conditions hold at scheduling execution time. The model is therefore stochastic. The minimization of the expected makespan implies an exponential-sized description of the objective function. We propose an analytic formulation of the stochastic objective function based on the task graph analysis, and a conditional constraint that handles it efficiently. Experimental results show the effectiveness of our approach in comparison with (1) an approach using a deterministic objective function and (2) scenario based constraint programming taking into account all scenarios or only a part of them.
1 Introduction We propose an original approach to the scheduling of conditional task graphs in presence of unary and cumulative resources, minimizing the expected makespan. Conditional Task Graphs (CTG) are directed acyclic graphs containing activities, linked by precedence relations. Some of the activities represent branches: at run time, only one of the successors of a branch is chosen for execution, depending on the occurrence of a condition labelling the corresponding arc. Since the truth or the falsity of those conditions is not known a priori, the problem is stochastic. Therefore, we have to take into account all possible scenarios during the schedule construction. CTGs are ubiquitous to a number of real life problems. In compilation of computer programs [4], for example, CTGs are used to explicitly take into account the presence of conditional instructions. Similarly, in the field of system design [15] CTGs are used to describe applications with if-then-else statements; in this case tasks represent processes and arcs are data communications. Once a hardware platform and an application is given, to design a system amounts to allocate platform resources to processes and to compute a schedule: in this context, taking into account branches allows better resource usage, and thus lower costs. In the conditional planning approach [12], plans are generated prior to execution, but they include both observation actions and conditional branches which may or may not be executed depending on the execution time result of certain observations. While a number of incomplete approaches have been proposed for this problem [14], [10], [15], to our knowledge, the only complete approaches working on conditional task graphs are described in [5] [9], and [7]; the first two papers only take into account unary resources (or, equivalently, disjunctive constraints), while in the latter
2
unary and cumulative resources are considered in a system design application under the minimization of the expected communication cost. The objective function we consider in this paper is far more complicated since it implies a declarative exponential-sized description. We propose an efficient way to overcome this problem by defining an expected makespan constraint that uses an analytic formulation of the stochastic objective function. This constraint and all the problem constraints considering conditional activities rely on two data structures: the Branch Fork Graph (BFG) that compactly represents all possible scenarios and the ω-tree, a BFG subgraph selecting a set of scenarios which include or exclude a specified group of nodes. If a condition named Control Flow Uniqueness (CFU) holds, the algorithms working on the BFG are polynomial. CTGs satisfying CFU are common to a number of application. The BFG and the ω-tree provide a general and powerful tool for defining other conditional global constraints such as the conditional edge finder, the conditional precedence graph. This is subject of current research. Experimental results are very promising. We have evaluated the approach on a set of 600 instances measuring the time to compute a solution, and compared the quality of the schedule to an approach using a deterministic objective function. In addition we have compared our methods with scenario based constraint programming [11] considering either all scenarios, or a fraction of them. In all comparisons our approach wins, outperforming the scenario based constraint programming both considering all scenarios or only a part of them. In the literature other sources of uncertainty are taken into account: for example in stochastic scheduling [1] stochastic activity durations are considered, in simple temporal network with uncertainty again unknown durations are considered. Other papers deal with so called alternative activities (see [2]) whose execution is decided by the user at scheduling construction time. The paper is organized as follows: we first describe the problem considered and the corresponding model in section 2; then the expected makespan constraint is proposed in section 3 along with the branch fork graph used for computing task probabilities, and the filtering algorithm used to prune end variables. Experimental results follow in section 4. Conclusion and current research description conclude the paper.
2 Problem description and model The problem we tackle is the scheduling of Conditional Task Graphs (CTG) in presence of unary and cumulative resources. A CTG (figure 1A) is a triple hT, A, Ci, where T is the set of nodes modelling generic tasks, A is the set of arcs modelling precedence constraints, and C is a set of conditions, each one associated to an arc, modelling what should be true in order to choose that branch during execution (e.g. the condition of an if-then-else construct). A node with more than one outgoing arc is said to be a branch if all arcs are conditional (e.g., t1 in figure 1A), a fork if all arcs are not conditional (e.g., t0 in figure 1A); mixed nodes are not allowed. A node with more than one ingoing arc is an or-node (e.g., t15 in figure 1A) if all arcs are mutually exclusive, it is instead an and-node (e.g., t21 in figure 1A) if all arcs are not mutually exclusive; again, mixed nodes are not allowed.
3
Since the truth or the falsity of conditions is not known in advance, the problem is stochastic. In particular, we can associate to each branch a stochastic variable B with probability space hC, A, pi, where C is the set of possible branch exit conditions c, A the set of events (one for each condition) and p the branch probability distribution; we compactly denote as c the event {B = c}, and therefore p(c) = p({B = c}) is the probability that condition c is true (see figure 1C). We can associate to each node ti an activation function f (ti ) expressed as a boolean composition of branch outcome events (compactly denoted as conditions) that trigger the execution of the corresponding activity. For example in the graph of figure 1A f (t2 ) = a, f (t8 ) = ¬a ∧ b, f (t17 ) = (¬d ∧ e) ∨ (d ∧ e). Each activation function f (ti ) also implicitly identifies a set of paths in the CTG sufficient for ti to execute. In the CTG each node represents a task (also called activity). Tasks are non preemptive, have fixed duration, and execute within a specified time window (defined by the earliest start time and the latest end time) and require for their execution either unary or cumulative resources. The objective function we consider is the minimization of the expected makespan. For this purpose we propose an expected makespan constraint, described in section 3. The solution of the CTG scheduling problem can be given either in terms of a scheduling table [14] or as a unique schedule. In the first case each task is assigned to a different start time, depending on the scenario. Unluckily, the size of such table grows exponentially as the number of branches increases. We therefore chose to provide a single schedule, where each task is assigned a unique start time, regardless it executes or not: at execution time the schedule will contain holes, depending on which scenario occurs. For example, in figure 2 we show a small CTG and the corresponding solution. This choice goes in the line of the notion of strong consistency and controllability defined in [9]. In addition, for some classes of problem such as compilation of computer programs, this is the only kind of solution which can be actually executed ([10]). Resource constraints have to be modified to take into account the presence of mutually exclusive tasks. Two tasks ti and tj are said to be mutually exclusive (mutex(ti ,tj )) if they never appear in the same scenario, so that they can access the same resource without competition. For example tasks t2 and t3 (or tasks t4 and t5 ) in figure 2 can overlap on the same unary resource since they are mutually exclusive. In fact tasks t2 and t3 are respectively triggered by conditions a and ¬a, which are never true in the same scenario. A unary resource, can be implemented by means of a conditional disjunctive constraint [5], which enforces: ∀ti , tj
mutex(ti , tj ) ∨ end(ti ) ≤ start(tj ) ∨ end(tj ) ≤ start(ti )
We model cumulative resources by means of conditional timetable constraints, proposed in [7]; the filtering algorithm is based on the branch/fork graph, described in section 3.1. We substantially adopted the same algorithm, but we reduced the worst case complexity from O(n2a nc ) to O(n2a log(nc )), where na , nc are the number of activities and conditions respectively.
4
Fig. 1. A: Example of CTG; B: Mapping between CTG and the corresponding BFG
Conditional constraints for unary and cumulative resources, as well as the new makespan constraint we propose, integrate well with a standard branch and bound procedure (which we use in this paper), as well as in many other CP search methods.
3 Expected makespan constraint For a deterministic task graph, the makespan is simply the end time of the last task; it can be expressed as: makespan = max{end(ti )} i
If the task graph is conditional the last task depends on the occurring scenario. In a conditional task graph, each scenario ω contains a specific set of tasks (say tasks(ω)); for each scenario the makespan is max{end(ti ) | ti ∈ tasks(ω)}. Thus, the most natural declarative expression for the expected makespan would be: X E(makespan) = p(ω) max{end(ti ) | ti ∈ tasks(ω)} (1) ω
where p(ω) is the probability of the scenario ω. Unluckily the number of scenarios is exponential in the number of branches, which limits the direct use of expression (1) to small, simple instances. Therefore, we chose to define and adopt a way to compute legal bounds on the makespan variable and the end times of all tasks in a procedural fashion. The procedure we identified was used to devise a sound and complete filtering algorithm for the expected makespan constraint (see section 3.6). The idea is the following. First note that the computation of the expected makespan is tractable when the order of the end variables of tasks is known.
5
Consider the example in figure 2: note that, since t5 is the last task, the makespan of all scenarios containing t5 is end(t5 ). Similarly, since t4 is the last but one task, end(t4 ) is the makespan value of all scenarios containing t4 and not containing t5 , and so on.
Fig. 2. Temporal task grouping
In general, let t0 , t1 , . . . , tna −1 be the sequence of CTG tasks ordered by increasing end time; let the order be completely specified, then: E(makespan) =
X
p(ti ∧ ¬ti+1 ∧ . . . ∧ ¬tna −1 ) end(ti )
(2)
i
The sum contains na terms, where na is the number of activities. Note that this number can be decreased by considering tail tasks only (i.e. tasks with no successor) Once the end order of tasks is fixed, we can thus compute the expected makespan in polynomial time, provided we are able to efficiently compute the probability weights in expression (2). In general, during search, the order of tasks is not fixed. It is always possible, however, to identify minimum and maximum length task sequences (note that they are possibly infeasible), compute their makespan with expression (2) and prune the task end variables accordingly. Expression (2) can therefore be used to devise a cost-based filtering algorithm to prune the makespan and the end variables during search; such filtering algorithm can be embedded in a new expected makespan constraint: emakespan(mkspan, ends, mappings, graph) where mkspan is the makespan variable, ends is an array with the end variables, mappings is an array which tells for each task the CTG node it is mapped to. Finally, the graph must be known in order to compute the associate BFG. Note that, in order to improve efficiency, one could build the constraint by specifying the end variables of tail tasks only. In the next sections we will first show how to efficiently compute probabilities in expression 2. We propose to use a structure called Branch/Fork graph that compactly represents all scenarios, and a way to query it to obtain the needed probabilities. In section 3.6 we will present the filtering algorithms for the makespan and the end variables.
6
3.1 Branch/Fork Graph A Branch/Fork Graph (BFG) intuitively represents the skeleton of all possible control flows and compactly encodes all scenarios of the corresponding CTG. A BFG is a bichromatic acyclic directed graph. Nodes are either branch (“B”, the solid dots in figure 1B) or fork (“F”, the circles in figure 1B). There is a branch node in the BFG for each branch node in the CTG. F nodes instead group CTG nodes that belong to the same scenarios. Therefore, a BFG can be built from its associated CTG, provided we know the activation functions f (ti ) of the tasks. All functions are supposed to be in disjunctive normal form, i.e. as disjunction of minterms, where a minterm is a conjunction of one or more conditions (f (ti ) = m0 ∨m1 ∨. . . and mj = cj0 ∧cj1 ∧. . .). There is a mapping between CTG nodes and BFG nodes. For example, in figure 1, tasks t2 , t3 and t4 are CTG nodes mapped to the same F node Fa in the BFG. They in fact, belong to the same scenario and have the same activation function. Figure 1B shows the CTG and the corresponding BFG along with the task mappings. Let F (ti ) be the set of F nodes the task ti is mapped to: if F (ti ) contains an F node Fj and all its descendants, we can remove all of them from F (ti ) and keep only Fj to compact the representation. For instance t5 should be mapped to F¬a , Fb , F¬b , Fc , F¬c , but it is actually mapped only to F¬a . Some structural properties of the BFG follow: 1. 2. 3. 4. 5.
B node parents are always F nodes B node parents represent mutually exclusive minterms/paths outgoing arcs of B nodes originate mutually exclusive minterms/paths F node parents represent non mutually exclusive minterms/paths outgoing arcs of F nodes originate non mutually exclusive minterms/paths
We have defined a BFG construction procedure described in [8] that we skip here for lack of space. The construction procedure we outlined has exponential time complexity; in practice it can be replaced by a polynomial one, if a property named control flow uniqueness holds.
Fig. 3. A: a CTG which satisfies; CFU B: a CTG which does not satisfy CFU
7
3.2 Control Flow Uniqueness We are interested in conditional graphs satisfying Control Flow Uniqueness (CFU) a condition introduced in [7]. CFU is satisfied if for each non head task ti there is at least a predecessor tj such that: f (tj ) ∧ cji ⇒ f (ti ), where cji is the condition possibly labeling arc (j, i); if there is no such condition cji = true. Note that if two predecessor tasks tj and tk both satisfy the expression above, then they are mutually exclusive. Tasks with a single predecessor trivially satisfy the expression above; the same holds for ornodes since all their predecessors are mutually exclusive, therefore CFU translates into a restriction on and-nodes only. In particular CFU requires each and-node to be triggered by a single “main” predecessor, or, in other words, that every and-node must be on a single control path. For example in figure 3A, task t5 is sufficient to trigger the execution of t8 (since t7 executes in all scenarios) and thus CFU holds. On the opposite, in figure 3B, neither t4 nor t5 alone are sufficient to activate t7 and CFU is not satisfied. In many practical cases CFU is not restrictive assumption: for example, when the graph results from the parsing of a computer program written in a high level language (such as C++, Java, C#) CFU is naturally enforced by the scope rules of the language. Control flow uniqueness translates into some additional structural properties for the BFG (proofs are omitted due to lack of space but can be found in [8]): – If CFU holds, every F node has a single parent and it is always a B node – If CFU holds, every F node splits its descendants into separated subgraphs From these properties, we deduce that if CFU holds the BFG is a bichromatic alternate graph. Moreover, since every branch node with m outgoing arcs originates exactly m F nodes, the BFG has exactly nc + 1 F nodes, where nc is the number of conditions. CFU is also a necessary condition for the two structural properties listed above to hold; therefore we can check CFU by trying to build a BFG with a single parent for each F node: if we cannot make it, then the original graph does not satisfy the condition. 3.3 BFG and scenarios The most interesting feature of a BFG is that it can be used to select and encode groups of scenarios in which arbitrarily chosen nodes execute/do not execute. If we have algorithms to extract interesting features of these scenario groups, such as their maximum/minimum weight (see [7]) or their probability (algorithm devised further on), we can turn the BFG into a powerful tool to build many useful conditional constraints, for example the expected makespan constraint we develop in this work. Groups of scenarios are encoded in the BFG as sets of ω-trees: Definition 1 (ω-tree). An ω-tree is any subgraph of the BFG satisfying the following properties: 1. 2. 3. 4.
the subgraph includes the root node if the subgraph includes an F node, it includes also all its children if the subgraph includes an F node, it includes also all its parents if the subgraph includes a B node, it includes also one and only one of its children
8
Fig. 4. (A) BFG for the graph in figure 1A - (B) an ω-tree - (C) a subgraph representing a set of ω-trees
Note that, despite its name, an ω-tree is not necessarily a tree: this is always the case only if CFU (which is not required by definition 1) is satisfied (figure 4B). Any ω-tree translates to a single scenario where all and only the conditions it includes are true. By relaxing condition 4 in definition (1) we get subsets of the BFG representing sets of omega trees, an thus sets of scenarios (see figure 4C). 3.4 Querying the BFG We now need a way to select subgraphs representing sets of scenarios which include or exclude a specified group of nodes. We consider selection rules specified by means of boolean queries in Conjunctive Normal Form (CNF). Each basic term of the query can be ti (with meaning “task ti executes”) or ¬ti (with meaning “task ti does not execute”). Some examples of valid queries are: q0 = ti ∧ tj
q1 = ti ∧ ¬tj ∧ ¬tk
q2 = (ti ∨ tj ) ∧ tk
The idea at the base of the query processing procedure is that, since the complete BFG represents all possible scenarios, we can select a subset of them by removing F nodes which do not satisfy the boolean query. Thus, in order to be processed, queries are negated and translated in Disjunctive Normal Form (DNF): ¬q0 = ¬ti ∨ ¬tj
¬q1 = ¬ti ∨ tj ∨ tk
¬q2 = (¬ti ∧ ¬tj ) ∨ ¬tk
Each element in the negated disjunction now has to be mapped to a set of F nodes to be removed from the BFG. This requires to compute for each F and B node an inclusion label and an exclusion label: 1. Inclusion labels: A CTG task ti is in the inclusion label i(Fj ) of a F node Fj if Fj ∈ F (ti ) or if ti is in the inclusion label of any of its parents (that are B nodes). A CTG task ti is in the inclusion label i(Bj ) of a B node Bj if ti is in the inclusion label of all of its parents. In practice ti ∈ i(Fj ) (resp. i(Bj )) if it does execute in any ω-tree containing Fj (resp. Bj ). 2. Exclusion labels: A CTG task ti is in the exclusion label e(Fj ) of an F node Fj if ti is in the exclusion label of any parent, or if parent of Fj is a B node and it exists a
9
brother F node Fk such that ti is mapped on a descendant of Fk and ti is not mapped on a descendant of Fj . A CTG task ti is in the exclusion label e(Bj ) of a B node Bj if ti is in the exclusion label of all its parents. In practice ti ∈ e(Fj ) (resp. e(Bj )) if it cannot execute in an ω-tree containing Fj (resp. Bj ). Note that we are interested only in F node labels; B nodes labels are used only in the building process. Once inclusion and exclusion labels are computed, each term of the disjunctions can be mapped to a set of F nodes. For example: ti → {Fj | ti ∈ i(Fj )} ¬ti → {Fj | ti ∈ e(Fj )} ti ∧ tk → {Fj | ti , tk ∈ i(Fj )} ti ∧ ¬tk → {Fj | ti ∈ i(Fj ), tk ∈ e(Fj )} As already said, queries are processed by removing from the complete BFG the F nodes corresponding to each term of the negated query. For example, on the graph of figure 1A (correspondent BFG in figure 1B or 4A), the query q = t21 ∧ ¬t3 ∧ ¬t16 = ¬(¬t21 ∨ t3 ∨ t16 ) is processed by removing from the BFG F¬c , Fa and F¬e , since t21 ∈ e(F¬c ), t3 ∈ i(Fa ) and t16 ∈ i(F¬e ). The resulting subgraph is shown in figure 4C. If during the process a B node loses all children the output of the query is an empty subgraph. Once the inclusion and exclusion labels are computed, a query is always processed in linear time. 3.5 Computing subgraph probabilities Querying the BFG provides us with a first set of tools needed to achieve our primary objective, i.e. computing weights in expression (2) in polynomial time. Remember a weight is in the form: w(ti ) = p(ti ∧ ¬ti+1 ∧ . . . ¬tna −1 ) Since the BFG can be queried for identifying a subgraph satisfying condition ti ∧ ¬ti+1 ∧ . . . ¬tna −1 , then in order to compute a weight we only need to extract the probability of a given subgraph. In the following we show a probability computation algorithm for BFGs derived from graphs satisfying Control Flow Uniqueness; we also assume branch probabilities are independent. Statement 1: Since every F node with m children splits the set of possible branch combinations E = B0 × B1 × . . . × Bb−1 into m partial sets E0 , E1 , . . . Em−1 such that: Y P (Ei ) P (E) = i
That means, the partial set of combinations are independent, since they share no branch variable. Statement 2: Every branch node S with m children splits the set of scenarios Ω in a family {Ω0 , Ω1 , . . .} such that Ω = i Ωi and Ωi ∩ Ωj = ∅. Therefore: X P (Ωi ) P (Ω) = i
Alternativa: possiamo continuare a dire esperimento composito, magari fancendo riferimento alla teoria della probabilita’ (il termine e’ preso da li’)
10
Algorithm 1 Subgraph probability 1: let L be the set of nodes to visit and V the one of visited nodes. Initially L contains all subgraph leaves and V = ∅ 2: for each F and B node keep a probability value p(n). Initially p(n) = 1 for all F nodes, p(n) = 0 for all B nodes 3: while L 6= ∅ do 4: pick a node n ∈ L 5: if n is an F node with parent np and ap = (np , n) then 6: p(np ) = p(np ) + p(n)p(ap ) 7: else if n is a B node with parent np then 8: p(np ) = p(np )p(n) 9: end if 10: V = V ∪ {n} 11: L = L \ {n} 12: if all children of np are in V then 13: L = L ∪ {np } 14: end if 15: end while 16: return p(root)
Again the probabilities of sets Ωi can be computed in an independent fashion. Relying on those observations, the probability of a subgraph can be computed via a backward visit as show in algorithm 1, which runs in linear time. As an example, consider the subgraph of figure 4C (condition probabilities are in figure 1C). The computation starts from the leaves (we consider Fb , F¬b , Fc ): at the beginning p(Fb ) = 1, p(F¬b ) = 1, p(fc ) = 1 (line 2 in the algorithm). Then, probabilities of B nodes are the weighted sum of those of their children (line 6); for example p(b1 ) = p(b)p(Fb ) + p(¬b)p(F¬b ) = 0.4 × 1 + 0.6 × 1 = 1 and p(b2 ) = p(c)p(Fc ) = 0.6 × 1 = 0.6. Probabilities of F nodes are instead the product of those of their children (line 8), and so p(F¬a ) = p(b1 )p(b2 ) = 1 × 0.6 = 0.6. The visit proceeds backwards until p(F0 ) is computed, which is also the probability of the subgraph. 3.6 Filtering algorithm We now have sufficient tools to efficiently compute weights in the makespan expression (2) and to prune the makespan variable and the end time variables of each task. As far as the makespan variable is concerned, its minimum value is achieved for the (possibly not feasible) configuration where all end variables assume their minimal value. Similarly, the maximum makespan corresponds to the configuration where all task ends are set to their maximal value. Note that in both situation the order of tasks is completely specified: we refer to their sequence in the two configurations as Smin and Smax . Sequence Smin is sorted by increasing min(end(ti )), Smax by increasing max(end(ti )). We can prune the makespan variable by enforcing: mkspan(Smin ) ≤ mkspan ≤ mkspan(Smax )
(3)
11
where mkspan(Smin ), mkspan(Smax ) are the makespan values of configurations Smin , Smax computed by means of expression 2. In order to improve computational efficiency, we can use F nodes instead of tasks in the computation of mkspan(Smin ) and mkspan(Smin ). Remember that there is a mapping between tasks (CTG nodes) and F nodes. Each F node is assigned a min and a max end value computed as follows: maxend(Fj ) = max{max(end(ti )) | ti is mapped to Fj } minend(Fj ) = max{min(end(ti )) | ti is mapped to Fj } Therefore, the two sequences Smin , Smax can store F nodes (sorted by minend and maxend) instead of activities (see figure 5A) and their size can be reduced to at most nc + 1 (where nc is the number of conditions).
Fig. 5. A: Example of Smin and Smax sequences containing F nodes. B: An update of maxend(F1 ) causes a swap in Smax .
Each time a variable end(ti ) mapped to Fj changes, values maxend(Fj ) and minend(Fj ) are updated and possibly some nodes are swapped in the sequences Smin , Smax (see figure 5B, where maxend(F1 ) changes). This updates can be done with complexity O(na + nc ), where na is the number of tasks. The makespan bound calculation of constraints (3) can be done by substituting tasks with F nodes in expression (2): X (4) p(Fi ∧ ¬Fi+1 ∧ . . . ∧ ¬Fnc −1 ) end(Fi ) E(makespan) = i
where end(Fi ) ∈ [minend(Fi ), maxend(Fi )] and probabilities p(Fi ∧ ¬Fi+1 ∧ . . . ∧ ¬Fnc −1 ) can be computed again by querying the BFG. The overall worst case complexity for the pruning of the makespan variable is O(c2 log(c)). Since we are dealing with a makespan minimization problem, it is crucial for the efficiency of the search process to exploit makespan domain updates to filter the end variables. Bounds for end(Fi ) (and thus for the end variables of tasks) can be computed again with expression (4); for example to compute the upper bound we have to subtract from
12
Fig. 6. Upper bound on end variables
the maximum makespan value (max(mkspan)) the minimum contribute of all F nodes other than Fi : P max(mkspan) − j6=i p(Fj ∧ ¬Fj+1 ∧ . . .)minend(Fj ) (5) U B(end(Fi )) = p(Fi ∧ ¬Fi+1 ∧ . . .) where F0 , . . . , Fi−1 , Fi , Fi+1 , . . . is the sequence where the contributes of Fj , j 6= i is minimized. Unfortunately, this sequence is affected by the value of end(Fi ). In principle, we should compute a bound for all possible assignments of end(Fi ), while keeping the contribute of other F nodes minimized. Note that the configuration where the contribute of all F node is minimized is Smin : we can compute a set of bounds for end(Fi ) by “sweeping” its position in the sequence, and repeatedly applying formula 5. An example is shown in figure 6, where a bound is computed for F0 (step 1 in figure 6). We start by computing a bound based on the current position of F0 in the sequence (step 2 in figure 6) ; if such a bound is less than endmin(F1 ), then maxend(F0 ) is pruned, otherwise we swap F0 and F1 in the sequence and update the probabilities (or weights) accordingly in expression (4). The process continues by comparing F0 with F2 and so on until maxend(F0 ) is pruned or the end of Smin is reached. Lower bounds for minend(Fi ) can be computed similarly, by reasoning on Smax . A detailed description of the filtering procedure is given in Algorithm 2. The F nodes are processed as listed in Smin (line 2); for each Fj the algorithm starts to scan the next intervals (line 6). For each interval we compute a bound (lines 7 to 11) based on the maximum makespan value (max(mkspan)), the current F node probability/weight (wgt) and the contribute of all other F nodes to the makespan lower bound (rest). If the end of the list is reached or the bound is within the interval (line 12) we prune all end variables of tasks mapped on Fj (line 13) and the next F node is processed. If the bound exceeds the current interval, we move to the next one. In the transition the current F node possibly gains weight by “stealing” it from the activity just crossed (lines 15 to 18): wgt and rest are updated accordingly.
13
Algorithm 2 End variables pruning (upper bound) 1: let Smin = F0 , F1 , . . . , Fk−1 2: for j = 0 to k − 1 do 3: compute result of query q = Fj ∧ ¬Fj+1 ∧ . . . ∧ Fk−1 and probability p(q) 4: wgt = p(q) 5: rest = mkLB − minend(Fj )wgt 6: for h = j to k − 1 do 7: if wgt > 0 then max(mkspan) − rest 8: UB = wgt 9: else 10: UB = ∞ 11: end if 12: if h = (k − 1) or U B ≤ minend(Fh+1 ) then 13: set U B as upper bound for all tasks mapped on Fj 14: else 15: remove element ¬Fh+1 from query q and update p(q) 16: newwgt = p(q) 17: rest = rest − (newwgt − wgt)minend(Fh+1 ) 18: wgt = newwgt 19: end if 20: end for 21: end for
The algorithm takes into account all the F nodes (complexity O(c)), for each of them analyzes the subsequent intervals (compl. O(c)) and update weights at each transition (compl. O(log(c))). The overall complexity is thus O(c2 log(c)).
4 Experimental results Our approach has been implemented using the state of the art solvers ILOG Solver 6.3 and Scheduler 6.3. We tested the approach on 600 randomly generated instances representing a hardware design problem, where a multi task application (described by means of a CTG) has to be scheduled on a multiprocessor hardware platform. The problem features complex precedence relations, unary resources (the processors) and a single cumulative resource (modelling a shared bus). Instances range from 37 to 109 tasks, 2 to 5 “heads” (tasks with no predecessor), 3 to 11 “tails” (tasks with no successor), 1 to 135 scenarios. The number of unary resources ranges from 3 to 6. Duration and resource usage parameters are randomly generated, but based on real values. Of course all instances satisfy the control flow uniqueness. We ran experiments with a time limit of 300 seconds; all tests were executed on a AMD Turion 64, 1.86 GHz. We performed a first group of tests to evaluate the efficiency of the expected makespan conditional constraint and the quality of the solutions provided, and a second group to compare the performances of our solver with a scenario-based one. Table 1 shows the results for the first group of tests; here we evaluate the performance of the solver using conditional constraints (referred to as C) and compare the quality of the computed
14 acts 37-45 45-50 50-54 54-57 57-60 60-65 65-69 69-76 76-81 81-86 86-93 93-109
C C stc W W 3-4 1.54 3115 0 0.83 0.80 3-5 2.67 4943 0 0.88 0.84 9.00 17505 0 0.88 0.85 3-5 4-5 25.68 52949 1 0.88 0.85 4-5 29.78 77302 1 0.94 0.90 4-6 24.03 28514 0 0.85 0.80 2 0.90 0.84 4-6 32.12 47123 4-6 96.45 101800 14 0.86 0.82 5-6 144.67 134235 21 0.90 0.86 5-6 143.31 130561 17 0.84 0.75 5-6 165.74 119930 25 0.93 0.87 5-6 185.56 127321 28 0.93 0.87 Table 1. Performance tests
URes
T(C)
F(C) > TL
schedules versus an identical model where the deterministic makespan is minimized (referred to as W). In this last case, no expected makespan constraint is used and the objective function is deterministic. Each row identifies a group of 50 instances. For each group we report the minimum and maximum number of activities (acts), the minimum and maximum number of unary resources (URes), the average solution time (T(C)), the average number of fails (F(C)) and the number of instances which could not be solved within the time limit (> TL). The computing time of the two approaches is surprisingly roughly equivalent for all instances. In column C/W we report the makespan value ratio which shows an average improvement of 12% over the determinist objective. The gain is around 16% if we consider only the instances where the makespan is actually improved (column stc C/W).
scens T(C) 1-2 2-3 3-4 4-5 5-6 6-6 6-8 8-9 9-12 12-14 14-20 20-135
41.00 66.02 43.80 49.94 66.39 51.26 38.85 57.78 52.96 117.93 95.74 178.88
T(S) T(S80 ) S80 T(S50 ) > TL > TL > TL T(C) T(C) C T(C) 49517 5 22.60 5 22.66 5 1.00 0.58 3 19.85 10 19.93 10 1.00 1.69 7 97928 8 54744 5 35.05 8 35.12 8 1.00 9.19 5 51179 6 73.75 9 73.63 9 1.00 57.03 8 58223 9 48.74 12 16.64 12 0.98 0.77 8 6.52 8 6.11 8 0.96 41.99 8 85611 5 34572 5 82.21 11 71.09 9 0.98 84.41 3 58636 9 66.32 10 63.70 10 0.98 26.76 9 89.52 13 86.97 13 0.98 40.43 6 51126 5 86954 17 45.60 22 43.02 22 0.97 37.35 18 81721 11 32.62 22 31.85 21 0.99 28.76 15 135086 24 66.19 37 65.56 37 1.00 22.09 35 Table 2. Comparison with scenario based solver F(C) > TL
S50 C 0.77 0.80 0.79 0.80 0.82 0.80 0.80 0.85 0.85 0.84 0.90 0.912
15
Table 2 compares the conditional model with a scenario based solver, where cumulative resources are implemented with one constraint per scenario and the expected makespan is expressed with the declarative formula (1). In both models unary resources are implemented with conditional constraints. Again, rows of table 2 report average results for groups of 50 instances; groups are sorted by increasing number of scenarios. The table reports the solution time and fails of the conditional solver (T(C), F(C)) and the performance ratios w.r.t the scenario based solver with 100% (S), 80% (S80 ) and 50% (S50 ) of the most likely scenarios. The four columns “> TL” show the number of instances not solved within the time limit for each approach. Finally, columns S50 /C and S80 /C show the accuracy of the solution provided by S50 and S80 solvers. As it can be seen the conditional model outperforms the scenario based one by an average factor of 49.08. By reducing the number of considered scenarios the performance gap decreases; nevertheless, the conditional solver remains always better than S80 ; it is outperformed by S50 when the number of scenarios is low, but the solution provided has an average 17% inaccuracy. Moreover, neither S50 nor S80 guarantee feasibility in all cases.
5 Conclusion In this paper we have proposed an efficient way to schedule conditional task graphs minimizing the expected makespan. The approach is based on the analysis of the conditional task graph and on the extraction of scenario probability. We show that the approach has similar performances with an approach using a deterministic objective function and outperforms the scenario based constraint programming even if not all scenarios are considered. The current research is aimed at implementing other global conditional constraints such as the edge finder and the precedence graph by exploiting the BFG and the ω-tree structures.
References 1. Beck, J.C. and Wilson, N.: Proactive Algorithms for Scheduling with Probabilistic Durations Proceedings of the Nineteenth International Joint Conference on Artificial Intelligence (IJCAI05), 2005. 2. Beck, J. C. and Fox M. S.: Scheduling Alternative Activities (1999), AAAI/IAAI, 680687,1999. 3. Benini, L., Bertozzi, D., Guerri, A., Milano, M.: Allocation and scheduling for MPSOCs via decomposition and no-good generation. In: Proc. of the Int.l Conference in Principles and Practice of Constraint Programming, 2005. 4. Faraboschi, P., Fisher, J.A., Young., C.: Instruction scheduling for instruction level parallel processors. In Proceedings of the IEEE, 89, pages 1638–1659, 2001. 5. Kuchcinski, K.: Constraints-driven scheduling and resource assignment. ACM Transactions on Design Automation of Electronic Systems 8, 2003. 6. Laborie, P.: Algorithms for propagating resource constraints in ai planning and scheduling: Existing approaches and new results. Journal of Artificial Intelligence 143 (2003) 151–188.
16 7. Lombardi, M. and Milano, M.: Stochastic Allocation and Scheduling for Conditional Task Graphs in MPSoCs In: Proc. of the Int.l Conference in Principles and Practice of Constraint Programming, 2006. 8. Lombardi, M. and Milano, M.: Scheduling Conditional Task Graphs LIA Technical Report LIA-005-97 http://www-lia.deis.unibo.it/research/TechReport.html 2007. 9. Vidal, T. and Fargier H.: Handling Contingencies in temporal constraint network: from consistency to controllability Journal of Experimental and Theoretical Artificial Intelligence, 11, (1999) 23-45. 10. Shin, D., Kim, J.: Power-aware scheduling of conditional task graphs in real-time multiprocessor systems. In: International Symposium on Low Power Electronics and Design (ISLPED), ACM, 2003. 11. Tarim, A., Manandhar, S., Walsh, T.: Stochastic constraint programming: A scenario-based approach. Constraints 11, 2006, 53–80. 12. Tsamardinos, I., Vidal, T., Pollack, M.: CTP: A New Constraint-Based Formalism for Conditional, Temporal Planning. Constraints, 8, 2003, 365- 388. 13. Walsh, T.: Stochastic constraint programming. In: Proc. of the European Conference on Artificial Intelligence, ECAI, 2002. 14. Wu, D., Al-Hashimi, B., Eles, P.: Scheduling and mapping of conditional task graph for the synthesis of low power embedded systems. In: Computers and Digital Techniques, IEE Proceedings. Volume 150 (5), 2003, 262–273. 15. Y. Xie and W. Wolf Allocation and scheduling of conditional task graph in hardware /software co-synthesis in Proc. of Design, Automation and Test in Europe Conf., 2001.