Coder Social home page Coder Social logo

cplexw's Introduction

CPLEXW.jl

This package contains an unofficial low-level Julia wrapper for IBM® ILOG® CPLEX® Optimization Studio, automatically generated from the official C headers using Clang.jl. Unlike CPLEX.jl, this wrapper allows access to all advanced CPLEX routines. However, it does not currently implement MathOptInterface or MathProgBase and therefore does not completely replace CPLEX.jl.

Disclaimer: You cannot use CPLEXW.jl without having purchased and installed a copy of CPLEX Optimization Studio from IBM. This wrapper is maintained by the JuliaOpt community, and is not officially developed or supported by IBM.

Installation

Please follow the same install instructions from CPLEX.jl, but instead of running Pkg.add("CPLEX"), run the following command instead:

Pkg.add("https://github.com/iSoron/CPLEXW.git")

Usage

The following example shows how can the package be used in standalone mode. After including CPLEXW, all standard CPLEX constants and functions (C API) become available to Julia. For a complete description of the available functions, please refer to the official CPLEX documentation. Julia's manual page on how to call C functions may also be helpful.

using CPLEXW

# Create CPLEX environment
rval = [Cint(0)]
env = CPXopenCPLEX(rval)

# Change some parameters
CPXsetintparam(env, CPX_PARAM_SCRIND, CPX_ON) # Print to the screen
CPXsetdblparam(env, CPX_PARAM_TILIM, 30)      # Time limit in seconds

# Create, populate and solve a problem
lp = CPXcreateprob(env, rval, "problem")
CPXreadcopyprob(env, lp, "myinstance.mps.gz", "mps")
CPXmipopt(env, lp)

Usage with JuMP and CPLEX.jl

This package can also be used when you already have a JuMP optimization model (solved with CPLEX), but you need access to some advanced routines which are not available through CPLEX.jl. The next example illustrates this scenario:

using JuMP, CPLEX, CPLEXW

# Create JuMP + CPLEX.jl model
model = direct_model(CPLEX.Optimizer())
@variable(model, x >= 0)
@objective(model, Min, x)
optimize!(model)

# Call low-level CPLEX function
cpx = backend(model).inner
CPXgetnumnz(cpx.env, cpx.lp)

Regenerating wrappers

To regenerate the wrappers, run the script gen/generate.jl. The environment variable CPLEX_INCLUDE_DIR must be defined, and must point to the directory containing the header files. For example, if CPLEX is installed at /opt/cplex-12.8, the variable should be set to /opt/cplex-12.8/cplex/include/ilcplex/. If successful, the script will generate several files in the directory gen/output. Only the files commons.jl and cplex.jl are currently used.

cplexw's People

Contributors

isoron avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

xiaoyi-gu

cplexw's Issues

Think about how to merge into CPLEX.jl

It'd be nice to merge this into the main body of CPLEX.jl, along with the script to regenerate things.

We'd probably want things a little more user-friendly, so if you had any ideas, please share.

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.