Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Suggestions for objective function #31

Open
ivarne opened this issue Mar 13, 2014 · 2 comments
Open

Suggestions for objective function #31

ivarne opened this issue Mar 13, 2014 · 2 comments

Comments

@ivarne
Copy link
Contributor

ivarne commented Mar 13, 2014

Currently Julia performs poorly with anonymous functions, and the sorting system has used a funny trick with types to pass a different comparison function. After reading @mauro3's comment about implicit objective functions in #30, I got an idea for a proposal for how to solve 3 problems in a somewhat cluncky way.

immutable Density <: ODEImplicit 
    mu::Float64
end

function ode_fun(typ::Density, y, y_t, t)
    return (typ.mu .* y .* t) - y_t
end

t_out, y_out = ode_xx(Density(1.091), y0, [0. 1.])

This would of be in addition to the normal F(y,t) = y', system currently proposed. This approach has 3 main advantages.

  1. It uses types instead of anonymous functions. That enables the use of Julia's dispatch and inference system to generate specific code for each ODE problem. Better performance will probably be the result.
  2. It gives a nice way to access system properties inside the differentiation function. If you do not need system properties, you can define the immutable/type as empty.
  3. It gives a natural way to tag different problem specifications in a way that encourages multiple dispatch.
@ivarne
Copy link
Contributor Author

ivarne commented Mar 13, 2014

Hmm... Different objective function specifications can actually just be controlled by a keyword argument. We would need to call a different internal solver function anyway, and then the check of the keyword argument will be outside the inner loop and not affect the types of the returned values.

@mauro3
Copy link
Contributor

mauro3 commented Apr 22, 2015

In 0.4, types can be called and have good type inference (as I'm sure @ivarne is aware of). I think it should be possible to use that out of the box with ODE.jl. Maybe it would make sense to "sanction" the use of the "Functors" of base: https://github.com/JuliaLang/julia/blob/0a341a6e7ece5802d45901797f304b85420e1eb2/base/functors.jl

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants