-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
088d102
commit 34e9c2b
Showing
4 changed files
with
34 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function addpolyconstraint!(m::JuMP.Model, p, s::ZeroPoly, domain::FullSpace) | ||
constraints = JuMP.constructconstraint!.(coefficients(p), :(==)) | ||
JuMP.addVectorizedConstraint(m, constraints) | ||
end | ||
|
||
function addpolyconstraint!(m::JuMP.Model, p, s::ZeroPoly, domain::AbstractAlgebraicSet) | ||
addpolyconstraint!(m, rem(p, ideal(domain)), s, FullSpace()) | ||
end | ||
|
||
function addpolyconstraint!(m::JuMP.Model, p, s::ZeroPoly, domain::BasicSemialgebraicSet) | ||
addpolyconstraint!(m, p, NonNegPoly(), domain) | ||
addpolyconstraint!(m, -p, NonNegPoly(), domain) | ||
nothing | ||
end | ||
|
||
addpolyconstraint!(m::JuMP.Model, args...) = error("PolyJuMP is just a JuMP extension for modelling Polynomial Optimization: it does not implement any reformulation. To use automatic sums of squares (SOS) reformulations, install the SumOfSquares Julia package and try \`using SumOfSquares\` and \`setpolymodule!(SumOfSquares)\` or use \`SOSModel\` instead of \`Model\`.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# x should be sorted and without duplicates | ||
function _createpoly(m::JuMP.Model, ::Poly{false}, x::AbstractVector{<:AbstractMonomial}, category::Symbol) | ||
polynomial((i) -> Variable(m, -Inf, Inf, category), x) | ||
end | ||
|
||
function createpoly(m::JuMP.Model, p::Poly{false, :Gram}, category::Symbol) | ||
_createpoly(m, p, monomials(sum(p.x)^2), category) | ||
end | ||
|
||
function createpoly(m::JuMP.Model, p::Union{Poly{false, :Default,Array{T}}, Poly{false, :Classic,Array{T}}}, category::Symbol) where T <: MultivariatePolynomials.AbstractMonomial | ||
_createpoly(m, p, monovec(p.x), category) | ||
end | ||
|
||
function createpoly(m::JuMP.Model, p::Union{PolyJuMP.Poly{false, :Default}, PolyJuMP.Poly{false, :Classic}}, category::Symbol) | ||
MultivariatePolynomials.polynomial([JuMP.Variable(m, -Inf, Inf, category)*p.x[i] for i in 1:length(p.x)]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters