How to set the state with different variables in properties?

1 回表示 (過去 30 日間)
Yang Chen
Yang Chen 2023 年 3 月 5 日
I am writing the custom reinforcement learning environment via template. I want to initialize state within properties. The following is from my current scripts. The scripts are based on the class called rl.env.MATLABEnvironment. The properties of this class can't accept the structure definition.
properties
% Initialize system state [schedule,ppath,completionTime,computeDuring]'
% schedule = [];
% ppath = [];
% completionTime = Inf;
% computeDuring = 0;
State = zeros(4,1)
end
However, I don't know how to definite State. In the above case, State consists of schedule, ppath, completionTime and computerDuring, where schedule and ppath are vectors, while completionTime and computerDuring are numbers. If I just define them as zeros(4,1), it doesn't work.

採用された回答

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2023 年 3 月 6 日
Hi Yang,
We have an example in Reinforcement Learning Toolbox that does training based on nonhomogeneous observations, and specifically a combination of scalars and images. This example is available as a predefined environment and you can actually check the code to see how we implemented it. If you do
edit rl.env.AbstractSimplePendlumWithImage
you will see that we create the state in the properties similar to what you do but this is only for the scalar states of the dynamical equations. The nonhomogeneous observations are passed internally as cell arrays starting from the 'reset' function.
Hope that helps

その他の回答 (1 件)

Luca Ferro
Luca Ferro 2023 年 3 月 6 日
編集済み: Luca Ferro 2023 年 3 月 6 日
use a struct:
state.schedule= [];
state.path=[];
state.completionTime=Inf;
state.computerDuring=0;
this will create a struct with said fields. You can access them by using state.schedule, state.path etc
  1 件のコメント
Yang Chen
Yang Chen 2023 年 3 月 6 日
Sorry, it doesn't work. My class is based on rl.env.MATLABEnvironment, which can't accept this synax.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironments についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by