how to apply an action in an rl matlab environment
Show older comments
Hello everyone,
I have a functioning environment, and now I want to make it more complex, but I'm not sure how. The code displays a summary and part of my environment. I have 5 objects on which I apply actions, and the possible actions are either 0 or 1 (32 possible actions). These actions are applied to element 7 of the array "mult". Now, I want to do the same but for elements 7, 10, 13, and 16. In other words, the 32 possible actions should be executed at these 4 instances, and the actions at these instances may be the same or different. Let me explain with an example: action 4 is performed at 7, action 24 at 10, action 4 at 13, and action 18 at 16. The only idea I came up with, although not feasible, is to define all possible combinations (20 objects, each with 0 or 1). Could you please provide some guidance?
% Observation information
ObservationInfo = rlNumericSpec([1 99]);
% Action information
ActionInfo = rlFiniteSetSpec({[0 0 0 0 0], ...
[0 0 0 0 1], ...
[0 0 0 1 0], ...
[0 0 0 1 1], ...
[0 0 1 0 0], ...
[0 0 1 0 1], ...
[0 0 1 1 0], ...
[0 0 1 1 1], ...
[0 1 0 0 0], ...
[0 1 0 0 1], ...
[0 1 0 1 0], ...
[0 1 0 1 1], ...
[0 1 1 0 0], ...
[0 1 1 0 1], ...
[0 1 1 1 0], ...
[0 1 1 1 1], ...
[1 0 0 0 0], ...
[1 0 0 0 1], ...
[1 0 0 1 0], ...
[1 0 0 1 1], ...
[1 0 1 0 0], ...
[1 0 1 0 1], ...
[1 0 1 1 0], ...
[1 0 1 1 1], ...
[1 1 0 0 0], ...
[1 1 0 0 1], ...
[1 1 0 1 0], ...
[1 1 0 1 1], ...
[1 1 1 0 0], ...
[1 1 1 0 1], ...
[1 1 1 1 0], ...
[1 1 1 1 1]});
function [NextObservation, Reward, IsDone, UpdatedInfo] = StepFunctTest(Action, Info)
% Start communication with OpenDSS
% Load Info into loads and irradiance
% Apply action
DSSText.command = sprintf('New LoadShape.estado_cap_1 npts=24 interval=1 mult=(0 0 0 0 0 0 %d 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)', Action(1));
DSSText.command = sprintf('New LoadShape.estado_cap_2 npts=24 interval=1 mult=(0 0 0 0 0 0 %d 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)', Action(2));
DSSText.command = sprintf('New LoadShape.estado_cap_3 npts=24 interval=1 mult=(0 0 0 0 0 0 %d 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)', Action(3));
DSSText.command = sprintf('New LoadShape.estado_cap_4 npts=24 interval=1 mult=(0 0 0 0 0 0 %d 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)', Action(4));
DSSText.command = sprintf('New LoadShape.estado_cap_5 npts=24 interval=1 mult=(0 0 0 0 0 0 %d 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)', Action(5));
% Configure OpenDSS simulation
% Solve the system
% Obtain NextObservation (voltages)
% Calculate reward
% Determine if the episode is done
IsDone = Reward ~= 0;
end
Accepted Answer
More Answers (0)
Categories
Find more on Reinforcement Learning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!