-
-
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
Juliacon2023 Revisions #373
Conversation
Add test for Coevolve calling user-provided funcs with t beyond tspan
The previous ExtendedJumpArray code contains code that implements part of the broadcastable interface, but is not actually used due to the entire interface not being included. This commit replaces that broadcast code, reusing much of the arg packing/repacking. Because of this, the current code uses the fallback indexing method when broadcasting, which requires branching inside the broadcast loop. This branch is likely well-branch-predicted, but the presence of the branch prevents kernel functions from being fused into efficent SIMD instructions. This defines a ExtendedJumpArrayStyle, a broadcast style that includes two sub-styles that represent the styles for broadcasting the `u` and `jump_u` entries. `copyto!` overloads are specified that do the efficent thing and call `copyto!`, using the broadcast computation tree, on `u` and `jump_u` separately. Binary style rules are defined such that broadcasts fall back to the old method if you do something like adding an ExtendedJumpArray to a normal vector. A Julia >=1.9 extension is added for FastBroadcast.jl, where the equivilant of the `copyto!` call, `fast_materialize!` is similarlly overloaded.
Add non-default broadcasting of ExtendedJumpArray's.
Add ExtendedJumpArray saveat test
Pass `integrator` around to make adding support for spatial constant rate jumps easier.
Refactor internal functions in spatial SSAs.
I will need to change some of the functions in bracketing for spatial SSA RSSACRDirect. The tests will help me make sure that I do not break anything.
…code. Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Bracketing unit tests
This is in preparation for the spatial SSA RSSACRDirect.
@gzagatti this shouldn't be merging into master, but merging into the paper branch right? |
@gzagatti do you have a pdf of the paper with your changes highlighted so we can see what changed easily instead of having to reread the whole thing? |
@gzagatti have you confirmed that both reviewers have completed their reviews and you are clear on their comments / questions? Looking at the threads there seem to be some clarification questions you asked that weren't answered, and I'm not sure both reviewers actually finished their reviews. It would be good to make sure we have the full reviews and the full response before resubmitting anything. |
It would be easier to complete the reviews if we can regenerate the paper and docs with your changes, so I would suggest merging whatever they are first. What do you think? |
@isaacsas find the latest version of paper and We can complete the review on our side before we request another check from the reviewers. @gdalle I am happy to accommodate both ways. |
Then I'd say merge the whole thing and ping me so I do another review pass :) |
Ambiguity fix
This PR addresses the paper reviews by @gdalle and @mschauer, which were very beneficial to our paper. Many thanks to both of you!
Apart from the changes to the paper. I would also like to address each issue raised individually.
(As a side note, I have merged this PR with PR #372, so it might be advisable to first merge that PR.)
Review from @gdalle.
I have modified the abstract to make our contribution more explicit and last paragraph in page 5. Our main contribution regarding the new algorithm, Coevolve, is the development of a queued thinning algorithm that steps in sync with model time bringing a few benefits.
Previous version of the thinning algorithm require the proposal of the next time to be confirmed before it can proceed to evolve time causing at least two issues. First, it increases the time-complexity of the algorithm. Let's assume that a traditional thinning algorithm takes on average P proposals before accepting the final one. Then for each of the D dependent sub-processes, we need a total of O(PD) steps for each round of thinning. Second, each time proposal needs to look ahead in time to evaluate the conditional intensity which makes it very difficult to couple TPPs with ODEs or any other stochastic process or unknown callback.
Coevolve reduces the number of time proposal rejections for each round of thinning. Once a new round starts, it makes one proposal for each sub-process O(D), after which model-time evolves. Then, we stop time for each proposal to determine whether we can accept or reject them. If we reject the proposal, we only need to make a single new proposal. Although, it is still the case that we need on average P proposals before accepting the final proposal for each sub-process. Now, we only need to accept a single proposal before triggering a new round of update. Therefore, on average we will make much fewer proposals than O(PD). The benefit of this approach is that we do not need to look ahead in time, so we can couple our process with any other process that might affect the conditional intensity. Additionally, we only need to evaluate the conditional intensity if time eventually reaches the proposal, so exotic intensities might not need to be evaluated as often.
Since these changes allow for more efficiently sampling and new simulation possibilities, we believe they go beyond adaptions from earlier work to make it work with JumpProcesses to stand as a new contribution.
Fixed.
Fixed.
There was a small bug in Alg 4, when$u > L^\ast(t)$ , then $u \leftarrow L^\ast(t)$ .
In any case, it is Alg 5 which is responsible for adding candidates to the queue.
The proposed candidates are always added to the priority queue because we need to stop at each proposed time in order. When the candidate is pre-rejected, we update the bounds and make a new proposal. Alternatively, if the candidate time has not been pre-rejected, we draw the acceptance threshold and compute the intensity rate to make a decision. If the candidate is accepted, we trigger a new round of thinning. Otherwise, we update the bounds and make a new proposal. Overall, we avoid unnecessary updates.
I have added a discussion of this point to the last paragraph of Section 4.
What would be the purpose of highlighting that line? I'm not sure what you mean by synchrony. Although line 15 is an important part of the algorithm, I believe it has to work together with the rest of the routine so I would like to avoid highlighting that line in particular lest it confuses readers.
Added an explanation on the first paragraph of Section 5.
I added a table to the Annex and re-wrote the paragraphs in Section 5 accordingly.
You are right. I qualified to say constant rate thinning aggregators.
You are right. I have refactored this paragraphs to make things more clear. Also, with expanded discussion at the end of Section 4 a lot of these sentences were removed.
Fixed.
Fixed. Explanation added to the paragraph.
Fixed.
Yes, it does, but not to the point of stabilizing the rejection rate. I tried to change$L$ to stabilize the rejection rate but after some trial-and-error I didn't obtain a satisfactory result. Finding optimal ways of choosing $L$ , $\bar{B}$ , $\underline{B}$ would be a good area of future research which is mentioned in the conclusion. As the algorithm stands without any optimization on these variables, our it is already pretty competitive.
Coevolve is synced with model time and does not look ahead. CHV operates on compensated time as you can see from Equation (4.8). Therefore, to stop at pre-specified times during the simulation you would have to perform root-finding which is not cheap. Otherwise, you can run the simulation capturing all the event times, then replay the simulation with discrete callbacks that stop at the realized events and wherever else you want which is not synchronous. In any case, none of these options are currently implemented by CHV.
Fine-grained saving, is one of the main advantages of Coevolve compared to CHV at the moment. However, we are currently thinking about how to allow arbitrary saving in CHV.
JumpProcesses already supports spatial point processes. For instance, check this tutorial. In the conclusion we mention that a more thorough comparison between spatial jump processes and spatial point processes could surface new algorithms that could be added to the library in the same vein that the exercise in this paper led to a new algorithm for TPPs.
Review from @mschauer.
I didn't quite understand your comment here. But I have tried to re-write the paragraph to improve readability.
In line 95, I am trying to explain in words the meaning of$p^\ast (t)$ , so it's indeed the case that $p^\ast (t)$ is conditioned on the history $H_{t−}$ .
Fixed.
I have added a footnote to the first mention of "exact methods". Although not all "exact methods" are completely exact since some of them rely on root finding approximation methods, we follow convention and denote all methods that describe the realization of each point in the process chronologically as "exact methods".
I had the chance to study your work, in particular the paper
Joris Bierkens, Paul Fearnhead, Gareth Roberts: The Zig-Zag Process and Super-Efficient Sampling for Bayesian Analysis of Big Data. The Annals of Statistics, 2019, 47. Vol., Nr. 3, pp. 1288-1320.
I think that the Taylor polynomial could be a promising avenue for automatically setting the upper boundary without user-input. I have added a discussion of this line of work in Section 4.2 where I mention the paper above in the context of non-fixed upper-bounds for thinning methods. I have also adapted Algorithm 5 to allow for non-fixed boundaries to allow for such approaches.
Going beyond the paper, I think there is great opportunity for cross-fertilization. The ZigZag Process could be simulated with JumpProcesses.jl and it would be interesting to perform a benchmark of the different methods. I am also wondering if you attempted to use other algorithms, such as thinning with intervals (like Coevole) or the CHV algorithm (for another take of an inverse method).
Fix #369 JuliaCon/proceedings-review#133.