├── .gitignore ├── Capítulo 1 ├── Ex_1.01.md ├── Ex_1.02.md ├── Ex_1.03.md ├── Ex_1.04.md ├── Ex_1.05.md └── README.md ├── Capítulo 2 ├── Ex_2.01.md ├── Ex_2.02.ipynb ├── Ex_2.02.md ├── Ex_2.03.md ├── Ex_2.04.ipynb ├── Ex_2.05.ipynb ├── Ex_2.06.md ├── Ex_2.10.md └── README.md ├── Capítulo 3 ├── Ex_3.01.md ├── Ex_3.02.md ├── Ex_3.03.md ├── Ex_3.05.ipynb ├── Ex_3.06.ipynb ├── Ex_3.06.md ├── Ex_3.07.ipynb ├── Ex_3.08.ipynb ├── Ex_3.08.md ├── Ex_3.09.ipynb ├── Ex_3.10.ipynb ├── Ex_3.11.ipynb ├── Ex_3.11.md ├── Ex_3.12.ipynb ├── Ex_3.12.md ├── Ex_3.13.md ├── Ex_3.14.md ├── Ex_3.22.md └── README.md ├── Capítulo 4 ├── Ex_4.01.md ├── Ex_4.03.md ├── Ex_4.04.md ├── Ex_4.06.md ├── Ex_4.07.ipynb ├── Ex_4.08.md ├── Ex_4.09.ipynb ├── Ex_4.10.ipynb └── README.md ├── Capítulo 5 ├── Ex_5.03.md ├── Ex_5.05.ipynb ├── Ex_5.06.ipynb ├── Ex_5.07.md ├── Ex_5.09.ipynb ├── Ex_5.10.ipynb ├── Ex_5.11.ipynb ├── Ex_5.13.ipynb └── README.md ├── Capítulo 6 ├── Ex_6.02.md └── README.md ├── Capítulo 7 └── README.md ├── Capítulo 8 ├── Ex_8.02.md ├── Ex_8.03.md ├── Ex_8.06.md ├── Ex_8.07.md └── README.md ├── Capítulo 9 ├── Ex_9.02.md └── README.md ├── LICENSE ├── README.md └── Stubs ├── Ex_X.XX.ipynb └── Ex_X.XX.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /Capítulo 1/Ex_1.01.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 1.1: Self-Play* 2 | 3 | **Suppose, instead of playing against a random opponent, the reinforcement learning algorithm described above played against itself, with both sides learning. What do you think would happen in this case? Would it learn a different policy for selecting moves?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | O algoritmo aprenderia com ele mesmo maneiras de vencer o jogo, através da experiência adquirida nas suas partidas. Sua política de movimento será diferente da de um humano, pois o algoritmo não teve nenhum contato(jogando contra ou por um modelo) com técnicas utilizadas por um humano, possuindo assim um maneira única de jogar, e podendo até existir momentos na partida que o algoritmo faça jogadas contraintuitivas para um humano, pois ele aprendeu que essa é a melhor jogada nessa situação para obter a vitória no final da partida. 10 | ``` 11 | 12 | --- 13 | Resposta 2: 14 | 15 | ``` 16 | Neste caso os algoritmos iriam valorizar os estados de maneiras diferentes. Imagine o jogo Tic Toc onde o jogador A sempre começa jogando. Dessa forma o Jogador B nunca viu o tabuleiro vazio e portando nao saberia qual posição escolher quando visse pela primeria vez o tabuleiro vazio. Os jogadores apesar de usarem o mesmo algoritmo de aprendizagem por reforço poderiam aprender politicas diferentes pois cada jogador teria suas próprias experiências. 17 | ``` 18 | -------------------------------------------------------------------------------- /Capítulo 1/Ex_1.02.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 1.2: Symmetries* 2 | 3 | **Many tic-tac-toe positions appear different but are really the same because of symmetries. How might we amend the learning process described above to take advantage of this? In what ways would this change improve the learning process? Now think again. Suppose the opponent did not take advantage of symmetries. In that case, should we? Is it true, then, that symmetrically equivalent positions should necessarily have the same value?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Se o oponente com quem o algoritmo está jogando toma as mesmas ações para posições que são simétricas, então é uma vantagem verificar há simetrias nas jogadas para assim, o algoritmo aprender com mais eficiência. Porém, se o jogador tomar ações diferentes para posições simétricas, então não valeria a pena verificar se há simetria, pois as ações do oponente seriam diferentes daquelas que estávamos esperando. Dito isso, o valor de posições simétricas é igual para casos em que o oponente toma as mesmas ações simétricas e diferente em casos que o oponente não toma a mesma ação simétrica. 10 | ``` 11 | 12 | --- 13 | Resposta 2: 14 | 15 | ``` 16 | Para o jogo da velha é possível usar 4 eixos de simetria para basicamente dividir o numero de estados por 4. Isso aumentaria drasticamente a velocidade / reduziria a memória necessária. Se o oponente não aproveitasse as simetrias, isso poderia resultar em um pior desempenho geral, por exemplo, se o oponente sempre jogasse certo, exceto em 1 canto, então usar simetrias significaria que você nunca tiraria vantagem dessa informação. Isso significa que posições simetricamente equivalentes nem sempre têm o mesmo valor em um jogo multijogador 17 | ``` 18 | -------------------------------------------------------------------------------- /Capítulo 1/Ex_1.03.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 1.3: Symmetries* 2 | 3 | **Suppose the reinforcement learning player was greedy, that is, it always played the move that brought it to the position that it rated the best. Might it learn to play better, or worse, than a nongreedy player? What problems might occur?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Ele aprenderá pior, o grande problema de apenas selecionar os melhores lances, baseado no que ele sabe até o momento, é que tal comportamento reforça o caminhamento apenas pelas possibilidades já conhecidas que melhor performaram até então. Logo, o player aprenderá algo novo em duas circunstâncias: 10 | 11 | 1. Quando o adversário conduzir o jogo para uma posição que o player desconhece, ou seja, ele terá que jogar algo "novo", ou; 12 | 2. Quando um caminho já reforçado, que possuí o melhor valor, sofrer a circustância 1 e sua pontuação se tornar inferior, ocasionado pela descoberta de novas possibilidades que resultam em resultados ruins. 13 | 14 | Desconsiderando tais casos, o player estará caminhando através daquelas possibilidades já conhecidas que são consideradas boas, isso limita o potencial de descoberta, fazendo com que possíveis jogadas mais promissoras não sejam, ou com muita dificuldade, descobertas. Além disso, as novas possibilidades causadas pelas jogadas do **adversário** podem estar conduzindo para derrotas constantes, sendo assim o aprendizado além de ineficiente pode não ser muito proveitoso. 15 | ``` 16 | 17 | --- 18 | Resposta 2: 19 | 20 | ``` 21 | Acredito que iria depender de quanto "conhecimento" o algoritmo já acumula, imaginando um algoritmo que no contexto de jogo da velha o mesmo se torna invencível, em que no pior dos casos um empate vai acontecer. Mas diria que pior, se o objetivo é aprender a jogar melhor, o "greedy player" não vai explorar novas possibilidades com determinada frequência, em contrapartida, o "nongredy player" pode não ter as melhores recompensas, mas vai explorar novas possibilidades com muito mais frequência que o jogador ganancioso, dessa forma o aprendizado, acredito que, é considerado melhor para o "nongreedy player". 22 | ``` 23 | 24 | --- 25 | Resposta 3: 26 | 27 | ``` 28 | Neste caso o algoritmo aprenderia com ele mesmo qual seria a melhor jogada para um determinado estado, porém poderia ocorrer um certo bias devido ao inimigo sempre repetir algum determinado passo acreditando que aquele movimento seria o melhor movimento para o estado, porém ao jogar com um ser humano o oponente poderia realizar uma jogada 'blafer' para confundir o algoritmo e assim o ser humano poderia tirar vantagem sobre o jogo. 29 | ``` 30 | -------------------------------------------------------------------------------- /Capítulo 1/Ex_1.04.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 1.4: Learning from Exploration* 2 | 3 | **Suppose learning updates occurred after all moves, including exploratory moves. If the step-size parameter is appropriately reduced over time (but not the tendency to explore), then the state values would converge to a different set of probabilities. What (conceptually) are the two sets of probabilities computed when we do, and when we do not, learn from exploratory moves? Assuming that we do continue to make exploratory moves, which set of probabilities might be better to learn? Which would result in more wins?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Para movimentos exploratórios, o conjunto de probabilidades seguiria a política "não gananciosa", não escolhendo os movimentos com maiores valor, enquanto para movimentos não exploratórios seria o que segue a "gananciosa". Realizando apenas movimentos gananciosos, é possível que o agente foque em movimentos que são muitos bons, já que prioriza os ganhos imediatos, enquanto movimentos não gananciosos também visa maximizar as recompensas no longo prazo. Explorando outros movimentos, o agente pode encontrar novas jogadas promissoras que podem ser as melhores e com isso, maximizar as recompensas. Realizar movimentos exploratórios pode resultar em desempenho melhor, levando em consideração que o resultado da abordagem gananciosa pode ser enviesada, logo, o desempenho do aprendizado com movimentos exploratórios é no mínimo tão ruim quanto que a outra abordagem, já que se uma ação, que foi escolhida na exploração, for melhor que a ganancioasa, seu valor será atualizado. Entretanto, o ideal é equilibrar as abordagens, um momento utilizando movimentos exploratórios e em outro movimentos gananciosos, que busca maximixar o resultado daquela ação. 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 1/Ex_1.05.md: -------------------------------------------------------------------------------- 1 | ### *Exercice 1.5: Other Improvements* 2 | 3 | **Can you think of other ways to improve the reinforcement learning player? Can you think of any better way to solve the tic-tac-toe problem as posed?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Uma maneira de melhorar o aprendizado do Reinforcement Learning player é criando um script com jogadas preferiveis antes de rodar o algoritmo de aprendizado. Como o jogo da velha é um jogo simples, existem jogadas que em um determinado estado do jogo são mais utilizadas por jogadores convencionalmente, uma ideia de como seria o script inicial: 10 | 11 | * Mais 02 pontos se a posição for a central; 12 | * Mais 01 ponto se a posição estiver nos quatro cantos da matriz; 13 | * Menos 02 pontos, se já houver uma ou mais peças do adversário na mesma linha, coluna ou diagonal onde a posição se encontra; 14 | * Mais 04 pontos se a posição impedir a vitória do adversário; 15 | * Mais 04 pontos se a posição levar a uma vitória; 16 | 17 | Escolhendo sempre a jogada que da mais pontos, isso pode acelerar o processo de aprendizado total ou pelo menos melhorar o jogo inicial do Reiforcement Learning player 18 | ``` 19 | 20 | --- 21 | Resposta 2: 22 | 23 | ``` 24 | Se o jogador estava se adaptando com o tempo, as atualizações antigas poderiam acelerar a melhoria. Alterar a taxa de exploração / aprendizagem com base na variação nas ações do oponente. Se o oponente está sempre fazendo os mesmos movimentos e você está ganhando com ele, então o e-greedy com 10% de exploração só vai fazer você perder os jogos. Mesmo que o jogo da velha seja um jogo solucionável, isso pode não resultar no melhor resultado com um oponente abaixo do ideal. 25 | ``` 26 | -------------------------------------------------------------------------------- /Capítulo 1/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 1: Introduction - Exercises 2 | 3 | Exercises list: 4 | 5 | - [x] 1.1 6 | - [x] 1.2 7 | - [x] 1.3 8 | - [x] 1.3 9 | - [x] 1.5 10 | -------------------------------------------------------------------------------- /Capítulo 2/Ex_2.01.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 2.1:* 2 | 3 | **In *ε*-greedy action selection, for the case of two actions and *ε* = 0.5, what is the probability that the greedy action is selected?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | A probabilidade de selecionar a ação ótima converge para mais de 1 - ε, logo 10 | 11 | 1 - 0.5 = 0.5 12 | 13 | 0.5 é a probabilidade para encontrar a melhor ação 14 | ``` 15 | 16 | --- 17 | Resposta 2: 18 | 19 | ``` 20 | A probabilidade da ação greedy ser selecionada é de 0,75 21 | 22 | Justificativa: Existe duas formas da melhor ação ser escolhida: 23 | 24 | 1) O algoritmo escolhe a melhor ação: 1-ε, ou seja 0,5, é a probabilidade dele escolher a melhor ação 25 | 2) O algoritmo escolhe uma ação aleatória e essa ação é a melhor ação: ε * 0,5 = 0,5 * 0,5 = 0,25 26 | 27 | Somando as duas probabilidades temos 0,75 como sendo a probabilidade da melhor ação ser escolhida. 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /Capítulo 2/Ex_2.02.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 2.2*\n", 8 | "\n", 9 | "#### Bandit example Consider a k -armed bandit problem with k = 4 actions, denoted 1, 2, 3, and 4. Consider applying to this problem a bandit algorithm using \"-greedy action selection, sample-average action-value estimates, and initial estimates of $Q_1(a) = 0$, for all a. Suppose the initial sequence of actions and rewards is $A_1 = 1, R_1 = -1, A_2 = 2, R_2 = 1, A_3 = 2, R_3 = -2, A_4 = 2, R_4 = 2, A_5 = 3, R_5 = 0$. On some of these time steps the \" case may have occurred, causing an action to be selected at random. On which time steps did this definitely occur? On which time steps could this possibly have occurred?" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "$k = \\{1, 2, 3, 4\\}$\n", 19 | "\n", 20 | "* $A_1 = 1$, $R_1 = -1$\n", 21 | "* $A_2 = 2$, $R_2 = 1$\n", 22 | "* $A_3 = 2$, $R_3 = -2$\n", 23 | "* $A_4 = 2$, $R_4 = 2$\n", 24 | "* $A_5 = 3$, $R_5 = 0$\n", 25 | "\n", 26 | "Dado $Q_n = \\frac {1}{n}\\sum \\limits _{i=1} ^{n-1} R_i$\n", 27 | "\n", 28 | "Em $t=0$, para todo $n \\in Q$, $Q_n = 0$, logo $A_1$ pode ter sido escolhida tanto por $\\epsilon$ quanto por $1-\\epsilon$, pois todas possui a mesma recompensa esperada;\n", 29 | "\n", 30 | "Em $t=1$, $Q_1 = \\frac {0-1}{0+1} = -1$, logo $A_2$ pode ter sido escolhida tanto por $\\epsilon$ quanto por $1-\\epsilon$, pois não é a ação gulosa e mais de uma ação atende a propriedade $A_t \\dot{=} argmax _{a}Q_t(a)$;\n", 31 | "\n", 32 | "Em $t=2$, $Q_2 = \\frac {0+0+1}{1} = 1$, logo $A_3$ é a ação gulosa e foi provavelmente escolhido por $1 - \\epsilon$;\n", 33 | "\n", 34 | "Em $t=3$, $Q_2 = \\frac {0+0+1-2}{2} = -1.5$, logo $A_4$ não é a ação gulosa, tendo sido escolhido por $\\epsilon$;\n", 35 | "\n", 36 | "Em $t=4$, $Q_2 = \\frac {0+0+1-2+2}{3} = 0.333...$, logo, $A_5$ não é a ação gulosa, e é escolhida por $\\epsilon$;\n", 37 | "\n", 38 | "Em $t=5$, $Q_3 = 0$." 39 | ] 40 | } 41 | ], 42 | "metadata": { 43 | "kernelspec": { 44 | "display_name": "Python 3", 45 | "language": "python", 46 | "name": "python3" 47 | }, 48 | "language_info": { 49 | "codemirror_mode": { 50 | "name": "ipython", 51 | "version": 3 52 | }, 53 | "file_extension": ".py", 54 | "mimetype": "text/x-python", 55 | "name": "python", 56 | "nbconvert_exporter": "python", 57 | "pygments_lexer": "ipython3", 58 | "version": "3.8.5" 59 | } 60 | }, 61 | "nbformat": 4, 62 | "nbformat_minor": 4 63 | } -------------------------------------------------------------------------------- /Capítulo 2/Ex_2.02.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 2.2: Bandit example* 2 | 3 | **Consider a k-armed bandit problem with k = 4 actions, denoted 1, 2, 3, and 4. Consider applying to this problem a bandit algorithm using "-greedy action selection, sample-average action-value estimates, and initial estimates of Q1(a) = 0, for all a. Suppose the initial sequence of actions and rewards is A1 = 1, R1 = -1, A2 = 2, R2 = 1, A3 = 2, R3 = -2, A4 = 2, R4 = 2, A5 = 3, R5 = 0. On some of these time steps the ε case may have occurred, causing an action to be selected at random. On which time steps did this definitely occur? On which time steps could this possibly have occurred?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Foram executadas 5 ações, o que provoca 5 estados (s1, s2, s3, s4, s5), para cada time step temos as seguintes qualidades das ações (Q), considerando a equanção Action-Value, apenas ações com Q diferente de 0: 10 | A1 A2 A3 A4 A5 11 | - 1: 0, 0, 0, 0, 0 12 | - 2: 1, 0, 0, 0, 0 13 | - 3: 1, 1, 0, 0, 0 14 | - 4: 1, 1.5, 0, 0, 0 15 | - 5: 1, 1.67, 0, 0, 0 16 | 17 | Analisando cada momento individualmente, no que diz respeito a ação ε: 18 | - 1: Inicialmente todos os Qs são 0, a escolha da ação a1 pode ter sido escolhida ε ou 1 - ε. 19 | - 2: A ação a2 foi escolhida aqui, só pode ter sido aleatoriamente, visto que Q(A1) é o maior valor. 20 | - 3: Aqui, as ações a1 e a2 possuem Q iguais, e novamente a ação a2 foi escolhida, o que pode ter sido escolhido ε ou 1 - ε. 21 | - 4: Q(a2) é o maior valor, 1.5, pode ter sido a escolha gulosa (maior valor) ou aleátoria também (todas as ações têm a mesma probabilidade de serem escolhidas). 22 | - 5: Nesse caso, Q(a2) é o maior valor, 1.67, e foi escolhida a ação a3, o que demostra que foi aleatória, pois a ação gulosa, a2, não foi escolhida. 23 | 24 | Portanto, nos time steps 2 e 5, as ações foram escolhidas de forma aleátoria (ε), enquanto que no restante pode ter sido ε ou 1 - ε. 25 | ``` 26 | 27 | --- 28 | Resposta 2: 29 | 30 | ``` 31 | Primeira iteração = não temos certeza se a ação 1 foi escolhida aleatoriamente ou se foi por padrão (Ex: Se Q1(a) = 0 para todos os a, então a primeira ação deve ser escolhida) 32 | 33 | Segunda iteração = Foi exploração, já que a greedy action era a primeira ação 34 | 35 | Terceira iteração = Empate entre a primeira e segunda ação. Não temos certeza se foi uma escolha aleatória entre as duas ou se foi por padrão (Ex: Entre um empate, escolher a mais recente) 36 | 37 | Quarta iteração = Greedy action 38 | 39 | Quinta iteração = Foi exploração, já que a greedy action era a segunda ação 40 | ``` 41 | 42 | --- 43 | Resposta 3: 44 | 45 | ``` 46 | Valoração dos estados S1 = 0, S2 = 0, S3 = 0, S4 = 0 ----> Ação tomada = 1 47 | No primeiro passo é possivel que tenha sido uma ação 'e' afinal todos os estados tinha valoração igual a zero 48 | 49 | Valoração dos estados S1 = -1, S2 = 0, S3 = 0, S4 = 0 ----> Ação tomada = 2 50 | No segundo passo é possivel que tenha sido uma ação 'e' pois a melhor ação poderia ser S2, S3 ou S4 51 | 52 | Valoração dos estados S1 = -1, S2 = 1, S3 = 0, S4 = 0 ----> Ação tomada = 2 53 | No terceiro passo é possivel que tenha sido uma ação 'e' pois a melhor ação é 2 54 | 55 | Valoração dos estados S1 = -1, S2 = -0,5, S3 = 0, S4 = 0 ----> Ação tomada = 2 56 | No quarto passo é usado uma ação 'e' pois a melhor ação poderia ser 3 ou 4 57 | 58 | Valoração dos estados S1 = -1, S2 = 1/3, S3 = 0, S4 = 0 ----> Ação tomada = 3 59 | No quinto passo é usado uma ação 'e' pois a melhor ação é 2 60 | ``` -------------------------------------------------------------------------------- /Capítulo 2/Ex_2.03.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 2.3:* 2 | 3 | **In the comparison shown in Figure 2.2, which method will perform best in the long run in terms of cumupative reward and probability of selecting the best acton? How much better will it be? Express your answer quantitatively.** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | O método ε = 0.01 performa melhor ao longo do tempo, mesmo ε = 0.1 convergindo mais rápido, porém conforme o número de tentantivas cresce, ε = 0.01 tem desempenho superior. Isso ocorre porque, ambos convergem para um valor de recompensa ótimo quando o número de tentantivas tende ao infinito. Porém, como ε = 0.01 utiliza ações gulosas (greedy) em cerca de 99% das vezes, enquanto que o outro por 90%, serão escolhidas mais vezes a ação que maximize a recompensa, ou seja, o fator aleatório, será menor para ε = 0.01. 10 | 11 | Simulando quantitativamente o q*(a), ou seja, a recompensa ótima para cada ação, temos: 12 | 13 | Para ε = 0.01 --> 0.99 * 1.5 = 1.485 14 | Para ε = 0.1 --> 0.9 * 1.5 = 1.35 15 | 16 | Percebe-se que com ε = 0.01, é esperado uma recomensa maior. 17 | 18 | Ps.: Levei em consideração que a recompensa esperada para 1 - ε, ações aleatórias é 0, visto que, são desconhecidas e aleatórias. 19 | ``` 20 | 21 | --- 22 | Resposta 2: 23 | 24 | ``` 25 | Quando o "e-greedy" é médio o algoritmo pode escolher uma maquina muito ruim e por azar a recompensa dela for muito alta, dessa forma iria demorar mais para o algoritmo perceber que aquela maquina é de fato ruim. Com "e-greedy" é muito pequeno acontece algo pior pois com o raciocinio de sempre escolher a melhor ação o algoritmo pode achar uma maquina que lhe dar 3 como recompensa enquanto que a maioria das outras lhe dão -1. Porem pode existir uma maquina que lhe der 10 como média. A grande questão é escolher o valor certo da explotação/exploração 26 | ``` 27 | -------------------------------------------------------------------------------- /Capítulo 2/Ex_2.04.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### *Exercise 2.4*\n", 8 | "\n", 9 | "#### If the step-size parameters $ \\alpha_{n}$, are not constant, then the estimate $ Q_{n} $ is a weighted average of previously received rewards with a weighting different from that given by (2.6). What is the weighting on each prior reward for the general case, analogousto (2.6), in terms of the sequence of step-size parameters?" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "\n", 19 | "$Q_{n+1} = Q_{n} + \\frac{1}{n}[R_{n}-Q_{n}]$ \n", 20 | "\n", 21 | "$= \\frac{1}{n}R_{n} + Q_{n} - \\frac{1}{n}Q_{n}$ \n", 22 | "\n", 23 | "$= \\frac{1}{n}R_{n} + (1 - \\frac{1}{n})Q_{n}$ \n", 24 | "\n", 25 | "$= \\frac{1}{n}R_{n} + (1 - \\frac{1}{n})[\\frac{1}{n-1}R_{n-1} + (1-\\frac{1}{n-1})Q_{n-1}]$ \n", 26 | "\n", 27 | "$= \\frac{1}{n}R_{n} + [(1 - \\frac{1}{n})\\frac{1}{n-1}R_{n-1} + (1 - \\frac{1}{n})(1-\\frac{1}{n-1})Q_{n-1}]$\n", 28 | "\n", 29 | "$= \\frac{1}{n}R_{n} + [(1 - \\frac{1}{n})(\\frac{1}{n-1})R_{n-1} + (1 - \\frac{1}{n})(1-\\frac{1}{n-1})[(\\frac{1}{n-2})R_{n-2} + (1-\\frac{1}{n-2})Q_{n-2})]]$ \n", 30 | "\n", 31 | "$ ... $ \n", 32 | " \n", 33 | "o processo se repete até $(1-\\frac{1}{1})Q_{1}$. \n", 34 | " \n", 35 | "A equação pode ser reescrita da seguinte maneira: \n", 36 | "\n", 37 | "$= \\frac{1}{n}R_{n} + \\sum_{i=1}^{n-1}R_{i}(\\frac{1}{i}) \\prod_{k=i+1}^{n}(1-\\frac{1}{k})$ \n", 38 | "\n", 39 | "Portanto o $ R_{n} $ será ponderado por $ \\frac{1}{n} $ e os demais $ R_{i} $'s influenciarão $ (\\frac{1}{i}) \\prod_{k=i+1}^{n}(1-\\frac{1}{k}) $ no resultado." 40 | ] 41 | } 42 | ], 43 | "metadata": { 44 | "kernelspec": { 45 | "display_name": "Python 3", 46 | "language": "python", 47 | "name": "python3" 48 | }, 49 | "language_info": { 50 | "codemirror_mode": { 51 | "name": "ipython", 52 | "version": 3 53 | }, 54 | "file_extension": ".py", 55 | "mimetype": "text/x-python", 56 | "name": "python", 57 | "nbconvert_exporter": "python", 58 | "pygments_lexer": "ipython3", 59 | "version": "3.7.3" 60 | } 61 | }, 62 | "nbformat": 4, 63 | "nbformat_minor": 2 64 | } -------------------------------------------------------------------------------- /Capítulo 2/Ex_2.05.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### *Exercise 2.5 (programming)*\n", 8 | "\n", 9 | "#### Design and conduct an experiment to demonstrate the difficulties that sample-average methods have for nonstationary problems. Use a modified version of the 10-armed testbed in which all the q*(a) start out equal and then take independent random walks (say by adding a normally distributed increment with mean 0 and standard deviation 0.01 to all the q*(a) on each step). Prepare plots like Figure 2.2 for an action-value method using sample averages, incrementally computed, and another action-value method using a constant step-size parameter, ALPHA = 0.1. Use ÉPSILON = 0.1 and longer runs, say of 10,000 steps." 10 | ] 11 | }, 12 | { 13 | "source": [ 14 | "---\n", 15 | "#### Resposta 1:" 16 | ], 17 | "cell_type": "markdown", 18 | "metadata": {} 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 1, 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [ 26 | "import random\n", 27 | "import matplotlib.pyplot" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "class Bandit(object):\n", 37 | " '''\n", 38 | " One-armed bandit auto ajustável\n", 39 | " '''\n", 40 | " def __init__(self, mean = 0, variance = 1):\n", 41 | " self.__mean = 0\n", 42 | " self.__variance = 1\n", 43 | " \n", 44 | " def evaluate(self):\n", 45 | " return random.gauss(self.__mean, self.__variance)\n", 46 | " \n", 47 | " def adjust(self):\n", 48 | " self.__mean += random.gauss(0, 0.01)\n", 49 | " \n", 50 | " @property\n", 51 | " def variance(self):\n", 52 | " return self.__variance\n", 53 | " \n", 54 | " @property\n", 55 | " def mean(self):\n", 56 | " return self.__mean\n", 57 | " \n", 58 | " def __repr__(self):\n", 59 | " return \"{0}(mean={1}, variance={2})\".format(\n", 60 | " self.__class__.__name__, self.__mean, self.__variance\n", 61 | " )" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 3, 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "class Testbed():\n", 71 | " def __init__(self, k, epsilon, variances:list = None, seed=4):\n", 72 | " self.__arms = k\n", 73 | " self.__actions = [None] * (k)\n", 74 | " for i in range(k):\n", 75 | " variance = variances[i] if variances and variances[i] else 1\n", 76 | " self.__actions[i] = Bandit(0, variance=variance)\n", 77 | " self.__epsilon = epsilon\n", 78 | " self.__seed = seed\n", 79 | " random.seed(self.__seed)\n", 80 | " \n", 81 | " @property\n", 82 | " def k(self):\n", 83 | " return self.__arms\n", 84 | "\n", 85 | " @property\n", 86 | " def epsilon(self):\n", 87 | " return self.__epsilon\n", 88 | " \n", 89 | " @property\n", 90 | " def seed(self):\n", 91 | " return self.__seed\n", 92 | "\n", 93 | " def evaluate(self, action: int):\n", 94 | " if not (action < len(self.__actions)):\n", 95 | " raise IndexError(\"Ação escolhida inválida: {}\".format(action))\n", 96 | " rewards = [i.evaluate() for i in self.__actions]\n", 97 | " R = rewards[action]\n", 98 | " opt = max(list(range(self.k)), key = lambda x: rewards[x])\n", 99 | " optimal = True if opt == action else False\n", 100 | " for i in self.__actions:\n", 101 | " i.adjust()\n", 102 | " return R, optimal\n", 103 | "\n", 104 | " def reset(self):\n", 105 | " '''\n", 106 | " Necessário para reiniciar o ambiente\n", 107 | " '''\n", 108 | " random.seed(self.seed)\n", 109 | " for i in range(1, self.k):\n", 110 | " bandit = self.__actions[i]\n", 111 | " self.__actions[i] = Bandit(0, bandit.variance)\n", 112 | " del bandit\n", 113 | " \n", 114 | " def agent(self, alpha = 0):\n", 115 | " '''\n", 116 | " Algoritmo do agente (pg. 54)\n", 117 | " \n", 118 | " Assume por padrão alfa = 0. Se nenhum valor diferente de alfa for\n", 119 | " atribuído, o algoritmo funciona com avaliação de média de amostras\n", 120 | " \n", 121 | " return generator\n", 122 | " '''\n", 123 | " Q = [0] * (self.k)\n", 124 | " N = [0] * (self.k)\n", 125 | " total_R = 0\n", 126 | " total_optimal = 0\n", 127 | " i = 0\n", 128 | " while True:\n", 129 | " i += 1\n", 130 | " A = self.__select_action(Q)\n", 131 | " R, optimal = self.evaluate(A)\n", 132 | " N[A] += 1\n", 133 | " Q[A] += alpha*(R - Q[A]) if alpha else (R - Q[A])/N[A]\n", 134 | " total_R += R\n", 135 | " total_optimal += int(optimal)\n", 136 | " yield (total_R/i, total_optimal/i)\n", 137 | " \n", 138 | " def __select_action(self, action_list: list):\n", 139 | " '''\n", 140 | " Seleciona a ação com uma probabilidade 1 - Épsilon de exploração\n", 141 | " \n", 142 | " A lista de ações é embaralhada para que os empates sejam resolvidos\n", 143 | " de forma aleatória\n", 144 | " \n", 145 | " return int\n", 146 | " '''\n", 147 | " choices = list(range(self.k))\n", 148 | " random.shuffle(choices)\n", 149 | " greedy = max(choices, key=lambda i: action_list[i])\n", 150 | " w = [1 - self.epsilon, self.epsilon]\n", 151 | " return random.choices([greedy, random.choice(choices)],w)[0]" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 4, 157 | "metadata": {}, 158 | "outputs": [], 159 | "source": [ 160 | "SEED = 4\n", 161 | "BANDITS = 10\n", 162 | "ALPHA = 0.1\n", 163 | "EPSILON = 0.1\n", 164 | "STEPS = 10000" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": 5, 170 | "metadata": {}, 171 | "outputs": [], 172 | "source": [ 173 | "env = Testbed(BANDITS, EPSILON, seed=SEED)\n", 174 | "# Sample Average Method Agent\n", 175 | "sam = env.agent()\n", 176 | "rewards_sam = [0]\n", 177 | "optimal_sam = [0]\n", 178 | "for i in range(STEPS):\n", 179 | " r, o = next(sam)\n", 180 | " rewards_sam.append(r)\n", 181 | " optimal_sam.append(o)\n", 182 | "\n", 183 | "env.reset()\n", 184 | "\n", 185 | "# Constant Step-Size Agent\n", 186 | "rewards_css = [0]\n", 187 | "optimal_css = [0]\n", 188 | "css = env.agent(alpha=ALPHA) \n", 189 | "for i in range(STEPS):\n", 190 | " r, o = next(css)\n", 191 | " rewards_css.append(r)\n", 192 | " optimal_css.append(o)" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": 6, 198 | "metadata": {}, 199 | "outputs": [ 200 | { 201 | "data": { 202 | "text/plain": [ 203 | "" 204 | ] 205 | }, 206 | "execution_count": 6, 207 | "metadata": {}, 208 | "output_type": "execute_result" 209 | }, 210 | { 211 | "data": { 212 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAA8mUlEQVR4nO3deXwUVbbA8d/JHpJAIAkhEMK+7xB2VBARRJRRUcAVdWTUccPZ9I2jDjrPZXxuo6PiqKijyIDiIDMuIKiA7Mi+yBZ2CAlkJ2uf90c1IYStgXQ6SZ/v59OfrrpV3X0qBXWqbt26V1QVY4wx/ivA1wEYY4zxLUsExhjj5ywRGGOMn7NEYIwxfs4SgTHG+LkgXwdwrmJjY7Vp06a+DsMYY6qVFSt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4aDGygBu9nnCqhPiJSy/3v/Ng219j9XEaF7Ff3siwR6eP+G95a5rtOz9c3TSrx5sxwnBY224A/+jqeC9iOATiXjWuAVe7XcJy60W+BLcAcoJ57fQFed2/3WiC5zHfdAWx1v2739bZ5uP0DOd5qqDnOf/CtwDQg1F0e5p7f6l7evMzn/+j+W2zGg9YUPt7WrsBy977+HKd1SI3ez8CfgU3AOuBDnJY/NWo/A1Nw7oEU4Vz53VmR+xVIdv/9tgGvUa7Bwale1sWEMcb4OX+pGjLGGHMalgiMMcbPWSIwxhg/Z4nAGGP8nCUCY4zxc5YIjDkNEfmjuyfMNSKySkR6i8hDIlLL17EZU5Gs+agxpyAifYEXgYGqWiAisTg9gP6I05Y7zacBGlOB7IrAmFNLANJUtQDAfeAfhdMHzjwRmQcgIpeLyCIRWSki09x9QCEiKSLyvLtf+KUi0tJdfr27r/3VIvKDbzbNmBPZFYExp+A+oC8AauE86TlVVb9393eUrKpp7quEz3CeXM0VkT/gPPU60b3e26r6FxG5FbhBVUeIyFpgmKruFZFoVc3wxfYZU5ZdERhzCqqaA/QAxuN0Bz1VRMaVW60PziAoC0VkFU4fMU3KLJ9S5r2ve3ohMFlE7sIZMMkYnws6+yrG+CdVLQG+A75zn8mXH+ZRgNmqOvZ0X1F+WlXvFpHewJXAChHpoarpFRu5MefGrgiMOQURaSMircoUdQV2Atk4Q4QCLAb6l6n/jxCR1mU+M7rM+yL3Oi1UdYmqPo5zpVG2K2FjfMKuCIw5tUjgbyISDRTj9PA4Hmfov69EZJ+qDnJXF00RkVD35x7D6eUWoK6IrAEK3J8D+Ks7wQhOb5OrK2NjjDkTu1lsjBeUvans61iMORurGjLGGD9nVwTGGOPn7IrAGGP8nCUCY4zxc5YIjDHGz1kiMMYYP2eJwBhj/Nz/A7IUEPYQEE31AAAAAElFTkSuQmCC\n", 213 | "text/plain": [ 214 | "
" 215 | ] 216 | }, 217 | "metadata": { 218 | "needs_background": "light" 219 | }, 220 | "output_type": "display_data" 221 | } 222 | ], 223 | "source": [ 224 | "# Average Reward\n", 225 | "reward = matplotlib.pyplot.figure(1)\n", 226 | "matplotlib.pyplot.ylabel(\"Average reward\")\n", 227 | "matplotlib.pyplot.xlabel(\"Steps\")\n", 228 | "matplotlib.pyplot.plot(rewards_sam, label=\"Sample Average\")\n", 229 | "matplotlib.pyplot.plot(rewards_css, label= \"Constant Step\")\n", 230 | "matplotlib.pyplot.legend()" 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": 7, 236 | "metadata": {}, 237 | "outputs": [ 238 | { 239 | "data": { 240 | "text/plain": [ 241 | "" 242 | ] 243 | }, 244 | "execution_count": 7, 245 | "metadata": {}, 246 | "output_type": "execute_result" 247 | }, 248 | { 249 | "data": { 250 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAA3iElEQVR4nO3deXhU1fnA8e+byb4RkrAJJEBYhGBAiSyiguCCFrUuFWhptS5ULa3V1oo/raVqq9VWrZZW6YYbSEVBoK4IKiCyGnbZA4QlgUD2bTJzfn/cmzAJIQyYyWQy7+d58szd5ua9uXDfe8859xwxxqCUUip4hfg7AKWUUv6liUAppYKcJgKllApymgiUUirIaSJQSqkgF+rvAM5UcnKy6datm7/DUEqpgLJ27dqjxph2Da0LuETQrVs31qxZ4+8wlFIqoIjI3lOt06IhpZQKcpoIlFIqyGkiUEqpIKeJQCmlgpwmAqWUCnKaCJRSKshpIlBKqSAXcO8RKKVUwKgqA1cluF1QWQylR6AsH1xOcJZDdTkYNyDgqoLKIjBAdCJICDjLrHWOMKiuhB4joON5TR6mJgKlVHCproKKQmu6/BiU5FkX6+pKcFdDZQkUH7SWG2NdqF2VUHQISvOs9VWl1vbGBVFtrQs1Yi0PcZy48DtLmzb2a/6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PnXb64zK78vh304kIPbMuKBwhwvCeyaz9zRW1yxb/auS3DVmpZve7BZvZcrCoSffZ75x4fntteoPrDh06RHJyMhER1tNwcnJy7brHH3+cBQsWUF5ezkUXXcQrr7yCiDBy5EjOP/98li5dSmlpKa+99hpPPfUUGzduZNy4cTz55JNkZ2czZswYBg0axLp160hPT+e1114jOjq6zu//+OOP+e1vf0tlZSVpaWn85z//ITY29qQ4Z82axX333cff//53VqxYwdChQ+nRowdZWVkkJCQA0KtXL5YtW0ZISAh33303+/ZZAz+98MILDB8+nKlTp7Jr1y52795NSkoKTz31FD/84Q8pLbVuGP/6179y0UUX4Xa7mTx5MosXL6Zr166EhYVx++23c/PNN7N27VoeeOABSkpKSE5OZsaMGXTq1Olbn6MgapNo3ZF/NXImX04Zxa/HnIuIMLRHYu0Wf7w544yTgFLq7F155ZXs37+f3r17c++99/L555/Xrps8eTKrV69m06ZNlJeXs3Dhwtp14eHhrFmzhrvvvpvrr7+eadOmsWnTJmbMmEF+fj4A27Zt495772Xr1q3Ex8fzt7/9rc7vPnr0KE8++SSLFi1i3bp1ZGZm8txzz50UY0VFBYsWLeLaa69lwoQJzJo1i5CQEK6//nrmzp0LwMqVK0lNTaVDhw7cd9993H///axevZp33nmHO++8s3ZfW7ZsYdGiRcyaNYv27dvzySefsG7dOmbPns3Pf/5zAN59912ys7PZsmULr7/+OitWrACs9z1+9rOfMWfOHNauXcvtt9/OI4880iTnIWieCGokxsfWVtoCzLprKO+sO8CI3tpjp1KnunP3ldjYWNauXcvSpUtZsmQJ48aN4+mnn+a2225jyZIlPPPMM5SVlXHs2DHS09O59tprAbjuuusAOO+880hPT6+9K+7Rowf79+8nISGBrl27Mnz4cAAmTpzIiy++yK9+9ava3/3VV1+xZcuW2m2qqqoYNmzYSTEuXLiQyy67jKioKG666SaeeOIJXnjhBcaNG8fjjz/Oj3/8Y9566y3GjRsHwKJFi9iyZUvt94uKiigpKamNOyrKuv44nU4mT55MVlYWDoeD7du3A7Bs2TK+973vER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255 | "metadata": { 256 | "needs_background": "light" 257 | }, 258 | "output_type": "display_data" 259 | } 260 | ], 261 | "source": [ 262 | "# Average Optimal Choice\n", 263 | "optimal_choice = matplotlib.pyplot.figure(2)\n", 264 | "matplotlib.pyplot.ylabel(\"% Optimal action\")\n", 265 | "matplotlib.pyplot.xlabel(\"Steps\")\n", 266 | "matplotlib.pyplot.plot(optimal_sam, label= \"Sample Average\")\n", 267 | "matplotlib.pyplot.plot(optimal_css, label= \"Constant Step\")\n", 268 | "matplotlib.pyplot.legend()" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [] 277 | } 278 | ], 279 | "metadata": { 280 | "kernelspec": { 281 | "display_name": "Python 3", 282 | "language": "python", 283 | "name": "python3" 284 | }, 285 | "language_info": { 286 | "codemirror_mode": { 287 | "name": "ipython", 288 | "version": 3 289 | }, 290 | "file_extension": ".py", 291 | "mimetype": "text/x-python", 292 | "name": "python", 293 | "nbconvert_exporter": "python", 294 | "pygments_lexer": "ipython3", 295 | "version": "3.8.5" 296 | } 297 | }, 298 | "nbformat": 4, 299 | "nbformat_minor": 2 300 | } -------------------------------------------------------------------------------- /Capítulo 2/Ex_2.06.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 2.6: Mysterious Spikes* 2 | 3 | **The results shown in Figure 2.3 should be quite reliable because they are averages over 2000 individual, randomly chosen 10-armed bandit tasks. Why, then, are there oscillations and spikes in the early part of the curve for the optimistic method? In other words, what might make this method perform particularly better or worse, on average, on particular early steps?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | O método otimista tem ou pode ter picos na fase inicial porque o agente busca usar mais a exploitação do que a exploração. 10 | Ou seja, a tendência é que ele busque ações que possam ter boas recompensas imediatas 11 | em vez de explorar várias ações diferentes procurando formar uma "opinião" sobre determinada ação. 12 | ``` 13 | -------------------------------------------------------------------------------- /Capítulo 2/Ex_2.10.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 2.10:* 2 | 3 | **Suppose you face a 2-armed bandit task whose true action values change randomly from time step to time step. Specifically, suppose that, for any time step, the true values of actions 1 and 2 are respectively 0.1 and 0.2 with probability 0.5 (case A), and 0.9 and 0.8 with probability 0.5 (case B). If you are not able to tell which case you face at any step, what is the best expectation of success you can achieve and how should you behave to achieve it? Now suppose that on each step you are told whether you are facing case A or case B (although you still don’t know the true action values). This is an associative search task. What is the best expectation of success you can achieve in this task, and how should you behave to achieve it?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | No primeiro caso não é conhecido o caso que está sendo tratado, a melhor solução é escolher a opção que possua a melhor estimativa de valor em combinação. Entretando eles possuem valores iguais: 10 | 11 | A1 = 0.5 * 0.1 + 0.5 * 0.9 = 0.5 12 | 13 | A2 = 0.5 * 0.2 + 0.5 * 0.8 = 0.5 14 | 15 | Portando a melhor expectativa de sucesso é 0.5 e o comportamento que se deve adotar é escolher aleatóriamente uma ação em cada etapa. 16 | 17 | No segundo caso é informado previamente o caso a ser enfrentado, portanto nós tratamos eles como problemas independentes, explorando os mesmos para assim podermos aprender a melhor ação para cada um. A melhor expectativa de sucesso é 0.55: 18 | 19 | 0.2 * 0.5 + 0.9 * 0.5 = 0.55 20 | ``` -------------------------------------------------------------------------------- /Capítulo 2/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 2: Multi-armed Bandits - Exercises 2 | 3 | Exercises list: 4 | 5 | - [x] 2.1 6 | - [x] 2.2 7 | - [x] 2.3 8 | - [x] 2.3 9 | - [x] 2.5 10 | - [x] 2.6 11 | - [ ] 2.7 12 | - [ ] 2.8 13 | - [ ] 2.9 14 | - [x] 2.10 15 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.01.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.1:* 2 | 3 | **Devise three example tasks of your own that fit into the MDP framework, identifying for each its states, actions, and rewards. Make the three examples as different from each other as possible. The framework is abstract and flexible and can be applied in many different ways. Stretch its limits in some way in at least one of your examples.** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | * Exemplo 1: 10 | Em um jogo de Xadrez, a próxima ação depende apenas da disposição das peças nos tabuleiros. Em uma MDP o estado é a disposição das peças no tabuleiro, a ação é o movimento que o agente realiza a partir de uma das peças, a recompensa é dada ao fim do turno do adversário e é atribuída a partir da diferença entre pontuação conseguida através da conquista de peças e a pontuação cedida ao adversário a partir da perda de peças. 11 | 12 | * Exemplo 2: 13 | 14 | * Exemplo 3: 15 | ``` 16 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.02.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.2:* 2 | 3 | **Is the MDP framework adequate to usefully represent all goal-directed learning tasks? Can you think of any clear exceptions?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Um caso onde eu acredito que não seja adequado a utilização o MDP é quando nos deparamos com um conjunto de estados e/ou conjunto de ações infinitas, como também se as informações da sequência estiverem incompleta ou até mesmo indisponíveis, outro caso é quando os estados são difíceis de compreender ou não é possivel representar-los numericamente. 10 | ``` 11 | 12 | --- 13 | Resposta 2: 14 | 15 | ``` 16 | MDP não é adequado em diversos cenários como por exemplo jogo de Xadrez onde o oponente apresenta centenas de jogadas com probabilidade não definida. Jogo de futebol de robôs apresentam diversos estados e probabilidade nao definida quando tomamos uma determinada ação. 17 | ``` 18 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.03.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.3:* 2 | 3 | **Consider the problem of driving. You could define the actions in terms of the accelerator, steering wheel, and brake, that is, where your body meets the machine. Or you could define them farther out—say, where the rubber meets the road, considering your actions to be tire torques. Or you could define them farther in—say, where your brain meets your body, the actions being muscle twitches to control your limbs. Or you could go to a really high level and say that your actions are your choices of where to drive. What is the right level, the right place to draw the line between agent and environment? On what basis is one location of the line to be preferred over another? Is there any fundamental reason for preferring one location over another, or is it a free choice?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Depende do objetivo que o modelador quer alcançar. Creio que o mais correto nessa situação é entender o problema que o algoritmo vai sanar e escolher os elementos que o agente venha a possuir um maior controle sobre o estado por meio das suas ações realizadas. 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.05.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 3.5*\n", 8 | "\n", 9 | "#### The equations in Section 3.1 are for the continuing case and need to be modified (very slightly) to apply to episodic tasks. Show that you know the modifications needed by giving the modified version of (3.3)." 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "$\\sum \\limits_{s \\in s ^+ } \\sum \\limits _{r \\in R} p(s',r|s,a)=1$" 19 | ] 20 | } 21 | ], 22 | "metadata": { 23 | "kernelspec": { 24 | "display_name": "Python 3", 25 | "language": "python", 26 | "name": "python3" 27 | }, 28 | "language_info": { 29 | "codemirror_mode": { 30 | "name": "ipython", 31 | "version": 3 32 | }, 33 | "file_extension": ".py", 34 | "mimetype": "text/x-python", 35 | "name": "python", 36 | "nbconvert_exporter": "python", 37 | "pygments_lexer": "ipython3", 38 | "version": "3.8.5" 39 | } 40 | }, 41 | "nbformat": 4, 42 | "nbformat_minor": 4 43 | } -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.06.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 3.6*\n", 8 | "\n", 9 | "#### Suppose you treated pole-balancing as an episodic task but also used discounting, with all rewards zero except for -1 upon failure. What then would the return be at each time? How does this return differ from that in the discounted, continuing formulation of this task?" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "A taxa de disconto determina que uma recompensa recebida em k passos vale $\\gamma^{k-1}$, logo, a recompensa no tempo t é dada por:\n", 19 | "\n", 20 | "$G_{t}=-\\gamma^{T-t}$, onde T é o tempo do estado Terminal\n", 21 | "\n", 22 | "A recompensa em t na formulação continua é dada por:\n", 23 | "\n", 24 | "$G_{t}=\\sum \\limits _{k \\in K} \\gamma^{k-t}$, onde K é o conjunto de todos os tempos antes de tempo do estado terminal" 25 | ] 26 | } 27 | ], 28 | "metadata": { 29 | "kernelspec": { 30 | "display_name": "Python 3", 31 | "language": "python", 32 | "name": "python3" 33 | }, 34 | "language_info": { 35 | "codemirror_mode": { 36 | "name": "ipython", 37 | "version": 3 38 | }, 39 | "file_extension": ".py", 40 | "mimetype": "text/x-python", 41 | "name": "python", 42 | "nbconvert_exporter": "python", 43 | "pygments_lexer": "ipython3", 44 | "version": "3.8.5" 45 | } 46 | }, 47 | "nbformat": 4, 48 | "nbformat_minor": 4 49 | } -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.06.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.6:* 2 | 3 | **Suppose you treated pole-balancing as an episodic task but also used 4 | discounting, with all rewards zero except for 1 upon failure. What then would the 5 | return be at each time? How does this return differ from that in the discounted, continuing 6 | formulation of this task?** 7 | 8 | --- 9 | Resposta 1: 10 | 11 | ``` 12 | Seria o mesmo: -−γ elevado a k, onde k estaria em um intervalo de tempo 13 | 14 | Em uma tarefa contínua, o gamma serve para que o retorno não seja infinito, não exploda. Já na tarefa episódica, isso não acontece, dessa forma, o uso do gamma pode ser considerado inútil 15 | ``` 16 | 17 | --- 18 | Resposta 2: 19 | 20 | ``` 21 | Quando o agente se movimenta e o bastão não cai então recebe 0 de recompensa e 22 | quando o bastão cai recebe -1 de recompensa. Dessa forma analisando a formula do Ganho teremos: 23 | 24 | G = R1 + yR2 + y²R3 + y3R4 + ... + y^(K+1)RK 25 | como o episodio termina quando o bastao e quando nao cai recebe recompensa 0 então: 26 | G = 0 + y0 + y²0 + y0 + ... + y^(K+1)-1 27 | De modo que só iria importar o estado final daquele episodio 28 | ``` -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.07.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 3.7*\n", 8 | "\n", 9 | "#### Imagine that you are designing a robot to run a maze. You decide to give it a reward of +1 for escaping from the maze and a reward of zero at all other times. The task seems to break down naturally into episodes—the successive runs through the maze—so you decide to treat it as an episodic task, where the goal is to maximize expected total reward (3.7). After running the learning agent for a while, you find that it is showing no improvement in escaping from the maze. What is going wrong? Have you e↵ectively communicated to the agent what you want it to achieve?" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "O retorno das recompensas em um caso contínuo é dado por:\n", 19 | "\n", 20 | "$G_{t}=R_{t+1}+R_{t+2}+...+R_{T}$;\n", 21 | "\n", 22 | "Dado que a recompensa para passos dentro do labirínto é de $1$ para estados terminal e $0$ para todos o outros, temos que:\n", 23 | "\n", 24 | "$G_{T}=1$;\n", 25 | "\n", 26 | "Considerando que o agente continua executando passos aleatórios até $t=\\infty$ ou $t = T$, o estado terminal será eventualmente alcançado, no entanto, qualquer estratégia resultará em recompensa $1$.\n", 27 | "\n", 28 | "Nesse caso, é mais eficiente ensinar o agente a sair do labirinto o quanto antes, dando recompensa $0$ para o estado terminal e $-1$ para qualquer outra movimentação dentro do labirínto, assim o agente maximiza a recompensa do episódio a partir da diminuição do número de passos no labirínto." 29 | ] 30 | } 31 | ], 32 | "metadata": { 33 | "kernelspec": { 34 | "display_name": "Python 3", 35 | "language": "python", 36 | "name": "python3" 37 | }, 38 | "language_info": { 39 | "codemirror_mode": { 40 | "name": "ipython", 41 | "version": 3 42 | }, 43 | "file_extension": ".py", 44 | "mimetype": "text/x-python", 45 | "name": "python", 46 | "nbconvert_exporter": "python", 47 | "pygments_lexer": "ipython3", 48 | "version": "3.8.5" 49 | } 50 | }, 51 | "nbformat": 4, 52 | "nbformat_minor": 4 53 | } -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.08.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 3.8*\n", 8 | "\n", 9 | "#### Suppose $\\gamma = 0.5$ and the following sequence of rewards is received $R_{1} = -1$, $R_{2} = 2$, $R_{3} = 6$, $R_{4} = 3$, and $R_{5} = 2$, with $T = 5$. What are $G_{0}$, $G_{1}$, ..., $G_{5}$ ? Hint: Work backwards." 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "Dado que:\n", 19 | "\n", 20 | "$G_{t} = R_{t+1} + \\gamma G_{t+1}$\n", 21 | "\n", 22 | "Temos:\n", 23 | "\n", 24 | "Uma vez que $G_{T} = 0$, temos $G_{5} = 0$;\n", 25 | "\n", 26 | "$G_{4} = R_{5} + \\gamma G_{5} = 2 + 0.5 * 0 = 2$;\n", 27 | "\n", 28 | "$G_{3} = R_{4} + \\gamma G_{3} = 3 + 0.5 * 2 = 4$;\n", 29 | "\n", 30 | "$G_{2} = R_{3} + \\gamma G_{3} = 6 + 0.5 * 4 = 8$;\n", 31 | "\n", 32 | "$G_{1} = R_{2} + \\gamma G_{2} = 2 + 0.5 * 8 = 6$;\n", 33 | "\n", 34 | "$G_{0} = R_{1} + \\gamma G_{1} = -1 + 6 * 0.5 = 2$" 35 | ] 36 | } 37 | ], 38 | "metadata": { 39 | "kernelspec": { 40 | "display_name": "Python 3", 41 | "language": "python", 42 | "name": "python3" 43 | }, 44 | "language_info": { 45 | "codemirror_mode": { 46 | "name": "ipython", 47 | "version": 3 48 | }, 49 | "file_extension": ".py", 50 | "mimetype": "text/x-python", 51 | "name": "python", 52 | "nbconvert_exporter": "python", 53 | "pygments_lexer": "ipython3", 54 | "version": "3.8.5" 55 | } 56 | }, 57 | "nbformat": 4, 58 | "nbformat_minor": 4 59 | } -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.08.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.8:* 2 | 3 | **Suppose y = 0.5 and the following sequence of rewards is received R 1 = 1, 4 | R 2 = 2, R 3 = 6, R 4 = 3, and R 5 = 2, with T = 5. What are G 0 , G 1 , . . ., G 5 ? Hint: 5 | Work backwards.** 6 | 7 | --- 8 | Resposta 1: 9 | 10 | ``` 11 | Fazendo de maneira mais trabalhosa 12 | G = R1 + y*R2 + y²R3 + y3R4 + ... + y^(K+1)*RK 13 | 14 | 15 | G0 = -1 + 0.5*2 + 0.5²*6 + 0.5³*3 + 0,5⁴*2 16 | G0 = 2 17 | 18 | G1 = 2 + 0.5*6 + 0.5²*3 + 0,5³*2 19 | G1 = 6 20 | 21 | G2 = 6 + 0.5*3 + 0,5²*2 22 | G2 = 8 23 | 24 | G3 = 3 + 0,5*2 25 | G3 = 4 26 | 27 | G4 = 2 28 | 29 | G5 = 0 30 | 31 | 32 | 33 | Fazendo seguindo a dica do livro 34 | Gt = Rt+1 + y*Gt+1 35 | 36 | G5 = 0 37 | G4 = 2 + 0.5*G5 = 2 38 | G3 = 3 + 0.5*G4 = 4 39 | G2 = 6 + 0.5*G3 = 8 40 | G1 = 2 + 0.5*G2 = 6 41 | G0 = -1 + 0.5*G1 = 2 42 | ``` 43 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.09.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 3.9*\n", 8 | "\n", 9 | "#### Suppose $\\gamma = 0.9$ and the reward sequence is $R_{1} = 2$ followed by an infinite sequence of 7s. What are $G_{1}$ and $G_{0}$?" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "Temos,\n", 19 | "\n", 20 | "$G_{t} = R_{t+1} + \\gamma R_{t+2} + \\gamma^2 R_{t+3} ...$;\n", 21 | "\n", 22 | "Logo,\n", 23 | "\n", 24 | "$G_{1} = R_{2} + \\gamma R_{3} + \\gamma^2 R_{4} + ...$;\n", 25 | "\n", 26 | "$G_{1} = 7 + 7 \\gamma + 7 \\gamma^2 + ...$;\n", 27 | "\n", 28 | "$G_{1} = 7 \\sum \\limits _{k=0} ^{\\infty} = \\gamma^k$;\n", 29 | "\n", 30 | "$G_{1} = \\frac {7}{1 - \\gamma}$;\n", 31 | "\n", 32 | "Com $\\gamma = 0.9$,\n", 33 | "\n", 34 | "$G_{1} = \\frac {7}{1 - 0.9} = \\frac {7}{0.1} = 70$;\n", 35 | "\n", 36 | "Ainda,\n", 37 | "\n", 38 | "$G_{t} = R_{t+1} + \\gamma G_{t+1}$;\n", 39 | "\n", 40 | "$G_{0} = R_{1} + \\gamma G_{1}$;\n", 41 | "\n", 42 | "$G_{0} = 2 + 0.9 * 70 = 2 + 63 = 65$;" 43 | ] 44 | } 45 | ], 46 | "metadata": { 47 | "kernelspec": { 48 | "display_name": "Python 3", 49 | "language": "python", 50 | "name": "python3" 51 | }, 52 | "language_info": { 53 | "codemirror_mode": { 54 | "name": "ipython", 55 | "version": 3 56 | }, 57 | "file_extension": ".py", 58 | "mimetype": "text/x-python", 59 | "name": "python", 60 | "nbconvert_exporter": "python", 61 | "pygments_lexer": "ipython3", 62 | "version": "3.8.5" 63 | } 64 | }, 65 | "nbformat": 4, 66 | "nbformat_minor": 4 67 | } -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.10.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 3.10*\n", 8 | "\n", 9 | "#### Prove the second equality in (3.10)\n", 10 | "\n", 11 | "#### (3.10) $G_{t} = \\sum \\limits _{k=0}^{\\infty} \\gamma ^{k}= \\frac{1}{1-\\gamma}$;" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "---\n", 19 | "#### Resposta 1:\n", 20 | "$G_{t} \\dot{=} \\sum \\limits _{k=0} ^{\\infty} \\gamma^{k}R_{t+k+1}$;\n", 21 | "\n", 22 | "$\\sum \\limits _{k=0} ^{\\infty} \\gamma^{k}R_{t+k+1} = \\sum \\limits _{k=0} ^{\\infty} \\gamma^{k}$;\n", 23 | "\n", 24 | "$G_{t} = \\sum \\limits _{k=0} ^{\\infty} \\gamma^{k}$;\n", 25 | "\n", 26 | "$G_{t}\\gamma = \\sum \\limits _{k=0} ^{\\infty} \\gamma^{k*1}$;\n", 27 | "\n", 28 | "$G_{t}\\gamma - G_{t} = \\sum \\limits _{k=0} ^{\\infty} \\gamma^{k+1} - \\gamma^{k}$;\n", 29 | "\n", 30 | "$G_{t}(\\gamma -1) = lim _{k \\to \\infty} \\gamma^{k+1} - 1$;\n", 31 | "\n", 32 | "$G_{T} = lim _{k \\to \\infty} \\frac{\\gamma ^{k+1} -1}{\\gamma -1}$;\n", 33 | "\n", 34 | "$G_{T} = lim _{k \\to \\infty} \\frac{1 - \\gamma ^{k+1}}{1 - \\gamma}$;\n", 35 | "\n", 36 | "Assumindo $0 < \\gamma < 1$, temos:\n", 37 | "\n", 38 | "$lim _{k \\to \\infty} \\gamma^{k+1} = 0$;\n", 39 | "\n", 40 | "Logo,\n", 41 | "\n", 42 | "$G_{T} = \\frac{1}{1 - \\gamma}$;" 43 | ] 44 | } 45 | ], 46 | "metadata": { 47 | "kernelspec": { 48 | "display_name": "Python 3", 49 | "language": "python", 50 | "name": "python3" 51 | }, 52 | "language_info": { 53 | "codemirror_mode": { 54 | "name": "ipython", 55 | "version": 3 56 | }, 57 | "file_extension": ".py", 58 | "mimetype": "text/x-python", 59 | "name": "python", 60 | "nbconvert_exporter": "python", 61 | "pygments_lexer": "ipython3", 62 | "version": "3.8.5" 63 | } 64 | }, 65 | "nbformat": 4, 66 | "nbformat_minor": 4 67 | } -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.11.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise X.X*\n", 8 | "\n", 9 | "#### {question}" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "{Solution}" 19 | ] 20 | } 21 | ], 22 | "metadata": { 23 | "kernelspec": { 24 | "display_name": "Python 3", 25 | "language": "python", 26 | "name": "python3" 27 | }, 28 | "language_info": { 29 | "codemirror_mode": { 30 | "name": "ipython", 31 | "version": 3 32 | }, 33 | "file_extension": ".py", 34 | "mimetype": "text/x-python", 35 | "name": "python", 36 | "nbconvert_exporter": "python", 37 | "pygments_lexer": "ipython3", 38 | "version": "3.8.5" 39 | } 40 | }, 41 | "nbformat": 4, 42 | "nbformat_minor": 4 43 | } -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.11.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.11:* 2 | 3 | **If the current state is St, and actions are selected according to a stochastic policy π, then what is the expectation of Rt+1 in terms of π and the four-argument function p (3.2)?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Eπ[Rt+1 | St = s] = Σ[π(a|s) * p(s', r | s, a) * r], para todo s' ∈ S, a ∈ A(s) 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.12.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise X.X*\n", 8 | "\n", 9 | "#### {question}" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "{Solution}" 19 | ] 20 | } 21 | ], 22 | "metadata": { 23 | "kernelspec": { 24 | "display_name": "Python 3", 25 | "language": "python", 26 | "name": "python3" 27 | }, 28 | "language_info": { 29 | "codemirror_mode": { 30 | "name": "ipython", 31 | "version": 3 32 | }, 33 | "file_extension": ".py", 34 | "mimetype": "text/x-python", 35 | "name": "python", 36 | "nbconvert_exporter": "python", 37 | "pygments_lexer": "ipython3", 38 | "version": "3.8.5" 39 | } 40 | }, 41 | "nbformat": 4, 42 | "nbformat_minor": 4 43 | } -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.12.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.12:* 2 | 3 | **Give an equation for vπ in terms of qπ and π.** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | vπ(s) = Eπ[Gt | St = s] = Σ[π(a|s) * qπ(s, a)], para todo a ∈ A(s) 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.13.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.13:* 2 | 3 | **Give an equation for q⇡ in terms of v⇡ and the four-argument p** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | qπ(s,a) = Σs' Σr p(s′,r | s,a)[r + γvπ(s′)], para todo s' ∈ S e r ∈ ℝ 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.14.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.14:* 2 | 3 | **The Bellman equation (3.14) must hold for each state for the value function vπ shown in Figure 3.2 (right) of Example 3.5. Show numerically that this equation holds for the center state, valued at +0.7, with respect to its four neighboring states, valued at +2.3, +0.4, -0.4, and +0.7. (These numbers are accurate only to one decimal place.)** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | 0.25 * (0 + 0.9 * 2.3) + 0.25 * (0 + 0.9 * 0,4) + 0.25 * (0 - 0.9 * 0.4) + 0.25 * (0 + 0.9 * 0.7) 10 | 11 | = 0.5175 + 0.09 - 0.09 + 0.1575 = 0.675 12 | 13 | Arredondando para uma casa decimal ≅ 0.7 14 | ``` 15 | -------------------------------------------------------------------------------- /Capítulo 3/Ex_3.22.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 3.22:* 2 | 3 | **Consider the continuing MDP shown to the right. The only decision to be made is that in the top state, where two actions are available, left and right. The numbers show the rewards that are received deterministically after each action. There are exactly two deterministic policies, πleft and πright. What policy is optimal if γ = 0? If γ = 0.9? If γ = 0.5?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Para γ = 0: 10 | vπleft(left) = 1 + γ * 0 = 1 + 0 * 0 = 1 11 | vπright(right) = 0 + γ * 2 = 0 + 0 * 2 = 0 12 | 13 | A política ótima para γ = 0 é vπleft. 14 | 15 | Para γ = 0.9: 16 | vπleft(left) = 1 + γ * 0 = 1 + 0.9 * 0 = 1 17 | vπright(right) = 0 + γ * 2 = 0 + 0.9 * 2 = 1.8 18 | 19 | A política ótima para γ = 0.9 é vπright. 20 | 21 | Para γ = 0.5: 22 | vπleft(left) = 1 + γ * 0 = 1 + 0.5 * 0 = 1 23 | vπright(right) = 0 + γ * 2 = 0 + 0.5 * 2 = 1 24 | 25 | Para γ = 0.5, tanto vπleft quanto vπright são políticas ótimas. 26 | ``` 27 | -------------------------------------------------------------------------------- /Capítulo 3/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 3: Finite Markov Decision Processes - Exercises 2 | 3 | Exercises list: 4 | 5 | - [x] 3.1 6 | - [x] 3.2 7 | - [x] 3.3 8 | - [ ] 3.4 9 | - [x] 3.5 10 | - [x] 3.6 11 | - [x] 3.7 12 | - [x] 3.8 13 | - [x] 3.9 14 | - [x] 3.10 15 | - [x] 3.11 16 | - [x] 3.12 17 | - [x] 3.13 18 | - [x] 3.14 19 | - [ ] 3.15 20 | - [ ] 3.16 21 | - [ ] 3.17 22 | - [ ] 3.18 23 | - [ ] 3.19 24 | - [ ] 3.20 25 | - [ ] 3.21 26 | - [x] 3.22 27 | - [ ] 3.23 28 | - [ ] 3.24 29 | - [ ] 3.25 30 | - [ ] 3.26 31 | - [ ] 3.27 32 | - [ ] 3.28 33 | - [ ] 3.29 34 | -------------------------------------------------------------------------------- /Capítulo 4/Ex_4.01.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 4.1:* 2 | 3 | **In Example 4.1, if π is the equiprobable random policy, what is qπ(11, down)? What is qπ(7, down)?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Ao executar o policy evaluation chegamos numa função estado-valor como mostrado na Figura 4.1 (k = ∞). Portanto: 10 | 11 | qπ(11, down) = R11-T + vπ(T) = -1 + 0 = -1 12 | qπ(7, down) = R7-11 + vπ(11) = -1 + -14 = -15 13 | ``` 14 | -------------------------------------------------------------------------------- /Capítulo 4/Ex_4.03.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 4.3:* 2 | 3 | **What are the equations analogous to (4.3), (4.4), and (4.5), but for action-value functions instead of state-value functions?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Equação 4.3: 10 | 11 | qπ(s,a) = Eπ[Rt+1 + γvπ(St+1) | St = s, At = a] 12 | 13 | 14 | Equação 4.4 e 4.5: 15 | 16 | qπ(s,a) = Σp(s', r | s, a)[r + γvπ(s')] 17 | Σ para todo s', r. 18 | ``` 19 | -------------------------------------------------------------------------------- /Capítulo 4/Ex_4.04.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 4.4:* 2 | 3 | **The policy iteration algorithm on page 80 has a subtle bug in that it may never terminate if the policy continually switches between two or more policies that are equally good. This is okay for pedagogy, but not for actual use. Modify the pseudocode so that convergence is guaranteed.** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | 1. Initialization 10 | V(s) ∈ ℝ and π(s) ∈ A(s) arbitrarily for all s ∈ S 11 | 12 | 2. Policy Evaluation 13 | Loop: 14 | Δ <- 0 15 | Loop for each s ∈ S: 16 | v <- V(s) 17 | V(s) <- Σp(s', r | s, π(s))[r + γvπ(s')] 18 | Δ <- max(Δ, |v - V(s)|) 19 | until Δ < θ (a small number determining the accuracy of estimation) 20 | 21 | 3. Policy Improvement 22 | policy-stable <- true 23 | For each s ∈ S: 24 | old-action <- π(s) 25 | π(s) <- argmax a Σp(s', r | s, a)[r + γvπ(s')] 26 | If old-action ≠ π(s), then policy-stable <- false 27 | If policy-stable, then stop and return V ≅ x* and π ≅ π*; else go to 2 28 | ``` 29 | 30 | --- 31 | Resposta 2: 32 | 33 | ``` 34 | A melhoria abaixo segue a mesma ideia de ter as etapas de Policy Evaluation e Policy Improvement, porém há algoritmos mais otimizados, como por exemplo o Value Iteration. 35 | 36 | 1. Initialization 37 | V(s) ∈ ℝ and π(s) ∈ A(s) arbitrarily for all s ∈ S 38 | 39 | 2. Policy Evaluation 40 | Loop: 41 | Δ <- 0 42 | Loop for each s ∈ S: 43 | v <- V(s) 44 | V(s) <- Σp(s', r | s, π(s))[r + γvπ(s')] 45 | Δ <- max(Δ, |v - V(s)|) 46 | until Δ < θ (a small number determining the accuracy of estimation) 47 | 48 | 3. Policy Improvement 49 | Loop: 50 | Δ <- 0 51 | old-state-value <- v 52 | Go to 2 53 | For each s ∈ S: 54 | π(s) <- argmax a Σp(s', r | s, a)[r + γvπ(s')] 55 | Δ <- max(Δ, |old-state-value(s) - V(s)|) 56 | until Δ < θ (a small number determining the accuracy of estimation) 57 | ``` 58 | -------------------------------------------------------------------------------- /Capítulo 4/Ex_4.06.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 4.6:* 2 | 3 | **Suppose you are restricted to considering only policies that are "-soft, meaning that the probability of selecting each action in each state, s, is at least "/|A(s)|. Describe qualitatively the changes that would be required in each of the steps 3, 2, and 1, in that order, of the policy iteration algorithm for v⇤ on page 80.** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Para os passos 1 e 2, nada mudaria. Já para o passo 3, não escolheríamos a ação específica pelo argmax. E sim, permitiriamos uma probabilidade uniforme de e/A-1 para todas as ações 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 4/Ex_4.07.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 4.7*\n", 8 | "\n", 9 | "#### Write a program for policy iteration and re-solve Jack’s car rental problem with the following changes. One of Jack’s employees at the first locationrides a bus home each night and lives near the second location. She is happy to shuttleone car to the second location for free. Each additional car still costs 2, as do all carsmoved in the other direction. In addition, Jack has limited parking space at each location. If more than 10 cars are kept overnight at a location (after any moving of cars), then an additional cost of 4 must be incurred to use a second parking lot (independent of how many cars are kept there). These sorts of nonlinearities and arbitrary dynamics often occur in real problems and cannot easily be handled by optimization methods other than dynamic programming. To check your program, first replicate the results given for the original problem." 10 | ] 11 | }, 12 | { 13 | "source": [ 14 | "---\n", 15 | "#### Resposta 1:" 16 | ], 17 | "cell_type": "markdown", 18 | "metadata": {} 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": null, 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [ 26 | "import numpy as np\n", 27 | "from copy import copy\n", 28 | "from random import choice\n", 29 | "from scipy.stats import poisson\n", 30 | "from itertools import product, chain\n", 31 | "\n", 32 | "import matplotlib.pyplot as plt" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "**Constantes e definições**" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "# Constantes\n", 49 | "RENT_CAR_REWARD = 10\n", 50 | "MOVE_CAR_COST = 2\n", 51 | "MAX_MOVE_CARS = 5\n", 52 | "TOTAL_CARS_BY_LOCATION = 20\n", 53 | "\n", 54 | "FIRST_LOCATION_FREE_MOVE_CARS = 0\n", 55 | "SECOND_LOCATION_FREE_MOVE_CARS = 0\n", 56 | "\n", 57 | "PARKING_LOT_COST = 0\n", 58 | "FREE_PARKING_SPACE = TOTAL_CARS_BY_LOCATION\n", 59 | "\n", 60 | "# λ para a distribuição de probabilidade Poisson do número de retornos e pedidos de aluguel\n", 61 | "FIRST_LOCATION_REQUEST_POISSON_LAMBDA = 3\n", 62 | "FIRST_LOCATION_RETURN_POISSON_LAMBDA = 3\n", 63 | "SECOND_LOCATION_REQUEST_POISSON_LAMBDA = 4\n", 64 | "SECOND_LOCATION_RETURN_POISSON_LAMBDA = 2\n", 65 | "\n", 66 | "# Hyperparâmetros \n", 67 | "DISCOUNT_FACTOR = 0.9\n", 68 | "ERROR_THRESHOLD = 0.01\n", 69 | "MAX_POLICY_IMPROVEMENT_ITERATIONS = 10" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": null, 75 | "metadata": {}, 76 | "outputs": [], 77 | "source": [ 78 | "# Estados\n", 79 | "STATES_BY_LOCATION = tuple(range(TOTAL_CARS_BY_LOCATION + 1))\n", 80 | "STATES = list(product(STATES_BY_LOCATION, STATES_BY_LOCATION))" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "def actions_set(state):\n", 90 | " \"\"\"\n", 91 | " Ações possíveis dado um estado. Exemplo: Dado estado (15, 18) -> [-5, -4, -3, -2, -1, 0, 1, 2]\n", 92 | " \"\"\"\n", 93 | " first_location, second_location = state\n", 94 | " # O número máximo de carros que pode sair de uma locadora é, o menor número entre:\n", 95 | " # - O número de carros na locadora (first_location)\n", 96 | " # - O número máximo de carros que a segunda locadora pode receber (TOTAL_CARS_BY_LOCATION - second_location)\n", 97 | " # - O número máximo de movimentos (MAX_MOVE_CARS)\n", 98 | " from_first_location = min(first_location, TOTAL_CARS_BY_LOCATION - second_location, MAX_MOVE_CARS)\n", 99 | " from_first_location = range(1, from_first_location + 1)\n", 100 | " from_second_location = min(second_location, TOTAL_CARS_BY_LOCATION - first_location, MAX_MOVE_CARS)\n", 101 | " from_second_location = range(-1, from_second_location * -1 - 1, -1)\n", 102 | " return tuple(chain(from_second_location, (0,), from_first_location))\n", 103 | "\n", 104 | "# Dicionários com todas as ações possíveis para cada estado\n", 105 | "ACTIONS_SET = {s: actions_set(s) for s in STATES}" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": null, 111 | "metadata": {}, 112 | "outputs": [], 113 | "source": [ 114 | "# Não usado para o problema, a função está aqui por pena de apagar\n", 115 | "def rental_cars_probability_given_balance(rental_cars, balance, request_lambda, return_lambda):\n", 116 | " \"\"\"\n", 117 | " Probabilidade de pedidos (rental_cars) dado o saldo final de carros (balance).\n", 118 | " Segundo o teorema de Bayes (Probabilidade condicional), temos:\n", 119 | " P(A | B) = P(B | A) * P (A) / P(B)\n", 120 | " P(A) -> Probabilidade da quantidade de alugueis no dia\n", 121 | " P(B) -> Probabilidade do saldo final de carros no dia\n", 122 | " P(B | A) -> Probabilidade do saldo final de carros dado a quantidade de alugueis no dia\n", 123 | " \n", 124 | " Dado a quantidade de alugueis no dia, a probabilidade do saldo final de carros é igual a probabilidade\n", 125 | " de carros devolvidos = saldos + quantidade de carros alugados no dia (balance + rental_cars).\n", 126 | " \n", 127 | " A probabilidade do saldo final de carros é dado pela distribuição Skellam. Skellam é a \n", 128 | " dsitribuição de probabilidade da diferença entre duas variáveis aleatórias de Poission\n", 129 | " \"\"\"\n", 130 | " return (poisson.pmf(balance + rental_cars, return_lambda) * poisson.pmf(rental_cars, request_lambda) / \n", 131 | " skellam.pmf(balance, return_lambda, request_lambda))" 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": null, 137 | "metadata": {}, 138 | "outputs": [], 139 | "source": [ 140 | "def reward_expectation(state, action, state_values):\n", 141 | " \"\"\"\n", 142 | " Recompensa total esperada dado um estado e uma ação\n", 143 | " \"\"\"\n", 144 | " first_location, second_location = state\n", 145 | "\n", 146 | " # Primeiro é necessário fazer a transferência de carros entre as locadoras\n", 147 | " first_location -= action\n", 148 | " second_location += action\n", 149 | " \n", 150 | " # Custo por está fazendo movimentação dos carros entre as locadoras\n", 151 | " move_car_reward = 0\n", 152 | " if action > 0:\n", 153 | " move_car_reward = (action - FIRST_LOCATION_FREE_MOVE_CARS) * -MOVE_CAR_COST\n", 154 | " elif action < 0:\n", 155 | " move_car_reward = (abs(action) - SECOND_LOCATION_FREE_MOVE_CARS) * -MOVE_CAR_COST\n", 156 | " \n", 157 | " reward = 0\n", 158 | " \n", 159 | " for first_rented in range(first_location + 1):\n", 160 | " # A probabilidade de todos os carros da locadoras serem alugados inclui também \n", 161 | " # as probabilidades dos números maiores que a quantidade total de carros. Pois se a quantidade\n", 162 | " # de pedidos exceder, ainda sim o todos os carros vão ser alugados. Ou seja é a probabilidade acumulada\n", 163 | " # até ali subtraída de 100%. Esse pensamento é aplicado para todos os eventos Poisson desse problema.\n", 164 | " if first_rented == first_location:\n", 165 | " rent_probability_1 = 1 - poisson.cdf(first_rented - 1, FIRST_LOCATION_REQUEST_POISSON_LAMBDA)\n", 166 | " else:\n", 167 | " rent_probability_1 = poisson.pmf(first_rented, FIRST_LOCATION_REQUEST_POISSON_LAMBDA)\n", 168 | " \n", 169 | " first_reward = first_rented * RENT_CAR_REWARD\n", 170 | " \n", 171 | " for second_rented in range(second_location + 1):\n", 172 | " if second_rented == second_location:\n", 173 | " rent_probability = 1 - poisson.cdf(second_rented - 1, SECOND_LOCATION_REQUEST_POISSON_LAMBDA)\n", 174 | " else:\n", 175 | " rent_probability = poisson.pmf(second_rented, SECOND_LOCATION_REQUEST_POISSON_LAMBDA)\n", 176 | " \n", 177 | " rent_probability *= rent_probability_1\n", 178 | " \n", 179 | " rent_reward = first_reward + second_rented * RENT_CAR_REWARD\n", 180 | " \n", 181 | " # Porque TOTAL_CARS_BY_LOCATION - first_location + first_rented?\n", 182 | " # A quantidade de carros retornados não deve passar capacidade máxima de carros da locadora.\n", 183 | " # Os estados além da capacidade não devem ser mapeados.\n", 184 | " for first_return in range(TOTAL_CARS_BY_LOCATION - first_location + first_rented + 1):\n", 185 | " if first_return == TOTAL_CARS_BY_LOCATION - first_location + first_rented:\n", 186 | " return_probability_1 = 1 - poisson.cdf(first_return - 1, FIRST_LOCATION_RETURN_POISSON_LAMBDA)\n", 187 | " else: \n", 188 | " return_probability_1 = poisson.pmf(first_return, FIRST_LOCATION_RETURN_POISSON_LAMBDA)\n", 189 | " \n", 190 | " for second_return in range(TOTAL_CARS_BY_LOCATION - second_location + second_rented + 1):\n", 191 | " if second_return == TOTAL_CARS_BY_LOCATION - second_location + second_rented:\n", 192 | " return_probability = 1 - poisson.cdf(second_return - 1, SECOND_LOCATION_RETURN_POISSON_LAMBDA)\n", 193 | " else: \n", 194 | " return_probability = poisson.pmf(second_return, SECOND_LOCATION_RETURN_POISSON_LAMBDA)\n", 195 | " \n", 196 | " return_probability *= return_probability_1\n", 197 | " \n", 198 | " next_first_location = first_location - first_rented + first_return\n", 199 | " next_second_location = second_location - second_rented + second_return\n", 200 | " next_state = next_first_location, next_second_location\n", 201 | " \n", 202 | " parking_lot_reward = 0 if next_first_location <= FREE_PARKING_SPACE else -PARKING_LOT_COST\n", 203 | " parking_lot_reward += 0 if next_second_location <= FREE_PARKING_SPACE else -PARKING_LOT_COST\n", 204 | " \n", 205 | " future_reward = DISCOUNT_FACTOR * state_values[next_state]\n", 206 | " \n", 207 | " reward += rent_probability * return_probability * (move_car_reward + rent_reward \n", 208 | " + parking_lot_reward + future_reward)\n", 209 | "\n", 210 | " return reward" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": null, 216 | "metadata": {}, 217 | "outputs": [], 218 | "source": [ 219 | "def policy_evaluation(state_values, policy):\n", 220 | " \"\"\"\n", 221 | " Avaliação da política: atualizando os valor reais de cada estado dado uma política.\n", 222 | " \"\"\"\n", 223 | " error = None\n", 224 | " while error is None or error > ERROR_THRESHOLD:\n", 225 | " error = 0\n", 226 | " for s in STATES:\n", 227 | " value = state_values[s]\n", 228 | " state_values[s] = reward_expectation(s, policy[s], state_values)\n", 229 | " error = max(error, abs(value - state_values[s]))\n", 230 | " print(f'Policy evaluation error: {error}')" 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": null, 236 | "metadata": {}, 237 | "outputs": [], 238 | "source": [ 239 | "def policy_improvement(state_values, policy):\n", 240 | " \"\"\"\n", 241 | " Melhora a política utilizando a função state-value como base. Escolhe as ações que vão dá as melhores recompensas.\n", 242 | " :return True se a política foi alterada. Caso contrário, False, significando que política já está estável. \n", 243 | " \"\"\"\n", 244 | " is_policy_stable = True\n", 245 | " for s in STATES:\n", 246 | " old_action = policy[s]\n", 247 | " policy[s] = max(ACTIONS_SET[s], key=lambda a: reward_expectation(s, a, state_values))\n", 248 | " is_policy_stable = False if old_action != policy[s] else is_policy_stable\n", 249 | " return not is_policy_stable" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": null, 255 | "metadata": {}, 256 | "outputs": [], 257 | "source": [ 258 | "def plot_results(policy, state_values):\n", 259 | " \"\"\"\n", 260 | " Plota o gráfico color map para a política e uma projeção do 3D da função estado-valor\n", 261 | " \"\"\"\n", 262 | " \n", 263 | " # Plot do Color Map\n", 264 | " data = np.array([[policy[(f, s)] for s in range(TOTAL_CARS_BY_LOCATION + 1)] for f in range(TOTAL_CARS_BY_LOCATION + 1)])\n", 265 | "\n", 266 | " fig = plt.figure(figsize=(10, 4))\n", 267 | " color_map_axis = fig.add_subplot(1, 2, 1)\n", 268 | " color_map = color_map_axis.imshow(data, origin='lower', interpolation='none', vmin=-MAX_MOVE_CARS, vmax=MAX_MOVE_CARS)\n", 269 | " color_map_axis.set_xlabel('#Cars at second location', fontsize=13)\n", 270 | " color_map_axis.set_ylabel('#Cars at first location', fontsize=13)\n", 271 | " color_map_axis.set_title('Jack\\'s car rental problem policy')\n", 272 | " plt.colorbar(color_map, ticks=[c for c in range(-MAX_MOVE_CARS, MAX_MOVE_CARS + 1)])\n", 273 | "\n", 274 | " # Plot do Estado-Valor\n", 275 | " state_values_data = np.array([[state_values[(f, s)] for s in range(TOTAL_CARS_BY_LOCATION + 1)] for f in range(TOTAL_CARS_BY_LOCATION + 1)])\n", 276 | " state_value_axis = fig.add_subplot(1, 2, 2, projection='3d')\n", 277 | "\n", 278 | " X = np.arange(TOTAL_CARS_BY_LOCATION + 1)\n", 279 | " Y = np.arange(TOTAL_CARS_BY_LOCATION + 1)\n", 280 | " X, Y = np.meshgrid(X, Y)\n", 281 | "\n", 282 | " state_value_axis.plot_surface(X, Y, state_values_data)\n", 283 | " state_value_axis.set_title('State-value function vπ(s)')\n", 284 | " state_value_axis.set_xlabel('#Cars at second location', fontsize=11)\n", 285 | " state_value_axis.set_ylabel('#Cars at first location', fontsize=11)\n", 286 | " state_value_axis.set_zlabel('vπ(s)', fontsize=11)" 287 | ] 288 | }, 289 | { 290 | "cell_type": "markdown", 291 | "metadata": {}, 292 | "source": [ 293 | "**Problema original**" 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": null, 299 | "metadata": {}, 300 | "outputs": [], 301 | "source": [ 302 | "# Inicialização do vetor state-value e policy\n", 303 | "state_values = {s: 0 for s in STATES}\n", 304 | "policy = {s: choice(ACTIONS_SET[s]) for s in STATES}" 305 | ] 306 | }, 307 | { 308 | "cell_type": "code", 309 | "execution_count": null, 310 | "metadata": { 311 | "scrolled": true 312 | }, 313 | "outputs": [], 314 | "source": [ 315 | "is_policy_stable = False\n", 316 | "for i in range(MAX_POLICY_IMPROVEMENT_ITERATIONS):\n", 317 | " print(f'Iteration {i + 1}: Policy evaluation...')\n", 318 | " policy_evaluation(state_values, policy)\n", 319 | " print(f'Iteration {i + 1}: Policy improvement...')\n", 320 | " if not policy_improvement(state_values, policy):\n", 321 | " break\n", 322 | "print('Finished!')" 323 | ] 324 | }, 325 | { 326 | "cell_type": "code", 327 | "execution_count": null, 328 | "metadata": {}, 329 | "outputs": [], 330 | "source": [ 331 | "plot_results(policy, state_values)" 332 | ] 333 | }, 334 | { 335 | "cell_type": "markdown", 336 | "metadata": {}, 337 | "source": [ 338 | "**Problema Modificado**\n", 339 | "- Transportar carros da primeira locadora para a segunda tem frete grátis para somente um carro. Transportar mais de um tem custo de 2 para cada carro adicional.\n", 340 | "- Há um custo de 4 para manter mais de 10 carros nas locadoras." 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": null, 346 | "metadata": {}, 347 | "outputs": [], 348 | "source": [ 349 | "# Limpar o cache do problema anterior\n", 350 | "REWARD_EXPECTATION_CONSTANTS_CACHE = dict()\n", 351 | "\n", 352 | "# Definição das constantes\n", 353 | "FIRST_LOCATION_FREE_MOVE_CARS = 1\n", 354 | "SECOND_LOCATION_FREE_MOVE_CARS = 0\n", 355 | "\n", 356 | "PARKING_LOT_COST = 4\n", 357 | "FREE_PARKING_SPACE = 10" 358 | ] 359 | }, 360 | { 361 | "cell_type": "code", 362 | "execution_count": null, 363 | "metadata": {}, 364 | "outputs": [], 365 | "source": [ 366 | "# Inicialização do vetor state-value e policy\n", 367 | "state_values_2 = {s: 0 for s in STATES}\n", 368 | "policy_2 = {s: choice(ACTIONS_SET[s]) for s in STATES}" 369 | ] 370 | }, 371 | { 372 | "cell_type": "code", 373 | "execution_count": null, 374 | "metadata": {}, 375 | "outputs": [], 376 | "source": [ 377 | "is_policy_stable = False\n", 378 | "for i in range(MAX_POLICY_IMPROVEMENT_ITERATIONS):\n", 379 | " print(f'Iteration {i + 1}: Policy evaluation...')\n", 380 | " policy_evaluation(state_values_2, policy_2)\n", 381 | " print(f'Iteration {i + 1}: Policy improvement...')\n", 382 | " if not policy_improvement(state_values_2, policy_2):\n", 383 | " break\n", 384 | "print('Finished!')" 385 | ] 386 | }, 387 | { 388 | "cell_type": "code", 389 | "execution_count": null, 390 | "metadata": {}, 391 | "outputs": [], 392 | "source": [ 393 | "plot_results(policy_2, state_values_2)" 394 | ] 395 | } 396 | ], 397 | "metadata": { 398 | "kernelspec": { 399 | "display_name": "Python 3", 400 | "language": "python", 401 | "name": "python3" 402 | }, 403 | "language_info": { 404 | "codemirror_mode": { 405 | "name": "ipython", 406 | "version": 3 407 | }, 408 | "file_extension": ".py", 409 | "mimetype": "text/x-python", 410 | "name": "python", 411 | "nbconvert_exporter": "python", 412 | "pygments_lexer": "ipython3", 413 | "version": "3.8.5" 414 | } 415 | }, 416 | "nbformat": 4, 417 | "nbformat_minor": 4 418 | } -------------------------------------------------------------------------------- /Capítulo 4/Ex_4.08.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 4.8:* 2 | 3 | **Why does the optimal policy for the gambler’s problem have such a curious form? In particular, for capital of 50 it bets it all on one flip, but for capital of 51 it does not. Why is this a good policy?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Com p=0.4, é melhor para o jogador jogar menos vezes, pois a probabilidade é que com muitas jogadas, ele ficará com zero de dinheiro e consequentemente, perderá. Por isso, quando se tem $50, é melhor apostar tudo em uma jogada e ter essa chance de 0.4 para ganhar. Por outro lado, se o jogador tem $51, ele pode apostar $1 em uma moeda e asssim ter $52, ele pode usar esses 2 para fazer mais apostas e assim vai.. Dessa forma, o jogador pode chegar a grandes números sem ter arriscado tudo em uma aposta, e nesse contexto, ele pode apostar tudo em uma jogada se perder e chegar aos $50 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 4/Ex_4.09.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 4.9*\n", 8 | "\n", 9 | "#### Implement value iteration for the gambler’s problem and solve it for ph = 0.25 and ph = 0.55. In programming, you may find it convenient to introduce two dummy states corresponding to termination with capital of 0 and 100, giving them values of 0 and 1 respectively. Show your results graphically, as in Figure 4.3. Are your results stable as Δ ← 0?" 10 | ] 11 | }, 12 | { 13 | "source": [ 14 | "---\n", 15 | "#### Resposta 1:" 16 | ], 17 | "cell_type": "markdown", 18 | "metadata": {} 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "#### Constantes e definições" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 1, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import matplotlib.pyplot as plt" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 2, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "# Constantes\n", 43 | "CAPITAL_GOAL = 100\n", 44 | "DISCOUNT_FACTOR = 1\n", 45 | "ERROR_THRESHOLD = 0" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 3, 51 | "metadata": {}, 52 | "outputs": [], 53 | "source": [ 54 | "# Estados\n", 55 | "STATES = tuple(range(0, CAPITAL_GOAL + 1))\n", 56 | "TERMINAL_STATES = 0, CAPITAL_GOAL\n", 57 | "NON_TERMINAL_STATES = tuple((s for s in STATES if s not in TERMINAL_STATES))" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 4, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [ 66 | "def actions_set(state):\n", 67 | " # Escolher apostas a partir de 1 para obrigar ao apostador sempre apostar alguma coisa,\n", 68 | " # caso contrário muitas vezes é melhor pro apostador permanecer no mesmo capital do que tentar apostar\n", 69 | " return range(1, min(state, CAPITAL_GOAL - state) + 1)" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": 5, 75 | "metadata": {}, 76 | "outputs": [], 77 | "source": [ 78 | "def reward_expectation(state, action, head_probability, state_values):\n", 79 | " # Recompensa esperada ao tirar coroa\n", 80 | " reward_1 = (1 - head_probability) * DISCOUNT_FACTOR * state_values[state - action]\n", 81 | " # Recompensa esperada ao tirar cara\n", 82 | " reward_2 = head_probability * DISCOUNT_FACTOR * state_values[state + action]\n", 83 | " return reward_1 + reward_2" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": 6, 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [ 92 | "def get_optimal_policy(head_probability, state_values):\n", 93 | " policy = {s: 0 for s in STATES}\n", 94 | " for s in NON_TERMINAL_STATES:\n", 95 | " policy[s] = max(actions_set(s), key=lambda a: reward_expectation(s, a, head_probability, state_values))\n", 96 | " return policy" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": 7, 102 | "metadata": {}, 103 | "outputs": [], 104 | "source": [ 105 | "def plot_results(state_values, policy):\n", 106 | " fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 3))\n", 107 | " fig.suptitle(f' Solution to the gambler’s problem for ph = {head_probability}')\n", 108 | "\n", 109 | " # Capital x Value estimates\n", 110 | " ax1.plot(state_values.keys(), state_values.values())\n", 111 | " ax1.spines[\"top\"].set_visible(False)\n", 112 | " ax1.spines[\"right\"].set_visible(False)\n", 113 | " ax1.set_xlabel('Captial')\n", 114 | " ax1.set_ylabel('Value Estimates')\n", 115 | "\n", 116 | " # Captial x Final policy (stakes)\n", 117 | " ax2.bar(policy.keys(), policy.values(), fill=False, width=1)\n", 118 | " ax2.spines[\"top\"].set_visible(False)\n", 119 | " ax2.spines[\"right\"].set_visible(False)\n", 120 | " ax2.set_xlabel('Captial')\n", 121 | " ax2.set_ylabel('Final policy (stakes)')" 122 | ] 123 | }, 124 | { 125 | "cell_type": "markdown", 126 | "metadata": {}, 127 | "source": [ 128 | "#### 1º Cenário: ph = 0.25" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": 8, 134 | "metadata": {}, 135 | "outputs": [], 136 | "source": [ 137 | "head_probability = 0.25\n", 138 | "state_values = {s: int(s == CAPITAL_GOAL) for s in STATES}" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": 9, 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "# Value Iteration\n", 148 | "\n", 149 | "iteration = 1\n", 150 | "error = None\n", 151 | "while error is None or error > ERROR_THRESHOLD:\n", 152 | " error = 0\n", 153 | " for s in NON_TERMINAL_STATES:\n", 154 | " v = state_values[s]\n", 155 | " state_values[s] = max(reward_expectation(s, a, head_probability, state_values) for a in actions_set(s))\n", 156 | " error = max(error or 0, abs(v - state_values[s]))\n", 157 | " iteration += 1" 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": 10, 163 | "metadata": {}, 164 | "outputs": [], 165 | "source": [ 166 | "policy = get_optimal_policy(head_probability, state_values)" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 11, 172 | "metadata": {}, 173 | "outputs": [ 174 | { 175 | "data": { 176 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAA3gAAADmCAYAAACH6ifgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAAsTAAALEwEAmpwYAAA/fklEQVR4nO3deXxdVbn/8c83U9Om80jntKXMs2UQUBkcEEVAEcEJEeV6HdCfw1WvXuU6XOWq11kUERAREEGwIuKAIDJKgTK0TKVN6EjHdEozP78/9g6cpkmatudkJznf9+uVV84ez7NXdrLynLX2WooIzMzMzMzMrP8ryToAMzMzMzMzyw8neGZmZmZmZgOEEzwzMzMzM7MBwgmemZmZmZnZAOEEz8zMzMzMbIBwgmdmZmZmZjZAOMEzs6Im6QRJy/bg+P+UdHk+YyoUSXdJ+kDWcewqSSFp7y62vU/SPb0dU771lWuUdJyk5yRtkXRGL7xfl9dtZma7xwmemQ0Ikk6XNF/SJklrJf1d0ow8v8cOyWBE/E9E5D1p2tN/6iVdLOmafMY0EKU/U08I+7KvAD+KiKERcUvWweSDEpdIWpd+XSJJXez7Jkn3SKqTtErS5ZKG5Wy/SlJTmgC3f5X23tWYme2cEzwz6/fSFoCrgU8BI4AZwI+B1izjsr4t/c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ULelpSb+W9JSkGyUNkXQRMAm4U9Kd6b4vffIo6Zb0k88Fki7s/cs0MzPbZa4jzfLMCZ5Z4R0EPNzJ+gbgzIg4gqSC+076SSbAvsBPImJ/YBPw4Yj4AbACODEiTuzkfO9PP/mcA1wkaUy+L8TMzCzPXEea5ZkTPLPsCPgfSY8DfwMm83KXlKURcW/6+hrg+B6c7yJJjwEPAFOB2XmO18zMrLe4jjTbTWVZB2BWBBYAZ3Wy/l3AOOAVEdEsqQaoTLdFh307Lm9H0gnAa4FXRkS9pLtyzmVmZtZXuY40yzO34JkV3t+BQbl9/iUdAkwHVqcV14npcrtpkl6Zvn4ncE/6ejMwrJP3GAFsSCuu/YBj8n0RZmZmBeA60izPnOCZFVhEBHAm8Np0COgFwDeA24A5kp4A3gs8nXPYM8BHJD0FjAIuTddfBtze/gB5jtuBsnT/b5J0QTEzM+vTXEea5Z+S3ysz6yskVQO3RsRBWcdiZmbWl7iONNs5t+CZmZmZmZkNEG7BMzMzMzMzGyDcgmdmZmZmZjZAOMEzMzMzMzMbIJzgmZmZmZmZDRBO8MzMzMzMzAYIJ3hmZmZmZmYDhBM8MzMzMzOzAeL/AwZPdCtyO0vCAAAAAElFTkSuQmCC\n", 177 | "text/plain": [ 178 | "
" 179 | ] 180 | }, 181 | "metadata": { 182 | "needs_background": "light" 183 | }, 184 | "output_type": "display_data" 185 | } 186 | ], 187 | "source": [ 188 | "plot_results(state_values, policy)" 189 | ] 190 | }, 191 | { 192 | "cell_type": "markdown", 193 | "metadata": {}, 194 | "source": [ 195 | "#### 2º Cenário: ph = 0.55" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 12, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "head_probability = 0.55\n", 205 | "state_values = {s: int(s == CAPITAL_GOAL) for s in STATES}" 206 | ] 207 | }, 208 | { 209 | "cell_type": "code", 210 | "execution_count": 13, 211 | "metadata": {}, 212 | "outputs": [], 213 | "source": [ 214 | "# Value Iteration\n", 215 | "\n", 216 | "iteration = 1\n", 217 | "error = None\n", 218 | "while error is None or error > ERROR_THRESHOLD:\n", 219 | " error = 0\n", 220 | " for s in NON_TERMINAL_STATES:\n", 221 | " v = state_values[s]\n", 222 | " state_values[s] = max(reward_expectation(s, a, head_probability, state_values) for a in actions_set(s))\n", 223 | " error = max(error or 0, abs(v - state_values[s]))\n", 224 | " iteration += 1" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": 14, 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [ 233 | "policy = get_optimal_policy(head_probability, state_values)" 234 | ] 235 | }, 236 | { 237 | "cell_type": "code", 238 | "execution_count": 15, 239 | "metadata": {}, 240 | "outputs": [ 241 | { 242 | "data": { 243 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAA3gAAADmCAYAAACH6ifgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAzlElEQVR4nO3dd5wddb3/8dc7m95IpaQnVCPdSLEioAZUIooU4YpY+FkQvYqFa+Na4arXcuWqiIAoRapEjWADvaJgQiehJSEhhSSb3pPN7uf3x8yGk7Nnd88me86c8n4+HoedPp+ZnTD7Od+miMDMzMzMzMyqX4+sAzAzMzMzM7Pu4QTPzMzMzMysRjjBMzMzMzMzqxFO8MzMzMzMzGqEEzwzMzMzM7Ma4QTPzMzMzMysRjjBM7O6JukESYv3YP//kHR1d8ZUKpLuk/SBrOPoKkkh6YB21r1X0t/LHVN3q5RrlPRqSc9J2ijp7WU4X7vXbWZmu8cJnpnVBEnTJD0qab2klZL+ImliN5+jTTIYEd+IiG5Pmvb0j3pJl0n6ZXfGVIvS36kHhH3JV4AfRsTAiPh11sF0ByWukLQq/VwhSe1se4KkljTBbf2cn7P+Pklbc9Y9U74rMTMrTs+sAzAz21NpCcD1wDuAvwADgTcB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
" 246 | ] 247 | }, 248 | "metadata": { 249 | "needs_background": "light" 250 | }, 251 | "output_type": "display_data" 252 | } 253 | ], 254 | "source": [ 255 | "plot_results(state_values, policy)" 256 | ] 257 | } 258 | ], 259 | "metadata": { 260 | "kernelspec": { 261 | "display_name": "Python 3", 262 | "language": "python", 263 | "name": "python3" 264 | }, 265 | "language_info": { 266 | "codemirror_mode": { 267 | "name": "ipython", 268 | "version": 3 269 | }, 270 | "file_extension": ".py", 271 | "mimetype": "text/x-python", 272 | "name": "python", 273 | "nbconvert_exporter": "python", 274 | "pygments_lexer": "ipython3", 275 | "version": "3.8.5" 276 | } 277 | }, 278 | "nbformat": 4, 279 | "nbformat_minor": 4 280 | } -------------------------------------------------------------------------------- /Capítulo 4/Ex_4.10.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 4.10*\n", 8 | "\n", 9 | "#### What is the analog of the value iteration update (4.10) for action values, q k+1 (s, a)?" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "$ q_{k+1}(s,a) = E[R_{k+1} + \\gamma max_{a'}q_{k}(S_{k+1}, a')] $\n", 19 | "\n", 20 | "$ \\qquad \\quad = \\sum_{s', r}p(s',r|s, a)[r + \\gamma max_{a'}q_{k}(s', a')] $ " 21 | ] 22 | } 23 | ], 24 | "metadata": { 25 | "kernelspec": { 26 | "display_name": "Python 3", 27 | "language": "python", 28 | "name": "python3" 29 | }, 30 | "language_info": { 31 | "codemirror_mode": { 32 | "name": "ipython", 33 | "version": 3 34 | }, 35 | "file_extension": ".py", 36 | "mimetype": "text/x-python", 37 | "name": "python", 38 | "nbconvert_exporter": "python", 39 | "pygments_lexer": "ipython3", 40 | "version": "3.7.3" 41 | } 42 | }, 43 | "nbformat": 4, 44 | "nbformat_minor": 2 45 | } -------------------------------------------------------------------------------- /Capítulo 4/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 4: Dynamic Programming - Exercises 2 | 3 | Exercises list: 4 | 5 | - [x] 4.1 6 | - [ ] 4.2 7 | - [x] 4.3 8 | - [x] 4.4 9 | - [ ] 4.5 10 | - [x] 4.6 11 | - [x] 4.7 12 | - [x] 4.8 13 | - [x] 4.9 14 | - [x] 4.10 15 | -------------------------------------------------------------------------------- /Capítulo 5/Ex_5.03.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 5.3:* 2 | 3 | **What is the backup diagram for Monte Carlo estimation of qπ?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | ação > estado > ação > estado > ... > estado terminal 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 5/Ex_5.05.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 5.5*\n", 8 | "\n", 9 | "#### Consider an MDP with a single nonterminal state and a single action that transitions back to the nonterminal state with probability $p$ and transitions to the terminal state with probability 1 $p$. Let the reward be +1 on all transitions, and let $ \\gamma $ = 1. Suppose you observe one episode that lasts 10 steps, with a return of 10. What are the first-visit and every-visit estimators of the value of the nonterminal state?" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "\n", 19 | "O estado nonterminal foi visitado 9 vezes, considerando que $\\gamma = 1$ os retornos do estado nonterminal foram: 1, 2, 3, 4, 5, 6, 7, 8, 9. \n", 20 | " \n", 21 | "Para o caso do first-visit a estimativa do estado nonterminal é igual a 9. \n", 22 | "Para o caso do every-visit a estimativa é a média dos retornos, portanto 5." 23 | ] 24 | } 25 | ], 26 | "metadata": { 27 | "kernelspec": { 28 | "display_name": "Python 3", 29 | "language": "python", 30 | "name": "python3" 31 | }, 32 | "language_info": { 33 | "codemirror_mode": { 34 | "name": "ipython", 35 | "version": 3 36 | }, 37 | "file_extension": ".py", 38 | "mimetype": "text/x-python", 39 | "name": "python", 40 | "nbconvert_exporter": "python", 41 | "pygments_lexer": "ipython3", 42 | "version": "3.7.3" 43 | } 44 | }, 45 | "nbformat": 4, 46 | "nbformat_minor": 2 47 | } -------------------------------------------------------------------------------- /Capítulo 5/Ex_5.06.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 5.6*\n", 8 | "\n", 9 | "#### What is the equation analogous to (5.6) for action values $Q(s, a)$ instead of\n", 10 | "state values $V(s)$, again given returns generated using $b$?" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "---\n", 18 | "#### Resposta 1:\n", 19 | "\n", 20 | "Precisa-se fazer um ajuste em $ \\tau(s) $, usaremos em seu lugar a função $ \\vartheta(s, a) $ que armazena o time-step $t$ onde o par state-action $(s, a)$ apareceu. \n", 21 | " \n", 22 | "Portanto a formula (5.6) ajustada para $Q(s,a)$ é:\n", 23 | " \n", 24 | "$Q(s, a) = \\frac{\\sum_{t\\in \\vartheta(s, a)}\\rho_{t:T(t)-1}G_{t}}{\\sum_{t\\in \\vartheta(s, a)}\\rho_{t:T(t)-1}}$ " 25 | ] 26 | } 27 | ], 28 | "metadata": { 29 | "kernelspec": { 30 | "display_name": "Python 3", 31 | "language": "python", 32 | "name": "python3" 33 | }, 34 | "language_info": { 35 | "codemirror_mode": { 36 | "name": "ipython", 37 | "version": 3 38 | }, 39 | "file_extension": ".py", 40 | "mimetype": "text/x-python", 41 | "name": "python", 42 | "nbconvert_exporter": "python", 43 | "pygments_lexer": "ipython3", 44 | "version": "3.7.3" 45 | } 46 | }, 47 | "nbformat": 4, 48 | "nbformat_minor": 2 49 | } -------------------------------------------------------------------------------- /Capítulo 5/Ex_5.07.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 5.7:* 2 | 3 | **In learning curves such as those shown in Figure 5.3 error generally decreases with training, as indeed happened for the ordinary importance-sampling method. But for the weighted importance-sampling method error first increased and then decreased. Why do you think this happened?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Isso acontece porque ela é tendenciosa, mesmo convertendo para zero. 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 5/Ex_5.09.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 5.9*\n", 8 | "\n", 9 | "#### Modify the algorithm for first-visit MC policy evaluation (Section 5.1) to\n", 10 | "use the incremental implementation for sample averages described in Section 2.4." 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "---\n", 18 | "#### Resposta 1:\n", 19 | "\n", 20 | "$ Input: \\enspace a \\enspace policy \\enspace \\pi \\enspace to \\enspace be \\enspace evaluated $\n", 21 | "\n", 22 | "$ Initialize: $\n", 23 | "\n", 24 | "$ \\qquad V(s) \\in \\mathbb{R},\\enspace arbitrarily,\\enspace for\\enspace all\\enspace s \\in S $\n", 25 | "\n", 26 | "$ \\qquad C(s) \\leftarrow 0,\\enspace for\\enspace all\\enspace s \\in S $\n", 27 | "\n", 28 | "$ Loop\\enspace forever\\enspace (for\\enspace each\\enspace episode): $\n", 29 | "\n", 30 | "$ \\qquad Generate\\enspace an\\enspace episode\\enspace following\\enspace \\pi :\\enspace S_{0},\\enspace A_{0},\\enspace R_{1},\\enspace S_{1},\\enspace A_{1},\\enspace R_{2} ,\\enspace . . . ,\\enspace S_{T} $\n", 31 | "\n", 32 | "$ \\qquad G\\leftarrow 0 $\n", 33 | "\n", 34 | "$ \\qquad Loop\\enspace for\\enspace each\\enspace step\\enspace of\\enspace episode,\\enspace t\\enspace =\\enspace T_{1},\\enspace T_{2},\\enspace . . . ,\\enspace 0: $\n", 35 | "\n", 36 | "$ \\qquad \\qquad G = \\gamma G + R_{t+1} $\n", 37 | "\n", 38 | "$ \\qquad \\qquad Unless\\enspace S_{t}\\enspace appears\\enspace in\\enspace S_{0},\\enspace S_{1},\\enspace ... ,\\enspace S_{t-1} : $\n", 39 | "\n", 40 | "$ \\qquad \\qquad \\qquad C(S_{t}) = C(S_{t}) + 1 $\n", 41 | "\n", 42 | "$ \\qquad \\qquad \\qquad V (S_{t}) = V (S_{t}) + \\frac{1}{C(S_{t})}[G - V (S_{t})]$ " 43 | ] 44 | } 45 | ], 46 | "metadata": { 47 | "kernelspec": { 48 | "display_name": "Python 3", 49 | "language": "python", 50 | "name": "python3" 51 | }, 52 | "language_info": { 53 | "codemirror_mode": { 54 | "name": "ipython", 55 | "version": 3 56 | }, 57 | "file_extension": ".py", 58 | "mimetype": "text/x-python", 59 | "name": "python", 60 | "nbconvert_exporter": "python", 61 | "pygments_lexer": "ipython3", 62 | "version": "3.7.3" 63 | } 64 | }, 65 | "nbformat": 4, 66 | "nbformat_minor": 2 67 | } -------------------------------------------------------------------------------- /Capítulo 5/Ex_5.10.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 5.10*\n", 8 | "\n", 9 | "#### Derive the weighted-average update rule (5.8) from (5.7). Follow the pattern of the derivation of the unweighted rule (2.3)." 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "\n", 19 | "$\\\\ V_{n+1} = \\frac{\\sum_{k=1}^{n}W_{k}G_{k}}{\\sum_{k=1}^{n}W_{k}} \\\\ $ \n", 20 | "$\\\\ = \\frac{W_{k}G_{k} + \\sum_{k=1}^{n-1}W_{k}G_{k}}{C_{n}} \\\\ $ \n", 21 | "$\\\\ = \\frac{1}{C_{n}}[W_{n}G_{n} + \\sum_{k=1}^{n-1}W_{k}G_{k}] \\\\ $ \n", 22 | "$\\\\ = \\frac{W_{n}}{C_{n}}[G_{n} + \\frac{\\sum_{k=1}^{n-1}W_{k}G_{k}}{W_{n}}] \\\\ $ \n", 23 | "$\\\\ = \\frac{W_{n}}{C_{n}}[G_{n} + \\frac{1}{W_{n}} \\sum_{k=1}^{n-1}W_{k}G_{k} ] \\\\ $ \n", 24 | " lembrando que $ (C_{n}-W_{n}) $ é igual a $ C_{n-1} $ \n", 25 | " \n", 26 | "$\\\\ = \\frac{W_{n}}{C_{n}}[G_{n} + (C_{n}-W_{n}) \\frac{1}{(C_{n}-W_{n})} \\frac{1}{W_{n}} \n", 27 | "\\sum_{k=1}^{n-1}W_{k}G_{k}] \\\\ $ \n", 28 | "$\\\\ = \\frac{W_{n}}{C_{n}}[G_{n} + (C_{n}-W_{n}) V_{n} \\frac{1}{W_{n}} ] \\\\ $ \n", 29 | "$\\\\ = \\frac{W_{n}}{C_{n}}[G_{n} + (C_{n}V_{n} - W_{n}V_{n} ) \\frac{1}{W_{n}} ] \\\\ $ \n", 30 | "$\\\\ = \\frac{W_{n}}{C_{n}}[G_{n} + \\frac{C_{n}V_{n}}{W_{n}} - V_{n} ] \\\\ $ \n", 31 | "$\\\\ = V_{n} + \\frac{W_{n}}{C_{n}}[G_{n} - V_{n} ]$ " 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [] 40 | } 41 | ], 42 | "metadata": { 43 | "kernelspec": { 44 | "display_name": "Python 3", 45 | "language": "python", 46 | "name": "python3" 47 | }, 48 | "language_info": { 49 | "codemirror_mode": { 50 | "name": "ipython", 51 | "version": 3 52 | }, 53 | "file_extension": ".py", 54 | "mimetype": "text/x-python", 55 | "name": "python", 56 | "nbconvert_exporter": "python", 57 | "pygments_lexer": "ipython3", 58 | "version": "3.7.3" 59 | } 60 | }, 61 | "nbformat": 4, 62 | "nbformat_minor": 2 63 | } -------------------------------------------------------------------------------- /Capítulo 5/Ex_5.11.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 5.11*\n", 8 | "\n", 9 | "#### In the boxed algorithm for off-policy MC control, you may have been expecting the W update to have involved the importance-sampling ratio $ \\frac{\\pi (A_{t}|S_{t})}{b(A_{t}|S_{t})} $, but instead it involves $ \\frac{1}{b(A_{t}|S_{t})} $. Why is this nevertheless correct?" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "\n", 19 | "Isso é porque a política $ \\pi $ se comporta de maneira greedy, escolhendo suas ações seguindo $ argmax_{a}Q(S_{t}, a) $, portanto o $ \\pi (A_{t}|S_{t}) $ é 1. Em outras palavras, a política sempre tomará tal ação nesse estado, sendo assim $ \\frac{\\pi (A_{t}|S_{t})}{b(A_{t}|S_{t})} = \\frac{1}{b(A_{t}|S_{t})} $" 20 | ] 21 | } 22 | ], 23 | "metadata": { 24 | "kernelspec": { 25 | "display_name": "Python 3", 26 | "language": "python", 27 | "name": "python3" 28 | }, 29 | "language_info": { 30 | "codemirror_mode": { 31 | "name": "ipython", 32 | "version": 3 33 | }, 34 | "file_extension": ".py", 35 | "mimetype": "text/x-python", 36 | "name": "python", 37 | "nbconvert_exporter": "python", 38 | "pygments_lexer": "ipython3", 39 | "version": "3.7.3" 40 | } 41 | }, 42 | "nbformat": 4, 43 | "nbformat_minor": 2 44 | } -------------------------------------------------------------------------------- /Capítulo 5/Ex_5.13.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise 5.13*\n", 8 | "\n", 9 | "#### Show the steps to derive (5.14) from (5.12)." 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "\n", 19 | "$ E[\\rho _{t:T-1}R_{t+1}] = E[\\rho _{t:t}\\ \\rho _{t+1:T-1}R_{t+1}] $\n", 20 | "\n", 21 | "$ = E[\\rho _{t:t}R_{t+1}]E[\\rho _{t+1:T-1}] $\n", 22 | "\n", 23 | "$ = E[\\rho _{t:t}R_{t+1}]E[\\prod_{k=t+1}^{T-1}\\frac{\\pi (A_{k}|S_{k})}{b(A_{k}|S_{k})}] $\n", 24 | "\n", 25 | "$ = E[\\rho _{t:t}R_{t+1}]\\prod_{k=t+1}^{T-1}E[\\frac{\\pi (A_{k}|S_{k})}{b(A_{k}|S_{k})}] $\n", 26 | "\n", 27 | " e de acordo com (5.13)\n", 28 | " \n", 29 | "$ E[\\frac{\\pi (A_{t}|S_{t})}{b(A_{t}|S_{t})}] = 1 $\n", 30 | "\n", 31 | " então\n", 32 | " \n", 33 | "$ = E[\\rho _{t:t}R_{t+1}] $\n", 34 | "\n" 35 | ] 36 | } 37 | ], 38 | "metadata": { 39 | "kernelspec": { 40 | "display_name": "Python 3", 41 | "language": "python", 42 | "name": "python3" 43 | }, 44 | "language_info": { 45 | "codemirror_mode": { 46 | "name": "ipython", 47 | "version": 3 48 | }, 49 | "file_extension": ".py", 50 | "mimetype": "text/x-python", 51 | "name": "python", 52 | "nbconvert_exporter": "python", 53 | "pygments_lexer": "ipython3", 54 | "version": "3.7.3" 55 | } 56 | }, 57 | "nbformat": 4, 58 | "nbformat_minor": 2 59 | } -------------------------------------------------------------------------------- /Capítulo 5/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 5: Monte Carlo Methods - Exercises 2 | 3 | Exercises list: 4 | 5 | - [ ] 5.1 6 | - [ ] 5.2 7 | - [x] 5.3 8 | - [ ] 5.4 9 | - [x] 5.5 10 | - [x] 5.6 11 | - [x] 5.7 12 | - [ ] 5.8 13 | - [x] 5.9 14 | - [x] 5.10 15 | - [x] 5.11 16 | - [ ] 5.12 17 | - [x] 5.13 18 | - [ ] 5.14 19 | -------------------------------------------------------------------------------- /Capítulo 6/Ex_6.02.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 6.2:* 2 | 3 | **This is an exercise to help develop your intuition about why TD methods are often more ecient than Monte Carlo methods. Consider the driving home example and how it is addressed by TD and Monte Carlo methods. Can you imagine a scenario in which a TD update would be better on average than a Monte Carlo update? Give an example scenario—a description of past experience and a current state—in which you would expect the TD update to be better. Here’s a hint: Suppose you have lots of experience driving home from work. Then you move to a new building and a new parking lot (but you still enter the highway at the same place). Now you are starting to learn predictions for the new building. Can you see why TD updates are likely to be much better, at least initially, in this case? Might the same sort of thing happen in the original scenario?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | O método TD pode usar predições do inicio ao fim de experiências passadas. Já o método MC precisa criar predições. Dessa forma, é provável que as predições de MC sejam diferentes da realidade e por isso, o método TD é melhor nesse caso 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 6/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 6: Temporal-Difference Learning - Exercises 2 | 3 | Exercises list: 4 | 5 | - [ ] 6.1 6 | - [x] 6.2 7 | - [ ] 6.3 8 | - [ ] 6.4 9 | - [ ] 6.5 10 | - [ ] 6.6 11 | - [ ] 6.7 12 | - [ ] 6.8 13 | - [ ] 6.9 14 | - [ ] 6.10 15 | - [ ] 6.11 16 | - [ ] 6.12 17 | - [ ] 6.13 18 | - [ ] 6.14 19 | -------------------------------------------------------------------------------- /Capítulo 7/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 7: n-step Bootstrapping - Exercises 2 | 3 | Exercises list: 4 | 5 | - [ ] 7.1 6 | - [ ] 7.2 7 | - [ ] 7.3 8 | - [ ] 7.4 9 | - [ ] 7.5 10 | - [ ] 7.6 11 | - [ ] 7.7 12 | - [ ] 7.8 13 | - [ ] 7.9 14 | - [ ] 7.10 -------------------------------------------------------------------------------- /Capítulo 8/Ex_8.02.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 8.2:* 2 | 3 | **Why did the Dyna agent with exploration bonus, Dyna-Q+, perform better in the first phase as well as in the second phase of the blocking and shortcut experiments?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | O algoritmo Dyna Q por ser menos exploratório, na primeira fase, pode ter encontrado um caminho não ótimo para chegar ao estado terminal e continuou a seguir esse caminho por mais tempo do que no algoritmo Dyna Q+, que possui uma exploração do ambiente maior, consequentemente atingindo mais rapido a política ótima. Já na segunda fase, no primeiro experimento, acontece algo similar a primeira fase, no bloqueio do caminho, os dois algoritmos encontram o caminho ótimo, porém o Dyna Q+ o encontra mais rapidamente. No segundo experimento, na abertura de um novo caminho, o Dyna Q+ encontra a política ótima pela sua natureza mais exploratória, enquanto o Dyna Q continua indo pelo caminho não otimo, justamente por causa da sua natureza pouco exploratória, mesmo utilizando e-greedy. 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 8/Ex_8.03.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 8.3:* 2 | 3 | **Careful inspection of Figure 8.5 reveals that the difference between Dyna-Q+ and Dyna-Q narrowed slightly over the first part of the experiment. What is the reason for this?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | O Dyna-Q+ encontra de uma maneira mais rápida a política ótima pela sua maior natureza exploratória, porém mesmo já possuindo a política ótima ele é forçado a continuar explorando, é por esse custo exploratório que a diferença entre Dyna-Q + e Dyna-Q vai se estreitando 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 8/Ex_8.06.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 8.6:* 2 | 3 | **The analysis above assumed that all of the b possible next states were equally likely to occur. Suppose instead that the distribution was highly skewed, that some of the b states were much more likely to occur than most. Would this strengthen or weaken the case for sample updates over expected updates? Support your answer.** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Isso fortalecerá as atualizações amostrais, possuindo um melhor desempenho porque, por sua natureza, pode ignorar estados muito improváveis e enfatizar o estados mais significativos, isto é, que aparecem com maior frequencia, obtendo a melhor estimativa com menos amostras. 10 | ``` 11 | 12 | --- 13 | Resposta 2: 14 | 15 | ``` 16 | Amostras de atualizações nesse contexo seriam mais próximas para valores mais baixos de b porque existem menos estados importantes. 17 | ``` 18 | -------------------------------------------------------------------------------- /Capítulo 8/Ex_8.07.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 8.7:* 2 | 3 | **Some of the graphs in Figure 8.8 seem to be scalloped in their early portions, particularly the upper graph for b = 1 and the uniform distribution. Why do you think this is? What aspects of the data shown support your hypothesis?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Estes recortes é pelo fato de levar muito tempo de computação para fazer uma varredura completa, e no caso do b=1 haverá maiores recortes, caso em que a mudança de um estado é totalmente transferida para outros estados, quantor maior o b, o sistema fica mais estabilizado devido à soma múltipla das mudanças parciais dos estados seguintes. Podemos observar que no caso de 1.000 estados, b=10 é mais suave, enquanto b=1 é mais recortado, o b=1 no caso de 10.000 estados seria mais recortado se a escala do eixo X, o tempo de computação, fossem iguais. 10 | 11 | 12 | Obs: não sei ao certo a tradução de scalloped, eu traduzi como recortado 13 | ``` 14 | -------------------------------------------------------------------------------- /Capítulo 8/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 8: Planning and Learning with Tabular Methods - Exercises 2 | 3 | Exercises list: 4 | 5 | - [ ] 8.1 6 | - [x] 8.2 7 | - [x] 8.3 8 | - [ ] 8.4 9 | - [ ] 8.5 10 | - [x] 8.6 11 | - [x] 8.7 12 | - [ ] 8.8 13 | -------------------------------------------------------------------------------- /Capítulo 9/Ex_9.02.md: -------------------------------------------------------------------------------- 1 | ### *Exercise 9.2:* 2 | 3 | ** Why does (9.17) define (n + 1)k distinct features for dimension k?** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | Porque existem N+1 maneiras de escolhermos ci,j. E temos que escolher k vezes. Por isso existe (N+1) elevado a k. 10 | ``` 11 | -------------------------------------------------------------------------------- /Capítulo 9/README.md: -------------------------------------------------------------------------------- 1 | # Chapter 9: On-policy Prediction with Approximation - Exercises 2 | 3 | Exercises list: 4 | 5 | - [ ] 9.1 6 | - [x] 9.2 7 | - [ ] 9.3 8 | - [ ] 9.4 9 | - [ ] 9.5 10 | - [ ] 9.6 11 | - [ ] 9.7 12 | - [ ] 9.8 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Richard S. Sutton and Andrew G. Barto 2018 RLBook Exercises 2 | 3 | ### Jupyter notebooks and markdown exercise solutions of "Reinforcement Learning: An Introduction", Richard S. Sutton and Andrew G. Barto book. 4 | 5 | --- 6 | Completion status: 7 | 8 | | | Chapter | Done | 9 | |---|------------------------|------| 10 | | ✅ | 1: Introduction | 5/5 | 11 | | | 2: Multi-armed Bandits | 7/10 | 12 | | | 3: Finite Markov Decision Processes| 14/29 | 13 | | | 4: Dynamic Programming | 8/10 | 14 | | | 5: Monte Carlo Methods | 8/14 | 15 | | | 6: Temporal-Difference Learning | 1/14 | 16 | | | 7: n-step Bootstrapping | 0/10 | 17 | | | 8: Planning and Learning with Tabular Methods | 4/8 | 18 | | | 9: On-policy Prediction with Approximation | 1/8 | 19 | 20 | --- 21 | ### Contributing: 22 | New solutions should be submitted through pull requests, base file formats for markdown and notebooks are available at the stubs folder. 23 | 24 | Files should be placed on the proper chapter folder following the naming scheme for markdown and Jupyter notebooks. 25 | 26 | ``` 27 | Ex_X.XX.md 28 | ``` 29 | 30 | ``` 31 | Ex_X.XX.ipynb 32 | ``` 33 | -------------------------------------------------------------------------------- /Stubs/Ex_X.XX.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### *Exercise X.X*\n", 8 | "\n", 9 | "#### {question}" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "---\n", 17 | "#### Resposta 1:\n", 18 | "{Solution}" 19 | ] 20 | } 21 | ], 22 | "metadata": { 23 | "kernelspec": { 24 | "display_name": "Python 3", 25 | "language": "python", 26 | "name": "python3" 27 | }, 28 | "language_info": { 29 | "codemirror_mode": { 30 | "name": "ipython", 31 | "version": 3 32 | }, 33 | "file_extension": ".py", 34 | "mimetype": "text/x-python", 35 | "name": "python", 36 | "nbconvert_exporter": "python", 37 | "pygments_lexer": "ipython3", 38 | "version": "3.8.5" 39 | } 40 | }, 41 | "nbformat": 4, 42 | "nbformat_minor": 4 43 | } -------------------------------------------------------------------------------- /Stubs/Ex_X.XX.md: -------------------------------------------------------------------------------- 1 | ### *Exercise X.X:* 2 | 3 | **{question}** 4 | 5 | --- 6 | Resposta 1: 7 | 8 | ``` 9 | {Solution} 10 | ``` 11 | --------------------------------------------------------------------------------