DAE problem set-up in DiffEq changed?

I used DifferentialEquations.jl to solve a DAE in 2017-2018 or so. I just tried to re-run the Jupyter notebook, and now I get an error message… Here is the essence of my past set-up:

function seborg_is(err,dxdt,x,par,t)
...
end

The model has 45 variables (differential + algebraic). I have defined initial values dxdt0 and x0 that used to work. I have defined a parameter vector par_is. Then I do:

# Specifying differential variables
diff_vars = fill(false,45)
diff_vars[1:4] = true
# Time span
tspan = (0.,10.)
# Problem definition
probis = DAEProblem(seborg_is,dxdt0,x0,tspan,par_is,differential_vars=diff_vars)

Here, the 5th argument (par_is) is the parameter vector meant to be used in function seborg_is. The current documentation doesn’t really say whether I’m allowed to specify the parameter vector like this – this used to work, but may have changed??

When I specify the DAE problem probis, I get the following error message:

MethodError: no method matching setindex_shape_check(::Bool, ::Int64)
Closest candidates are:
  setindex_shape_check(!Matched::AbstractArray{#s75,1} where #s75, ::Integer) at indices.jl:218
  setindex_shape_check(!Matched::AbstractArray{#s75,1} where #s75, ::Integer, !Matched::Integer) at indices.jl:221
  setindex_shape_check(!Matched::AbstractArray{#s75,2} where #s75, ::Integer, !Matched::Integer) at indices.jl:225
  ...

Stacktrace:
 [1] macro expansion at .\multidimensional.jl:722 [inlined]
 [2] _unsafe_setindex!(::IndexLinear, ::Array{Bool,1}, ::Bool, ::UnitRange{Int64}) at .\multidimensional.jl:717
 [3] _setindex! at .\multidimensional.jl:712 [inlined]
 [4] setindex!(::Array{Bool,1}, ::Bool, ::UnitRange{Int64}) at .\abstractarray.jl:1074
 [5] top-level scope at In[47]:3

Questions:

  1. What has changed?
  2. How can I modify my code?

Nothing on DiffEqs side: the interface stayed the same.

It can be literally any type: we just pass it through.

Look at the spot where the error is. Without seeing the code or the stack trace this is impossible for someone to help you with.bmy guess is that it was Julia 0.6 code and now you’re post 1.0, so it’s one of those changes like u[:]=… when it needs a .=

3 Likes

Thanks for tip. I’ll check again tomorrow. I thought I had tested the code on Julia v 1.2; the Jupyter notebook opened in v. 1.2. But maybe I didn’t run it.

Ah. I needed to change diff_vars[1:4] = true to diff_vars[1:4] .= true – this is what caused the included error message.

[In addition, the IDA() solver has been split out into its own package Sundials, + I had to change ones(array) to ones(size(array)) in other parts of my code…]

2 Likes