解决ODE-仅是积极的解决方案 [英] Solving ODEs - only positive solutions

查看:98
本文介绍了解决ODE-仅是积极的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解决仅限于积极解决方案的ODE,即:

I am trying to to solve ODEs restricted to positive solutions, i.e.:

dx/dt=f(x)

x>=0.

在MATLAB中,这非常容易实现. R是否有任何解决方法或软件包将解决方案空间限制为仅正值?

In MATLAB this is very easy to implement. Is there any workaround or package for R to restrict the solution-space to positive values only?

在我的情况下,这非常关键,不幸的是没有其他选择.我搜索了一段时间,但没有成功. :-(

This is very crucial in my case and unfortunately there is no alternative. I searched for a while now but without any success. :-(

推荐答案

这里仍然没有足够的内容.对于我所熟悉的各种问题,修改系统使其在对数转换后的状态变量的范围内运行效果很好(您可以始终对结果进行逆转换,例如将其与数据进行比较).例如,我已将其用于流行病学中的SIR模型.我将尝试使用@MauritsEver的示例,以说明如何将系统转换为以对数刻度运行​​:

There's still not quite enough to go on here. For the sorts of problems I'm familiar with, modifying the system to operate on the scale of the log-transformed state variables works well (you can always back-transform the results e.g. to compare them with data). I have used this, for example, with the SIR model in epidemiology. I'm going to try with @MauritsEver's example, to illustrate transforming the system to operate on the log scale:

library(deSolve)
model <- function (time, y, parms) {
   with(as.list(c(y, parms)), {
       dlogN <-   r * (1 - exp(logN) / K)
       list(dlogN)
   })
}

# Starting conditions
y <- c(logN = log(0.1))
parms <- c(r = 0.1, K = 10)
times <- seq(0, 100, 1)
out <- as.data.frame(ode(y, times, model, parms))
out_backtran <- transform(out,N=exp(logN))
plot(N~time,data=out_backtran)

此方法具有以下缺点:

  • 它不会处理恰好在边界上的解决方案,并且会遇到过快"(即状态变量在有限时间内收敛到零的情况)接近边界的解决方案的问题
  • 按照书面规定,它需要人工翻译.完全有可能编写一个系统,允许用户输入一组方程式和一组转换并自动应用转换,但这会很费力.
  • 它可能会稍微增加计算工作量(任何时候我们必须使用必须求幂的状态变量的原始比例值)

这篇关于解决ODE-仅是积极的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆