-
-
Notifications
You must be signed in to change notification settings - Fork 230
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
Consider breaking syntax changes #235
Comments
By 2, you mean that it would be possible to only use Functors and never care about ParameterizedFunction wrappers? if so, yes please! For the 1, YEEEEEEES pleeeeeeeeease! I actually have written DynamicalSystems with the "proposed change" format initially, just because it was so weird for me. But I don't mind changing it back. For 1 however, please have it as EDIT: wait, now I understood point 2. Why make them explicit always? Just have the optional definition |
I haven't used |
|
|
I definitely do not support keyword arguments for such a basic component of the equations of motion. Fortunately it is very easy to make them positional default arguments, since |
Not necessarily. And those two aren't mutually exclusive either. |
Well, unless you want to always write 2 definitions in your source code in the handling of equations of motion, one that has |
If you have one parameter you can use a number and it'll work just fine in the current way. |
Sounds unnecessary complication for me. It's not like you can gain something performance wise by allowing possibility of both number and container? |
You can make it a tuple of a single number, sure. That's still a bitstype though, so I'm not sure why you'd bring that up. |
I would like to vote Yes for both. Mutating the first argument is what I am used to seeing, e.g., in |
Alright, my expression was bad. What I wanted to point out is that you could always have |
That would not allow the possibility of |
@Datseris, I can see your point. Maybe the The intuition in textbooks, as far as I can see, is that they write the |
When making them optional, remember what that would actually do to user codes. They always have to be able to accept the optional stuff, either by function f(du,u,args...)
...
end or function f(du,u;kwargs...)
....
end otherwise it would error if the integrator internally calls The interesting thing about a standard signature which involves splatting is we could always add weird stuff in the future though... but I'm not sure how much that'd actually do anything. |
That being said, from @ChrisRackauckas's perspective, that would not make much difference at all, either. If there is an assumption that |
I do not like splatting, I would really hate to write my equations of motion as If they need to use both Why would the user care about whether a method or not is optional. They just use what they need, and not define extra. |
How would I know which one to call? I have if is_two_param
f(du,u)
elseif is_three_param
f(du,u,t)
elseif is_four_param
f(du,u,t,p)
end ? (that's actually not too difficult to get everywhere because it could be built via a closure, but that's quite prone to bugs). This is because if you call a function which the user hasn't defined, it'll error. Even then, there's the question of how to distinguish between those cases and still allow a non-mutating form (which is quite important!). I'm not entirely sure how I could find out all of this information without making some of it explicit type information. This then ties over to SciML/DiffEqBase.jl#52 where if we can have function f(du,u)
...
end
af = AutonomousFunction(f)
prob = ODEProblem(af,u0,tspan) when isn't less verbose but now allows the solver to know what form it must be in order to call it correctly. |
I did not consider that. Then I am all up for having explicit parameter Haven;t thought about it from that perspective. |
Oh man! If the |
So it looks like everybody is for explicit parameters and mutation in front?
Making the extra arguments optional will not be possible. What will be possible will be that the two forms, in place an out of place, which is whether
Yes, this will get rid of a whole layer of closures that we commonly use. |
Why do the parameters need to be saved at each step if they are not changing? |
Because you can make them time-varying. The DEDataArray is for this purpose of saving the parameters. It seems to come up in a lot of people's use-cases that they care about time-varying algebraic quantities, though arguably the SavingCallback and FunctionCallingCallback do this better now. If this was ever to become an option, it would definitely be false by default though, so don't worry about it. |
Alright, I am willing to bribe people to vote for the first. Alternative facts methods incoming now |
That actually makes a lot of sense if the parameters are a known function of time. Now that I understand that, I think that the proposed syntax makes a lot of sense. Unfortunately, I don't think that there is any correct ordering for |
So let's look at what this would look like in full. I'll use method 1 because that seems to be winning so far. We would have: f(u,t,p) # out-of-place ODE/SDE
f(du,u,t,p) # in-place ODE/SDE
f(du,u,t,p) # out-of-place DAE
f(res,du,u,t,p) # in-place DAE
f(u,h,t,p) # out-of-place DDE
f(du,u,h,t,p) # in-place DDE
f(du,u,t,x,y,p) # proposed PDE syntax
rate(t,u,integrator) # for jumps, add the integrator
integrator.p # parameters directly in the integrator
ODEProblem(f,u0,tspan,p=nothing) # parameters passed to problem
f(v,x,t) # DynamicalODEProblem out-of-place syntax
f(dv,v,x,t) # DynamicalODEProblem in-place syntax
f(du,u,W,t) # RODE in-place syntax Additionally, changes would include: h(out,t;idxs=nothing,deriv=0) # HistoryFunction args move to keyword arguments and moving the Jacobian/etc. specification to Question: would it be preferred if we did this at the same time as the 1.0 transition, i.e. the version which drops v0.6 is the same one which then introduces these changes? I am not sure if this change can give deprecations BTW, so it will be majorly breaking. |
Looks good, I am not too fussed about whether it is synced with 1.0 transitions, just whatever turns out to be the easiest. Right now, I can't think of anything else that should be broken. |
Is it possible to change rate(t,u,integrator) # for jumps, add the integrator to rate(u,t,integrator) # for jumps, add the integrator to keep the consistency? Or, am I missing something? Most likely I would not be using it at all, but when I checked the code, my OCD got triggered |
You're right. I missed that one. One nice thing about this change is that it would be easy to add a switch so that instead of Even if it's not standard, having a switch for this would allow all sorts of weird algorithms and cache re-use (I'll be using it in the internal sensitivity calculation algorithms for example). |
(I'm an outsider here so I'm not sure if this is more than a noise. But anyway...) I've never used PDE solver but does this:
mean you would have But vararg in the middle is no problem in Julia so this is not a bit deal anyway. PS: ...or even |
Looking through that commit I see two possible problems,
I can complete this list and make a PR when I get more time later on today (probably not until I get home in about 5 hours). |
Alright, it's settled. After talking to some people individually, and some in chats, it seems there's pretty much a consensus for Thanks everyone who pitched in. I will announce this right away and get going on it. From now on, master branch is allowed to have this syntax. The OP now will track which packages upgraded their master. A massive amount of version bounds on DiffEqBase will go through, and then nothing will upgrade until all packages go through METADATA. Every package will get a major version bump (except Sundials which just did...?), and DifferentialEquations.jl will be the last to update after all other go through. Please feel free to pitch in and help out. We will especially need eyes to keep going over the docs, tutorials, and benchmarks to make sure all of those examples are up to date. I don't think the notebooks need to be re-ran, but they should be made runnable. |
Sounds good. I will be contributing indirectly by making sure that my packages run after the change and what unexpected behavior/syntax errors I get, which is quite a test of usage I have to admit. |
Sounds fantastic. Sorry that I didn't go through the rest of the docs thoroughly like I said I would, I got very held up yesterday. I will definitely have a read through at some stage when I get some time. Thank you so much for all of your hard work, I really appreciate it. |
Personally, I would like to thank you for your efforts --- not only in making the package really useful and well-documented but also in asking for users' preferences in doing so.
This I will try to help with... definitely! :) Cheers! |
Everything is upper bounded on DiffEqBase, DiffEqDiffTools, and OrdinaryDiffEq. This won't make anything come into effect until the whole ecosystem is tagged. Tags are in for DiffEqBase, DiffEqDiffTools, and OrdinaryDiffEq as well. Dependents have been added to the list of necessary PRs. |
what is the link for the updated docs? The page you have linked in a previous comment doesn't exist anymore. |
Hm, maybe it is a good time to think whether to have the in-place version as the first seen example? (or mention EDIT: First-seen examples are quite important as it is the first thing new users see and therefore the first thing they use. It is also often the case that people do not go further than the first seen example, if they can serve their case. However, if they don't use static arrays and this leads to bad performance, somebody really noob in Julia could say "ooooh what is this its not faster that pythoooon uga uga uga" :D :D :D |
That is a good question. On one hand, it's what most people should be using. On the other hand, I have found that it can be very confusing to people who are not "programmers", and so many stick with the out of place form simply out of familiarity. It hurts me when thinking about speed, but the ease-of-use should not be underrated. |
That may be true, but it is also worth to say that (at least in Julia) the skills required to understand in-place operations are as high (if not even lower) as the skills required to just handle Vector data in general. And I think it is clear that the latter skills are mandatory to use DiffEq and actually do something with it. |
I am not sure that's true. This is a good example: https://github.com/PoisotLab/BioEnergeticFoodWebs.jl @tpoisot's library is a great use of DiffEq, but it currently uses the out-of-place format on Vectors. This is because they couldn't figure out the cache resizing for ODEs of changing size: PoisotLab/BioEnergeticFoodWebs.jl@3c46723 I'll go in and fix this which a PR that does the cache resizing, but it is something that's not simple. Though you can also say that resizing diffeqs is something specialized itself. |
Can't imagine something more advanced/complicated to be perfectly honest, so I don't think this is an argument for the first-seen example :D |
I missed |
The core libraries are all updated. Now I am waiting on @pkofod to tag an NLsolve.jl update and then these will all get tagged. |
Is there any example of using the parameters while them not being an Array? I really cannot think of how to do it and allow for other types besides arrays... @ChrisRackauckas you said that the type of I have a function where I want to solve problems for different parameters, and the user to choose which parameter to be varied (with what values). If But what if |
Then require an Array. There's nothing about DiffEq's engine that needs it to be an array, but you can require it to be an array for your uses. But that was always true about how parameters could be used.
It's a nice way without using global constants to have a bunch of cache variables in your function. Also, named tuples are a great use of parameters because then they are named (e.g. const a = 0.89
f(u,p,t) = a*u
ODEProblem(f,u0,tspan) can become a = 0.89
f(u,a,t) = a*u
ODEProblem(f,u0,tspan,a) I really disliked the amount of But again, you can restrict on your end. I bet you $20 that you've already made a lot of assumptions about what can be solved that don't necessarily hold, but that's fine. |
Okay, tags are starting to go through. The release post is drafted: One last thing to discuss. 10. For any Dynamical ODE function `f(t,u1,u2,dui)`, it's now `f(dui,u1,u2,p,t)`
11. For any Dynamical ODE function `f(t,u1,u2)`, it's now `f(u1,u2,p,t)`
12. For any second order ODE function `f(t,u,du,out)`, it's now `f(out,u,du,p,t)`
13. For any second order ODE function `f(t,u,du)`, it's now `f(u,du,p,t)` Does this ordering make sense for second order ODEs? Note that it has to match DynamicalODE functions. |
The blog post is live: http://juliadiffeq.org/2018/01/24/Parameters.html Everything is passing tests. Tagging is going. After the tags go through, then I will focus on getting PRs to dependent packages. |
Every JuliaDiffEq library has a tag PR in METADATA, and the core libraries have tags already. DifferentialEquations.jl won't get a tag until all of these are in, which once that's true I will wipe my packages, download DiffEq, checkout master, and make sure that runs clean. Then that will tag and it'll all be live. There's upper bounds on the dependent packages still which will need PRs too. |
DifferentialEquations.jl is now tagged. PRs to dependent libraries coming soon. |
The rest of the PRs @Datseris said he'd do, so this is done. |
|
With Julia v1.0 being released, we have a last big attempt at breaking syntax changes. The question is, should we do any?
Two that would be possible are:
f(du,t,u)
instead off(t,u,du)
(orf(du,u,t)
).f(t,u,p,du)
as standard. Then there would be no need for the ParameterizedFunction wrappers. Instead, problems could hold parameters, and maybe they could be saved each step with an option?Edit:
We are doing
f(mutate, dependent variables, p/integrator, independent variables)
. Compatible on master:All are updated on master branches. Check marks now mean tags.
p
in prob)And dependent libraries:
The text was updated successfully, but these errors were encountered: