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

Split expressions into static and dynamic #1269

Closed
FFroehlich opened this issue Sep 17, 2020 · 10 comments
Closed

Split expressions into static and dynamic #1269

FFroehlich opened this issue Sep 17, 2020 · 10 comments

Comments

@FFroehlich
Copy link
Member

static expressions don't depend on time/states and only need to be evaluated after reinitialization, not at every timepoint.

@dweindl
Copy link
Member

dweindl commented Sep 6, 2022

Also, some expressions only need to be evaluated at measurement timepoints. Could also treat them separately, or just flatten everything in y and remove unused expressions afterwards.

@dweindl
Copy link
Member

dweindl commented Feb 19, 2024

If we split the expressions as suggested, how would we handle them in ReturnData? Combine static+dynamic expressions a stick to the current ReturnData::w? I.e., the separation of static/dynamic would be hidden to the user.

@dweindl
Copy link
Member

dweindl commented Feb 19, 2024

How to implement?

A: void Model::fw(realtype t, realtype const* x) -> void Model::fw(realtype t, realtype const* x, bool static_=true, bool dynamic=true)
body: if (static_) { /* static exprs */ } if (dynamic) { /* dynamic exprs */ }

vs

B: add: void Model::fw_static(realtype t, realtype const* x), void Model::fw_dynamic(realtype t, realtype const* x), void Model::fw(realtype t, realtype const* x) { fw_static(t, x); fw_dynamic(t, x);}

vs

C: as B but with additional split of w values into w_static + w_dynamic

I think I'd go for A as this minimizes the required code changes.

@FFroehlich
Copy link
Member Author

FFroehlich commented Feb 19, 2024

Yeah A sounds pretty straightforward. Would go for a single flag though as I don't think we ever want to evaluate static only.

@dweindl dweindl self-assigned this Feb 22, 2024
dweindl added a commit to dweindl/AMICI that referenced this issue Feb 22, 2024
@dweindl
Copy link
Member

dweindl commented Feb 22, 2024

Not sure if the initial issue was about w or model expressions in general. Just to be explicit: It might make sense to do the same for other model functions as well.

dweindl added a commit to dweindl/AMICI that referenced this issue Feb 23, 2024
@FFroehlich
Copy link
Member Author

initial issue was only about w. what other expressions could this be applied to?

@dweindl
Copy link
Member

dweindl commented Feb 23, 2024

initial issue was only about w. what other expressions could this be applied to?

Depending on the model, there are quite some time-independent entries for the various derivatives. But not sure whether the benefit outweighs the additional complexity.

@FFroehlich
Copy link
Member Author

initial issue was only about w. what other expressions could this be applied to?

Depending on the model, there are quite some time-independent entries for the various derivatives. But not sure whether the benefit outweighs the additional complexity.

ah, well , haven't looked at the PR yet, but it would be great to do the same for dwdw, dwdx and dwdp.

@dweindl
Copy link
Member

dweindl commented Feb 23, 2024

Right, but potentially also beyond dwd*.

@dweindl
Copy link
Member

dweindl commented Feb 23, 2024

ah, well , haven't looked at the PR yet, but it would be great to do the same for dwdw, dwdx and dwdp.

I'll look into that separately, after review/merge of #2303.

dweindl added a commit to dweindl/AMICI that referenced this issue Feb 24, 2024
Split expressions in `w` into dynamic (explicitly or implicitly time-dependent) and static ones.
Evaluate static ones only when needed, i.e. after (re)initializing x_rdata or parameters.

See AMICI-dev#1269
dweindl added a commit to dweindl/AMICI that referenced this issue Feb 24, 2024
Split expressions in `w` into dynamic (explicitly or implicitly time-dependent) and static ones.
Evaluate static ones only when needed, i.e. after (re)initializing x_rdata or parameters.

See AMICI-dev#1269
dweindl added a commit to dweindl/AMICI that referenced this issue Feb 26, 2024
Split expressions in `w` into dynamic (explicitly or implicitly time-dependent) and static ones.
Evaluate static ones only when needed, i.e. after (re)initializing x_rdata or parameters.

See AMICI-dev#1269
dweindl added a commit that referenced this issue Feb 27, 2024
Split expressions in `w` and its derivatives into dynamic (explicitly or implicitly time-dependent) and static ones.
Evaluate static ones only when needed, i.e. after (re)initializing x_rdata or parameters.

See #1269
@dweindl dweindl closed this as completed Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants