This moti- vated the introduction in [19] of the refined notion of normalized completed contours. In some cases, the .... fa ; b g;fa ; b gand fa ; b g. On this example ...
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES JEAN MAIRESSE AND LAURENT VUILLON A BSTRACT. In a heap model, solid blocks, or pieces, pile up according to the Tetris game mechanism. An optimal sequence is an infinite sequence of pieces minimizing the asymptotic average height of the heap. In a heap model with two pieces, we prove that there always exists an optimal sequence which is either periodic or Sturmian. We completely characterize the cases where the optimal is periodic and the ones where it is Sturmian. The proof is constructive, providing an explicit optimal sequence. We show an application for a system of two processes sharing a resource, and we prove that a greedy schedule is not always optimal.
C ONTENTS 1. Introduction 2. Heap Model 3. Optimal Behavior 4. Sturmian Word 5. (Max,+) Automaton 5.1. (Max,+) and (min,+) spectral theory 5.2. Deterministic automaton 5.3. Cayley automaton 5.4. Completed automaton 6. Heap Models with Two Pieces: Realizations of Dimensions 2 or 3 6.1. Bi-completed heap automaton 6.2. Minimal realization 7. Heap Models with Two Pieces: Optimal Schedules 7.1. The case R(a) = f1g; R(b) = f2g 7.2. The case R(a) = f1; 2g; R(b) = f1; 2g 7.3. The case R(a) = f1; 2g; R(b) = f2g 7.4. The case R(a) = f1; 2g; R(b) = f2; 3g 7.5. Finite Sturmian word 8. Conclusion: Heap Models with Three or More Pieces Acknowledgments References
2 3 6 7 8 8 9 9 9 11 11 12 14 15 16 17 19 23 24 25 26
Date: October 19, 1998. Key words and phrases. Optimal scheduling, timed Petri net, heap of pieces, Tetris game, (max,+) semiring, automaton with multiplicities, Sturmian word. This work was partially supported by the European Community Framework IV programme through the research network ALAPEDES (“The ALgebraic Approach to Performance Evaluation of Discrete Event Systems”). 1
2
JEAN MAIRESSE AND LAURENT VUILLON
1. I NTRODUCTION Heap models have recently been studied as a pertinent model of discrete event systems, see Gaubert & Mairesse [18, 20] and Brilman & Vincent [10, 11]. They provide a good compromise between modeling power and tractability. As far as modeling is concerned, heap models are naturally associated with trace monoids, see [30]. It was proved in [20] that the behavior of a timed one-bounded Petri net can be represented using a heap model (an example appears in Figure 1). We can also mention the use of heap models in the physics of surface growth, see [5]. The tractability follows essentially from the existence of a representation of the dynamic of a heap model by a (max,+) automaton, see [11, 18].
A heap model is formed by a finite set of slots and a finite set of pieces A. A piece is a solid block occupying a subset of the slots and having a polyomino shape. With a word w = a1 an 2 A , we associate the heap obtained by piling up the pieces a1; : : :; an in this order. The piling occurs according to the Tetris game mechanism. Let y(w) be the height of the heap w. An optimal schedule is defined as an infinite word u 2 A! such that
1 y(u[n]) = lim 1 min y(w) ; lim n n n n w2An where u[n] is the prefix of length n of u. A worst case schedule is defined by replacing min by max in the above equation. The problem of finding a worst schedule is completely
solved, see [16, 18, 19]. Finding an optimal schedule is more difficult, a reason being the non-compatibility of the minimization with the (max; +) dynamic of the model. In [19], it is proved that if the heights of the pieces are rational, then there exists a periodic optimal schedule. If we remove the rationality assumption, the problem becomes more complicated and was left unsolved in [19]. Here we treat the case of a heap model with two pieces. A new phenomenon appears: there does not always exist a periodic optimal schedule. However, we prove, and this is the main result of the paper, that there exists an optimal schedule which is either periodic or Sturmian. When the optimal schedule is periodic, it is of the form u! where u is a finite Sturmian word. We characterize the cases where the optimal is periodic and the ones where it is Sturmian. The proof is constructive, providing an explicit optimal sequence.
a
b b
2
1
1
2
1 + 2
1 a
1 + 2
To further motivate the practical interest of this work, we present a manufacturing model studied by Gaujal & al [22, 21]. There are two types of tasks to be performed on the same
1
F IGURE 1. One-bounded Petri net and its associated heap model. machine used in mutual exclusion. Each task is cyclic and a cycle is constituted by two successive activities: one that requires the machine (durations: 1 and 1 respectively)
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
3
and one that does not (durations: 2 and 2 respectively). Think for instance of the two activities as being the processing and the wrapping. This jobshop can be represented by the timed one-bounded Petri net of Figure 1. The durations 1 ; 2; 1 and 2 are the holding times of the places. As proved in [20], an equivalent description is possible using the heap model represented in Figure 1. The height of a heap a1 an ; ai 2 fa; bg; corresponds to the total execution time of the sequence of tasks a1 ; : : :; an executed in this order. A schedule is optimal if it minimizes the average height of the heap, or equivalently if it maximizes the throughput of the Petri net. It corresponds to an optimal allocation of the machine. We do not make any restriction on the schedules we consider. In particular we do not impose a frequency for tasks a and b. For a justification, imagine for instance that the two tasks correspond to two different ways of processing the same object. We prove in x7.4 that if 1 = 1 = 0 and if 2 > 0; 2 > 0; 2= 2 62 Q then there is a Sturmian optimal schedule; otherwise there exists a periodic optimal schedule. We also show that the greedy schedule is not always optimal, see Example 7.4. Let us compare the results of this paper with other cases where optimality is attained via balanced (i.e. Sturmian or periodic with a finite Sturmian period) schedules. In Hajek [25], the model consists in a flow of arriving customers to be dispatched between two queues and the problem considered is the optimal behavior under a ratio constraint for the routings. The author introduces the notion of multimodularity, a discrete version of convexity, and proves that a multimodular objective function is minimized by balanced schedules. Variants and extensions to other open queuing or Petri net models have been carried out in [1, 2], still using multimodularity. In a heap model however, the height functions yH and xH (to be defined below) are not multimodular. In [21, 22], the authors consider the model of Figure 1. They study the optimal behavior and the optimal behavior under a frequency constraint for the letters. Balanced schedules are shown to be optimal and the proofs are based on various properties of these sequences. We consider a more general model. For the unconstrained problem, we prove in Proposition 7.5 that balanced schedules are again optimal. On the other hand, under frequency constraints, we show in x7.5 that optimality is not attained via balanced words anymore. Our methods of proof, mainly based on the (max,+) representation, are completely different from the ones mentioned above. The paper is organized as follows. In x2 and x3, we define precisely the model and the problem considered. In x4 and x5, we recall some properties of Sturmian words and (max,+) automata respectively. We prove in x6 that it is always possible to study a heap model by considering an associated model with at most 3 slots. We provide an enumeration of all the possible simplified models; there are 4 cases. In x7.1-7.4, we prove the main result of the paper, recalled above, by considering the four cases one by one. As a conclusion, in x8, we provide some insights and mention some open questions for heap models with three or more pieces. 2. H EAP M ODEL Consider a finite set R of slots and a finite set A of pieces. A piece a 2 A is a rigid (possibly non connected) “block” occupying a non-empty subset R(a) of the slots. It has a lower contour and an upper contour which are represented by two row vectors l(a) and u(a) in (R [ f?1g)R with the convention l(a)r = u(a)r = ?1 if r 62 R(a). They verify u(a) l(a) and mini2R(a) l(a)i = 0. We assume that each piece occupies at least one slot, R(a) 6= ;; 8a 2 A, and that each slot is occupied by at least one piece, R?1(r) 6= ;; 8r 2 R. The 5-tuple H = (A; R; R; u; l) constitutes a heap model.
4
JEAN MAIRESSE AND LAURENT VUILLON
A piece a occupies a region of the R R+ plane of the form f(r; y) 2 R(a) R+ j + l(a)r y + u(a)r g, for some . With an ordered sequence of pieces, we associate a
heap by piling up the pieces, starting from a ground (whose shape is given by a row vector in (R[f?1g)R). The piling occurs as follows: a piece a is subject to vertical translations (change of ) and occupies the lowest possible position, provided it is above the ground and the pieces previously piled up (minimal verifying the constraints). It is the Tetris game piling mechanism (except that horizontal translations and rotations are not allowed). The piling mechanism is best understood visually and on an example. Example 2.1. We consider the following heap model. A = fa; bg, R = f1; 2; 3g; R(a) = f1; 2g, R(b) = f2; 3g;
u(a) = [1 + 2; 1; ?1]; l(a) = [0; 0; ?1]; u(b) = [?1; 1; 1 + 2 ]; l(b) = [?1; 0; 0].
We consider an horizontal ground associated with the word w = ababa.
(0; 0; 0).
We have represented, in Fig. 2, the heap
a
b
a a
b
b a a
b
a
F IGURE 2. Heap associated with the word ababa. We recall some standard definitions and notations. We denote by N and R the sets Nnf0g and Rnf0g respectively. These notations should not be confused with the Kleene star that we now define. Let A be a finite set (alphabet). We denote by A the free monoid on A, that is, the set of (finite) words equipped with concatenation. The empty word is denoted by e. The length of a word w is denoted by jwj and we write jwja for the number of occurrences of the letter a in w. We denote by alph(w) the set of letters appearing in w. We write w = w1 wn; n = jwj. An infinite word (or sequence) is a mapping u : N ! A. We write u = u1 u2 . The set of infinite words is denoted by A! . An infinite word u is periodic if there exists l 2 N such that ui+l = ui ; 8i 2 N. In this case, we write u = (u1 ul )! . We denote by u[n] = u1u2 un the prefix of length n of an infinite word u.
When A is the set of pieces of a heap model, (infinite) words will also be called (infinite) schedules. We also interpret w 2 A as a heap, i.e. as a sequence of pieces piled up in the order given by the word.
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
5
The upper contour of the heap w is a row vector xH (w) in (R [ f?1g)R, where xH (w)r is the height of the heap on slot r. The vector xH (e) corresponds to the shape of the ground. The height of the heap w is (1)
yH (w) = max x (w) : r2R H r
There is a useful interpretation of heap models in terms of task resource models, see [18]. The pieces correspond to tasks and the slots to resources. The difference u(a)r ? l(a)r ; r 2 R(a), corresponds to the time during which the task a requires the resource r. The execution of a task begins as soon as all the required resources, used by earlier tasks, become free. The shape of the ground xH (e) codes the initial availability instants of the resources. For example, this interpretation is effective for the model of Figure 1. We recall that a set K equipped with two operations and is a semiring if is associative and commutative, is associative and distributive with respect to , there is a zero element 0 (a 0 = a; a 0 = 0 a = 0) and a unit element 1 (a 1 = 1 a = a). The set Rmax = (R[f?1g;max; +) is a semiring, called the (max,+) semiring. From now on, we use the semiring notations: = max; = +; 0 = ?1 and 1 = 0. Note that Rmax is an idempotent semiring, i.e. verifies a a = a. The semiring Rmin is obtained from Rmax by replacing max by min and ?1 by +1. The subsemiring B = (0; 1; ; ) is the boolean semiring. We use the matrix and vector operations induced by the semiring structure. For matrices A; B of appropriate sizes, (A B)ij = Aij Bij = max(Aij ; Bij ), (A B)ij = k Aik Bkj = maxk (Aik + Bkj ), and for a scalar a, (a A)ij = a Aij = a + Aij . We usually omit the sign, writing for instance AB instead of A B . On the other hand, the operations denoted by +; ?; and = always have to be interpreted in the conventional algebra. We define the ‘pseudo-norm’ jAj = maxij Aij . We denote by 0, resp. 1, the vector or matrix whose elements are all equal to 0, resp. 1 (with the dimension depending on the context). Given an alphabet A, a (max,+) automaton of dimension k is a triple (; ; ), where k; 6= 0; and 2 Rmax k1; 6= 0; are the initial and final vectors and where 2 R1max kk is a morphism. The morphism is entirely defined by the matrices : A ! Rmax (a); a 2 A; and for w = a1 an, we have (w) = (a1) (an) (product of matrices in Rmax). The map y : A ! Rmax, y(w) = (w) is said to be recognized by the (max,+) automaton. A (max,+) automaton is a specialization to the Rmax semiring of the classical notion of an automaton with multiplicities, see [8, 15]. An automaton (; ; ) of dimension k over the alphabet A is represented graphically by a labeled digraph. The graph has k nodes; if (a)ij > 0 then there is an arc between nodes i and j with labels a and (a)ij ; if i > 0 then there is an ingoing arrow at node i with label i and if j > 0 then there is an outgoing arrow at node j with label j . Examples appear in Figures 8,9 or 10.
L
For each piece a of a heap model H, we define the matrix M(a) 2 RR max by
(2)
8 > u(a)r ? l(a)s :0
if s = r; r 62 R(a); if r 2 R(a); s 2 R(a); otherwise.
Variants of Theorem 2.2 are proved in [11, 18, 20]. Theorem 2.2. Let H = (A; R; R; u; l) be a heap model and let I 2 RR max be the ground shape. For a word w = a1 an, the upper contour and the height of the heap verify
6
JEAN MAIRESSE AND LAURENT VUILLON
(products in Rmax)
xH (w) = I M(a1 ) M(an ) ; yH (w) = I M(a1 ) M(an )1 : More formally, yH is recognized by the (max,+) automaton (I; M; 1). (3)
From now on, we identify the heap model and the associated (max,+) automaton, writing either H = (A; R; R; u; l) or H = (I; M; 1). We also call H a heap automaton. Example 2.3. In the model considered in Figure 1 and Example 2.1, the matrices associated with the pieces are
0 1 2 1 M(a) = @ 12 1 0
0
0 0 1
1 01 0 0 1 A ; M(b) = @ 0 1 1 2 A : 0
1 1 2
The coordinates have to be interpreted in Rmax. 3. O PTIMAL B EHAVIOR Given a (max,+) automaton U following limit: (4)
= (; ; ) and its recognized map y, we consider the
min (U ) = lim sup n1 wmin 2An y(w) n!+1
If we have i > 0; 8i, or i > 0; 8i, then the above lim sup is in fact a limit. This follows from the subadditive inequality: j(w1w2 )j j(w1)j + j(w2 )j, see [18] for details. The optimal problem is defined as follows. Evaluate min (U ) and find w 2 A! such that limn y(w[n])=n = min (U ). Such a solution w 2 A! is called an optimal sequence or schedule. When we consider a heap automaton H, the limit min (H) is equal to the minimal asymptotic growth rate of a heap. When the heap model is associated with a Petri net, as in Figure 1, the maximal throughput of the net is given by 1=min (H). In this case, determining an optimal schedule is usually the central problem as it determines the most efficient way to operate the net. In a heap automaton, if one of the pieces, say a, is such that IjR(a) = 0, then the optimal problem becomes trivial. Indeed, we have yH (an ) = 0; 8n; hence a! is optimal. From now on, we assume that IjR(a) 6= 0; 8a 2 A. With this assumption, we have yH (w) > 0; 8w 2 A . Two (max,+) automata U = (; ; ) and V = ( ; ; ) defined over the same alphabet A are said to be finitely distant if (w) = 0 () (w) = 0 ; (5) 9M < 1; supw2A j(w) ? (w) j M ;
where the supremum is taken over non- 0 terms. The optimal problems coincide for two finitely distant automata U and V , in the sense that min (U ) = min (V ) and that optimal schedules are the same. For instance, two heap automata (I; M; 1) and (I~; M; 1) are finitely distant (under the assumption IjR(a) 6= 0 and I~jR(a) 6= 0; 8a 2 A), see [19] for a proof. In this paper, we often solve the optimal problem by switching from an automaton to another and finitely distant one.
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
7
4. S TURMIAN W ORD As will be seen in x7 an optimal schedule of a two pieces heap model is either periodic or Sturmian. We recall below some basic facts about Sturmian words. They appear in various areas like numbers theory and continued fractions [28], physics and quasi-crystals [24] or discrete event systems [25, 21]. For a reference paper on the subject, see [7, 9]. In the literature, there are many equivalent characterizations of Sturmian words. The present work involves the jump and the mechanical words. A finite word w is a factor of a (finite or infinite) word u if w is a finite subsequence of consecutive letters in u, i.e. w = ui ui+1 ui+n?1 for some i and n. Let the complexity function of u be the function p : N ! N which counts the number of factors of a given length appearing in u. We define a Sturmian word as an infinite word such that p(n) = n + 1. In particular, it is defined over a two letters alphabet as p(1) = 2.
For an infinite word u, we have the following property: if p(n0) n0 for some n0 2 N then the infinite word is ultimately periodic (i.e. 9n 2 N; 9l 2 N such that ui+l = ui; 8i n). As a consequence, Sturmian words are the non ultimately periodic words with minimal complexity. We now define jump and mechanical words. Under some irrationality condition, these words are Sturmian. A converse result, stating that a Sturmian word can be represented as a jump or a mechanical word, is given in Remark 4.1. Jump word. Let us consider 1; 2 2 R+ and 2 R+; < 2. We consider the points fn1; n 2 Ng as labeled by a and the points fn2 + ; n 2 Ng as labeled by b. Let us consider the set fn1; n 2 Ng [ fn2 + ; n 2 Ng in its natural order and the corresponding sequence of labels. Each time there is a double point, we choose to read a before b. We obtain the jump word w with characteristics (1 ; 2; ). If 1=2 is rational then w is periodic and if 1 =2 is irrational then w is Sturmian.
α2
α1
0
a
b
b
a b
b
ab
b
b a
b
b a
F IGURE 3. Representation of a jump word. Another more common but absolutely equivalent description uses cutting sequences. Let us consider a straight line y = x + ; 2 R+; 2 R+; and its intersection points with the square grid consisting of all vertical and horizontal lines with integer coordinates. By restriction to the positive quadrant R+R+, we obtain an ordered sequence Q1 ; Q2; of intersection points. We label Qn with a if it is on a vertical line, with b if it is on an horizontal line and with ab if it is the intersection of an horizontal and a vertical line. The sequence of labels provides an infinite word w which is said to be the cutting word with characteristics ( ; ). By orthogonal projection of the points Qn (with their labels) on the horizontal axis, we obtain easily the following equivalences between cutting and jump words. The jump word (1; 2; ) is equal to the cutting word (1=2; 1 ? =2); the cutting word ( ; ) is equal to the jump word (1; 1= ; (d e ? )= ).
8
JEAN MAIRESSE AND LAURENT VUILLON
Mechanical word. Let us consider whose n-th letter is given by
(
(6)
wn = a b
2 [0; 1]; 2 R. We define the infinite word w
if d(n + 1) + e ? dn + e = 0 if d(n + 1) + e ? dn + e = 1 :
We say that w is the mechanical word with characteristics (; ). If is rational then w is periodic and if is irrational then w is Sturmian. Mechanical words were introduced by Morse and Hedlund [27]. Their interest comes from the existence of an explicit arithmetic formula to compute the n-th letter in the word. For a proof of the following equivalences, see [9]. The mechanical word (; ) is equal to the cutting word (=(1 ? ); =(1 ? )); the cutting word ( ; ) is equal to the mechanical word ( =(1 + ); =(1 + )). We conclude, and this is the result that we use in the following, that the jump word (1; 2; ) is equal to the mechanical word defined by
? 2 1 1 + 2 ; 1 + 2 :
Remark 4.1. With the definitions given above, it is not true that any Sturmian word can be represented as a jump, cutting or mechanical word. To overcome this, let us perform simultaneously the following modifications in the definitions. In the jump word, we read b before a whenever there is a double point; in the cutting word, points which lie on the intersection of an horizontal and a vertical line are labeled by ba; in the mechanical word, we change d:e into b:c in (6). The equivalence results between jump, cutting and mechanical words remain true with the new definitions. But now, we can state an additional result, see [9]. Given a Sturmian word w, there exists 1; 2 2 R+; 1=2 62 Q and 2 R+; < 2, such that w is the jump word (1 ; 2; ) (with one of the two possible conventions for double points). There are analog statements for the cutting and mechanical words. 5. (M AX ,+) AUTOMATON
nn. The 5.1. (Max,+) and (min,+) spectral theory. Let us consider a matrix A in Rmax spectral problem consists in solving the equation uA = u, where 2 R is called an 1n an eigenvector (with u 6= (0; : : : ; 0)). A matrix A is irreducible eigenvalue and u 2 Rmax if for all i; j , there exists k such that Akij > 0. Next result is certainly the most famous and the most often rediscovered result in the (max,+) semiring. Different versions with various degrees of generality can be found in [14, 29, 23, 13], see also the reference books [4, 26]. Theorem 5.1 ((max,+) Perron-Frobenius). The maximal eigenvalue max (A) of a matrix
n is equal to the maximal circuit mean of A: A in Rnmax
M
A i i + + A ik i : (Ai i Aik i )1=k = i max ;::: ;i k k i ;::: ;ik If the matrix A is irreducible, then max (A) is its unique eigenvalue. n For a matrix A 2 Rn min , we have an analog result obtained by replacing ‘maximal’ by ‘minimal’ and max by min in the statement of Theorem 5.1. nn or A matrix A with coordinates in R [ f0g can be interpreted as being either in Rmax max (A) =
1 2
1
1
1 2
1
1
n Rn min by changing the meaning of 0 accordingly. We use this ambiguity to simplify the statement of Proposition 5.2 below.
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
9
5.2. Deterministic automaton. A (max,+) automaton (; ; ) is deterministic if there exists exactly one i such that i > 0; and if for all letter a and for all i, there exists at most one j such that (a)ij > 0. It is trim if for all state i; there exist words u and v such that (u)i > 0 (i is accessible) and (v) i > 0 (i is co-accessible).
Proposition 5.2. Let U = (; ; ) be a deterministic and trim (max,+) automaton over the alphabet A. We define the Rmin matrix M = mina2A (a) (with 0 = +1). The optimal growth rate min (U ) is equal to min (M), the minimal eigenvalue of M . Let aij 2 A be a letter in the argmin of mina2A (a)ij and let (i1 ; : : : ; il ) be a circuit of M such that (Mi1 i2 + + Mil i1 )=l = min (M). An optimal schedule is provided by (ai1 i2 ail i1 )! .
As the automaton is deterministic, there are no max operations involved in the computation of (w) ; w 2 A . Hence U can be interpreted as a (min,+) automaton, for which the optimal behavior problem is easily solvable (as is the worst case problem for (max,+) automaton, see [16, 18]). For a complete proof of the proposition, see xIX. in [16].
We often use the following procedure: Given a (max,+) automaton, we find a deterministic, trim, and finitely distant automaton, then we apply Proposition 5.2 to the new automaton.
l , we define (A) 2 Rkmax l to be the 5.3. Cayley automaton. Given a matrix A in Rkmax matrix such that A = jAj (A) (if A = 0 then (A) = 0). It verifies j(A)j = ij (A)ij = 1 (except if A = 0). We say that (A) is the normalized matrix associated with A. Let us consider a (max,+) automaton U = (; ; ) over the alphabet A. We define
L
(U ) = f((w)); w 2 A g : In the case of a heap automaton H, (H) is the set of normalized upper contours. Let us assume that (U ) is finite. Then we define the Cayley automaton of U . It is a deterministic (max,+) automaton of dimension (U ) over the alphabet A. It is defined by (; ; ) where for u; v 2 (U ); a 2 A, ( ( j j if u = () u = ; (a)uv = ju(a)j if (u(a)) = v and u = u : 0 0 otherwise otherwise : (7)
The automaton U and its Cayley automaton both recognize the same map, i.e.
(w) = (w) ; 8w 2 A :
The proof is immediate, see also [16]. The dimension of the Cayley automaton is in general much larger than the one of U . However, it is deterministic, and assuming that i > 0; 8i, it is also trim. In particular when H is a heap automaton and (H) is finite, then the Cayley automaton is deterministic and trim. Applying Proposition 5.2 to it, we conclude that there exists a periodic optimal schedule. For an illustration, see x7.2 and Example 7.2. The procedure described above is similar to the classical determinization algorithm for boolean automata. The difference is of course that (U ) is always finite in the boolean case. 5.4. Completed automaton. Given a heap model H, it is easy to see that (H) is infinite as soon as there exists two pieces a and b whose set of slots are not the same. This motivated the introduction in [19] of the refined notion of normalized completed contours. In some cases, the set of such contours will be finite whereas (H) is infinite. Here, we recall
10
JEAN MAIRESSE AND LAURENT VUILLON
only the results that will be needed. For details, and in particular for an algebraic definition of completion in terms of residuation, see [19]. Given a row vector u, let u ~ be the column vector defined by u~r = ?ur if ur > 0 and u~r = ur = 0 otherwise. Let a be a piece and M(a) its associated matrix. We recall that l(a) and u(a) are row vectors. It follows from the definition in (2) that M(a) = I l~(a)u(a), where I is the identity matrix defined by Iii = 1 and Iij = 0; i 6= j . We associate with a the pieces a and a, which are the upper and lower contour pieces. More precisely, a and a are defined by their matrices (8) M(a) = I u~(a)u(a); M(a) = I ~l(a)l(a) : An example is provided in Figure 4. For clarity, pieces of height 1 are represented by a thick line. piece a
piece a
piece a
F IGURE 4. A piece and its associated upper and lower contour pieces. Let us consider a heap model H = (A; R; R; u; l), also described as the heap automaton H = (I; M; 1). Given a row vector u 2 RRmax, interpreted as the upper contour of a heap, we define the completed contour (u) 2 RR max as follows (9) (u)i = a2min uM(a)i : R? (i) 1
The vector (u) can be loosely described as the maximal upper contour such that a heap piled up on u is the same as a heap piled up on (u). More precisely,
8w 2 A ; 8i 2 [fa2alph(w)gR(a); (u)M(w)i = uM(w)i :
If i 62 [fa2alph(w)g R(a), then the above property is not necessarily true. In fact, for such an i, we have uM(w)i = ui , (u)M(w)i = (u)i , and in general (u)i > ui . An illustration of this appears in Example 7.3 where for u = (1; 2) we have (u) = (2; 2); uM(b) = (1; 3) and (u)M(b) = (2; 3). For a contour u 2 RR max, we define the normalized completed contour '(u) = ((u)). Let us define (10)
'(H) = f'(I M(w)); w 2 A g :
Let us assume that '(H) is finite. Then we define the completed automaton of H. It is a deterministic and trim (max,+) automaton over the alphabet A, of dimension '(H). It is
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
defined by (; ; 1) where for u; v 2 '(H); a 2 A,
(
u = j(I)j 0
if u = '(I) otherwise
;
and (a)uv
(
= j(uM(a))j 0
11
if '(uM(a)) = v otherwise
:
It is not always true that I M(w)1 = (w)1. Consider for instance the model with a single piece a defined by l(a) = (1; 1); u(a) = (2; 2). We have 1(an)1 = 1M(an )1 + 1; 8n 2 N. However, it is simple to prove that H and its completed automaton are finitely distant. For the upper bound in (5), we can choose M = supu2 Rfj(u)j ?jujg which is finite, see [19] for a formal proof. The two automata have the same optimal behavior. In particular, whenever '(H) is finite, there is a periodic optimal schedule. This will be used several times in x7, see for instance Example 7.3.
R
6. H EAP M ODELS
WITH
T WO P IECES : R EALIZATIONS
OF
D IMENSIONS 2
OR
3
6.1. Bi-completed heap automaton. Given a heap automaton H = (I; M; 1), we are going to define an associated bi-completed heap automaton. For each piece a 2 A, we define N (a) 2 RRR max by
N (a) = ~l(a)u(a); M(a) = I N (a) : We define the upper completed pieces a ; a 2 A, and the lower completed pieces a ; a 2 A; via their associated (max,+) matrices. (12) M(a ) = I min N (a)M(u) ; M(a ) = I min M(u)N (a) : u2A u2A
(11)
The matrix I N (a)M(u) is associated with the piece, say a0, obtained by piling up a and the part of the lower contour piece u corresponding to the slots R(a). The piece a0 has the property that the heaps a0u and au are identical. The piece a can be interpreted as the piece with lower contour l(a) and with the biggest possible upper contour such that the asymptotic behavior of a heap is not modified when replacing a by a . There is an analog interpretation for the pieces a . We say that the pieces a are completed from above, and that the pieces a are completed from below. An illustration is given in Example 6.1 and Figure 5. We define the bi-completed pieces a ; a 2 A, by their associated matrices.
M(a ) = I min N (a )M(u ) : u2A Here the pieces a ; a 2 A, are obtained by completing from below first and then complet(13)
ing from above. We could have chosen to do the opposite and we would have obtained different pieces in general. An example of bi-completion is provided in Figure 5.
~ ; 1), over the alphabet A, defined by M~ (a) = M(a ), is The heap automaton (I; M called the bi-completed heap automaton. It is finitely distant from the original automaton. The argument is similar to the one used for the completed automaton. Both the contour completion of x5.4 and the above piece completion are based on the idea of local transformations which do not modify the asymptotic behavior. However, they are not identical: the completed contours are not the upper contours of the heaps of (bi-)completed pieces.
12
JEAN MAIRESSE AND LAURENT VUILLON
Example 6.1. Let us consider a heap automaton defined by
H = (1; M; 1) over fa; bg where M is
M(a) = 11 33 ; M(b) = 12 23 : Let us compute for instance M(b ). As R(b) = R, we have M(b) = N (b ). We obtain, ^ denoting the min, M(b ) = M N (b) ^ M(b)N (b) (a) 1 2 3 4 1 2 1 2 ^ 1 1 = ?2 1 2 3 ?1 1 2 3 = 2 3 : b
b
a
a
b
a
b
a
F IGURE 5. Two pieces and the associated upper completed, lower completed and bi-completed pieces. It is simpler to obtain the completed pieces graphically, using the intuition described above. We have represented in Figure 5 the upper, lower and bi-completed pieces: fa ; bg; fa; bg and fa ; bg. On this example, one would obtain different bi-completed pieces by performing the upper completion first and the lower completion second. 6.2. Minimal realization. Let a and b be two pieces. We say that r is a contact slot for the heap ab if M(a)M(b)ij = M(a)ir M(b)rj ; 8i 2 R(a); j 2 R(b) (visually, a is in contact with b at slot r in the heap ab). Let us assume that A is a set of bi-complete pieces, i.e. of pieces which are not modified by the bi-completion operation defined above. Then for any piece a and any slot r 2 R(a), there exist pieces u and v such that r is a contact slot of au and va. In the remainder of the section, we use this property to prove Theorem 6.2. Theorem 6.2. Let H = (I; M; 1) be a heap automaton consisting of two pieces. Over the ~ = (I~; M ~ ; 1) of dimension at most 3 and same alphabet, there exists a heap automaton H ~ have the same which is finitely distant from H. In particular, the two automata H and H optimal behavior. Proof. First, we consider the bi-completed automaton associated with H. For convenience, we set the ground shape to be 1. The new automaton is finitely distant from H, see x3. For simplicity, we use the notation H = (1; M; 1) for the new automaton.
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
13
~ be a subset of R. The heap model Let R be the set of slots of the model and let R ~ obtained by restriction of H to R is denoted by HjR ~ and defined by HjR~ = (1; MjR ~ R~ ; 1) ~ (visually, the new pieces are the old ones restricted to R). Assume that the two pieces a and b of the model have at least one common slot. In ~ contains order for HjR~ to be finitely distant from H, it is necessary and sufficient that R a contact slot for each one of the 4 heaps aa, ab, ba and bb. Indeed, let us assume that R~ contains such contact slots. We have, by definition of a contact slot, M(aa)jR ~ R~ = M(a)jR M (a) = M (aa) , and analog equalities for ab , ba and bb . We ~ R~ ~ R~ ~ R~ jR jR conclude easily that 1
n
o
sup 1M(w)1 ? 1MjR ~ R~ (w)1 jM(a)j jM(b)j :
w2A
Hence, HjR~ is finitely distant from H. We have shown that the condition is sufficient. Let us prove that the condition is necessary. Assume that aa for instance has no con~ . Then we have jM(aa)j ? jMjR tact point in R ~ R~ (aa)j = > 1. It implies that (1=2n)(jM(a2n)j ? jMjR ~ R~ (a2n)j ) = , showing that H and HjR~ are not finitely distant. By choosing one contact slot for each one of the heaps aa; ab; ba and bb, we obtain a ~ of cardinality at most 4 and such that the automaton HjR~ is finitely distant from set R H. We now prove that 3 slots at are in fact always sufficient. We define the application c : R ! P (A2 ), where P (A2 ) denotes the set of subsets of A2 . The set c(r) contains xy if there is a contact at slot r in the heap xy. Let us consider a slot r 2 R(a) \ R(b). As we work with bi-complete pieces, c(r) must contain words starting with a and b and words finishing with a and b. Hence we must have
faa; bbg c(r) or fab; bag c(r) : If we have faa; bbg c(r) (resp. fab; bag c(r)), we complete the slot r with a contact
(14)
slot for the heap ab and one for the heap ba (resp. for aa and bb). We have a set of at most 3 slots which verifies the required properties.
~ to contain a contact slot of Now assume that R(a) \ R(b) = ;. It is enough for R aa and one of bb, hence to be of cardinality at most 2, for HjR~ to be finitely distant from H. Performed on the original heap automaton, instead of the bi-completed one, the above argument would not work. Consider for instance the heap model H of dimension 4 defined by l(a) = (1; 1; 1; 0); u(a) = (3; 2; 3; 0); l(b) = (0; 1; 1; 1) and u(b) = (0; 3; 2; 3). One ~ of R such that HjR~ is finitely distant from can check that there exists no proper subset R H. Example 6.3. Let us illustrate Theorem 6.2 on an example. We consider a heap automaton
H = (1; M; 1) of dimension 4 and consisting of two bi-complete pieces defined as follows
04 4 5 B1 1 2 M(a) = B @2 2 3
0 0 0 0 0 0 1
1 01 0 0 01 CC ; M(b) = BB 0 3 2 2 CC : A @0 2 1 1A 0
5 4 4
The pieces are represented in Figure 6. We have
c(1) = faag; c(2) = fab; bag; c(3) = fab; bag and c(4) = fbbg :
14
JEAN MAIRESSE AND LAURENT VUILLON
~ = f1; 2; 4g or f1; 3; 4g and the heap automaton HjR~ will Here, we can choose either R be finitely distant from H. This can be ‘checked’ on Figure 6. In this example, we do
b
b
a a
F IGURE 6. Heap automaton of dimension 4 and a finitely distant one of dimension 3. not always have 1M(w)1 1MjR ~ R~ (w)1 1.
= 1MjR ~ R~ (w)1.
However we verify that 1
1M(w)1 ?
Theorem 6.2 is a minimal realization type of result. The generic problem of this kind is as follows: Given an automaton with multiplicities in a semiring, find another automaton recognizing the same map and of minimal dimension. In a commutative field, the problem is solved, see [8] for a proof and references. In Rmax, it is a repertoried difficult and unsolved problem, see [17] for partial results and references. Here, our result is specific in several ways. First, we look at a particular type of (max,+) automata, heap automata with two pieces. Second, we look for a realization by a heap automaton and not by an arbitrary (max,+) automaton. Third, we only require a weak type of realization, see (5). 7. H EAP M ODELS WITH T WO P IECES : O PTIMAL S CHEDULES In this section, we prove the main result of the paper, Theorem 7.1. Theorem 7.1. Let us consider a heap model with two pieces. There exists an optimal schedule which is either periodic or Sturmian. Proof. As a by-product of Theorem 6.2, to study heap automata with two pieces, it is enough to consider automata with bi-complete pieces and of dimension at most 3. We are going to prove that there are only four cases which need to be treated (up to a renumbering of pieces and slots) which are:
H = (fa; bg; f1; 2g; R; u;l)
R(a) = f1g; R(b) = f2g R(a) = f1; 2g; R(b) = f1; 2g R(a) = f1; 2g; R(b) = f2g H = (fa; bg; f1; 2;3g;R;u; l) R(a) = f1; 2g; R(b) = f2; 3g : We recall that the function c(:) was defined in the proof of Theorem 6.2.
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
15
(i) If R(a) \ R(b) = ;, we have seen in the proof of Theorem 6.2, that the heap model can be represented with two slots only, one for each piece. (ii) Let us assume that R(a) = R(b). Let r be such that aa 2 c(r). Using (14), we obtain that we have either faa; bbg c(r) or faa; ab; bag c(r). If we are in the second case, we complete r with a contact slot for bb. If we are in the first case, let us consider a slot r0 such that ab 2 c(r0 ). We have, as before, either fab; bag c(r0) or fab; aa; bbg c(r0 ). If we are in the first case, the heap model can be represented using the slots fr; r0g. If we are in the second case, we complete r0 with a contact slot for ba. In all cases, we have found a finitely distant heap model with two slots. (iii) Let us assume that R(b) R(a); R(b) 6= R(a). We consider a slot r 2 R(a) \ R(b) and such that bb 2 c(r). As above, we must have either fbb; ab; bag c(r) or faa; bbg c(r). In the second case, we are back to the situation (ii). In the first case, we complete r with a slot r0 such that aa 2 c(r0). If r0 belongs to R(a) \ R(b), we are back to the case (ii); otherwise we have a new situation: two slots fr; r0g with R(a) = fr; r0g and R(b) = frg. (iv) Let us assume that R(a) \ R(b) 6= ;; R(a)nR(b) 6= ;; R(b)nR(a) 6= ;. We consider a slot r 2 R(a) \ R(b) and such that ab 2 c(r). We have either fab; aa; bbg c(r) or fab; bag c(r). In the first case, we are back to (ii). In the second case, we complete R with a contact slot ra for aa and a contact slot rb for bb. Depending on ra and rb , we are either back to (ii) or (iii) or we have a new situation: three slots fr; ra; rbg with R(a) = fr; rag and R(b) = fr; rbg.
The case R(a) = R(b) = f1g does not need to be treated as it it can be considered as a subcase of R(a) = R(b) = f1; 2g. We consider in x7.1-7.4 the four different cases. For each case, we prove that the results of Theorem 7.1 hold. Hence pasting the cases together, we obtain a proof of the Theorem. Furthermore we provide an explicit way to compute min (H) and an optimal (Sturmian or periodic) solution in each case.
In the sections below, we always denote the heap model considered by H = (A; R; R; u; l) with A = fa; bg and R = f1; 2g or f1; 2; 3g. Viewed as a heap automaton, it is denoted by H = (I; M; 1). We always implicitly assume that we are working with
bi-complete pieces. If one of the two pieces, say a, verifies max (M(a)) = 1, or equivalently u(a) = l(a), then the optimal problem becomes trivial. We have min (H) = 1 and a periodic optimal schedule is provided by a! . From now on, we assume that max (M(a)) > 1 and max (M(b)) > 1. We recall that we have assumed in x3 that for any piece u 2 A, we have IjR(u) 6= 0. We also recall that by modifying the ground shape in a heap automaton, we obtain a finitely distant automaton. Below, in each of the different cases, we choose the ground shape which is the most adapted. 7.1. The case R(a) = f1g; R(b) = f2g. We set ha = u(a)1 ? l(a)1 and hb = u(b)2 ? l(b)2 . We assume that the ground shape is 1. We claim that the jump word u with characteristics (ha ; hb; 0) (see x4) is optimal. Furthermore, we have min (H) = ha hb =(ha +hb ). An example is provided in Figure 7. We now prove this assertion. We define the set of optimal finite words as: MIN
(An) = fv 2 An j yH (v) = wmin y (w)g : 2An H
We recall that given w 2 A! , we denote by w[n] the prefix of w having length n. Let us prove that the jump word u defined by (ha ; hb; 0) is such that u[n] belongs to MIN(An ).
16
JEAN MAIRESSE AND LAURENT VUILLON
b
b
a b
a
b
hb
a b
ha
b a b
b a b
0
ba
F IGURE 7. The optimal schedule is a jump word. We assume that u[n] is not an element of the set MIN(An ) and we choose v We have
2 MIN(An ):
max(xH (u[n])1; xH (u[n])2) > max(xH (v)1 ; xH (v)2 ) =) max(ha ju[n]ja; hbju[n]jb) > max(ha jvja; hbjvjb ) : Let us assume that ha ju[n]ja > hb ju[n]jb (the other case is treated by exchanging the roles of a and b). We have n = ju[n]ja + ju[n]jb = jvja + jvjb and ha ju[n]ja > ha jvja . We conclude that jvjb > ju[n]jb. To summarize, we have ha ju[n]ja > hb jvjb > hbju[n]jb: This is a contradiction with the jump definition of u as by construction we have to consider all the points multiple of hb between 0 and ha ju[n]ja and in particular the point hb jvjb. We conclude that u[n] belongs to MIN(An ). Clearly, u is an optimal word as all its prefixes are finite optimal words. A way to obtain the n-th letter of the word is by using that u is equal to the mechanical word (ha =(ha + hb); hb =(ha + hb )). We have, by definition of u, j ha ju[n]ja ? hb ju[n]jb j max(ha ; hb); 8n. Hence we have limn ju[n]ja=ju[n]jb = hb=ha . It implies that ju[n]ja = ha hb : ha ju[n]ja = h lim min (H) = lim a n ju[n]ja + ju[n]jb ha + hb n n Using the results of x4, we have obtained an optimal schedule which is periodic when ha =hb is rational and Sturmian when ha =hb is irrational. To be complete, let us prove that it is not possible to find a periodic optimal schedule in the case ha =hb irrational. Let u be a finite word and let us define w = u! . As ha =hb is irrational, we have ha juja 6= hbjujb. Let us assume that ha juja > hbjujb. It implies that ha juja > jujhahb =(ha + hb ). We obtain
n n n lim n yH (u )=ju j = lim n nhajuja=ju j > ha hb=(ha + hb ) :
This concludes the proof. 7.2. The case R(a) = f1; 2g; R(b) = f1; 2g. As R(a) = R(b) = R, for all u; v 2 R2max, we have (uM(a)) = (vM(a)) and (uM(b)) = (vM(b)). We deduce that we have
(H) = f(I); (I M(a)); (I M(b))g :
Hence we can solve the optimal problem using the Cayley automaton, whose cardinality is at most 3, and Proposition 5.2. In particular there exists a periodic optimal schedule.
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
17
We can go further in the description of optimal solutions. Let us change the ground shape to I M(a). Now we have (H) = f(I M(a)); (I M(b))g, and the Cayley automaton is of dimension 2. By Prop. 5.2, periodic optimal schedules are obtained by taking as a period the label of some circuit in the Cayley automaton. Hence, it is always the case that one of the schedules a! ; b! or (ab)! is optimal.
Example 7.2. Let us consider the heap automaton H = (1; M; 1) defined by
M(a) = 23 12 ; M(b) = 21 32 :
We have represented the corresponding pieces in Fig. 8. We check easily that
aj2
b
aj3
a
bj2
bj3 1
(1; ?1)
(H) =
1
aj3 1
(?1; 1)
bj3
(1; 1)
1
F IGURE 8. Heap model with two pieces and its Cayley automaton.
f(1); (1M(a)); (1M(b))g = f(1; 1); (1; ?1); (?1; 1)g. Let (; ; 1) be the Cayley
automaton and let M
= min((a); (b)). We have = (1; 0; 0) and 1 00 0 31 00 3 31 0 0 A ; (b) = @ 0 0 3 A ; M = @ 0 2 3 A : 0 3 0 0 0 2 0 3 2 The only eigenvalue of the Rmin matrix M is 2, the corresponding circuits of minimal mean are f2g and f3g and M22 = (a)22; M33 = (b)33. By Proposition 5.2, min (H) = 2 and a! or b! are optimal sequences. 7.3. The case R(a) = f1; 2g; R(b) = f2g. We introduce the following notations: = l(a)1 ? l(a)2 and hb = u(b)2 ? l(b)2 . Note that hb = max (M(b)) > 1 by assumption.
00 3 (a) = @ 0 2
We have
M(a) = 1 ?1 ; M(b) =
For u = (u1 ; u2), we obtain, see (9),
1 0 0 1
(u)1 = uM(a)1 = u1 u2 (u)2 = min(uM(a)2 ; uM(b)2 ) = u2
Hence, we have
(
'(u) = (u) (; 1)
if u2 if u2
< u1 : u1
:
18
JEAN MAIRESSE AND LAURENT VUILLON
Let the ground shape be equal to 1M(a). We have, 8u 2 R2max; u 6= (0; 0); '(uM(a)) = '(1M(a)) = (1M(a)M(a)). We deduce that
'(H) = f'(1M(abn )); n 2 Ng : We also have 1M(abn+1) ? 1M(abn ) = (1; hb). Hence there exists a smallest integer m such that
1M(abm )1 ? 1M(abm )2
() u(a)1 ? u(a)2 ? hmb
It implies in particular that 8n m; '(1M(abn )) = (; 1). We conclude that
'(H) = f'(1M(abn )); n 2 f0; : : : ; mgg : We have proved that '(H) is finite. Hence we can solve the optimal problem using the
completed automaton and Prop. 5.2. We have represented in Figure 9, the completed
a a
a
M(abm?1 ))
(; 1)
b
M(ab))
M(a))
(1
(1
b
b
a
b
b
(1
a
F IGURE 9. Completed automaton automaton in the case m 3. To keep the figure readable, we have not shown the multiplicities. There are exactly m + 2 simple circuits in this automaton with respective labels b and abn; 0 n m. For 0 n m ? 2, the multiplicity to go from '(1M(abn )) to '(1M(abn+1 )) is 1 while the one to go from '(1M(abn+1 )) to '(1M(a)) is always max (M(a)). Hence the circuits of label abn ; 0 n m ? 2; are certainly not of minimal mean weight. We conclude that an optimal schedule can be found among the schedules (abm )! ,(abm?1 )! or b! (if m = 0, then either a! or b! is optimal). An illustration of this is provided in the example below. Example 7.3. We consider a heap automaton H = (1; M; 1) with M defined by
3
M(a) = 3
1 1
; M(b) =
1 0
0
1
:
The corresponding pieces are represented in Figure 10. The completion operation has the following effect: (m; n) = (m; n) if m n and (m; n) = (n; n) if m < n. Hence we have '(H) = f(1; 1); (1; ?1); (1; ?2); (1; ?3)g. Let (; ; 1) be the completed automaton and let M = min((a); (b)). We have
00 B0 (a) = B @0
0 0 0 0 0
0 0 0 0
3 3 3 3
1 01 CC ; (b) = BB 1 A @0
0 0 1 0 0
0 0 0 1
0 0 0 0
1 01 CC ; M = BB 1 A @0
0 0 1 0 0
0 0 0 1
3 3 3 3
1 CC : A
The completed automaton is represented in Figure 10. The matrix M is irreducible, its eigenvalue is min (M) = 3=4 and its minimal circuit is f4; 3; 2; 1g. Hence we conclude that min (H) = 3=4 and that an optimal schedule is (abbb)! .
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
b
a
aj3 1
1
aj3
1
1
(1; 1)
(1;
bj1
bj1
?1)
19
aj3 (1; ?2)
bj1
bj1
1 (1;
?3)
aj3
F IGURE 10. Heap model and its completed automaton. 7.4. The case R(a) = f1; 2g; R(b) = f2; 3g. Let us set ha = u(a)1 ? l(a)1 and hb = u(b)3 ? l(b)3 . Two situations need to be considered: (i) the case u(a)2 > l(a)2 (with the case u(b)2 > l(b)2 being treated similarly) and (ii) the case u(a)2 = l(a)2 and u(b)2 = l(b)2 . We assume first that u(a)2 = l(a)2 and u(b)2 = l(b)2 . We suppose that there exists an infinite heap w with an infinite number of each piece and without any ‘gap’ at slots 1 and 3. Now, we focus on the second slot of the heap w. The heights of the pieces a and b at slot 2 are given by fnha + I1 + l(a)2 ? l(a)1 ; n 2 Ng and fnhb + I3 + l(b)2 ? l(b)3 ; n 2 Ng respectively. We set the ground shape to be
I = (0; 1; 0) = (l(a)1 ? l(a)2 ; 1; l(b)3 ? l(b)2 ) : The heights of the pieces at slot 2 are now given by fnha ; n 2 Ng and fnhb; n 2 Ng. Hence, the sequence of labels (read from bottom to top) at slot 2 is the jump word w defined by (ha ; hb; 0). Now, if we pile up the pieces according to w, we indeed obtain a (15)
heap without any gap on slots 1 and 3. An illustration is given in Figure 11. On slot 2, the pieces have been shortened to facilitate their identification.
a
a
b
b a
a
a
b
b
b b a
b
b b a
b
a
F IGURE 11. Optimal heap w = abbabbaba .
20
JEAN MAIRESSE AND LAURENT VUILLON
Let us prove that w is optimal. We set of w[n] is b, we have
= xH (w[n])3 ? xH (w[n])1. If the last piece
= xH (w[n])3 ? xH (w[n])2 + xH (w[n])2 ? xH (w[n])1 = u(b)3 ? u(b)2 + xH (w[n])2 ? xH (w[n])1 : In the heap, two successive pieces a are at a distance ha . Hence a piece b and the previous piece a are at a distance between 0 and ha at slot 2. We conclude that u(b)3 ? u(b)2 + u(a)2 ? u(a)1 u(b)3 ? u(b)2 + u(a)2 ? u(a)1 + ha : We obtain similar bounds (independent of n) when the last piece of w[n] is a. It implies that we have limn xH (w[n])1=n = limn xH (w[n])3=n. As the heap w is as compact as possible, it follows immediately that w is optimal. If ha =hb is rational then w is periodic and otherwise it is Sturmian. The n-th letter of w can be computed explicitly using that w is the mechanical word (ha =(ha + hb ); hb=(ha + hb)). Using an argument of x7.1, we can show that if ha =hb is irrational, there does not exist any periodic optimal schedule. Still using an argument of x7.1, we also obtain that min (H) = ha hb =(ha + hb). Let us assume now that u(a)2 > l(a)2 . We must have u(a)2 ? l(a)2 < u(a)1 ? l(a)1 and u(b)2 ? l(b)2 < u(b)3 ? l(b)3 otherwise the pieces would not be bi-complete. We assume for the moment that ha =hb is irrational. We still consider the ground shape defined in (15). It is immediate to check that '(I M(aa)) = '(I M(a)) and '(I M(bb)) = '(I M(b)).We deduce that we have
'(H) = fI; '(I M(a)); '(I M(b))g [ f'(I M(abw)); '(I M(baw)); w 2 A g : Let us study the set f'(I M(abw)); w 2 A g first. Let x be the jump word (ha ; hb; u(a)2? l(a)2 ). Let us assume that the corresponding infinite heap has no gap on slots 1 and 3. Then, the heights of the pieces on slot 2 are: lower part of piece a: fnha ; n 2 Ng; upper part of piece a: fnha + u(a)2 ? l(a)2 ; n 2 Ng; lower part of piece b: fnhb + u(a)2 ? l(a)2 ; n 2 Ng; upper part of piece b: fnhb + u(a)2 ? l(a)2 + u(b)2 ? l(b)2 ; n 2 Ng.
As ha =hb is irrational, by density of the points fnhb + (mod ha ); n interval [0; ha], there exists a smallest couple (p; q) 2 N2 such that (16) or
2 Ng in the
pha < qhb + u(a)2 ? l(a)2 < pha + u(a)2 ? l(a)2 qhb + u(a)2 ? l(a)2 < pha < qhb + u(a)2 ? l(a)2 + u(b)2 ? l(b)2 :
This is a violation of the piling mechanism, see Figure 12-(i) for an illustration. Hence we conclude that there are some gaps on slot 1 or 3 in the heap x. The word x[p + q] is the longest prefix of x such that there is no gap at slots 1 and 3 in the associated heap. We have jx[p + q]ja = p and jx[p + q]jb = q. In Figure 12-(i), we have p = 2; q = 3 and x[5] = abbab. Let us consider a heap abu with juj = p + q. There are two possible cases. (1) There is a gap somewhere in the heap at slot 1 or 3. This implies that we have in heap u a contact at slot 2 between a piece a and a piece b, or between a piece b and a piece a. Hence, we have or
'(I M(abu)) = '(I M(abv)); jvj < p + q '(I M(abu)) = '(I M(bav)); jvj < p + q :
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
21
b a
b b
b
a
b
a
b a
b
b
a
b a
(i)
b
(ii)
b a
b
(iii)
F IGURE 12. (i) Heap x[5] = abbab, (ii) heap abbabab, (iii) heap abbabbb. This case is illustrated in Figure 12-(ii) where '(I M(abbabab))
babab and v = e.
= '(I M(ab)), i.e. u =
(2) There is no gap at slots 1 and 3. In this case, we must have abu = x[n]am or abu = x[n]bm with n < p + q. In the heaps x[n]amb and x[n]bma, there is necessarily a contact at slot 2 between the last two pieces. We conclude that '(I M(x[n]am )) = '(I M(a)) and '(I M(x[n]bm )) = '(I M(b)). This case is illustrated in Figure 12-(iii) where '(I M(abbabbb)) = '(I M(b)). To summarize, we have proved that
f'(I M(abw)); w 2 A g = f'(I M(a)); '(I M(b))g [ f'(I M(abw)); '(I M(baw)); jwj < p + qg :
We can perform a similar analysis on heaps starting with the pieces ba, using the jump word y = bz where z is the jump word (ha ; hb; hb ? u(b)2 + l(b)2 ). We obtain the existence of a minimal couple (r; s) 2 N2 such that
f'(I M(baw)); w 2 A g = f'(I M(a)); '(I M(b))g [ f'(I M(abw)); '(I M(baw)); jwj < r + sg :
Setting m = max(p + q; r + s), we conclude that
'(H) = fI; '(I M(a)); '(I M(b))g [ f'(I M(abw)); '(I M(baw)); jwj < mg : We have proved that '(H) is finite, hence we can apply Proposition 5.2 to the completed
automaton. There exists an optimal schedule which is periodic.
Now, let us assume that ha =hb is rational. We still consider the jump word x with characteristics (ha ; hb; u(a)2 ? l(a)2 ). It is periodic, see x4. If the corresponding heap has no gap on slots 1 and 3, then the schedule x is optimal (same argument as in the first part of the section). The period can also be obtained via the finite completed automaton. If the heap has a gap somewhere on slot 1 or 3, it implies that there exists (p; q) such that (16) is verified. We conclude the proof by showing that '(H) is finite exactly as in the case ha =hb irrational.
22
JEAN MAIRESSE AND LAURENT VUILLON
A close look at the details of the above proof allows a complete description of the simple circuits in the completed automaton which can possibly be of minimal mean weight. The labels of these circuits are: a; b; x[p + q]; y[r + s]; x[p + q]y[r + s]. Hence, one of the following schedules is optimal: fa! ; b! ; x[p + q]! ; y[r + s]! ; (x[p + q]y[r + s])! . Example 7.4. We treat completely an instance of the jobshop described in the introduction, see Figure 1. The durations of the activities are assumed to be 1 = ; 2 = 4 (= 4 ); 1 = and 2 = 1 ? . We assume that we have (in Rmax) 11 < 1 < 15; or equivalently 1=15 < < 1=11. The corresponding heap model H is defined by
0 5 4 M(a) = @ 5 4 0
The completed automaton of
1
bj1?
1
01 0 01 1 A ; M(b) = @ 0 1 A : 0
1
The
bj1
bj1 ( ? 1; ? 1; 1)
; ?; ?)
1
H = ((I M(a)); M; 1) is represented in Figure 13.
bj1
(1
a j 5
0
0 0 1
1
1
? 1;5 ? 1; 1)
( 6
? 1; 10 ? 1; 1)
( 11
aj1
aj1 a j 16 ? 1
F IGURE 13. Completed automaton. labels of the simple circuits are a; b; ba; ba2 and ba3. Their respective mean weights are 5; 1; 1=2; 1=3 and 15=4. Hence the label of the circuit of minimal mean weight is ba2 if 1=3 15=4 and ba3 if 15=4 1=3. We conclude that an optimal schedule is
(
(ba2)! (ba3)!
if if
4=45 < 1=11 1=15 < 4=45
The greedy scheduling consists in always allocating the resource to the first task which is ready to use it (i.e. w[n+1] = w[n]a, resp. w[n+1] = w[n]b, if we have xH (w[n])a < xH (w[n])b, resp. xH (w[n])b < xH (w[n])a). In the present model, the greedy schedule is (ba3 )! . The case 2]4=45; 1=11[ is particularly interesting as greedy scheduling is suboptimal, see Figure 14. In [22] xIV, the optimal problem is studied for the model of Figure 1. The above phenomenon seems to have gone unnoticed by the authors. They restrict their attention to a slightly different criterion, minimization of the idle time of the resource, and they show that greedy schedules are indeed optimal for this criterion. Summary. We recapitulate below the results on optimal schedule proved so far. We set
ha = max (M(a)) and hb = max (M(b)).
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
a
23
a
b
a
a
b a
a a
b a
a
b
a
a
b a
a
a
a
b
b a
a
F IGURE 14. Model with = 8=89, greedy schedule and optimal schedule.
R(a) = f1g; R(b) = f2g R(a) = f1; 2g; R(b) = f1; 2g R(a) = f1; 2g; R(b) = f2g R(a) = f1; 2g; R(b) = f2; 3g
ha =hb 2 Q
ha =hb 62 Q
periodic periodic periodic periodic
Sturmian periodic periodic periodic or Sturmian
7.5. Finite Sturmian word. A finite Sturmian word is by definition a factor of a Sturmian word. A (finite or infinite) word w is balanced if j juja ? jvja j 1 for all factors u; v of w such that juj = jvj. It is known, see e.g. [9] for a proof, that a finite word is a finite Sturmian word iff it is balanced. An infinite word is Sturmian iff it is balanced and aperiodic. The balanced words are the ones in which the letters are the most regularly distributed. The shortest non-balanced word is aabb. The moral of next proposition, a strengthening of Theorem 7.1, is that ‘optimality equals regularity’. Proposition 7.5. Let H be a heap model with two pieces. Then there exists a balanced optimal schedule. In other words, there exists either a Sturmian optimal schedule or a finite Sturmian word u such that the periodic schedule u! is optimal. Proof. A jump word is a balanced word. Hence each time the optimal schedule is given by a jump word (either periodic or Sturmian), it has the desired property. It is proved in x7.1-7.4, that an optimal schedule was always either a jump word or a periodic word to be found among the following ones: a! ; b! ; (ab)! (x7.1); b! ; (abn)! ; n 2 N (x7.3); a! ; b! ; x[p+q]! ; y[r+s]! ; (x[p+q]y[r+s])! (x7.4). All these possible periods are balanced. Ratio constraints. In [25, 21, 22], the authors were primarily interested in the following constrained optimal problem: find w 2 A! minimizing limn yH (w[n])=n while verifying limn jw[n]ja=n = where 0 1 is some given ratio constraint.
24
JEAN MAIRESSE AND LAURENT VUILLON
In a manufacturing model, the motivation is to maximize the throughput while meeting a given production ratio. For this constrained problem, and for the model of Figure 1, it is proved in [21, 22] that the optimal schedule is always the jump word (1 ? ; ; 0). Two points are worth being noticed. First, the optimal schedule is either Sturmian ( 62 Q) or periodic ( 2 Q) of the form u! where u is the shortest finite Sturmian word meeting the ratio constraint. This result is analog to Proposition 7.5. Second, the optimal schedule does not depend on the timings of the model (1; 2; 1 and 2 in Figure 1). Unfortunately, these two properties depend heavily on the specific shape of the pieces in the model of Figure 1. They are not verified in a general heap model with two pieces, as shown below. Example 7.6. Consider the heap model of Example 7.2. We look at the constrained optimal problem with ratio = 1=2. The optimal schedule of length 2n; n 2 N; is an bn as b
b a b b a a
a
F IGURE 15. Optimal and worst schedule of ratio 1/2 and length 4. illustrated on Figure 15. No infinite balanced word with ratio 1=2 is optimal. A possible optimal schedule is w = aba2 b2 an bn . Here, the schedule (ab)! , whose period is the shortest finite Sturmian word meeting the constraint, is not an optimal but a worst case schedule! Examples in the same spirit appeared in [12], xVI-1 and in [20], x5.1.
One may consider a more general setting for constrained problems. Let L A be a language of admissible behaviors and let us consider the problem of finding a schedule which is optimal among the schedules whose prefixes belong to L. When there exists a deterministic automaton U finitely distant from H, and when L is either rational or algebraic (context-free), then there is a general methodology to solve such a constrained problem. In particular, when L is rational there exists a periodic optimal schedule. For details, see [18, 19]. On the other hand, when the unconstrained problem admits a Sturmian optimal schedule, it is not clear how to solve the constrained problem. 8. C ONCLUSION : H EAP M ODELS
WITH
T HREE
OR
M ORE P IECES
The case of a heap model with an arbitrary number of rational pieces (8a 2 A; u(a); l(a) 2 QRmax) is solved in [19]. There always exist a periodic optimal schedule in this case. In x7, we have treated the case of a heap model with two general pieces. There always exist a periodic or Sturmian optimal schedule, Theorem 7.1. We have summarized these results in the table below.
OPTIMAL SEQUENCES IN A HEAP MODEL WITH TWO PIECES
QR max RR max
jAj = 2
jAj > 2
periodic periodic or Sturmian
periodic ?
25
Let us now consider heap models with three or more general pieces. Generalized versions of jump words appear naturally in some models. Let A = fa1; a2; ; ak g be the alphabet. We consider i 2 R+; i 2 R+; i < i; for i 2 f1; : : :; kg. We label the points fni + i ; n 2 Ng by ai and we consider the set [ki=1fni + i ; n 2 Ng in its natural order. Let w be the the corresponding infinite sequence of labels. By convention, in case of multiple points, we read the labels in lexicographic order (a1 < a2 < < ak ). The infinite word w is called the (hypercubic) billiard sequence with characteristics (i; i ; i = 1; : : :; k). When the vector (1 ; : : :; k) is totally irrational (no rational relations between the coordinates), we have a generalization of Sturmian words. Billiard sequences have been studied in [3, 6]. Now let us consider the heap model H = (A; f1; : : :; k + 1g; R; u; l) with R(ai ) = fi; k + 1g; u(ai)i ? l(ai )i = hi > 1 and u(ai )k+1 = l(ai )k+1 . The ground shape is assumed to be (0; : : :; 0; 1). This is a generalization of the first case treated in x7.4. Let w be the billiard sequence with characteristics (hi ; 0; i = 1; : : :; k). Using an argument similar to the one in x7.4, we obtain that w is an optimal schedule. The subword obtained from w by restriction to two letters, say ai and aj , is the jump word (hi ; hj ; 0). It follows that limn jw[n]jai =jw[n]jaj = hj =hi: We deduce that
Q
k h h1 jw[n]ja = i=1 i min (H) = lim P P k jw[n]j k h?1 Qk h : n ai i=1 i i=1 j =1 j The case, generalizing x7.1, of a heap model (A; f1; : : :; kg; R; u; l) with R(ai ) = i, is 1
treated similarly, and we obtain billiard sequences as the optimal schedules.
c
b
a
F IGURE 16. Heap model with unknown optimal behavior. The general case, even with three pieces, is an open problem. For instance, we do not know the optimal schedule in the model of Figure 16, when = 62 Q. ACKNOWLEDGMENTS The authors thank St´ephane Gaubert and Bruno Gaujal for numerous discussions on the subject.
26
JEAN MAIRESSE AND LAURENT VUILLON
R EFERENCES [1] E. Altman, B. Gaujal, and A. Hordijk. Admission control in stochastic event graphs. Technical Report 3179, INRIA, Rocquencourt, France, 1997. [2] E. Altman, B. Gaujal, A. Hordijk, and G. Koole. Optimal admission, routing and service assignment control: the case of single buffer queues. In Proceedings of the 37th IEEE CDC, Tampa, Florida, 1998. [3] P. Arnoux, C. Mauduit, I. Shiokawa, and J. Tamura. Complexity of sequences defined by billiard in the cube. Bull. Soc. Math. France, 122:1–12, 1994. [4] F. Baccelli, G. Cohen, G.J. Olsder, and J.P. Quadrat. Synchronization and Linearity. John Wiley & Sons, New York, 1992. [5] A. Barabasi and H. Stanley. Fractal Concepts in Surface Growth. Campbridge University Press, 1995. [6] Y. Baryshnikov. Complexity of trajectories in rectangular billiards. Commun. Math. Phys., 174:295–309, 1995. [7] J. Berstel. Recent results on Sturmian words. In J. Dassow and A. Salomaa, editors, Developments in Language Theory. World Scientific, 1996. [8] J. Berstel and C. Reutenauer. Rational Series and their Languages. Springer Verlag, 1988. [9] J. Berstel and P. S´ee´ bold. Sturmian words. In M. Lothaire, editor, Algebraic Combinatorics on Words. 1999. To appear. [10] M. Brilman. Evaluation de Performances d’une Classe de Syst`emes de Ressources Partag´ees. PhD thesis, Univ. Joseph Fourier - Grenoble I, 1996. [11] M. Brilman and J.M. Vincent. Dynamics of synchronized parallel systems. Stochastic Models, 13(3):605– 619, 1997. [12] J. Carlier and P Chretienne. Timed Petri net schedules. In Advances in Petri Nets, number 340 in LNCS, pages 62–84. Springer Verlag, 1988. [13] G. Cohen, D. Dubois, J.P. Quadrat, and M. Viot. A linear system-theoretic view of discrete-event processes and its use for performance evaluation in manufacturing. IEEE Trans. Automatic Control, 30:210–220, 1985. [14] R. Cuninghame-Green. Describing industrial processes with interference and approximating their steadystate behaviour. Oper. Res. Quat., 13(1):95–100, 1962. [15] S. Eilenberg. Automata, languages and machines, volume A. Academic Press, New York, 1974. [16] S. Gaubert. Performance evaluation of (max,+) automata. IEEE Trans. Aut. Cont., 40(12):2014–2025, 1995. [17] S. Gaubert, P. Butkoviˇc, and R. Cuninghame-Green. Minimal (max,+) realization of convex sequences. SIAM J. on Control and Opt., 36:137–147, 1998. [18] S. Gaubert and J. Mairesse. Task resource models and (max,+) automata. In J. Gunawardena, editor, Idempotency, volume 11, pages 133–144. Cambridge University Press, 1997. [19] S. Gaubert and J. Mairesse. Computation of Lyapunov exponents in heaps of pieces: worst, optimal and average case. In preparation, 1998. [20] S. Gaubert and J. Mairesse. Modeling and analysis of timed Petri nets using heaps of pieces. IEEE Trans. Aut. Cont., 1998. To appear. [21] B. Gaujal. Optimal allocation sequences of two processes sharing a resource. Discrete Event Dynamic Systems, 7:327–354, 1997. [22] B. Gaujal, M. Jafari, M. Baykal-G¨ursoy, and G. Alpan. Allocation sequences of two processes sharing a resource. IEEE Transactions on Robotics and Automation, 11(5):748–753, 1995. [23] M. Gondran and M. Minoux. Valeurs propres et vecteurs propres dans les dio¨ıdes et leur interpr´etation en th´eorie des graphes. EDF, Bulletin de la Direction des Etudes et Recherches, Serie C, Math´ematiques Informatique, 2:25–41, 1977. [24] B. Grunbaum and G.S. Shepard. Tiling and Patterns. Freeman, New-York, 1986. [25] B. Hajek. Extremal splittings of point processes. Math. Oper. Res., 10:543–556, 1985. [26] V. Maslov and S. Samborski˘ı, editors. Idempotent Analysis, volume 13 of Adv. in Sov. Math. AMS, 1992. [27] M. Morse and G. Hedlund. Symbolic dynamics II: Sturmian sequences. Amer. J. Math., 61:1–42, 1940. [28] G. Rauzy. Mots infinis en arithm´etique. In M. Nivat and D. Perrin, editors, Automata on Infinite Words, number 192 in LNCS, pages 165–171. Springer Verlag, 1985. [29] I.V. Romanovski˘ı. Optimization and stationary control of discrete deterministic process in dynamic programming. Cybernetics, 3:66–78, 1967. [30] G.X. Viennot. Heaps of pieces, I: Basic definitions and combinatorial lemmas. In Labelle and Leroux, ´ editors, Combinatoire Enum´ erative, number 1234 in Lect. Notes in Math., pages 321–350. Springer, 1986. LIAFA, CNRS-U NIVERSIT E´ PARIS VII, CASE 7014, 2 PLACE J USSIEU , 75251 PARIS C EDEX 05, F RANCE . P HONE . +33 1 44 27 70 97; FAX . +33 1 44 27 62 86 E-mail address: (Jean.Mairesse,Laurent.Vuillon)@liafa.jussieu.fr