Skip to main content

A Python interface to OPL.

Project description

Welcome to the IBM® OPL connector for Python. Licensed under the Apache License v2.0.

With this library, you can quickly and easily add the power of optimization to your Python application. You can model your problems by using the OPL language and IDE, and integrate it in Python via Python/pandas/sql alchemy inputs/outputs.

Solving with CPLEX requires that IBM® ILOG CPLEX Optimization Studio V12.8.0 is installed on your machine.

Install the library

pip install doopl

Get the examples

Get your IBM® ILOG CPLEX Optimization Studio edition

  • You can get a free Community Edition of CPLEX Optimization Studio, with limited solving capabilities in term of problem size.

  • Faculty members, research professionals at accredited institutions can get access to an unlimited version of CPLEX through the IBM® Academic Initiative.

License

This library is delivered under the Apache License Version 2.0, January 2004 (see LICENSE.txt).

Starting point

The API is very compact and simple. You must have the OPL binaries in your PATH/LD_LIBRARY_PATH or DYLD_LIBRARY_PATH, depending on your platform. They are located in <cplex_studio_dir>/opl/bin/<platform> where:

  • cplex_studio_dir is the installation directory of CPLEX 12.8

  • platform is your plaform (OPL nomenclature, that is x64_win64, x86-64_linux or x86-64_osx)

Here is small sumup of the capabilities:

  • Inputs can be tuple lists, panda’s dataframe, sql alchemy fetch statements.

  • Generate, solve and get output tuplesets as panda’s dataframe

  • Get the CPLEX problem statistics and quality metrics for the solution

  • Convert all integer variables to floating point variables and vice-versa.

  • Run the conflict/relaxation mechanism.

  • Call the ‘RunSeed’ diagnosis for CPLEX/CPO based problems.

Each of these features are demonstrated with simple examples.

Here is a small example to start working with the API:

from doopl.factory import *

# Create an OPL model from a .mod file
with create_opl_model(model="file.mod") as opl:
    # tuple can be a list of tuples, a pandas dataframe...
    opl.set_input("TupleSet1", tuples)

    # Generate the problem and solve it.
    opl.run()

    # Get the names of post processing tables
    print("Table names are: "+ str(opl.output_table_names))

    # Get all the post processing tables as dataframes.
    for name, table in iteritems(opl.report):
        print("Table : " + name)
        for t in table.itertuples(index=False):
            print(t)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

doopl-12.8.0.8-cp37-cp37m-win_amd64.whl (7.7 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

doopl-12.8.0.8-cp37-cp37m-manylinux1_x86_64.whl (98.2 kB view hashes)

Uploaded CPython 3.7m

doopl-12.8.0.8-cp37-cp37m-macosx_10_6_x86_64.whl (97.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.6+ x86-64

doopl-12.8.0.8-cp36-cp36m-win_amd64.whl (7.7 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

doopl-12.8.0.8-cp36-cp36m-manylinux1_x86_64.whl (98.2 kB view hashes)

Uploaded CPython 3.6m

doopl-12.8.0.8-cp36-cp36m-macosx_10_6_x86_64.whl (97.9 kB view hashes)

Uploaded CPython 3.6m macOS 10.6+ x86-64

doopl-12.8.0.8-cp35-cp35m-win_amd64.whl (7.7 MB view hashes)

Uploaded CPython 3.5m Windows x86-64

doopl-12.8.0.8-cp35-cp35m-manylinux1_x86_64.whl (98.2 kB view hashes)

Uploaded CPython 3.5m

doopl-12.8.0.8-cp35-cp35m-macosx_10_6_x86_64.whl (97.9 kB view hashes)

Uploaded CPython 3.5m macOS 10.6+ x86-64

doopl-12.8.0.8-cp27-cp27mu-manylinux1_x86_64.whl (98.4 kB view hashes)

Uploaded CPython 2.7mu

doopl-12.8.0.8-cp27-cp27m-win_amd64.whl (7.7 MB view hashes)

Uploaded CPython 2.7m Windows x86-64

doopl-12.8.0.8-cp27-cp27m-manylinux1_x86_64.whl (98.4 kB view hashes)

Uploaded CPython 2.7m

doopl-12.8.0.8-cp27-cp27m-macosx_10_6_x86_64.whl (98.3 kB view hashes)

Uploaded CPython 2.7m macOS 10.6+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page