Giter VIP home page Giter VIP logo

Comments (2)

ChrisRackauckas avatar ChrisRackauckas commented on June 14, 2024

I'm surprised you ever had a vector return work with that. @register_symbolic always assumed a scalar output. You need to update this to @register_array_symbolic for array functions and it should be fine.

from symbolics.jl.

chris-hampel-CA avatar chris-hampel-CA commented on June 14, 2024

Ok I see that is was added in 5.13.0. Thanks for letting me know!

I am trying to test the script on 5.13.0, but I am still getting stumped with figuring out the exact implementation. I think I am closely following the example near line 530 in the MTK test file

If you don't mind taking a peak below and offering some guidance, would be much appreciated.

function vec_return(T, n)
    [T, T, T] 
end
@register_array_symbolic vec_return(T, n) begin
    size=(3,)
    eltype=promote_type(eltype(T), eltype(n)) #=optional?, fails to build eqs if I do not specify this=#
end

nx=3.0 
Tx=500.0

vars = @variables (x[1:3], a, b, c)
pars = @parameters (n=nx, T=Tx)

eqs = [
    x ~ vec_return(T, n)
    a ~ 1 + x[1]
    b ~ 2 + x[2]
    c ~ 3 + x[3]
]
@show eqs

@named sys = NonlinearSystem(eqs, vars, pars)
guess = [x[1] => 1, x[2] => 1, x[3] => 1,
        a => 1, b => 1, c => 1]
prob = NonlinearProblem(sys, guess, [])
sol = solve(prob, NewtonRaphson())

The eqs print as:

eqs = Any[(broadcast(~, x, Main.var"##mock test#292".vec_return(T, n)))[1], (broadcast(~, x, Main.var"##mock test#292".vec_return(T, n)))[2], (broadcast(~, x, Main.var"##mock test#292".vec_return(T, n)))[3], a ~ 1 + x[1], b ~ 2+ x[2], c ~ 3 + x[3]]

The error is:

  LoadError: MethodError: no method matching -(::SymbolicUtils.BasicSymbolic{Any}, ::SymbolicUtils.BasicSymbolic{Real})

Does anything look blatantly incorrect in the implementation when using @register_array_symbolic in your mind? Thanks.

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