Coder Social home page Coder Social logo

Comments (7)

ChrisRackauckas avatar ChrisRackauckas commented on May 23, 2024

I pretty much always use callable types for this, except in cases where I know I want to change the enclosed types due to dual numbers. One thing I have to note is that supporting it as .F makes it less generic, which can be rough to deal with with optimizers (requiring code looping over or generating over getfield). These days I like everything being uniform via ParameterizedFunction(f,params), which is a callable type that encloses a function, and sticks all of the parameters into one thing. If the user wants names for parameters, they can use something like a NamedTuple to hold the parameters, or you can do that behind the scenes here.

from dynamicalsystems.jl.

Datseris avatar Datseris commented on May 23, 2024

I haven't perfectly understood you, which makes me think I probably was not clear enough.

First things first: DynamicalSystems will not care about the parameters or change them internally. Why are you saying that .F makes it less generic? This will only ever be done from the users, e.g.:

using DynamicalSystems
ds = Systems.lorenz() # this is a line from the package
for β in 2:0.1:10
ds.eom!.β = β # this is NOT from the package
λ = lyapunov(ds, 10) # this a line from the package
end

Secondly, to use ParameterizedFunction I would have to do an explicit interfaces that allows for one extra argument (params) for any function call. Or not? Because if I use pf.p = ... (as in the documentation for ParameterizedFunctions`, then is this any different than the above case?

Thirdly, how will ParameterizedFunction avoid this optimization obstacles that you mentioned (if it does). Is it worth it here for my case? I read through the README, but it is not so obvious to me as to which are the advantages of using pf in the current case. Of course it is obvious for DiffEq since parameter estimation is a big deal etc.

Thanks for the comments by the way! Appreciate it!

from dynamicalsystems.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 23, 2024

No, I wasn't saying you should used ParameterizedFunctions for this. I was saying a similar strategy (which is not the macro btw).

First things first: DynamicalSystems will not care about the parameters or change them internally.

Then .F and all of that is fine. Callable types is the right way to go then.

from dynamicalsystems.jl.

Datseris avatar Datseris commented on May 23, 2024

Great thanks for the feedback. I was also thinking about it for months and I was always displeased with the current approach (the fact that change of parameter requires a direct re-construction of a type).

I will implement this now, and change all the example system and the docs. let's see how long it will take...

from dynamicalsystems.jl.

Datseris avatar Datseris commented on May 23, 2024

On another note, do you still stand that for e.g. a Jacobian having something like pf(Type{Val{:jac}}, args...) is the way to go?

Since jacobians are also crucial, I was thinking allowing the users to do:

stuct Syststem
a::Float64
end
function (f::System)(du::Vector, u::Vector)
# here are eom
end
function (f::System)(J::Matrix, u::Vector)
# here is the jacob
end

I am aware that this cannot allow states that are matrices, but this is in general impossible for DynamicalSystems.

from dynamicalsystems.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 23, 2024

No, I am instead building a type for functions in the future.

https://github.com/JuliaDiffEq/DiffEqBase.jl/blob/master/src/diffeqfunction.jl
SciML/DiffEqBase.jl#52

It's very involved and likely overkill for your case.

from dynamicalsystems.jl.

Datseris avatar Datseris commented on May 23, 2024

This is implemented and also the suggested behavior as of version 0.7

from dynamicalsystems.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.