我正在开发一个R包,其中包含以下功能:
#' @export
makeEnvironment = function(name) {
envir = R6::R6Class(
public = list(
initialize = function(name) {
remote.base = "http://127.0.0.1:5000"
private$client = gym::create_GymClient(remote.base)
private$instance.id = gym::env_create(private$client, name)
outdir = "/tmp/random-agent-results"
gym::env_monitor_start(private$client, private$instance.id, outdir,
force = TRUE, resume = FALSE)
print(gym::env_action_space_info(private$client, private$instance.id))
}
),
private = list(
client = NULL,
instance.id = NULL
)
)
package.path = system.file(package = "reinforcelearn")
path2pythonfile = paste0(package.path, "/gym_http_server.py")
system2("python", args = path2pythonfile, stdout = NULL, wait = FALSE)
envir$new(name)
}
我可以在此处找到我调用的python脚本:https://github.com/openai/gym-http-api/blob/master/gym_http_server.py
当我启动RStudio时,加载包并运行makeEnvironment("MountainCar-v0")
我收到错误
curl :: curl_fetch_memory(url,handle = handle)出错:无法执行 连接到127.0.0.1端口5000:拒绝连接
由gym::env_create(private$client, name)
引起。如果我再次重复makeEnvironment("MountainCar-v0")
,它就可以了。
有人可以帮忙吗?为什么我会收到此错误以及如何解决此问题?
会话信息
R版本3.4.1(2017-06-30)平台:x86_64-w64-mingw32 / x64(64位) 运行于:Windows> = 8 x64(build 9200)
Matrix产品:默认
locale:[1] LC_COLLATE = German_Germany.1252 LC_CTYPE = German_Germany.1252 LC_MONETARY = German_Germany.1252 [4] LC_NUMERIC = C LC_TIME = German_Germany.1252
附加基础包:[1] stats graphics grDevices utils
数据集方法基础其他附件包:[1] reinforcelearn_0.0.0.9070
通过命名空间加载(而不是附加):[1] httr_1.2.1
compiler_3.4.1 backports_1.1.0 R6_2.2.2 Matrix_1.2-10
tools_3.4.1 [7] nnet_7.3-12 curl_2.8.1
MDPtoolbox_4.0.3 grid_3.4.1 checkmate_1.8.3 jsonlite_1.5
[13] gym_0.1.0 linprog_0.9-2 lattice_0.20-35