This article is the second part of the introduction to reinforcement learning series. It mainly introduces the MDP Markov decision process, a very important theoretical framework in reinforcement learning.

# MDP Markov decision-making process

MDP is Markov Decision Process. MDP is a mathematical form of reinforcement learning problem, so to speak, this section begins with the theoretical part of reinforcement learning.

## Basic concept

### What is reinforcement learning?

A few concepts need to be made clear first. The first is the agent. An agent is a machine that can learn and implement decisions. Everything other than an agent that interacts with it is called an environment. In the environment, the agent interacts with the environment, selects the action from the state of the environment at a certain moment, and the environment gives the corresponding feedback to the action, changes to the new state at the next moment, and generates a reward to return to the agent. This is an agent – environment interaction. The diagram below.

Reinforcement learning considers the interactive learning between the agent and the environment. The learning goal of the agent is the reward returned by the environment, and the RL task is the expectation of maximizing the cumulative sum of rewards. It is a method of active learning without supervision. Rewards are also the basis for evaluating action choices.

### MDP

MDP is the foundation of reinforcement learning and the theoretical framework of RL. In MDP, we consider state SSS, action AAA, and reward RRR. Specifically, the agent observes a certain characteristic expression sts_TST of the environment state at time TTT, then selects the action ATA_TAT, and receives the result of the action ATA_TAT at the next moment, that is, the reward RT + 1R_ {t+1} RT +1. At the same time enter the next state st+1s_{t+1}st+1. When the state, action, reward set (S, A, R)(S, A, R)(S, A, R) in MDP has A finite number of elements, such MDP is also called finite MDP. The formalized sequence is as follows:

Four-parameter expression

Here’s a summary:

The probability equation above shows that in MDP, the probability of each possible value of ST, RTS_T, R_TST, rt depends only on the previous state and action ST −1, at−1s_{t-1}, A_ {T-1} ST −1, AT −1, irrespective of the earlier state and action. Such a state is therefore said to be Markov.

For continuous tasks, G is defined as the weighted sum of rewards:

Gamma \gamma is called the discounting factor.

In fact, the total reward GtG_tGt is still finite, because as long as the reward is non-zero constant and γ>1\gamma>1γ>1, the total reward GtG_tGt is convergent, for example, when the reward is a constant 1, it can be expressed as

## State value function and action value function

Policy is a mapping from the state to the probability of selection of each action, which is a random function of the agent’s selection of actions. In terms of PI \ PI PI. π\ PI π is bound to SSS. PI (a) ∣ s \ PI PI (a | s) (a) ∣ s said state s action selection under a probability, PI (s)/PI (s) of PI (s) is in the state (that is, the moment) of the probability density function. PI (s)/PI (s) (s) is a function of PI, PI (a ∣ s)/PI (a | s) PI (a ∣ s) is the probability of a specific value.

The value function of state under different strategies is different, so we use vπ(s)v_{\ PI}(s)vπ(s) to represent the value function of state SSS under strategy π\ PI π. Therefore, qπ(s,a)q_{\ PI}(s,a)qπ(s,a) is used to represent the value function of action aaa under the state SSS under the policy π\ PI π. V πv_{\ PI}vπ is also called the state value function of the strategy π\ PI π, and qπq_{\ PI}qπ is also called the action value function of the strategy π\ PI π. The probability of taking the same action may be different under different strategies.

For all states SSS, the value of the current state is the expected probability of the reward that the agent will receive for performing an action based on the current policy, starting from state S, given a strategy π\ PI π. The expectation here is because when entering from SSS to the next state s’s ‘, different actions are taken to enter different S’s ‘and the rewards are different. Therefore, the expectation should be obtained for all possible S’s’.

Similarly, for the action value function qπq_{\ PI}qπ, that is, given the strategy π\ PI π, after the execution of action A, because different action environment may produce different rewards, so to expect the reward of all possible decision sequences, we have

To understand this, you can see that,$v_{\pi}$The expectation of reward from state to state,$q_{\pi}$The expectation of reward from action to action. The probability of$p$It’s the environment, so we can only optimize the strategy.

In fact, it is not difficult to find that vπv_{\ PI}vπ has the following relationship with qπq_{\ PI}qπ :

If you look at the formula, the value of the state is equal to the value of all the possible actions in that state, times the expectation of the probability of choosing the possible actions under the current strategy. The value of the action depends on the expected value of the subsequent rewards and the sum of the rest of the rewards.

Q π(s,a)q_{\ PI}(s,a)qπ(s,a)

Further, for any strategy π\ PI π and any state SSS, we can obtain the relationship between the current value of state SSS and its possible successor state s’s ‘:

This equation is also known as the Bellman equation. Since PPP is a probability density function, the last term is actually the expected value, which is qπq_{\ PI}qπ.

## Berman’s optimal equation

How do we derive that?

We know that the Behrman equation, in fact, is the recursive form of the state value function:

How do you find the optimal strategy?

In fact, there may be more than one optimal strategy (π∗\pi_*π∗), but they must share the optimal action value function as well as the state value function, so there are:

In the optimal policy, the value of each state must be equal to the expected reward of the optimal action in that state (because the policy has been determined), as follows:

This is the Bellman optimal equation for the state value function.

And for the action value function, its Behrman optimal equation is as follows:

**reference**

- Barto, Sutton. Reinforcement Learning (Second Edition)