Coder Social home page Coder Social logo

sciml / diffeqr Goto Github PK

View Code? Open in Web Editor NEW
136.0 12.0 14.0 338 KB

Solving differential equations in R using DifferentialEquations.jl and the SciML Scientific Machine Learning ecosystem

License: Other

R 100.00%
differential-equations ode sde dae dde differential-algebraic-equations ordinary-differential-equations stochastic-differential-equations delay-differential-equations sciml

diffeqr's Introduction

diffeqr

CRAN status R build status

diffeqr is a package for solving differential equations in R. It utilizes DifferentialEquations.jl for its core routines to give high performance solving of ordinary differential equations (ODEs), stochastic differential equations (SDEs), delay differential equations (DDEs), and differential-algebraic equations (DAEs) directly in R.

If you have any questions, or just want to chat about solvers/using the package, please feel free to chat in the Zulip channel. For bug reports, feature requests, etc., please submit an issue.

Installation

diffeqr is registered into CRAN. Thus to add the package, use:

install.packages("diffeqr")

To install the master branch of the package (for developers), use:

devtools::install_github('SciML/diffeqr', build_vignettes=T)

Note that the first invocation of diffeqr::diffeq_setup() will install both Julia and the required packages if they are missing. If you wish to have it use an existing Julia binary, make sure that julia is found in the path. For more information see the julia_setup() function from JuliaCall.

Google Collab Notebooks

As a demonstration, check out the following notebooks:

Usage

diffeqr provides a direct wrapper over DifferentialEquations.jl. The namespace is setup so that the standard syntax of Julia translates directly over to the R environment. There are two things to keep in mind:

  1. All DifferentialEquations.jl commands are prefaced by de$
  2. All commands with a ! are replaced with _bang, for example solve! becomes solve_bang.

Ordinary Differential Equation (ODE) Examples

1D Linear ODEs

Let's solve the linear ODE u'=1.01u. First setup the package:

de <- diffeqr::diffeq_setup()

Define the derivative function f(u,p,t).

f <- function(u,p,t) {
  return(1.01*u)
}

Then we give it an initial condition and a time span to solve over:

u0 <- 1/2
tspan <- c(0., 1.)

With those pieces we define the ODEProblem and solve the ODE:

prob = de$ODEProblem(f, u0, tspan)
sol = de$solve(prob)

This gives back a solution object for which sol$t are the time points and sol$u are the values. We can treat the solution as a continuous object in time via

sol$.(0.2)

and a high order interpolation will compute the value at t=0.2. We can check the solution by plotting it:

plot(sol$t,sol$u,"l")

linear_ode

Systems of ODEs

Now let's solve the Lorenz equations. In this case, our initial condition is a vector and our derivative functions takes in the vector to return a vector (note: arbitrary dimensional arrays are allowed). We would define this as:

f <- function(u,p,t) {
  du1 = p[1]*(u[2]-u[1])
  du2 = u[1]*(p[2]-u[3]) - u[2]
  du3 = u[1]*u[2] - p[3]*u[3]
  return(c(du1,du2,du3))
}

Here we utilized the parameter array p. Thus we use diffeqr::ode.solve like before, but also pass in parameters this time:

u0 <- c(1.0,0.0,0.0)
tspan <- c(0.0,100.0)
p <- c(10.0,28.0,8/3)
prob <- de$ODEProblem(f, u0, tspan, p)
sol <- de$solve(prob)

The returned solution is like before except now sol$u is an array of arrays, where sol$u[i] is the full system at time sol$t[i]. It can be convenient to turn this into an R matrix through sapply:

mat <- sapply(sol$u,identity)

This has each row as a time series. t(mat) makes each column a time series. It is sometimes convenient to turn the output into a data.frame which is done via:

udf <- as.data.frame(t(mat))

Now we can use matplot to plot the timeseries together:

matplot(sol$t,udf,"l",col=1:3)

timeseries

Now we can use the Plotly package to draw a phase plot:

plotly::plot_ly(udf, x = ~V1, y = ~V2, z = ~V3, type = 'scatter3d', mode = 'lines')

plotly_plot

Plotly is much prettier!

Option Handling

If we want to have a more accurate solution, we can send abstol and reltol. Defaults are 1e-6 and 1e-3 respectively. Generally you can think of the digits of accuracy as related to 1 plus the exponent of the relative tolerance, so the default is two digits of accuracy. Absolute tolernace is the accuracy near 0.

In addition, we may want to choose to save at more time points. We do this by giving an array of values to save at as saveat. Together, this looks like:

abstol <- 1e-8
reltol <- 1e-8
saveat <- 0:10000/100
sol <- de$solve(prob,abstol=abstol,reltol=reltol,saveat=saveat)
udf <- as.data.frame(t(sapply(sol$u,identity)))
plotly::plot_ly(udf, x = ~V1, y = ~V2, z = ~V3, type = 'scatter3d', mode = 'lines')

precise_solution

We can also choose to use a different algorithm. The choice is done using a string that matches the Julia syntax. See the ODE tutorial for details. The list of choices for ODEs can be found at the ODE Solvers page. For example, let's use a 9th order method due to Verner:

sol <- de$solve(prob,de$Vern9(),abstol=abstol,reltol=reltol,saveat=saveat)

Note that each algorithm choice will cause a JIT compilation.

Performance Enhancements

One way to enhance the performance of your code is to define the function in Julia so that way it is JIT compiled. diffeqr is built using the JuliaCall package, and so you can utilize the Julia JIT compiler. We expose this automatically over ODE functions via jitoptimize_ode, like in the following example:

f <- function(u,p,t) {
  du1 = p[1]*(u[2]-u[1])
  du2 = u[1]*(p[2]-u[3]) - u[2]
  du3 = u[1]*u[2] - p[3]*u[3]
  return(c(du1,du2,du3))
}
u0 <- c(1.0,0.0,0.0)
tspan <- c(0.0,100.0)
p <- c(10.0,28.0,8/3)
prob <- de$ODEProblem(f, u0, tspan, p)
fastprob <- diffeqr::jitoptimize_ode(de,prob)
sol <- de$solve(fastprob,de$Tsit5())

Note that the first evaluation of the function will have an ~2 second lag since the compiler will run, and all subsequent runs will be orders of magnitude faster than the pure R function. This means it's great for expensive functions (ex. large PDEs) or functions called repeatedly, like during optimization of parameters.

We can also use the JuliaCall functions to directly define the function in Julia to eliminate the R interpreter overhead and get full JIT compilation:

julf <- JuliaCall::julia_eval("
function julf(du,u,p,t)
  du[1] = 10.0*(u[2]-u[1])
  du[2] = u[1]*(28.0-u[3]) - u[2]
  du[3] = u[1]*u[2] - (8/3)*u[3]
end")
JuliaCall::julia_assign("u0", u0)
JuliaCall::julia_assign("p", p)
JuliaCall::julia_assign("tspan", tspan)
prob3 = JuliaCall::julia_eval("ODEProblem(julf, u0, tspan, p)")
sol = de$solve(prob3,de$Tsit5())

To demonstrate the performance advantage, let's time them all:

> system.time({ for (i in 1:100){ de$solve(prob    ,de$Tsit5()) }})
   user  system elapsed
   6.69    0.06    6.78
> system.time({ for (i in 1:100){ de$solve(fastprob,de$Tsit5()) }})
   user  system elapsed
   0.11    0.03    0.14
> system.time({ for (i in 1:100){ de$solve(prob3   ,de$Tsit5()) }})
   user  system elapsed
   0.14    0.02    0.15

This is about a 50x improvement!

Limitations of the JIT Compilation

Using Julia's ModelingToolkit for tracing to JIT compile via Julia has a few known limitations:

  • It requires that all of the function calls are tracable. Scalar functions like cos and sin all fall into this category. Notably, matrix multiplication is not supported.
  • It will have a compilation lag on the first call.

Stochastic Differential Equation (SDE) Examples

1D SDEs

Solving stochastic differential equations (SDEs) is the similar to ODEs. To solve an SDE, you use diffeqr::sde.solve and give two functions: f and g, where du = f(u,t)dt + g(u,t)dW_t

de <- diffeqr::diffeq_setup()
f <- function(u,p,t) {
  return(1.01*u)
}
g <- function(u,p,t) {
  return(0.87*u)
}
u0 <- 1/2
tspan <- c(0.0,1.0)
prob <- de$SDEProblem(f,g,u0,tspan)
sol <- de$solve(prob)
udf <- as.data.frame(t(sapply(sol$u,identity)))
plotly::plot_ly(udf, x = sol$t, y = sol$u, type = 'scatter', mode = 'lines')

geometric_sdes

Systems of Diagonal Noise SDEs

Let's add diagonal multiplicative noise to the Lorenz attractor. diffeqr defaults to diagonal noise when a system of equations is given. This is a unique noise term per system variable. Thus we generalize our previous functions as follows:

f <- function(u,p,t) {
  du1 = p[1]*(u[2]-u[1])
  du2 = u[1]*(p[2]-u[3]) - u[2]
  du3 = u[1]*u[2] - p[3]*u[3]
  return(c(du1,du2,du3))
}
g <- function(u,p,t) {
  return(c(0.3*u[1],0.3*u[2],0.3*u[3]))
}
u0 <- c(1.0,0.0,0.0)
tspan <- c(0.0,1.0)
p <- c(10.0,28.0,8/3)
prob <- de$SDEProblem(f,g,u0,tspan,p)
sol <- de$solve(prob,saveat=0.005)
udf <- as.data.frame(t(sapply(sol$u,identity)))
plotly::plot_ly(udf, x = ~V1, y = ~V2, z = ~V3, type = 'scatter3d', mode = 'lines')

Using a JIT compiled function for the drift and diffusion functions can greatly enhance the speed here. With the speed increase we can comfortably solve over long time spans:

tspan <- c(0.0,100.0)
prob <- de$SDEProblem(f,g,u0,tspan,p)
fastprob <- diffeqr::jitoptimize_sde(de,prob)
sol <- de$solve(fastprob,saveat=0.005)
udf <- as.data.frame(t(sapply(sol$u,identity)))
plotly::plot_ly(udf, x = ~V1, y = ~V2, z = ~V3, type = 'scatter3d', mode = 'lines')

stochastic_lorenz

Let's see how much faster the JIT-compiled version was:

> system.time({ for (i in 1:5){ de$solve(prob    ) }})
   user  system elapsed
 146.40    0.75  147.22
> system.time({ for (i in 1:5){ de$solve(fastprob) }})
   user  system elapsed
   1.07    0.10    1.17

Holy Monster's Inc. that's about 145x faster.

Systems of SDEs with Non-Diagonal Noise

In many cases you may want to share noise terms across the system. This is known as non-diagonal noise. The DifferentialEquations.jl SDE Tutorial explains how the matrix form of the diffusion term corresponds to the summation style of multiple Wiener processes. Essentially, the row corresponds to which system the term is applied to, and the column is which noise term. So du[i,j] is the amount of noise due to the jth Wiener process that's applied to u[i]. We solve the Lorenz system with correlated noise as follows:

f <- JuliaCall::julia_eval("
function f(du,u,p,t)
  du[1] = 10.0*(u[2]-u[1])
  du[2] = u[1]*(28.0-u[3]) - u[2]
  du[3] = u[1]*u[2] - (8/3)*u[3]
end")
g <- JuliaCall::julia_eval("
function g(du,u,p,t)
  du[1,1] = 0.3u[1]
  du[2,1] = 0.6u[1]
  du[3,1] = 0.2u[1]
  du[1,2] = 1.2u[2]
  du[2,2] = 0.2u[2]
  du[3,2] = 0.3u[2]
end")
u0 <- c(1.0,0.0,0.0)
tspan <- c(0.0,100.0)
noise_rate_prototype <- matrix(c(0.0,0.0,0.0,0.0,0.0,0.0), nrow = 3, ncol = 2)

JuliaCall::julia_assign("u0", u0)
JuliaCall::julia_assign("tspan", tspan)
JuliaCall::julia_assign("noise_rate_prototype", noise_rate_prototype)
prob <- JuliaCall::julia_eval("SDEProblem(f, g, u0, tspan, p, noise_rate_prototype=noise_rate_prototype)")
sol <- de$solve(prob)
udf <- as.data.frame(t(sapply(sol$u,identity)))
plotly::plot_ly(udf, x = ~V1, y = ~V2, z = ~V3, type = 'scatter3d', mode = 'lines')

noise_corr

Here you can see that the warping effect of the noise correlations is quite visible! Note that we applied JIT compilation since it's quite necessary for any difficult stochastic example.

Differential-Algebraic Equation (DAE) Examples

A differential-algebraic equation is defined by an implicit function f(du,u,p,t)=0. All of the controls are the same as the other examples, except here you define a function which returns the residuals for each part of the equation to define the DAE. The initial value u0 and the initial derivative du0 are required, though they do not necessarily have to satisfy f (known as inconsistent initial conditions). The methods will automatically find consistent initial conditions. In order for this to occur, differential_vars must be set. This vector states which of the variables are differential (have a derivative term), with false meaning that the variable is purely algebraic.

This example shows how to solve the Robertson equation:

f <- function (du,u,p,t) {
  resid1 = - 0.04*u[1]              + 1e4*u[2]*u[3] - du[1]
  resid2 = + 0.04*u[1] - 3e7*u[2]^2 - 1e4*u[2]*u[3] - du[2]
  resid3 = u[1] + u[2] + u[3] - 1.0
  c(resid1,resid2,resid3)
}
u0 <- c(1.0, 0, 0)
du0 <- c(-0.04, 0.04, 0.0)
tspan <- c(0.0,100000.0)
differential_vars <- c(TRUE,TRUE,FALSE)
prob <- de$DAEProblem(f,du0,u0,tspan,differential_vars=differential_vars)
sol <- de$solve(prob)
udf <- as.data.frame(t(sapply(sol$u,identity)))
plotly::plot_ly(udf, x = sol$t, y = ~V1, type = 'scatter', mode = 'lines') |>
  plotly::add_trace(y = ~V2) |>
  plotly::add_trace(y = ~V3)

Additionally, an in-place JIT compiled form for f can be used to enhance the speed:

f = JuliaCall::julia_eval("function f(out,du,u,p,t)
  out[1] = - 0.04u[1]              + 1e4*u[2]*u[3] - du[1]
  out[2] = + 0.04u[1] - 3e7*u[2]^2 - 1e4*u[2]*u[3] - du[2]
  out[3] = u[1] + u[2] + u[3] - 1.0
end")
u0 <- c(1.0, 0, 0)
du0 <- c(-0.04, 0.04, 0.0)
tspan <- c(0.0,100000.0)
differential_vars <- c(TRUE,TRUE,FALSE)
JuliaCall::julia_assign("du0", du0)
JuliaCall::julia_assign("u0", u0)
JuliaCall::julia_assign("p", p)
JuliaCall::julia_assign("tspan", tspan)
JuliaCall::julia_assign("differential_vars", differential_vars)
prob = JuliaCall::julia_eval("DAEProblem(f, du0, u0, tspan, p, differential_vars=differential_vars)")
sol = de$solve(prob)

daes

Delay Differential Equation (DDE) Examples

A delay differential equation is an ODE which allows the use of previous values. In this case, the function needs to be a JIT compiled Julia function. It looks just like the ODE, except in this case there is a function h(p,t) which allows you to interpolate and grab previous values.

We must provide a history function h(p,t) that gives values for u before t0. Here we assume that the solution was constant before the initial time point. Additionally, we pass constant_lags = c(20.0) to tell the solver that only constant-time lags were used and what the lag length was. This helps improve the solver accuracy by accurately stepping at the points of discontinuity. Together this is:

f <- JuliaCall::julia_eval("function f(du, u, h, p, t)
  du[1] = 1.1/(1 + sqrt(10)*(h(p, t-20)[1])^(5/4)) - 10*u[1]/(1 + 40*u[2])
  du[2] = 100*u[1]/(1 + 40*u[2]) - 2.43*u[2]
end")
h <- JuliaCall::julia_eval("function h(p, t)
  [1.05767027/3, 1.030713491/3]
end")
u0 <- c(1.05767027/3, 1.030713491/3)
tspan <- c(0.0, 100.0)
constant_lags <- c(20.0)
JuliaCall::julia_assign("u0", u0)
JuliaCall::julia_assign("tspan", tspan)
JuliaCall::julia_assign("constant_lags", tspan)
prob <- JuliaCall::julia_eval("DDEProblem(f, u0, h, tspan, constant_lags = constant_lags)")
sol <- de$solve(prob,de$MethodOfSteps(de$Tsit5()))
udf <- as.data.frame(t(sapply(sol$u,identity)))
plotly::plot_ly(udf, x = sol$t, y = ~V1, type = 'scatter', mode = 'lines') |> plotly::add_trace(y = ~V2)

delay

Notice that the solver accurately is able to simulate the kink (discontinuity) at t=20 due to the discontinuity of the derivative at the initial time point! This is why declaring discontinuities can enhance the solver accuracy.

GPU-Accelerated ODE Solving of Ensembles

In many cases one is interested in solving the same ODE many times over many different initial conditions and parameters. In diffeqr parlance this is called an ensemble solve. diffeqr inherits the parallelism tools of the SciML ecosystem that are used for things like automated equation discovery and acceleration. Here we will demonstrate using these parallel tools to accelerate the solving of an ensemble.

First, let's define the JIT-accelerated Lorenz equation like before:

de <- diffeqr::diffeq_setup()
lorenz <- function (u,p,t){
  du1 = p[1]*(u[2]-u[1])
  du2 = u[1]*(p[2]-u[3]) - u[2]
  du3 = u[1]*u[2] - p[3]*u[3]
  c(du1,du2,du3)
}
u0 <- c(1.0,1.0,1.0)
tspan <- c(0.0,100.0)
p <- c(10.0,28.0,8/3)
prob <- de$ODEProblem(lorenz,u0,tspan,p)
fastprob <- diffeqr::jitoptimize_ode(de,prob)

Now we use the EnsembleProblem as defined on the ensemble parallelism page of the documentation: Let's build an ensemble by utilizing uniform random numbers to randomize the initial conditions and parameters:

prob_func <- function (prob,i,rep){
  de$remake(prob,u0=runif(3)*u0,p=runif(3)*p)
}
ensembleprob = de$EnsembleProblem(fastprob, prob_func = prob_func, safetycopy=FALSE)

Now we solve the ensemble in serial:

sol = de$solve(ensembleprob,de$Tsit5(),de$EnsembleSerial(),trajectories=10000,saveat=0.01)

To add GPUs to the mix, we need to bring in DiffEqGPU. The diffeqr::diffeqgpu_setup() helper function will install CUDA for you and bring all of the bindings into the returned object:

degpu <- diffeqr::diffeqgpu_setup("CUDA")

Note: diffeqr::diffeqgpu_setup can take awhile to run the first time as it installs the drivers!

Now we simply use EnsembleGPUKernel(degpu$CUDABackend()) with a GPU-specialized ODE solver GPUTsit5() to solve 10,000 ODEs on the GPU in parallel:

sol <- de$solve(ensembleprob,degpu$GPUTsit5(),degpu$EnsembleGPUKernel(degpu$CUDABackend()),trajectories=10000,saveat=0.01)

For the full list of choices for specialized GPU solvers, see the DiffEqGPU.jl documentation.

Note that EnsembleGPUArray can be used as well, like:

sol <- de$solve(ensembleprob,de$Tsit5(),degpu$EnsembleGPUArray(degpu$CUDABackend()),trajectories=10000,saveat=0.01)

though we highly recommend the EnsembleGPUKernel methods for more speed. Given the way the JIT compilation performed will also ensure that the faster kernel generation methods work, EnsembleGPUKernel is almost certainly the better choice in most applications.

Benchmark

To see how much of an effect the parallelism has, let's test this against R's deSolve package. This is exactly the same problem as the documentation example for deSolve, so let's copy that verbatim and then add a function to do the ensemble generation:

library(deSolve)
Lorenz <- function(t, state, parameters) {
  with(as.list(c(state, parameters)), {
    dX <-  a * X + Y * Z
    dY <-  b * (Y - Z)
    dZ <- -X * Y + c * Y - Z
    list(c(dX, dY, dZ))
  })
}

parameters <- c(a = -8/3, b = -10, c = 28)
state      <- c(X = 1, Y = 1, Z = 1)
times      <- seq(0, 100, by = 0.01)
out <- ode(y = state, times = times, func = Lorenz, parms = parameters)

lorenz_solve <- function (i){
  state      <- c(X = runif(1), Y = runif(1), Z = runif(1))
  parameters <- c(a = -8/3 * runif(1), b = -10 * runif(1), c = 28 * runif(1))
  out <- ode(y = state, times = times, func = Lorenz, parms = parameters)
}

Using lapply to generate the ensemble we get:

> system.time({ lapply(1:1000,lorenz_solve) })
   user  system elapsed
 225.81    0.46  226.63

Now let's see how the JIT-accelerated serial Julia version stacks up against that:

> system.time({ de$solve(ensembleprob,de$Tsit5(),de$EnsembleSerial(),trajectories=1000,saveat=0.01) })
   user  system elapsed
   2.75    0.30    3.08

Julia is already about 73x faster than the pure R solvers here! Now let's add GPU-acceleration to the mix:

> system.time({ de$solve(ensembleprob,degpu$GPUTsit5(),degpu$EnsembleGPUKernel(degpu$CUDABackend()),trajectories=1000,saveat=0.01) })
   user  system elapsed 
   0.11    0.00    0.12

Already 26x times faster! But the GPU acceleration is made for massively parallel problems, so let's up the trajectories a bit. We will not use more trajectories from R because that would take too much computing power, so let's see what happens to the Julia serial and GPU at 10,000 trajectories:

> system.time({ de$solve(ensembleprob,de$Tsit5(),de$EnsembleSerial(),trajectories=10000,saveat=0.01) })
   user  system elapsed
  35.02    4.19   39.25
> system.time({ de$solve(ensembleprob,degpu$GPUTsit5(),degpu$EnsembleGPUKernel(degpu$CUDABackend()),trajectories=10000,saveat=0.01) })
   user  system elapsed 
   1.22    0.23    1.50 

To compare this to the pure Julia code:

using OrdinaryDiffEq, DiffEqGPU, CUDA, StaticArrays
function lorenz(u, p, t)
    ฯƒ = p[1]
    ฯ = p[2]
    ฮฒ = p[3]
    du1 = ฯƒ * (u[2] - u[1])
    du2 = u[1] * (ฯ - u[3]) - u[2]
    du3 = u[1] * u[2] - ฮฒ * u[3]
    return SVector{3}(du1, du2, du3)
end

u0 = SA[1.0f0; 0.0f0; 0.0f0]
tspan = (0.0f0, 10.0f0)
p = SA[10.0f0, 28.0f0, 8 / 3.0f0]
prob = ODEProblem{false}(lorenz, u0, tspan, p)
prob_func = (prob, i, repeat) -> remake(prob, p = (@SVector rand(Float32, 3)) .* p)
monteprob = EnsembleProblem(prob, prob_func = prob_func, safetycopy = false)
@time sol = solve(monteprob, GPUTsit5(), EnsembleGPUKernel(CUDA.CUDABackend()),
    trajectories = 10_000,
    saveat = 1.0f0);

# 0.015064 seconds (257.68 k allocations: 13.132 MiB)

which is about two orders of magnitude faster for computing 10,000 trajectories, note that the major factors are that we cannot define 32-bit floating point values from R and the prob_func for generating the initial conditions and parameters is a major bottleneck since this function is written in R.

To see how this scales in Julia, let's take it to insane heights. First, let's reduce the amount we're saving:

@time sol = solve(monteprob,GPUTsit5(),EnsembleGPUKernel(CUDA.CUDABackend()),trajectories=10_000,saveat=1.0f0)
0.015040 seconds (257.64 k allocations: 13.130 MiB)

This highlights that controlling memory pressure is key with GPU usage: you will get much better performance when requiring less saved points on the GPU.

@time sol = solve(monteprob,GPUTsit5(),EnsembleGPUKernel(CUDA.CUDABackend()),trajectories=100_000,saveat=1.0f0)
# 0.150901 seconds (2.60 M allocations: 131.576 MiB)

compared to serial:

@time sol = solve(monteprob,Tsit5(),EnsembleSerial(),trajectories=100_000,saveat=1.0f0)
# 22.136743 seconds (16.40 M allocations: 1.628 GiB, 42.98% gc time)

And now we start to see that scaling power! Let's solve 1 million trajectories:

@time sol = solve(monteprob,GPUTsit5(),EnsembleGPUKernel(CUDA.CUDABackend()),trajectories=1_000_000,saveat=1.0f0)
# 1.031295 seconds (3.40 M allocations: 241.075 MiB)

For reference, let's look at deSolve with the change to only save that much:

times      <- seq(0, 100, by = 1.0)
lorenz_solve <- function (i){
  state      <- c(X = runif(1), Y = runif(1), Z = runif(1))
  parameters <- c(a = -8/3 * runif(1), b = -10 * runif(1), c = 28 * runif(1))
  out <- ode(y = state, times = times, func = Lorenz, parms = parameters)
}

system.time({ lapply(1:1000,lorenz_solve) })
   user  system elapsed 
  49.69    3.36   53.42 

The GPU version is solving 1000x as many trajectories, 50x as fast! So conclusion, if you need the most speed, you may want to move to the Julia version to get the most out of your GPU due to Float32's, and when using GPUs make sure it's a problem with a relatively average or low memory pressure, and these methods will give orders of magnitude acceleration compared to what you might be used to.

diffeqr's People

Contributors

asinghvi17 avatar chrisrackauckas avatar nanhung avatar non-contradiction avatar waidschrat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diffeqr's Issues

MethodError: no method matching EnsembleGPUArray()

Hi,

I've been running some of your example code, and am really excited by the performance boost a Julia back-end could mean for my work!

Everything runs great for me, except the GPU example.

de$solve(ensembleprob, de$Tsit5(), degpu$EnsembleGPUArray(), trajectories = trajectories, saveat = saveat)

returns for me:

Error: Error happens in Julia.
MethodError: no method matching EnsembleGPUArray()

I've tried uninstalling and reinstalling the development version of diffeqr but this hasn't solved things. I'm a seasoned R user but know nothing about Julia!

When running example I get a "Initial condition incompatible with functional form."

> sol = de$solve(prob) Error: Error happens in Julia. Initial condition incompatible with functional form. Detected an in-place function with an initial condition of type Number or SArray. This is incompatible because Numbers cannot be mutated, i.e. x = 2.0; y = 2.0; x .= y` will error.

If using a immutable initial condition type, please use the out-of-place form.
I.e. define the function du=f(u,p,t) instead of attempting to "mutate" the immutable du.

If your differential equation function was defined with multiple dispatches and one is
in-place, then the automatic detection will choose in-place. In this case, override the
choice in the problem constructor, i.e. ODEProblem{false}(f,u0,tspan,p,kwargs...).

For a longer discussion on mutability vs immutability and in-place vs out-of-place, see:
https://diffeq.sciml.ai/stable/tutorials/faster_ode_example/#Example-Accelerating-a-Non-Stiff-Equation:-The-Lorenz-Equation

Stacktrace:
[1] get_concrete_u0(prob::ODEProblem{Float64, Tuple{Float64, Float64}, t`

sessionInfo is:

`> sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] diffeqr_1.1.1

loaded via a namespace (and not attached):
[1] TH.data_1.1-1 minqa_1.2.4 colorspace_2.0-3 rjson_0.2.21 ggsignif_0.6.3 ellipsis_0.3.2
[7] modeltools_0.2-23 EnvStats_2.7.0 rprojroot_2.0.3 fs_1.5.2 rstudioapi_0.14 ggpubr_0.4.0
[13] remotes_2.4.2 JuliaCall_0.17.5 fansi_1.0.3 mvtnorm_1.1-3 lubridate_1.8.0 coin_1.4-2
[19] codetools_0.2-18 splines_4.2.1 cachem_1.0.6 libcoin_1.0-9 knitr_1.40 pkgload_1.3.0
[25] jsonlite_1.8.2 nloptr_2.0.3 broom_1.0.1 km.ci_0.5-6 cluster_2.1.4 shiny_1.7.2
[31] compiler_4.2.1 httr_1.4.4 ciTools_0.6.1 backports_1.4.1 assertthat_0.2.1 Matrix_1.5-1
[37] fastmap_1.1.0 lazyeval_0.2.2 cli_3.4.1 later_1.3.0 htmltools_0.5.3 prettyunits_1.1.1
[43] tools_4.2.1 coda_0.19-4 gtable_0.3.1 glue_1.6.2 dplyr_1.0.10 Rcpp_1.0.9
[49] carData_3.0-5 cenGAM_0.5.3 vctrs_0.4.2 nlme_3.1-159 stringr_1.4.1 xfun_0.33
[55] ps_1.7.1 lme4_1.1-30 mime_0.12 miniUI_0.1.1.1 lifecycle_1.0.2 devtools_2.4.4
[61] rstatix_0.7.0 MASS_7.3-58.1 zoo_1.8-11 scales_1.2.1 promises_1.2.0.1 parallel_4.2.1
[67] sandwich_3.0-2 curl_4.3.2 yaml_2.3.5 memoise_2.0.1 gridExtra_2.3 NADA_1.6-1.1
[73] KMsurv_0.1-5 ggplot2_3.3.6 stringi_1.7.8 permute_0.9-7 boot_1.3-28 pkgbuild_1.3.1
[79] rlang_1.0.6 pkgconfig_2.0.3 matrixStats_0.62.0 arm_1.13-1 evaluate_0.17 lattice_0.20-45
[85] purrr_0.3.4 htmlwidgets_1.5.4 tidyselect_1.1.2 processx_3.7.0 magrittr_2.0.3 bookdown_0.29
[91] R6_2.5.1 profvis_0.3.7 generics_0.1.3 multcomp_1.4-20 DBI_1.1.3 withr_2.5.0
[97] pillar_1.8.1 mgcv_1.8-40 fitdistrplus_1.1-8 survival_3.4-0 abind_1.4-5 tibble_3.1.8
[103] crayon_1.5.2 car_3.1-0 survMisc_0.5.6 utf8_1.2.2 plotly_4.10.0 urlchecker_1.0.1
[109] rmarkdown_2.16 usethis_2.1.6 grid_4.2.1 data.table_1.14.2 callr_3.7.2 vegan_2.6-2
[115] forcats_0.5.2 digest_0.6.29 xtable_1.8-4 tidyr_1.2.1 httpuv_1.6.6 NADA2_1.1.0
[121] stats4_4.2.1 munsell_0.5.0 viridisLite_0.4.1 survminer_0.4.9 sessioninfo_1.2.2 `

Full solution object

Right now the solution that is returned is simply a list with sol$t and sol$u. In DiffEq it's a lot more comprehensive and has an interpolation sol(t). There is a discussion going on to find out how to do this in R: Non-Contradiction/JuliaCall#49 . When it gets added it will be backwards compatible with what we have now, so it's comfortable to start using the current interface without fear of compatibility issues.

Error with jitOptimize_ode function

Hi,

I am getting an error when running the jitOptimize_ode function in diffeqr library. I have correctly installed Julia 1.5.2 and the path as the diffeqr setup works fine and it sets up JuliaCall. However, when running with the above function I get the following error. I recently downloaded the most recent R and RStudio - though I got the same message with earlier version.
Thanks in advance for your help and suggestions
Kind regards,
Gautam

fastprob <- diffeqr::jitoptimize_ode(de, prob)

Error: Error happens in Julia.
MethodError: no method matching iterate(::Term{Real})
Closest candidates are:
iterate(!Matched::ExponentialBackOff) at error.jl:252
iterate(!Matched::ExponentialBackOff, !Matched::Any) at error.jl:252
iterate(!Matched::Cmd) at process.jl:639
...
Stacktrace:
[1] copyto!(::Array{Any,1}, ::Term{Real}) at .\abstractarray.jl:733
[2] _collect(::UnitRange{Int64}, ::Term{Real}, ::Base.HasEltype, ::Base.HasLength) at .\array.jl:630
[3] collect at .\array.jl:624 [inlined]
[4] broadcastable at .\broadcast.jl:682 [inlined]
[5] broadcasted at .\broadcast.jl:1260 [inlined]
[6] broadcast(::typeof(-), ::Term{Real}, ::Term{Real}) at .\broadcast.jl:775
[7] simple_call(::String, ::Term{Real}, ::Vararg{Term{Real},N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}) at C:\Users\gmukh\Documents\R\win-library\4.0\JuliaCall\julia\interface1.jl:7
[8] simple_call(::String, ::Term{Real}, ::Vararg{Term{Real},N} where N) at C:\Users Error: Error happens in Julia.
REvalError:

Arrays of arrays in parameters cannot JIT compile

Hi

I have extended my epidemic SIR model to two age groups, which have some contact rates among each other (captured with a mixing matrix), and some transition rates (ageing, demo matrix). Since diffeqr does not accept additional arguments, I have wrapped the two matrices in "p" with an R list. However, diffeqr seems to have a problem with the array or matrix type in R.

The following code:

library(diffeqr)

maxtime <- 3650.0

# Make up some demography data
lifespan <- 80
steps <- 40
alower <- seq(0,lifespan-steps,steps) # lower boundary of age groups
alength <- c(diff(alower), steps) # duration in years in age group
ngroups <- length(alower)
demo <- matrix(data=NA, nrow=ngroups, ncol=5)

demo[,1] <- alower
demo[,2] <- 100000/lifespan*alength # Popsizes
demo[,3] <- demo[,2]/sum(demo[,2]) # proportions in each age group
demo[,4] <- c(1/(alength*365)) # ageing rates out of compartment
demo[,5] <- c(demo[nrow(demo),4], demo[1:(nrow(demo)-1),4]) # ageing rates into compartment
demo

# Make up some social mixing data
mixmat <- matrix(data=c(10.9, 4.5, 4.5, 6.1), nrow=2)

# Theta
beta <- 0.02
gamma <- 1/5
mu <- 1/(70*365)
sigma <- 1/365
k <- 5
eta <- 0.2 
phi <- 10

init <- log(c(demo[,"N"], rep(1, ngroups), rep(1e-12, ngroups))) 

theta <- c(beta=beta, gamma=gamma, sigma=sigma, eta=eta, phi=phi, ngroups=ngroups, k=k)
theta <- list(theta, demo, mixmat)

enviro <- diffeqr::diffeq_setup()

model <- function(logstate, parms, times) {
  
  # this doesnt work
  theta = as.vector(parms[[1]]) # this should be a vector
  demo = as.array(parms[[2]]) # this should be matrix/array
  mixmat = as.array(parms[[3]]) # this should be matrix/array
  
  ageout = demo[,4]
  agein = demo[,5]
  
  beta = theta[1]
  gamma = theta[2]
  sigma = theta[3]
  eta = theta[4]
  phi = theta[5]
  ngroups = theta[6]
  
  # states
  state = exp(logstate)
  S = state[(1:ngroups)+0*ngroups]
  I = state[(1:ngroups)+1*ngroups]
  R = state[(1:ngroups)+2*ngroups] 
  N = S + I + R
  
  Slower <- c(N[ngroups], S[-ngroups])
  Ilower <- c(0, I[-ngroups])
  Rlower <- c(0, R[-ngroups])
  
  # calculate FOI
  beta_eff = beta * (1+eta*sin(pi*(times-phi)/365.0)^2)
  FOI = beta_eff*colSums(mixmat*I/N)
  
  dSdt = -FOI*S + sigma*R - ageout*S  + agein*Slower
  dIdt = FOI*S - gamma*I - ageout*I + agein*Ilower
  dRdt = gamma*I - sigma*R - ageout*R + agein*Rlower
  
  return(list(cbind(dSdt/S, dIdt/I, dRdt/R)))
  
}

problem <- enviro$ODEProblem(model, init, c(0.0, maxtime), theta)
problemacc <- diffeqr::jitoptimize_ode(enviro,problem) 
solution <- enviro$solve(problemacc, enviro$AutoVern7(enviro$KenCarp4()), 
                         saveat=1.0, abstol=1e-8, reltol=1e-8) # default tolerance leads to weird behaviour with this model (generation of individuals)

throws this error:

Error: Error happens in Julia.
MethodError: no method matching reshape(::Operation, ::Int64)
Closest candidates are:
  reshape(!Matched::FillArrays.AbstractFill, ::Union{Colon, Int64}...) at C:\Users\fabienne\.julia\packages\FillArrays\RM6r2\src\FillArrays.jl:204
  reshape(!Matched::OffsetArrays.OffsetArray, ::Union{Colon, Int64}...) at C:\Users\fabienne\.julia\packages\OffsetArrays\7j7P7\src\OffsetArrays.jl:240
  reshape(!Matched::AbstractMultiScaleArray, ::Int64...) at C:\Users\fabienne\.julia\packages\MultiScaleArrays\c9WNi\src\diffeq.jl:49
  ...
Stacktrace:
 [1] simple_call(::String, ::Operation, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}) at C:\Users\fabienne\Documents\R\win-library\4.0\JuliaCall\julia\interface1.jl:11
 [2] simple_call(::String, ::Operation, ::Vararg{Any,N} where N) at C:\Users\fabienne\Documents\R\win-library\4.0\JuliaCall\julia\interface1.jl:2
 [3] julia_extptr_callback(::Ptr{ListSxp}) at C:\Users\fabienne\.julia\packages\ Error: Error happens in Julia.
REvalError:

Is there a way around this? If not it might be necessary to write the function as JuliaCall::julia_eval. Is there an example of an ODE function that uses array/matrix calculation in Julia lang (doesn't have to be an SIR, any compartmental model will do)? Thanks

Install fails on windows 10

Here's the log I get when trying to install diffeqr:

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

install.packages("doParallel")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/doParallel_1.0.16.zip'
Content type 'application/zip' length 64200 bytes (62 KB)
downloaded 62 KB

package โ€˜doParallelโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages

data.table::update.dev.pkg()
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
trying URL 'https://Rdatatable.gitlab.io/data.table/bin/windows/contrib/4.0/data.table_1.13.7.zip'
Content type 'application/zip' length 2778661 bytes (2.6 MB)
downloaded 2.6 MB

package โ€˜data.tableโ€™ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package โ€˜data.tableโ€™
Warning: restored โ€˜data.tableโ€™

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages
R data.table package has been updated to NA (1.13.6)
Warning message:
In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Users\dkatz\R\win-library\4.0\00LOCK\data.table\libs\x64\datatable.dll to C:\Users\dkatz\R\win-library\4.0\data.table\libs\x64\datatable.dll: Permission denied

install.packages("GlmSimulatoR")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
also installing the dependencies โ€˜DBIโ€™, โ€˜codaโ€™, โ€˜biglmโ€™, โ€˜tweedieโ€™, โ€˜cplmโ€™

There is a binary version available but the source version is later:
binary source needs_compilation
DBI 1.1.0 1.1.1 FALSE

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/coda_0.19-4.zip'
Content type 'application/zip' length 323055 bytes (315 KB)
downloaded 315 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/biglm_0.9-2.1.zip'
Content type 'application/zip' length 81043 bytes (79 KB)
downloaded 79 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/tweedie_2.3.2.zip'
Content type 'application/zip' length 371573 bytes (362 KB)
downloaded 362 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/cplm_0.7-9.zip'
Content type 'application/zip' length 1798055 bytes (1.7 MB)
downloaded 1.7 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/GlmSimulatoR_0.2.3.zip'
Content type 'application/zip' length 207601 bytes (202 KB)
downloaded 202 KB

package โ€˜codaโ€™ successfully unpacked and MD5 sums checked
package โ€˜biglmโ€™ successfully unpacked and MD5 sums checked
package โ€˜tweedieโ€™ successfully unpacked and MD5 sums checked
package โ€˜cplmโ€™ successfully unpacked and MD5 sums checked
package โ€˜GlmSimulatoRโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages
installing the source package โ€˜DBIโ€™

trying URL 'https://cloud.r-project.org/src/contrib/DBI_1.1.1.tar.gz'
Content type 'application/x-gzip' length 743802 bytes (726 KB)
downloaded 726 KB

  • installing source package 'DBI' ...
    ** package 'DBI' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'DBI'
    finding HTML links ... done
    ANSI html
    DBI-package html
    DBIConnection-class html
    DBIConnector-class html
    DBIDriver-class html
    DBIObject-class html
    DBIResult-class html
    Id html
    SQL html
    dbAppendTable html
    dbBind html
    dbCallProc html
    dbCanConnect html
    dbClearResult html
    dbColumnInfo html
    dbConnect html
    dbCreateTable html
    dbDataType html
    dbDisconnect html
    dbDriver html
    dbExecute html
    dbExistsTable html
    dbFetch html
    dbGetConnectArgs html
    dbGetDBIVersion html
    dbGetException html
    dbGetInfo html
    dbGetQuery html
    dbGetRowCount html
    dbGetRowsAffected html
    dbGetStatement html
    dbHasCompleted html
    dbIsReadOnly html
    dbIsValid html
    dbListConnections html
    dbListFields html
    dbListObjects html
    dbListResults html
    dbListTables html
    dbQuoteIdentifier html
    dbQuoteLiteral html
    dbQuoteString html
    dbReadTable html
    dbRemoveTable html
    dbSendQuery html
    dbSendStatement html
    dbSetDataMappings html
    dbUnquoteIdentifier html
    dbWithTransaction html
    dbWriteTable html
    hidden_aliases html
    make.db.names html
    rownames html
    sqlAppendTable html
    sqlCreateTable html
    sqlData html
    sqlInterpolate html
    sqlParseVariables html
    transactions html
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded from temporary location
    *** arch - i386
    *** arch - x64
    ** testing if installed package can be loaded from final location
    *** arch - i386
    *** arch - x64
    ** testing if installed package keeps a record of temporary installation path
  • DONE (DBI)

The downloaded source packages are in
โ€˜C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packagesโ€™

install.packages("ggplot2")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/ggplot2_3.3.3.zip'
Content type 'application/zip' length 4066618 bytes (3.9 MB)
downloaded 3.9 MB

package โ€˜ggplot2โ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages

install.packages("dplyr"0
Error: unexpected numeric constant in "install.packages("dplyr"0"
install.packages("dplyr")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)

There is a binary version available but the source version is later:
binary source needs_compilation
dplyr 1.0.2 1.0.3 TRUE

installing the source package โ€˜dplyrโ€™

trying URL 'https://cloud.r-project.org/src/contrib/dplyr_1.0.3.tar.gz'
Content type 'application/x-gzip' length 946024 bytes (923 KB)
downloaded 923 KB

  • installing source package 'dplyr' ...
    ** package 'dplyr' successfully unpacked and MD5 sums checked
    ERROR: cannot remove earlier installation, is it in use?
  • removing 'C:/Users/dkatz/R/win-library/4.0/dplyr'
  • restoring previous 'C:/Users/dkatz/R/win-library/4.0/dplyr'
    Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
    problem copying C:\Users\dkatz\R\win-library\4.0\00LOCK-dplyr\dplyr\libs\x64\dplyr.dll to C:\Users\dkatz\R\win-library\4.0\dplyr\libs\x64\dplyr.dll: Permission denied

The downloaded source packages are in
โ€˜C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packagesโ€™
Warning message:
In install.packages("dplyr") :
installation of package โ€˜dplyrโ€™ had non-zero exit status

install.packages("rpca")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/rpca_0.2.3.zip'
Content type 'application/zip' length 29188 bytes (28 KB)
downloaded 28 KB

package โ€˜rpcaโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages

Logit <- function(x) log(x / (1.0 - x))
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
Error in lgb.Dataset(train$data, label = train$label) :
could not find function "lgb.Dataset"
setinfo(dtrain, "init_score", rep(Logit(mean(train$label)), length(train$label)))
Error in setinfo(dtrain, "init_score", rep(Logit(mean(train$label)), length(train$label))) :
could not find function "setinfo"
data(agaricus.test, package = "lightgbm")
test <- agaricus.test

params <- list(

  • objective = "binary"
    
  • , learning_rate = 0.1
    
  • , max_depth = -1L
    
  • , min_data_in_leaf = 1L
    
  • , min_sum_hessian_in_leaf = 1.0
    
  • )

model <- lgb.train(

  • params = params
    
  • , data = dtrain
    
  • , nrounds = 3L
    
  • )
    Error in lgb.train(params = params, data = dtrain, nrounds = 3L) :
    could not find function "lgb.train"

#> [LightGBM] [Info] Number of positive: 3140, number of negative: 3373
#> [LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.001179 seconds.
#> You can set force_row_wise=true to remove the overhead.
#> And if memory is not enough, you can set force_col_wise=true.
#> [LightGBM] [Info] Total Bins 232
#> [LightGBM] [Info] Number of data points in the train set: 6513, number of used features: 116
#> [LightGBM] [Warning] No further splits with positive gain, best gain: -inf
#> [LightGBM] [Warning] No further splits with positive gain, best gain: -inf
#> [LightGBM] [Warning] No further splits with positive gain, best gain: -inf

tree_interpretation <- lgb.interprete(model, test$data, 1L:5L)
Error in lgb.interprete(model, test$data, 1L:5L) :
could not find function "lgb.interprete"
install.packages("bupaR")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
also installing the dependencies โ€˜httpuvโ€™, โ€˜xtableโ€™, โ€˜sourcetoolsโ€™, โ€˜fastmapโ€™, โ€˜shinyโ€™, โ€˜miniUIโ€™, โ€˜eventdataRโ€™, โ€˜lubridateโ€™

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/httpuv_1.5.5.zip'
Content type 'application/zip' length 1707955 bytes (1.6 MB)
downloaded 1.6 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/xtable_1.8-4.zip'
Content type 'application/zip' length 706054 bytes (689 KB)
downloaded 689 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/sourcetools_0.1.7.zip'
Content type 'application/zip' length 691369 bytes (675 KB)
downloaded 675 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/fastmap_1.0.1.zip'
Content type 'application/zip' length 196633 bytes (192 KB)
downloaded 192 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/shiny_1.5.0.zip'
Content type 'application/zip' length 5357761 bytes (5.1 MB)
downloaded 5.1 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/miniUI_0.1.1.1.zip'
Content type 'application/zip' length 36543 bytes (35 KB)
downloaded 35 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/eventdataR_0.2.0.zip'
Content type 'application/zip' length 1337393 bytes (1.3 MB)
downloaded 1.3 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/lubridate_1.7.9.2.zip'
Content type 'application/zip' length 1750985 bytes (1.7 MB)
downloaded 1.7 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/bupaR_0.4.4.zip'
Content type 'application/zip' length 257842 bytes (251 KB)
downloaded 251 KB

package โ€˜httpuvโ€™ successfully unpacked and MD5 sums checked
package โ€˜xtableโ€™ successfully unpacked and MD5 sums checked
package โ€˜sourcetoolsโ€™ successfully unpacked and MD5 sums checked
package โ€˜fastmapโ€™ successfully unpacked and MD5 sums checked
package โ€˜shinyโ€™ successfully unpacked and MD5 sums checked
package โ€˜miniUIโ€™ successfully unpacked and MD5 sums checked
package โ€˜eventdataRโ€™ successfully unpacked and MD5 sums checked
package โ€˜lubridateโ€™ successfully unpacked and MD5 sums checked
package โ€˜bupaRโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages

install.packages("heuristicsmineR")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
also installing the dependencies โ€˜shinyTimeโ€™, โ€˜zooโ€™, โ€˜edeaRโ€™, โ€˜downloaderโ€™, โ€˜igraphโ€™, โ€˜influenceRโ€™, โ€˜viridisโ€™, โ€˜visNetworkโ€™, โ€˜processmapRโ€™, โ€˜DiagrammeRโ€™, โ€˜petrinetRโ€™, โ€˜ggthemesโ€™

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/shinyTime_1.0.1.zip'
Content type 'application/zip' length 44462 bytes (43 KB)
downloaded 43 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/zoo_1.8-8.zip'
Content type 'application/zip' length 1093964 bytes (1.0 MB)
downloaded 1.0 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/edeaR_0.8.6.zip'
Content type 'application/zip' length 559583 bytes (546 KB)
downloaded 546 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/downloader_0.4.zip'
Content type 'application/zip' length 24922 bytes (24 KB)
downloaded 24 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/igraph_1.2.6.zip'
Content type 'application/zip' length 9344948 bytes (8.9 MB)
downloaded 8.9 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/influenceR_0.1.0.zip'
Content type 'application/zip' length 62675 bytes (61 KB)
downloaded 61 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/viridis_0.5.1.zip'
Content type 'application/zip' length 1866735 bytes (1.8 MB)
downloaded 1.8 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/visNetwork_2.0.9.zip'
Content type 'application/zip' length 4595104 bytes (4.4 MB)
downloaded 4.4 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/processmapR_0.3.4.zip'
Content type 'application/zip' length 862668 bytes (842 KB)
downloaded 842 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/DiagrammeR_1.0.6.1.zip'
Content type 'application/zip' length 5556211 bytes (5.3 MB)
downloaded 5.3 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/petrinetR_0.2.1.zip'
Content type 'application/zip' length 68308 bytes (66 KB)
downloaded 66 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/ggthemes_4.2.0.zip'
Content type 'application/zip' length 440129 bytes (429 KB)
downloaded 429 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/heuristicsmineR_0.2.4.zip'
Content type 'application/zip' length 1545770 bytes (1.5 MB)
downloaded 1.5 MB

package โ€˜shinyTimeโ€™ successfully unpacked and MD5 sums checked
package โ€˜zooโ€™ successfully unpacked and MD5 sums checked
package โ€˜edeaRโ€™ successfully unpacked and MD5 sums checked
package โ€˜downloaderโ€™ successfully unpacked and MD5 sums checked
package โ€˜igraphโ€™ successfully unpacked and MD5 sums checked
package โ€˜influenceRโ€™ successfully unpacked and MD5 sums checked
package โ€˜viridisโ€™ successfully unpacked and MD5 sums checked
package โ€˜visNetworkโ€™ successfully unpacked and MD5 sums checked
package โ€˜processmapRโ€™ successfully unpacked and MD5 sums checked
package โ€˜DiagrammeRโ€™ successfully unpacked and MD5 sums checked
package โ€˜petrinetRโ€™ successfully unpacked and MD5 sums checked
package โ€˜ggthemesโ€™ successfully unpacked and MD5 sums checked
package โ€˜heuristicsmineRโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages

install.packages("petrinetR")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/petrinetR_0.2.1.zip'
Content type 'application/zip' length 68308 bytes (66 KB)
downloaded 66 KB

package โ€˜petrinetRโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages

install.packages("diffeqr")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
also installing the dependency โ€˜JuliaCallโ€™

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/JuliaCall_0.17.2.zip'
Content type 'application/zip' length 1621965 bytes (1.5 MB)
downloaded 1.5 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/diffeqr_1.1.0.zip'
Content type 'application/zip' length 56644 bytes (55 KB)
downloaded 55 KB

package โ€˜JuliaCallโ€™ successfully unpacked and MD5 sums checked
package โ€˜diffeqrโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages

library(diffeqr)
de <- diffeqr::diffeq_setup()
Julia version 1.5.2 at location C:\PROGRA~1\Julia\JULIA-~1.2\bin will be used.
Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.
Error: Error happens in Julia.
SystemError: opening file "C:\Users\dkatz\AppData\Local\Temp\jl_euTf1m\Registry.toml": No such file or directory
Stacktrace:
[1] systemerror(::String, ::Int32; extrainfo::Nothing) at .\error.jl:168
[2] #systemerror#48 at .\error.jl:167 [inlined]
[3] systemerror at .\error.jl:167 [inlined]
[4] open(::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing) at .\iostream.jl:284
[5] open at .\iostream.jl:273 [inlined]
[6] open(::Base.var"#294#295"{Tuple{}}, ::String; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}) at .\io.jl:323
[7] open at .\io.jl:323 [inlined]
[8] read at .\io.jl:408 [inlined]
[9] parsefile at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\ext\TOML\src\TOML.jl:50 [inlined]
[10] read_registry(::String; cache::Bool) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\Types.jl:1044
[11] (::Pkg.Types.v
In addition: Warning messages:
1: In readLines(rf) :
incomplete final line found on 'C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\file7690145130f4'
2: In readLines(rf) :
incomplete final line found on 'C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\file769057f66aad'

lorenz <- function (u,p,t){

  • du1 = p[1]*(u[2]-u[1])
  • du2 = u[1]*(p[2]-u[3]) - u[2]
  • du3 = u[1]*u[2] - p[3]*u[3]
  • c(du1,du2,du3)
  • }

u0 <- c(1.0,1.0,1.0)
tspan <- c(0.0,100.0)
p <- c(10.0,28.0,8/3)
prob <- de$ODEProblem(lorenz,u0,tspan,p)
Error in de$ODEProblem : object of type 'closure' is not subsettable
fastprob <- diffeqr::jitoptimize_ode(de,prob)
Error: object of type 'closure' is not subsettable
sol <- de$solve(fastprob,de$Tsit5(),saveat=0.01)
Error in de$solve : object of type 'closure' is not subsettable
class(de)
[1] "function"
install_github("aryoda/tryCatchLog")
Error in install_github("aryoda/tryCatchLog") :
could not find function "install_github"
library(devtools)
Loading required package: usethis
install_github("aryoda/tryCatchLog")
Downloading GitHub repo aryoda/tryCatchLog@HEAD

checking for file 'C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\remotes76905a1f6fe5\aryoda-tryCatchLog-6a102c2/DESCRIPTION' ...

โˆš checking for file 'C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\remotes76905a1f6fe5\aryoda-tryCatchLog-6a102c2/DESCRIPTION' (1.6s)

  • preparing 'tryCatchLog':
    checking DESCRIPTION meta-information ...

    checking DESCRIPTION meta-information ...

โˆš checking DESCRIPTION meta-information

  • checking for LF line-endings in source and make files and shell scripts

  • checking for empty or unneeded directories

  • building 'tryCatchLog_1.2.2.tar.gz'

Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)

  • installing source package 'tryCatchLog' ...
    ** using staged installation
    ** R
    ** demo
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'tryCatchLog'
    finding HTML links ... done
    append.to.last.tryCatchLog.result html
    build.log.entry html
    build.log.output html
    determine.platform.NewLine html
    get.pretty.call.stack html
    get.pretty.option.value html
    get.pretty.tryCatchLog.options html
    is.duplicated.log.entry html
    is.package.available html
    is.windows html
    last.tryCatchLog.result html
    limitedLabelsCompact html
    log2console html
    platform.NewLine html
    reset.last.tryCatchLog.result html
    set.logging.functions html
    tryCatchLog html
    tryLog html
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded from temporary location
    *** arch - i386
    *** arch - x64
    ** testing if installed package can be loaded from final location
    *** arch - i386
    *** arch - x64
    ** testing if installed package keeps a record of temporary installation path
  • DONE (tryCatchLog)

library(tryCatchLog)
futile.logger not found. Using tryCatchLog-internal functions for logging...
f <- function(value) {

  • print("begin")
  • log(value) # negative number -> warning; string -> error
  • print("end")
  • }

tryLog(f("not a number"))
[1] "begin"
ERROR [2021-01-22 07:41:05] non-numeric argument to mathematical function

Compact call stack:
1 tryLog(f("not a number"))
2 #3: .handleSimpleError(function (c)

Full call stack:
1 tryLog(f("not a number"))
2 tryCatchLog(expr = expr, execution.context.msg = execution.context.msg, write.error.dump.file = write.error.dump.file, write.error.dump.folder = write.error.dump.folder, error = funct
3 tryCatch(withCallingHandlers(expr, condition = cond.handler), ..., finally = finally)
4 tryCatchList(expr, classes, parentenv, handlers)
5 tryCatchOne(expr, names, parentenv, handlers[[1]])
6 doTryCatch(return(expr), name, parentenv, handler)
7 withCallingHandlers(expr, condition = cond.handler)
8 f("not a number")
9 #3: .handleSimpleError(function (c)
{
log.message <- c$message
if (is.null(log.message)) {
if (inherits(c, "interrupt"))
log.message

print("Errors don't stop me!")
[1] "Errors don't stop me!"
install_github("futile.logger")
Error in parse_repo_spec(repo) :
Invalid git repo specification: 'futile.logger'
install_packages("futile.logger")
Error in install_packages("futile.logger") :
could not find function "install_packages"

install.packages("futile.logger")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
also installing the dependencies โ€˜formatRโ€™, โ€˜lambda.rโ€™, โ€˜futile.optionsโ€™

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/formatR_1.7.zip'
Content type 'application/zip' length 152142 bytes (148 KB)
downloaded 148 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/lambda.r_1.2.4.zip'
Content type 'application/zip' length 111403 bytes (108 KB)
downloaded 108 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/futile.options_1.0.1.zip'
Content type 'application/zip' length 21104 bytes (20 KB)
downloaded 20 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/futile.logger_1.4.3.zip'
Content type 'application/zip' length 101971 bytes (99 KB)
downloaded 99 KB

package โ€˜formatRโ€™ successfully unpacked and MD5 sums checked
package โ€˜lambda.rโ€™ successfully unpacked and MD5 sums checked
package โ€˜futile.optionsโ€™ successfully unpacked and MD5 sums checked
package โ€˜futile.loggerโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages

install.packages("pre")
Installing package into โ€˜C:/Users/dkatz/R/win-library/4.0โ€™
(as โ€˜libโ€™ is unspecified)
also installing the dependencies โ€˜plotrixโ€™, โ€˜plotmoโ€™, โ€˜TeachingDemosโ€™, โ€˜shapeโ€™, โ€˜earthโ€™, โ€˜glmnetโ€™

There is a binary version available but the source version is later:
binary source needs_compilation
plotrix 3.7-8 3.8-1 FALSE

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/plotmo_3.6.0.zip'
Content type 'application/zip' length 1556519 bytes (1.5 MB)
downloaded 1.5 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/TeachingDemos_2.12.zip'
Content type 'application/zip' length 1231883 bytes (1.2 MB)
downloaded 1.2 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/shape_1.4.5.zip'
Content type 'application/zip' length 790375 bytes (771 KB)
downloaded 771 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/earth_5.3.0.zip'
Content type 'application/zip' length 2169702 bytes (2.1 MB)
downloaded 2.1 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/glmnet_4.1.zip'
Content type 'application/zip' length 2252921 bytes (2.1 MB)
downloaded 2.1 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/4.0/pre_1.0.0.zip'
Content type 'application/zip' length 404031 bytes (394 KB)
downloaded 394 KB

package โ€˜plotmoโ€™ successfully unpacked and MD5 sums checked
package โ€˜TeachingDemosโ€™ successfully unpacked and MD5 sums checked
package โ€˜shapeโ€™ successfully unpacked and MD5 sums checked
package โ€˜earthโ€™ successfully unpacked and MD5 sums checked
package โ€˜glmnetโ€™ successfully unpacked and MD5 sums checked
package โ€˜preโ€™ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packages
installing the source package โ€˜plotrixโ€™

trying URL 'https://cloud.r-project.org/src/contrib/plotrix_3.8-1.tar.gz'
Content type 'application/x-gzip' length 317856 bytes (310 KB)
downloaded 310 KB

  • installing source package 'plotrix' ...
    ** package 'plotrix' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** data
    ** demo
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'plotrix'
    finding HTML links ... done
    ablineclip html
    add.ps html
    addtable2plot html
    arctext html
    axis.break html
    axis.mult html
    barNest html
    barlabels html
    barp html
    battleship.plot html
    bin.wind.records html
    binciW html
    binciWl html
    binciWu html
    box.heresy html
    boxed.labels html
    brkdn.plot html
    brkdnNest html
    bumpchart html
    categoryReshape html
    centipede.plot html
    clean.args html
    clock24.plot html
    clplot html
    cluster.overplot html
    clustered.dotplots html
    color.axis html
    color.gradient html
    color.id html
    color.legend html
    color.scale html
    color.scale.lines html
    color2D.matplot html
    corner.label html
    count.overplot html
    cylindrect html
    death_reg html
    dendroPlot html
    densityGrid html
    diamondplot html
    dispersion html
    do.first html
    dotplot.mtb html
    draw.arc html
    draw.circle html
    draw.ellipse html
    draw.radial.line html
    draw.tilted.sector html
    drawNestedBars html
    drawSectorAnnulus html
    ehplot html
    election html
    emptyspace html
    fan.plot html
    feather.plot html
    fill.corner html
    find_max_cell html
    floating.pie html
    fullaxis html
    gantt.chart html
    gap.barplot html
    gap.boxplot html
    gap.plot html
    gap_barp html
    get.breaks html
    get.gantt.info html
    get.segs html
    get.soil.texture html
    get.tablepos html
    get.triprop html
    getFigCtr html
    getIntersectList html
    getMarginWidth html
    getYmult html
    get_axispos3d html
    gradient.rect html
    hexagon html
    histStack html
    intersectDiagram html
    jiggle html
    joyPlot html
    kiteChart html
    l2010 html
    labbePlot html
    ladderplot html
    legendg html
    lengthKey html
    makeDensityMatrix html
    makeIntersectList html
    maxEmptyRect html
    mtext3d html
    multhist html
    multivari html
    multsymbolbox html
    oz.windrose html
    oz.windrose.legend html
    p2p_arrows html
    panes html
    pasteCols html
    paxis3d html
    perspx html
    pie.labels html
    pie3D html
    pie3D.labels html
    placeLabels html
    plotCI html
    plotH html
    plot_bg html
    plotrix-package html
    polar.plot html
    polygon.shadow html
    print.brklist html
    propbrk html
    psegments3d html
    ptext3d html
    pyramid.plot html
    radial.grid html
    radial.pie html
    radial.plot html
    radial.plot.labels html
    radialtext html
    raw.means.plot html
    rectFill html
    rescale html
    revaxis html
    ruginv html
    seats html
    size_n_color html
    sizeplot html
    sizetree html
    sliceArray html
    smoothColors html
    soil.texture html
    soil.texture.uk html
    soils html
    spread.labels html
    spreadout html
    stackpoly html
    staircase.plot html
    staircasePlot html
    starPie html
    staxlab html
    std.error html
    sumbrk html
    symbolbarplot html
    symbolbox html
    tab.title html
    taylor.diagram html
    textbox html
    thigmophobe html
    thigmophobe.labels html
    triax.abline html
    triax.fill html
    triax.frame html
    triax.plot html
    triax.points html
    tsxpos html
    twoord.plot html
    twoord.stackplot html
    valid.n html
    vectorField html
    violin_plot html
    weighted.hist html
    zoomInPlot html
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    *** arch - i386
    *** arch - x64
    ** testing if installed package can be loaded from final location
    *** arch - i386
    *** arch - x64
    ** testing if installed package keeps a record of temporary installation path
  • DONE (plotrix)

The downloaded source packages are in
โ€˜C:\Users\dkatz\AppData\Local\Temp\RtmpyuuAyP\downloaded_packagesโ€™

install.packages("diffeqr")
Warning: package โ€˜diffeqrโ€™ is in use and will not be installed

Any help will be much appreciated!

MethodError: no method matching similar_array_type(::Type{JuMP.Containers.DenseAxisArray{VariableRef,1,Tuple{UnitRange{Int64}},Tuple{Dict{Int64,Int64}}}}, ::Type{GenericAffExpr{Float64,VariableRef}})

Hi there,

I am running my code and have the following error:

MethodError: no method matching similar_array_type(::Type{JuMP.Containers.DenseAxisArray{VariableRef,1,Tuple{UnitRange{Int64}},Tuple{Dict{Int64,Int64}}}}, ::Type{GenericAffExpr{Float64,VariableRef}})
Closest candidates are:
similar_array_type(::Type{LinearAlgebra.Symmetric{T,MT}}, ::Type{S}) where {S, T, MT} at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/linear_algebra.jl:137
similar_array_type(::Type{Array{T,N}}, ::Type{S}) where {S, T, N} at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/linear_algebra.jl:141
similar_array_type(::Type{var"#s17"} where var"#s17"<:Union{LinearAlgebra.Adjoint{T,A}, LinearAlgebra.Transpose{T,A}}, ::Type{S}) where {S, T, A} at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/linear_algebra.jl:353
...

Stacktrace:
[1] promote_operation(::typeof(*), ::Type{Int64}, ::Type{JuMP.Containers.DenseAxisArray{VariableRef,1,Tuple{UnitRange{Int64}},Tuple{Dict{Int64,Int64}}}}) at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/linear_algebra.jl:156
[2] promote_operation(::typeof(MutableArithmetics.sub_mul), ::Type{T} where T, ::Type{T} where T, ::Type{T} where T) at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/shortcuts.jl:53
[3] mutability(::Type{T} where T, ::Function, ::Type{T} where T, ::Type{T} where T, ::Type{T} where T) at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/interface.jl:154
[4] mutability(::GenericAffExpr{Float64,VariableRef}, ::Function, ::GenericAffExpr{Float64,VariableRef}, ::Int64, ::JuMP.Containers.DenseAxisArray{VariableRef,1,Tuple{UnitRange{Int64}},Tuple{Dict{Int64,Int64}}}) at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/interface.jl:160
[5] operate!(::typeof(MutableArithmetics.sub_mul), ::GenericAffExpr{Float64,VariableRef}, ::Int64, ::JuMP.Containers.DenseAxisArray{VariableRef,1,Tuple{UnitRange{Int64}},Tuple{Dict{Int64,Int64}}}) at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/rewrite.jl:80
[6] macro expansion at /Users/Javi/.julia/packages/MutableArithmetics/bPWR4/src/rewrite.jl:276 [inlined]
[7] macro expansion at /Users/Javi/.julia/packages/JuMP/y5vgk/src/macros.jl:447 [inlined]
[8] top-level scope at ./In[60]:43
[9] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091

The problem occurs with this constraint: @constraint(m, p_gen[t]-p_load[t]+epsilon<=M*z_excess), p_gen is a continuos variable, z_excess a binary variable

Why are `f` and `fname` used at the same time?

Good work!
It seems redundant that both f and fname are used.
Maybe fname argument can be removed. And when is.character(f), f is treated as fname, otherwise it is treated as a function.

ERROR: LoadError: MethodError: no method matching Sundials.NVector(::Array{Int64,1})

Hi there,

I was exploring the package following the example in the link below. https://mbe.modelica.university/behavior/equations/electrical/
Is a simple example of RLC low-pass filter. In Matlab it work, but in Julia I was no success. The function f below, was obtained in Matlab and still I encountered errors. Please, could you help with this issue?

function f(out,du,u,p,t)
out[1] = 24.0 - 100.0u[2] - du[1]
out[2] = u[3] - 0.1
du[2]
out[3] = u[2] + u[3] - u[1]
end
uโ‚€ = [0, 0, 0]
duโ‚€ = [24.0, 0.0, 0.0]
tspan = (0.0,2.0)

using DifferentialEquations
differential_vars = [true,true,false]
prob = DAEProblem(f,duโ‚€,uโ‚€,tspan,differential_vars=differential_vars)

using Sundials
sol = solve(prob,IDA())

using Plots; plotly() # Using the Plotly backend
plot(sol, tspan=(0.0, 2.0), layout=(3,1))

The result is:

ERROR: LoadError: MethodError: no method matching Sundials.NVector(::Array{Int64,1})
Closest candidates are:
Sundials.NVector(::Array{Float64,1}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/nvector_wrapper.jl:16
Sundials.NVector(::Ptr{Sundials._generic_N_Vector}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/nvector_wrapper.jl:24
Stacktrace:
[1] #__init#75(::Bool, ::Nothing, ::Float64, ::Bool, ::Bool, ::Nothing, ::Float64, ::Float64, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Bool, ::Bool, ::Nothing, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.__init), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/common_interface/solve.jl:870
[2] __init(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/common_interface/solve.jl:790
[3] #init_call#440(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.init_call), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Vararg{Any,N} where N) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:0
[4] init_call(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Vararg{Any,N} where N) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:10
[5] #init#441(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(init), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Vararg{Any,N} where N) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:30
[6] init(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Vararg{Array{Any,1},N} where N) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:18
[7] #__solve#22(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.__solve), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/common_interface/solve.jl:10
[8] __solve(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/common_interface/solve.jl:10 (repeats 5 times)
[9] #solve_call#442(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.solve_call), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:0
[10] solve_call(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:37
[11] #solve#443(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(solve), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:57
[12] solve(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:45
[13] top-level scope at /Users/iEMTtool/Documents/Untitled:15
[14] include_string(::Module, ::String, ::String) at /Applications/JuliaPro-1.2.0-1.app/Contents/Resources/julia/Contents/Resources/julia/lib/julia/sys.dylib:?
[15] (::getfield(Atom, Symbol("##139#144")){String,String,Module})() at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:138
[16] withpath(::getfield(Atom, Symbol("##139#144")){String,String,Module}, ::String) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/CodeTools/sf1Tz/src/utils.jl:30
[17] withpath at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:47 [inlined]
[18] #138 at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:135 [inlined]
[19] with_logstate(::getfield(Atom, Symbol("##138#143")){String,String,Module}, ::Base.CoreLogging.LogState) at ./logging.jl:395
[20] with_logger at ./logging.jl:491 [inlined]
[21] #137 at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:134 [inlined]
[22] hideprompt(::getfield(Atom, Symbol("##137#142")){String,String,Module}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/repl.jl:85
[23] macro expansion at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:133 [inlined]
[24] macro expansion at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Media/ItEPc/src/dynamic.jl:24 [inlined]
[25] (::getfield(Atom, Symbol("##136#141")))(::Dict{String,Any}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:122
[26] handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/comm.jl:164
[27] (::getfield(Atom, Symbol("##19#21")){Array{Any,1}})() at ./task.jl:268
in expression starting at /Users/iEMTtool/Documents/Untitled:15
ERROR: LoadError: MethodError: no method matching Sundials.NVector(::Array{Int64,1})
Closest candidates are:
Sundials.NVector(::Array{Float64,1}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/nvector_wrapper.jl:16
Sundials.NVector(::Ptr{Sundials._generic_N_Vector}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/nvector_wrapper.jl:24
Stacktrace:
[1] #__init#75(::Bool, ::Nothing, ::Float64, ::Bool, ::Bool, ::Nothing, ::Float64, ::Float64, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Bool, ::Bool, ::Nothing, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.__init), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/common_interface/solve.jl:870
[2] __init(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/common_interface/solve.jl:790
[3] #init_call#440(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.init_call), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Vararg{Any,N} where N) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:0
[4] init_call(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Vararg{Any,N} where N) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:10
[5] #init#441(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(init), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Vararg{Any,N} where N) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:30
[6] init(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Vararg{Array{Any,1},N} where N) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:18
[7] #__solve#22(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.__solve), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/common_interface/solve.jl:10
[8] __solve(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Sundials/MllUG/src/common_interface/solve.jl:10 (repeats 5 times)
[9] #solve_call#442(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.solve_call), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:0
[10] solve_call(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:37
[11] #solve#443(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(solve), ::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:57
[12] solve(::DAEProblem{Array{Int64,1},Array{Float64,1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,DAEFunction{true,typeof(f),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Array{Bool,1}}, ::IDA{:Dense,Nothing,Nothing}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/DiffEqBase/jMOwn/src/solve.jl:45
[13] top-level scope at /Users/iEMTtool/Documents/Untitled:15
[14] include_string(::Module, ::String, ::String) at /Applications/JuliaPro-1.2.0-1.app/Contents/Resources/julia/Contents/Resources/julia/lib/julia/sys.dylib:?
[15] (::getfield(Atom, Symbol("##139#144")){String,String,Module})() at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:138
[16] withpath(::getfield(Atom, Symbol("##139#144")){String,String,Module}, ::String) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/CodeTools/sf1Tz/src/utils.jl:30
[17] withpath at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:47 [inlined]
[18] #138 at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:135 [inlined]
[19] with_logstate(::getfield(Atom, Symbol("##138#143")){String,String,Module}, ::Base.CoreLogging.LogState) at ./logging.jl:395
[20] with_logger at ./logging.jl:491 [inlined]
[21] #137 at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:134 [inlined]
[22] hideprompt(::getfield(Atom, Symbol("##137#142")){String,String,Module}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/repl.jl:85
[23] macro expansion at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:133 [inlined]
[24] macro expansion at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Media/ItEPc/src/dynamic.jl:24 [inlined]
[25] (::getfield(Atom, Symbol("##136#141")))(::Dict{String,Any}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/eval.jl:122
[26] handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at /Users/iEMTtool/.juliapro/JuliaPro_v1.2.0-1/packages/Atom/lBERI/src/comm.jl:164
[27] (::getfield(Atom, Symbol("##19#21")){Array{Any,1}})() at ./task.jl:268
in expression starting at /Users/iEMTtool/Documents/Untitled:15

1-dimensional equations are converted to scalar equations

As discussed here, @dlekshmi and myself are having trouble running 1D example from the CRAN ODE vignette.

The original code with function definition through R

f <- function(u,p,t) {
  return(1.01*u)
}

u0 = 1/2
tspan <- list(0.0,1.0)
sol = diffeqr::ode.solve(f,u0,tspan)

gives the following error

Error: Error happens in Julia. MethodError: Cannot convert an object of type OrdinaryDiffEq.ODECompositeSolution{Float64,1,Array{Float64,1},Nothing,Nothing,Array{Float64,1},Array{Array{Float64,1},1},ODEProblem{Float64,Tuple{Float64,Float64},false,Nothing,ODEFunction{false,RCall.var"#11#12"{RObject{ClosSxp}},UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},CompositeAlgorithm{Tuple{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType}},AutoSwitch{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType},Rational{Int64},Int64}},OrdinaryDiffEq.CompositeInterpolationData{ODEFunction{false,RCall.var"#11#12"{RObject{ClosSxp}},UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.CompositeCache{Tuple{OrdinaryDif

And a modified version with function definition through JuliaCall

f <- JuliaCall::julia_eval("
function f(du,u,p,t)
  du = 1.01*u
end")

tspan=list(0.0,1.0)
u0=c(0.5)
sol = diffeqr::ode.solve('f',u0,tspan)

gives

Error: Error happens in Julia. MethodError: no method matching similar(::Float64) Closest candidates are: similar(!Matched::Sundials.NVector) at C:\Users\alinaa.julia\packages\Sundials\SKP8f\src\nvector_wrapper.jl:69 similar(!Matched::Array{T,1}) where T at array.jl:375 similar(!Matched::Array{T,2}) where T at array.jl:376 ... Stacktrace: [1] alg_cache(::Tsit5, ::Float64, ::Float64, ::Type{T} where T, ::Type{T} where T, ::Type{T} where T, ::Float64, ::Float64, ::ODEFunction{true,typeof(f),UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Float64, ::Float64, ::Float64, ::Nothing, ::Bool, ::Val{true}) at C:\Users\alinaa.julia\packages\OrdinaryDiffEq\lGGkK\src\caches\low_order_rk_caches.jl:356 [2] (::OrdinaryDiffEq.var"#172#173"{Float64,Float64,DataType,DataType,DataType,Float64,Float64,ODEFunction{true,typeof(f),UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,N

Issue can be circumvented by turning the function into a system of equations. I put together a more detailed R notebook with my session info/system of equations hack, and previously suggested fixes.

Error in R4.3 + Julia 1.9.2 with Mac M1

I've tried running JuliaCall and it works fine, but when I run diffeqr I get an error.
I get the same error whether I install julia via brew on my Mac or diffeq_setup() from a clean install.

de <- diffeqr::diffeq_setup()

f <- function(u,p,t) {
  return(1.01*u)
}

u0 <- 1/2
tspan <- c(0., 1.)

prob = de$ODEProblem(f, u0, tspan)
sol = de$solve(prob)

Error: Error happens in Julia.
type RFunction has no field r
Stacktrace:
[1] getproperty
@ ./Base.jl:37 [inlined]
[2] numargs(f::RCall.RFunction{RObject{ClosSxp}})
@ SciMLBase ~/.julia/packages/SciMLBase/kTUaf/src/utils.jl:10
[3] isinplace(f::RCall.RFunction{RObject{ClosSxp}}, inplace_param_number::Int64, fname::String, iip_preferred::Bool; has_two_dispatches::Bool, isoptimization::Bool)
@ SciMLBase ~/.julia/packages/SciMLBase/kTUaf/src/utils.jl:242
[4] isinplace(f::RCall.RFunction{RObject{ClosSxp}}, inplace_param_number::Int64, fname::String, iip_preferred::Bool)
@ SciMLBase ~/.julia/packages/SciMLBase/kTUaf/src/utils.jl:240
[5] isinplace(f::RCall.RFunction{RObject{ClosSxp}}, inplace_param_number::Int64)

@ SciMLBase ~/.julia/packages/SciMLBase/kTUaf/src/utils.jl:240
[6] ODEProblem(f::RCall.RFunction{RObject{ClosSxp}}, u0::Float64, tspan::Vector{Float64}, p::SciMLBase.NullParameters; > kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ SciMLB

named vectors in Julia function

Hi

I just started using diffeqr to fit ODE models in R. Is there a way to have named vectors in the function? Indexing works:

library(diffeqr)
theta <-  c(beta=.25, gamma=1/5, mu=1/(70*365), sigma=1/365)
maxtime <- 3650.0
init <- c(100000,0,0)

func_julia <- function(init, param, times) {
  beta <- param[1]
  gamma <- param[2]
  mu <- param[3]
  sigma <- param[4]
  S = state[1]
  I = state[2]
  R = state[3] 
  N = S + I + R
  dSdt = -beta*I*S/N + mu*N - mu*S + sigma*R
  dIdt = beta*I*S/N*S - gamma*I - mu*I 
  dRdt = gamma*I - mu*R - sigma*R
  return(c(dSdt, dIdt, dRdt))
}

enviro <- diffeqr::diffeq_setup()
problem <- enviro$ODEProblem(func_julia, init, c(0.0, maxtime), theta)
solution <- enviro$solve(problem , enviro$AutoVern7(enviro$KenCarp4()), 
                        saveat=1.0, abstol=1e-8, reltol=1e-6)

but using named vectors in R throws an error:

func_julia <- function(init, param, times) {
  beta <- param[["beta"]]
  gamma <- param[["gamma]]
  mu <- param[["mu"]]
  sigma <- param[["sigma"]]
  S = state[1]
  I = state[2]
  R = state[3] 
  N = S + I + R
  dSdt = -beta*I*S/N + mu*N - mu*S + sigma*R
  dIdt = beta*I*S/N*S - gamma*I - mu*I 
  dRdt = gamma*I - mu*R - sigma*R
  return(c(dSdt, dIdt, dRdt))
}
Error in param[["beta"]] : subscript out of bounds
Error: Error happens in Julia.

Named vectors would be great especially for inference and if there are dozens of parameters in the model. Thanks
Fabienne

modelling of events

Hi

I have just started using diffeqr for R and I would love to use it for my (rather large) disease modelling project. I will have an ODE model with a substantial number of compartments and I have to trigger changes the values of states or parameters at specific time points (externally forced, corresponding to an intervention). In plain R and deSolve() I would do this with an event function. Is there an equivalent for diffeqr? And if yes, is example code available?

Bw, Fabienne

Getting started with diffeqr and Julia1.5.2

Hi,
I am trying to get diffeqr installed but am having some problems getting diffeqr setup to work. I installed the package diffeqr and the associated packages as required and Julia 1.5.2 for Windows 10 64-bit system. Would appreciate any suggestions
Kind regards,
Gautam

Error: Error happens in Julia.
Error when installing package DifferentialEquations:
could not load library "libdSFMT"
The specified module could not be found.
Stacktrace:
[1] dsfmt_init_by_array at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Random\src\DSFMT.jl:70 [inlined]
[2] seed!(::Random.MersenneTwister, ::Array{UInt32,1}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Random\src\RNGs.jl:283
[3] seed! at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Random\src\RNGs.jl:290 [inlined]
[4] seed! at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Random\src\Random.jl:426 [inlined]
[5] Random.MersenneTwister(::Nothing) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Random\src\RNGs.jl:139 (repeats 2 times)
[6] default_rng(::Int64) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Random\src\RNGs.jl:304
[7] default_rng at D:\buildbot\worker\package_win6

MethodError: no method matching -(::Array{Float64,1}, ::Float64)

Hi there,

I'm really happy this package exists! Thanks for making it available. However, I am having a problem getting SDEs to work (so far ODEs work perfectly).
When I run the following example from the readme I get an error from Julia:

f <- function(u,p,t) {
  du1 = p[1]*(u[2]-u[1])
  du2 = u[1]*(p[2]-u[3]) - u[2]
  du3 = u[1]*u[2] - p[3]*u[3]
  return(c(du1,du2,du3))
}
g <- function(u,p,t) {
  return(c(0.3*u[1],0.3*u[2],0.3*u[3]))
}
u0 = c(1.0,0.0,0.0)
tspan <- list(0.0,1.0)
p = c(10.0,28.0,8/3)
sol = diffeqr::sde.solve(f,g,u0,tspan,p=p,saveat=0.005)

The result is:

Error: Error happens in Julia.
MethodError: no method matching -(::Array{Float64,1}, ::Float64)
Closest candidates are:
  -(!Matched::Float64, ::Float64) at float.jl:397
  -(!Matched::Complex{Bool}, ::Real) at complex.jl:298
  -(!Matched::Missing, ::Number) at missing.jl:93
  ...
Stacktrace:
 [1] macro expansion at C:\Users\u1013287\.julia\packages\Parameters\35RKe\src\Parameters.jl:733 [inlined]
 [2] perform_step!(::StochasticDiffEq.SDEIntegrator{SOSRI,Array{Float64,1},Float64,Float64,Array{Float64,1},Float64,Float64,Float64,NoiseProcess{Float64,2,Float64,Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},typeof(DiffEqNoiseProcess.WHITE_NOISE_DIST),typeof(DiffEqNoiseProcess.WHITE_NOISE_BRIDGE),false,DataStructures.Stack{Tuple{Float64,Array{Float64,1},Array{Float64,1}}},ResettableStacks.ResettableStack{Tuple{Float64,Array{Float64,1},Array{Float64,1}}},RSWM{:RSwM3,Float64},RandomNumbers.Xorshifts.Xoroshiro128Plus},Array{Float64,1},RODESolution{Float64,2,Array{Array{Float64,1},

I am using Julia 1.0.2.

My session info:

R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] nimble_0.6-11  bindrcpp_0.2.2 diffeqr_0.1.1 

loaded via a namespace (and not attached):
 [1] deSolve_1.21            progress_1.2.0          tidyselect_0.2.4        purrr_0.2.5            
 [5] pbapply_1.3-3           lattice_0.20-35         colorspace_1.3-2        viridisLite_0.3.0      
 [9] miniUI_0.1.1            htmltools_0.3.6         yaml_2.1.19             plotly_4.7.1           
[13] scico_1.0.0             rlang_0.2.1             manipulateWidget_0.10.0 pillar_1.1.0           
[17] later_0.7.3             glue_1.2.0              bindr_0.1.1             plyr_1.8.4             
[21] stringr_1.3.1           munsell_0.5.0           gtable_0.2.0            htmlwidgets_1.3        
[25] coda_0.19-2             knitr_1.20              httpuv_1.4.4.1          crosstalk_1.0.0        
[29] parallel_3.5.0          Rcpp_0.12.19            readr_1.1.1             xtable_1.8-2           
[33] scales_0.5.0            promises_1.0.1          webshot_0.5.0           magick_1.9             
[37] jsonlite_1.5            mime_0.5                ggplot2_2.2.1.9000      hms_0.4.1              
[41] digest_0.6.15           stringi_1.2.3           dplyr_0.7.7             shiny_1.1.0            
[45] grid_3.5.0              tools_3.5.0             magrittr_1.5            rgl_0.99.16            
[49] lazyeval_0.2.1          tibble_1.4.2            nichefillr_0.0.0.9000   crayon_1.3.4           
[53] tidyr_0.8.1             pkgconfig_2.0.1         data.table_1.11.4       randtoolbox_1.17.1     
[57] prettyunits_1.0.2       httr_1.3.1              assertthat_0.2.0        rstudioapi_0.8         
[61] cubature_1.4            JuliaCall_0.16.1        R6_2.3.0                rngWELL_0.10-5         
[65] igraph_1.2.1            compiler_3.5.0         

Any help with this would be much appreciated! Thanks.

Passing parameter lists

I've been trying to get diffeqr to work a passed parameter list and I get the following:

f <- function(u,p,t) {
   with(as.list(p), {
   du1 = p1*(u[2]-u[1])
   du2 = u[1]*(p2-u[3]) - u[2]
  du3 = u[1]*u[2] - p3*u[3]
  return(list(c(du1,du2,du3)))
 })
}

u0 <- c(1.0,0.0,0.0)
tspan <- c(0.0,100.0)
p <- list(p1=10.0,p2=28.0,p3=8/3)
prob <- de$ODEProblem(f, u0, tspan, p)

Which produces this error:

Error: Error happens in Julia.
MethodError: Cannot convert an object of type Array{Float64,1} to an object of type Float64
Closest candidates are:
convert(::Type{T}, !Matched::ArrayInterface.StaticInt{N}) where {T<:Number, N} at /Users/bridenhour/.julia/packages/ArrayInterface/q5Rwc/src/static.jl:18
convert(::Type{T}, !Matched::VectorizationBase.LazyMulAdd{M,O,I}) where {M, O, I, T<:Number} at /Users/bridenhour/.julia/packages/VectorizationBase/AzQKz/src/lazymul.jl:17
convert(::Type{T}, !Matched::VectorizationBase.Vec{W,S}) where {T<:Number, S, W} at /Users/bridenhour/.julia/packages/VectorizationBase/AzQKz/src/llvm_intrin/conversion.jl:96
...
Stacktrace:
[1] setindex!(::Array{Float64,1}, ::Array{Float64,1}, ::Int64) at ./array.jl:847
[2] _unsafe_copyto!(::Array{Float64,1}, ::Int64, ::Array{Any,1}, ::Int64, ::Int64) at ./array.jl:257
[3] unsafe_copyto! at ./array.jl:311 [inlined]
[4] _copyto_impl! at ./array.jl:335 [inlined]
[5] copyto! at ./array.jl:321 [inlined]
[6]

Direct definition of fast functions from R

f <- function(u,p,t) {
  du1 = p[1]*(u[2]-u[1])
  du2 = u[1]*(p[2]-u[3]) - u[2]
  du3 = u[1]*u[2] - p[3]*u[3]
  return(c(du1,du2,du3))
}
u0 <- c(1.0,0.0,0.0)
tspan <- c(0.0,100.0)
p <- c(10.0,28.0,8/3)
prob = de$ODEProblem(f, u0, tspan, p)
odesys = de$modelingtoolkitize(prob)
jul_f = de$ODEFunction(odesys)
prob2 = de$ODEProblem(jul_f, u0, tspan, p)
sol = de$solve(prob2,de$Tsit5()) # overhead!

f3 <- JuliaCall::julia_eval("
function f3(du,u,p,t)
  du[1] = 10.0*(u[2]-u[1])
  du[2] = u[1]*(28.0-u[3]) - u[2]
  du[3] = u[1]*u[2] - (8/3)*u[3]
end")
JuliaCall::julia_assign("u0", u0)
JuliaCall::julia_assign("p", p)
JuliaCall::julia_assign("tspan", tspan)
prob3 = JuliaCall::julia_eval("ODEProblem(f3, u0, tspan, p)")
sol = de$solve(prob3,de$Tsit5()) # no overhead but messy!

system.time({ for (i in 1:100){ de$solve(prob2   ,de$Tsit5()) }})
system.time({ for (i in 1:100){ de$solve(prob3   ,de$Tsit5()) }})

Notice how modelingtoolkitize still has overhead of the function is defined like this. @Non-Contradiction is there a way to directly build Julia functions from R without overhead? Until then, we'll be using this workaround via jitoptimize_ode.

Matrix multiplication in JIT compile

Hi,
I'm trying to do vector equations with diffeqr+jit_compile:
de_jul <- diffeqr::diffeq_setup()
p <- c(10,28,8/3); u0 <- c(1,0.2,0.3); tspan <- c(0,50); p <- c(10,28,8/3); K_lor=matrix(c(-p[1],p[1],0,p[2],-1,0,0,0,-p[3]),3,3)
f_ode_julia_vect <- function(u,x,t) {du=x%*%u + c(0,-u[1]*u[3],u[1]*u[2]); return(du)}
prob<-de_jul$ODEProblem(f_ode_julia_vect, u0,tspan,K_lor); fastprob=diffeqr::jitoptimize_ode(de_jul,prob)

but I get the following error:
Error in x %*% u : requires numeric/complex matrix/vector arguments
Trying without jit:
prob <- de_jul$ODEProblem(f_ode_julia_vect, u0, tspan, K_lor); sol <- de_jul$solve(prob)
produces the error:
MethodError: no method matching Array{Float64,1}(::Array{Float64,2})
Closest candidates are:
Array{Float64,1}(::AbstractArray{S,N}) where {T, N, S} at array.jl:562
Array{Float64,1}() where T at boot.jl:425
Array{Float64,1}(!Matched::UndefInitializer, !Matched::Int64) where T at boot.jl:406

However if I input the matrix but don't do a matrix multiplication:
f_ode_julia_vect<-function(u,x,t){du=c(x[1,1]*u[1]+x[1,2]*u[2],x[2,1]*u[1]+x[2,2]*u[2],x[3,3]*u[3])+c(0,-u[1]*u[3],u[1]*u[2]); return(du)}
then it works, but since I work with relatively large ODE systems that are much more convenient to write as vector equations this solution doesn't really help.
Thanks a lot for any help.

R dev notes

In case I forget in the future:

http://r-pkgs.had.co.nz/release.html

  • To bring the package into current usage, open the project diffeqr.Rproj file.
  • Use devtools::test() to run tests

For tagging:

  • Update DESCRIPTION with new version number
  • devtools::release() is the long way, devtools::submit_cran() is quick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.