{"id":865,"date":"2019-01-09T09:49:18","date_gmt":"2019-01-09T09:49:18","guid":{"rendered":"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=865"},"modified":"2019-01-09T10:16:41","modified_gmt":"2019-01-09T10:16:41","slug":"basics-of-reinforcement-learning-ii","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/chapter\/basics-of-reinforcement-learning-ii\/","title":{"rendered":"Basics of Reinforcement Learning &#8211; II"},"content":{"raw":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/pSMAFT0Iplw\" target=\"_blank\" rel=\"noopener\"><img src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a>\r\n<\/span><\/div>\r\n\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>Learning Objectives<\/strong>\r\n\r\n&nbsp;\r\n\r\nThe learning objectives of the module are as follows:\r\n\r\n&nbsp;\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 To understand the Reinforcement Learning and its variants\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 To discuss about Passive Learning and Active learning\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 To explain the Markov Decision Process and Partially Observable MDP\r\n\r\n&nbsp;\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 To illustrate the Least Mean Square and Adaptive Programming\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>38.1 Reinforcement Learning<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">As already discussed in the previous module reinforcement learning is the problem of getting an agent to act in the world so as to maximize its rewards. It is a trial-and-error learning paradigm which learns from rewards and punishments. Reinforcement learning is not just an algorithm but a new paradigm in itself. Its objective is to learn about a system from minimal feedback.<\/p>\r\n&nbsp;\r\n\r\nLet us recall the mathematical formulation of the learning task, we e xecute actions in the environment, observe results and\r\n\r\n<img class=\"aligncenter size-full wp-image-868\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-264.png\" alt=\"\" width=\"634\" height=\"192\" \/>\r\n<p style=\"text-align: justify\">The learning task associated with reinforcement learning can be characterized based on three perspectives namely learning type , environment and rewards. The learning type can be passive or active. The environment can be known or unknown, in other words does the agent know effects of actions? Does the agent have a model of environment?<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"font-size: 1em;text-align: initial\">Here we will assume that the environment is accessible. The rewards can be terminal only or non-terminal.<\/span><\/p>\r\n\r\n<\/div>\r\n<div style=\"text-align: center\">\r\n\r\n&nbsp;\r\n\r\n<strong>38.2 Passive versus Active Learning<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Passive Learning is a learning about an agent which has fixed policy and tries to learn the utilities of states by observing the world go by and is analogous to policy evaluation in policy iteration. Here the agent only learns how \u201cgood\u201d each state or action is. The values of states are learnt and the action is taken accordingly.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">Active learning is the learning where the agent attempts to find an optimal (or at least good) policy by acting in the world. It is not a fixed policy but it is like finding a best policy. It is analogous to solving the underlying MDP (Markov Decision Process).<\/p>\r\n&nbsp;\r\n\r\n<strong>38.3\u00a0 Reinforcement Approaches<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Reinforcement Learning is a sequential decision problem, you learn one state and then go to the other state and then upcoming states with the reward for each state.<\/p>\r\n&nbsp;\r\n\r\n<strong>Model-Based vs. Model-Free RL<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Model based approach to RL will learn the MDP model, or an approximation of it and then use it for policy evaluation or to find the optimal policy. The agent learns values of states (or state histories) and tries to maximize utility of their outcomes. Here there is a need for a model of the environment including the operations that are available and the states they lead to. In another approach the agent learns values of state-action pairs. In this case the agent does not require a model of the environment (except legal moves) and cannot look ahead. The Model free approach to RL will derive the optimal policy without explicitly learning the model. It is useful when model is difficult to represent and\/or learn.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">Deterministic\u00a0 transitions\u00a0 and\u00a0\u00a0 Stochastic\u00a0 transitions\u00a0 are\u00a0\u00a0 two\u00a0\u00a0 reinforcement\u00a0\u00a0 learning perspectives.\u00a0 is the probability of reaching state j when taking action a in state i. The uncertainty in going from state i and when an action is taken and there is no guarantee that state j can be reached. This is a sequential problem where each and every move is recorded.<\/p>\r\n&nbsp;\r\n\r\nA simple environment presents the agent with a sequential decision problem:\r\n\r\n&nbsp;\r\n\r\nMove cost = 0.04\r\n\r\n<img class=\"aligncenter size-full wp-image-870\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-265.png\" alt=\"\" width=\"256\" height=\"177\" \/><strong style=\"text-align: center;font-size: 1em\">Figure 38.1 Reinforcement learning<\/strong>\r\n\r\n<\/div>\r\n<strong>\u00a0<\/strong>\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Temporal credit assignment problem is a sparse reinforcement problem. In the offline algorithm the action sequences are determined beforehand. In the online algorithm the action sequences are conditional on observations along the way (Figure 38.1). This type is important in stochastic environment (e.g. jet flying).<\/span><\/p>\r\n\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>38.4 RL Model<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The objective of reinforcement learning is to find the mapping that maximizes some combination of future reinforcements (rewards) received over time. The valuation models quantify how good the mapping is. We can consider the finite horizon model where we first consider maximizing total reward over a finite horizon. In other words the agent has n time steps to live. This is defined as<\/p>\r\n<img class=\"aligncenter size-full wp-image-871\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-266.png\" alt=\"\" width=\"325\" height=\"80\" \/>\r\n<p style=\"text-align: justify\">When we do not assume finite time then we have the infinite horizon discounted model. Defining expected value as total reward is problematic with infinite horizons and hence we introduce discount factor 0 \u2264 g &lt; 1 that is future rewards are discounted by g per time step.<\/p>\r\n<img class=\"aligncenter size-full wp-image-872\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-267.png\" alt=\"\" width=\"562\" height=\"82\" \/>\r\n\r\nThe Average reward is given as\r\n\r\n<img class=\"aligncenter size-full wp-image-873\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-268.png\" alt=\"\" width=\"218\" height=\"85\" \/>\r\n<p style=\"text-align: justify\">In order to solve the problem mathematically we formulate it as a Markov Decision Process (MDP) or Partially Observable Markov Decision Process (POMDP). We maximize the state -value and action-value functions using the Bellmann optimality equation. We need to use approximations such as dynamic programming, Monte Carlo Methods, Temporal-difference Learning to solve the Bellmann equation.<\/p>\r\n&nbsp;\r\n\r\n<strong>38.4.1 Markov Decision Process and Partially Observable Markov Decision Process<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The usual Markov Decision Process has the following components. The set of States S, set of actions A, the state transition probability P(s\u2019|s,a), the immediate Rewards R(s,a) and discount factor g. The current state is always perfectly observed.<\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<img class=\"aligncenter size-full wp-image-874\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-269.png\" alt=\"\" width=\"298\" height=\"184\" \/>\r\n<p style=\"text-align: center\"><strong>Figure 38.2 MDP Process<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">The Partially Observable Markov Decision Processes (POMDP) has just like MDP the set of states S, set of actions A, the probabilistic transitions, the immediate rewards, a discount factor but in addition has the observations Z, observation probabilities and an initial belief b0. The brief theory of how MDP works is discussed below,<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">An MDP has four components: S, A, R, T as already discussed the (finite) state set S (|S| = n), the (finite) action set A (|A| = m). the (Markov) transition function T(s,a,s\u2019) = Pr(s\u2019 | s,a) (Probability of going to state <strong>s\u2019<\/strong> after taking action <strong>a<\/strong> in state <strong>s)<\/strong> and the bounded, real-valued reward function R(s) (Immediate reward we get for being in state s). For example in a goal-based domain R(s) may equal 1 for goal states and 0 for all others. This reward function can be generalized to include action costs: R(s,a) and can also be generalized to be a stochastic function. Moreover, MDP can easily generalize to countable or continuous state and action spaces<\/p>\r\n&nbsp;\r\n\r\n<strong>38.5\u00a0 Passive Learner in a Known Environment<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">A passive learner simply watches the world going by, and tries to learn the utility of being in various states. Another way to think of a passive learner is as an agent with a fixed policy of trying to determine its benefits. In passive learning, the environment generates state transitions and the agent perceives them. Consider an agent trying to learn the utilities of the states shown below:<\/p>\r\n&nbsp;\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 Agent can move {North, East, South, West}\r\n\r\n&nbsp;\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Terminate on reading [4,2] or [4,3]\r\n\r\n&nbsp;\r\n\r\n<img class=\"aligncenter size-full wp-image-875\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-270.png\" alt=\"\" width=\"298\" height=\"184\" \/>\r\n<p style=\"text-align: center\"><strong>Figure 38.2 Example<\/strong><\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<img class=\"aligncenter size-full wp-image-876\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-271.png\" alt=\"\" width=\"596\" height=\"118\" \/>\r\n<p style=\"text-align: center\"><strong>Figure 38.3 State Transition Probabilities<\/strong><\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Agent is provided with Mij = a model giving the probability of reaching from state i to state j (each state transitions to neighbouring states with equal probability). With this assumption it means that the probability of a state is determined by the number of transitions from that state. Thus if a state has 3 transitions from it, the probability of transition to each of those states is 0.33 (Figure 38.3).<\/p>\r\n&nbsp;\r\n\r\n<strong>38.6 Passive Learning in a Known Environment<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">There are three approaches in passive learning in a known environment such as LMS (least mean squares), ADP (adaptive dynamic programming) and TD (temporal difference learning).We will discuss each methods in detail.<\/p>\r\n&nbsp;\r\n\r\n<strong>38.6.1 LMS (Least Mean Squares)<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">In this method we find an estimate of utility <strong><em>U<\/em><\/strong><strong><em>p<\/em><\/strong><strong><em>(s). This method has<\/em><\/strong> slow convergence and it takes the agent well over a 1000 training sequences to get close to the correct value. Assume that after entering +1 or -1 state the agent enters zero reward terminal state. We need to follow the policy for many epochs to get the required training sequences. Agent makes random runs (sequences of random moves) through environment (Example given in Figure 38.2) as given below:<\/p>\r\n&nbsp;\r\n\r\n[1,1]-&gt;[1,2]-&gt;[1,3]-&gt;[2,3]-&gt;[3,3]-&gt;[4,3] =\u00a0 +1\r\n\r\n&nbsp;\r\n\r\n[1,1]-&gt;[2,1]-&gt;[3,1]-&gt;[3,2]-&gt;[4,2] =\u00a0 -1\r\n\r\n&nbsp;\r\n\r\nHere we carry out direct estimation which is model free. We will estimate <em>U<\/em><em>p<\/em><em>(s)<\/em> as average total reward of epochs containing s (calculating from s to end of epoch). The r<em>eward to go<\/em> of a state s is calculated by the sum of the (discounted) rewards from that state until a terminal state is reached . The key here is to use observed <strong><em>reward to go<\/em><\/strong> to a state as the direct evidence of the actual expected utility of that state.\r\n\r\n&nbsp;\r\n\r\n<strong>38.6.2 ADP (Adaptive Dynamic Programming)<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Adaptive Dynamic Programming (ADP) is a model based approach. In this method we follow the policy for a while and then use the value or policy iteration algorithm to calculate exact utilities of states given an estimated model. This method makes optimal use of the local constraints on utilities of states imposed by the neighborhood structure of the environment. However this method is somewhat intractable for large state spaces. Let R(i) be the reward of being in state i, (often non zero for only a few end states) and Mij is the probability of transition from state i to j .<\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<img class=\"aligncenter size-full wp-image-877\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-272.png\" alt=\"\" width=\"455\" height=\"185\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The ADP is a model based approach which follow the policy for a while and estimates transition model based on observations and the reward function. The estimated model is used to compute utility of policy. We estimate transition model T(s,a,s\u2019) which simply the fraction of times we see s\u2019 after taking a in state s. From Figure 38.4 we see that<\/p>\r\n&nbsp;\r\n\r\nU(3,3) = 0.33 x U(4,3) + 0.33 x U(2,3) + 0.33 x U(3,2)\r\n\r\n&nbsp;\r\n\r\n=\u00a0 0.33 x 1.0 + 0.33 x 0.0886 + 0.33 x -0.4430\r\n\r\n&nbsp;\r\n\r\n=\u00a0 0.2152\r\n\r\n<img class=\"aligncenter size-full wp-image-878\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-273.png\" alt=\"\" width=\"679\" height=\"281\" \/>\r\n<p style=\"text-align: center\"><strong>Figure 38.3 Adaptive Dynamic Programming 38.6.3 TD (Temporal Difference Learning)<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">The key of temporal difference learning is to use the observed transitions to adjust the values of the observed states so that they agree with the constraint equations. The performance of runs are \u201cnoisier\u201d than LMS but with smaller error. The approach deals with observed states during sample runs but not all instances, unlike ADP. Suppose we observe a transition from state i to state j with U(i) = -0.5 and U(j) = +0.5, These values suggest that we should increase U(i) to make it agree better with its successor which can be achieved using the following updating rule.<\/p>\r\n<img class=\"aligncenter size-full wp-image-879\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-274.png\" alt=\"\" width=\"523\" height=\"68\" \/>\r\n<p style=\"text-align: justify\">This intuitively moves us closer to satisfying Bellman constraint. In the above equation a is a <strong>learning rate<\/strong> parameter. It can be adapted for good convergence. We will discuss more about this approach in a succeeding module.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">38.7 Passive Learning in an Unknown Environment<\/strong><\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The Least Mean Square(LMS) approach and Temporal-Difference(TD) approach operate unchanged in an initially unknown environment. The Adaptive Dynamic Programming (ADP) approach adds a step that updates an estimated model of the environment.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">In ADP Approach the environment model is learned by direct observation of transitions. The environment model M can be updated by keeping track of the percentage of times each state transitions to each of its neighbors . The ADP approach and the TD approach are closely related. They both try to make local adjustments to the utility estimates in order to make each state \u201cagree\u201d with its successors. While TD adjusts a state to agree with its observed successor, ADP adjusts the state to agree with all of the successors. However an important difference is that while TD makes a single adjustment per observed transition, ADP makes as many adjustments as needed to restore consistency between the utility estimates U and the environment model M . To make ADP more efficient we can directly approximate the algorithm for value iteration or policy iteration. Prioritized-sweeping heuristic makes adjustments to states whose likely successors have just undergone a large adjustment in their own utility estimates . The advantages of the approximate ADP include efficiency in terms of computation and elimination of long value iterations that occur in the early stages.<\/p>\r\n&nbsp;\r\n\r\n<strong>38.8 Active Learning in an Unknown Environment<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">To achieve active learning minor changes needs to be incorporated into the passive learning agent. Now the environment model incorporates the probabilities of transitions to other states given a particular action. In order to maximize its expected utility the agent needs a performance element to choose an action at each step.<\/p>\r\n<img class=\"aligncenter size-full wp-image-880\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-275.png\" alt=\"\" width=\"467\" height=\"99\" \/>\r\n\r\n<strong>Active ADP Approach<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The need to learn the probability Maij of a transition instead of Mij and the input to the function will include the action taken.<\/p>\r\n&nbsp;\r\n\r\n<strong>Active TD Approach<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The model acquisition problem for the TD agent is identical to that for the ADP agent. The update rule remains unchanged and the TD algorithm will converge to the same values as ADP as the number of training sequences tends to infinity.<\/p>\r\n&nbsp;\r\n\r\n<strong>38.9 Explore versus Exploit<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Exploitation is the maximization of immediate reward while exploration is the maximization of long-term wellbeing. Then choose a random action once in k times. Otherwise, choose the action with the highest expected utility (k-1 out of k times). The learner actively interacts with the environment: At the beginning the learner does not know anything about the environment. It gradually gains the experience and learns how to react to the environment.<\/p>\r\n&nbsp;\r\n\r\n<strong>38.9.1 Dilemma (exploration-exploitation):<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"font-size: 1em;text-align: justify\">After some number of steps, should I select the best current choice (exploitation) or try to learn more about the environment (exploration)?. When we choose exploitation it may result in the selection of a sub-optimal action and prevent the learning of the optimal choice. On the other hand exploration may spend too much time on trying bad currently suboptimal actions. Hence we have the combined Wacky approach (exploration) that act randomly in hopes of eventually exploring entire environment. The greedy approach (exploitation): acts to maximize utility using current estimate. The reasonable balance: act more wacky (exploratory) when agent has little idea of environment; more greedy when the model is close to correct. An example of the combination of approaches is the n-armed bandits approach.<\/span><\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>38.9.2 Single State: K-armed Bandit Approach<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">In the <em>k<\/em>-armed bandit problem, we must <strong>explore<\/strong> a variety of actions and then <strong>exploit<\/strong> the best of them. In order to solve the K-armed bandit problem, we must explore a variety of actions (in order to estimate their values) and exploit the best of them (in order to maximise reward). Among <em>K<\/em> levers, choose the one that pays best (Figure 38.4). Here\u00a0Q(a) is the value of action a and reward is ra. Set Q(a) = ra and choose a*if Q(a*)=maxa Q(a).<\/p>\r\n<img class=\"aligncenter size-full wp-image-881\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-276.png\" alt=\"\" width=\"407\" height=\"293\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><strong>Figure 38.4 K-armed Bandit Approach 38.9.3 Example: K-armed Bandit:<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">Let us assume that we are given Rs.10 to play on a slot machine with 5 levers and each play costs Rs.1; each pull of a lever may produce payoff of 0, 1 Rs, 5Rs, 10Rs. Find the optimal policy where payoff is the most. Again it is a tradeoff between exploitation and exploration where exploitation is the continuity of pulling the lever that returns positive value while exploration is trying to pull a new one. Here we have two models, the deterministic model where payoff of each lever is fixed, but unknown in advance and the stochastic model where payoff of each lever is uncertain, with known or unknown probability.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">In deterministic case, when <em>Q<\/em>(<em>a<\/em>) is value of action <em>a, and r<\/em><em>a<\/em> is the reward of action a, we make Q(a)= <em>r<\/em><em>a<\/em> <em>and we choose an action a*<\/em> if <em>Q<\/em>(<em>a<\/em>*)=max<em>a<\/em> <em>Q<\/em>(<em>a<\/em>). In the stochastic model, the reward is non-deterministic: p(r|a) and Qt (a) is the estimate of the value of action a at\u00a0<span style=\"text-align: initial;font-size: 1em\">time t. We need to use the Delta rule where h is learning factor and Qt +1(a) is the expected value which should converge to the mean of p(r|a) as t increases.<\/span><\/p>\r\n\r\n<\/div>\r\n&nbsp;\r\n<p style=\"text-align: justify\">The single state (single slot machine) uses Q(Si aj ) the value of action aj in state si as the reward to be learnt while for the multiple states we use p(r|si,aj) to account for the different reward probabilities. Action causes state change, in addition to reward and rewards are not necessarily of immediate value. There can also be delayed rewards.<\/p>\r\n&nbsp;\r\n\r\n<strong>Summary:<\/strong>\r\n<ul>\r\n \t<li>Outlined the objectives of Reinforcement Learning<\/li>\r\n \t<li>Explained Passive and Active Learning.<\/li>\r\n \t<li>Reviewed the known and unknown environment<\/li>\r\n \t<li>Discussed exploration vs exploitation<\/li>\r\n<\/ul>\r\n&nbsp;\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>you can view video on Basics of Reinforcement Learning - II<\/strong><\/td>\r\n<td><a href=\"https:\/\/youtu.be\/pSMAFT0Iplw\" target=\"_blank\" rel=\"noopener\"><img class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n\r\n<strong>Web Links<\/strong>\r\n<ul>\r\n \t<li>http:\/\/en.wikipedia.org\/wiki\/Reinforcement_learning<\/li>\r\n \t<li>http:\/\/www.cs.cmu.edu\/afs\/cs\/project\/theo-20\/www\/mlbook\/ch13.pdf<\/li>\r\n \t<li>http:\/\/neuro.bstu.by\/ai\/RL-3.pdf<\/li>\r\n \t<li>https:\/\/cs.uwaterloo.ca\/~ppoupart\/ICML-07-tutorial-slides\/icml07-brl-tutorial-part2-intro-ghavamzadeh.pdf<\/li>\r\n \t<li>ce.sharif.edu\/courses\/91-92\/1\/ce717-2\/resources\/root\/Lectures\/RL.pdf<\/li>\r\n \t<li>www.cogsys.wiai.uni-bamberg.de\/teaching\/ss05\/ml\/slides\/cogsysII-10.pdf<\/li>\r\n \t<li>https:\/\/www.cs.uic.edu\/~piotr\/cs594\/YijueRL.ppt<\/li>\r\n \t<li>https:\/\/en.wikipedia.org\/wiki\/Multi-armed_bandit<\/li>\r\n \t<li>http:\/\/teaching.csse.uwa.edu.au\/units\/CITS3001\/lectures\/lectures\/3001%20Reinforcement%20learning.<\/li>\r\n \t<li>https:\/\/www.udacity.com\/wiki\/cs271\/unit10-notes#!#passive-vs-active<\/li>\r\n \t<li>http:\/\/www.cs.mcgill.ca\/~vkules\/bandits.pdf<\/li>\r\n \t<li>www.cs.berkeley.edu\/~jordan\/MLShortCourse\/reinforcement-learning.ppt<\/li>\r\n \t<li>http:\/\/www.inf.ed.ac.uk\/teaching\/courses\/rl\/slides15\/rl02.pdf<\/li>\r\n<\/ul>\r\n&nbsp;\r\n\r\n<strong>Supporting &amp; Reference Materials<\/strong>\r\n<ul>\r\n \t<li>Richard S. Sutton and Andrew G. Barto , \u201cReinforcement Learning: An Introduction\u201d, 1998, MIT press<\/li>\r\n \t<li>Wiering, Marco, van Otterlo, Martijn (Eds.), \u201cReinforcement Learning\u201d, State-of-the-Art Series: Adaptation, Learning, and Optimization, Vol. 12, 2012<\/li>\r\n \t<li>Stuart Russell and Peter Norvig \u201cArtificial Intelligence: A Modern Approach Prentice Hall Series in Artificial Intelligence), 2009<\/li>\r\n \t<li>Tom Mitchell, \u201cMachine Learning\u201d, McGraw-Hill Education, 1997<\/li>\r\n \t<li><a href=\"http:\/\/www.amazon.in\/s\/ref=dp_byline_sr_book_1?ie=UTF8&amp;field-author=Alpaydin+Ethem&amp;search-alias=stripbooks\">Alpaydin Ethem, <\/a>\u201cIntroduction to Machine Learning\u201d, The MIT Press; third edition, 2014<\/li>\r\n \t<li><a href=\"http:\/\/www.amazon.in\/s\/ref=dp_byline_sr_book_1?ie=UTF8&amp;field-author=Stephen+Marsland&amp;search-alias=stripbooks\">Stephen Marsland, <\/a>\u201cMachine Learning: An Algorithmic Perspective\u201d, Chapman and Hall\/CRC; 2 edition, 2014<\/li>\r\n<\/ul>\r\n&nbsp;","rendered":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/pSMAFT0Iplw\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a><br \/>\n<\/span><\/div>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>Learning Objectives<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The learning objectives of the module are as follows:<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 To understand the Reinforcement Learning and its variants<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 To discuss about Passive Learning and Active learning<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 To explain the Markov Decision Process and Partially Observable MDP<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 To illustrate the Least Mean Square and Adaptive Programming<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.1 Reinforcement Learning<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">As already discussed in the previous module reinforcement learning is the problem of getting an agent to act in the world so as to maximize its rewards. It is a trial-and-error learning paradigm which learns from rewards and punishments. Reinforcement learning is not just an algorithm but a new paradigm in itself. Its objective is to learn about a system from minimal feedback.<\/p>\n<p>&nbsp;<\/p>\n<p>Let us recall the mathematical formulation of the learning task, we e xecute actions in the environment, observe results and<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-868\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-264.png\" alt=\"\" width=\"634\" height=\"192\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-264.png 634w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-264-300x91.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-264-65x20.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-264-225x68.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-264-350x106.png 350w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/p>\n<p style=\"text-align: justify\">The learning task associated with reinforcement learning can be characterized based on three perspectives namely learning type , environment and rewards. The learning type can be passive or active. The environment can be known or unknown, in other words does the agent know effects of actions? Does the agent have a model of environment?<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"font-size: 1em;text-align: initial\">Here we will assume that the environment is accessible. The rewards can be terminal only or non-terminal.<\/span><\/p>\n<\/div>\n<div style=\"text-align: center\">\n<p>&nbsp;<\/p>\n<p><strong>38.2 Passive versus Active Learning<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Passive Learning is a learning about an agent which has fixed policy and tries to learn the utilities of states by observing the world go by and is analogous to policy evaluation in policy iteration. Here the agent only learns how \u201cgood\u201d each state or action is. The values of states are learnt and the action is taken accordingly.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Active learning is the learning where the agent attempts to find an optimal (or at least good) policy by acting in the world. It is not a fixed policy but it is like finding a best policy. It is analogous to solving the underlying MDP (Markov Decision Process).<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.3\u00a0 Reinforcement Approaches<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Reinforcement Learning is a sequential decision problem, you learn one state and then go to the other state and then upcoming states with the reward for each state.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Model-Based vs. Model-Free RL<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Model based approach to RL will learn the MDP model, or an approximation of it and then use it for policy evaluation or to find the optimal policy. The agent learns values of states (or state histories) and tries to maximize utility of their outcomes. Here there is a need for a model of the environment including the operations that are available and the states they lead to. In another approach the agent learns values of state-action pairs. In this case the agent does not require a model of the environment (except legal moves) and cannot look ahead. The Model free approach to RL will derive the optimal policy without explicitly learning the model. It is useful when model is difficult to represent and\/or learn.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Deterministic\u00a0 transitions\u00a0 and\u00a0\u00a0 Stochastic\u00a0 transitions\u00a0 are\u00a0\u00a0 two\u00a0\u00a0 reinforcement\u00a0\u00a0 learning perspectives.\u00a0 is the probability of reaching state j when taking action a in state i. The uncertainty in going from state i and when an action is taken and there is no guarantee that state j can be reached. This is a sequential problem where each and every move is recorded.<\/p>\n<p>&nbsp;<\/p>\n<p>A simple environment presents the agent with a sequential decision problem:<\/p>\n<p>&nbsp;<\/p>\n<p>Move cost = 0.04<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-870\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-265.png\" alt=\"\" width=\"256\" height=\"177\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-265.png 256w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-265-65x45.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-265-225x156.png 225w\" sizes=\"auto, (max-width: 256px) 100vw, 256px\" \/><strong style=\"text-align: center;font-size: 1em\">Figure 38.1 Reinforcement learning<\/strong><\/p>\n<\/div>\n<p><strong>\u00a0<\/strong><\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Temporal credit assignment problem is a sparse reinforcement problem. In the offline algorithm the action sequences are determined beforehand. In the online algorithm the action sequences are conditional on observations along the way (Figure 38.1). This type is important in stochastic environment (e.g. jet flying).<\/span><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>38.4 RL Model<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The objective of reinforcement learning is to find the mapping that maximizes some combination of future reinforcements (rewards) received over time. The valuation models quantify how good the mapping is. We can consider the finite horizon model where we first consider maximizing total reward over a finite horizon. In other words the agent has n time steps to live. This is defined as<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-871\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-266.png\" alt=\"\" width=\"325\" height=\"80\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-266.png 325w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-266-300x74.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-266-65x16.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-266-225x55.png 225w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><\/p>\n<p style=\"text-align: justify\">When we do not assume finite time then we have the infinite horizon discounted model. Defining expected value as total reward is problematic with infinite horizons and hence we introduce discount factor 0 \u2264 g &lt; 1 that is future rewards are discounted by g per time step.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-872\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-267.png\" alt=\"\" width=\"562\" height=\"82\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-267.png 562w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-267-300x44.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-267-65x9.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-267-225x33.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-267-350x51.png 350w\" sizes=\"auto, (max-width: 562px) 100vw, 562px\" \/><\/p>\n<p>The Average reward is given as<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-873\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-268.png\" alt=\"\" width=\"218\" height=\"85\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-268.png 218w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-268-65x25.png 65w\" sizes=\"auto, (max-width: 218px) 100vw, 218px\" \/><\/p>\n<p style=\"text-align: justify\">In order to solve the problem mathematically we formulate it as a Markov Decision Process (MDP) or Partially Observable Markov Decision Process (POMDP). We maximize the state -value and action-value functions using the Bellmann optimality equation. We need to use approximations such as dynamic programming, Monte Carlo Methods, Temporal-difference Learning to solve the Bellmann equation.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.4.1 Markov Decision Process and Partially Observable Markov Decision Process<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The usual Markov Decision Process has the following components. The set of States S, set of actions A, the state transition probability P(s\u2019|s,a), the immediate Rewards R(s,a) and discount factor g. The current state is always perfectly observed.<\/p>\n<\/div>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-874\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-269.png\" alt=\"\" width=\"298\" height=\"184\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-269.png 298w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-269-65x40.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-269-225x139.png 225w\" sizes=\"auto, (max-width: 298px) 100vw, 298px\" \/><\/p>\n<p style=\"text-align: center\"><strong>Figure 38.2 MDP Process<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The Partially Observable Markov Decision Processes (POMDP) has just like MDP the set of states S, set of actions A, the probabilistic transitions, the immediate rewards, a discount factor but in addition has the observations Z, observation probabilities and an initial belief b0. The brief theory of how MDP works is discussed below,<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">An MDP has four components: S, A, R, T as already discussed the (finite) state set S (|S| = n), the (finite) action set A (|A| = m). the (Markov) transition function T(s,a,s\u2019) = Pr(s\u2019 | s,a) (Probability of going to state <strong>s\u2019<\/strong> after taking action <strong>a<\/strong> in state <strong>s)<\/strong> and the bounded, real-valued reward function R(s) (Immediate reward we get for being in state s). For example in a goal-based domain R(s) may equal 1 for goal states and 0 for all others. This reward function can be generalized to include action costs: R(s,a) and can also be generalized to be a stochastic function. Moreover, MDP can easily generalize to countable or continuous state and action spaces<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.5\u00a0 Passive Learner in a Known Environment<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">A passive learner simply watches the world going by, and tries to learn the utility of being in various states. Another way to think of a passive learner is as an agent with a fixed policy of trying to determine its benefits. In passive learning, the environment generates state transitions and the agent perceives them. Consider an agent trying to learn the utilities of the states shown below:<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 Agent can move {North, East, South, West}<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Terminate on reading [4,2] or [4,3]<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-875\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-270.png\" alt=\"\" width=\"298\" height=\"184\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-270.png 298w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-270-65x40.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-270-225x139.png 225w\" sizes=\"auto, (max-width: 298px) 100vw, 298px\" \/><\/p>\n<p style=\"text-align: center\"><strong>Figure 38.2 Example<\/strong><\/p>\n<\/div>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-876\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-271.png\" alt=\"\" width=\"596\" height=\"118\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-271.png 596w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-271-300x59.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-271-65x13.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-271-225x45.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-271-350x69.png 350w\" sizes=\"auto, (max-width: 596px) 100vw, 596px\" \/><\/p>\n<p style=\"text-align: center\"><strong>Figure 38.3 State Transition Probabilities<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Agent is provided with Mij = a model giving the probability of reaching from state i to state j (each state transitions to neighbouring states with equal probability). With this assumption it means that the probability of a state is determined by the number of transitions from that state. Thus if a state has 3 transitions from it, the probability of transition to each of those states is 0.33 (Figure 38.3).<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.6 Passive Learning in a Known Environment<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">There are three approaches in passive learning in a known environment such as LMS (least mean squares), ADP (adaptive dynamic programming) and TD (temporal difference learning).We will discuss each methods in detail.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.6.1 LMS (Least Mean Squares)<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In this method we find an estimate of utility <strong><em>U<\/em><\/strong><strong><em>p<\/em><\/strong><strong><em>(s). This method has<\/em><\/strong> slow convergence and it takes the agent well over a 1000 training sequences to get close to the correct value. Assume that after entering +1 or -1 state the agent enters zero reward terminal state. We need to follow the policy for many epochs to get the required training sequences. Agent makes random runs (sequences of random moves) through environment (Example given in Figure 38.2) as given below:<\/p>\n<p>&nbsp;<\/p>\n<p>[1,1]-&gt;[1,2]-&gt;[1,3]-&gt;[2,3]-&gt;[3,3]-&gt;[4,3] =\u00a0 +1<\/p>\n<p>&nbsp;<\/p>\n<p>[1,1]-&gt;[2,1]-&gt;[3,1]-&gt;[3,2]-&gt;[4,2] =\u00a0 -1<\/p>\n<p>&nbsp;<\/p>\n<p>Here we carry out direct estimation which is model free. We will estimate <em>U<\/em><em>p<\/em><em>(s)<\/em> as average total reward of epochs containing s (calculating from s to end of epoch). The r<em>eward to go<\/em> of a state s is calculated by the sum of the (discounted) rewards from that state until a terminal state is reached . The key here is to use observed <strong><em>reward to go<\/em><\/strong> to a state as the direct evidence of the actual expected utility of that state.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.6.2 ADP (Adaptive Dynamic Programming)<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Adaptive Dynamic Programming (ADP) is a model based approach. In this method we follow the policy for a while and then use the value or policy iteration algorithm to calculate exact utilities of states given an estimated model. This method makes optimal use of the local constraints on utilities of states imposed by the neighborhood structure of the environment. However this method is somewhat intractable for large state spaces. Let R(i) be the reward of being in state i, (often non zero for only a few end states) and Mij is the probability of transition from state i to j .<\/p>\n<\/div>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-877\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-272.png\" alt=\"\" width=\"455\" height=\"185\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-272.png 455w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-272-300x122.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-272-65x26.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-272-225x91.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-272-350x142.png 350w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The ADP is a model based approach which follow the policy for a while and estimates transition model based on observations and the reward function. The estimated model is used to compute utility of policy. We estimate transition model T(s,a,s\u2019) which simply the fraction of times we see s\u2019 after taking a in state s. From Figure 38.4 we see that<\/p>\n<p>&nbsp;<\/p>\n<p>U(3,3) = 0.33 x U(4,3) + 0.33 x U(2,3) + 0.33 x U(3,2)<\/p>\n<p>&nbsp;<\/p>\n<p>=\u00a0 0.33 x 1.0 + 0.33 x 0.0886 + 0.33 x -0.4430<\/p>\n<p>&nbsp;<\/p>\n<p>=\u00a0 0.2152<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-878\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-273.png\" alt=\"\" width=\"679\" height=\"281\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-273.png 679w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-273-300x124.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-273-65x27.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-273-225x93.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-273-350x145.png 350w\" sizes=\"auto, (max-width: 679px) 100vw, 679px\" \/><\/p>\n<p style=\"text-align: center\"><strong>Figure 38.3 Adaptive Dynamic Programming 38.6.3 TD (Temporal Difference Learning)<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The key of temporal difference learning is to use the observed transitions to adjust the values of the observed states so that they agree with the constraint equations. The performance of runs are \u201cnoisier\u201d than LMS but with smaller error. The approach deals with observed states during sample runs but not all instances, unlike ADP. Suppose we observe a transition from state i to state j with U(i) = -0.5 and U(j) = +0.5, These values suggest that we should increase U(i) to make it agree better with its successor which can be achieved using the following updating rule.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-879\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-274.png\" alt=\"\" width=\"523\" height=\"68\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-274.png 523w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-274-300x39.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-274-65x8.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-274-225x29.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-274-350x46.png 350w\" sizes=\"auto, (max-width: 523px) 100vw, 523px\" \/><\/p>\n<p style=\"text-align: justify\">This intuitively moves us closer to satisfying Bellman constraint. In the above equation a is a <strong>learning rate<\/strong> parameter. It can be adapted for good convergence. We will discuss more about this approach in a succeeding module.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">38.7 Passive Learning in an Unknown Environment<\/strong><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The Least Mean Square(LMS) approach and Temporal-Difference(TD) approach operate unchanged in an initially unknown environment. The Adaptive Dynamic Programming (ADP) approach adds a step that updates an estimated model of the environment.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In ADP Approach the environment model is learned by direct observation of transitions. The environment model M can be updated by keeping track of the percentage of times each state transitions to each of its neighbors . The ADP approach and the TD approach are closely related. They both try to make local adjustments to the utility estimates in order to make each state \u201cagree\u201d with its successors. While TD adjusts a state to agree with its observed successor, ADP adjusts the state to agree with all of the successors. However an important difference is that while TD makes a single adjustment per observed transition, ADP makes as many adjustments as needed to restore consistency between the utility estimates U and the environment model M . To make ADP more efficient we can directly approximate the algorithm for value iteration or policy iteration. Prioritized-sweeping heuristic makes adjustments to states whose likely successors have just undergone a large adjustment in their own utility estimates . The advantages of the approximate ADP include efficiency in terms of computation and elimination of long value iterations that occur in the early stages.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.8 Active Learning in an Unknown Environment<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">To achieve active learning minor changes needs to be incorporated into the passive learning agent. Now the environment model incorporates the probabilities of transitions to other states given a particular action. In order to maximize its expected utility the agent needs a performance element to choose an action at each step.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-880\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-275.png\" alt=\"\" width=\"467\" height=\"99\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-275.png 467w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-275-300x64.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-275-65x14.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-275-225x48.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-275-350x74.png 350w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><\/p>\n<p><strong>Active ADP Approach<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The need to learn the probability Maij of a transition instead of Mij and the input to the function will include the action taken.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Active TD Approach<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The model acquisition problem for the TD agent is identical to that for the ADP agent. The update rule remains unchanged and the TD algorithm will converge to the same values as ADP as the number of training sequences tends to infinity.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.9 Explore versus Exploit<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Exploitation is the maximization of immediate reward while exploration is the maximization of long-term wellbeing. Then choose a random action once in k times. Otherwise, choose the action with the highest expected utility (k-1 out of k times). The learner actively interacts with the environment: At the beginning the learner does not know anything about the environment. It gradually gains the experience and learns how to react to the environment.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>38.9.1 Dilemma (exploration-exploitation):<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"font-size: 1em;text-align: justify\">After some number of steps, should I select the best current choice (exploitation) or try to learn more about the environment (exploration)?. When we choose exploitation it may result in the selection of a sub-optimal action and prevent the learning of the optimal choice. On the other hand exploration may spend too much time on trying bad currently suboptimal actions. Hence we have the combined Wacky approach (exploration) that act randomly in hopes of eventually exploring entire environment. The greedy approach (exploitation): acts to maximize utility using current estimate. The reasonable balance: act more wacky (exploratory) when agent has little idea of environment; more greedy when the model is close to correct. An example of the combination of approaches is the n-armed bandits approach.<\/span><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>38.9.2 Single State: K-armed Bandit Approach<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In the <em>k<\/em>-armed bandit problem, we must <strong>explore<\/strong> a variety of actions and then <strong>exploit<\/strong> the best of them. In order to solve the K-armed bandit problem, we must explore a variety of actions (in order to estimate their values) and exploit the best of them (in order to maximise reward). Among <em>K<\/em> levers, choose the one that pays best (Figure 38.4). Here\u00a0Q(a) is the value of action a and reward is ra. Set Q(a) = ra and choose a*if Q(a*)=maxa Q(a).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-881\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2019\/01\/2-276.png\" alt=\"\" width=\"407\" height=\"293\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-276.png 407w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-276-300x216.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-276-65x47.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-276-225x162.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2019\/01\/2-276-350x252.png 350w\" sizes=\"auto, (max-width: 407px) 100vw, 407px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><strong>Figure 38.4 K-armed Bandit Approach 38.9.3 Example: K-armed Bandit:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Let us assume that we are given Rs.10 to play on a slot machine with 5 levers and each play costs Rs.1; each pull of a lever may produce payoff of 0, 1 Rs, 5Rs, 10Rs. Find the optimal policy where payoff is the most. Again it is a tradeoff between exploitation and exploration where exploitation is the continuity of pulling the lever that returns positive value while exploration is trying to pull a new one. Here we have two models, the deterministic model where payoff of each lever is fixed, but unknown in advance and the stochastic model where payoff of each lever is uncertain, with known or unknown probability.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In deterministic case, when <em>Q<\/em>(<em>a<\/em>) is value of action <em>a, and r<\/em><em>a<\/em> is the reward of action a, we make Q(a)= <em>r<\/em><em>a<\/em> <em>and we choose an action a*<\/em> if <em>Q<\/em>(<em>a<\/em>*)=max<em>a<\/em> <em>Q<\/em>(<em>a<\/em>). In the stochastic model, the reward is non-deterministic: p(r|a) and Qt (a) is the estimate of the value of action a at\u00a0<span style=\"text-align: initial;font-size: 1em\">time t. We need to use the Delta rule where h is learning factor and Qt +1(a) is the expected value which should converge to the mean of p(r|a) as t increases.<\/span><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The single state (single slot machine) uses Q(Si aj ) the value of action aj in state si as the reward to be learnt while for the multiple states we use p(r|si,aj) to account for the different reward probabilities. Action causes state change, in addition to reward and rewards are not necessarily of immediate value. There can also be delayed rewards.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Summary:<\/strong><\/p>\n<ul>\n<li>Outlined the objectives of Reinforcement Learning<\/li>\n<li>Explained Passive and Active Learning.<\/li>\n<li>Reviewed the known and unknown environment<\/li>\n<li>Discussed exploration vs exploitation<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>you can view video on Basics of Reinforcement Learning &#8211; II<\/strong><\/td>\n<td><a href=\"https:\/\/youtu.be\/pSMAFT0Iplw\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Web Links<\/strong><\/p>\n<ul>\n<li>http:\/\/en.wikipedia.org\/wiki\/Reinforcement_learning<\/li>\n<li>http:\/\/www.cs.cmu.edu\/afs\/cs\/project\/theo-20\/www\/mlbook\/ch13.pdf<\/li>\n<li>http:\/\/neuro.bstu.by\/ai\/RL-3.pdf<\/li>\n<li>https:\/\/cs.uwaterloo.ca\/~ppoupart\/ICML-07-tutorial-slides\/icml07-brl-tutorial-part2-intro-ghavamzadeh.pdf<\/li>\n<li>ce.sharif.edu\/courses\/91-92\/1\/ce717-2\/resources\/root\/Lectures\/RL.pdf<\/li>\n<li>www.cogsys.wiai.uni-bamberg.de\/teaching\/ss05\/ml\/slides\/cogsysII-10.pdf<\/li>\n<li>https:\/\/www.cs.uic.edu\/~piotr\/cs594\/YijueRL.ppt<\/li>\n<li>https:\/\/en.wikipedia.org\/wiki\/Multi-armed_bandit<\/li>\n<li>http:\/\/teaching.csse.uwa.edu.au\/units\/CITS3001\/lectures\/lectures\/3001%20Reinforcement%20learning.<\/li>\n<li>https:\/\/www.udacity.com\/wiki\/cs271\/unit10-notes#!#passive-vs-active<\/li>\n<li>http:\/\/www.cs.mcgill.ca\/~vkules\/bandits.pdf<\/li>\n<li>www.cs.berkeley.edu\/~jordan\/MLShortCourse\/reinforcement-learning.ppt<\/li>\n<li>http:\/\/www.inf.ed.ac.uk\/teaching\/courses\/rl\/slides15\/rl02.pdf<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Supporting &amp; Reference Materials<\/strong><\/p>\n<ul>\n<li>Richard S. Sutton and Andrew G. Barto , \u201cReinforcement Learning: An Introduction\u201d, 1998, MIT press<\/li>\n<li>Wiering, Marco, van Otterlo, Martijn (Eds.), \u201cReinforcement Learning\u201d, State-of-the-Art Series: Adaptation, Learning, and Optimization, Vol. 12, 2012<\/li>\n<li>Stuart Russell and Peter Norvig \u201cArtificial Intelligence: A Modern Approach Prentice Hall Series in Artificial Intelligence), 2009<\/li>\n<li>Tom Mitchell, \u201cMachine Learning\u201d, McGraw-Hill Education, 1997<\/li>\n<li><a href=\"http:\/\/www.amazon.in\/s\/ref=dp_byline_sr_book_1?ie=UTF8&amp;field-author=Alpaydin+Ethem&amp;search-alias=stripbooks\">Alpaydin Ethem, <\/a>\u201cIntroduction to Machine Learning\u201d, The MIT Press; third edition, 2014<\/li>\n<li><a href=\"http:\/\/www.amazon.in\/s\/ref=dp_byline_sr_book_1?ie=UTF8&amp;field-author=Stephen+Marsland&amp;search-alias=stripbooks\">Stephen Marsland, <\/a>\u201cMachine Learning: An Algorithmic Perspective\u201d, Chapman and Hall\/CRC; 2 edition, 2014<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"author":3,"menu_order":37,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-865","chapter","type-chapter","status-publish","hentry"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters\/865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/users\/3"}],"version-history":[{"count":6,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters\/865\/revisions"}],"predecessor-version":[{"id":884,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters\/865\/revisions\/884"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters\/865\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/media?parent=865"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapter-type?post=865"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/contributor?post=865"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/license?post=865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}