找回密码
 注册
查看: 294|回复: 0

R语言 Simile包 Simile-package()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 02:51:04 | 显示全部楼层 |阅读模式
Simile-package(Simile)
Simile-package()所属R语言包:Simile

                                         Interface to executable Simile models
                                         接口可执行的比喻模型

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

This package loads, parameterizes, executes and interrogates executable models saved by Simile.
这个包的负载,参数化,执行和保存比喻询问可执行的模型。


Details

详细信息----------Details----------

Package:
包装方式:

</td><td align="left"> Simile
</ TD> <TD ALIGN="LEFT">比喻

Type:
类型:

</td><td align="left"> Package
</ TD> <TD ALIGN="LEFT">包装

Version:
版本:

</td><td align="left"> 1.0
</ TD> <TD ALIGN="LEFT"> 1.0

Date:
日期:

</td><td align="left"> 2011-05-30
</ TD> <TD ALIGN="LEFT"> 2011-05-30

License:
许可:

</td><td align="left"> Unrestricted
</ TD> <TD ALIGN="LEFT">无限制

LazyLoad:
LazyLoad:

</td><td align="left"> yes
</ TD> <TD ALIGN="LEFT">是

The package loads some Simile libraries into R's tcltk extension, so you need Simile installed to use it. Initialize the package by calling use.simile.at() to tell it where to find Simile in the file system. Tell it where to find the saved executable model with load.model() which returns a handle to the loaded model. This can be used to interrogate static model info via list.objects() and get.model.property(), and to create executable instances with create.model(), which returns their handles.
包加载一些的明喻库到R的tcltk的扩展,所以你需要比喻安装使用。初始化包的的调用use.simile.at()来告诉它在哪里可以找到文件系统中的比喻。告诉它在哪里可以找到保存的可执行模型与load.model()返回的句柄加载的模型。这可用于静态模型信息通过list.objects()和get.model.property()查询,并创建可执行的情况下,与create.model(),它返回其句柄。

An executable instance can be parameterized either by loading a Simile parameter metafile with consult.parameter.metafile(), or directly from R arrays with create.param.array() and set.model.parameter(). The functions set.model.step(), reset.model() and execute.model() control execution. get.model.time() returns the time at which execution finished. Use get.value.array() to get the values from any model component as an R array, or get.value.list() to get them as an R list.
通过加载一个比喻参数图元文件consult.parameter.metafile(),或者直接从R阵列与create.param.array()和set.model.parameter(),一个可执行的实例可以被参数化。 “的功能set.model.step(),的reset.model()和execute.model()控制的执行。 get.model.time()返回的时间执行完毕。中使用get.value.array()得到的值,任何模型组件R数组,或get.value.list的的(),让他们的R列表。


(作者)----------Author(s)----------



Simulistics Ltd




参考文献----------References----------



实例----------Examples----------






require("Simile")
path.to.installation <- tcl("tk_chooseDirectory", "-title",
"Folder where Simile is installed:")
use.simile.at(path.to.installation)

exec.extn <- as.character(tcl("info","sharedlibextension"))
path.to.spiro <- tcl("tk_getOpenFile",
                     "-title", "Compiled binary for Spiro example:",
                     "-initialfile", paste("spiro",exec.extn,sep=""))
mHandle <- load.model(path.to.spiro)
objs <- list.objects(mHandle)

for (obj in objs) {
  print(c(obj, get.model.property(mHandle, obj, "Class")))
}

iHandle <- create.model(mHandle)
set.model.step(iHandle, 1, 1)

# now we are going to parameterize it using a state file for the slider helper[现在我们将它参数化使用状态文件的滑块帮手]
# -- to make this work we add / to end of destination submodel name[ - 使这项工作,我们的目标子模型名称添加/结束]
# and load the mime library, which is needed for this type of file.[和加载的mime库为这种类型的文件,这是需要的。]
# This must be done before initializing model to avoid error messages[这之前,必须完成初始化模式,以避免错误消息]
tcl("package","require","mime")
pFile  <- tcl("file", "join", path.to.installation, "Examples", "dancer.spf")
consult.parameter.metafile(iHandle, pFile, "/")

# also the file from the distribution has no value for "Wheel outside?"[也从分发的文件“轮外有没有价值?”]
# so we set this boolean directly[所以我们直接设置这个布尔]
pHandle <- create.param.array(iHandle, "/start/Wheel outside?")
set.model.parameter(pHandle, FALSE)

# initialize the model, including default slider values[初始化的模型,包括默认的滑块值]
reset.model(iHandle, -2)

# unfortunately this overwrites time series values with their defaults from[不幸的是,这将覆盖从时间序列值,其默认值]
# the model code, so we will get the default pattern even though we loaded[型号代码,所以我们会得到默认的模式即使我们装]
# 'dancer' -- display it anyway[“舞者” - 显示也无妨]

xs <- list(get.value.list(iHandle, "/runs/x"))
ys <- list(get.value.list(iHandle, "/runs/y"))
for (count in 1:1739) {
  execute.model(iHandle, count)
  xs[[count+1]] <- get.value.list(iHandle, "/runs/x")
  ys[[count+1]] <- get.value.list(iHandle, "/runs/y")
}
xs <- mapply(c,xs)
ys <- mapply(c,ys)
plot(xs, ys, type="l")
print("View default pattern -- now try to plot dancer")
scan(nmax=0) # hit cr to continue[打CR继续]

# load parameters again (except wheel outside which defaults FALSE)[重新加载参数(除车轮外,默认值为FALSE)]
consult.parameter.metafile(iHandle, pFile, "/")

# apply reset at level 0 to propagate input values[申请重置0级到传播的输入值]
reset.model(iHandle, 0)

xs <- list(get.value.list(iHandle, "/runs/x"))
ys <- list(get.value.list(iHandle, "/runs/y"))
for (count in 1:419) {
  execute.model(iHandle, count)
  xs[[count+1]] <- get.value.list(iHandle, "/runs/x")
  ys[[count+1]] <- get.value.list(iHandle, "/runs/y")
}
xs <- mapply(c,xs)
ys <- mapply(c,ys)
plot(xs, ys, type="l")

print("OK, but that's not how it looks on Simile is it? Try this...")
scan(nmax=0) # hit cr to continue[打CR继续]
xs <- aperm(xs, c(2,1))
ys <- aperm(ys, c(2,1))
plot(xs, ys, type="l")


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-5-24 11:47 , Processed in 0.023551 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表