{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "nAvx4-UCNzt2"
},
"source": [
"# Chapter Summary\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nAvx4-UCNzt2"
},
"source": [
"In Chapter 2, we considered actions and sensing operations that were executed at a specific moment in time,\n",
"having no dependence or interaction with either future or past actions or observations.\n",
"In this chapter, we considered the more realistic, and more interesting, case, in which\n",
"the interdependence between sequences of actions and observations can exploited\n",
"via probabilistic inference.\n",
"This led to the introduction of much of the essential machinery that underlies robotics perception and planning, and that will be developed throughout the remainder of the book."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Models\n",
"\n",
"The key modeling tool that we introduced is the language of Bayesian networks. Bayes nets are a type of graphical model named after reverend Bayes, who also gave his name to the practice of interpreting probability distributions as *beliefs* rather than observed frequencies.\n",
"\n",
"A foundational Bayes net family is the Markov chain, modeling a state evolving over time. State transitions are modeled using a conditional distribution of the current state, conditioned on the previous state, invoking the Markov property. A Markov chain is then a sequence of such transition conditionals, and this in itself is an incredibly powerful idea. Typically, these transitions are *stationary*, in that they do not depend on time, but we have introduced *controlled* Markov chains to capture the dependence of the state on actions. This is an essential tool in robotics: modeling how the state of the robot and/or its environment changes -probabilistically- as a result of the robot's actions.\n",
"\n",
"Unrolling a Bayes net fragment over time was then generalized to the concept of Dynamic Bayes Nets (DBNs), allowing us to also model noisy sensors measuring aspects of the state. The DBN framework allowed us to precisely capture the fact that these measurements only depend on the current state, and that the states themselves are Markov, conditioned on a given action. These two modeling assumptions, coupled with reasoning in a discrete time-setting, are so universal in robotics that the particular action-state-measurement Dynamic Bayes Net from Section 3.3 can be used to describe almost all robot modeling approaches.\n",
"\n",
"One of the key properties of Dynamic Bayes nets is that they are easy to sample from, using ancestral sampling, which allows us to simulate what a given sequence of actions might accomplish, and what we would measure in these hypothetical roll-outs. This is used to illustrate, or even power, various perception and planning algorithms, which we discuss below."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{index} factor graphs, factors",
"```",
"## Reasoning\n",
"\n",
"Bayes nets are great for *modeling*, and in Section 3.4 we introduced Hidden Markov Models that allow us to reason about a sequence of hidden states, observed via noisy measurements. Hidden Markov models have been around for a long time and transformed areas such as speech recognition. They are exactly what we need for robot localization over time, as well. Beyond the simple vacuum cleaning robot example, they can be generalized to nearly any robot/environment combo that we can model using discrete states transitioning over time. In our example we use just a single discrete sensor, but the HMM is able to accommodate multiple sensors, even continuous ones. \n",
"\n",
"We then discussed efficient inference using factor graphs. Naive inference, be it maximum a posteriori (MAP) or computing the full posterior over the hidden states is exponential in complexity. Hence, we introduced a new graphical formalism, **factor graphs**, that focus only on the hidden variables, capturing the effect of priors, transitions, and measurements - assumed given - as **factors**. \n",
"We showed how an HMM can easily be converted to a factor graph, but this generalizes really to any dynamic Bayes net with given actions and measurements. We then sketched out - for an HMM - the max-product and sum-product algorithms, which respectively compute the MAP estimate and the full posterior, with time complexity that is *linear* in the number of time steps. Such is the power of dynamic programming."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Section 3.5, we introduced Markov Decision Processes or MDPs, which we used to model decision making in a stochastic environment, albeit with complete knowledge of the state. This is a rich subject, and we introduced many new concepts, including reward, utility functions, rollouts, and policies and their value. \n",
"\n",
"Finally, we considered learning optimal policies in Section 3.6. After deriving the Bellman equation we discussed two algorithms to compute the optimal policy/value function: policy iteration and value iteration. However, both of these assume full knowledged of the world model (transition probabilities between states) and reward structure. In a model-based method we try to estimate these from experience gathered by exploring the environment. However, a more direct method focused on estimating the action values (Q-values) is Q-learning, which is an example of a model-free method. Finally, we discussed how to balance exploitation and exploration to avoid getting stuck in local corners of the policy space."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{index} elimination algorithm",
"```",
"## Background and History\n",
"\n",
"Markov chains date back to -you guessed it- [Andrey Markov](https://en.wikipedia.org/wiki/Andrey_Markov) who used them to study, among other things, the statistics of language. In fact, attesting to the importance and generality of the concept, any finite-context large language model can be viewed as a Markov chain - admittedly with a rather vast state space.\n",
"\n",
"In this book, we use factor graphs as the organizing structure for probabilistic\n",
"inference. In later chapters we will expand their use to continuous\n",
"variables, and will see that factor graphs aptly describe the\n",
"independence assumptions and sparse nature of the large nonlinear\n",
"least-squares problems that arise in robotics. But their usefulness extends\n",
"far beyond that: they are at the core of the sparse linear solvers we\n",
"use as building blocks; they clearly show the nature of filtering and\n",
"incremental inference; and they lead naturally to distributed and/or parallel\n",
"versions of robotics.\n",
"A deeper dive into factor graphs, including some historical notes and their use in robotics, can be found in the\n",
"review papers {cite:p}`Dellaert17fnt_fg` and {cite:p}`Dellaert21ar_fg`.\n",
"\n",
"Hidden Markov Models (HMMs) were introduced in 1966 by {cite:t}`Baum66aoms_hmms`, and really broke through when they were applied in the speech recognition work by IMB {cite:p}`Jelinek75it_decoder`. \n",
"The dynamic programming algorithms we introduced for HMMs are actually special cases for linear, chain-structured factor graphs. \n",
"In the HMM literature, they are known as the Viterbi and Forward-Backward algorithms, respectively. However, because at every step, one variable is eliminated from the maximization, both max-product and sum-product algorithms are in fact instances of the **elimination algorithm** (see again the review paper by {cite:t}`Dellaert17fnt_fg`), which works for *arbitrary* factor graphs, albeit not necessarily in $O(n)$ time.\n",
"\n",
"The *principle of optimality* was stated by Bellman in a\n",
"[seminal 1960 article in the IEEE Transactions on Automatic Control](https://www.rand.org/content/dam/rand/pubs/papers/2008/P1416.pdf) {cite:p}`Bellman60`.\n",
"One of the most respected contemporary sources for Markov decision processes reinforcement learning is the [book by Sutton and Barto](http://incompleteideas.net/book/the-book-2nd.html) {cite:p}`Sutton18book_reinforcement`, which was recently updated to a second edition. Q-learning dates from a [Ph.D. thesis by Chris Watkins](https://www.cs.rhul.ac.uk/~chrisw/thesis.html) {cite:p}`Watkins89thesis_Qlearning`.\n",
"The seminal book by Pearl {cite:p}`Pearl88Probabilistic` introduced general Bayes nets for probabilistic\n",
"reasoning to the artificial intelligence community.\n",
"A modern comprehensive treatment of graphical models for probabilistic inference is \n",
"provided in {cite:p}`ProbGraphModels`.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"include_colab_link": true,
"name": "S30_vacuum_intro.ipynb",
"provenance": []
},
"interpreter": {
"hash": "c6e4e9f98eb68ad3b7c296f83d20e6de614cb42e90992a65aa266555a3137d0d"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
},
"latex_metadata": {
"affiliation": "Georgia Institute of Technology",
"author": "Frank Dellaert and Seth Hutchinson",
"title": "Introduction to Robotics"
}
},
"nbformat": 4,
"nbformat_minor": 2
}