Clear Filters
Clear Filters

What is the difference between sim (RL toolbox) and directly click "run" in the Simulink Model

1 view (last 30 days)
sim - Simulate trained reinforcement learning agents within specified environment
After training my RL agent I use TestSim = sim(agent,env) to test my trained agent.
However, I find that the agent performence is different and much worse if I directly click run bottom is the Simulink model pannel rather than using sim command.
I have checked that in my Simulink model the RL agent block has correctly quoted my trained agent in the MATLAB workspace

Answers (1)

Krishna
Krishna on 8 Jul 2024
Hey,
I understand that you are facing worse performance when running directly from simulink. Can you please check the following things,
  1. Ensure initial conditions are identical for both methods. Running the simulation directly from the panel might use default initial conditions different from those set in the 'sim' command
  2. Verify consistency in simulation parameters (start/stop times, solver settings, step sizes) between both methods
  3. Set the random seed to the same value for both simulations to ensure consistency in the agent's performance
  4. Check for any callbacks or scripts that might run when starting the simulation from the Simulink panel, as they can alter the simulation behavior.
Also ensure the Simulink model references the correct and current version of the trained agent from the MATLAB workspace.
Please go through the following documentation to learn more about 'sim' command and its default values to be used while simulation,
Also please share the simulation model for further investigation if possible.
Hope this helps.

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!