Invalid size or type for observation specification. Simulink Environment for Reinforcement Learning

10 visualizaciones (últimos 30 días)
I'm trying to define a Simulink Environment for Reinforcement Learning describing a Mass Spring Damper System. In particular, I would like to consider 3 observations (position, velocity and accelleration) and only 1 continuos action as manipulated variable.
This is a part of my code:
%Defining action signal
actionInfo = rlNumericSpec([1 1]);
actionInfo.Name = 'Control Force';
%Defining observation signal
observationInfo = rlNumericSpec([3 1]);
observationInfo.Name = 'Obs';
observationInfo.Description = 'Position, Velocity and Accelleration';
%Creating environment object
env = rlSimulinkEnv(mdl,[mdl '/RL Agent'], observationInfo, actionInfo);
I get this error:
Error using rlSimulinkEnv>localValidateIOSpecs
Invalid size or type for observation specification.
Error in rlSimulinkEnv (line 90)
localValidateIOSpecs(numAgents,observationInfo,actionInfo);
Error in Tentativo1 (line 48)
env = rlSimulinkEnv(mdl,[mdl '/RL Agent'], observationInfo, actionInfo);
The integral code is in the files attached below.
Thak you for your attention, I'll wait for your help.

Respuestas (1)

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis el 27 de En. de 2023
Editada: Emmanouil Tzorakoleftherakis el 27 de En. de 2023
I had a look at the attached zip. The error is on line 33 in 'Tentativo1.m'. This line should be
mdl = 'RL'; % make sure your current folder is in the MATLAB path
Before, you had the '.slx' extension there and when you where creating the environment, it made it look like you had 2 agents in your model.
Note that there is (at least) one more error in your code, in the reset function (line 77) - n value has not been assigned before that point

Community Treasure Hunt

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

Start Hunting!

Translated by