Closed
Description
Hi, I am considering to solve a misdp problem. I found this example online and thought, I would try to see if this works. However, It always get stuck at creating a diagonal matrix of an array variable.
using JuMP, Pajarito, LinearAlgebra
# Set up QP JuMP model, solve, print solution
# xB is a bound on the absolute values of the estimate variables x_j
# Solver can be either MIQP/MINLP or MICP
# Model is a bit "low level" in order to be compatible with MathProgBase ConicToLPQPBridge
# Set up MISDP JuMP model, solve, print solution
# No bound xB is needed in this model
function misdp_cardls(m, d, A, b, k, rho, solver)
mod = Model(solver=solver)
@variable(mod, tau)
@variable(mod, z[1:d],Int)
@objective(mod, Min, tau)
@constraint(mod, sum(z) <= k)
Im = Matrix{Float64}(I,m,m);
dz = diagm(z);
@SDconstraint(mod, [(Im + 1/rho*A*dz*A') b ; b' tau] >= 0)
solve(mod)
println(" selected features (z) = \n$(getvalue(z))\n")
end
#=========================================================
Choose solvers and options
=========================================================#
mip_solver_drives = true
rel_gap = 1e-5
# using Cbc
# mip_solver = CbcSolver()
using CPLEX
mip_solver = CplexSolver(
CPX_PARAM_SCRIND=(mip_solver_drives ? 1 : 0),
# CPX_PARAM_SCRIND=1,
CPX_PARAM_EPINT=1e-8,
CPX_PARAM_EPRHS=1e-7,
CPX_PARAM_EPGAP=(mip_solver_drives ? 1e-5 : 1e-9)
)
# using SCS
# conic_solver = SCSSolver(eps=1e-6, max_iters=1000000, verbose=0)
using Mosek
conic_solver = MosekSolver(LOG=0)
micp_solver = PajaritoSolver(
mip_solver_drives=mip_solver_drives,
log_level=3,
rel_gap=rel_gap,
mip_solver=mip_solver,
cont_solver=conic_solver,
)
#=========================================================
Specify/generate data
=========================================================#
d = 6 # Dimension of feature space
m = 20 # Number of samples
#srand(100) # Change or comment random seed to get different data
A = randn(m, d) # Sample point matrix (rows are samples)
b = randn(m) # Sample measurement vector
# @show A
# @show b
k = floor(Int, d/2) # Number of features to select (||x||_0 <= k)
rho = 1. # Ridge regularization multiplier
xB = 4 # Bound on absolute values of estimate variables (|x_j| <= xB)
#=========================================================
Solve JuMP models
=========================================================#
println("\n\n****MISDP model****\n")
misdp_cardls(m, d, A, b, k, rho, micp_solver)
Metadata
Metadata
Assignees
Labels
No labels