Skip to content

Instantly share code, notes, and snippets.

@angeris
Last active April 18, 2019 18:50
Show Gist options
  • Save angeris/8ac92dee79081c946979bcce8160f656 to your computer and use it in GitHub Desktop.
Save angeris/8ac92dee79081c946979bcce8160f656 to your computer and use it in GitHub Desktop.
MWE for reproducing large performance decrease for JuMP v0.18.5
using JuMP
using ProgressMeter
using LinearAlgebra
using SparseArrays
import Gurobi
# Formulates ‖x‖² ≤ y as an SOC
function quad_cons(m, x, y)
@constraint(m, sum(x.^2) ≤ y )
end
t_min = 1
t_max = 2 - t_min
N = 26 # number of points in domain
freqs = [1, 2, 3]
n_freq = length(freqs) # number of frequencies for the given problem
L_all = []
⊗ = kron
@info "Generating Matrices"
for i=1:n_freq
global L_all
w = freqs[i]
weights = 5*ones(N*N)
g = zeros(N*N)
b = zeros(N*N)
L_1d = (N*N)/(w*w) * Diagonal(ones(N))
L = L_1d ⊗ sparse(I, N, N)
push!(L_all, L)
end
z_init = zeros(n_freq, N*N)
t_init = t_min*ones(N*N)
@info "Generating model"
m = Model(solver=Gurobi.GurobiSolver())
@variable(m, nu[1:N*N, 1:n_freq])
@variable(m, t[1:N*N])
@info "Generating constraints"
@showprogress 1 for j=1:N*N
@time quad_cons(m, [ (L_all[i][:,j]' * nu[:,i]) for i=1:n_freq ], t[j])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment