Deserialise odin's intermediate model representation from a json string into an R object. Unlike the json, there is no schema for this representation. This function provides access to the same deserialisation that odin uses internally so may be useful in applications.

odin_ir_deserialise(x)

Arguments

x

An intermediate representation as a json string

Value

A named list

See also

Examples

# Parse a model of exponential decay
ir <- odin::odin_parse({
  deriv(y) <- -0.5 * y
  initial(y) <- 1
})
# Convert the representation to an R object
odin::odin_ir_deserialise(ir)
#> $version
#> [1] ‘1.5.11’
#> 
#> $config
#> $config$base
#> [1] "odin"
#> 
#> $config$include
#> NULL
#> 
#> $config$custom
#> NULL
#> 
#> 
#> $meta
#> $meta$internal
#> [1] "internal"
#> 
#> $meta$user
#> [1] "user"
#> 
#> $meta$state
#> [1] "state"
#> 
#> $meta$result
#> [1] "dstatedt"
#> 
#> $meta$output
#> [1] "output"
#> 
#> $meta$time
#> [1] "t"
#> 
#> $meta$initial_time
#> [1] "initial_t"
#> 
#> 
#> $features
#> $features$continuous
#> [1] TRUE
#> 
#> $features$discrete
#> [1] FALSE
#> 
#> $features$mixed
#> [1] FALSE
#> 
#> $features$has_array
#> [1] FALSE
#> 
#> $features$has_output
#> [1] FALSE
#> 
#> $features$has_user
#> [1] FALSE
#> 
#> $features$has_delay
#> [1] FALSE
#> 
#> $features$has_interpolate
#> [1] FALSE
#> 
#> $features$has_stochastic
#> [1] FALSE
#> 
#> $features$has_data
#> [1] FALSE
#> 
#> $features$has_compare
#> [1] FALSE
#> 
#> $features$has_include
#> [1] FALSE
#> 
#> $features$has_debug
#> [1] FALSE
#> 
#> $features$has_derivative
#> [1] FALSE
#> 
#> $features$initial_time_dependent
#> [1] FALSE
#> 
#> 
#> $data
#> $data$elements
#> $data$elements$initial_y
#> $data$elements$initial_y$name
#> [1] "initial_y"
#> 
#> $data$elements$initial_y$location
#> [1] "internal"
#> 
#> $data$elements$initial_y$storage_type
#> [1] "double"
#> 
#> $data$elements$initial_y$rank
#> [1] 0
#> 
#> $data$elements$initial_y$dimnames
#> NULL
#> 
#> $data$elements$initial_y$stage
#> [1] "constant"
#> 
#> 
#> $data$elements$y
#> $data$elements$y$name
#> [1] "y"
#> 
#> $data$elements$y$location
#> [1] "variable"
#> 
#> $data$elements$y$storage_type
#> [1] "double"
#> 
#> $data$elements$y$rank
#> [1] 0
#> 
#> $data$elements$y$dimnames
#> NULL
#> 
#> $data$elements$y$stage
#> [1] "time"
#> 
#> 
#> 
#> $data$variable
#> $data$variable$length
#> [1] 1
#> 
#> $data$variable$contents
#> $data$variable$contents$y
#> $data$variable$contents$y$name
#> [1] "y"
#> 
#> $data$variable$contents$y$offset
#> [1] 0
#> 
#> $data$variable$contents$y$initial
#> [1] "initial_y"
#> 
#> 
#> 
#> 
#> $data$output
#> $data$output$length
#> [1] 0
#> 
#> $data$output$contents
#> named list()
#> 
#> 
#> 
#> $equations
#> $equations$deriv_y
#> $equations$deriv_y$name
#> [1] "deriv_y"
#> 
#> $equations$deriv_y$type
#> [1] "expression_scalar"
#> 
#> $equations$deriv_y$source
#> $equations$deriv_y$source[[1]]
#> [1] 1
#> 
#> 
#> $equations$deriv_y$depends
#> $equations$deriv_y$depends$functions
#> [1] "*" "-"
#> 
#> $equations$deriv_y$depends$variables
#> [1] "y"
#> 
#> 
#> $equations$deriv_y$lhs
#> [1] "y"
#> 
#> $equations$deriv_y$rhs
#> $equations$deriv_y$rhs$value
#> $equations$deriv_y$rhs$value[[1]]
#> [1] "*"
#> 
#> $equations$deriv_y$rhs$value[[2]]
#> $equations$deriv_y$rhs$value[[2]][[1]]
#> [1] "-"
#> 
#> $equations$deriv_y$rhs$value[[2]][[2]]
#> [1] 0.5
#> 
#> 
#> $equations$deriv_y$rhs$value[[3]]
#> [1] "y"
#> 
#> 
#> 
#> 
#> $equations$initial_y
#> $equations$initial_y$name
#> [1] "initial_y"
#> 
#> $equations$initial_y$type
#> [1] "expression_scalar"
#> 
#> $equations$initial_y$source
#> $equations$initial_y$source[[1]]
#> [1] 2
#> 
#> 
#> $equations$initial_y$depends
#> NULL
#> 
#> $equations$initial_y$lhs
#> [1] "initial_y"
#> 
#> $equations$initial_y$rhs
#> $equations$initial_y$rhs$value
#> [1] 1
#> 
#> 
#> 
#> 
#> $debug
#> list()
#> 
#> $components
#> $components$create
#> $components$create$variables
#> character(0)
#> 
#> $components$create$equations
#> [1] "initial_y"
#> 
#> 
#> $components$user
#> $components$user$variables
#> character(0)
#> 
#> $components$user$equations
#> character(0)
#> 
#> 
#> $components$initial
#> $components$initial$variables
#> character(0)
#> 
#> $components$initial$equations
#> character(0)
#> 
#> 
#> $components$rhs
#> $components$rhs$variables
#> [1] "y"
#> 
#> $components$rhs$equations
#> [1] "deriv_y"
#> 
#> 
#> $components$update_stochastic
#> $components$update_stochastic$variables
#> character(0)
#> 
#> $components$update_stochastic$equations
#> character(0)
#> 
#> 
#> $components$output
#> $components$output$variables
#> character(0)
#> 
#> $components$output$equations
#> character(0)
#> 
#> 
#> $components$compare
#> $components$compare$variables
#> character(0)
#> 
#> $components$compare$equations
#> character(0)
#> 
#> 
#> 
#> $user
#> named list()
#> 
#> $interpolate
#> $interpolate$min
#> character(0)
#> 
#> $interpolate$max
#> character(0)
#> 
#> $interpolate$critical
#> character(0)
#> 
#> 
#> $source
#> $source[[1]]
#> [1] "deriv(y) <- -0.5 * y"
#> 
#> $source[[2]]
#> [1] "initial(y) <- 1"
#> 
#> 
#> $ir
#> {"version":"1.5.11","config":{"base":"odin","include":null,"custom":null},"meta":{"internal":"internal","user":"user","state":"state","result":"dstatedt","output":"output","time":"t","initial_time":"initial_t"},"features":{"continuous":true,"discrete":false,"mixed":false,"has_array":false,"has_output":false,"has_user":false,"has_delay":false,"has_interpolate":false,"has_stochastic":false,"has_data":false,"has_compare":false,"has_include":false,"has_debug":false,"has_derivative":false,"initial_time_dependent":false},"data":{"elements":[{"name":"initial_y","location":"internal","storage_type":"double","rank":0,"dimnames":null,"stage":"constant"},{"name":"y","location":"variable","storage_type":"double","rank":0,"dimnames":null,"stage":"time"}],"variable":{"length":1,"contents":[{"name":"y","offset":0,"initial":"initial_y"}]},"output":{"length":0,"contents":[]}},"equations":[{"name":"deriv_y","type":"expression_scalar","source":[1],"depends":{"functions":["*","-"],"variables":["y"]},"lhs":"y","rhs":{"value":["*",["-",0.5],"y"]}},{"name":"initial_y","type":"expression_scalar","source":[2],"depends":null,"lhs":"initial_y","rhs":{"value":1}}],"debug":[],"components":{"create":{"variables":[],"equations":["initial_y"]},"user":{"variables":[],"equations":[]},"initial":{"variables":[],"equations":[]},"rhs":{"variables":["y"],"equations":["deriv_y"]},"update_stochastic":{"variables":[],"equations":[]},"output":{"variables":[],"equations":[]},"compare":{"variables":[],"equations":[]}},"user":[],"interpolate":{"min":[],"max":[],"critical":[]},"source":["deriv(y) <- -0.5 * y","initial(y) <- 1"]} 
#>