SciML / SciML/JumpProcesses.jl

Accessing an ArrayPartition through x doesn't work with VariableRateJump

Open
#57 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
150
Forks
41
Avg merge
1d 9h
Merged PRs (30d)
28

Description

Example:

function f(du,u,p,t)
  #du[1] = -u[1]
  du.x[1][1] = -u.x[1][1]  # ERROR here
end

u0 = ArrayPartition([1.0],[1.0])
ode = ODEProblem(f,u0,(0.0,1.0))

rate(u,p,t) = 10*u[1]
function affect!(integrator)
  #integrator.u[2] += randn()
  integrator.u.x[2] .+= randn() # ERROR here
end
jump = VariableRateJump(rate,affect!)
jump_prob = JumpProblem(ode,Direct(),jump)
sol = solve(jump_prob,Tsit5())

Results in:
type SubArray has no field x
inside the function f, where apparently u is of type SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true} rather than an ArrayPartition.
Replacing the offending line with the commented-out line in f, a similar exception appears in affect!:
type ExtendedJumpArray has no field x.
In the offending line is similarly replaced in affect!, it works as expected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example with f, affect!, VariableRateJump, and JumpProblem, then trace how u becomes a SubArray and how the jump state becomes an ExtendedJumpArray. No source file or test is named, so begin by locating the callback and state-wrapping paths. Done means ArrayPartition state access through .x works in both callbacks without breaking ordinary indexing.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.