On Wed, Oct 21, 2009 at 8:41 PM, Thomas Petzoldt <
Thomas.Petzoldt@tu-dresden.de> wrote:

> Soetaert, Karline wrote:
>
> [...]
>
> > A more appropriate model would be:
> >
> >
> > NoCrash <- function (time, N, parms) {
> >             with(as.list(parms),
> >                  {
> >                    dn <-  r * N * (1 - (N/K)) - h*(N>0)
> >                    if (! is.numeric(dn)) dn <- 0
> >                    list(dn)
> >                  }
> >                  )
> >           }
> >
> > require(deSolve)
> > parms  = c(r = 0.1, K = 10000, h=200)
> > init   = c(N = 2000)
>
> Well, this works in practice, but allow me to two additional points:
>
> First, the line "if (! is.numeric(dn)) dn <- 0" is redundant, probably a
> residual of testing?
>
> Second, instead of a hard limit (that is of course a good test case for the
> solvers), I usually prefer a more smooth limit, e.g:
>
> NoCrash <- function (time, N, parms) {
>             with(as.list(parms), {
>                   dn <-  r * N * (1 - (N/K)) - h * N / (N + hlim)
>                   list(dn)
>             })
>           }
>
> parms  <- c(r = 0.1, K = 10000, h = 200, hlim = 1)
> init   <- c(N = 2000)
>
> out <- ode(func=NoCrash, y = init, parms = parms,
>  times = seq(0,50,.01), method = "lsoda")
>
> plot(out, type = "l")
>
> You can of course try different values of hlim, e.g. hlim=100.
>

Thanks - these work, but  using h * N / (N + hlim) as the harvesting term,
results in a different harvesting strategy (not constant anymore, but
dependent on N).
I used

NoCrash = function (time, N, parms) {
            with(as.list(parms), {
                  dn <-  ifelse( N<0, -N, r * N * (1 - (N/K)) - h )
                  list(dn)
            })
          }

and this also works.

Cheers,

Rainer


> Thomas P.
>
>
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
>



-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Cell:           +27 - (0)83 9479 042
Fax:            +27 - (0)86 516 2782
Fax:            +49 - (0)721 151 334 888
email:          Rainer@krugs.de

Skype:          RMkrug
Google:         R.M.Krug@gmail.com

	[[alternative HTML version deleted]]

