Hi all. I have happily been using `Catalyst.jl`

(and of course related packages, such as `ModelingToolkit.jl`

and `DifferentialEquations.jl`

), but when remaking problems while using `EnsembleProblem`

I encountered some odd behavior. In general, when I am making my reaction systems, many of the parameters end up being unused. That means, when I use the `@variables a[1:N]`

to create `N`

variables, these come back when I use the `@unpack`

macro, even though the parameters are not in the reaction system.

To illustrate this, consider the following simple MWE of logistic growth

```
using Catalyst
N = 4
@variables t
@species (x(t))[1:N]
@parameters a[1:N]
rxs = Array{Any}(undef, N)
for n in 1:N
if n != 4
rxs[n] = Reaction(a[n]*(1-x[n]), [x[n]], [x[n]], [1], [2])
else
rxs[n] = Reaction(1, [x[n]], [x[n]], [1], [2])
end
end
@named rs = ReactionSystem(rxs)
```

In this example I have not used `a[4]`

, and indeed when doing `parameters(rs)`

this parameter does not appear in the parameters.

```
julia> parameters(rs)
3-element Vector{SymbolicUtils.BasicSymbolic{Real}}:
a[1]
a[2]
a[3]
```

Yet, when using the `@unpack`

macro, it does

```
julia> @unpack a = rs; a
a[1:4]
```

This becomes strange when using `remake(...)`

as I am basically specify the value of (in my case, many) parameters that are not even in the reaction system. While I can potentially filter `a`

by using the reaction system directly, e.g. something along the lines of

```
julia> p = Symbolics.Num.(ModelingToolkit.parameters(prob.f.sys))
julia> [_a => avalues for _a in a if any(isequal.(_a, p))]
```

this imposes a *heavy* computation time burden as `any(...)`

of course needs to loop over the array until it finds some. As I have large systems with many parameters these loops slow down my code by a lot.

So,

- is there a way of extracting/unpacking only the parameters that are present in the reaction system?, and
- why does
`@unpack`

also unpack these variables even though they are not contained in the reaction system?

Many thanks.