From f50a8ea670e3f1d2014be572a0ba3450e1b0b6a7 Mon Sep 17 00:00:00 2001 From: Chris Coey Date: Sun, 15 Jul 2018 14:09:33 -0400 Subject: [PATCH 1/5] by default use MSD if MIP solver allows --- src/solver.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/solver.jl b/src/solver.jl index 6a0e94f..521db76 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -68,7 +68,7 @@ function PajaritoSolver(; timeout = Inf, rel_gap = 1e-5, - mip_solver_drives = false, + mip_solver_drives = nothing, mip_solver = UnsetSolver(), mip_subopt_solver = UnsetSolver(), mip_subopt_count = 0, @@ -113,6 +113,12 @@ function PajaritoSolver(; error("No MIP solver specified (set mip_solver)\n") end + if mip_solver_drives == nothing + mip_solver_drives = applicable(MathProgBase.setlazycallback!, MathProgBase.ConicModel(mip_solver), x -> x) + elseif mip_solver_drives && !applicable(MathProgBase.setlazycallback!, MathProgBase.ConicModel(mip_solver), x -> x) + error("MIP solver does not support callbacks (cannot set mip_solver_drives = true)") + end + if viol_cuts_only == nothing # If user has not set option, default is true on MSD and false on iterative viol_cuts_only = mip_solver_drives From e02793f6473c8a89f52f9684d668ee613abf500c Mon Sep 17 00:00:00 2001 From: Chris Coey Date: Sun, 15 Jul 2018 14:24:52 -0400 Subject: [PATCH 2/5] print MSD or iter --- examples/cardls.jl | 2 +- src/conic_algorithm.jl | 2 +- src/solver.jl | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/cardls.jl b/examples/cardls.jl index cd9d7cc..0affd36 100644 --- a/examples/cardls.jl +++ b/examples/cardls.jl @@ -53,7 +53,7 @@ end Choose solvers and options =========================================================# -mip_solver_drives = false +mip_solver_drives = true rel_gap = 1e-5 diff --git a/src/conic_algorithm.jl b/src/conic_algorithm.jl index c47cdc3..5830cc1 100644 --- a/src/conic_algorithm.jl +++ b/src/conic_algorithm.jl @@ -647,7 +647,7 @@ function MathProgBase.optimize!(m::PajaritoConicModel) m.new_incumb = false m.cache_dual = Dict{Vector{Float64},Vector{Float64}}() - if m.log_level > 1 + if m.log_level >= 1 @printf "\nStarting %s algorithm\n" (m.mip_solver_drives ? "MIP-solver-driven" : "iterative") end status_oa = m.mip_solver_drives ? solve_mip_driven!(m) : solve_iterative!(m) diff --git a/src/solver.jl b/src/solver.jl index 521db76..f1d4fa4 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -112,7 +112,6 @@ function PajaritoSolver(; if mip_solver == UnsetSolver() error("No MIP solver specified (set mip_solver)\n") end - if mip_solver_drives == nothing mip_solver_drives = applicable(MathProgBase.setlazycallback!, MathProgBase.ConicModel(mip_solver), x -> x) elseif mip_solver_drives && !applicable(MathProgBase.setlazycallback!, MathProgBase.ConicModel(mip_solver), x -> x) From 68f161e849622f006a748fa3e3bae3da7efa4cda Mon Sep 17 00:00:00 2001 From: Chris Coey Date: Sun, 15 Jul 2018 14:09:33 -0400 Subject: [PATCH 3/5] by default use MSD if MIP solver allows --- src/solver.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/solver.jl b/src/solver.jl index 75f7411..1940968 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -64,7 +64,7 @@ function PajaritoSolver(; timeout = Inf, rel_gap = 1e-5, - mip_solver_drives = false, + mip_solver_drives = nothing, mip_solver = UnsetSolver(), mip_subopt_solver = UnsetSolver(), mip_subopt_count = 0, @@ -113,6 +113,12 @@ function PajaritoSolver(; error("No MIP solver specified (set mip_solver)\n") end + if mip_solver_drives == nothing + mip_solver_drives = applicable(MathProgBase.setlazycallback!, MathProgBase.ConicModel(mip_solver), x -> x) + elseif mip_solver_drives && !applicable(MathProgBase.setlazycallback!, MathProgBase.ConicModel(mip_solver), x -> x) + error("MIP solver does not support callbacks (cannot set mip_solver_drives = true)") + end + if viol_cuts_only == nothing # If user has not set option, default is true on MSD and false on iterative viol_cuts_only = mip_solver_drives From 103ee680da81401b8d4ae46420bb9c21dda84539 Mon Sep 17 00:00:00 2001 From: Chris Coey Date: Sun, 15 Jul 2018 14:24:52 -0400 Subject: [PATCH 4/5] print MSD or iter --- examples/cardls.jl | 2 +- src/conic_algorithm.jl | 2 +- src/solver.jl | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/cardls.jl b/examples/cardls.jl index fe18e4b..c6b48c1 100644 --- a/examples/cardls.jl +++ b/examples/cardls.jl @@ -53,7 +53,7 @@ end Choose solvers and options =========================================================# -mip_solver_drives = false +mip_solver_drives = true rel_gap = 1e-5 diff --git a/src/conic_algorithm.jl b/src/conic_algorithm.jl index 07707aa..88eee39 100644 --- a/src/conic_algorithm.jl +++ b/src/conic_algorithm.jl @@ -645,7 +645,7 @@ function MathProgBase.optimize!(m::PajaritoConicModel) m.new_incumb = false m.cache_dual = Dict{Vector{Float64},Vector{Float64}}() - if m.log_level > 1 + if m.log_level >= 1 @printf "\nStarting %s algorithm\n" (m.mip_solver_drives ? "MIP-solver-driven" : "iterative") end status_oa = m.mip_solver_drives ? solve_mip_driven!(m) : solve_iterative!(m) diff --git a/src/solver.jl b/src/solver.jl index 1940968..7e26403 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -112,7 +112,6 @@ function PajaritoSolver(; if mip_solver == UnsetSolver() error("No MIP solver specified (set mip_solver)\n") end - if mip_solver_drives == nothing mip_solver_drives = applicable(MathProgBase.setlazycallback!, MathProgBase.ConicModel(mip_solver), x -> x) elseif mip_solver_drives && !applicable(MathProgBase.setlazycallback!, MathProgBase.ConicModel(mip_solver), x -> x) From c92d9f46c3d347eff8196ac3e72fc3f3a27297bb Mon Sep 17 00:00:00 2001 From: Chris Coey Date: Fri, 20 Jul 2018 16:59:08 -0400 Subject: [PATCH 5/5] ensure Pajarito MISOCP solvers use iterative --- test/conictest.jl | 2 +- test/runtests.jl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/conictest.jl b/test/conictest.jl index 80050cf..623b1a9 100644 --- a/test/conictest.jl +++ b/test/conictest.jl @@ -1063,7 +1063,7 @@ function run_sdpexp_misocp(mip_solver_drives, mip_solver, cont_solver, log_level testname = "SOC eig cuts (Dopt)" probname = "expsdp_optimalD" @testset "$testname" begin - solver = PajaritoSolver(timeout=120., mip_solver=mip_solver, cont_solver=cont_solver, log_level=log_level, sdp_eig=true, sdp_soc=true, prim_cut_feas_tol=1e-7, cut_zero_tol=1e-8) + solver = PajaritoSolver(timeout=120., mip_solver_drives=mip_solver_drives, mip_solver=mip_solver, cont_solver=cont_solver, log_level=log_level, sdp_eig=true, sdp_soc=true, prim_cut_feas_tol=1e-7, cut_zero_tol=1e-8) (status, time, objval, objbound, sol) = solve_cbf(testname, probname, solver, redirect) diff --git a/test/runtests.jl b/test/runtests.jl index 148d1a9..3e4c4c5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -32,25 +32,25 @@ tol_gap = 0.0 if glp solvers["MILP"]["GLPK"] = GLPKMathProgInterface.GLPKSolverMIP(msg_lev=GLPK.MSG_OFF, tol_int=tol_int, tol_bnd=tol_feas, mip_gap=tol_gap) if eco - solvers["MISOCP"]["Paj(GLPK+ECOS)"] = PajaritoSolver(mip_solver=GLPKMathProgInterface.GLPKSolverMIP(presolve=true, msg_lev=GLPK.MSG_OFF, tol_int=tol_int, tol_bnd=tol_feas/10, mip_gap=tol_gap), cont_solver=ECOS.ECOSSolver(verbose=false), log_level=0, rel_gap=1e-7) + solvers["MISOCP"]["Paj(GLPK+ECOS)"] = PajaritoSolver(mip_solver_drives=false, mip_solver=GLPKMathProgInterface.GLPKSolverMIP(presolve=true, msg_lev=GLPK.MSG_OFF, tol_int=tol_int, tol_bnd=tol_feas/10, mip_gap=tol_gap), cont_solver=ECOS.ECOSSolver(verbose=false), log_level=0, rel_gap=1e-7) end end if cpx solvers["MILP"]["CPLEX"] = solvers["MISOCP"]["CPLEX"] = CPLEX.CplexSolver(CPX_PARAM_SCRIND=0, CPX_PARAM_EPINT=tol_int, CPX_PARAM_EPRHS=tol_feas, CPX_PARAM_EPGAP=tol_gap) if mos - solvers["MISOCP"]["Paj(CPLEX+Mosek)"] = PajaritoSolver(mip_solver=CPLEX.CplexSolver(CPX_PARAM_SCRIND=0, CPX_PARAM_EPINT=tol_int, CPX_PARAM_EPRHS=tol_feas/10, CPX_PARAM_EPGAP=tol_gap), cont_solver=Mosek.MosekSolver(LOG=0), log_level=0, rel_gap=1e-7) + solvers["MISOCP"]["Paj(CPLEX+Mosek)"] = PajaritoSolver(mip_solver_drives=false, mip_solver=CPLEX.CplexSolver(CPX_PARAM_SCRIND=0, CPX_PARAM_EPINT=tol_int, CPX_PARAM_EPRHS=tol_feas/10, CPX_PARAM_EPGAP=tol_gap), cont_solver=Mosek.MosekSolver(LOG=0), log_level=0, rel_gap=1e-7) end end if grb solvers["MILP"]["Gurobi"] = solvers["MISOCP"]["Gurobi"] = Gurobi.GurobiSolver(OutputFlag=0, IntFeasTol=tol_int, FeasibilityTol=tol_feas, MIPGap=tol_gap) if mos - solvers["MISOCP"]["Paj(Gurobi+Mosek)"] = PajaritoSolver(mip_solver=Gurobi.GurobiSolver(OutputFlag=0, IntFeasTol=tol_int, FeasibilityTol=tol_feas/10., MIPGap=tol_gap), cont_solver=Mosek.MosekSolver(LOG=0), log_level=0, rel_gap=1e-7) + solvers["MISOCP"]["Paj(Gurobi+Mosek)"] = PajaritoSolver(mip_solver_drives=false, mip_solver=Gurobi.GurobiSolver(OutputFlag=0, IntFeasTol=tol_int, FeasibilityTol=tol_feas/10., MIPGap=tol_gap), cont_solver=Mosek.MosekSolver(LOG=0), log_level=0, rel_gap=1e-7) end end #if cbc # solvers["MILP"]["CBC"] = Cbc.CbcSolver(logLevel=0, integerTolerance=tol_int, primalTolerance=tol_feas, ratioGap=tol_gap, check_warmstart=false) # if eco -# solvers["MISOCP"]["Paj(CBC+ECOS)"] = PajaritoSolver(mip_solver=Cbc.CbcSolver(logLevel=0, integerTolerance=tol_int, primalTolerance=tol_feas/10, ratioGap=tol_gap, check_warmstart=false), cont_solver=ECOS.ECOSSolver(verbose=false), log_level=0, rel_gap=1e-6) +# solvers["MISOCP"]["Paj(CBC+ECOS)"] = PajaritoSolver(mip_solver_drives=false, mip_solver=Cbc.CbcSolver(logLevel=0, integerTolerance=tol_int, primalTolerance=tol_feas/10, ratioGap=tol_gap, check_warmstart=false), cont_solver=ECOS.ECOSSolver(verbose=false), log_level=0, rel_gap=1e-6) # end #end # if try_import(:SCIP)