Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop tests for indexing problem with a parameter #387

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- Core
version:
- '1'
- '1.6'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
Expand Down
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
JumpProcessFastBroadcastExt = "FastBroadcast"

[compat]
ArrayInterface = "6, 7"
DataStructures = "0.17, 0.18"
ArrayInterface = "7"
DataStructures = "0.18"
DiffEqBase = "6.122"
DocStringExtensions = "0.8.6, 0.9"
DocStringExtensions = "0.9"
FunctionWrappers = "1.0"
Graphs = "1.4"
PoissonRandom = "0.4"
RandomNumbers = "1.3"
RecursiveArrayTools = "2, 3"
Reexport = "0.2, 1.0"
RecursiveArrayTools = "3"
Reexport = "1.0"
SciMLBase = "1.51, 2"
StaticArrays = "0.10, 0.11, 0.12, 1.0"
StaticArrays = "1.0"
UnPack = "1.0.2"
julia = "1.6"
julia = "1.10"

[extras]
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
Expand Down
9 changes: 6 additions & 3 deletions src/problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ end
# when setindex! is used.
function Base.setindex!(prob::JumpProblem, args...; kwargs...)
SciMLBase.___internal_setindex!(prob.prob, args...; kwargs...)
if using_params(prob.massaction_jump)
update_parameters!(prob.massaction_jump, prob.prob.p)
end

# since parameters are no longer allowed to be mutated and the preceding will error this
# isn't needed
# if using_params(prob.massaction_jump)
# update_parameters!(prob.massaction_jump, prob.prob.p)
# end
Comment on lines +126 to +130
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setp will still allow for issues, along with manual mutation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need a custom dispatch on it then to update MassActionJumps?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @AayushSabharwal can probably help with that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great, thanks!

Copy link
Member

@AayushSabharwal AayushSabharwal Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have set_parameter! in SII which is used by setp internally, and can be implemented to do other bookkeeping actions when setp is used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AayushSabharwal, can you add the needed dispatches to that when parameters get modified, i.e. something like what we had before when modifying a problem:

if using_params(prob.massaction_jump)
    update_parameters!(prob.massaction_jump, prob.prob.p)
end

Alternatively, @ChrisRackauckas do we want to put this on users (since this could be expensive, so a faster workflow is to only call it once all parameter modifications are finished)? That does leave a gotcha someone could encounter unless they carefully read the docs (which is why the previous behavior here always updated directly after modifying a parameter).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we do put calling the jump update function on users currently when modifying integrators within callbacks, so perhaps it isn't unreasonable to do that.

end

# when getindex is used.
Expand Down
10 changes: 6 additions & 4 deletions test/jprob_symbol_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ affect1!(integ) = (integ.u[1] += 1)
affect2!(integ) = (integ.u[2] += 1)
crj1 = ConstantRateJump(rate1, affect1!)
crj2 = ConstantRateJump(rate2, affect2!)
g = DiscreteFunction((du, u, p, t) -> nothing; syms = [:a, :b], paramsyms = [:p1, :p2])
g = DiscreteFunction((du, u, p, t) -> nothing; sys = SymbolicIndexingInterface.SymbolCache([:a, :b], [:p1, :p2], :t))
dprob = DiscreteProblem(g, [0, 10], (0.0, 10.0), [1.0, 2.0])
jprob = JumpProblem(dprob, Direct(), crj1, crj2)

# runs the tests
@test jprob[:a] == 0
@test jprob[:b] == 10
@test jprob[:p1] == 1.0
@test jprob[:p2] == 2.0

# tests for setindex (e.g. `jprob[:a] = 10`) not possible, this requires the problem to have a .f.sys filed.,
# these are no longer supported by SciMLBase
@test getp(jprob,:p1)(jprob) == 1.0
@test getp(jprob,:p2)(jprob) == 2.0
ChrisRackauckas marked this conversation as resolved.
Show resolved Hide resolved
@test jprob.ps[:p1] == 1.0
@test jprob.ps[:p2] == 2.0
Comment on lines +18 to +21
Copy link
Member Author

@isaacsas isaacsas Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where has the dispatch been added to ensure update_parameters!(jprob.massaction_jump, jprob.prob.p) is called when these parameter changes are made?

Loading