PolyJuMP.jl
PolyJuMP.jl copied to clipboard
support variable creation with NonNegPoly(X)
@variable(m, p, NonNegPoly(X))
perhaps also
@variable(m, p, NonNegPoly(X), domain=D)? (or maybe domain could be a second argument to NonNegPoly)
The type of the returned variable may depend on the type of the domain. For instance with SumOfSquares, it is MatPolynomial{JuMP.VariableRef} for a domain FullSpace while with a domain is will be Polynomial{AffExpr}.
If the domain is not in NonNegPoly then JuMP.variable_type will not be possible to implement because it should only depend on the type of positional arguments (see https://github.com/JuliaOpt/JuMP.jl/blob/64c5834412cb22dc7047e3edaf5bdc62d0303d3d/src/macros.jl#L1086).
However, using the domain keyword is more consistent with the @constraint macro.
We could return a Polynomial{AffExpr} in the case the domain is a FullSpace too (we just need to call polynomial on the MatPolynomial before returning it) so that the value of variable_type does not depend on the type of the domain.