Skip to content

Inconsistent behavior of Poly with DynamicPolynomials and TypedPolynomials. #255

Description

@hurak

I am trying to reproduce the example on Lyapunov function search from the documentation. The example uses DynamicPolynomials. Since the degree of the polynomials is fixed here, my understanding was that I can freely switch to TypedPolynomials. But then the example fails. Below is the snippet of code relevant to reproduce the failure. First, with DynamicPolynomials:

julia> using DynamicPolynomials

julia> @polyvar x[1:3]
(PolyVar{true}[x₁, x₂, x₃],)

julia> using SumOfSquares

julia> monosX = x.^2
3-element Vector{Monomial{true}}:
 x₁²
 x₂²
 x₃²

julia> Poly(monosX)
Poly{MonomialBasis{Monomial{true}, Vector{Monomial{true}}}}(MonomialBasis{Monomial{true}, Vector{Monomial{true}}}(Monomial{true}[x₁², x₂², x₃²]))

And now (after restarting the REPL) the same code with TypedPolynomials:

julia> using TypedPolynomials

julia> @polyvar y[1:3]
(y₁, y₂, y₃)

julia> using SumOfSquares

julia> monosY = y.^2
(y₁², y₂², y₃²)

julia> Poly(monosY)
ERROR: MethodError: no method matching Poly(::Tuple{Monomial{(y₁,), 1}, Monomial{(y₂,), 1}, Monomial{(y₃,), 1}})
Closest candidates are:
  Poly(::AbstractVector{<:MultivariatePolynomials.AbstractPolynomialLike}) at ~/.julia/packages/PolyJuMP/pghif/src/variable.jl:36
  Poly(::PB) where PB<:AbstractPolynomialBasis at ~/.julia/packages/PolyJuMP/pghif/src/variable.jl:34
Stacktrace:
 [1] top-level scope
   @ REPL[5]:1

Is this a feature or a bug? I confess I still do not get the difference between the two polynomial types perfectly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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