Universal algorithms for solving the matrix Bellman equations over semirings
G. L. Litvinov, A. Ya. Rodionov, S. N. Sergeev & A. N. Sobolevski
Soft Computing A Fusion of Foundations, Methodologies and Applications
ISSN 1432-7643
Soft Comput DOI 10.1007/s00500-013-1027-5
1 23 Your article is protected by copyright and all rights are held exclusively by Springer- Verlag Berlin Heidelberg. This e-offprint is for personal use only and shall not be self- archived in electronic repositories. If you wish to self-archive your work, please use the accepted author’s version for posting to your own website or your institution’s repository. You may further deposit the accepted author’s version on a funder’s repository at a funder’s request, provided it is not made publicly available until 12 months after publication.
1 23 Author's personal copy
Soft Comput DOI 10.1007/s00500-013-1027-5
FOUNDATIONS
Universal algorithms for solving the matrix Bellman equations over semirings
G. L. Litvinov • A. Ya. Rodionov • S. N. Sergeev • A. N. Sobolevski
Ó Springer-Verlag Berlin Heidelberg 2013
Abstract This paper is a survey on universal algorithms computer representation of real numbers are provided by for solving the matrix Bellman equations over semirings various modifications of floating point arithmetics, and especially tropical and idempotent semirings. How- approximate arithmetics of rational numbers (Litvinov ever, original algorithms are also presented. Some appli- et al. 2008), interval arithmetics etc. The difference cations and software implementations are discussed. between mathematical objects (‘‘ideal’’ numbers) and their finite models (computer representations) results in com- putational (for instance, rounding) errors. 1 Introduction An algorithm is called universal if it is independent of a particular numerical domain and/or its computer represen- Computational algorithms are constructed on the basis of tation (Litvinov and Maslov 1996, 1998, 2000; Litvinov certain primitive operations. These operations manipulate et al. 2000). A typical example of a universal algorithm is data that describe ‘‘numbers.’’ These ‘‘numbers’’ are ele- the computation of the scalar product (x, y) of two vectors ments of a ‘‘numerical domain,’’ that is, a mathematical x ¼ðx1; ...; xnÞ and y ¼ðy1; ...; ynÞ by the formula ðx; yÞ¼ object such as the field of real numbers, the ring of integers, x1y1 þ þxnyn: This algorithm (formula) is independent different semirings etc. of a particular domain and its computer implementation, In practice, elements of the numerical domains are since the formula is well-defined for any semiring. It is clear replaced by their computer representations, that is, by that one algorithm can be more universal than another. For elements of certain finite models of these domains. example, the simplest Newton–Cotes formula, the rectan- Examples of models that can be conveniently used for gular rule, provides the most universal algorithm for numerical integration. In particular, this formula is valid Communicated by A. D. Nola. also for idempotent integration [that is, over any idempotent semiring, see (Kolokoltsov and Maslov 1997; Litvinov This work is supported by the RFBR-CRNF grant 11-01-93106 and 2007)]. Other quadrature formulas (for instance, combined RFBR grant 12-01-00886-a. trapezoid rule or the Simpson formula) are independent of computer arithmetics and can be used (for instance, in the G. L. Litvinov (&) A. N. Sobolevski A.A. Kharkevich Institute for Information Transmission iterative form) for computations with arbitrary accuracy. In Problems, and National Research University Higher School contrast, algorithms based on Gauss–Jacobi formulas are of Economics, Moscow, Russia designed for fixed accuracy computations: they include e-mail: [email protected] constants (coefficients and nodes of these formulas) defined A. Ya. Rodionov S. N. Sergeev with fixed accuracy. (Certainly, algorithms of this type can Moscow Center for Continuous Mathematical Education, be made more universal by including procedures for com- Moscow, Russia puting the constants; however, this results in an unjustified complication of the algorithms.) S. N. Sergeev University of Birmingham, School of Mathematics, Modern achievements in software development and Edgbaston B15 2TT, UK mathematics make us consider numerical algorithms and 123 Author's personal copy
G. L. Litvinov et al. their classification from a new point of view. Conventional mechanics; in fact, the two principles are closely connected numerical algorithms are oriented to software (or hard- (see Litvinov 2007; Litvinov and Maslov 1996, 1998). In a ware) implementation based on floating point arithmetic sense, the traditional mathematics over numerical fields can and fixed accuracy. However, it is often desirable to per- be treated as a ‘quantum’ theory, whereas the idempotent form computations with variable (and arbitrary) accuracy. mathematics can be treated as a ‘classical’ shadow (or For this purpose, algorithms are required that are inde- counterpart) of the traditional one. It is important that the pendent of the accuracy of computation and of the specific idempotent correspondence principle is valid for algorithms, computer representation of numbers. In fact, many algo- computer programs and hardware units. rithms are independent not only of the computer repre- In quantum mechanics the superposition principle sentation of numbers, but also of concrete mathematical means that the Schro¨dinger equation (which is basic for the (algebraic) operations on data. In this case, operations theory) is linear. Similarly in idempotent mathematics the themselves may be considered as variables. Such algo- (idempotent) superposition principle (formulated by V. rithms are implemented in the form of generic programs P. Maslov) means that some important and basic problems based on abstract data types that are defined by the user in and equations that are nonlinear in the usual sense (for addition to the predefined types provided by the language. instance, the Hamilton-Jacobi equation, which is basic for The corresponding program tools appeared as early as in classical mechanics and appears in many optimization Simula-67, but modern object-oriented languages (like problems, or the Bellman equation and its versions and C??, see, for instance (Lorenz 1993; Pohl 1997)) are more generalizations) can be treated as linear over appropriate convenient for generic programming. Computer algebra idempotent semirings, see Maslov (1987a, b). algorithms used in such systems as Mathematica, Maple, Note that numerical algorithms for infinite dimensional REDUCE, and others are also highly universal. linear problems over idempotent semirings (for instance, A different form of universality is featured by iterative idempotent integration, integral operators and transforma- algorithms (beginning with the successive approximation tions, the Hamilton–Jacobi and generalized Bellman method) for solving differential equations (for instance, equations) deal with the corresponding finite-dimensional methods of Euler, Euler–Cauchy, Runge–Kutta, Adams, a approximations. Thus idempotent linear algebra is the basis number of important versions of the difference approxi- of the idempotent numerical analysis and, in particular, the mation method, and the like), methods for calculating discrete optimization theory. elementary and some special functions based on the Carre´ (1971, 1979) (see also Gondran 1975; Gondran and expansion in Taylor’s series and continuous fractions (Pade´ Minoux 1979, 2010) used the idempotent linear algebra to approximations). These algorithms are independent of the show that different optimization problems for finite graphs computer representation of numbers. can be formulated in a unified manner and reduced to solving The concept of a generic program was introduced by Bellman equations, that is, systems of linear algebraic many authors; for example, in Lehmann (1977) such pro- equations over idempotent semirings. He also generalized grams were called ‘program schemes.’ In this paper, we principal algorithms of computational linear algebra to the discuss universal algorithms implemented in the form of idempotent case and showed that some of these coincide with generic programs and their specific features. This paper is algorithms independently developed for solution of optimi- closely related to Litvinov (2007), Litvinov and Maslov zation problems. For example, Bellman’s method of solving (1996, 1998), Litvinov and Maslova (2000), Litvinov et al. the shortest path problem corresponds to a version of Jaco- (2000, 2011), Sergeev (2011), in which the concept of a bi’s method for solving a system of linear equations, whereas universal algorithm was defined and software and hardware Ford’s algorithm corresponds to a version of Gauss–Seidel’s implementation of such algorithms was discussed in con- method. We briefly discuss Bellman equations and the cor- nection with problems of idempotent mathematics, see, for responding optimization problems on graphs, and use the instance, Kolokoltsov and Maslov (1997), Litvinov and ideas of Carre´ to obtain new universal algorithms. We stress Sobolevskiıˇ(2001), Mikhalkin (2006), Viro (2001, 2008). that these well-known results can be interpreted as a mani- The so-called idempotent correspondence principle, see festation of the idempotent superposition principle. Litvinov and Maslov (1996, 1998), linking this mathematics Note that many algorithms for solving the matrix Bellman with the usual mathematics over fields, will be discussed equation could be found in Baccelli et al. (1992), Carre´ below. In a nutshell, there exists a correspondence between (1971, 1979), Cuninghame-Green (1979), Gondran (1975), interesting, useful, and important constructions and results Gondran and Minoux (2010), Litvinov et al. (2011), concerning the field of real (or complex) numbers and similar Litvinov and Maslova (2000), Rote (1985), Sergeev (2011), constructions dealing with various idempotent semirings. Tchourkin and Sergeev (2007). More general problems of This correspondence can be formulated in the spirit of the linear algebra over the max-plus algebra are examined, for well-known N. Bohr’s correspondence principle in quantum instance in Butkovicˇ (2010). 123 Author's personal copy
Universal algorithms for solving the matrix
We also briefly discuss interval analysis over idempo- S is called a semifield if every nonzero element is tent and positive semirings. Idempotent interval analysis invertible. appears in Litvinov and Sobolevskiıˇ(2000, 2001), Sobo- A semiring S is called idempotent if x x ¼ x for all levskiıˇ(1999), where it is applied to the Bellman matrix x [ S. In this case the addition defines a canonical equation. Many different problems coming from the partial order on the semiring S by the rule: x y iff idempotent linear algebra, have been considered since then, x y ¼ y: It is easy to prove that any idempotent semiring see for instance Cechla´rova´ and Cuninghame-Green is positive with respect to this order. Note also that x y ¼ (2002), Fiedler et al. (2006), Hardouin et al. (2009), supfx; yg with respect to the canonical order. In the sequel, Mysˇkova (2005, 2006). It is important to observe that we shall assume that all idempotent semirings are ordered intervals over an idempotent semiring form a new idem- by the canonical partial order relation. potent semiring. Hence universal algorithms can be applied We shall say that a positive (for instance, idempotent) to elements of this new semiring and generate interval semiring S is complete if for every subset T , S there exist extensions of the initial algorithms. elements sup T 2 S and inf T 2 S; and if the operations This paper is about software implementations of uni- and distribute over such sups and infs. versal algorithms for solving the matrix Bellman equations The most well-known and important examples of posi- over semirings. In Sect. 2 we present an introduction to tive semirings are ‘‘numerical’’ semirings consisting of (a mathematics of semirings and especially to the tropical subset of) real numbers and ordered by the usual linear
(idempotent) mathematics, that is, the area of mathematics order B on R : the semiring R? with the usual operations working with idempotent semirings (that is, semirings with ¼þ; ¼ and neutral elements 0 = 0, 1 = 1, the idempotent addition). In Sect. 3 we present a number of semiring Rmax ¼ R [ f 1g with the operations ¼ well-known and new universal algorithms of linear algebra max; ¼þ and neutral elements 0 =-?, 1 = 0, the b over semirings, related to discrete matrix Bellman equation semiring Rmax ¼ Rmax [ f1g; where x 1; x 1¼1 and algebraic path problem. These algorithms are closely for all x; x 1¼1 x ¼1 if x = 0, and 0 1¼ [a,b] related to their linear-algebraic prototypes described, for 1 0; and the semiring Smax,min = [a, b], where instance, in the celebrated book of Golub and Van Loan -? B a \ b B??, with the operations ¼max; ¼ (1989) which serves as the main source of such prototypes. min and neutral elements 0 = a, 1 = b. The semirings Following the style of Golub and van Loan (1989)we b [a,b] Rmax; Rmax; and Smax,min = [a, b] are idempotent. The present them in MATLAB code. The perspectives and S semirings Rb ; S½a;b ; Rb R are complete. experience of their implementation are also discussed. max max;min þ ¼ þ f1g Remind that every partially ordered set can be imbedded to its completion (a minimal completeS set containing the initial one). The semiring Rmin ¼ R f1g with operations 2 Mathematics of semirings ¼min and ¼þand neutral elements 0 = ?, 1 = 0 is isomorphic to Rmax. 2.1 Basic definitions The semiring Rmax is also called the max-plus algebra. The semifields Rmax and Rmin are called tropical algebras. A broad class of universal algorithms is related to the The term ‘‘tropical’’ initially appeared in Simon (1988) for concept of a semiring. We recall here the definition (see, a discrete version of the max-plus algebra as a suggestion for instance, Golan 2000). of Choffrut, see also Gunawardena (1998), Mikhalkin A set S is called a semiring if it is endowed with two (2006), Viro (2008). associative operations: addition and multiplication Many mathematical constructions, notions, and results such that addition is commutative, multiplication distrib- over the fields of real and complex numbers have nontrivial utes over addition from either side, 0 (resp., 1) is the analogs over idempotent semirings. Idempotent semirings neutral element of addition (resp., multiplication), 0 x ¼ have become recently the object of investigation of new x 0 ¼ 0 for all x 2 S; and 0 6¼ 1: branches of mathematics, idempotent mathematics and Let the semiring S be partially ordered by a relation tropical geometry, see, for instance Baccelli et al. (1992), such that 0 is the least element and the inequality x y Cuninghame-Green (1979), Litvinov (2007), Mikhalkin implies that x z y z; x z y z; and z x z y (2006), Viro (2001, 2008). for all x, y, z [ S; in this case the semiring S is called Denote by MatmnðSÞ a set of all matrices A = (aij) with positive (see, for instance, Golan 2000). m rows and n columns whose coefficients belong to a An element x [ S is called invertible if there exists an semiring S. The sum A B of matrices A; B 2 MatmnðSÞ -1 1 1 element x [ S such that xx ¼ x x ¼ 1: A semiring and the product AB of matrices A 2 MatlmðSÞ and B 2
123 Author's personal copy
G. L. Litvinov et al.
MatmnðSÞ are defined according to the usual rules of linear In the case of idempotent addition (1) becomes partic- algebra: A B ¼ðaij bijÞ2MatmnðSÞ and ularly nice: ! m a ¼ aai ¼ sup ai: ð2Þ AB ¼ aaij bkj 2 MatlnðSÞ; i 0 i 0 k¼1 If a positive semiring S is not complete, then it often where A 2 MatlmðSÞ and B 2 MatmnðSÞ: Note that we write happens that the closure operation can still be defined on AB instead of A B: some ‘‘essential’’ subset of S. Also recall that any positive If the semiring S is positive, then the set MatmnðSÞ is semifield S can be completed (Golan 2000; Litvinov et al. ordered by the relation A ¼ðaijÞ B ¼ðbijÞ iff aij bij in 2001), and then the closure is defined for every element of S for all 1 B i B m,1B j B n. the completion. The matrix multiplication is consistent with the order In numerical semirings the operation * is usually very 0 0 in the following sense: if A; A 2 MatlmðSÞ; B; B 2 easy to implement: x* = (1 - x)-1 if x \ 1inR ; or Rb 0 0 0 0 þ þ MatmnðSÞ and A A ; B B ; then AB A B in MatlnðSÞ: b and x ¼1if x C 1inRþ; x ¼ 1 if x 1 in Rmax and The set MatnnðSÞ of square (n 9 n) matrices over a [posi- b b [a,b] tive, idempotent] semiring S forms a [positive, idempotent] Rmax; x ¼1if x 1 in Rmax; x ¼ 1 for all x in Smax,min. In all other cases x* is undefined. semi-ring with a zero element O = (oij), where oij ¼ The closure operation in matrix semirings over a com- 0; 1 i; j n; and a unit element I = (dij), where dij ¼ 1 if plete positive semiring S can be defined as in (1): i = j and dij ¼ 0 otherwise. The set Matnn is an example of a noncommutative A :¼ sup I A Ak; ð3Þ semiring if n [ 1. k 0 and one can show that it is the least solution X satisfying 2.2 Closure operation the matrix equations X ¼ AX I and X ¼ XA I: Equivalently, A* can be defined by induction: let In what follows, we are mostly interested in complete A* = (a )* = (a* ) in Mat ðSÞ be defined by (1), and for positive semirings, and particularly in idempotent semi- 11 11 11 any integer n [ 1 and any matrix rings. Regarding examples of the previous section, recall ½a;b b b A11 A12 that the semirings S ; Rmax ¼ Rmax [ fþ1g; Rmin ¼ A ¼ ; max;min A A b 21 22 Rmin [ f 1g and Rþ ¼ Rþ [ fþ1g are complete posi- [a,b] b b where A11 2 MatkkðSÞ; A12 2 Matkn kðSÞ; A21 2 Matn kk tive, and the semirings Smax,min, Rmax and Rmin are idempotent. ðSÞ; A22 2 Matn kn kðSÞ; 1 k n; by definition, b b b Rþ is a completion of R?, and Rmax (resp. Rmin) are A11 A11A12D A21A11 A11A12D A ¼ ; ð4Þ completions of Rmax (resp. Rmin). More generally, we note D A21A11 D that any positive semifield S can be completed by means of a standard procedure, which uses Dedekind cuts and is where D ¼ A22 A21A11A12: described in Golan (2000), Litvinov et al. (2001). The Defined here for complete positive semirings, the clo- sure operation is a semiring analogue of the operation result of this completion is a semiring Sb; which is not a (1 - a)-1 and, further, (I - A)-1 in matrix algebra over semifield anymore. the field of real or complex mumbers. This operation can The semiring of matrices Mat ðSÞ over a complete nn be thought of as regularized sum of the series I þ A þ positive (resp., idempotent) semiring is again a complete A2 ; and the closure operation defined above is positive (resp., idempotent) semiring. For more back- þ another such regularization. Thus we can also define the ground in complete idempotent semirings, the reader is closure operation a* = (1 - a)-1 and A* = (I - A)-1 in referred to Litvinov et al. (2001). the traditional linear algebra. To this end, note that the In any complete positive semiring S we have a unary recurrence relation above coincides with the formulas of operation of closure a 7! a defined by escalator method of matrix inversion in the traditional k a :¼ sup 1 a a ; ð1Þ linear algebra over the field of real or complex numbers, up k 0 to the algebraic operations used. Hence this algorithm of Using that the operations and distribute over such matrix closure requires a polynomial number of operations sups, it can be shown that a* is the least solution of x ¼ in n, see below for more details. ax 1 and x ¼ xa 1; and also that a*b is the the least Let S be a complete positive semiring. The matrix (or solution of x ¼ ax b and x ¼ xa b: discrete stationary) Bellman equation has the form
123 Author's personal copy
Universal algorithms for solving the matrix
X ¼ AX B; ð5Þ This definition allows for some pairs of nodes to be disconnected if the corresponding element of the matrix where A 2 MatnnðSÞ; X; B 2 MatnsðSÞ; and the matrix X is A is 0 and for some channels to be ‘‘loops’’ with coincident unknown. As in the scalar case, it can be shown that for * ends if the matrix A has nonzero diagonal elements. complete positive semirings, if A is defined as in (3) then Recall that a sequence of nodes of the form A*B is the least in the set of solutions to equation (5) with p ¼ðy0; y1; ...; ykÞ respect to the partial order in MatnsðSÞ: In the idempotent case with k C 0 and ðyi; yiþ1Þ2C; i ¼ 0; ...; k 1; is called a path of length k connecting y with y . Denote the set of all A ¼ aAi ¼ sup Ai: ð6Þ 0 k i 0 i 0 such paths by Pk(y0,yk). The weight A(p) of a path p 2 Pkðy0; ykÞ is defined to be the product of weights of arcs Consider also the case when A = (aij)isn 9 n strictly connecting consecutive nodes of the path: upper-triangular (such that aij ¼ 0 for i C j), or AðpÞ¼Aðy0; y1Þ Aðyk 1; ykÞ: n 9 n strictly lower-triangular (such that aij ¼ 0 for n i B j). In this case A = O, the all-zeros matrix, and it By definition, for a ‘path’ p 2 P0ðxi; xjÞ of length k = 0 the can be shown by iterating X ¼ AX I that this equation weight is 1 if i = j and 0 otherwise (Fig. 1). 0 has a unique solution, namely For each matrix A 2 MatnnðSÞ define A = E = (dij)