Unrecognized method, property, or field 'randi' for class 'rl.util.r​lFiniteSet​Spec'.

1 回表示 (過去 30 日間)
Ankita Tondwalkar
Ankita Tondwalkar 2022 年 4 月 1 日
コメント済み: Ankita Tondwalkar 2022 年 4 月 2 日
Hello,
I am trying to sample an action from the actionspace which is in the predefined MATLAB environment 'BasicGridWorld'.
env = rlPredefinedEnv('BasicGridWorld');
obsInfo = getObservationInfo(env);
actInfo = getActionInfo(env);
disp(obsInfo)
disp(actInfo)
a= actInfo.randi()
However the actInfo belongs to the class rl.util.rlFiniteSetSpec which does not support rand or randi method and is of type string.
I suppose I have to first convert it to type num and then randomly select 1 out of the 4 actions from that class?
Is this approach correct?

回答 (1 件)

Geoff Hayes
Geoff Hayes 2022 年 4 月 1 日
@Ankita Tondwalkar - from here, actInfo is an array of rlNumericSpec objects | array of rlFiniteSetSpec objects. I think that you need to first determine the length of the array and then choose an integer between one and that length using randi.
  1 件のコメント
Ankita Tondwalkar
Ankita Tondwalkar 2022 年 4 月 2 日
@Geoff Hayes I did the following and this work.
A = ["N";"S";"E";"W"]
B= []
s = strrep(A,"N","1")
s1= strrep(s,"S","2")
s2= strrep(s1,"E","3")
s3 = strrep(s2,"W","4")
B = [s3]
Actions = cell2mat(arrayfun(@str2num,B,'uni',0))
randomIndex = randi(length(Actions), 1)
selected_A_value = Actions(randomIndex)

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

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by