-
Notifications
You must be signed in to change notification settings - Fork 8
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
deal with symbols that don't appear in an equation #8
Comments
While I'm all for making things more efficient, I don't quite see how the proposed change is usable in practice. How would algorithm writers know which variables appear in which equations? Would we expect them to rely on our incidence tables and then only pack up variables that appear in the tables? Another potential issue I see is different equations requiring a different subset of variables at a particular time. For example, in this particular equation only c appears at time t+1, but what if another equation had both My last question is what type of efficiency gains we are hoping to achieve by doing this? Is it the memory requirement of keeping unused variables in vectors (or higher order arrays)? Sorry if this sounds overly critical -- I don't think I have quite as clear of a vision for how this would be used. |
I don't mind the criticism, especially since these are not really issues ;-) Yes, of course, the algorithm writer will have access to the incidence tables, both for each equation and for each group of equation. This is necessary anyway if you want to avoid the construction interpolators for controls that don't even appear in This is feasible by recompiling a special function or keeping the existing ones, by passing arrays with columns that will never be accessed. Also, if you compile several equations, the incidence for this group of equations is the union of the individual incidences. In the above example if the two equations where To be frank I don't know very well the right way to do it in Python. But on the julia side, it sounds easy. I guess, you just need specialize the function |
This is a follow up to EconForge/Dolo.jl#26
Suppose we have a vector of symbols like
states=[:a,:b,:c]
and the the equationa+b +c + c(1)
. Imagine, we have an equation type whose signature is:g(states(-1), states, states(1))
By default (in dolo.jl and dolo.py), we would compile a function
g(x, y, z)
wherex,y,z
are all vectors of the same size (of length 3). But this could lead to suboptimal computation since:c
needs to be known)I see two way of adressing the problem:
g
is computed which involve only the variables that are actually used. Concretely, x would be expectd to be of size 0, y of size 3 and z of size 1. This fixes all drawbacks, but algorithms would seem a bit less natural. It would also probably require several versions of the same function.1/ in the case of a whole vector being ommited we could allow
g(nothing, y,z)
(respg(None,y,z)
) to work as expected.2/ introduce a new class of vectors with non contiguous indexing (for use in our functions). For instance,
zz
could be stored in memory as(v_a)
, butzz[3]
would interpreted in the generated function aszz[1]
.I don't know whether this is completely crazy. It would seem natural to me to write,
g(nothing, y, z)
org(x,y,Packed(zz,(3,)))
ifzz
is a one element vector. The Packed object would only be intended to change the behaviour ing()
.@spencerlyon2 : any thought ?
The text was updated successfully, but these errors were encountered: