%% Configure Parallel Computing Options for Training
% To turn on parallel computing for training a reinforcement learning agent, set the UseParallel training option to true.

trainOpts = rlTrainingOptions('UseParallel',true);

%
% To configure your parallel training, configure the fields of the trainOpts.ParallelizationOptions. For example, specify the following training options:
% Asynchronous mode
% Workers send data to the host every 100 steps within a training episode
% Workers compute and send gradients to the host

trainOpts.ParallelizationOptions.Mode = "async";
trainOpts.ParallelizationOptions.StepsUntilDataIsSent = 100;
trainOpts.ParallelizationOptions.DataToSendFromWorkers = "Gradients";
trainOpts.ParallelizationOptions

%
% You can now use trainOpts as an input argument to the train command to perform training with parallel computing.
% Copyright 2019 The MathWorks, Inc.