Solvers
Convex.jl transforms each problem into an equivalent cone program in order to pass the problem to a specialized solver. Depending on the types of functions used in the problem, the conic constraints may include linear, second-order, exponential, or semidefinite constraints, as well as any binary or integer constraints placed on the variables.
By default, Convex.jl does not install any solvers. Many users use the solver SCS, which is able to solve problems with linear, second-order cone constraints (SOCPs), exponential constraints and semidefinite constraints (SDPs). Likewise, COSMO is a pure-Julia solver which can handle every cone that Convex.jl itself supports. Any other solver in JuliaOpt may also be used, so long as it supports the conic constraints used to represent the problem. Many other solvers in the JuliaOpt ecosystem can be used to solve (mixed integer) linear programs (LPs and MILPs). Mosek and Gurobi can be used to solve SOCPs (even with binary or integer constraints), and Mosek can also solve SDPs. For up-to-date information about solver capabilities, please see the table here describing which solvers can solve which kind of problems. See also ConvexTests.jl to see the results of running test problems with Convex.jl for many solvers.
Installing these solvers is very simple. Just follow the instructions in the documentation for that solver.
To use a specific solver, you can use the following syntax
solve!(p, Gurobi.Optimizer)
solve!(p, Mosek.Optimizer)
solve!(p, GLPK.Optimizer)
solve!(p, ECOS.Optimizer)
solve!(p, SCS.Optimizer)
(Of course, the solver must be installed first.) For example, we can use GLPK to solve a MILP
using GLPK
solve!(p, GLPK.Optimizer)
Many of the solvers also allow options to be passed in. More details can be found in each solver's documentation.
For example, if we wish to turn off printing for the SCS solver (ie, run in quiet mode), we can do so by
using SCS
opt = () -> SCS.Optimizer(verbose=false)
solve!(p, opt)
or equivalently,
solve!(p, () -> SCS.Optimizer(verbose=false))
If we wish to increase the maximum number of iterations for ECOS or SCS, we can do so by
using ECOS
solve!(p, () -> ECOS.Optimizer(maxit=10000))
using SCS
solve!(p, () -> SCS.Optimizer(max_iters=10000))
To turn off the problem status warning issued by Convex when a solver is not able to solve a problem to optimality, use the keyword argument verbose=false
of the solve method, along with any desired solver parameters:
solve!(p, () -> SCS.Optimizer(verbose=false), verbose=false)