Replies: 5 comments 14 replies
-
Super nice ideas!
The model of Problem / Algorithm / State sounds good, I think for now I often combined Algorithm and state – and they were always mutating, why would we do non-mutation ones? But sure in general we could do non mutating ones. I can check tomorrow for examples from my side as well – about nested algorithms for example. Thanks for all the ideas! |
Beta Was this translation helpful? Give feedback.
-
As an addendum after some more discussions with @mtfishman : something that I've always found to be quite elegant is the "iterator" approach, which I've first seen in IterativeSolvers.jl but have since seen in various forms and incarnations throughout the Julia ecosystem. function my_solver!(x, A, b)
iterable = MySolverIterable(x, A, b)
for item in iterable end
return iterable.x
end What is nice about this approach is that it allows you to insert arbitrary callback functions between iterations. (Also, I just think it looks very elegant). See also:
The biggest problem is that it tends to clash with some of the concepts that are linked with
Some of these things have also partially been discussed here and here The SCIML interface does have some particularly nice features that wrap an iterator and influence how it returns information, possibly every I'd love to hear your take on this as well, since I do think it has some advantages as well as disadvantages. |
Beta Was this translation helpful? Give feedback.
-
I think one point I would like to understand a bit more – philosophically – from your ideas is the split between Algorithm and its state. Until now my mental model was often
What is the benefit of splitting the last point into two and how to split that?
Would that mean one can |
Beta Was this translation helpful? Give feedback.
-
I looked a bit at the iterator interface – besides the naming, Besides this naming thing being a negative point, I do not yet see a positive point in using the iterate interface. |
Beta Was this translation helpful? Give feedback.
-
Sorry for a bit of delay here. I hope to continue with an idea for a debug state soon |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Looking at the readme file, that seems like a great place to start.
Some thoughts and considerations that I'm trying to collect here:
Features
The main features I would be looking for, which more or less aligns with what is currently proposed:
Some other goodies, such as:
I like the abstraction in terms of tasks, here are my initial thoughs about that:
Whenever possible, I would like to design the functionality as much as possible around functions, and not types. I think this is one of the most common things that packages that want to be generic get wrong. This boils down to Julia having a type tree instead of a more generic type system. Often, having to decide if something has to subtype either abstract type
A
orB
, is a big source of friction to adapt/extend into. Basically, I would try to design functions with fixed arity, such that the position of the argument determines its functionality, while the type can be anything. Here is an example of something like this, where we are only dispatching on theAlgorithm
type, but otherwise use positional arguments. (see bottom for the boilerplate).I like the design in terms of separating static information about the problem from the mutable state during the problem.
I think I would even suggest splitting it a bit further, going for:
Problem
: static information about the problem to solve, can always assume this does not change during the solvingAlgorithm
: full specification of the algorithm to solve with. Serves as a "glorifiedNamedTuple
": it holds the settings, and is used to dispatch between different implementations. Again, assume this does not change during the solving.State
: All information that is carried between iterations. This ideally has optional mutation. (possiblystate = step!!(state, problem, algorithm)
?)Of course, all of this is guided by things that I've used and experimented with in the past, and one of the nice parts of sharing is merging things that we like and discarding things we don't like.
Let me therefore share some design patterns and approaches that I have particularly enjoyed, and think would make sense to put in a package like this. (Please do feel free to share yours, I think this can improve all our experiences)
&(::Algorithm, ::Algorithm)
is something that is used a lot and is very convenient.Beta Was this translation helpful? Give feedback.
All reactions