Giter VIP home page Giter VIP logo

Comments (9)

ChrisRackauckas avatar ChrisRackauckas commented on August 22, 2024

You need to do solve(prob,QuadGKJL(),reltol=1e-3,abstol=1e-3).u. But it's having an issue that the domain transformation is increasing nout? @agerlach is that supposed to happen?

from integrals.jl.

agerlach avatar agerlach commented on August 22, 2024

I'll take a look at it. May not be until tomorrow though.

from integrals.jl.

agerlach avatar agerlach commented on August 22, 2024

But it's having an issue that the domain transformation is increasing nout? @agerlach is that supposed to happen?

Yes. B/c the gradient is computed as the integral of the vector of partials. Here length(p)=2, so nout gets changed to 2. QuadGKJL() does not support vector valued integrands. So, @frank-ccc if you swap out QuadGKJL() for any of the other methods it will work as expected, e.q.

function testf(lb,ub,p)
    prob = QuadratureProblem(f,lb,ub,p)
    solve(prob,QuadGKJL(),reltol=1e-3,abstol=1e-3)[1]
end

function testf2(lb,ub,p)
    prob = QuadratureProblem(f,lb,ub,p)
    solve(prob,CubatureJLh(),reltol=1e-3,abstol=1e-3)[1]
end

dp1 = Zygote.gradient(p->testf(lb,ub,p),p)[1]
dp2 = Zygote.gradient(p->testf2(lb,ub,p),p)[1]

from integrals.jl.

ChrisRackauckas avatar ChrisRackauckas commented on August 22, 2024

Oh hmm, it would be good to find an informative error message here, or break it apart on QuadGK

from integrals.jl.

frank-ccc avatar frank-ccc commented on August 22, 2024

@ChrisRackauckas @agerlach thanks a lot to help resolve this. I am actually trying to solve a Fredholm problem with differential programming. May I contact you separately if have questions?

from integrals.jl.

ChrisRackauckas avatar ChrisRackauckas commented on August 22, 2024

Yeah sure

from integrals.jl.

lxvm avatar lxvm commented on August 22, 2024

@ChrisRackauckas It appears this issue was fixed by #189 since we no longer use nout as a check on QuadGKJL. The following translation of the mwe is working for me

using Integrals, Cuba, Cubature, Zygote, FiniteDiff, ForwardDiff
using Test

f(y,p) = sum(sin.(p[1].*y) + p[2])
lb = 1.0
ub = 3.0
p = [2.0,1.0]
prob = IntegralProblem(f,lb,ub,p)
sol = solve(prob,QuadGKJL(),reltol=1e-3,abstol=1e-3)

function testf(lb,ub,p)
    prob = IntegralProblem(f,lb,ub,p)
    solve(prob,QuadGKJL(),reltol=1e-3,abstol=1e-3).u
end

function testf2(lb,ub,p)
    prob = IntegralProblem(f,lb,ub,p)
    solve(prob,CubatureJLh(),reltol=1e-3,abstol=1e-3).u
end

dlb1,dub1,dp1 = Zygote.gradient(testf,lb,ub,p)
dlb2,dub2,dp2 = Zygote.gradient(testf2,lb,ub,p)

@test dlb1 โ‰ˆ dlb2
@test dub1 โ‰ˆ dub2
@test dp1 โ‰ˆ dp2

I will follow up on this with a pr to run the existing AD tests on all the compatible algorithms, which would be helpful at catching edge cases.

from integrals.jl.

ChrisRackauckas avatar ChrisRackauckas commented on August 22, 2024

Awesome, really nice job on that update PR. Seems like it fixed most issues ๐Ÿ˜…

from integrals.jl.

lxvm avatar lxvm commented on August 22, 2024

Can confirm that this is fixed by #189 and will close now that we have #196 for better testing

from integrals.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.