Receding Horizon Inverse Reinforcement Learning
Abstract
Inverse reinforcement learning (IRL) seeks to infer a cost function that explains the underlying goals and preferences of expert demonstrations.
This paper presents receding-horizon inverse reinforcement learning (RHIRL), an IRL algorithm for high-dimensional, noisy, continuous systems with black-box dynamic models.
RHIRL addresses two key challenges of IRL: scalability and robustness.
To handle high-dimensional continuous systems, RHIRL matches the induced optimal trajectories with expert demonstrations locally in a receding horizon manner and “stitches” together the local solutions to learn the cost; it thereby avoids the “curse of dimensionality”.
This contrasts with earlier algorithms that match with expert demonstrations globally over the entire high-dimensional state space.
To be robust against imperfect expert demonstrations and control noise, RHIRL learns a state-dependent cost function “disentangled” from system dynamics under mild conditions.
Experiments on benchmark tasks show that RHIRL outperforms several leading IRL algorithms in most instances.
We also prove that the cumulative error of RHIRL grows linearly with the task duration.
Introduction
Reinforcement learning (RL) has made exciting progress in a range of complex tasks, including real-time game playing [24], visuo-motor control of robots [35] and many other works.
The success, however, often hinges on a carefully crafted cost function [17, 25], which is a major impediment to the wide adoption of RL in practice.
Inverse reinforcement learning (IRL) [26] addresses this need by learning a cost function that explains the underlying goals and preferences of expert demonstrations.
This work focuses on two key challenges in IRL, scalability and robustness .
Classic IRL algorithms commonly consist of two nested loops.
The inner loop approximates the optimal control policy for a hypothesized cost function, while the outer loop updates the cost function by comparing the behavior of the induced policy with expert demonstrations.
The inner loop must solve the (forward) reinforcement learning or optimal control problem, which is in itself a challenge for complex high-dimensional systems.
Many interesting ideas have been proposed for
IRL, including, e.g., maximum entropy learning [39, 41], guided cost learning [7], and adversarial learning [8].
See Figure 1 for illustrations.
They try to match a globally optimal approximate policy with expert demonstrations over the entire system state space or a sampled approximation of it.
This is impractical for high-dimensional continuous systems and is a fundamental impediment to scalability.
Like RL, IRL suffers from the same “curse of dimensionality”.
To scale up, receding-horizon IRL (RHIRL) computes locally optimal policies with receding horizons rather than a globally optimal policy and then matches them with expert demonstrations locally in succession (Figure 1 d ).
The local approximation and matching substantially mitigate the impact of high-dimensional space and improve the sample efficiency of RHIRL, at the cost of a local rather than a global solution.
So
RHIRL trades off optimality for scalability and provides an alternative to current approaches.
[Figure]
Another important concern of IRL is noise in expert demonstrations and system control.
Human experts may be imperfect for various reasons and provide good, but still suboptimal demonstrations.
Further, the system may fail to execute the commanded actions accurately because of control noise.
We want to learn a cost function that captures the expert’s intended actions rather than the imperfectly executed actions.
While earlier work has investigated the question of learning from sub-optimal or failed demonstrations [3, 31, 38], there is a subtle, but critical difference between (i) demonstrations intended to be suboptimal and (ii) optimal demonstrations corrupted by noise.
The existing work [3, 31, 38] addresses (i); RHIRL addresses (ii).
To learn the true intentions from the noise corrupted demonstrations, RHIRL relies on a simplifying assumption: the cost function is linearly separable with two components, one state-dependent and one control-dependent.
Many interesting systems in practice satisfy the assumption, at least, approximately [28].
RHIRL then learns the state-dependent cost component, which is disentangled from the system dynamics [8] and agnostic to noise.
Related Work
IRL can be viewed as an indirect approach to imitation learning.
It learns a cost function, which induces an optimal policy whose behavior matches with expert demonstrations.
In contrast, behavior cloning (BC) is a direct approach.
It assumes independence among all demonstrated state-action pairs and learns a policy that maps states to actions through supervised learning of state-action pairs from expert demonstrations.
The simplicity of BC is appealing.
However, it typically requires large amounts of data to learn well and suffers from covariate shift [30].
IRL is more data-efficient.
Further, it produces a cost function, which explains the expert demonstrations and potentially transfers to other systems with different dynamics.
These benefits, however, come at the expense of greater computational complexity.
Classic IRL algorithms learn a cost function iteratively in a double-loop: the outer loop updates a hypothesized cost function, and the inner loop solves the forward RL problem for an optimal policy and matches it with expert demonstrations.
Various methods have been proposed [1, 7, 39, 41], but they all seek a globally optimal solution over the entire state space (Figure 1 a ) [39, 41] or the entire task duration (Figure 1 b ) [1, 7].
As a result, they face significant challenges in scalability and must make simplifications, such as locally linear dynamics [7].
Recent methods use the generative adversarial network (GAN) [10] to learn a discriminator that differentiates between the state or state-action distribution induced by the learned cost and that from expert demonstrations [5, 8, 9, 13, 14, 18, 21, 27, 29].
We view this global matching as a major obstacle to scalability.
In addition, GAN training is challenging and faces difficulties with convergence.
RHIRL stands in between BC and the aforementioned IRL algorithms by trading off optimality for scalability.
BC performs local matching at each demonstrated state-action pair, treating all of them independently.
Most existing IRL algorithms perform global matching over the entire state space or sampled trajectories from it.
RHIRL follows the standard IRL setup.
To tackle the challenge of scalability for high-dimensional continuous systems, RHIRL borrows ideas from receding horizon control (RHC) [19].
It solves for locally optimal control sequences with receding horizons and learns the cost function by “stitching” together a series of locally optimal solutions to match the global state distribution of expert demonstrations (Figure 1 d ).
Earlier work has explored the idea of RHC in IRL [23], but relies on handcrafted reward features and is limited to discrete, low-dimensional tasks.
More recent work learns reward features automatically [20].
However, it focuses on lane navigation for autonomous driving, exploting a known analytic model of dynamics and noise-free, perfect expert demonstrations.
RHIRL aims at general high-dimensional continuous tasks with noisey expert demonstrations.
Another challenge to IRL is suboptimal expert demonstrations and system control noise.
Several methods learn an auxiliary score or ranking to reweigh the demonstrations, in order to approximate the underlying optimal expert distribution [4, 5, 38].
RHIRL does not attempt to reconstruct the optimal expert demonstrations.
It explicitly models the human errors in control actions as additive
Gaussian noise and matches the noisy control with expert demonstrations, in order to learn from the intended, rather than the executed expert actions.
Modelling the human error as additive Gaussian noise is a natural choice technically [22, 34, 40], but compromises on realism.
Human errors in sequential decision making may admit other structural regularities, as a result of planning, resource constraints, uncertainty, or bounded rationality[15].
Studying the specific forms of human errors in the IRL context requires insights beyond the scope of our current work, but forms a promising direction for future investigation.
Receding Horizon Inverse Reinforcement Learning 3.1 Overview
Consider a continuous dynamical system:
[Equation]
where x t ∈ R n is the state, v t ∈ R m is the control at time t , and the initial system state at t =follows a distribution µ .
To account for noise in expert demonstrations, we assume that v t is a random variable following the Gaussian distribution
N ( v t | u t , Σ) , with mean u t and covariance Σ .
We can control u t directly, but not v t , because of noise.
The state-transition function f captures the system dynamics.
RHIRL represents f as a black-box simulator and does not require its analytic form.
Thus, we can accommodate arbitrary complex nonlinear dynamics.
To simplify the presentation, we assume that the system dynamics is deterministic.
We sketch the extension to stochastic dynamics at the end of the section, the full proof is given in Appendix C.
In RL, we are given a cost function and want to find a control policy that minimizes the expected total cost over time under the dynamical system.
In IRL, we are not given the cost function, but instead, a set D of expert demonstrations.
Each demonstration is a trajectory of states visited by the expert over time:
τ = ( x 0 , x 1 , x 2 , ..., x T − 1 ) for a duration of T steps.
We assume that the expert chooses the actions to minimize an unknown cost function and want to recover this cost from the demonstrations.
Formally, suppose that the cost function is parameterized by θ .
RHIRL aims to learn a cost function that minimizes the loss L ( θ ; D ) , which measures the difference between the demonstration trajectories and the optimal control policy induced by the cost function with parameters θ .
RHIRL performs this minimization iteratively, using the gradient ∂ L /∂θ to update θ .
In iteration t , let x t be the system state at time t and D t be the set of expert sub-trajectories starting at time t and having a duration of maximum K steps.
We use the current cost to perform receding horizon control (RHC) at x t , with time horizon K , and then update the cost by comparing the resulting state trajectory distribution with the demonstrations in D t .
Earlier IRL work requires the simulator to reset to the states from the initial state distribution [1, 6, 7, 8, 13, 18].
To perform receding horizon optimization,
RHIRL requires a simulator to reset to the initial state x t for the local control sequence optimization at each time step t = 0 , ...
T − 1 , a common setting in optimal control (e.g., [36, 37, 20]).
See
Algorithm 1 for a sketch.
First, sample M control sequences, each of length K (line 6).
We assume that the covariance Σ is known.
If it is unknown, we set it to be identity by default.
For our experiment results reported in Table 1 and Table 2, Σ is unknown and is approximated by a constant factor of the identity matrix (grid search is performed to determine this constant factor).
We show through experiments that the learned cost function is robust over different noise settings (Section 4.3).
Next, we apply model-predictive path integral (MPPI) control [37] at x t .
MPPI provides an analytic solution for the optimal control sequence distribution and the associated state sequence distribution, which allow us to estimate the gradient
∂ L /∂θ efficiently through importance sampling (lines 7–8) and update cost function parameters θ (line 9).
Finally, we execute the computed optimal control (line 10–12) and update the mean control input for the next iteration (line 13).
We would like to emphasize that we only use the simulator to sample rollouts and evaluate the current cost function.
Fixed expert demonstrations D are given upfront.
Unlike DAgger, we do not query the expert online during training.
Our challenge is to uncover a cost function that captures the expert’s intended controls ( u 0 , u 1 , . .
, u T − 1 ) , even though they were not directly observed, because of noise, and do so in a scalable and robust manner for high-dimensional, noisy systems.
We develop three ideas: structuring the cost function, matching locally with expert demonstrations, and efficient computation of the gradient ∂ L /∂θ , which are described next.
3.2 Robust Cost Functions
To learn a cost function robust against noise, we make a simplifying assumption that linearly separates the one-step cost into two components: a state cost g ( x ; θ ) parameterized by θ and a quadratic control cost u T Σ − 1 u .
Despite the simplification, this cost function models a wide variety of interesting systems in practice [28].
It allows RHIRL to learn a state cost g ( x ; θ ) , independent of control noise (Section 3.4), and thus generalize over different noise distributions (Section 4.3).
Suppose that V = ( v 0 , v 1 , . .
. , v K − 1 ) is a control sequence of length K , conditioned on the input
U =
( u 0 , u 1 , . . .
, u K − 1 ) .
We apply V to the dynamical system in (1) with start state x 0 and obtain a state sequence τ = ( x 0 , x 1 , . . .
, x K ) with x k = f
( x k − 1 , v k − 1 ) for k = 1 , 2 , . . .
, K .
Define the total cost of V as
[Equation]
where λ ≥ 0 is a constant weighting the relative importance between the state and control costs.
For convenience, define also the total state cost of V as
[Equation]
While S is defined in terms of the control sequence V , it only depends on the corresponding state trajectory τ .
This is very useful, as the training data contains state and not control sequences explicitly.
3.3 Local Control Sequence Matching
To minimize the loss L , each iteration of RHIRL applies RHC with time horizon K under the current cost parameters θ and computes locally optimal control sequences of length K .
In contrast, classic
IRL algorithms, such as MaxEnt [41], perform global optimization over the entire task duration T in the inner loop.
While RHC sacrifices global optimality, it is much more scalable and enables RHIRL to handle high-dimensional continuous systems.
We use the hyperparameter K to trade off optimality and scalability.
Specifically, we use MPPI [37] to solve for an optimal control sequence distribution at the current start state x t in iteration t .
The main result of MPPI suggests that the optimal control sequence distribution
Q minimizes the “free energy” of the dynamical system and this free energy can be calculated from the cost of the state trajectory under Q .
Mathematically, the probability density p Q ( V ∗ ) can be expressed as a function of the state cost S ( V, x t ; θ ) , with respect to a Gaussian “base” distribution
B ( U B , Σ) that depends on the control cost:
[Equation]
where Z is the partition function.
For the quadratic control cost in (2), we have U B = (0 , 0 , . . . )
Intuitively, the expression in (4) says that the probability density of V ∗ is the product of two factors, one penalizing high control cost and one penalizing high state cost.
So controls with large values or resulting in high-cost states occur with probability exponentially small.
Equation (4) provides the optimal control sequence distribution under the current cost.
Suppose that the control sequences for expert demonstrations D t follow a distribution E .
We define the loss
L ( θ ; D t , x t ) as the KL-divergence between the two distributions:
[Equation]
which RHIRL seeks to minimize in each iteration.
While the loss L is defined in terms of control sequence distributions, the expert demonstrations D provide state information and not control information.
However, each control sequence V induces a corresponding state sequence τ for a given start state x 0 , and τ determines the cost of V according to (2).
We show in the next subsection that ∂ L /∂θ can be computed efficiently using only state information from D .
This makes RHIRL appealing for learning tasks in which control labels are difficult or impossible to acquire.
3.4 Gradient Optimization
To simplify notations, we remove the explicit dependency on x t and D t and assume that in iteration t of RHIRL, all control sequences are applied with x t as the start state and expert demonstrations come from D t .
We have
[Equation]
The first line follows directly from the definition, and the derivation for the second line is available in
Appendix A.
We estimate the two integrals in (6) through sampling.
For the first integral, we can use the expert demonstrations as samples.
For the second integral, we cannot sample p Q directly, as the optimal control distribution Q is unknown in advance.
Instead, we sample from a known Gaussian distribution with density p ( V | U, Σ) and apply importance sampling so that
[Equation]
The importance weight w ( V ) is given by
[Equation]
To simplify the first ratio in (8), we substitute in the expression for p Q from (4):
[Equation]
We then simplify the second ratio, as both are Gaussian distributions with the same covariance matrix Σ :
[Equation]
where u k and v k , k = 0 , 1 , . .
, K − 1 are the mean controls and the sampled controls from p ( V | U, Σ) , respectively.
Similarly, u B k , k = 0 , 1 , . . .
, K − 1 are the mean controls for the base distribution, and they are all 0 in our case.
Substituting (9) and (10) into (8), we have
[Equation]
For each sampled control sequence V , we evaluate the expression in (11) and normalize over all samples to obtain w ( V ) .
To summarize, we estimate ∂ L /∂θ through sampling:
[Equation]
where V i , i = 1 , . . .
, N are the control sequences for the expert demonstrations in D t and V j , j = 1 , 2 , . . .
, M are the sampled control sequences.
Equation (12) connects ∂ L /∂θ with ∂S/∂θ .
The state cost function S is represented as a shallow neural network, and its derivative can be obtained easily through back-propagation.
To evaluate ∂ ∂θ S ( V i , x t ; θ ) , we do not actually use the expert control sequences, as they are unknown.
We use the corresponding state trajectories in D t directly, as the state cost depends only on the visited states.
See equation (3).
Finally, we approximate the optimal mean control sequence according to (7):
[Equation]
The first element in the control sequence U is the chosen control for the current time step t .
We remove the first element from U and append zero at the end.
The new control sequence is then used as the mean for the sampling distribution in the next iteration.
3.5 Analysis
Since RHIRL performs local optimization sequentially over many steps, one main concern is error accumulation over time.
For example, standard behavior cloning has one-step error ϵ and cumulative
error O ( T 2 ϵ ) over T steps, because of covariate shift [30].
The DAgger algorithm reduces the error to O ( Tϵ ) by querying the expert repeatedly during online learning [30].
We prove a similar result for RHIRL, which uses offline expert demonstrations only.
In iteration t of RHIRL, let p E ( V t | x t ) be the K -step expert demonstration distribution and p Q ( V t
| U B , Σ , x t ; θ ) be the computed K -step optimal control distribution for some fixed cost parameters θ .
RHIRL minimizes the KL-divergence between these two distributions in each iteration.
Let p E ( x ) be the state marginal distribution of expert demonstrations and p RHC ( x ; θ ) be the state marginal distribution of the computed RHC policy under θ over the entire task duration T .
Intuitively, we want the control policy under the learned cost to visit states similar to those of expert demonstrations in distribution.
In other words, p RHC ( x ; θ ) and p E ( x ) are close.
Theorem 3.1.
If D KL (cid:0) p E ( V t | x t ) ∥ p Q ( V t | U B , Σ , x t ; θ ) (cid:1) < ϵ for all t = 0 , 1 , ..., T − 1 , then
D TV ( p E ( x ) , p RHC ( x ; θ )) <
T (cid:112) ϵ/ 2 .
The theorem says that RHIRL’s cumulative error, measured in total variation distance D TV between p E ( x ) and p RHC ( x ; θ ) , grows linearly with T .
The proof consists of three steps.
First, in each iteration t , if the KL-divergence between two control sequence distributions are bounded by ϵ , so is the
KL-divergence between the two corresponding state distributions induced by control sequences.
Next, we show that the KL-divergence between the state distributions over two successive time steps are bounded by the same ϵ .
Finally, we switch from KL-divergence to total variation distance and apply the triangle inequality to obtain the final result.
Note that our local optimization’s objective is defined in KL divergence, while the final error bound is in TV distance.
We switch the distance measures to get the best from both.
Minimizing the KL divergence leads to strong local optimization result, but KL itself is not a proper metric.
Therefore, we further bound the KL divergence by TV distance to obtain a proper metric bound for the final result.
The full proof is given in Appendix B. Since
Pendulum-v
LunarLander-v
Hopper-v
Walker2d-v
Ant-v
CarRacing-v |S| : 3-D 8-D 11-D 17-D 111-D 96 × 96 (image) |A| : 1-D 2-D 3-D 6-D 8-D 3-D T :
RHC performs local optimization in each iteration, we cannot guarantee global optimality.
However, the theorem indicates that unlike standard behavior cloning, the cumulative error of RHIRL grows linearly and not quadratically in T .
This shows one advantage of IRL over behavior cloning from the theoretical angle.
Given a control policy V with the resulting state marginal distribution p V ( x ) , we can calculate the expected total cost of V by integrating the one-step cost over p V .
Now suppose that the one-step cost is bounded.
Theorem 3.1 then implies that the regret in total cost, compared with the expert policy, also grows linearly in T .
3.6 Extension to Stochastic Dynamics
Suppose that the system dynamics is stochastic: x t +1 = f
( x t , v t , ω t ) , where ω t is a random variable that models the independent system noise.
RHIRL still applies, with modifications.
We redefine the total cost functions
˜ J ( V, x 0 ; θ ) and ˜ S
( V, x 0 ; θ ) by taking expectation over the system noise distribution.
When calculating the importance weight ˜ w ( V ) in (11), we sample over the noise distribution to estimate the expected total state cost.
Finally, we may need more samples when estimating the gradient in (12), because of the increased variance due to the system noise.
The full derivation of the extension to stochastic dynamics is given in Appendix C.
The experiments in the current work all have deterministic dynamics.
We leave experiments with the extension to future work.
Experiments
We investigate two main questions.
Does RHIRL scale up to high-dimensional continuous control tasks?
Does RHIRL learn a robust cost function under noise?
4.1 Setup
We compare RHIRL with two leading IRL algorithms, namely AIRL [8] and f -IRL [27], and one imitation learning algorithm, GAIL [13].
In particular, f -IRL is a recent algorithm that achieves leading performance on high-dimensional control tasks.
We use the implementation of AIRL,
GAIL, and f -IRL from the f -IRL’s official repository along with the reported hyperparameters [27], whenever possible.
We also perform hyperparameter search on a grid to optimize the performance of every method on every task.
The specific hyperparameter settings used are reported in Appendix D.2.
Our benchmark set consists of six continuous control tasks (Figure 2) from OpenAI Gym [2], with increasing sizes of state and action spaces.
For the most complex task, CarRacing, the input consists of 96 × 96 raw images, resulting in an enormous state space that poses great challenges [11].
To our knowledge, RHIRL is the first few IRL algorithms to attempt such a high-dimensional space.
For fair comparison, we customize all tasks to the fixed task horizon settings (Figure 2.
See Appendix D.2 for details on task parameter settings.
We use WorldModel [11] to generate expert demonstration data for CarRacing and use SAC [12] for the other tasks.
We add Gaussian noise to the input controls and collect expert demonstrations at different control noise levels.
The covariance of the control noise is unknown to all methods, including, in particular, RHIRL.
[Figure]
To measure the performance of the learned cost function and policy, we score its induced optimal policy using the ground-truth cost function.
For ease of comparison with the literature, we use negated cost values,
i
[Table]
e., rewards, in all reported results.
Higher values indicate better performance.
Each experiment is repeated 10 times to estimate the performance variance.
4.2 Scalability
[Table]
We compare RHIRL with other methods, first in noise-free environments (Figure 4) and then with increasing noise levels (Table 1).
Figure 4 shows the learning curve of each methods in noise-free environments.
Overall,
RHIRL converges faster and achieves higher return, especially for tasks with higher state space dimensions.
This improved performance suggests that the benefit of local optimization adopted by RHIRL outweighs its potential limitations.
Table 1 shows the final performance of all methods at various noise levels.
RHIRL clearly outperforms AIRL and
GAIL in all experiments.
So we focus our discussion on comparison with f -IRL.
In noise-free environments, RHIRL and f -IRL perform comparably on most tasks.
On CarRacing, the most challenging task, RHIRL performs much better.
RHIRL manages to learn the critical driving behaviors illustrated in Figure 3, despite the high-dimensional image input.
However, RHIRL does not manage to learn to drive fast enough.
That is the main reason why it under-performs the expert.
In comparison, f -IRL only learns to follow a straight lane after a large number of environment steps, and still fails to make a sharp turn after 3 .
× 10 7 environment steps.
In the noisy environments, the advantage of RHIRL over f -IRL is more pronounced even on some of the low-dimensional tasks, because RHIRL accounts for the control noise explicitly in the cost function.
4.3 Robustness
[Table]
Next we evaluate RHIRL and other methods for robustness under noise.
A robust cost function encodes the expert’s true intent.
It is expected to yield consistent performance over different noise levels, regardless of noise in expert demonstrations.
For each task, a cost function is learned in a noise-free environment and is then used to re-optimize a policy in the corresponding noisy environments.
Specifically for GAIL, since it learns a policy and does not recover the associated cost function, we directly apply the learned policy in noisy environments.
Table 2 shows that noise causes performance degradation in all methods.
However, RHIRL is more robust in comparison.
For simple tasks, Pendulum and Lunarlander, RHIRL and fIRL perform consistently well across different noise levels, while GAIL and
AIRL fail to maintain their good performance, when the noise level increases.
For the more challenging tasks, Hopper and Walker, RHIRL’s performance degrades mildly, and fIRL suffers more significant performance degradation.
It is worth noting that the expert demonstrations used to train the transferred cost function are from the perfect system.
Therefore, some expert actions and states may no longer be optimal or feasible in a highly noisy environment.
Moreover, the cost function trained in the perfect system cannot reason about the long-term consequences of an action in a high noise environment.
Therefore, it is challenging for the learned cost function to be robust to a highly noisy environment, as capturing the true intention of the expert is difficult.
4.4 Effect of Receding Horizon K
RHIRL uses the receding horizon K to trade off optimality and efficiency.
We hope to ablate the effect of K on
Hopper-v2 to show how different K s affect the final performance and sample complexity.
The task horizon for
Hopper-v2 is 1000 steps, i.e. T = 1000 .
We run RHIRL with the receding horizon K ∈ { 5 , 20 , 100 } .
The results are illustrated in Figure 5.
When K is small, RHIRL improves its performance quickly but converges to the suboptimal solution.
For K = 5 , RHIRL’s performance shoots up after the first few iterations to 1000 , then it quickly converges to a final score of 1100 .
When K increases, though the performance improves slightly slower than K = 5 , it can continue to learn and reach a score of 3071 .
At K = 20 , it takes fewer than 1 e 6 env steps to stabilize to a score greater than 3000 .
However, when K is too large, the learning becomes much slower.
When K = 100 , it takes more than 1 e 7 env steps to stabilize to a score larger than 3000 , which is 10 times more than when K = 20 .
On the other hand,
K = 100 can achieve a final score of 3083 , which is slightly more than that of K = 20 .
This ablation study shows that our receding horizon K can tradeoff optimality and efficiency: using a smaller K allows us to learn faster at the expense of a sub-optimal solution, while using a large K may make the learning inefficient.
Seeking a suitable K can balance the requirement for optimality and efficiency.
Conclusion
RHIRL is a scalable and robust IRL algorithm for high-dimensional, noisy, continuous systems.
Our experiments show that RHIRL outperforms several leading IRL algorithms on multiple benchmark tasks, especially when expert demonstrations are noisy.
RHIRL’s choice of local rather than global optimization is an important issue that deserves further investigation.
Overall, we view this as an interesting trade-off between scalability and optimality.
While this trade-off is well known in reinforcement learning, optimal control, and general optimization problems, it is mostly unexplored in IRL.
Further, local optimization may tie the learned cost with the optimizer.
It would be interesting to examine whether the learned cost transfers easily to other domains with different optimizers.
We are keen to investigate these important issues and their implications to IRL as our next step.
Acknowledgments This research is supported in part by the Agency of Science, Technology and
Research, Singapore, through the National Robotics Program (Grant No. 192 25 00054), the National
Research Foundation (NRF), Singapore and DSO National Laboratories under the AI Singapore
Program (AISG Award
No: AISG2-RP-2020-016), and the National University of Singapore (AcRF grant A-0008071-00-00).
Any opinions, findings and conclusions or recommendations expressed in this material are those of the authors and do not reflect the views of NRF Singapore.
Checklist
The checklist follows the references.
Please read the checklist guidelines carefully for information on how to answer these questions.
For each question, change the default [TODO] to [Yes] , [No] , or [N/A] .
You are strongly encouraged to include a justification to your answer , either by referencing the appropriate section of your paper or providing a brief inline description.
For example:
• Did you include the license to the code and datasets?
[Yes] See Section ?? .
• Did you include the license to the code and datasets?
[No] The code and the data are proprietary.
• Did you include the license to the code and datasets?
[N/A]
Please do not modify the questions and only use the provided macros for your answers.
Note that the
Checklist section does not count towards the page limit.
In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
For all authors... (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope?
[Yes] (b) Did you describe the limitations of your work?
[Yes] See Section(c)
Did you discuss any potential negative societal impacts of your work?
[N/A] (d) Have you read the ethics review guidelines and ensured that your paper conforms to them?
[Yes] 2.
If you are including theoretical results... (a) Did you state the full set of assumptions of all theoretical results?
[Yes] (b) Did you include complete proofs of all theoretical results?
[Yes] See Appendix 3.
If you ran experiments... (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
[Yes] , code is included in the supplementary material.
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
[Yes] (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[Yes] (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
[Yes] 4.
If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... (a) If your work uses existing assets, did you cite the creators?
[N/A] (b) Did you mention the license of the assets?
[N/A] (c) Did you include any new assets either in the supplemental material or as a URL?
[N/A] (d) Did you discuss whether
and how consent was obtained from people whose data you’re using/curating?
[N/A] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
[N/A] 5.
If you used crowdsourcing or conducted research with human subjects... (a) Did you include the full text of instructions given to participants and screenshots, if applicable?
[N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
[N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]
A Gradient Derivation
This section derives the gradient ∂ L ∂θ in equation (12) in full details.
Recall L is defined as:
[Equation]
Firstly, we substitute L in ∂ L ∂θ and rewrite log p E
[Equation]
V ) p Q ( V | U B , Σ; θ ) as the difference between log p E ( V ) and p Q ( V | U B , Σ; θ ) .
[Equation]
Since p E ( V ) is independent of θ , the first derivative in the second line of equation (14) evaluates to 0.
Next, we substitute p Q ( V | U B , Σ; θ ) using the optimal control sequence distribution expression in equation (4):
[Equation]
Since p B ( V | U B , Σ) is independent of θ , the first derivative in the second line of equation (14) evaluates to 0.
We are left with only two integrals in equation (15).
Next, we factorize out ∂∂θ log Z from the integral since the partition function Z is constant to all V :
[Equation]
The second line in equation (16) follows as (cid:82) p E ( V ) dV = 1 .
Next, we substitute Z = (cid:82) p B ( V | U B , Σ) exp( − 1 λ S ( V ; θ ))
dV in ∂Z∂θ and simplify it:
[Equation]
We rewrite 1 Z p B
( V | U B , Σ) exp( − 1 λ S ( V ; θ )) in the last line of equation (17) as p Q ( V | U B , Σ; θ ) using equation (4) and finally we have:
[Equation]
[Equation]
B Proof of Theorem 3.
We use T to denote the task horizon, and K to denote the receding time horizon for local optimization.
Let us simplify notations in the optimal control sequence distribution p Q ( V | U B , Σ , x t ; θ ) and remove the explicit dependency on U B and Σ .
We assume that all control sequences are applied with U B as the base distribution and Σ as the covariate matrix.
We assume the expert’s underlying cost function is parameterized by θ E , so we have p E ( . )
=
p ( . ; θ E ) .
B.1 Sketch
We present a theoretical analysis on the convergence of RHIRL.
Our main theorem 3.1 states that given that the Kullback–Leibler (KL) divergence over local control sequence distribution for each time step t = 0 , 1 , ...T − 1 is bounded by ϵ , though we do not query expert during the learning, using the cached expert demonstrations alone allows us to bound the error over global state marginal distribution linear in the task horizon T under total variance measure.
First, we show that if the KL-divergence over the local control sequence distribution is bounded by ϵ , so is the KL-divergence over the resulting state distribution.
At each time step t , the optimal control sequences distribution p Q ( V t | x t ; θ t ) at the initial state x t contains the full information to generate the corresponding state trajectories p ( τ t | x t ; θ ) , and consequently the state distributions p t ( x | x t ; θ ) (by neglecting the temporal information).
Upon applying the information loss (lemma B.1), we prove in lemma B.2 that, given initial state x t , if the KL-divergence over V t is bound by ϵ , so is the corresponding state distribution p t ( x ) , i.e. D KL ( p t ( x | x t ; θ E ) ∥
p t ( x | x t ; θ )) ≤ D KL ( p ( V t | x t ; θ E ) ∥
p Q ( V t | x t ; θ )) ≤ ϵ .
Next, we show the KL-divergence over global state marginal distribution between two consecutive time steps is also bounded by ϵ .
For each optimal control sequence we compute, we only execute the first control and use the rest to warm start the re-planning for the next time step.
Therefore, for each time step, we only change a small region of the global state distribution, i.e. reachable space of the current time step.
We use p t RHC ( x ; θ ) to denote the global state marginal distribution by recursively applying RHC from time step i = 0 , ..., t under θ and switching to θ E thereafter until T − 1 .
Using generalized log sum inequality, we prove in lemma B.3 that if the KL-divergence over V t is bounded by ϵ for all t = 0 , ..., T − 1 , the KL-divergence over the global state marginal distribution between each of the two consecutive time steps is bounded by ϵ , i.e. D KL ( p t RHC ( x ; θ )
∥ p t +1 RHC ( x ; θ )) ≤ K +1 T ϵ .
Finally, we use Pinsker’s inequality to upper bound the total variation (TV) distance by KL-divergence over state marginal distribution.
Then we use the triangle inequality to show that the TV distance between expert and the actual visited state distribution over the task horizon T using RHIRL is bounded by an error linearly in T , i.e. D TV ( p E ( x ) ∥ p RHC ( x ; θ )) <
T (cid:112) ϵ/ 2 .
B.2 Proofs
First, we use Lemma B.1, B.2 to prove that the KL-divergence over control sequence space upper bounds the KL-divergence over the resulting state distribution.
We define the control sequence starts at task time step t as V t = { v t , v t +1 , ..., v t + K − 1 } .
Moreover, its corresponding trajectory segment τ t = { x t , x t +1 , ..., x t + K } is computed uniquely from V t and initial state x t by iteratively applying the dynamic model x t +1 = f
( x t , v t ) .
We use p ( x t ) to denote the state density at a single time step t .
Assume V t is optimized based on the cost parameterization θ , then the corresponding state distribution is defined as the summation of all state density over horizon K , i.e. p t ( x ; θ ) = 1 K +1 (cid:80) t + K i =
t p ( x i ; θ ) .
Lemma B.1 (Information loss[16]) .
Let a and b be two random variables and f ( . ) be a convex function.
Let P ( a, b ) be a joint probability distribution.
The marginal distributions are P ( a )
=
(cid:80) b P ( a, b ) and P ( b ) = (cid:80) a P ( a, b ) .
Assume that a can explain away b .
This is expressed as follows
– given any two probability distribution P ( . ) , Q ( . ) , assume the following equality holds for all a , b :
[Equation]
Under these conditions, the following inequality holds:
[Equation] [Equation]
Lemma B.2.
Given the initial state x t and the two control sequence distributions p ( V t | x t ; θ E ) and p Q ( V t | x t ; θ ) , the KL-divergence between the resulting state distribution is upper bounded by
KL-divergence between the control sequence distribution.
[Equation]
Proof.
Firstly, we prove that the KL-divergence over state trajectory distribution p ( τ t ) is upper bounded by the KL-divergence between p ( V t ) .
Given dynamical model f , the control sequence V t and the initial state x t contains all information to generate the corresponding τ t .
Therefore, for any joint distribution P ( τ t , V t | x t ) and Q ( τ t , V t | x t ) , the following is true
[Equation]
Upon applying the information loss Lemma B.1, we have the inequality:
[Equation]
Next we prove that the KL-divergence between state distribution is upper bounded by the trajectory distribution.
Since a trajectory τ t = { x t , x t +1 , ..., x t + K } contains full information of the resulting states (by neglecting the temporal information), for any joint distribution P ( x | τ t ) and Q ( x | τ t ) , the following is true
[Equation]
Upon applying Lemma B.1 we have the inequality:
[Equation]
Therefore, given the KL-divergence between the control sequence distribution is upper bounded by ϵ , we use the equality in equation (22) and (24) to show that the KL-divergence between the resulting state distribution is also upper bounded by ϵ .
[Equation]
Definition 1 (One-step Recoverability [32]) .
Assume that the state distribution of the learner and expert are different at time t , that is D KL
( p ( x t ; θ E ) ∥
p ( x t ; θ )) ̸ = 0 , there exists a policy π re that when used for the learner, can bound:
[Equation]
where the current initial state distribution of the student follows p ( x t ; θ ) .
Intuitively, this condition requires that, no matter what is the current state distribution, the learner can recover to the expert demonstrated distribution in a single time-step.
In our case, this is a natural condition since the difference in the initial state distribution p ( x t ; θ ) and p ( x t ; θ E ) is not arbitrarily large: we use re-planning to ensure the receding state sequences is always bounded below ϵ , hence this recoverability condition can be easily satisfied.
We emphasize that this recoverable policy is never executed in our algorithm, it is only used for the theoretical analysis.
Next, we derive a bound over the global state marginal distribution between two consecutive time steps.
At each time step t = 0 , ..., T − 1 , we re-optimize the local control sequence distribution and only execute the first control, hence we only change state density over a small reachable space.
We define p t RHC ( x, θ ) as the global marginal state distribution by applying RHC from i = 0 , 1 , ..., t under θ and then using the recoverable policy π re to switch to the expert θ E thereafter until T − 1 , i.e., p t RHC ( x ; θ )
= 1 T ( (cid:80) t +1 i =
p ( x i ; θ ) + p ( x t +2 ; π re ) + (cid:80) T i =
t +3 p ( x i ; θ E )) .
According to the definition of the recoverable policy, we have D KL ( p ( x t
+2 ; θ E ) ∥ p ( x t +2 ; π re )) ≤ ϵ 1 , therefore, p t RHC ( x ; θ )
≈ 1 T ( (cid:80) t +1 i =
p ( x i ; θ ) + (cid:80)
Ti
= t +2 p ( x i ; θ E )) .
To quantify the change in global state marginal distribution, we derive a bound for the KL-divergence between two consecutive time steps, i.e.
D KL ( p t − 1 RHC ( x ; θ ) ∥
p t RHC ( x ; θ )) .
Lemma B.3.
If the KL-divergence over resulting state density from the control sequence distribution of length K are bounded by ϵ , i.e. D KL ( p t ( x | x t ; θ E ) ∥
p t ( x | x t ; θ )) <
ϵ , where x t is the state encountered by our policy at t = 0 , 1 , ..., T − 1 and is one-step recoverable, then KL-divergence over the global state marginal distribution between two consecutive control executions are bounded by ϵ ,
[Equation]
) for t = 1 , ..., T − 1 .
We state the generalized log sum inequality below in lemma B.4, the proof can be found in the
Appendix of [16].
Lemma B.4 and B.5 will be used in the proof for Lemma B.3.
Lemma B.4 (Generalized log sum inequality[16]) .
Let p 1 , ..., p n and q 1 , ..., q n be non-negative numbers.
Let p =
(cid:80) ni
=1 p i and q = (cid:80) ni
=1 q i .
Let f ( . ) be a convex function.
We have the following:
[Equation]
Lemma B.5.
Let p ( x ) and q ( x ) be non-negative functions, and c is a constant factor.
We have the following:
[Equation]
Proof.
[Equation]
Now, we are ready to prove lemma B.3.
Proof.
For each t = 0 , ..., T − 1 , we re-plan for the optimal local control sequence start at x t so that the resulting state distribution over horizon K is bounded, i.e. D KL ( p t ( x | x t ; θ E ) ∥
p t ( x | x t ; θ )) <
ϵ , where p t ( x | x t ; θ ) = 1 K +1 (cid:80) t
+ K i =
t p ( x i ; θ ) .
However, instead of executing all K controls in the sequence, we only execute the first control at the current time step t and change the state distribution p ( x t +1 ; θ ) reachable for that single time step, then we use the remaining control sequence to warm start the local control sequence optimization for the next time step.
To account the effect of replanning, for each time step t , since we do not change the state distribution after p ( x t +1 ; θ ) , we can think of the change in the global state distribution as if we follow the optimal control under θ at time step t and then use the recoverable policy π re to switch to θ E afterwards over the control sequence horizon K .
Hence, the actual state density is
[Equation]
Theoretically, since we do not query the expert online, the initial state x t distribution in theorem 3.
and lemma B.2 should follow the expert demonstration at time t , i.e. p ( x t ; θ E ) .
However, our MPC controller cannot jump to this distribution and we replan from our current state distribution p ( x t ; θ ) .
To resolve this mismatch, we require the recoverability condition in our optimization procedure such that, for each resulting state from the controller, there always exists a one-step recoverable policy π re that can correct the current state distribution p ( x t ; θ ) to p ( x t +1 ;
θ E ) in one step.
Therefore, with this one-step recoverable condition on every state x t induced by the cost function parameterized by θ , x t in theorem 3.1 and lemma B.2 now follows the state distribution of our controller, i.e. p ( x t ; θ ) .
That is,
[Equation]
Recall that we use p t RHC ( x ; θ ) to account for the global state marginal distribution resulted from executing a single optimal control at time step t .
More specifically, p t RHC ( x ; θ ) is defined as the state marginal distribution by executing only the first optimal control from the replanned optimal control sequence at each time step from i = 0 , ..., t under θ and switching to θ E thereafter by using the recoverable policy π re until T − 1 , i.e. p t RHC ( x ; θ ) ≈ 1 T ( (cid:80) t +1 i
=
p ( x i ; θ ) + (cid:80)
Ti
= t +2 p ( x i ; θ E )) .
We bound the KL-divergence over global state distribution between two consecutive time step as follow:
[Equation]
≤
T ( (cid:90)
[Equation]
i = p ( x
[Equation]
θ ) log (cid:80)
[Equation]
θ ) (cid:80)
[Equation]
−
[Equation]
=
p ( x
[Equation]
) dx + (cid:90) ( p ( x t ; θ ) + t + K (cid:88)
i =
t + p ( x i ; θ E )) log p ( x
[Equation]
; θ ) + (cid:80) t
+ K i =
t +1 p
[Equation]
x i
[Equation]
θ E ) p ( x
[Equation]
[Equation]
( x t +1 ; θ ) + (cid:80) t
+ K i
=
t +
[Equation]
p ( x i ; θ E ) dx + (cid:90)
T (cid:88) i =
t + K + p
( x i ; θ E ) log (cid:80)
Ti = t + K +1 p
( x i ; θ E ) (cid:80)
Ti = t + K +1 p
( x i
[Equation]
θ E ) dx ) =
T (cid:90) ( p ( x t ; θ ) + t + K (cid:88) i =
t + p ( x i ; θ E )) log p ( x t ; θ ) + (cid:80) t
+ K i =
t +1 p ( x i ; θ E ) p ( x t ; θ ) + p ( x t +1 ; θ ) + (cid:80) t
+ K i =
t +2 p ( x i ; θ E ) dx =
K +
T (cid:90)
K + 1( p ( x t ; θ ) + t + K (cid:88) i =
t + p ( x i ; θ E )) log 1 K +1 ( p ( x t ; θ ) + (cid:80)
[Equation]
[Equation]
The first equality in equation (32) follows the definition of p t RHC ( x ; θ ) and the second line follows the definition of the recoverable policy π re .
Then, we use lemma B.5 to factor out 1 T in the third line.
The next inequality follows from the generalized log sum inequality stated in lemma B.4, and we have the first and third terms reduce to 0 and are left with the second term in the next line.
We apply lemma B.5 again to the integral using the constant factor 1 K +1 .
In addition, to make the equality hold, we multiply the inverse of the constant factor K + 1 outside the integral.
We observe the integral is now the KL divergence between the expert p t ( x | x t ; θ E ) and one-step-execution of our policy 1 K +
[Equation]
p
[Equation]
x t
[Equation]
) + p
[Equation]
x
[Equation]
+
[Equation]
θ )
+
[Equation]
+ K
i
[Equation]
t +2 p
[Equation]
x i
[Equation]
θ E )) .
The final inequality follows from the bound derived in equation (31).
For t = 0 , we have p 0 RHC ( x ; θ )
= 1 T ( p ( x 0 ; θ ) + (cid:80) T − 1 i =1 p
x i ; θ E )) .
Since the initial state x 0 for expert and our policy are sampled from the same initial state distribution µ , p ( x 0 ) is independent of θ , i.e. p ( x 0 ; θ ) = p ( x 0 ; θ E ) .
Therefore, p RHC ( x ; θ E ) = p ( x 0 )
+ (cid:80) T − 1 i =1 p
x
i ; θ E ) =
p 0 RHC ( x ; θ ) .
Moreover, the final global state marginal distribution p RHC ( x ; θ ) is the same as the p T − 1 RHC ( x ; θ ) , i.e. p
[Equation]
x ; θ ) =
[Equation]
p ( x i ; θ ) = p
[Equation]
RHC ( x ; θ ) .
For any t = 1 , 2 , .., T − 1 , we have proved
D
[Equation]
Finally, we are prepared to prove theorem 3.1.
Proof.
We evaluate the TV distance over the state marginal distribution between the expert policy and our control law.
[Equation]
The first equality in equation (33) follows from the fact that p RHC ( x ; θ E ) =
p 0 RHC ( x ; θ ) and p RHC ( x ; θ ) =
p T − 1 RHC ( x ; θ ) .
We use triangle inequality of the TV distance measures to obtain the inequality in the second line.
Recall that by Pinsker’s inequality, the total variation (TV) distance is related to Kullback–Leibler (KL) divergence by the following inequality: D TV ( P ∥ Q ) ≤ (cid:113) 12 D KL ( P ∥ Q ) .
We apply Pinsker’s inequality to each of the TV terms in the second line of equation (33) to bound them by a summation of KL-divergence as shown in the first line of equation (34).
Next, given the control sequence distribution for every time step is bounded by ϵ , we apply lemma B.2 to show that the resulting state distribution from the optimal control sequences for each time step t is also bounded by ϵ .
Next, we use this result and apply Lemma B.3 to bound the KL-divergence over the global state marginal distribution between two consecutive time steps by K +1 T ϵ .
Second line in equation (34) follows from this result and finally we derive the final bound linear in T .
[Equation]
The last line follows from the fact that K << T , so (cid:113) K +1 T < 1 .
C Extension to Stochastic Dynamics
RHIRL optimizes the trajectories in the space of control sequences p ( V ) , whereas V = { u 0 , u 1 , u 2 , ..., u K − 1 } is a sequence of controls.
If the system is deterministic, we can apply
V to the dynamical system x t +1 = f
( x t , v t ) with start state x 0 and obtain a state sequence τ = ( x 0 , x 1 , . . .
, x K ) .
We recall that total state trajectory cost of V defined in equation (3) as follows:
[Equation]
We use the information-theoretic MPC (MPPI) [37] to solve for an optimal control sequence distribution at the current start state x t in iteration t .
The main result of MPPI suggests that, under a deterministic system, the optimal control sequence distribution Q minimizes the “free energy” of the dynamical system and this free energy can be calculated from the cost of the state trajectory under
Q .
Mathematically, the probability density p Q ( V ∗ ) , as shown in equation (4) can be expressed as a function of the state cost S ( V, x t ; θ ) , with respect to a Gaussian “base” distribution B ( V B , Σ) that depends on the control cost:
[Equation]
where Z is the partition function.
Intuitively, this result shows that the control sequence V that results in lower state-trajectory cost S ( V ) are exponentially more likely to be chosen.
In this section, we extend RHIRL to stochastic dynamics where x t {++
 = f ( x t , v t , ω t ) , where ω t is a random variable that models the independent system noise. More specifically, we assume that x t+} +1 ∼ p ( x t +1 | x t , v t ) .
Due to the stochasticity of the dynamics, the state trajectory cost in equation (3) and the optimal control distribution in equation (4) are affected.
Therefore, we first redefine the trajectory state cost under stochastic dynamics, then derive the counterpart of equation (4) for the optimal control sequence distribution under the stochastic dynamics, finally we adapt our existing RHIRL algorithm to stochastic dynamics.
C.1 State Trajectory Cost ˜ S ( V ; θ ) under Stochastic Dynamics
Due to the stochasticity of the dynamics, given the initial state x 0 , we no longer have a one-to-one mapping from the control sequence V to the resulting state trajectory τ = ( x 0 , x 1 , ..., x K ) .
Instead, we have a distribution of state trajectories:
[Equation]
To accommodate this change, the trajectory state cost of a control sequence ˜ S ( V, x 0 ; θ ) is defined over the distribution of the resulting state trajectories, instead of single trajectory:
[Equation]
We always measure the preferences over the control sequence V by their resulting state trajectories τ .
Hence, when the resulting trajectories changes from a single deterministic sequence of states to a distribution of state trajectories, we adapt our measure of the resulting cost: under the deterministic dynamics where each V uniquely maps to the same state trajectory τ , the state trajectory cost is the cost of that specific trajectory; while under the stochastic dynamics where the same control sequence
V maps to a distribution of τ , the state trajectory cost of a control sequence is now defined as the expected state cost of the distribution of trajectory.
We measure the state trajectory cost of a control sequence S ( V, x 0 ; θ ) , instead of simply a state trajectory cost on the states itself S ( τ, x 0 ; θ ) , because we want to use this measure to directly optimize the control sequence.
C.2 Optimal Control Sequence Distribution under Stochastic Dynamics
Next, we derive the optimal control sequence distribution under the stochastic dynamics.
Our derivation is based on MPPI [37], which uses the “free-energy” principle to derive the optimal control sequence distribution under deterministic dynamics.
Definition 2 (Free-energy ([33], Definition 1) .
Let P ∈ P
( Z ) and the function J ( x ) :
Z → R be a measurable function.
The the term:
[Equation]
(38) is called free energy of J ( x ) with respect to P , ρ is a constant.
Now we have the free-energy of a control system under stochastic dynamics as stated below.
It has a “Gaussian” base control sequence distribution B ( U B , Σ)
such that its control sequence distribution follows p B
( V ∗ | U B , Σ) whereas Σ is the Gaussian control noise covariance matrix.
˜ S
( V ; θ ) denotes the state trajectory cost function.
[Equation]
λ ∈ R
+ is the inverse temperature of the control system.
Suppose now we have another control sequence distribution with probability measure p ( V ) and these two distributions are absolutely continuous, then we can rewrite the free-energy w.r.t p B ( V ) using the expectation over the density of p ( V ) use the standard importance sampling trick:
[Equation]
Therefore, we have
[Equation]
The right-hand side is the lower bound of the free-energy of the control system.
We use p Q ( V ) to denote the optimal control sequence distribution.
This distribution is only optimal if and only if the bound in the equation above is tight, i.e. F ( ˜ S, p B , x 0 , λ ; θ ) =
− 1 λ E p Q
[ ˜ S ( V, x 0 ; θ )] + λD KL ( p Q ( V ) || p B ( V ∗ | U B , Σ)) .
We claim that the optimal control sequence distribution ˜ p Q under the stochastic dynamics is as follows:
[Equation]
whereas Z = (cid:82) exp( − 1 λ ˜ S
( V, x 0 ; θ ))
p B ( V ∗ | U B , Σ) dV is the partition function.
We prove that equation (47) is the optimal control sequence distribution under stochastic dynamics by showing that this ˜ p Q ( V ∗ | U B , Σ , x 0 ; θ ) tightens the bound of free-energy in equation (46).
We substitute ˜
p Q ( V ∗ | U B , Σ , x 0 ; θ ) into the RHS of equation (46) and simplify the expression of the
KL-divergence:
[Equation]
Next we substitute the expression for the partition function Z and we found that the RHS is exactly the definition of the the free-energy of the control system with base distribution B ( U B , Σ) :
[Equation]
The final equality forces the inequality to be tight.
Therefore, p Q ( V ∗ | U B , Σ , x 0 ; θ ) in equation (47) is the optimal control sequence distribution under the stochastic dynamics.
We observe that the optimal control sequence distribution under deterministic system p Q ( V ∗ | U B , Σ , x 0 ; θ ) in equation (4) and that under the stochastic dynamics ˜
p Q ( V ∗ | U B , Σ , x 0 ; θ ) in equation (47) only differs in the calculation of the state trajectory cost of the control sequences.
Intuitively, it means that under deterministic dynamics, we choose the control sequence V that will, for sure, leads to a state trajectory with lower cost; while when we extend to stochastic dynamics, the control sequence V that results in lower state-trajectory cost S ( V ) in expectation are exponentially more likely to be chosen.
Practically, now we need more samples for a single control sequence to compute the expectation in equation (37).
C.3 RHIRL under Stochastic Dynamics
Next, we adapt our RHIRL algorithm to this new state trajectory cost measure ˜ S ( V, x 0 ; θ ) and the optimal control sequences ˜
p Q ( V ∗ | U B , Σ , x 0 ; θ ) under stochastic dynamics.
We recall that under the deterministic dynamics, RHIRL uses importance sampling in equation (12) to estimate the ∂ L ∂θ so as to update the cost function parameter θ :
[Equation]
whereas the N control sequences in the first term are from the expert demonstration D t and the M control sequences in the second term are from our approximated optimal control sequence distribution p Q ( V ∗ ) , and w ( V j ) is the importance sampling weight.
To estimate ∂ L ∂θ , we need to calculate/approximate the importance sampling weight w ( V ) , and the derivative of the state trajectory cost ∂∂θ S ( V, x 0 ; θ ) w.r.t θ .
We recall that the importance sampling weight w ( V ) depends on the state trajectory cost S ( V, x 0 ; θ ) in equation (11):
[Equation]
Under the deterministic dynamics, the importance sampling weight w ( V ) is estimated using MonteCarlo approximation with M state trajectory samples as follows:
[Equation]
Since the state trajectory cost S ( V, x 0 ; θ ) is a linear sum of the cost of all states, ∂S∂θ can be directly computed as follows:
[Equation]
To extend RHIRL to stochastic dynamics, when the state trajectory cost function is now ˜ S ( V, x 0 ; θ ) , we need to redefine how to estimate ˜ w ( V ) and consequently ∂ ˜ S∂θ .
When extend to stochastic dynamic, we have the following:
[Equation]
and we still adopts Monte-carlo sampling to approximate ˜ w ( V ) .
However, since ˜ S ( V, x 0 ; θ ) now measures the expected state trajectory cost under the stochastic dynamics, we need to go one step further and use sampling to estimate ˜ S
( V, x 0 ; θ ) using M s number of state trajectories τ h
= ( x 0 , x h 1 , ..., x hK ) per ( x 0 , V ) pair:
[Equation]
Therefore, now the importance sampling weight ˜ w ( V ) is approximated from M × M s state trajectories, with M s trajectories from each ( x 0 , V j ) pair as follows:
[Equation]
We emphasize that under the stochastic dynamics, we use the state trajectory samples to estimate both the state trajectory cost ˜ S
( V, x 0 ; θ ) and the importance sampling weight ˜ w ( V ) .
Since the ˜ S now measures the expected cost over a distribution of trajectories, we need more samples to estimate ˜ w ( V ) compared to the deterministic setting.
Moreover, in the final ∂ L ∂θ , we need to differentiate ˜ S
( V, x 0 ; θ ) w.r.t.
θ .
Since ˜ S is estimated from sampling, we have:
[Equation]
Finally, we summarize how to extend RHIRL to stochastic dynamics.
In stochastic dynamics, each control sequence V will map to a distribution of state trajectory p ( τ | V, x 0 ) .
Hence, we adapt our measure of state trajectory cost S ( V, x 0 ; θ ) from a single trajectory to be the expected cost over a distribution of state trajectories
˜ S
( V, x 0 ; θ ) in equation (37).
Next, we revise the optimal control sequence distribution to a stochastic setting ˜ p Q ( V ∗ | U B , Σ , x 0 ; θ ) in equation (47).
More specifically, we show under the stochastic dynamics, the optimal control sequences V ∗ is chosen based on the expected cost of its resulting state trajectories.
Finally, under this new state trajectory cost ˜ S
( V, x 0 ; θ ) and the optimal control sequence distribution ˜ p Q ( V ∗ | U B , Σ , x 0 ; θ ) , we adapt the approximation of the importance sampling weight ˜ w ( V ) and consequently the gradient of the overall loss w.r.t θ by adding one more sampling process to estimate the new state trajectory cost.
Moreover, in practice, we can use the same set of samples to estimate both state trajectory cost ˜ S ( V, x 0 ; θ ) and the importance sampling weights ˜ w ( V ) .
D Experimental Details
In this section, we list down the implementation details of RHIRL and the baselines.
The code is included in the supplementary material.
We also report the hyperparameters used in the experiments, the detailed network architectures, training procedures and evaluation procedures used for our experiments.
D.1 Practical Issues of RHIRL Control Noise Covariance Approximation
The actual control noise covariance Σ is unknown to RHIRL and the baselines.
However, RHIRL uses the noise covariance matrix Σ to sample the controls around the nominal control (Algorithm 1, line 6) and calculate the quadratic control cost in Equation (37).
Since we have no access to the true Σ , RHIRL approximates Σ as a constant factor of the identity matrix βI , whereas β is the hyperparameter we optimize using grid search and I is the identify matrix with its width equals to the dimension of the action space.
Therefore, instead of sampling the controls from N ( V | U, Σ) , we sample from N ( V | U, βI ) in practice.
We also use βI in Equation (37) to replace the unknown Σ .
Even in the noise-free environment, we set β to a non-zero value to foster exploration; otherwise, the importance sampling degenerates to the single nominal control.
Our experiment shows that RHIRL is robust to the choice of β : the cost learning performs well even if βI ̸ = Σ .
This may be attributed to the fact that we jointly optimize the state cost function and β .
Therefore the learned state cost function may compensate for the inaccurate approximation for Σ .
Numerical Stability
Equation(11) forms the basis of importance sampling and estimation.
However, the learned cost can be a huge negative number, which causes numerical instability in estimating the importance weights.
To mitigate this issue, we subtract the minimum trajectory cost S min from all rollouts to improve the numeric stability.
Since subtracting the same number from all rollouts does not change the order of the preference, this operation does not affect the optimality of our derivation.
Nominal Control Initialization and Local Optimality
RHIRL samples around the nominal control sequence to collect the samples for importance sampling.
However, if the initial nominal control sequence performs poorly, it is not easy to generate any good samples to improve the current control sequences.
To mitigate this problem, we add an exploration strategy to the sampling process in (Algorithm 1, line 6): with probability α , we continue with the standard sampling strategy to sample around the nominal control; with probability 1 − α
we sample uniformly from the entire action space.
This helps RHIRL to correct from the unsuitable nominal control initialization and also helps RHIRL to escape the local optimal solution.
We set α = 0 .
5 for all tasks in our experiments.
Control Smoothness
Updating the optimal control by importance sampling might cause some jerk in the control space.
In order to make the control change smoothly in its local space, we apply a Savitzky–Golay filter over the time horizon dimension to constrain the control that does not change too much over the time horizon.
D.2 Training Details
We list the hyper-parameters of RHIRL for different tasks.
These hyper-parameters were selected via grid search.
[Table]
The implementation of the baselines (f-IRL, AIRL and GAIL) are adapted from f-IRL’s
[27] official repository.
We use the hyperparameters reported in f-IRL for the MuJoCo tasks and performed grid search on the hyperparameters for the rest of the tasks.
SAC[12] is used as the base MaxEnt RL algorithm for both expert policy and the baselines optimization algorithm.
We use a tanh squashed
Gaussian as the policy network for Pendulum-v0, LunarLander-v2, and the MuJoCo tasks; and we use a Gaussian Convolutional policy as the policy network for CarRacing-v0.
The mean and std of the Gaussian are parameterized by a ReLU MLP of size (64, 64).
Adam is used as the optimizer.
We use the reported SAC temperature, α = 0 .
2 , reward scale c = 0 .
2 , and gradient penalty coefficient λ = 4 . 0 .
The rest of the hyperparameters for f-IRL, GAIL and AIRL are listed below.
[Table]
D.3 Reward Function/Discriminators Network architectures
We use the same neural network architecture to parameterize the cost-function/rewardfunction/discriminator for all methods.
For continuous control task with raw state input
, i
[Table]
e. pendulum, lunarlander and the MuJoCo tasks, we use two-layer of MLP with ReLU activation function to parameterized the cost function/discriminator.
The hidden size for Pendulum-v0 is (32, 32), and (64, 64) for the rest of the tasks.
For continuous control task with image input,
i
[Table]
e. carracing, we use a four convolutional layer with kernel size 3 × 3 as the feature extractor.
The output of the CNN layer is vector with size (128,) and is fed into the same reward network as describe above.
D.4 Numerical Experiments Results
We report the average returns and the standard deviation for Table 1 and Table 2 in Table 3 and
Table 4 respectively.
The mean and standard deviation computed from
[Table] [Table]