PolyJuMP.jl icon indicating copy to clipboard operation
PolyJuMP.jl copied to clipboard

support variable creation with NonNegPoly(X)

Open chriscoey opened this issue 7 years ago • 1 comments

@variable(m, p, NonNegPoly(X)) perhaps also @variable(m, p, NonNegPoly(X), domain=D)? (or maybe domain could be a second argument to NonNegPoly)

chriscoey avatar Nov 03 '18 14:11 chriscoey

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.

blegat avatar Nov 03 '18 14:11 blegat