Julia wrapper for the ECOS embeddable conic optimization interior point solver.
You can install ECOS.jl through the Julia package manager:
ECOS.jl will automatically install and setup the ECOS solver itself using BinaryProvider.jl.
After ECOS.jl is installed and built, you can replace the installed binary dependencies with custom builds by overwritting the binaries and libraries in ECOS.jl's
deps/usr folder (e.g. in Julia v0.6
Note that the custom binaries will not be overwritten by subsequent builds of the currently installed version of ECOS.jl. However, if ECOS.jl is updated and the update includes new BinaryProvider versions of the ECOS binaries, then the custom binaries will be overwritten by the new BinaryProvider versions.
The ECOS interface is completely wrapped. ECOS functions corresponding to the C API are available as
ECOS.ver (these are not exported from the module). Function arguments are extensively documented in the source, and an example of usage can be found in
All ECOS solver options can be set through the direct interface and through MathOptInterface.
The list of options is defined the
ecos.h header, which we reproduce here:
gamma # scaling the final step length delta # regularization parameter eps # regularization threshold feastol # primal/dual infeasibility tolerance abstol # absolute tolerance on duality gap reltol # relative tolerance on duality gap feastol_inacc # primal/dual infeasibility relaxed tolerance abstol_inacc # absolute relaxed tolerance on duality gap reltol_inacc # relative relaxed tolerance on duality gap nitref # number of iterative refinement steps maxit # maximum number of iterations verbose # verbosity bool for PRINTLEVEL < 3
To use these settings you can either pass them as keyword arguments to
(direct interface) or as arguments to the
(MathOptInterface interface), e.g.
# Direct my_prob = ECOS.setup(n, m, ..., c, h, b; maxit=10, feastol=1e-5) # MathOptInterface (with JuMP) model = Model(with_optimizer(ECOS.Optimizer, maxit=10, feastol=1e-5))
This example shows how we can model a simple knapsack problem with JuMP and use ECOS to solve it.
using JuMP using ECOS items = [:Gold, :Silver, :Bronze] values = Dict(:Gold => 5.0, :Silver => 3.0, :Bronze => 1.0) weight = Dict(:Gold => 2.0, :Silver => 1.5, :Bronze => 0.3) model = Model(with_optimizer(ECOS.Optimizer)) @variable(model, 0 <= take[items] <= 1) # Define a variable for each item @objective(model, Max, sum(values[item] * take[item] for item in items)) @constraint(model, sum(weight[item] * take[item] for item in items) <= 3) optimize!(model) println(value(take)) # take # [ Gold] = 0.9999999680446406 # [Silver] = 0.46666670881026834 # [Bronze] = 0.9999999633898735
ECOS.jl is licensed under the MIT License (see LICENSE.md), but note that ECOS itself is GPL v3.