Giter VIP home page Giter VIP logo

ecos.jl's Introduction

ECOS.jl

Julia wrapper for the ECOS embeddable conic optimization interior point solver.

Build Status codecov

Installation

You can install ECOS.jl through the Julia package manager:

julia> Pkg.add("ECOS")

ECOS.jl will automatically install and setup the ECOS solver itself using BinaryProvider.jl.

Custom Installation

After ECOS.jl is installed and built, you can replace the installed libecos dependency with a custom installation by following the Pkg documentation for overriding artifacts. Note that your custom libecos is required to be at least version 2.0.5.

Usage

The ECOS interface is completely wrapped. ECOS functions corresponding to the C API are available as ECOS.setup, ECOS.solve, ECOS.cleanup, and 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 test/direct.jl.

ECOS.jl also supports the MathOptInterface standard solver interface. Thanks to this support ECOS can be used as a solver with both the JuMP and Convex.jl modeling languages.

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 setup (direct interface) or as arguments to the ECOS.Optimizer constructor (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))

JuMP example

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.

ecos.jl's People

Contributors

blegat avatar femtocleaner[bot] avatar iainnz avatar iamed2 avatar jfsantos avatar joehuchette avatar juan-pablo-vielma avatar juliatagbot avatar karanveerm avatar mlubin avatar odow avatar omus avatar r-barnes avatar ranjanan avatar shadiakiki1986 avatar staticfloat avatar tkelman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.