Skip to content

Lack of validation in output variables causes two issues #272

Description

@richfitz

Two models that break:

deriv(S) <- Births - b*S - beta * S * I / N 
deriv(I) <- beta * S * I / N - (b+sigma) * I
deriv(R) <- sigma * I - b*R 
 
# initial conditions of the variables
initial(S) <- N - I0
initial(I) <- I0
initial(R) <- 0
 
# parameter values
N <- 1e6                  # total population size
I0 <- user(1)             # num infectious cases at start of epidemic
beta <- R0*(sigma+b)          # transmission parameter
sigma <- user(2)          # recovery rate (1/mean duration infectiousness)
R0 <- user(5)             # av num new cases caused by single infectious case
b <- user(0.02)           # death rate (average life expectancy of 1 year or 52 weeks) = 1/52
Births <- b*N             # number of births (for a constant population size)
 
output(R0) <- S + I + R

this one validates but won't compile (this is not great in the web version, as the user has no indication of what is wrong). There's a slightly different variant if the target of output is a constant rather than user parameter:

deriv(S) <- Births - b*S - beta * S * I / N 
deriv(I) <- beta * S * I / N - (b+sigma) * I
deriv(R) <- sigma * I - b*R 
 
# initial conditions of the variables
initial(S) <- N - I0
initial(I) <- I0
initial(R) <- 0
 
# parameter values
N <- 1e6                  # total population size
I0 <- user(1)             # num infectious cases at start of epidemic
beta <- R0*(sigma+b)          # transmission parameter
sigma <- user(2)          # recovery rate (1/mean duration infectiousness)
R0 <- user(5)             # av num new cases caused by single infectious case
b <- user(0.02)           # death rate (average life expectancy of 1 year or 52 weeks) = 1/52
Births <- b*N             # number of births (for a constant population size)
 
output(N) <- S + I + R

In this case N is full of junk and eventually crashes R.

Not sure what effect these might have in non-C targets but it can't be good either way really.

Also logged as mrc-3628, same issue

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions