Disable logging to disk from Simulink, during Reinforcement Learning training

1 次查看(过去 30 天)
I'm using the train function to run a Reinforcement Learning training using a PPO agent, with a rlSimulinkEnv object defining the environment.
Regarding the rlTrainingOptions, I'm using the default option for "SimulationStorageType", which is "memory". So I expect (if I understand correctly) that all the simulation data should be saved to RAM, not to disk, whenever possible. However I noticed that Simulink is actually saving the simulation data into .dmr files stored in my TEMPDIR.
I also tried to disable the Simulink logging to TEMPDIR directly from the Simulink Data Inspector, setting the Record Mode to "View during simulation only". However, as soon as I start the Reinforcement Learning Training, the simulation data are still saved as .dmr files in my TEMPDIR.
Is there a way to actually avoid saving .dmr files to TEMPDIR when training in a Simulink environment, and instead using only RAM to store the simulation data as long as the Matlab session is active?
I'm using version R2024a

回答(2 个)

Ruchika Parag
Ruchika Parag 2024-7-19
Hi Federico, it seems like Simulink is saving simulation data to .dmr files in your temporary directory, despite using the 'rlTrainingOptions' with 'SimulationStorageType' set to "memory". Here are steps to ensure data is stored in RAM:
1. Simulink Data Inspector Settings
Ensure logging is set to "View during simulation only" and "Save data in MAT files" is unchecked:
  1. Open Simulink Data Inspector.
  2. Go to Preferences (gear icon).
  3. Set "Record mode" to "View during simulation only".
  4. Uncheck "Save data in MAT files".
2. Make sure your training options specify to use memory:
trainingOptions = rlTrainingOptions(...
'MaxEpisodes', 1000, ...
'MaxStepsPerEpisode', 500, ...
'StopTrainingCriteria', 'AverageReward', ...
'StopTrainingValue', 500, ...
'ScoreAveragingWindowLength', 100, ...
'SaveAgentCriteria', 'EpisodeReward', ...
'SaveAgentValue', 500, ...
'SimulationStorageType', 'memory');
3. Model Configuration
Disable unnecessary logging in your Simulink model:
  1. Open Configuration Parameters (Ctrl+E).
  2. Under "Data Import/Export", disable unnecessary logging options.
4. Model Callbacks
Check for callbacks that may log data to disk:
  1. Open Model Properties.
  2. Check the "Callbacks" tab.
5. Programmatically Disable Logging
Use 'set_param' to disable logging:
set_param(gcs, 'DataLogging', 'off');
set_param(gcs, 'SignalLogging', 'off');
set_param(gcs, 'DSMLogging', 'off');
set_param(gcs, 'SaveFormat', 'Array');
By following these steps, you should be able to keep the simulation data in RAM.

Federico Toso
Federico Toso 2024-7-24
Hello, thank you for the suggestions. Unfortunately I haven't been able to solve the problem so far.
Actually I would like to keep logging my Simulink signals, but save them to memory rather than to disk. So disabling the logging completely is not a solution for my problem.
Regarding the settings of Simulink Data inspector, I could not find the setting "Save data in MAT files" that you mentioned. Could you please be more specific about its location? I'm using Matlab R2024a, in case this makes any difference
Thank you!

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by