Full text
Nonlinear Dyn (2024) 112:8363–8391 https://doi.org/10.1007/s11071-024-09509-8 ORIGINAL PAPER Monte Carlo tree search control scheme for multibody dynamics applications Yixuan Tang ·Grzegorz Orzechowski · Aleš Prokop ·Aki Mikkola Received: 14 June 2023 / Accepted: 7 March 2024 / Published online: 3 April 2024 © The Author(s) 2024 Abstract There is considerable interest in applying reinforcement learning (RL) to improve machine control across multiple industries, and the automotive industry is one of the prime examples. Monte Carlo Tree Search (MCTS) has emerged and proven powerful in decision-making games, even without understanding the rules. In this study, multibody system dynamics (MSD) control is first modeled as a Markov Decision Process and solved with Monte Carlo Tree Search. Based on randomized search space exploration, the MCTS framework builds a selective search tree by repeatedly applying a Monte Carlo rollout at each child node. However, without a library of available choices, deciding among the many possibilities for agent parameters can be intimidating. In addition, the MCTS poses a significant challenge for searching due to the large branching factor. This challenge is typically overcome by appropriate parameter design, search guiding, action reduction, parallelization, and early termination. To address these shortcomings, the overarching goal of this study is to provide needed insight into inverted pendulum controls via vanilla and modified MCTS agents, respectively. A series of reward functions are well-designed according to the control Y. Tang (B)·G. Orzechowski ·A. Mikkola Department of Mechanical Engineering, LUT University, 53850 Lappeenranta, Finland e-mail: Yixuan.T[email protected]; Yixuan.Ta[email protected] A. Prokop Faculty of Mechanical Engineering, Brno University of Technology, Technicka 2896/2, 616 69, Brno, Czech Republic goal, which maps a specific distribution shape of reward bonus and guides the MCTS-based control to maintain the upright position. Numerical examples show that the reward-modified MCTS algorithms significantly improve the control performance and robustness of the default choice of a constant reward that constitutes the vanilla MCTS. The exponentially decaying reward functions perform better than the constant value or polynomial reward functions. Moreover, the exploitation vs. exploration trade-off and discount parameters are carefully tested. The study’s results can guide the research of RL-based MSD users. Keywords Monte Carlo Tree Search ·Multibody dynamics ·Reward functions ·Parametric analysis · Artificial intelligence control ·Inverted pendulum 1 Introduction Artificial intelligence (AI), often realized by applying machine learning (ML), has recently been attracting considerable interest and has been on the rise in academia and industry. The objective of this work is to use AI to control multibody system dynamics, such as inverted pendulum control, and improve the performance of classical AI controllers. The most common ML approach is to train learning algorithms with a lot of data to solve decision-making and prediction tasks, which has brought many groundbreaking innovations. Reinforcement learning (RL) [1] is one of the 123
8364 Y. Tang et al. main branches of ML. Depending on how the agents learn from the environment model to get a known transition probability, the RL algorithms can be grouped into model-free and model-based RL algorithms [2]. To maximize cumulative reward, the RL algorithms generate data through continuous interaction with the environment. Each interaction cycle in RL intends to find the optimal decision to take action. The agent in model-free RL algorithms uses the data sampled from experience and learns the value function and policy. Model-free RL algorithms are suitable when using the deep learning (DL) framework to sample large-scale data and conduct network training. Due to the large amount of data sampling required, however, the modelfree RL algorithms are computationally intensive. At the same time, the agent in model-based RL algorithms samples the simulation data to interact with the environment model and plan value function and policy. Ideally, if the model is sufficiently accurate, a good policy can be learned from it [3]. However, a compounding error [4] will develop between the model and the actual environment. The optimization process for RL algorithms primarily uses a mathematical framework known as the Markov decision process [5]. Monte Carlo Tree Search (MCTS) can be categorized as a model-based reinforcement learning approach, which involves planning for a sequential decision-making algorithm using standard Markov decision process logic. MCTS consists of searching combinatorial spaces represented by trees and Monte Carlo methods. Monte Carlo is one of the fundamental RL algorithms used to solve any Markov decision process problem [6]. Decision-mak- ing involves identifying and selecting the best alternative based on personal values and preferences. Decision-making processes are integral to games, involving players making strategic choices to achieve their objectives. In 2006, Rémi Coulomb [7] developed the MCTS algorithm in the 9 ×9 Go-chess-playing program, Crazy Stone. Before that, almost all Go programs used deterministic search algorithms. In 2017, the AlphaGoZero [8] (trained without human examples) defeated the strongest previous versions of AlphaGo [9] (trained with human expert data). MCTS was one of the main ideas behind the success of AlphaGo [9] and AlphaGoZero [8]. The MCTS is often combined with ML models to achieve great success in games. Notably, AlphaGo [9] combined MCTS with deep neural network is currently state-of-the-art for games in the class of chess and Go [10]. It has inspired many approaches for games sharing the same basic structure with a trained shallow value [11] and policy [12] networks. Moreover, MCTS also acted as a trainer for reinforcement learners to build ML models. Pinto and Coutinho [13] used MCTS as a possible options framework and prepared options for the video games. Kartal et al. [14] used MCTS as a demonstrator in hard-exploration domains because the negative rewards may have profound consequences acts. In addition to its remarkable achievements in games, MCTS also attracted interest from real-world problems beyond games [15]. This study only focuses on the application of mechanics and control. Shen et al. [16] proposed the M-walk to overcome the sparse reward problem, where the agent comprises an MCTS and a deep neural network to generate trajectories with more positive rewards. Using the same cost function and system model in autonomous driving, the MCTS algorithm achieves a much lower cost than classical Model Predictive Control (MPC) [17]. However, the scope of the study [17] is limited, and more insight is needed to draw more general conclusions about MCTS characteristics as compared with other control schemes, including MPC. A novel perspective to use MCTS to reconstruct the state space from a single time series for detection and observation was proposed in [18]. The Monte Carlo simulations of the surrogate models provided highly accurate approximations and significantly reduced the computational cost of structural head models [19]. Although MCTS has proven powerful in sequential decision-making problems, it poses a significant challenge for searching due to the search tree’s complexity [15,20]. Lacking computational power limits the potential of building an exhaustive search tree from the whole state space. The performances of MCTS can be significantly below algorithm capacity if the parameters are limitedly designed [21]. This can be clearly seen in Sect.4.3, where multiple MCTS control examples are evaluated with varying parameters. In recent years, several MCTS modifications intended to tackle the decision-making problems in games and have made new achievements in the following aspects. (1) In case of the tree is growing sideways with limited chances for the in-depth inspection of promising branches, the MCTS did action reduction modified 123
Monte Carlo tree search control scheme... 8365 to narrow down the number of available actions [22,23]. (2) Real-time strategy is a challenge and hot-spot for RL algorithms due to considerable decision space and partial observability, which can benefit from methods of action reduction, early termination, sampling strategy [20] and parallel algorithm. (3) Making the trade-off between exploitation and exploration is one of the challenges facing the use of RL algorithms that has been studied by mathematicians for many decades [24]. An exploitation and exploration trade-off depends mainly on the various tree policies with different parameters. Updating the policy parameters increased the strength of MCTS [25]. (4) To guide the search-based algorithm to a good solution, the reward function design is the key to solution evaluation problem [23]. Learning reward functions through deep neural networks has become popular in RL for complex tasks involving goals that are poorly defined or hard to specify [26]. In addition, the reward design avoiding the sparse reward problem [16] or reflecting the optimal reward problem [21] improved the performance of MCTS. To overcome the limitations of the Monte Carlo Tree Search (MCTS) algorithm, which are mainly caused by the complexity and large number of branches in the tree, the paper examines the solutions proposed in points 2, 3, and 4 of the aforementioned list. After point 2, the early termination is done by limiting the time horizon of the simulation rollouts. After point 3, the paper explores the impact of the exploration parameter on the algorithm’s performance, to study the trade-off between exploitation and exploration. After point 4, the MCTS algorithm is guided by several reward functions. However, the study only focuses on two specific actions, so the tree’s sideways growth is not considered. Computer technology can be used for the dynamic simulation of complex mechanical systems, and AI has also attracted much attention and seen rapid progress in multibody system dynamics (MSD). Therefore, reliable and efficient models are crucial in various MSD applications via AI technology. Angeli et al. [27] established a nonlinear map via DL to minimal rigid multibody coordinates with the Kalman filter to speed up the simulations. Peng et al. [28] established a general friction model via DL to determine the contact surface and characterize friction properties. In addition, the dynamics response predictions for rigid MSD [29] and flexible MSD [30] via DL successfully met the research needs for real-time. Although the development of AI in MSD applications is remarkable, little has been done to date to explore the MSD applications with MCTS. In MSD, decision-making processes usually involve setting a control objective and then using optimization techniques to find the control inputs that can either maximize or minimize this objective. The modifications made to MCTS in games can be applied to address decision-making challenges in MSD, such as making the right moves to keep an inverted pendulum upright. Efficient implementation of MSD numerical solutions requires time discretizing a set of continuous ordinary or partial differential equations. The motion of a rigid MSD in 2D or 3D can serve as a series of decision-making problems of the Markov decision process and apply MCTS to solve them. Thus, the discrete action space in MCTS can be naturally added to the dynamic equations due to the discrete time. In this study, we consider the classical control MSD task of stabilizing inverted pendulums using vanilla and modified MCTS to reach the level of automatic drive. By limiting choices to left or right movements in the inverted pendulum search tree, the sideways tree growth challenge is eliminated. Making a balance of exploitation vs. exploration trade-off and manipulating the reward function can improve learning results, which are widely recognized in games and will also be discussed in MSD applications. The main contributions are summarized as follows. (1) This marks the inaugural application of MCTS to multibody applications. While reinforcement learning typically favours along-sighted algorithms in virtual games [1], there is limited work on this concept in mechanical systems. In this mechanical study, the discount parameter incrementally grows from 0 to 1, revealing superior performance by long-sighted agents compared to short-sighted counterparts. (2) Opting for minor exploitation and more exploration is expected to result in significant improvement in control when compared to other trade-off parameter combinations. Typically, maximized exploitation, focusing only on specific previous actions, is too greedy to utilize other chances for success. Conversely, maximizing exploration involves consid- 123
8366 Y. Tang et al. ering both actions simultaneously, creating another opportunity for success. (3) A series of reward functions guiding the MCTS- based controller to maintain the upright position is designed, which significantly improve the control performance of the default constant reward used in the benchmark reinforcement learning cart pole environment [31]. (4) The exponential reward functions perform better than the polynomial reward functions. Among them, the angle penalty and tip displacement penalty were shown to control the multi-inverted pendulum well. (5) The redesigned reward functions improve the control robustness of MCTS. With prolonged simulation time, the vanilla MCTS exhibits diminished control robustness, while the modified MCTS maintains stable performance. The objective of this work is to identify the effects of parameters in the vanilla MCTS via the two inverted pendulum control systems and improve the vanilla MCTS through reward designs. Section2offers a detailed background on building an MCTS, which combines a tree search approach with MC simulations. A modified MCTS algorithm with several frameworks of reward functions is proposed, whose distribution shapes guide the search algorithm towards higher reward regions to control the inverted pendulums upright. The rigid MSD based on semi-recursive formulation is illustrated in Sect.3. The effects of parameters in the vanilla MCTS and the improved performances in the modified MCTS are accordingly demonstrated via two numerical examples in Sect.4. Section5describes the findings and future studies. 2 Monte Carlo tree search in control The MCTS is a decision-making algorithm that combines a tree search approach with Monte Carlo simulations and uses the outcome of these simulations to evaluate states in a look-ahead decision tree. See Fig. 1 for details of such a combination. The Monte Carlo is one of the fundamental RL algorithms used to solve any Markov decision process problem [6]. And the Markov decision process, discussed in Sect. 2.1,isthe logic behind the MCTS. In the field of control, there are two key components that are interrelated: the controller (or agent) and the plant (or environment) being controlled. These terms are often used interchangeably based on the context. In control theory, the terms controller and plant are used to describe the components, while in the context of reinforcement learning, the terms agent and environment are used instead. In Figs.1and 5, we use the terms controller and plant. However, in Fig.2and discussion in the reinforcement learning context, we refer to the agent and environment. 2.1 Markov decision process The Markov decision process is the logic behind the MCTS. Modeling a control task as a Markov decision process is a key concept in RL. In a Markov decision process setting, the RL problem is formulated by the tuple M=(S,A,R,P,γ)[24]. (1) Sis the state space (also called the observation), which contains the information about the environment and the agent at a given moment. (2) Ais the action space, which defines the interactions between the agent and the environment. (3) R(s,a)is the reward function to be learned, which gives a numeric signal of goodness to the moves the agent chooses. (4) P∈[01]is the transition probability distribution function (mostly to be learned), which represents the probability of being in the next state safter the agent performed action ain state s. p=P(s|s,a)is learned from the previous experience for the stochastic control system and typically follows the Boltzmann, uniform, or categorical distribution [10]. While p=P(s,a)=1isforthe deterministic control, such a move will always be chosen and there is no need to learn. The sum of the probabilities across all possible next states is equal to 1, i.e., sP(s|s,a)=1, ∀s∈S, where ∀s∈S represents for any s∈Sholds. (5) γ∈[01]is the discount factor, which adjusts the importance of rewards over time and how much the affections of the future are discounted. A discount rate close to 1, i.e., γ−→ 1, means that the agent is long-sighted and future rewards are given similar weight to immediate rewards optimizing over the long-term. Whereas a low discount rate, i.e., γ−→ 0, means that the agent is short-sighted and leads to preferring only short-term time horizons [10]. 123
Monte Carlo tree search control scheme... 8367 Fig. 1 One-time interval MCTS open-loop control of the plant. At each control time step, the current state of the plant initializes the tree. The plant takes the best-approximated action after the tree is built (typically when the computational budget is exhausted or the allotted time is reached). Internally, the MCTS controller expands the tree by selecting an appropriate node and performing a Monte Carlo simulation starting at the selected node’s state. After the Monte Carlo rollout, the performance measure is returned as a reward. The controller is explained in details in Sect.2.3 and Fig.3 For a state s∈S, the agent takes a control action a∈A, then a reward r=R(s,a)is received, and a next state sis reached in the environment. In RL, sand aappear in pairs, that is (St,At,St+1,At+1,...).The subscript trepresents the steps, and the corresponding reward is recorded as Rt+1. The probability of moving from the current state Stto the next state St+1follows the so-called Markov property. This property says that the probability is independent of the history and regardless of all previous states or actions encountered, P(St+1|St,At)=P(St+1|St,At,St−1, At−1,...,S0,A0). (1) Within a Markov decision process, the current state contains enough information to choose optimal actions to maximize future rewards. However, models require previous experience to predict the next action, such as the autoregressive models. As a result, such models fail to meet the so-called Markov property. Some important terms are introduced below to help understand the algorithms as follows. (1) Cycle – A tuple of state, action, reward, and next state, such as (St,At,Rt+1,St+1), which is the interaction cycle between the agent and the environment. See Fig.2. At each step, the agent observes the environment, picks an action, and then receives a new reward and state. And every step has an opportunity for learning and improving performance. (2) Episode e[1] – An episodic task is a task that has an ending, either because the clock stops or because the agent reaches a terminal state. The episode is a sequence of cycles from the beginning to the end that describes a complete interaction process, such as e:(S0,A0,R1,S1,A1,R2,S2,...,AT−1,RT,ST). (2) Therefore, there is a finite number of steps in an episodic task. Mostly, such interactions go on for several cycles in an episode. In a tree search plan, an agent may take several episodes, numbered as ne, to learn to solve a task, especially in a pure Markov decision process, ne=1. The episode is always the first thing that the agent needs to generate. (3) Search budget n– The maximum search computational cost of given. As in [32], the given search budget is divided into neepisodes as n=neH,(3) where His the total steps in an episode, termed a horizon. The effect of the follow-up of step tcan be summed up as the time-discounted cumulative rewards Gtby γ, termed a discount return. The objective of the agent is to take actions that maximize the expected value of the sum of future discounted rewards Gt(or discounted cumulative rewards) during an episode, which is equal to Gt=Rt+1 +γRt+2 +γ2Rt+3 +···+γT−t−1RT =Rt+1 +γ(Rt+2 +γRt+3 +···+γT−t−2RT) 123
8368 Y. Tang et al. =Rt+1 +γGt+1,(4) where Tis the final step. The agent can be designed to learn mappings from states to actions called policies π(a|s). When the agent follows policy π(a|s)starting from state sto adopt a combination of random variables, each strategy will eventually produce a time-discounted cumulative return Gt. The expectation Eof these cumulative returns is defined as the state-value function or v-function. The state-value function represents the expected return when following policy π(a|s)from state s, which is equal to v(s)=Eπ[Gt|St=s].(5) Substituting Eq. (4) into Eq. (5) results in the statevalue expression of the model-free RL as follows. v(s)=Eπ[Rt+1 +γGt+1|St=s].(6) The Bellman equation for state-value in the Markov decision process is defined as follows [1]. v(s)= a π(a|s) s p(r+γv(s)), ∀s∈S.(7) Notice that the state-value in Eq. (7) is obtained via the transition probability Pwith the knowledge of the environment model, which is used for model-based RL. After evaluating the value of the state in Eq. (6)or Eq. (7), the state-action pairs (s,a)must be evaluated to determine what results will be produced after taking this state. By comparing different actions under the same policy, the best action is selected, and the policies are improved. To evaluate the above-mentioned state-action pairs (s,a), the action-value function, qfunction, or mean reward is defined as the expected return if the agent follows policy π(a|s)after taking action ain state s, q(s,a)=Eπ[Gt|St=s,At=a] =Eπ[Rt+1 +γGt+1|St=s,At=a].(8) The Bellman equation for action-value is defined as [1] q(s,a)= s p(r+γv(s)), ∀s∈S,∀a∈A(s). (9) Eq. (8) and Bellman Eq. (9) are used for model-free RL and model-based RL, respectively. Figure 2shows the differences in the algorithm used in an interaction cycle between the Monte Carlo and MCTS. Substituting Eq. (9) into Eq. (7), one can get the relationship between the v-function and q-function in the model-based RL as follows. v(s)= a π(a|s)q(s,a), ∀s∈S,∀a∈A(s). (10) 2.2 Monte Carlo methods To solve finite Markov decision problems, Dynamic Programming (DP), Monte Carlo (MC) methods, and Temporal Difference (TD) learning are the three fundamental solution approaches [6]. The Monte Carlo methods are used in this study, which are based on the statistical (or large number) principle and require only experience-sample sequences of states, actions, and rewards from actual or simulated interaction with an environment [24]. Therefore, they can be used for direct learning without a model to be learned with the functions of transition probability distribution P.The core idea is that agents constantly interact with the environment to generate a series of historical trajectories and an index of the cumulative return Gtunder a specific state and action in the historical trajectories. The Monte Carlo methods do not bootstrap because their estimations for each state are independent and do not build upon the estimate of any other state [24]. In the Monte Carlo methods, the values of the vand q functions are estimated by, respectively, Vand Q.The estimated V-function for a state sis the mean return for that state, VT(s)=1 N(s) T t=1 Gt=1 N(s)(GT+ T−1 t=1 Gt), (11) where the superscript Trepresents the end step, which is also the end of an episode. Notice that VT(s)is calculated only at the end of an episode because GTin Eq. (11) depends on the end step T. The estimated V- function for the step (T−1)-th is VT−1(s)=1 N(s)−1 T−1 t=1 Gt, which can be submitted into Eq. (11) yields. VT(s)=1 N(s)GT+(N(s)−1)VT−1(s) =VT−1(s)+1 N(s)GT−VT−1(s). (12) 123
Monte Carlo tree search control scheme... 8369 Fig. 2 Algorithm differences of an interaction cycle between Monte Carlo and MCTS–Without the environment model, the agent of Monte Carlo can’t get the distribution of P, and therefore, the Markov decision process tuple is M=(S,A,R,γ). The state-value and action-value are calculated via Eqs. (6)and (8) due to the lack of Pin the model-free RL. For MCTS, the agent learns Pfrom the environment model. Therefore, M=(S,A,R,γ,P). And the state-value and action-value are calculated via Eqs. (7)and(9) Similarly, the estimated Q-function for the stateaction pairs (s,a)is the mean return for that pair. QT(s,a)=1 N(s,a) T t=1 Gt =QT−1(s,a)+1 N(s,a)GT−QT−1(s,a). (13) When Tapproaches infinity, the estimate values of Monte Carlo in Eqs. (11) and (13) will approach the true values of model-free Markov decision process in Eqs. (5) and (8), respectively. lim T→∞ VT(s)=lim T→∞ 1 N(s) T t=1 Gt=Eπ[Gt|St=s] =v(s), (14) and lim T→∞ QT(s,a)=lim T→∞ 1 N(s,a) T t=1 Gt =Eπ[Gt|St=s,At=a]=q(s,a). (15) That is, when T→∞, Monte Carlo methods → model-free Markov decision process. This implicitly regularizes the Monte Carlo methods towards the previous model-free Markov decision process. 2.3 Vanilla Monte Carlo tree search Monte Carlo Tree Search is one of the simulationbased search methods that emerged and became popular in gaming. The MCTS (= Monte Carlo methods + Tree search algorithm) framework develops a selective search tree by repeatedly applying a Monte Carlo evaluation (see Sect. 2.2) at each child (or leaf) node and then uses a tree structure to update and select node values efficiently. Unlike traditional planning and learning algorithms, MCTS does not acquire knowledge from the past, i.e., from steps that have already been done. The main characteristic of the simulation-based search is the strategy to look ahead and plan the future best action based on the results of a large number of simulations. The sample returns are observed between each trajectory’s initial and termination state, and the values estimate the most promising episodes in the search tree. These simulations are performed to forecast the outcomes of possible decisions and plan in time. The core of MCTS is an iterative process divided into four steps. See Fig.3. (1) Selection – In this step, the algorithm begins at the root node and traverses the tree according to the so-called tree policy. The strategy’s main goal is to select the best node to maximize the estimated value and reach a child node. (2) Expansion – Add a single child node to the search tree under the node selected in the previous step, as shown in Fig. 3. (3) Rollout (or simulation) – Unlike games, an application to multibody system dynamics involves realworld physical models. Therefore, in this context, the models of inverted pendulums will be primarily utilized. Based on random Monte Carlo simulations from the added child node, the rollout policy is used with a termination outcome with a specific reward. For example, for the double inverted pendulums, once the cart deviates more than a settled distance from the center of the pole tilt exceeds a predetermined degree, the task will be terminated with a reward of 0. Otherwise, the task gets a reward of 1 from each interaction cycle. In addition, the states visited will not be stored in the lookahead 123
8370 Y. Tang et al. Fig. 3 Tree build scheme in the Monte Carlo Tree Search algorithm. The algorithm is divided into iteration cycles involving four steps (selection, expansion, rollout, and backup). The treebuilding process will stop when the search budget in Eq. (3)is exhausted. For illustration purposes, the scheme depicts an environment of double inverted pendulums on a cart with two discrete actions (moving left and moving right) and three states. However, the MCTS scheme is universal and applies to any environment with discrete actions tree except for the started child node during the rollout. Again, see Fig.3. Future discounted cumulative rewards can be obtained from Eq. (4)as Gt=Rt+1 +γRt+2 +γ2Rt+3 +···+γd−t−1Rd =Rt+1 +γGt+1,0<t<d,(16) where dis the lookahead tree depth and trepresents the t-th interaction cycle in this tree. In addition, the rollout includes the states visited but not stored. (4) Backup (or backpropagation) – After reaching the terminal state in d-th tree depth, the visit count and action-value in Eq. (13) of the current simulation are updated through all nodes up to the root node as Nt(s,a)=Nt−1(s,a)+1,(17) and Qt(s,a)=Qt−1(s,a)+Gt−Qt−1(s,a) Nt(s,a),(18) 123
Monte Carlo tree search control scheme... 8371 as shown in Fig. 3. And each edge (s,a)stores a set of statistics as E(s,a)≡(P(s,a), Q(s,a), N(s,a), R(s,a)),(19) where P(s,a),Q(s,a),N(s,a), and R(s,a)are a transition probability, an action value, a visit count, and a reward, respectively. When the agent does the t-th interaction cycle, for node i, the following set is stored here (Fig.3), Et(Si,Ai) ≡(Pt(Si,Ai), Qt(Si,Ai), Nt(Si,Ai), Rt(Si,Ai)). (20) In addition, the node must be visited several times to ensure the estimate is reliable. The iteration of steps 1–4 in MCTS will continue until the search budget nin Eq. (3) is exhausted. There are two policies in the MCTS; one is the tree policy in the selection step, and the other is the rollout policy in the rollout step. Some of the parameters of the MCTS are shown in Table 1. At each interaction cycle, the agent observes the current state of the environment and selects an action that will cause the environment to move to a new state, i.e., left and right. At the same time, the environment will return a reward to the agent, reflecting the result of the action. 2.4 Tree policy As mentioned in the introduction, there are two challenges facing the tree policy: a sideway growing tree and exploitation vs. exploration trade-off. The former challenge does not exist for the inverted pendulums because only two actions can be chosen here to make the tree grow in-depth. Exploitation and exploration are two aspects that drive the decision during the tree policy, a trade-off representing real-life problem-solving approaches in RL. The starting point for the trade-off investigation is to give the readers a preliminary impression of how the trade-off parameter affects the control performance of the inverted pendulums. This study uses the tree policy of PUCT (Predictor + Upper Confidence with Treebased Search policy) [33] to select an action, which is one of the bandit strategies. For child node i, the PUCT formula can be expressed as follows, πpuct (a|s)=argmax ⎡ ⎢ ⎣Q(Si,Ai) exploitation, greedy +U(Si,Ai) exploration ⎤ ⎥ ⎦. (21) (1) Exploitation: Q(Si,Ai)is the action-value from Eq. (13), representing the exploitation of the visited good paths. (2) Exploration: U(Si,Ai)is the understand level of child node i, which represents the exploration of the unvisited paths. And, U(Si,Ai)=Cpuct P(Si,Ai)aN(s,a) N(Si,Ai)+1, (22) where N(Si,Ai)is the number of child node ihas been visited. aN(s,a)corresponds to the total number of visits done so far and evaluated in the parent node. The state-action pairs in the search tree are edges (s,a), and each node icontains edges (s,a)for all legal actions ∀a∈A(s).Cpuct [9]is a constant exploration parameter determining the level of exploration, which will be discussed in detail in the numerical examples. When Cpuct =0, the PUCT policy degenerates to a pure greedybased policy, e.g., regression tree. The PUCT policy of Eq. (21) initially prefers actions with high transition probability Pand low visit count N,but asymptotically prefers actions with high actionvalue Q[8]. The PUCT formula strengthens the convergence of known reward nodes and encourages the exploration of nodes that have not been visited. In the stochastic control for the uniformly distributed case, P(Si,Ai)=P(s|s,a)=1 anc(s,a),(23) where ncis the sum of the number of children for the parent. The environment of an inverted pendulum has only two actions. Exploration involves considering these two actions simultaneously, and their choices are random, discovering new paths with the potential for success. Pure exploitation (or greedy-based) policy lacks exploration and only considers the good existing actions, which is too greedy to utilize other chances for success. As the tree is transversed, the balance between exploitation and exploration must be retained to obtain the maximum value of the PUCT formula, i.e., Eq. (21). 2.5 Reward variants in Monte Carlo tree search The reward function is developed to evaluate which actions are worth doing, which is vital to achieving 123
8378 Y. Tang et al. Fig. 8 Simulation results for single inverted pendulum on cart environment when Ts=200 and γ=0.85. (Default case A in Table 6) corresponding control results are shown online [45]. Analysis of the presented figures reveals the following results. (1) The results in Fig.8present the control performance when Cpuct =0, representing the agent using a purely greedy policy. As pointed out in Sect.2.4, the pure greedy-based policy lacks exploration and only considers the good existing actions, which is too greedy to utilize other chances for success. All the numerical results in [45] show similar failures for a single/double inverted pendulum on the cart, no matter the discount parameter’s value. This indicates that exceptionally poor performance results from the MCTS agent only learning from the previous experience with no exploration involved. (2) The plots for Cpuct =2 show a significant area of high control effectiveness in the mean plot. This area begins for budgets of about 1000 and horizon values of 10 to 15. When increasing the value of Cpuct, such as from 4, 8, 16,32, 64, 128, 256, 512 to 1024, the results are getting worse [45]. The plot for Cpuct =1024 (see Fig. 9) reveals the pattern where the areas of high control effectiveness are directly adjacent to areas of low control effectiveness. This is achieved for low standard deviation. The adjacent areas of low and high control effectiveness often differ by just one step in the tree-building process (Fig. 3). While the results (as shown for Cpuct =1024) allow for finding good control results with a reasonably small budget, they also reveal the large sensitivity to parameter selection. Larger Cpuct values also seem to require larger γto control the system effectively. (3) An increase in horizon typically requires a larger budget, which is expected because more simulations are required to build a tree of the same size when a smaller horizon is used. However, the standard deviation plot shows that some combinations of parameters result in worse performance than their neighbors. A similar result pattern was observed for γfrom 0.8upto1.0 and for Cpuct up to 64. Moving away from optimal settings results in a smaller area of a high mean Tsand a noisier standard deviation. (4) Significantly improvements in the control performance can be found when comparing proposed redesigned reward functions (shown in Sects. 4.2.2 and 4.2.3) to default constant reward. See results in Figs.9and 11. The success rate Sincreases from the 30.3% for case A to 78.0% for the modified case Q. The improvement is more remarkable for longer simulations with Ts=500, where Sis just 1.3% for case B and 66.4% for modified case U. These improvements can also be found when using other redesigned reward functions. More results can be found in [45]. These results validate the effectiveness of the proposed reward functions. (5) A poor control robustness can be found when using the default constant reward by comparing the Figs.9and 10. The control performance drops sharply with the same set of parameters when increasing the control time, and almost no combination of parameters can provide acceptable 123
Monte Carlo tree search control scheme... 8379 Fig. 9 Simulation results for single inverted pendulum on cart environment when Ts=200 and γ=0.85. (Default case A in Table 6) results. However, significant improvements in the control robustness can be found when using the redesigned reward functions by comparing Figs.11 and 12. Similar significant improvements can also be found using the polynomial reward functions (Eqs. (31) and (32)) and exponential reward functions (Eqs. (33) and (34)). Again, more results can be found in [45]. (6) Comparing all the generated results online [45] whose parameters are listed in Table 6, the exponential reward function of angle penalty when w=1 and pθ=0.25 (cases Q and U) shows the best con- 123
8380 Y. Tang et al. Fig. 10 Simulation results for single inverted pendulum on cart environment when Ts=500 and γ=0.85. (Default case B in Table 6) trol effectiveness for both Ts=200 and Ts=500 in general. For example, the results of Q (angle penalty) show better performance than results of AD (angle penalty and tip displacement penalty) when Cpuct =2,4 and 8. Considering only the cart displacement penalty (case C) makes the results worse than the default one (case A) when Ts=200. The reward function with a combination of angle and cart displacement penalties performs not as well as the one that only considers the angle penalty, such as case Q and cases V, W, X, Y, Z, and AA. 123
Monte Carlo tree search control scheme... 8381 Fig. 11 Simulation results for single inverted pendulum on cart environment with modified reward function when Ts=200 and γ=0.85. (Modified case Q in Table 6) 123
8382 Y. Tang et al. Fig. 12 Simulation results for single inverted pendulum on cart environment with modified reward function when Ts=500 and γ=0.85. (Modified case U in Table 6) 123
Monte Carlo tree search control scheme... 8383 Fig. 13 Simulation results for double inverted pendulum on cart environment with angle penalty reward when Ts=200 and γ=1. (Modified case G in Table 7) 123
8384 Y. Tang et al. Fig. 14 Simulation results for double inverted pendulum on cart environment with angle penalty reward when Ts=500 and γ=1. (Modified case I in Table 7) 123
Monte Carlo tree search control scheme... 8385 Fig. 15 Simulation results for double inverted pendulum on cart environment with tip drop reward when Ts=200 and γ=1. (Modified case Q in Table 7) 123
8386 Y. Tang et al. Fig. 16 Simulation results for double inverted pendulum on cart environment with tip drop reward when Ts=500 and γ=1. (Modified case T in Table 7) 123
Monte Carlo tree search control scheme... 8387 Table 6 Test cases for the single pendulum ID Name Tmax sFigure Equation wpθor pypxqθor qyqx A Constant 200 8and 9(30)–– –– – B Constant 500 10 (30)–– –– – C Linear to x200 – (31)0– 1– – D Linear to θ1200 – (31)11 –– – E Linear to θ1and xI 200 – (31)0.51 1– – F Linear to θ1and xII 200 – (31)0.751 1– – G Linear to θ1and xIII 200 – (31)0.251 1– – H Linear to θ1and xII 500 – (31)0.751 1– – I Quadratic to θ1200 – (31)12 –– – J Quadratic to x200 – (31)0– 2– – K Quadratic to θ1and x200 – (31)0.752 2– – L Square root to θ1200 – (31)10.5 –– – M Polynomial to θ1and x200 – (31)0.752 6– – N Linear to yeand xeI 200 – (32)0.51 1– – O Linear to yeand xeII 200 – (32)0.751 1– – P Exponential to θ1I 200 – (33)1– –5/12 – Q Exponential to θ1II 200 11 (33) 1 – – 0.25 – R Exponential to θ1III 200 – (33)1– –2/3– S Exponential to θ1IV 200 – (33)1– –1/6– T Exponential to θ1V 200 – (33)1– –1/12 – U Exponential to θ1II 500 12 (33) 1 – – 0.25 – V Exponential to θ1and xI 200 – (33) 0.75 – – 0.25 0.25 W Exponential to θ1and xII 200 – (33) 0.75 – – 0.25 0.2 X Exponential to θ1and xIII 200 – (33) 0.75 – – 0.25 0.3 Y Exponential to θ1and xIV 200 – (33) 0.85 – – 0.25 0.25 Z Exponential to θ1and xV 200 – (33) 0.75 – – 0.25 0.1 AA Exponential to θ1and xVI 200 – (33) 0.75 – – 0.25 0.4 AB Exponential to θ1and xIV 500 – (33) 0.85 – – 0.25 0.25 AC Exponential to θ1and xVII 500 – (33) 0.95 – – 0.25 0.25 AD Exponential to yeI 200 – (34) 1 – – 0.25 – AE Exponential to yeII 200 – (34)1– –0.1– AF Exponential to yeIII 200 – (34)1– –0.4– AG Exponential to yeII 500 – (34)1– –0.1– Similar results also can be found when Ts=500, such as in case U and cases AB, and AC. 4.3.2 Double inverted pendulum The results for the double inverted pendulum on the cart (see Figs.13,14,15 and 16) show similar behavior to their single pendulum counterpart when the large area of the good control effectiveness is achieved. However, a larger budget and horizon values are needed to stabilize the system due to the more considerable complexity of the dynamics of the double-inverted pendulum system than the single one. This translates to far higher computational costs. In addition, only the redesigned reward functions with exponential form are studied in the double-inverted pendulum, as they exhibit the best control performance in the single-inverted pendulum, as stated in the last result in Sect. 4.3.1. Table 7 123