Skip to content

vickyskarthik/DRL-P2-Continuous-control

Repository files navigation

DRL-Projects

This is repo is based on Udacity's Nanodegree on Deep Reinforcement Learning

Reacher

Continuous Control

This project repository contains the code and references to implement a DQN for solving a navigation problem in Banana Simulator.

The Environment

For this project, you will work with the Reacher environment.

In this environment, a double-jointed arm can move to target locations. A reward of +0.1 is provided for each step that the agent's hand is in the goal location. Thus, the goal of your agent is to maintain its position at the target location for as many time steps as possible.

The observation space consists of 33 variables corresponding to position, rotation, velocity, and angular velocities of the arm. Each action is a vector with four numbers, corresponding to torque applicable to two joints. Every entry in the action vector should be a number between -1 and 1.

Distributed Training

For this project, we will provide you with two separate versions of the Unity environment:

The first version contains a single agent. The second version contains 20 identical agents, each with its own copy of the environment. The second version is useful for algorithms like PPO, A3C, and D4PG that use multiple (non-interacting, parallel) copies of the same agent to distribute the task of gathering experience.

Solving the Environment

Note that your project submission need only solve one of the two versions of the environment.

Option 1: Solve the First Version

The task is episodic, and in order to solve the environment, your agent must get an average score of +30 over 100 consecutive episodes.

Option 2: Solve the Second Version

The barrier for solving the second version of the environment is slightly different, to take into account the presence of many agents. In particular, your agents must get an average score of +30 (over 100 consecutive episodes, and over all agents). Specifically,

After each episode, we add up the rewards that each agent received (without discounting), to get a score for each agent. This yields 20 (potentially different) scores. We then take the average of these 20 scores. This yields an average score for each episode (where the average is over all 20 agents). As an example, consider the plot below, where we have plotted the average score (over all 20 agents) obtained with each episode.

Getting started

Installation requirements

  • To begin with, you need to configure a Python 3.6 / PyTorch 0.4.0 environment with the requirements described in Udacity repository

  • Then you need to clone this project and have it accessible in your Python environment

  • For this project, you will not need to install Unity. This is because we have already built the environment for you, and you can download it from one of the links below. You need to only select the environment that matches your operating system:

    (For Windows users) Check out this link if you need help with determining if your computer is running a 32-bit version or 64-bit version of the Windows operating system.

    (For AWS) If you'd like to train the agent on AWS (and have not enabled a virtual screen), then please use this link (version 1) or this link (version 2) to obtain the "headless" version of the environment. You will not be able to watch the agent without enabling a virtual screen, but you will be able to train the agent. (To watch the agent, you should follow the instructions to enable a virtual screen, and then download the environment for the Linux operating system above.)

  • Finally, you can unzip the environment archive in the project's environment directory and set the path to the UnityEnvironment in the code.

Instructions

Training an agent

You can either run Continuous_Control.ipynb in the Udacity Online Workspace for "Project2: Continuous Control" step by step or build your own local environment and set the path to the UnityEnvironment in the code.

Note: The Workspace does not allow you to see the simulator of the environment; so, if you want to watch the agent while it is training, you should train locally.

Solution

The algorithm used to solve this problem is Deep Deterministic Policy Gradient(DDPG).

DDPG Algorithm

Algorithm

OUTPUT

outputscore

GRAPH of Score Vs Episode

graph

Future Works

So far the agent is trained only using DDPG which can also be implemented using the following algorithms

  1. Proximal Policy Optimization(PPO)
  2. Generalized Advantage Estimation(GAE)
  3. Advantage Actor Critic(A2C)
  4. Asynchronous Advantage Actor-Critic(A3C)
  5. Distributed Distributional Deterministic Policy Gradients(D4PG)

Also in this attempt the agent interacted with the environment but the agent can be trained using raw pixels from the environment as input.

Reference

[1] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, Oleg Klimov, Proximal Policy Optimization Algorithms

[2] Juliani, A., Berges, V., Vckay, E., Gao, Y., Henry, H., Mattar, M., Lange, D. (2018). Unity: A General Platform for Intelligent Agents. [arXiv preprint arXiv:1809.02627.] (https://github.com/Unity-Technologies/ml-agents)

[3] R. S. Sutton and A. G. Barto, Introduction to Reinforcement Learning, 2nd ed. Cambridge, MA, USA: MIT Press, 2017

[4] Deterministic Policy Gradient Algorithms, Silver et al. 2014

[5]Continuous Control With Deep Reinforcement Learning, Lillicrap et al. 2016

About

This repos is created as a part of Udacity Deep Reinforcement Learning Nanodegree Program on continuous control

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published