{"title": "Linearly-solvable Markov decision problems", "book": "Advances in Neural Information Processing Systems", "page_first": 1369, "page_last": 1376, "abstract": null, "full_text": "Linearly-solvable Markov decision problems\n\nEmanuel Todorov Department of Cognitive Science University of California San Diego todorov@cogsci.ucsd.edu\n\nAbstract\nWe introduce a class of MPDs which greatly simplify Reinforcement Learning. They have discrete state spaces and continuous control spaces. The controls have the effect of rescaling the transition probabilities of an underlying Markov chain. A control cost penalizing KL divergence between controlled and uncontrolled transition probabilities makes the minimization problem convex, and allows analytical computation of the optimal controls given the optimal value function. An exponential transformation of the optimal value function makes the minimized Bellman equation linear. Apart from their theoretical signi cance, the new MDPs enable ef cient approximations to traditional MDPs. Shortest path problems are approximated to arbitrary precision with largest eigenvalue problems, yielding an O (n) algorithm. Accurate approximations to generic MDPs are obtained via continuous embedding reminiscent of LP relaxation in integer programming. Offpolicy learning of the optimal value function is possible without need for stateaction values; the new algorithm (Z-learning) outperforms Q-learning. This work was supported by NSF grant ECS0524761.\n\n1 Introduction\nIn recent years many hard problems have been transformed into easier problems that can be solved ef ciently via linear methods [1] or convex optimization [2]. One area where these trends have not yet had a signi cant impact is Reinforcement Learning. Indeed the discrete and unstructured nature of traditional MDPs seems incompatible with simplifying features such as linearity and convexity. This motivates the search for more tractable problem formulations. Here we construct the rst MDP family where the minimization over the control space is convex and analytically tractable, and where the Bellman equation can be exactly transformed into a linear equation. The new formalism enables ef cient numerical methods which could not previously be applied in Reinforcement Learning. It also yields accurate approximations to traditional MDPs. Before introducing our new family of MDPs, we recall the standard formalism. Throughout the paper S is a nite set of states, U (i) is a set of admissible controls at state i 2 S , ` (i; u) 0 is a cost for being in state i and choosing control u 2 U (i), and P (u) is a stochastic matrix whose element pij (u) is the transition probability from state i to state j under control u. We focus on problems where a non-empty subset A S of states are absorbing and incur zero cost: pij (u) = j and i ` (i; u) = 0 whenever i 2 A. Results for other formulations will be summarized later. If A can be reached with non-zero probability in a nite number of steps from any state, then the undiscounted in nite-horizon optimal value function is nite and is the unique solution [3] to the Bellman equation n o X pij (u) v (j ) (1) v (i) = min ` (i; u) + For generic MDPs this equation is about as far as one can get analytically.\nu2U (i) j\n\n\f\n2 A class of more tractable MDPs\nIn our new class of MDPs the control u 2 RjS j is a real-valued vector with dimensionality equal to the number of discrete states. The elements uj of u have the effect of directly modifying the transition probabilities of an uncontrolled Markov chain. In particular, given an uncontrolled transition probability matrix P with elements pij , we de ne the controlled transition probabilities as pij (u) = pij exp (uj ) (2)\n\nNote that P (0) = P . In some sense this is the most general notion of \"control\" one can imagine we are allowing the controller to rescale the underlying transition probabilities in any way it wishes. However there are two constraints implicit in (2). First, pij = 0 implies pij (u) = 0. In this case uj has no effect and so we set it to 0 for concreteness. Second, P (u) must have row-sums equal to 1. Thus the admissible controls are n o X U (i) = u 2 RjS j ; pij exp (uj ) = 1; pij = 0 =) uj = 0 (3)\nj\n\nReal-valued controls make it possible to de ne a natural control cost. Since the control vector acts directly on the transition probabilities, it makes sense to measure its magnitude in terms of the difference between the controlled and uncontrolled transition probabilities. Differences between probability distributions are most naturally measured using KL divergence, suggesting the following de nition. Let pi (u) denote the i-th row-vector of the matrix P (u), that is, the vector of transition probabilities from state i to all other states under control u. The control cost is de ned as r (i; u) = KL (pi (u) jjpi (0)) = X\nj :pij 6=0\n\npij (u) log\n\npij (u) pij (0)\n\n(4)\n\nFrom the properties of KL divergence it follows that r (i; u) Substituting (2) in (4) and simplifying, the control cost becomes X r (i; u) = pij (u) uj\nj\n\n0, and r (i; u) = 0 iff u = 0. (5)\n\nThis has an interesting interpretation. The Markov chain likes to behave according to P but can be paid to behave according to P (u). Before each transition the controller speci es the price uj it is willing to pay (or collect, if uj < 0) for every possible next state j . When the actual transition occurs, say to state k , the controller pays the price uk it promised. Then r (i; u) is the price the controller expects to pay before observing the transition. Coming back to the MDP construction, we allow an arbitrary state cost q (i) above control cost: ` (i; u) = q (i) + r (i; u) 0 in addition to the (6)\n\nWe can now exploit the bene ts of this unusual construction. The minimization in (7) subject to the constraint (3) can be performed in closed form using Lagrange multipliers, as follows. For each i de ne the Lagrangian X ( X L (u; i) = pij exp (uj ) (uj + v (j )) + i pij exp (uj ) 1 8)\nj j\n\nWe require q (i) = 0 for absorbing states i 2 A so that the process can continue inde nitely without incurring extra costs. Substituting (5, 6) in (1), the Bellman equation for our MDP is n o X v (i) = min q (i) + pij exp (uj ) (uj + v (j )) (7)\nu2U (i) j\n\nThe necessary condition for an extremum with respect to uj is 0=\n\n@L = pij exp (uj ) (uj + v (j ) + i + 1) @ uj\n\n(9)\n\nWhen pij 6= 0 the only solution is uj (i) = v (j ) i 1 (10)\n\n\f\nTaking another derivative yields @2L @ uj @ uj u = pij exp\nj =u j ( i)\n\nuj\n\n(i)\n\n>\n\n0\n\n(11)\n\nand therefore (10) is a minimum. The Lagrange multiplier i can be found by applying the constraint (3) to the optimal control (10). The result is X 1 i = log pij exp ( v (j )) (12)\nj\n\nand therefore the optimal control law is uj (i) =\n\nv (j )\n\nlog\n\nThese probabilities are proportional to the product of two terms: the uncontrolled transition probabilities pij which do not depend on the costs or values, and the (exponentiated) next-state values v (j ) which do not depend on the current state. In the special case pij = consti the transition probabilities (14) correspond to a Gibbs distribution where the optimal value function plays the role of an energy function. Substituting the optimal control (13) in the Bellman equation (7) and dropping the min operator, X u ( v (i) = q (i) + pij (u (i)) j (i) + v (j ) 15) j X = q (i) + pij (u (i)) ( i 1)\nj\n\nThus we have expressed the optimal control law in closed form given the optimal value function. Note that the only in uence of the current state i is through the second term, which serves to normalize the transition probability distribution pi (u ) and is identical for all next states j . Thus the optimal controller is a high-level controller: it tells the Markov chain to go to good states without specifying how to get there. The details of the trajectory emerge from the interaction of this controller and the uncontrolled stochastic dynamics. In particular, the optimally-controlled transition probabilities are pij exp ( v (j )) pij (u (i)) = P (14) k pik exp ( v (k ))\n\nX\n\nk\n\npik exp ( v (k ))\n\n(\n\n13)\n\nR\n\n= q (i) = q (i)\n\ni\n\nlog\n\nWe now introduce the exponential transformation\n\nearranging terms and exponentiating both sides of (15) yields X exp ( v (i)) = exp ( q (i)) pij exp ( v (j ))\nj\n\n1 X\n\nj\n\npij exp ( v (j ))\n\n(16)\n\nz (i) = exp ( v (i)) which makes the minimized Bellman equation linear: z (i) = exp ( q (i)) X\nj\n\n(17)\n\npij z (j )\n\n(18)\n\nDe ning the vector z with elements z (i), and the diagonal matrix G with elements exp ( q (i)) along its main diagonal, (18) becomes z = GP z Thus our class of optimal control problems has been reduced to a linear eigenvalue problem. (19)\n\n\f\n2.1\n\nIterative solution and convergence analysis\n\nFrom (19) it follows that z is an eigenvector of GP with eigenvalue 1. Furthermore z (i) > 0 for all i 2 S and z (i) = 1 for i 2 A. Is there a vector z with these properties and is it unique? The answer to both questions is af rmative, because the Bellman equation has a unique solution and v is a solution to the Bellman equation iff z = exp ( v) is an admissible solution to (19). The only remaining question then is how to nd the unique solution z. The obvious iterative method is z k +1 = G P z k ; z0 = 1 (20)\n\nThis iteration always converges to the unique solution, for the following reasons. A stochastic matrix P has spectral radius 1. Multiplication by G scales down some of the rows of P , therefore GP has spectral radius at most 1. But we are guaranteed than an eigenvector z with eigenvalue 1 exists, therefore GP has spectral radius 1 and z is a largest eigenvector. Iteration (20) is equivalent to the power method (without the rescaling which is unnecessary here) so it converges to a largest eigenvector. The additional constraints on z are clearly satis ed at all stages of the iteration. In particular, for i 2 A the i-th row of GP has elements j , and so the i-th element of zk remains equal i to 1 for all k . We now analyze the rate of convergence. Let m = jAj and n = jS j. The states can be permuted so that GP is in canonical form: T ( T2 1 GP = 21) 0 I\n\nwhere the absorbing states are last, T1 is (n m) by (n m), and T2 is (n m) by m. The reason we have the identity matrix in the lower-right corner, despite multiplication by G, is that q (i) = 0 for i 2 A. From (21) we have T =T ( Tk 1 T I ( 1 k k k Gk + + T1 + I 2 T1 I T1 ) T2 1 1 1 P= 22) 0 I 0 I\n\nA stochastic matrix P with m absorbing states has m eigenvalues 1, and all other eigenvalues are smaller than 1 in absolute value. Since the diagonal elements of G are no greater than 1, all eigenk values of T1 are smaller than 1 and so limk!1 T1 = 0. Therefore iteration (20) converges exponentially as k where < 1 is the largest eigenvalue of T1 . Faster convergence is obtained for smaller . The factors that can make small are: (i) large state costs q (i) resulting in small terms exp ( q (i)) along the diagonal of G; (ii) small transition probabilities among non-absorbing states (and large transition probabilities from non-absorbing to absorbing states). Convergence is independent of problem size because has no reason to increase as the dimensionality of T1 increases. Indeed numerical simulations on randomly generated MDPs have shown that problem size does not systematically affect the number of iterations needed to reach a given convergence criterion. Thus the average running time scales linearly with the number of non-zero elements in P . 2.2 Alternative problem formulations\n\nWhile the focus of this paper is on in nite-horizon total-cost problems with absorbing states, we have obtained similar results for all other problem formulations commonly used in Reinforcement Learning. Here we summarize these results. In nite-horizon problems equation (19) becomes z (t) = G (t) P (t) z (t + 1) (23)\n\nwhere z (t nal ) is initialized from a given nal cost function. In in nite-horizon average-cost-perstage problems equation (19) becomes z = GP z (24) where is the largest eigenvalue of GP , z is a differential value function, and the average cost-perstage turns out to be log ( ). In in nite-horizon discounted-cost problems equation (19) becomes z = GP z\n(\n\n25)\n\nwhere < 1 is the discount factor and z is de ned element-wise. Even though the latter equation is nonlinear, we have observed that the analog of iteration (20) still converges rapidly.\n\n\f\nFig 1A\n0 2 3 3 4 4 6 6 8 9 10 11 11 22 22 23 25 20 21 23 25 24 25 26 26 28 28 30 30 31 31 18 16 14 14 12 12 13 13 10 10 10 11 9 9 10 11 10 11 8 0 1 1 1 2 2\n\nFig 1B\n3 3 4 4 5 5 5 7 6 6 6 6 6 6\n\n11 11\n\n12 12\n\n13 13\n\n14 14\n\n3 Shortest paths as an eigenvalue problem\nSuppose the state space S of our MDP corresponds to the vertex set of a directed graph, and let D be the graph adjacency matrix whose element dij indicates the presence (dij = 1) or absence (dij = 0) of a directed edge from vertex i to vertex j . Let A S be a non-empty set of destination vertices. Our goal is to nd the length s (i) of the shortest path from every i 2 S to some vertex in A. For i 2 A we have s (i) = 0 and dij = j . i\n\nWe now show how the shortest path lengths s (i) can be obtained from our MDP. De ne the elements of the stochastic matrix P as dij pij = P (26) k dik corresponding to a random walk on the graph. Next choose > 0 and de ne the state costs q (i) = when i 2 A, = q (i) = 0 when i 2 A (27) This cost model means that we pay a price whenever the current state is not in A. Let v (i) denote the optimal value function for the MDP de ned by (26, 27). If the control costs were 0 then the shortest paths would simply be s (i) = 1 v (i). Here the control costs are not 0, however they are bounded. This can be shown using pij (u) = pij exp (uj ) 1 (28) p. which implies that for pij 6= 0 we have uj log ij Since r (i; u) is a convex combination of the elements of u, the following bound holds: m ( p r (i; u) maxj (uj ) log inj :pij 6=0 ij 29) The control costs are bounded and we are free to choose arbitrarily large, so we can make the state costs dominate the optimal value function. This yields the following result: v (i) s (i) = lim 30) !1 ( Thus we have reduced the shortest path problem to an eigenvalue problem. In spectral graph theory many problems have previously been related to eigenvalues of the graph Laplacian [4], but the shortest path problem was not among them until now. Currently the most widely used algorithm is Dijkstra's algorithm. In sparse graphs its running time is O (n log (n)). In contrast, algorithms for nding largest eigenpairs have running time O (n) for sparse matrices.\n\nOf course (30) involves a limit and so we cannot obtain the exact shortest paths by solving a single eigenvalue problem. However we can obtain a good approximation by setting large enough but not too large because exp ( ) may become numerically indistinguishable from 0. Fig 1 illustrates the solution obtained from (30) and rounded down to the nearest integer, for = 1 in 1A and = 50 in 1B. Transitions are allowed to all neighbors. The result in 1B matches the exact shortest paths. Although the solution for = 1 is numerically larger, it is basically a scaled-up version of the correct solution. Indeed the R2 between the two solutions before rounding was 0:997.\n\n\f\n4 Approximating discrete MDPs via continuous embedding\nIn the previous section we replaced the shortest path problem with a continuous MDP and obtained an excellent approximation. Here we obtain approximations of similar quality in more general settings, using an approach reminiscent of LP-relaxation in integer programming. As in LP-relaxation, theoretical results are hard to derive but empirically the method works well. We construct an embedding which associates the controls in the discrete MDP with speci c control vectors of a continuous MDP, making sure that for these control vectors the continuous MDP has the same costs and transition probabilities as the discrete MDP. This turns out to be possible under mild and reasonable assumptions, as follows. Consider a discrete MDP with transition probabilities and e costs denoted p and `. De ne the matrix B (i) of all controlled transition probabilities from state i. e This matrix has elements baj (i) = pij (a) ; e a 2 U (i) (31) We need two assumptions to guarantee the existence of an exact embedding: for all i 2 S the matrix B (i) must have full row-rank, and if any element of B (i) is 0 then the entire column must be 0. If the latter assumption does not hold, we can replace the problematic 0 elements of B (i) with a small and renormalize. Let N (i) denote the set of possible next states, i.e. states j for which pij (a) > 0 e for any/all a 2 U (i). Remove the zero-columns of B (i) and restrict j 2 N (i). The rst step in the construction is to compute the real-valued control vectors ua corresponding to the discrete actions a. This is accomplished by matching the transition probabilities of the discrete and continuous MDPs: u= pij exp a pij (a) ; e 8 i 2 S ; j 2 N (i) ; a 2 U (i) (32) j ( 33)\n\nThese constraints are satis ed iff the elements of the vector ua are p ua = log (pij (a)) log ij e j e q (i) + r (i; ua ) = ` (i; a) ;\nj\n\nThe second step is to compute the uncontrolled transition probabilities pij and state costs q (i) in the continuous MDP so as to match the costs in the discrete MDP. This yields the set of constraints 8 i 2 S ; a 2 U (i) (34) (\n\nFor the control vector given by (33) the KL-divergence cost is X uu p r (i; ua ) = pij exp a a = h (i; a) X pij (a) log ij e j j\nj j\n\n35)\n\nwhere h (i; a) is the entropy of the transition probability distribution in the discrete MDP: X h (i; a) = pij (a) log (pij (a)) e e The constraints (34) are then equivalent to q (i)\nj\n\n(36)\n\np. e De ne the vector y (i) with elements ` (i; a) h (i; a), and the vector x (i) with elements log ij The dimensionality of y (i) is jU (i)j while the dimensionality of x (i) is jN (i)j jU (i)j. The latter inequality follows from the assumption that B (i) has full row-rank. Suppressing the dependence on the current state i, the constraints (34) can be written in matrix notation as q1 Since the probabilities pij must sum up to 1, the vector x must satisfy the additional constraint X exp (xj ) = 1 (39)\nj\n\nX baj (i) log\n\np\n\nij\n\n=\n\ne ` (i; a)\n\nh (i; a)\n\n(37)\n\nBx = y\n\n(38)\n\nb We are given B ; y and need to compute q ; x satisfying (38, 39). Let x be any vector such that b Bb = y, for example x = B y y where y denotes the Moore-Penrose pseudoinverse. Since B is x a stochastic matrix we have B 1 = 1, and so q1 b B (x + q 1) = Bb = y x (40)\n\n\f\nFig 2A\n\nFig 2B\n\nFig 2C\n40 30 20 10 R 2 = 0.986\n\n*\n\n*\n\n*\n\n*\n\n0\n\n0\n\n20\n\n40\n\n60\n\nvalue in discrete MDP\n\nWe now illustrate this construction with the example in Fig 2. The grid world has a number of obstacles (black squares) and two absorbing states (white stars). The possible next states are the immediate neighbors including the current state. Thus jN (i)j is at most 9. The discrete MDP has jN (i)j 1 actions corresponding to stochastic transitions to each of the neighbors. For each action, the transition probability to the \"desired\" state is 0:8 and the remaining 0:2 is equally distributed e among the other states. The costs ` (i; a) are random numbers between 1 and 10 which is why the optimal value function shown in grayscale appears irregular. Fig 2A shows the optimal value function for the discrete MDP. Fig 2B shows the optimal value function for the corresponding continuous MDP. The scatterplot in Fig 2C shows the optimal values in the discrete and continuous MDP (each dot is a state). The values in the continuous MDP are numerically smaller which is to be expected since the control space is larger. Nevertheless, the correlation between the optimal values in the discrete and continuous MDPs is excellent. We have observed similar performance in a number of randomly-generated problems.\n\nThis completes the embedding. If the above q turns out to be negative, we can either choose another e b x by adding an element from the null-space of B , or scale all costs ` (i; a) by a positive constant. Such scaling does not affect the optimal control law for the discrete MDP, but it makes the elements of B y y more negative and thus q becomes more positive.\n\nb Therefore x = x + q 1 satis es (38) for all q , and we can adjust q to also satisfy (39), namely X ( q = log exp (xj ) b 41)\nj\n\n5 Z-learning\nSo far we assumed that a model of the continuous MDP is available. We now turn to stochastic approximations of the optimal value function which can be used when a model is not available. All we have access to are samples (ik ; jk ; qk ) where ik is the current state, jk is the next state, qk is the state cost incurred at ik , and k is the sample number. Equation (18) can be rewritten as X (42) z (i) = exp ( q (i)) pij z (j ) = exp ( q (i)) EP [z (j )]\nj\n\nLet us now compare (43) to the Q-learning algorithm applicable to discrete MDPs. Here we have samples (ik ; jk ; `k ; uk ). The difference is that `k is now a total cost rather than a state cost, and we have a control uk generated by some control policy. The update equation for Q-learning is ` ( b b b Q (ik ; uk ) (1 k) Q (ik ; uk ) + k 0 min + Q (jk ; u0 ) 44) k\nu 2U (jk )\n\nwhere the sequence of learning rates k is appropriately decreased as k increases. The approximation to v (i) is simply log (z (i)). We will call this algorithm Z-learning. b\n\nThis suggests an obvious stochastic approximation z to the function z , namely b z (ik ) b (1 k) z (ik ) + k exp ( qk ) z (jk ) b b\n\n(43)\n\n\f\n1\n\nFig 3A\nZ-learning Q-learning\n\n1\n\nFig 3B\n* Q\n\n*\n\n*\n0 0 1 2 3 x 10 4 0 0\n\nZ\n5 10 15\n\nNumber of state transitions\nTo compare the two algorithms, we rst constructed continuous MDPs with q (i) = 1 and transitions to the immediate neighbors in the grid worlds shown in Fig 3. For each state we found the optimal transition probabilities (14). We then constructed a discrete MDP which had one action (per state) that caused the same transition probabilities, and the corresponding cost was the same as in the continuous MDP. We then added jN (i)j 1 other actions by permuting the transition probabilities. Thus the discrete and continuous MDPs were guaranteed to have identical optimal value functions. Note that the goal here is no longer to approximate discrete with continuous MDPs, but to construct pairs of problems with identical solutions allowing fair comparison of Z-learning and Q-learning. We run both algorithms with the same random policy. The learning rates decayed as k = c= (c + t (k )) where the constant c was optimized separately for each algorithm and t (k ) is the run to which sample k belongs. When the MDP reaches an absorbing state a new run is started from a random initial state. The approximation error plotted in Fig 3 is de ned as maxi jv (i) v (i)j b maxi v (i) (45)\n\nand is computed at the end of each run. For small problems (Fig 3A) the two algorithms had identical convergence, however for larger problems (Fig 3B) the new Z-learning algorithm was clearly faster. This is not surprising: even though Z-learning is as model-free as Q-learning, it bene ts from the analytical developments in this paper and in particular it does not need a maximization operator or state-action values. The performance of Q-learning can be improved by using a non-random (say greedy) policy. If we combine Z-learning with importance sampling, the performance of Z-learning can also be improved by using such a policy.\n\n6 Summary\nWe introduced a new class of MDPs which have a number of remarkable properties, can be solved ef ciently, and yield accurate approximations to traditional MDPs. In general, no single approach is likely to be a magic wand which simpli es all optimal control problems. Nevertheless the results so far are very encouraging. While the limitations remain to be clari ed, our approach appears to have great potential and should be thoroughly investigated.\n\nReferences\n[1] [2] [3] [4] B. Scholkopf and A. Smola, Learning with kernels. MIT Press (2002) S. Boyd and L. Vandenberghe, Convex optimization. Cambridge University Press (2004) D. Bertsekas, Dynamic programming and optimal control (2nd ed). Athena Scienti c (2000) F. Chung, Spectral graph theory. CMBS Regional Conference Series in Mathematics (1997)\n\n\f\n", "award": [], "sourceid": 3002, "authors": [{"given_name": "Emanuel", "family_name": "Todorov", "institution": null}]}