-
Notifications
You must be signed in to change notification settings - Fork 6
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
Dynamic intervention behaviour should account for the slope at trigger threshold crossings #586
Comments
@liunelson @djinnome Is this issue resolved now? |
I don't think this issue is resolved. @djinnome shared this @sabinala mentioned the interface notebooks https://github.com/ciemss/pyciemss/blob/main/docs/source/optimize_interface.ipynb In both cases, I don't see how I could set up an intervention policy that runs while a target variable is greater than a threshold value (e.g. set The From the notebooks, it seems that, currently, I can only define dynamic interventions that:
Taking the example from |
@liunelson let me try coding up an example of this, it should be doable! |
@liunelson I've tried messing around with this quite a bit and I'm not finding a way around this issue. Let's take it up with Sam when he returns next week. |
@liunelson , thanks for the detailed discussion and requests. This scenario is on the border of what ChiRho (and thus PyCIEMSS) can handle, but I think we can get a workable solution without major upstream changes.
This is true. In our examples thusfar we've been able to work around this by knowing something about the domain. For example, in general we know that infections increase over time, so if we have an event function defined by infections crossing some threshold then we know that that is approaching that threshold from below. If this ends up being a real blocker for this scenario then we could refine this.
This is not true. ChiRho's interruptions inherit from
You absolutely can do this. You just need to have the dynamical system have a state variable for the derivative of the state variable, as you would anyway if you wanted to encode a higher order differential equation into its first order form. Then you would just have the event function refer to that state variable representing the derivative of another state variable. This does require modification of the model, which could in theory be automated to include terms for derivatives.
Can you share the code that generated this behavior? It's hard to say what's going wrong as is. |
@SamWitty How would this work exactly? "'I think we should be able to set the trigger variable, the trigger threshold, and a trigger slope, akin to how triggering works in oscilloscopes' You absolutely can do this. You just need to have the dynamical system have a state variable for the derivative of the state variable, as you would anyway if you wanted to encode a higher order differential equation into its first order form. Then you would just have the event function refer to that state variable representing the derivative of another state variable. This does require modification of the model, which could in theory be automated to include terms for derivatives." Let's say you want an intervention to trigger when a certain state variable crosses the threshold from above (with negative slope). Would you write the intervention like this? (
|
@sabinala Possibly, but it's generally better to avoid conditional branching when you want things to be autodiffed (as we do here). Here's another way of doing this (that is very untested):
|
@SamWitty I would like to try your suggestion, but I haven't been able to make a state variable for the slope ( |
@sabinala , I'm realizing now that this is a bit harder than I thought. It's easy to add the integral of an existing state variable to the state, but not the derivative. |
True, I made a few attempts at getting it to work, but no luck. Leaving this for now. |
Relevant to @anirban-chaudhuri @sabinala
Dynamic interventions are triggered by a model variable crossing some threshold value. In
pyciemss
, this involves achirho
ZeroEvent
.Pascale and Dan on our team raised this point recently:
chirho ZeroEvent
doesn't care whether the approach/crossing happens above or below the threshold https://github.com/ciemss/chirho/blob/master/chirho/dynamical/handlers/interruption.pyThe text was updated successfully, but these errors were encountered: