CyLP is a Python interface to COIN-OR’s Linear and mixed-integer program solvers (CLP, CBC, and CGL)

Related tags

Machine LearningCyLP
Overview

CyLP

CyLP is a Python interface to COIN-OR’s Linear and mixed-integer program solvers (CLP, CBC, and CGL). CyLP’s unique feature is that you can use it to alter the solution process of the solvers from within Python. For example, you may define cut generators, branch-and-bound strategies, and primal/dual Simplex pivot rules completely in Python.

You may read your LP from an mps file or use the CyLP’s easy modeling facility. Please find examples in the documentation.

Docker

If you're comfortable with Docker, you can get started right away with the container available on Dockerhub that comes with CyLP pre-installed.

https://hub.docker.com/repository/docker/coinor/cylp

Otherwise, read on.

Prerequisites

CyLP depends on Numpy (www.numpy.org) and Scipy (www.scipy.org). Please note that Numpy does need to be installed prior to installing CyLP, even though it is listed as a dependency in the setup.py file.

You will also need to install binaries for Cbc. The version should be 2.10 (recommended) or earlier (current master branch of Cbc will not work with this version of CyLP). You can install Cbc by either by installing with a package manager, by downloading pre-built binaries, or by building yourself from source using coinbrew.

  1. To install Cbc in Linux, the easiest way is to use a package manager. Install coinor-libcbc-dev on Ubuntu/Debian or coin-or-Cbc-devel on Fedora. Cbc is also available on Linux through conda with

    $ conda create -n cbc coin-or-cbc -c conda-forge

  2. On OS X, it is easiest to install Cbc with homebrew:

    $ brew tap coin-or-tools/coinor

    $ brew install coin-or-tools/coinor/cbc pkg-config

    Cbc is also available on OS X through conda with

    $ conda create -n cbc coin-or-cbc -c conda-forge

  3. On Windows, a binary wheel is available and it is not necessary to install Cbc.

You should no longer need to build Cbc from source on any platform unless for some reason, none of the above recipes applies to you. If you do need to build from source, please go to the Cbc project page and follow the instructions there. After building and installing, make sure to either set the COIN_INSTALL_DIR variable to point to the installation or set PKG_CONFIG_PATH to point to the directory where the .pc files are installed. You may also need to set either LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (OS X).

Installation

If you are building against the coin-or-cbc package installed by conda, be sure to conda install pkg-config, which is needed to find he Cbc libraries installed by conda. Once Numpy and Cbc are installed, simply do:

$ pip install cylp
Optional step:

If you want to run the doctests (i.e. make doctest in the doc directory) you should also define:

$ export CYLP_SOURCE_DIR=/Path/to/cylp

Now you can use CyLP in your python code. For example:

>>> from cylp.cy import CyClpSimplex
>>> s = CyClpSimplex()
>>> s.readMps('../input/netlib/adlittle.mps')
0
>>> s.initialSolve()
'optimal'
>>> round(s.objectiveValue, 3)
225494.963

Or simply go to CyLP and run:

$ python -m unittest discover

to run all CyLP unit tests.

Modeling Example

Here is an example of how to model with CyLP's modeling facility:

import numpy as np
from cylp.cy import CyClpSimplex
from cylp.py.modeling.CyLPModel import CyLPArray

s = CyClpSimplex()

# Add variables
x = s.addVariable('x', 3)
y = s.addVariable('y', 2)

# Create coefficients and bounds
A = np.matrix([[1., 2., 0],[1., 0, 1.]])
B = np.matrix([[1., 0, 0], [0, 0, 1.]])
D = np.matrix([[1., 2.],[0, 1]])
a = CyLPArray([5, 2.5])
b = CyLPArray([4.2, 3])
x_u= CyLPArray([2., 3.5])

# Add constraints
s += A * x <= a
s += 2 <= B * x + D * y <= b
s += y >= 0
s += 1.1 <= x[1:3] <= x_u

# Set the objective function
c = CyLPArray([1., -2., 3.])
s.objective = c * x + 2 * y.sum()

# Solve using primal Simplex
s.primal()
print s.primalVariableSolution['x']

This is the expected output:

Clp0006I 0  Obj 1.1 Primal inf 2.8999998 (2) Dual inf 5.01e+10 (5) w.o. free dual inf (4)
Clp0006I 5  Obj 1.3
Clp0000I Optimal - objective value 1.3
[ 0.2  2.   1.1]

Documentation

You may access CyLP's documentation:

  1. Online : Please visit http://coin-or.github.io/CyLP/
  2. Offline : To install CyLP's documentation in your repository, you need Sphinx (http://sphinx-doc.org/). You can generate the documentation by going to cylp/doc and run make html or make latex and access the documentation under cylp/doc/build. You can also run make doctest to perform all the doctest.

Who uses CyLP

CyLP is being used in a wide range of practical and research fields. Some of the users include:

  1. PyArt, The Python ARM Radar Toolkit, used by Atmospheric Radiation Measurement (U.S. Department of energy). https://github.com/ARM-DOE/pyart
  2. Meteorological Institute University of Bonn.
  3. Sherbrooke university hospital (Centre hospitalier universitaire de Sherbrooke): CyLP is used for nurse scheduling.
  4. Maisonneuve-Rosemont hospital (L'hôpital HMR): CyLP is used for physician scheduling with preferences.
  5. Lehigh University: CyLP is used to teach mixed-integer cuts.
  6. IBM T. J. Watson research center
  7. Saarland University, Germany
Comments
  • Python 3 support for CyLP

    Python 3 support for CyLP

    • Changes needed for CyLP to work in Python 3.4.
    • A single code base is used which supports Python 2.7, 3.3, and 3.4.
    • Unit test pass in all of the above Python version.

    closes #15

    opened by jjhelmus 37
  • ModuleNotFoundError: No module named 'cylp.cy.CyCoinIndexedVector'

    ModuleNotFoundError: No module named 'cylp.cy.CyCoinIndexedVector'

    After cloned CyLP master branch, and locally installed to virtualenv via python setup.py install,

    When running with code: cy_solver = CyClpSimplex() cy_solver.readMps(TEST_FILE)

    The following exception is thrown: File "/Users/shuohuang/Projects/CyLP/cylp/cy/__init__.py", line 1, in <module> from .CyCoinIndexedVector import CyCoinIndexedVector ModuleNotFoundError: No module named 'cylp.cy.CyCoinIndexedVector'

    bug information 
    opened by fuxiocteract 19
  • Compile issue - 'PyThreadState'

    Compile issue - 'PyThreadState'

    Hi,

    I've compiled CyLP before without any issues but just ran into a problem with Python 3.7 I'm using coincbc-2.10.2 (conda forge), python 3.7.3, numpy 1.16.4, gcc 9.1.0 and cython 0.29.11. Also the COIN_INSTALL_DIR has been correctly set.

    I've seen similar errors from PyThreadState reported for pandas and numpy link

    Hope you can help!

    Here's the error stack.

    n0/jss548/miniconda3/envs/radar-dev/lib/python3.7/site-packages/numpy/core/include -I. -I/g/data/en0/jss548/miniconda3/envs/radar-dev/include/python3.7m -c cylp/cy/CyCbcModel.cpp -o build/temp.linux-x86_64-3.7/cylp/cy/CyCbcModel.o -w cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++ cylp/cy/CyCbcModel.cpp: In function 'void __Pyx_ExceptionSave(PyObject**, PyObject**, PyObject**)': cylp/cy/CyCbcModel.cpp:10528:21: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_type'; did you mean 'curexc_type'? 10528 | type = tstate->exc_type; | ^~~~~~~~ | curexc_type cylp/cy/CyCbcModel.cpp:10529:22: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_value'; did you mean 'curexc_value'? 10529 | value = tstate->exc_value; | ^~~~~~~~~ | curexc_value cylp/cy/CyCbcModel.cpp:10530:19: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_traceback'; did you mean 'curexc_traceback'? 10530 | tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback cylp/cy/CyCbcModel.cpp: In function 'void __Pyx_ExceptionReset(PyObject, PyObject, PyObject)': cylp/cy/CyCbcModel.cpp:10542:24: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_type'; did you mean 'curexc_type'? 10542 | tmp_type = tstate->exc_type; | ^~~~~~~~ | curexc_type cylp/cy/CyCbcModel.cpp:10543:25: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_value'; did you mean 'curexc_value'? 10543 | tmp_value = tstate->exc_value; | ^~~~~~~~~ | curexc_value cylp/cy/CyCbcModel.cpp:10544:22: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_traceback'; did you mean 'curexc_traceback'? 10544 | tmp_tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback cylp/cy/CyCbcModel.cpp:10545:13: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_type'; did you mean 'curexc_type'? 10545 | tstate->exc_type = type; | ^~~~~~~~ | curexc_type cylp/cy/CyCbcModel.cpp:10546:13: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_value'; did you mean 'curexc_value'? 10546 | tstate->exc_value = value; | ^~~~~~~~~ | curexc_value cylp/cy/CyCbcModel.cpp:10547:13: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_traceback'; did you mean 'curexc_traceback'? 10547 | tstate->exc_traceback = tb; | ^~~~~~~~~~~~~ | curexc_traceback cylp/cy/CyCbcModel.cpp: In function 'int __Pyx_GetException(PyObject**, PyObject**, PyObject**)': cylp/cy/CyCbcModel.cpp:10590:24: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_type'; did you mean 'curexc_type'? 10590 | tmp_type = tstate->exc_type; | ^~~~~~~~ | curexc_type cylp/cy/CyCbcModel.cpp:10591:25: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_value'; did you mean 'curexc_value'? 10591 | tmp_value = tstate->exc_value; | ^~~~~~~~~ | curexc_value cylp/cy/CyCbcModel.cpp:10592:22: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_traceback'; did you mean 'curexc_traceback'? 10592 | tmp_tb = tstate->exc_traceback; | ^~~~~~~~~~~~~ | curexc_traceback cylp/cy/CyCbcModel.cpp:10593:13: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_type'; did you mean 'curexc_type'? 10593 | tstate->exc_type = local_type; | ^~~~~~~~ | curexc_type cylp/cy/CyCbcModel.cpp:10594:13: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_value'; did you mean 'curexc_value'? 10594 | tstate->exc_value = local_value; | ^~~~~~~~~ | curexc_value cylp/cy/CyCbcModel.cpp:10595:13: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'exc_traceback'; did you mean 'curexc_traceback'? 10595 | tstate->exc_traceback = local_tb; | ^~~~~~~~~~~~~ | curexc_traceback error: command '/apps/gcc/9.1.0/bin/gcc' failed with exit status 1 ---------------------------------------- ERROR: Command "/g/data/en0/jss548/miniconda3/envs/radar-dev/bin/python -u -c 'import setuptools, tokenize;file='"'"'/short/en0/jss548/tmp/pip-install-b93fks8q/cylp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /short/en0/jss548/tmp/pip-record-4bnpy7e2/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /short/en0/jss548/tmp/pip-install-b93fks8q/cylp/

    bug question 
    opened by joshua-wx 18
  • error during pip install of cylp, os environ COIN_INSTALL_DIR not set with apt install of coin

    error during pip install of cylp, os environ COIN_INSTALL_DIR not set with apt install of coin

    I installed COIN using sudo apt-get install coinor-cbc on an ubuntu machine. (Which is the suggested method of installation on the official coin page).

    Now when I try to install cylp using pip, I get the following error:

    Collecting cylp
      Using cached cylp-0.2.3.6.tar.gz
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-build-setUG3/cylp/setup.py", line 44, in <module>
            'to the location of the COIN installation')
        Exception: Please set the environment variable COIN_INSTALL_DIR to the location of the COIN installation
    
        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-setUG3/cylp/
    
    

    What should COIN_INSTALL_DIR be set to if I installed coin through apt? I have no idea where the location of my COIN installation is. How do I find out?

    Ideally this error message should say something like:

    Please set the environment variable COIN_INSTALL_DIR to the location of the COIN installation. If you installed COIN through your package manager, this is probably /whateverTheDirIs
    

    I don't know why this environment variable wasn't permanantly set upon install of COIN. I did logout and log back in to refresh the environment. That didn't fix it.

    opened by matt-telstra 18
  • pip installation fails on Windows

    pip installation fails on Windows

    According to the README, CyLP should be installable via pip install cylp, with numpy mentioned as a requirement. The README specifically says: On Windows, installing will download a binary wheel that includes Cbc (no additional steps required). However, when I do the following on my Windows 10 machine with Anaconda:

    conda create -n coin python numpy scipy
    conda activate coin
    pip install cylp
    

    I get this long error message:

        ERROR: Command errored out with exit status 1:
         command: 'C:\Users\mkaut\AppData\Local\Continuum\anaconda3\envs\coin\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\mkaut\\AppData\\Local\\Temp\\pip-install-__v7_3xr\\cylp\\setup.py'"'"'; __file__='"'"'C:\\Users\\mkaut\\AppData\\Local\\Temp\\pip-install-__v7_3xr\\cylp\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\mkaut\AppData\Local\Temp\pip-install-__v7_3xr\cylp\pip-egg-info'
             cwd: C:\Users\mkaut\AppData\Local\Temp\pip-install-__v7_3xr\cylp\
        Complete output (35 lines):
        Traceback (most recent call last):
          File "C:\Users\mkaut\AppData\Local\Temp\pip-install-__v7_3xr\cylp\setup.py", line 52, in get_libs
            flags = (check_output(['pkg-config', '--libs', 'cbc'])
          File "C:\Users\mkaut\AppData\Local\Continuum\anaconda3\envs\coin\lib\subprocess.py", line 411, in check_output
            return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
          File "C:\Users\mkaut\AppData\Local\Continuum\anaconda3\envs\coin\lib\subprocess.py", line 489, in run
            with Popen(*popenargs, **kwargs) as process:
          File "C:\Users\mkaut\AppData\Local\Continuum\anaconda3\envs\coin\lib\subprocess.py", line 854, in __init__
            self._execute_child(args, executable, preexec_fn, close_fds,
          File "C:\Users\mkaut\AppData\Local\Continuum\anaconda3\envs\coin\lib\subprocess.py", line 1307, in _execute_child
            hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
        FileNotFoundError: [WinError 2] The system cannot find the file specified
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
          File "C:\Users\mkaut\AppData\Local\Temp\pip-install-__v7_3xr\cylp\setup.py", line 61, in get_libs
            with open(join(CoinDir, 'share', 'coin',
        NameError: name 'CoinDir' is not defined
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "C:\Users\mkaut\AppData\Local\Temp\pip-install-__v7_3xr\cylp\setup.py", line 100, in <module>
            libs, libDirs, incDirs = get_libs()
          File "C:\Users\mkaut\AppData\Local\Temp\pip-install-__v7_3xr\cylp\setup.py", line 75, in get_libs
            raise Exception('''
        Exception:
                    Could not automatically find location of COIN installation.
                    If an error occus, please ensure that either COIN_INSTALL_DIR
                    is set to the location of the installation or PKG_CONFIG_PATH
                    points to the location of the .pc files.
    
        Warning: Could not automatically find COIN installation
        ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    

    Is this a bug, or have I missed something? I see that it is missing COIN, but the README says that this should be downloaded automatically...

    opened by mkaut 13
  • problem at getting started

    problem at getting started

    Hi, here is what get when running : >>>from cylp.cy import CyClpSimplex

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
     File "cylp/cy/__init__.py", line 1, in <module>
      from CyCoinIndexedVector import CyCoinIndexedVector
     ImportError: No module named CyCoinIndexedVector
    

    cannot figure out why getting this message!

    opened by posseidon23 12
  • Unit tests fail on OS X 10.9 (Mavericks) with CBC 2.8.8

    Unit tests fail on OS X 10.9 (Mavericks) with CBC 2.8.8

    On a machine running Mac OS X 10.9 (Mavericks), using Python 2.7.6 provided by Anaconda 1.8.0.

    CBC version 2.8.8 was built using the defaults:

    ./configure
    make
    make install
    

    CyLP builds fine but the unit tests fail as follows:

    ~/python/CyLP$ nosetests -v
    test_Obj1 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_bound1 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_bound2 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_bound3 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_bound4 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_constraint_1 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_constraint_single1 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_constraint_single2 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_constraint_single3 (cylp.py.modeling.test_modeling.TestModeling) ... ok
    test_removeConst (cylp.py.modeling.test_modeling.TestModeling) ... python(76203,0x7fff7db6d310) malloc: *** error for object 0x101deccf8: incorrect checksum for freed object - object was probably modified after being freed.
    *** set a breakpoint in malloc_error_break to debug
    

    Trying to use the CyClpSimplex object in Python code from the above build leads to either a malloc error as in above, or a segmentation fault.

    Doing some debugging it looks like the CBC libraries are linked to libc++ (The clang C++ standard library that is the default in 10.9), where as the CyLP shared libraries are linked against libstdc++ (The GCC library). Unfortunately these two libraries are not ABI compatible which is what I think is leading to the memory errors.

    ~/code/Cbc/Cbc-2.8.8$ otool -L lib/libCbc.3.dylib
    lib/libCbc.3.dylib:
        /Users/jhelmus/code/Cbc/Cbc-2.8.8/lib/libCbc.3.dylib (compatibility version 12.0.0, current version 12.8.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    
    ~/python/CyLP$ otool -L cylp/cy/CyClpSimplex.so
    cylp/cy/CyClpSimplex.so:
        /Users/jhelmus/code/Cbc/Cbc-2.8.8/lib/libCbcSolver.3.dylib (compatibility version 12.0.0, current version 12.8.0)
        /Users/jhelmus/code/Cbc/Cbc-2.8.8/lib/libCbc.3.dylib (compatibility version 12.0.0, current version 12.8.0)
        /Users/jhelmus/code/Cbc/Cbc-2.8.8/lib/libCgl.1.dylib (compatibility version 10.0.0, current version 10.5.0)
        /Users/jhelmus/code/Cbc/Cbc-2.8.8/lib/libOsiClp.1.dylib (compatibility version 14.0.0, current version 14.6.0)
        /Users/jhelmus/code/Cbc/Cbc-2.8.8/lib/libClp.1.dylib (compatibility version 14.0.0, current version 14.6.0)
        /Users/jhelmus/code/Cbc/Cbc-2.8.8/lib/libOsi.1.dylib (compatibility version 13.0.0, current version 13.5.0)
        /Users/jhelmus/code/Cbc/Cbc-2.8.8/lib/libCoinUtils.3.dylib (compatibility version 13.0.0, current version 13.11.0)
        /usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
        libz.1.dylib (compatibility version 1.0.0, current version 1.2.7)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
        /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 60.0.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 2577.0.0)
    

    I tried to force CyLP to link against the libc++ libraries but ran into issue

    ~/python/CyLP$ export LDFLAGS="-stdlib=libc++"
    ~/python/CyLP$ export MACOSX_DEPLOYMENT_TARGET=10.9
    ~/python/CyLP$ python setup.py build_ext -i
    running build_ext
    building 'cylp.cy.CyClpPrimalColumnPivotBase' extension
    creating build
    creating build/temp.macosx-10.5-x86_64-2.7
    creating build/temp.macosx-10.5-x86_64-2.7/cylp
    creating build/temp.macosx-10.5-x86_64-2.7/cylp/cpp
    creating build/temp.macosx-10.5-x86_64-2.7/cylp/cy
    ...
    gcc -fno-strict-aliasing -I/Users/jhelmus/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I./cylp/cpp -I./cylp/cy -I/Users/jhelmus/code/Cbc/Cbc-2.8.8/include/coin -I/Users/jhelmus/anaconda/lib/python2.7/site-packages/numpy/core/include -I. -I/Users/jhelmus/anaconda/include/python2.7 -c cylp/cy/CyClpDualRowPivotBase.cpp -o build/temp.macosx-10.5-x86_64-2.7/cylp/cy/CyClpDualRowPivotBase.o -w
    cylp/cy/CyClpDualRowPivotBase.cpp:5852:13: error: call to 'isspace' is ambiguous
            if (isspace(*ts))
                ^~~~~~~
    /usr/include/ctype.h:267:1: note: candidate function
    isspace(int _c)
    ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cctype:124:38: note:
          candidate function
    inline _LIBCPP_INLINE_VISIBILITY int isspace(int __c) {return __libcpp_i...
                                         ^
    1 error generated.
    error: command 'gcc' failed with exit status 1
    

    This seems to be the problem that PR #8 tries to address but I never was able to get the customInstall class to run the fixes.

    The work-around I have been using for the time is add the necessary flags when building CBC so that the libraries link against libstdc++.

    ./configure 'ADD_CXXFLAGS=-stdlib=libstdc++' 'LDFLAGS=-stdlib=libstdc++'
    make
    make install
    

    When built with the above, CyLP passes all tests, but oddly the CBC libraries still are linked to libc++ when checked with otool.

    I did not run into this issue on OS X 10.8, but no longer have access to a machine running that version to test on.

    opened by jjhelmus 11
  • Error when installing CyLP: no member named 'f_tstate' in '_frame'

    Error when installing CyLP: no member named 'f_tstate' in '_frame'

    Hi,

    I've been trying to install CyLP on my mac and when I run python setup.py install I get the error pasted below. Do you know how to get around this error? I found this link: https://github.com/scikit-learn/scikit-learn/issues/3114 and ran pip install cython https://github.com/scikit-learn/scikit-learn/archive/master.zip as the suggested workaround, but that didn't seem to make any difference and I still get the same error. Is there another way I can get around this?

    Thanks!


    Last login: Sun Mar 27 16:57:54 on ttys001 Kathleen-Szabos-MacBook-Pro:~ admin$ ls Applications Movies anaconda Desktop Music eclipse Documents Pictures setuptools-20.3.1.zip Downloads Public Library Sites Kathleen-Szabos-MacBook-Pro:~ admin$ cd Downloads/ Kathleen-Szabos-MacBook-Pro:Downloads admin$ cd CyLP-master Kathleen-Szabos-MacBook-Pro:CyLP-master admin$ python setup.py install Traceback (most recent call last): File "setup.py", line 40, in CoinDir = os.environ['COIN_INSTALL_DIR'] File "/Users/admin/anaconda/lib/python3.5/os.py", line 683, in getitem raise KeyError(key) from None KeyError: 'COIN_INSTALL_DIR'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "setup.py", line 46, in location = dirname(check_output(['which', 'clp']).strip()) File "/Users/admin/anaconda/lib/python3.5/subprocess.py", line 629, in check_output **kwargs).stdout File "/Users/admin/anaconda/lib/python3.5/subprocess.py", line 711, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['which', 'clp']' returned non-zero exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "setup.py", line 49, in raise Exception('Please set the environment variable COIN_INSTALL_DIR' Exception: Please set the environment variable COIN_INSTALL_DIR to the location of the COIN installation Kathleen-Szabos-MacBook-Pro:CyLP-master admin$ export COIN_INSTALL_DIR=/Users/admin/Downloads/Cbc-2.9.8 Kathleen-Szabos-MacBook-Pro:CyLP-master admin$ python setup.py install /Users/admin/anaconda/lib/python3.5/site-packages/setuptools-20.3.1-py3.5.egg/setuptools/dist.py:285: UserWarning: Normalizing '0.7.4 ' to '0.7.4' running install cylp/cy/CyClpDualRowPivotBase.cpp: if (std::isspace(_ts)) cylp/cy/CyCoinModel.cpp: if (std::isspace(_ts)) cylp/cy/CyDualPivotPythonBase.cpp: if (std::isspace(_ts)) cylp/cy/CyOsiCuts.cpp: if (std::isspace(_ts)) cylp/cy/CyPEPivot.cpp: std::isspace(Py_CHARMASK(s[len-1])) && cylp/cy/CyTest.cpp: std::isspace(Py_CHARMASK(s[len-1])) && running build running build_py running build_ext building 'cylp.cy.CyClpPrimalColumnPivotBase' extension gcc -fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/admin/anaconda/include -arch x86_64 -I./cylp/cpp -I./cylp/cy -I/Users/admin/Downloads/Cbc-2.9.8/include/coin -I/Users/admin/anaconda/lib/python3.5/site-packages/numpy/core/include -I. -I/Users/admin/anaconda/include/python3.5m -c cylp/cpp/IClpPrimalColumnPivotBase.cpp -o build/temp.macosx-10.5-x86_64-3.5/cylp/cpp/IClpPrimalColumnPivotBase.o -w gcc -fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/admin/anaconda/include -arch x86_64 -I./cylp/cpp -I./cylp/cy -I/Users/admin/Downloads/Cbc-2.9.8/include/coin -I/Users/admin/anaconda/lib/python3.5/site-packages/numpy/core/include -I. -I/Users/admin/anaconda/include/python3.5m -c cylp/cy/CyClpPrimalColumnPivotBase.cpp -o build/temp.macosx-10.5-x86_64-3.5/cylp/cy/CyClpPrimalColumnPivotBase.o -w cylp/cy/CyClpPrimalColumnPivotBase.cpp:5019:19: error: no member named 'f_tstate' in '_frame' (*frame)->f_tstate = tstate; ~~~~~~~~ ^ 1 error generated. error: command 'gcc' failed with exit status 1

    opened by kathleenszabo 10
  • Slow adding constraints

    Slow adding constraints

    Consider the following program:

    #!/usr/bin/env python
    
    from cylp.cy import CyClpSimplex
    
    s = CyClpSimplex()
    s.optimizationDirection = 'max'
    
    for n in range(0, 20):
        print n
    
        # volume
        a = s.addVariable('a_{}'.format(n), 1, isInt=False)
        s += 0.0 <= a <= ((n+1) * 10)
    
        # onoff
        b = s.addVariable('b_{}'.format(n), 1, isInt=True)
        s += (-(n+1) * 10) * b + a <= 0
    
    s.writeLp('test.lp')
    

    This creates 40 variables: 20 real variables with an upper and lower bound, and 20 "on off" binary variables, which are constrained to be "on" if their corresponding real variable is >= 0.

    This program is exceptionally slow to build using CyLP, I think due to the way it manages the sparse matrix? My actual problem has a lot more than 20 variables to be added. Is there a more direct way to achieve this? Perhaps by tracking the row/column indices manually? The resulting matrix is particularly sparse, although the variables are interconnected (not in the example, but in my real problem).

    opened by snorfalorpagus 10
  • a.any() or a.all() truth value error

    a.any() or a.all() truth value error

    Hi

    based on the example code posted on the README.rst I get the following error. Have you seen it?

    I am running it on windows 10 64bit and in an Anaconda Python 2.7 32bit environment. I get the following error prompt.

    Cheers Andres

    Traceback (most recent call last):
      File "testCylp.py", line 21, in <module>
        s += A * x <= a
      File "CyClpSimplex.pyx", line 1206, in cylp.cy.CyClpSimplex.CyClpSimplex.__iadd__ (cylp\cy\CyClpSimplex.cpp:15746)
      File "CyClpSimplex.pyx", line 1219, in cylp.cy.CyClpSimplex.CyClpSimplex.addConstraint (cylp\cy\CyClpSimplex.cpp:15965)
      File "d:\Anaconda3\envs\py27_32\lib\site-packages\cylp-0.7.2-py2.7-win32.egg\cylp\py\modeling\CyLPModel.py", line 981, in addConstraint
        c = cons.evaluate(consName)
      File "d:\Anaconda3\envs\py27_32\lib\site-packages\cylp-0.7.2-py2.7-win32.egg\cylp\py\modeling\CyLPModel.py", line 266, in evaluate
        cons.perform(token, left, right)
      File "d:\Anaconda3\envs\py27_32\lib\site-packages\cylp-0.7.2-py2.7-win32.egg\cylp\py\modeling\CyLPModel.py", line 372, in perform
        if left == None:
    ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
    

    The following pip packages are installed

    (py27_32) D:\>conda list
    # packages in environment at d:\Anaconda3\envs\py27_32:
    #
    certifi                   2017.7.27.1              py27_0    conda-forge
    cylp                      0.7.2                     <pip>
    mkl                       2017.0.3                      0
    numpy                     1.13.1                   py27_0
    pip                       9.0.1                    py27_0    conda-forge
    python                    2.7.13                        1    conda-forge
    scipy                     0.19.1              np113py27_0
    setuptools                36.3.0                   py27_0    conda-forge
    vs2008_runtime            9.00.30729.5054               0
    wheel                     0.29.0                   py27_0    conda-forge
    wincertstore              0.2                      py27_0    conda-forge
    
    opened by andresbh 9
  • Thoughts to have CyLP on conda-forge

    Thoughts to have CyLP on conda-forge

    Hello,

    So I was thinking, it might be a worth while endeavour to get CyLP on conda-forge https://conda-forge.org/ similar to coincbc, Py-ART, numpy etc. Probably would make the installation process much easier and managing environments better. I began testing some conda building with it, but the most recent pypi version has older cython generated files so conda-build fails. Questions I have are, is there desire to have CyLP on conda-forge? If so, would it be possible to have a pypi release that reflects the most recent github changes? I can then maybe take a whack at it and see if I can get a build going. Just some thoughts etc.

    opened by zssherman 8
  • Jupyter Kernel Dies at getCbcModel()

    Jupyter Kernel Dies at getCbcModel()

    I am using this example: http://coin-or.github.io/CyLP/modules/CyCbcModel.html On jupyter kernel dies at cbcModel = s.getCbcModel()

    Ipython displays this error /home/builder/.termux-build/coinor-clp/src/src/OsiClp/OsiClpSolverInterface.cpp:7183: virtual int OsiClpSolverInterface::dualPivotResult(int &, int &, int, int, double &, CoinPackedVector *): assertion "modelPtr_->solveType() == 2" failed Aborted

    opened by defencedog 0
  • test_MIP.py Error

    test_MIP.py Error

    New to cylp, I install cylp by pip and run the file CyLP/cylp/tests/test_MIP.py

    But python returns with error: " cbcModel.branchAndBound() AttributeError: 'cylp.cy.CyCbcModel.CyCbcModel' object has no attribute 'branchAndBound' " I hope to find a solution for this, thanks so much!

    opened by xueno6 3
  • Cbc binary version to use?

    Cbc binary version to use?

    I have a simple question: in CyLP documentation, it says: Cbc. The version should be 2.10 (recommended)

    is that still the case or we can use 2.10.8 binary to build CyLP? thank you.

    opened by HuangRicky 5
  • how to surpress printing of simplex solver

    how to surpress printing of simplex solver

    I would like to surpress all printing of the primal simplex solver for CyClpSimplex when calling primal(). I have tried to do so with python contextlib to redicrect stdout and stderr into /dev/null but it still keeps printing things like: Clp0006I 0 Obj 0 Dual inf 0.018082951 (1) w.o. free dual inf (0)

    is there a way to surpress this?

    opened by fboerman 0
  • method for setting arbitrary parameters

    method for setting arbitrary parameters

    Hello,

    I use cvxpy with cbc solver from CyLP to solve ILP problem of a big size.

    Parameters which I pass to cvxpy function solve: problem.solve(verbose=True, solver='CBC', numberThreads = 1, allowablePercentageGap = 1) are not later used in CyLP. Because the problem is big I want to use more threads for counting.

    Is it possible to add method for setting arbitrary parameters and use more threads to solve problem?

    Discussion on this topic here: https://github.com/coin-or/Cbc/issues/489

    opened by Marie73 1
  • OsiSolverInterface methods not exposed to Python

    OsiSolverInterface methods not exposed to Python

    https://github.com/coin-or/Osi/blob/master/src/Osi/OsiSolverInterface.hpp has lots of useful methods, but https://github.com/coin-or/CyLP/blob/master/cylp/cy/CyOsiSolverInterface.pxd does not expose them.

    opened by mkoeppe 0
Releases(v0.91.5)
Owner
COIN-OR Foundation
Computational Infrastructure for Operations Research.
COIN-OR Foundation
30 Days Of Machine Learning Using Pytorch

Objective of the repository is to learn and build machine learning models using Pytorch. 30DaysofML Using Pytorch

Mayur 119 Nov 24, 2022
slim-python is a package to learn customized scoring systems for decision-making problems.

slim-python is a package to learn customized scoring systems for decision-making problems. These are simple decision aids that let users make yes-no p

Berk Ustun 37 Nov 02, 2022
🌲 Implementation of the Robust Random Cut Forest algorithm for anomaly detection on streams

🌲 Implementation of the Robust Random Cut Forest algorithm for anomaly detection on streams

Real-time water systems lab 416 Jan 06, 2023
This handbook accompanies the course: Machine Learning with Hung-Yi Lee

This handbook accompanies the course: Machine Learning with Hung-Yi Lee

RenChu Wang 472 Dec 31, 2022
Free MLOps course from DataTalks.Club

MLOps Zoomcamp Our MLOps Zoomcamp course Sign up here: https://airtable.com/shrCb8y6eTbPKwSTL (it's not automated, you will not receive an email immed

DataTalksClub 4.6k Dec 31, 2022
Bayesian optimization in JAX

Bayesian optimization in JAX

Predictive Intelligence Lab 26 May 11, 2022
This repo includes some graph-based CTR prediction models and other representative baselines.

Graph-based CTR prediction This is a repository designed for graph-based CTR prediction methods, it includes our graph-based CTR prediction methods: F

Big Data and Multi-modal Computing Group, CRIPAC 47 Dec 30, 2022
This project used bitcoin, S&P500, and gold to construct an investment portfolio that aimed to minimize risk by minimizing variance.

minvar_invest_portfolio This project used bitcoin, S&P500, and gold to construct an investment portfolio that aimed to minimize risk by minimizing var

1 Jan 06, 2022
Backprop makes it simple to use, finetune, and deploy state-of-the-art ML models.

Backprop makes it simple to use, finetune, and deploy state-of-the-art ML models. Solve a variety of tasks with pre-trained models or finetune them in

Backprop 227 Dec 10, 2022
Python implementation of Weng-Lin Bayesian ranking, a better, license-free alternative to TrueSkill

Python implementation of Weng-Lin Bayesian ranking, a better, license-free alternative to TrueSkill This is a port of the amazing openskill.js package

Open Debates Project 156 Dec 14, 2022
ML Optimizers from scratch using JAX

Toy implementations of some popular ML optimizers using Python/JAX

Shreyansh Singh 38 Jul 29, 2022
Predicting job salaries from ads - a Kaggle competition

Predicting job salaries from ads - a Kaggle competition

Zygmunt Zając 57 Oct 23, 2020
A modular active learning framework for Python

Modular Active Learning framework for Python3 Page contents Introduction Active learning from bird's-eye view modAL in action From zero to one in a fe

modAL 1.9k Dec 31, 2022
Azure MLOps (v2) solution accelerators.

Azure MLOps (v2) solution accelerator Welcome to the MLOps (v2) solution accelerator repository! This project is intended to serve as the starting poi

Microsoft Azure 233 Jan 01, 2023
Automated Machine Learning Pipeline with Feature Engineering and Hyper-Parameters Tuning

The mljar-supervised is an Automated Machine Learning Python package that works with tabular data. I

MLJAR 2.4k Jan 02, 2023
Multiple Linear Regression using the LinearRegression class from sklearn.linear_model library

Multiple-Linear-Regression-master - A python program to implement Multiple Linear Regression using the LinearRegression class from sklearn.linear model library

Kushal Shingote 1 Feb 06, 2022
Datetimes for Humans™

Maya: Datetimes for Humans™ Datetimes are very frustrating to work with in Python, especially when dealing with different locales on different systems

Timo Furrer 3.4k Dec 28, 2022
Diabetes Prediction with Logistic Regression

Diabetes Prediction with Logistic Regression Exploratory Data Analysis Data Preprocessing Model & Prediction Model Evaluation Model Validation: Holdou

AZİZE SULTAN PALALI 2 Oct 23, 2021
A high performance and generic framework for distributed DNN training

BytePS BytePS is a high performance and general distributed training framework. It supports TensorFlow, Keras, PyTorch, and MXNet, and can run on eith

Bytedance Inc. 3.3k Dec 28, 2022
A simple guide to MLOps through ZenML and its various integrations.

ZenBytes Join our Slack Community and become part of the ZenML family Give the main ZenML repo a GitHub star to show your love ZenBytes is a series of

ZenML 127 Dec 27, 2022