R MDPtoolbox: как увеличить количество итераций (используя R) - PullRequest
0 голосов
/ 25 мая 2019

Я занимаюсь разработкой модели обучения подкреплению на R и хочу увеличить количество итераций решателя MDPtoolbox (решатель $ iter ), есть идеи, пожалуйста?

ниже - мой код, который дает только 3 итерации, как заставить модель иметь больше итераций. 10 ^ 2, 10 ^ 3 ... или 10 ^ n например?

# clear the workspace
cat("\014")
rm(list = ls())
print('START...')

install.packages("MDPtoolbox")
library(MDPtoolbox)

# Defining the Set of Actions - Left, Right, Up and Down for 2*2 matrix
# Remember! This will be a probability matrix, so we will use the matrix() function such that the sum of probabilities in each row is 1

#Up Action
#   s1 s2 s3 s4
up=matrix(c( 1, 0, 0, 0, #s1
             1, 0, 0, 0, #s2
             0, 0, 0, 1, #s3
             0, 0, 0, 1),#s4
          nrow=4,ncol=4,byrow=TRUE)

#Down Action
down=matrix(c(0, 1, 0, 0,
              0, 1, 0, 0,
              0, 0, 1, 0,
              0, 0, 1, 0),
            nrow=4,ncol=4,byrow=TRUE)

#Left Action
left=matrix(c( 1, 0, 0, 0,
               0, 1, 0, 0,
               0, 1, 0, 0,
               0, 0, 0, 1),
            nrow=4,ncol=4,byrow=TRUE)

#Right Action
right=matrix(c( 1, 0, 0, 0,
                0, 0, 1, 0,
                0, 0, 1, 0,
                0, 0, 0, 1),
             nrow=4,ncol=4,byrow=TRUE)

#Combined Actions matrix
Actions=list(up=up, down=down, left=left, right=right)

# Defining the rewards and penalties
Rewards=matrix(c( -1, -1, -1, -1,
                  -1, -1, -1, -1,
                  -1, -1, -1, -1,
                  10, 10, 10, 10),
               nrow=4,ncol=4,byrow=TRUE)

# Solving the navigation
solver=mdp_policy_iteration(P=Actions, R=Rewards, discount = 0.1)

# Getting the policy
solver$policy #2 4 1 1
names(Actions)[solver$policy] #"down" "right" "up" "up"

# Number of iterations
solver$iter # <--- i want to increase this number
...