Skip to content

Commit

Permalink
fix stale code that is breaking builds (#830)
Browse files Browse the repository at this point in the history
* Changing DP.Polyvar -> DP.Variable as suggested

* Renaming MultivariateBases -> MB.

* addinequality! -> add_inequality!

* fix stale broken code

---------

Co-authored-by: stephanmg <[email protected]>
  • Loading branch information
lkapelevich and stephanmg authored Nov 25, 2023
1 parent 7f81cf2 commit 61b12b5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/JuMP_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function setup_model(
if !isnothing(extender)
# for PolyJuMP/SumOfSquares models
for B in model.bridge_types
MOI.Bridges.add_bridge(opt, B{Float64})
MOI.Bridges.add_bridge(opt, B)
end
end

Expand Down
10 changes: 5 additions & 5 deletions examples/contraction/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function build(inst::ContractionJuMP{T}) where {T <: Float64}
JuMP.@variable(
model,
polys[1:3],
PolyJuMP.Poly(PolyJuMP.MultivariateBases.FixedPolynomialBasis(lagrange_polys))
PolyJuMP.Poly(PolyJuMP.MB.FixedPolynomialBasis(lagrange_polys))
)

M = [polys[1] polys[2]; polys[2] polys[3]]
Expand Down Expand Up @@ -105,13 +105,13 @@ function get_lagrange_polys(pts::Matrix{T}, deg::Int) where {T <: Real}
end

# returns the multivariate Chebyshev polynomials in x up to degree deg
function get_chebyshev_polys(x::Vector{DP.PolyVar{true}}, deg::Int)
function get_chebyshev_polys(x::Vector{<:DP.Variable}, deg::Int)
if deg > 8
@warn("get_chebyshev_polys is not numerically stable for large degree")
end
n = length(x)
u = get_chebyshev_univ(x, deg)
V = Vector{DP.Polynomial{true, Int}}(undef, PolyUtils.get_L(n, deg))
V = Vector(undef, PolyUtils.get_L(n, deg))
V[1] = DP.Monomial(1)
col = 1
for t in 1:deg, xp in Combinatorics.multiexponents(n, t)
Expand All @@ -124,14 +124,14 @@ function get_chebyshev_polys(x::Vector{DP.PolyVar{true}}, deg::Int)
return V
end

function get_chebyshev_univ(monovec::Vector{DP.PolyVar{true}}, deg::Int)
function get_chebyshev_univ(monovec::Vector{<:DP.Variable}, deg::Int)
if deg > 8
@warn("get_chebyshev_univ is not numerically stable for large degree")
end
n = length(monovec)
u = Vector{Vector}(undef, n)
for j in 1:n
uj = u[j] = Vector{DP.Polynomial{true, Int}}(undef, deg + 1)
uj = u[j] = Vector(undef, deg + 1)
uj[1] = DP.Monomial(1)
uj[2] = monovec[j]
for t in 3:(deg + 1)
Expand Down
4 changes: 2 additions & 2 deletions examples/convexityparameter/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ function test_extra(inst::ConvexityParameterJuMP{T}, model::JuMP.Model) where {T
end

# construct domain inequalities for SumOfSquares models from Hypatia domains
bss() = SAS.BasicSemialgebraicSet{Float64, DynamicPolynomials.Polynomial{true, Float64}}()
bss() = SAS.FullSpace()

function get_domain_inequalities(dom::PolyUtils.BoxDomain, x)
box = bss()
for (xi, ui, li) in zip(x, dom.u, dom.l)
SAS.addinequality!(box, (-xi + ui) * (xi - li))
SAS.add_inequality!(box, (-xi + ui) * (xi - li))
end
return box
end
Expand Down
4 changes: 2 additions & 2 deletions examples/semidefinitepoly/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import SumOfSquares
import PolyJuMP

struct SemidefinitePolyJuMP{T <: Real} <: ExampleInstanceJuMP{T}
x::Vector{<:DP.PolyVar}
x::Vector{<:DP.Variable}
H::Matrix{<:DP.Polynomial}
is_feas::Bool # whether model should be primal-dual feasible; only for testing
use_wsosmatrix::Bool # use wsosinterppossemideftri cone, else PSD formulation
use_dual::Bool # use dual formulation, else primal formulation
end

function SemidefinitePolyJuMP{Float64}(
x::Vector{DP.PolyVar{true}},
x::Vector{<:DP.Variable},
poly::DP.Polynomial,
args...,
)
Expand Down

0 comments on commit 61b12b5

Please sign in to comment.