Answers.Body: <p>I will give one perspective on this from the domain of robotics. You are right that most RL agents are trained in simulation particularly for research papers, because it allows researchers to in theory benchmark their approaches in a common environment. Many of the environments exist strictly as a test bed for new algorithms and are not even physically realizable, e.g. <a href="https://gym.openai.com/envs/HalfCheetah-v2/" rel="nofollow noreferrer">HalfCheetah</a>. You could in theory have a separate simulator say running in another process that you use as your planning model, and the &quot;real&quot; simulator is then your environment. But really that's just a mocked setup for what you really want in the end, which is having a real-world agent in a real-world environment.</p>
  <p>What you describe could be very useful, with one important caveat: the simulator needs to in fact be a good model of the real environment. For robotics and many other interesting domains, this is a tall order. Getting a physics simulator that faithfully replicates the real-world environment can be tricky, as one may need accurate friction coefficients, mass and center of mass, restitution coefficients, material properties, contact models, and so on. Oftentimes the simulator is too crude an approximation of the real-world environment to be useful as a planner.</p>
  <p>That doesn't mean we're completely hosed though. <a href="https://arxiv.org/pdf/1810.05687.pdf" rel="nofollow noreferrer">This paper</a> uses highly parallelized simulators to search for simulation parameters that approximate the real-world well. What's interesting is it's not even necessarily finding the correct real-world values for e.g. friction coefficients and such, but it finds values for parameters that, taken together, produces simulations that match the real-world experience. The better the simulation gets at approximating what's going on in the real world, the more viable it is to use the simulator for task planning. I think with the advent of <a href="https://developer.nvidia.com/isaac-gym" rel="nofollow noreferrer">GPU-optimized physics simulators</a> we will see simulators be a more useful tool even for real-world agents, as you can try many different things in parallel to get a sense of what is the likely outcome of a planned action sequence.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-28T04:10:38.413Z
Answers.LastActivityDate: 2020-11-28T04:10:38.413Z
Answers.UserDisplayName: adamconkey
Answers.Body: <blockquote>
  <p>Shouldn't this allow us to find better actions more quickly compared to policy gradient updates?</p>
  </blockquote>
  <p>It depends on the nature of the simulation. If the simulation models a car as a solid body moving with three <span class="math-container">$(x,y,\theta)$</span> degrees of freedom in a plane (hopefully, if it doesn't hit anything and propel vertically), the three ordinary differential equations of solid body motion can be solved quite quickly, compared to a simulation used to model the path of least resistance of a ship on wavy sea, where fluid dynamics equations must be solved, that require a huge amount of resources. OK, the response time needed for a ship is much longer, than for a car, yes, but to compute it predictively, one needs a huge amount of computational power.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-23T09:56:11.290Z
Answers.LastActivityDate: 2020-06-23T09:56:11.290Z
Answers.UserDisplayName: tmaric
Answers.Body: <p>The question is generalizability. I completely agree though but, ideally the policy found will generalize to more complex environments the model hasn't seen. You could also run a planner on a new scenario but the issue is that it would be too computationally demanding for real time.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-28T05:33:31.280Z
Answers.LastActivityDate: 2020-12-28T05:33:31.280Z
Answers.UserDisplayName: FourierFlux
Body: <p>Most reinforcement learning agents are trained in simulated environments. The goal is to maximize performance in (often) the same environment, preferably with a minimum amount of interactions. Having a good model of the environment allows to use planning and thus drastically improves the sample efficiency!</p>
  
  <p><strong>Why is the simulation not used for planning</strong> in these cases? It is a sampling model of the environment, right? Can't we try multiple actions at each or some states, follow the current policy to look several steps ahead and finally choose the action with the best outcome? Shouldn't this allow us to find better actions more quickly compared to policy gradient updates?</p>
  
  <p>In this case, our environment and the model are kind of identical and this seems to be the problem. Or is the good old curse of dimensionality to blame again? Please help me figure out, what I'm missing. </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-09T13:06:41.647Z
Comments.Text: Hi and welcome to AI SE! What makes you think that simulated environments are or can not be used for planning?
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-09T16:56:31.137Z
Comments.Text: Hi @nbro! Thank you for the warm comment and the helpful question, which I'm happy to answer: afaiu, the most popular deep RL algorithms are model-free. These are sample inefficient as they learn from pure interactions with the environment. An agent with a good model of the environment could use the model to plan ahead. This way the agent would get experience without interacting with the environment and thus increase the sample efficiency. When this is true, why are popular algorithms like PPO still very sample inefficient? I think I'm missing something. Please help : )
Comments.UserDisplayName: Ray Walker
Tags: <reinforcement-learning><models><planning><model-based-methods>
Title: Isn't a simulation a great model for model-based reinforcement learning?
UserDisplayName: Ray Walker
ThreadText: # Isn't a simulation a great model for model-based reinforcement learning?
  
  (Asked by: username_0 on 2020-04-09)
  
  Most reinforcement learning agents are trained in simulated environments. The goal is to maximize performance in (often) the same environment, preferably with a minimum amount of interactions. Having a good model of the environment allows to use planning and thus drastically improves the sample efficiency!
  
  **Why is the simulation not used for planning** in these cases? It is a sampling model of the environment, right? Can't we try multiple actions at each or some states, follow the current policy to look several steps ahead and finally choose the action with the best outcome? Shouldn't this allow us to find better actions more quickly compared to policy gradient updates?
  
  In this case, our environment and the model are kind of identical and this seems to be the problem. Or is the good old curse of dimensionality to blame again? Please help me figure out, what I'm missing.
  
  **Tags:** reinforcement-learning, models, planning, model-based-methods
  
  > **Comments:**
  > **username_1**: Hi and welcome to AI SE! What makes you think that simulated environments are or can not be used for planning?  
  > **username_0**: Hi @username_1! Thank you for the warm comment and the helpful question, which I'm happy to answer: afaiu, the most popular deep RL algorithms are model-free. These are sample inefficient as they learn from pure interactions with the environment. An agent with a good model of the environment could use the model to plan ahead. This way the agent would get experience without interacting with the environment and thus increase the sample efficiency. When this is true, why are popular algorithms like PPO still very sample inefficient? I think I'm missing something. Please help : )  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2020-11-28. Score: 1
  
  I will give one perspective on this from the domain of robotics. You are right that most RL agents are trained in simulation particularly for research papers, because it allows researchers to in theory benchmark their approaches in a common environment. Many of the environments exist strictly as a test bed for new algorithms and are not even physically realizable, e.g. [HalfCheetah](https://gym.openai.com/envs/HalfCheetah-v2/). You could in theory have a separate simulator say running in another process that you use as your planning model, and the "real" simulator is then your environment. But really that's just a mocked setup for what you really want in the end, which is having a real-world agent in a real-world environment.
  
  What you describe could be very useful, with one important caveat: the simulator needs to in fact be a good model of the real environment. For robotics and many other interesting domains, this is a tall order. Getting a physics simulator that faithfully replicates the real-world environment can be tricky, as one may need accurate friction coefficients, mass and center of mass, restitution coefficients, material properties, contact models, and so on. Oftentimes the simulator is too crude an approximation of the real-world environment to be useful as a planner.
  
  That doesn't mean we're completely hosed though. [This paper](https://arxiv.org/pdf/1810.05687.pdf) uses highly parallelized simulators to search for simulation parameters that approximate the real-world well. What's interesting is it's not even necessarily finding the correct real-world values for e.g. friction coefficients and such, but it finds values for parameters that, taken together, produces simulations that match the real-world experience. The better the simulation gets at approximating what's going on in the real world, the more viable it is to use the simulator for task planning. I think with the advent of [GPU-optimized physics simulators](https://developer.nvidia.com/isaac-gym) we will see simulators be a more useful tool even for real-world agents, as you can try many different things in parallel to get a sense of what is the likely outcome of a planned action sequence.
  
  
  ---
  
  ### Answer by username_3 on 2020-06-23. Score: 0
  
  > Shouldn't this allow us to find better actions more quickly compared to policy gradient updates?
  
  It depends on the nature of the simulation. If the simulation models a car as a solid body moving with three $(x,y,\theta)$ degrees of freedom in a plane (hopefully, if it doesn't hit anything and propel vertically), the three ordinary differential equations of solid body motion can be solved quite quickly, compared to a simulation used to model the path of least resistance of a ship on wavy sea, where fluid dynamics equations must be solved, that require a huge amount of resources. OK, the response time needed for a ship is much longer, than for a car, yes, but to compute it predictively, one needs a huge amount of computational power.
  
  
  ---
  
  ### Answer by username_4 on 2020-12-28. Score: 0
  
  The question is generalizability. I completely agree though but, ideally the policy found will generalize to more complex environments the model hasn't seen. You could also run a planner on a new scenario but the issue is that it would be too computationally demanding for real time.
  
  
  ---
  
  