Thomas,

It is a limitation of the function you are using. The method "vode" is an 
implicit method, meaning that it has to create and invert a matrix of the size 
= number of variables ^2. In your case, this is a full matrix of 33000 rows and 
columns.
If your ODE is easy to solve, you might try to use method = "adams" or method = 
"ode45", which will select an explicit method, that does not need this huge 
matrix.
If you are trying to solve a PDE, you probably want to use ode.1D or ode.2D or 
ode.3D depending on the dimensionality of your PDE. It is possible to solve 
problems of the order 1e5 variables with these functions.
If it is not a PDE, and it cannot be solved with adams or ode45, then you might 
try method = "lsodes" which will select a sparse solver.


Hope this helps,

Karline

By the way, there exists a mailing list, called R-sig-dynamic-models that deals 
with this type of questions.

Original message:

Date: Fri, 3 Feb 2012 09:33:05 -0500

From: Thomas Brown <thomasbrown8...@gmail.com<mailto:thomasbrown8...@gmail.com>>

To: r-help@r-project.org<mailto:r-help@r-project.org>

Subject: [R] ode() tries to allocate an absurd amount of memory

Message-ID:

               
<caf9vq7znr26sxucrdsyem1ietttaj13tmnvdncpfz8t56yj...@mail.gmail.com<mailto:caf9vq7znr26sxucrdsyem1ietttaj13tmnvdncpfz8t56yj...@mail.gmail.com>>

Content-Type: text/plain



Hi there R-helpers:



I'm having problems with the function ode() found in the package deSolve.

It seems that when my state variables are too numerous (>33000 elements),

the function throws the following error:



Error in vode(y, times, func, parms, ...) :

  cannot allocate memory block of size 137438953456.0 Gb

In addition: Warning message:

In vode(y, times, func, parms, ...) : NAs introduced by coercion



This appears to be case regardless of the computer I use; that is, whether

it's a laptop or server with 24Gb of RAM. Why is ode() trying to allocate

137 billion gigabytes of memory?! (I receive exactly the same error message

whether I have, for example, 34000 or 80000 state variables: the amount of

memory trying to be allocated is exactly the same.) I have included a

trivial example below that uses a function that returns a rate of change of

zero for all state variables.



> require(deSolve)

Loading required package: deSolve

> C<-rep(0,34000)

> TestFunc<-function(t,C,para){

+         return(list(rep(0,length(C))))

+ }

> soln<-ode(y=C,times=seq(0,1,0.1),func=TestFunc,parms=c(0),method="vode")

Error in vode(y, times, func, parms, ...) :

  cannot allocate memory block of size 137438953456.0 Gb

In addition: Warning message:

In vode(y, times, func, parms, ...) : NAs introduced by coercion

>



Am I making a foolish mistake somewhere or is this simply a limitation of

the function?



Thanks in advance!


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to