-
-
Notifications
You must be signed in to change notification settings - Fork 49
API decisions for all solvers #4
Comments
As mentioned in #2, we probably want to make the support for time ranges work the same on all solvers as well. |
I don't see any issues with making these improvements and would be happy to merge them. It is sometimes worth considering what numpy does since they too often have a matlab background. It typically follows this same API, but it also provides an object-oriented single-step interface which seems quite handy. |
I haven't worked a lot with NumPy - do you have anything specific in mind, or was it just a general comment? The only NumPy-related ODE stuff I can find is in scipy.integrate, and the API there doesn't look like something I'd like to try to match... |
I haven't used it much either -- just a general comment. Specifically, I was looking at scipy.integrate.ode and while the non-reentrant behavior is a terrible decision, the flexibility to single-step the integration could be very nice |
I agree - that is a nice feature, which as a bonus is really easy to implement if one has a good way to let the user ask for it. We could do something like that (and open up for many other customizations in the future without having to change the API) by allowing the user to pass a
doesn't look nearly as bad as
which would be the Matlab equivalent if there was one... |
Don't forget that Julia now has named arguments, so that can be written: I'm just brainstorming ideas here, but this is roughly what I had in mind for an alternative: solver = ode(@f, t0, y0; reltol=0.01)
solver[:method] = "45"
solver[:abstol] = 0.0001
t, y = solver[:step] # step for solver's "default" time step
t, y = solver[1.2] # step for +1.2 "second"
tout, yout = solver[0:100] # vector of solutions for +0 to +100 "seconds" |
Named arguments is a fantastic way to do that. The user doesn't have to give the type, right? So it would just be And when you mention it, I do kind of like the idea of being able to get a "solver object", where I can get a solution, change one property (but not touch others) and then get another solution to compare with. Consider instead the following syntax:
Maybe we could have both - as long as the signatures of the different |
Discussion continues in #20 ... |
I think the API to these solvers is sometimes a bit confusing, and would like to propose some improvements. In general, I want the API to be as similar as Matlab's as possible - but that's because I'm coming from that direction. I don't know if e.g. R has this functionality, and if the API is different there, so some of these suggestions might be very biased.
Vector
rather than aMatrix
with one column. Bothtout
andyout
should be column vectors (but I think that's already the case, right?)yout
should correspond to a time, rather than each column. This is how Matlab does it, and it also makes sense sincetout
andyout
then has the same number of rows, and the rows correspond to each other.y0
, and as return value ofodefun
, to make it easier to use them on scalar problems.I'd be happy to put some work in towards this, but I'd like to hear your ideas before I start coding =)
The text was updated successfully, but these errors were encountered: