-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Indexing fixes #408
Merged
Merged
Indexing fixes #408
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c4e3bee
drop tests for indexing problem with a parameter
isaacsas d99890d
Update jprob_symbol_indexing.jl
ChrisRackauckas a80abc6
Update test/jprob_symbol_indexing.jl
ChrisRackauckas bd48982
bumps for the new LTS
ChrisRackauckas 77995f7
Update test/jprob_symbol_indexing.jl
ChrisRackauckas f4e4a80
Merge remote-tracking branch 'origin/master' into pr/387
isaacsas 7a279c6
Auto stash before merge of "pr/387" and "origin/master"
isaacsas dbd37f6
fix problem symbolic indexing
isaacsas 0f14821
return set_parameter! returns
isaacsas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
# prepares the problem | ||
using JumpProcesses, Test | ||
using JumpProcesses, Test, SymbolicIndexingInterface | ||
rate1(u, p, t) = p[1] | ||
rate2(u, p, t) = p[2] | ||
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]) | ||
maj = MassActionJump([[1 => 1], [1 => 1]], [[1 => -1], [1 => -1]]; param_idxs = [1,2]) | ||
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) | ||
jprob = JumpProblem(dprob, Direct(), crj1, crj2, maj) | ||
|
||
# runs the tests | ||
# test basic querying of u0 and p | ||
@test jprob[:a] == 0 | ||
@test jprob[:b] == 10 | ||
@test jprob[:p1] == 1.0 | ||
@test jprob[:p2] == 2.0 | ||
@test getp(jprob,:p1)(jprob) == 1.0 | ||
@test getp(jprob,:p2)(jprob) == 2.0 | ||
@test jprob.ps[:p1] == 1.0 | ||
@test jprob.ps[:p2] == 2.0 | ||
|
||
# tests for setindex (e.g. `jprob[:a] = 10`) not possible, this requires the problem to have a .f.sys filed., | ||
# test updating u0 | ||
jprob[:a] = 20 | ||
@test jprob[:a] == 20 | ||
|
||
# test mass action jumps update with parameter mutation in problems | ||
@test jprob.massaction_jump.scaled_rates[1] == 1.0 | ||
jprob.ps[:p1] = 3.0 | ||
@test jprob.ps[:p1] == 3.0 | ||
@test jprob.massaction_jump.scaled_rates[1] == 3.0 | ||
p1setter = setp(jprob, [:p1, :p2]) | ||
p1setter(jprob, [4.0, 10.0]) | ||
@test jprob.ps[:p1] == 4.0 | ||
@test jprob.ps[:p2] == 10.0 | ||
@test jprob.massaction_jump.scaled_rates == [4.0, 10.0] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is technically correct,
set_parameter!
will be called once for each parameter which would make this very expensive. I'll PR to SII to add a callback that runs at the end ofsetp
(finalize_parameters_hook!(prob, ps)
?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SciML/SymbolicIndexingInterface.jl#58
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I guess we could also use that for calling
reset_aggregated_jumps!
when integrators get updated in callbacks, which means one less thing for users to have to handle.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AayushSabharwal please ping me when a SII release with that callback is available so I can get this finished -- we need this for making updates to Catalyst for MTK9. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been released now @isaacsas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I thought it was merged and would be available. Sorry 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it's out in 0.3.13