Search Unity

Speeding up simulation

Discussion in 'ML-Agents' started by alvaro_unity903, Mar 25, 2021.

  1. alvaro_unity903

    alvaro_unity903

    Joined:
    Jan 20, 2020
    Posts:
    21
    I'm looking for a way to increase my simulation speed without affecting my physics by doing so. Is there a way I can have my Agents collecting observations outside of the FixedUpdate step? I would like to use a 0'2 seconds step for my observations, however, increasing my Fixed TimeStep to 0'2 will heavily reduce my physics accuracy, resulting in a bad collision calculations. Any idea on how to approach this?
     
  2. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    You can speed up the simulation speed by changing the time scale in Project Settings -> Time -> Time Scale. The default is 20 (20x real time) when using the
    mlagents-learn
    command, you can override that default using the
    --time-scale=
    argument. Time scale can also be changed in the config file.

    Yes but be aware this is different than increasing your simulation speed. By default ml-agents implements a lifecycle around the FixedUpdate, to turn this off set the AutomaticSteppingEnabled property to false at the beginning of training. Keep in mind this disables all the automated stuff you're probably used to, you'll need to implement your own system of sending observations and requesting actions manually. You wont be able to use pre-built components like the Decision Requester either.
     
  3. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    735
    Hi @alvaro_unity903,
    You have a couple of options.
    You could setup the decision requested to request every 0.2 seconds by calculating how many steps would need to happen. I think physics runs at 50fps so 0.02 seconds. That means you’d want the DecisionRequester to request decisions every 10 steps to get an observation every 0.2 seconds.

    alternatively you could disable automatic stepping from the academy, have some class that keeps track of time and calls Academy.Instance.EvironmentStep every 0.2 seconds.

    Let me know if you have further questions.
     
  4. alvaro_unity903

    alvaro_unity903

    Joined:
    Jan 20, 2020
    Posts:
    21
    Thank both of you. We have been playing with the time scale, but we want to increase the speed more. Now, we have a bottleneck in the AI part. To improve this, and also the learning, we want to take agent observations and request decisions every 0.2 seconds.

    We are going to research the DecisionRequester settings. Thank you, this makes sense and seems a useful way to improve without adding extra code.
     
    christophergoy likes this.