Skip to content

Missing differentiation function on one() #252

@wupeifan

Description

@wupeifan

Here's an MWE:

using ModelingToolkit

@variables beta, alpha, delta
@variables x1, x2, x3

# expression
tmp = beta * (alpha * exp(x1) * x2 ^ (alpha - 1) + 1 - delta) / x3
# derivative w.r.t. x1 and x2
t1 = ModelingToolkit.gradient(tmp, [x1, x2])

# notice that there are one() functions even after running simplify_constants
julia> t1
2-element Array{Operation,1}:
                     beta * x2 ^ (alpha - 1) * alpha * exp(x1) * (one(beta * ((alpha * exp(x1) * x2 ^ (alpha - 1) + 1) - delta)) / x3)
 beta * alpha * exp(x1) * (alpha - 1) * x2 ^ ((alpha - 1) - 1) * (one(beta * ((alpha * exp(x1) * x2 ^ (alpha - 1) + 1) - delta)) / x3)

# AND HERE GOES THE ERROR MESSAGE
julia> ModelingToolkit.gradient(t1[1], [beta])
ERROR: MethodError: no method matching derivative(::typeof(one), ::Tuple{Operation}, ::Val{1})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions