Skip to content
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

Errors in Callbacks usage #129

Closed
ccontrer opened this issue Jan 11, 2017 · 5 comments
Closed

Errors in Callbacks usage #129

ccontrer opened this issue Jan 11, 2017 · 5 comments

Comments

@ccontrer
Copy link

ccontrer commented Jan 11, 2017

Hi @ChrisRackauckas, I've been playing around with the callbacks and I keep getting some errors. I'll use the Bouncing Ball example.
If I use

using DifferentialEquations
using Plots

f = @ode_def BallBounce begin
  dy =  v
  dv = -g
end g=9.81

function event_f(t,u) # Event when event_f(t,u) == 0
  u[1]
end

function apply_event!(u,cache)
  u[2] = -u[2]
end

callback = @ode_callback begin
  @ode_event event_f apply_event!
end

u0 = [50.0,0.0]
tspan = (0.0,15.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob,callback=callback)
plot(sol)

I get

ERROR: LoadError: UndefVarError: nlsolve not defined

I tried using

const dt_safety = 1 # Multiplier to dt after an event
const interp_points = 10
const terminate_on_event = false
const rootfind_event_loc = false
callback = @ode_callback begin
  @ode_event event_f apply_event! rootfind_event_loc interp_points terminate_on_event dt_safety
end

The graph is not shown as expected
figure_1
If try the new Callbacks types

function condition(t,u,integrator) # Event when event_f(t,u) == 0
  u[1]
end

function apply_event!(integrator)
  integrator.u[2] = -integrator.u[2]
end

interp_points = 10
rootfind = true
save_positions = (true,true)
cb = Callback(condtion,affect!,rootfind,interp_points,save_positions)

Then, sol = solve(prob,Tsit5(),callback=cb), I get

ERROR: LoadError: UndefVarError: Callback not defined

I know, Callbacks is a work in progress I just wanted to shared my experience and understand these issues.
By the way, amazing work with the package!

@ccontrer ccontrer changed the title Callbacks usage Errors in Callbacks usage Jan 11, 2017
@ChrisRackauckas
Copy link
Member

ChrisRackauckas commented Jan 11, 2017

Hey,
Yes, you need to be on the latest version. I would've thought that the tags have gone through, but sadly they haven't yet (I should've waited on the doc changes!). You will need to Pkg.checkout("OrdinaryDiffEq") and Pkg.checkout("DiffEqBase") for the time being. (Pkg.free when you're done to get back to release). You can track the tags at METADATA. For example:

JuliaLang/METADATA.jl#7508

There's quite a few changes so it might stumble a little bit to get them all through, but there should be a period of stability afterwards. Sorry about the troubles!

@ccontrer
Copy link
Author

I tried it, but it was funky. Is this supposed to happen?

INFO: Downgrading DifferentialEquations: v1.5.0 => v0.5.0

@ChrisRackauckas
Copy link
Member

It's probably because that's the only way it can resolve the current versioning. Max version requirements were placed on some packages since that's how I was told to make sure that incompatible versions wouldn't exist while tags were waiting to go through. Honestly, I am just going to be putting up an issue explaining what's going on saying that to use the newer functionality / newer docs you should probably just wait for the tags, and apologize for the time being. I am very sorry and hopefully soon the tags will work themselves out, but I cannot give any guarantee since I have no role in the tagging process and it seems that METADATA is very backed up...

If you want to try it out now, you can go on master for every component package, but that's not recommended unless you're planning to develop.

@ccontrer
Copy link
Author

That sounds good. I'll try to go on master for the other packages, and see what I get. I won't bother you since I'll be digging in the development zone.
Looking forward to use the new version!
Cheers.

@ChrisRackauckas
Copy link
Member

It's just that the releases are now something like 200-300+ commits behind the masters... it makes it difficult for tests to pass, so that then slows down the tags because I'm supposed to disable tests for new functionality because the tagging process is slow? Sorry, this is making me visibly mad so I'm going to just have to let it slowly work itself out. If you check out DiffEqDevDocs.jl it shows how to use MetaPkg to checkout a bunch of packages, though it actually doesn't get them all (because some have been added since then).

To track the issue in full, I'll be using this issue:

#130

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

No branches or pull requests

2 participants