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

R语言 simecol包 iteration()函数中文帮助文档(中英文对照)

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

                                        Discrete Simulation
                                         离散模拟

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

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

Solver function to simulate discrete ecological (or other) dynamic models. It is normally called indirectly from sim.
求解器的功能,以模拟离散生态(或其他)动态模型。它通常被间接地从sim。


用法----------Usage----------


  iteration(y, times=FALSE, func=FALSE, parms=FALSE, animate = FALSE, ...)



参数----------Arguments----------

参数:y
the initial values for the system.  If y has a name attribute, the names will be used to label the output matrix.
系统的初始值。 y如果有一个name属性,名称将被用于标记输出矩阵。


参数:times
times at which explicit estimates for y are desired.  The first value in times must be the initial time.
的显式估计为y需要的时间。 times的第一个值必须是初始时间。


参数:func
a user-supplied function that computes the values of the next time step (not the derivatives !!!)  in the system (the model defininition) at time t. The user-supplied function  func must be called as: yprime = func(t, y, parms).  t is the current time point in the integration, y is the current estimate of the variables in the ode system, and parms is a vector of parameters (which may have a names attribute, desirable in a large system).  The return value of func should be a list, whose first element is a vector containing the derivatives of y with respect to time, and whose second element is a vector (possibly with a names attribute) of global values that are required at each point in times.
一个用户提供的函数,计算系统中的下一个时间步长(而不是衍生工具!)(模型defininition)在时间t的值。用户提供的函数func,,必须称为:yprime = func(t, y, parms)。 t是当前时间点的整合,y是目前估计的颂歌系统中的变量,和parms是一个向量参数(可能有一个名称属性,希望在一个大系统)。返回值的函数应该是一个列表的第一个元素是一个向量,包含衍生工具的y就time,和第二个元素是一个向量(可能与names属性)times中的每个点在全球所需要的值。


参数:parms
vector or list holding the parameters used in func  that should be modifiable without rewriting the function.
矢量或列表保存在func这应该是可修改的不重写该功能的情况下所使用的参数。


参数:animate
Animation during the simulation (if available for the specified class.
在模拟过程中的动画(如果有指定的类。


参数:...
optional arguments passed to the plot function if animate=TRUE.
可选参数传递给plot功能animate=TRUE。


Details

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

The solver method iteration is used to simulate discrete event models.  Normally, this function is run indirectly from sim.
求解方法iteration是用来模拟离散事件模型。通常情况下,这个功能是间接地从sim运行。

In contrast to differential equation solvers, the main function of the model must not return the first derivative but instead and explicitly the new state at the specified times.
相反的差分方程解算器,main功能的模型不能返回的一阶导数,但在指定的时间,而不是明确的新的国家。

The actual value of time is available in the main function as time and the current increment as parms["DELTAT"] or parms$DELTAT. It is element of a vector if parms is a vector and it is a list if parms is a list.
是为main和time或parms["DELTAT"]电流的增加,可以在parms$DELTAT功能的实际值。如果parms是一个向量,如果parms是一个列表,它是一组元素的矢量。

If iteration is used for difference equations (see example dlogist below), it is mandatory to multiply the incremental part with DELTAT to ensure that variable time steps are correctly respected and that the first row of the simulation outputs contains the states at t_0.
如果用于差分方程的迭代(见dlogist下面),它是强制性的增量部分乘以DELTAT,以确保变步长是正确的尊重和模拟输出的第一行包含国家在t_0。

The default iteration method of class simObj supports the observer mechanism. This means that a function stored in slot observer is called during each iteration step with the return value of main as its first argument. You can use this to control the amount of data stored during each iteration step (e.g. whole population or only mean values for individual based models), to do run-time animation or to write log files.
默认iteration方法的类simObj支持observer机制。这意味着一个函数存储在插槽observer中main作为第一个参数的返回值每步迭代过程中调用。您可以使用它来控制存储的数据量在每次迭代步骤(例如,整个人口平均值为单独的模型),运行时的动画或写入log文件。


值----------Value----------

A list of the model outputs (states ...) for each timestep.
列表模型输出(州)为每一个时间步。


参见----------See Also----------

sim,  observer, parms, lsoda, rk4, euler.
sim,observer,parms,lsoda,rk4,euler。


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


data(conway)
## plot after simulation:[#图后模拟:]
plot(sim(conway), delay=100)

## plot during simulation[在模拟过程中的#图]
sim(conway, animate=TRUE, delay=100)

## discrete version of logistic growth equation[#离散Logistic增长方程]
## Note: function main returns the *new value*, not the derivative[#注:*新的main函数的返回值*,而不是衍生工具]

dlogist <- new("odeModel",
  main = function (time, init, parms, ...) {
    x <- init
    with(as.list(parms), {
      x <- x + r * x * (1 - x / K) * DELTAT
      #   ^^^ add to old value       ^^^^^^ special parameter with time step[^ ^ ^添加到旧值^ ^ ^ ^ ^ ^特殊参数与时间步长]
      list(c(x))
    })
  },
  parms  = c(r=0.1, K=10),
  times  = seq(0, 100, 1),
  init   = c(population=0.1),
  solver = "iteration" #!!![!]
)

plot(sim(dlogist))

## alternative with function that returns the derivative[#替代返回衍生工具的功能,]
## discrete steps are realized with the euler method[#离散的步骤来实现的欧拉法]

dlogist <- new("odeModel",
  main = function (time, init, parms, ...) {
    x <- init
    with(as.list(parms), {
      x <- r * x * (1 - x / K)
      list(c(x))
    })
  },
  parms  = c(r=0.1, K=10),
  times  = seq(0, 100, 1),
  init   = c(population=0.1),
  solver = "euler"
)

plot(sim(dlogist))


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-24 06:38 , Processed in 0.026603 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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