Disable logging to disk from Simulink, during Reinforcement Learning training
이전 댓글 표시
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
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:
- Open Simulink Data Inspector.
- Go to Preferences (gear icon).
- Set "Record mode" to "View during simulation only".
- 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:
- Open Configuration Parameters (Ctrl+E).
- Under "Data Import/Export", disable unnecessary logging options.
4. Model Callbacks
Check for callbacks that may log data to disk:
- Open Model Properties.
- 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.
카테고리
도움말 센터 및 File Exchange에서 Reinforcement Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!