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

Expand functionality of variable_symbols and variable_index #27

Open
TorkelE opened this issue Jan 3, 2024 · 0 comments
Open

Expand functionality of variable_symbols and variable_index #27

TorkelE opened this issue Jan 3, 2024 · 0 comments

Comments

@TorkelE
Copy link
Member

TorkelE commented Jan 3, 2024

Let's consider a system, sys, with
states = [X, Y, Z]
Here, I will keep my examples to variables, but the same functionality would be useful for parameters as well (and the corresponding parameter_index and parameter_symbols functions).

Request 1, expand variable_index to other cases

Currently, if sym is any of Y, :Y, 1, then variable_index(sys, sym) returns 2 (which is useful in e.g. the BifurcationKit extension, to find the index of e.g. a bifurcation parameter). Would it be possible to make it cover cases when you give arrays, maps, and dictionaries? E.g for
[X, Z] it is broadcasted over the array and you get [1, 3]. Similarly
[X => 1.5, Z => 0.0] becomes [1 => 1.5, 3 => 0.0]
and Dict([X => 1.5, Z => 0.0]) becomes Dict([1 => 1.5, 3 => 0.0]).
These cases are quite niche, but seems like a natural extension. E.g. conversions to maps would be useful in some cases where I interface Catalyst to JumpProcessess to creat spatial Jumps (which contain [1 => 1.5, 3 => 0.0] type structures).

Request 2, allow variable_symbols to be employed more generally

Say that we want to go the other way (from any of Y, :Y, 1 to Y). Here, we can use
variable_symbols(sys)[sym] to receive Y only of sym is 1. If we instead do
variable_symbols(sys)[variable_index(sys, sym)] it works generally.

Would it be possible to either generalise variable_symbols(sys) to a variable_symbols(sys, sym) function which is just variable_symbols(sys)[variable_index(sys, sym)]? Furthermore, would it be possible to apply this to the various forms:
[:X, :Z]
[:X => 1.5, :Z => 0.0]
Dict([:X => 1.5, :Z => 0.0])
A version of this we already got in Catalyst where XProblem input initial conditions and parameters can be on the two latter forms. Conversion to array could be useful in StructuralIdentifiabiltiy where arrays are used to e.g. signify which parameter values are already known.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant