Giter Club home page Giter Club logo

cylp's Introduction

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 and installation

On Windows: Installation as a binary wheel

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

$ python -m pip install cylp

On Linux/macOS: Installation as a binary wheel

Binary wheels are available for Linux and some versions of OS X for some versions of Python. To see if there is a wheel available for your platform, you can browse

https://pypi.org/project/cylp/#files

or just try:

$ python -m pip install cylp

In case this fails, it is most likely that there is no wheel for your platform. In particular, there are no wheels for MacOS running on Apple Silicon. If you are on Linux, this can probably be addressed by switching to a supported Python version with, e.g., conda:

$ conda create -n cylp python=3.9
$ conda activate cylp

If all else fails, it is easy to install from source, but Cbc must be installed first, as detailed below. The easiest route for this is to use conda.

On Linux/macOS with conda: Installation from source

To install from source, you will need to install binaries for Cbc or also build Cbc from source. The version should be 2.10 (recommended) or earlier (current master branch of Cbc will not work with this version of CyLP).

The following commands will create and activate a new conda environment with all these prerequisites installed:

$ conda create -n cylp coin-or-cbc cython numpy pkg-config scipy -c conda-forge
$ conda activate cylp

Now you can install CyLP from PyPI:

$ pip install --no-build-isolation cylp

(The option --no-build-isolation ensures that cylp uses the Python packages installed by conda in the build phase.)

Alternatively, if you have cloned CyLP from GitHub:

$ pip install --no-build-isolation .

On Linux/macOS with pip: Installation from source

You will 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 your system's 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, or the corresponding package on your distribution.

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

    $ brew install cbc pkg-config

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 (macOS).

Next, build and install CyLP:

$ python -m pip install cylp

This will build CyLP install the runtime dependencies (install-requires), NumPy and SciPy <https://scipy.org> and build and install CyLP.

Testing your installation

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 (this is currently broken).

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 (https://www.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

The following software packages make use of CyLP:

  1. CVXPY, a Python-embedded modeling language for convex optimization problems, uses CyLP for interfacing to CBC, which is one of the supported mixed-integer solvers.

CyLP has been 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).
  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

cylp's People

Contributors

a-andre avatar aebrahim avatar benchampion avatar bitdeli-chef avatar jjhelmus avatar lumbric avatar matt-telstra avatar mkoeppe avatar mpy avatar ralfjung avatar rmcgibbo avatar scollis avatar sdementen avatar svigerske avatar tkralphs avatar vbadanov avatar zssherman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cylp's Issues

DeprecationWarning raised..

In calling from Py-ART's phase processing engine.. Looks like you call something in Numpy with a float that will soon only accept an integer

/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/core/numeric.py:183: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
a = empty(shape, dtype, order)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/core/numeric.py:183: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
a = empty(shape, dtype, order)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/core/numeric.py:183: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
a = empty(shape, dtype, order)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/core/numeric.py:183: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
a = empty(shape, dtype, order)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/core/numeric.py:183: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
a = empty(shape, dtype, order)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:300: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res = zeros((n, n), v.dtype)
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/numpy/lib/twodim_base.py:305: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
res[:n-k].flat[i::n+1] = v
/Users/scollis/anaconda/lib/python2.7/site-packages/cylp-0.7.1-py2.7-macosx-10.6-x86_64.egg/cylp/py/modeling/CyLPModel.py:372: FutureWarning: comparison to None will result in an elementwise object comparison in the future.
if left == None:
/Users/scollis/anaconda/lib/python2.7/site-packages/cylp-0.7.1-py2.7-macosx-10.6-x86_64.egg/cylp/py/utils/sparseUtil.py:388: FutureWarning: comparison to None will result in an elementwise object comparison in the future.
if b == None:
/Users/scollis/anaconda/lib/python2.7/site-packages/pyart/correct/phase_proc.py:925: FutureWarning: comparison to None will result in an elementwise object comparison in the future.
s = CyClpSimplex(model)

Solve fails on problem with only 1 variable

The following code runs correctly for count = 2, but fails with count = 1.

#!/usr/bin/env python

from cylp.cy import CyClpSimplex
from cylp.py.modeling.CyLPModel import CyLPArray

count = 2

s = CyClpSimplex()
x = s.addVariable('x', count)

s += 0.0 <= x <= 10.0

s.objective = CyLPArray([20]*count) * x
s.optimizationDirection = 'max'

status = s.primal()
result = s.primalVariableSolution['x']

print(status)
print(result)

The error raised:

meh.py:9: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  x = s.addVariable('x', count)
meh.py:12: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  s += 0.0 <= x <= 10.0
Traceback (most recent call last):
  File "meh.py", line 14, in <module>
    s.objective = CyLPArray([20]*count) * x
  File "CyClpSimplex.pyx", line 141, in cylp.cy.CyClpSimplex.CyClpSimplex.objective.__set__ (cylp/cy/CyClpSimplex.cpp:4559)
  File "CyClpSimplex.pyx", line 1192, in cylp.cy.CyClpSimplex.CyClpSimplex.setObjectiveArray (cylp/cy/CyClpSimplex.cpp:17461)
ValueError: Buffer has wrong number of dimensions (expected 1, got 0)

This can be worked around by adding another variable, which can be completely unconstrained and not included in the objective function definition. However, this shouldn't be required.

lp.rhs seems incorrect

I'm working on a Gomory cut generator that uses CyLP. I was assuming that lp.rhs contained the value of B^-1 b and this seems to be the case after initially solving a giving linear program. However, if I add an inequality (cut) and then resolve, lp.rhs is no longer correct. This can be checked easily by comparing the value of the solution that CyLP returns with the value of the right-hand side. The right-hand side values for the rows in which the original variables are basic should match the solution values and they don't. To reproduce, get CuPPy and run it out of the box.

https://github.com/tkralphs/CuPPy

You will see that in the second iteration, lp.rhs and sol don't match.

Summing over axis

First off, thank you for a wonderful, wonderful tool. CyLP has saved me so much time already 👍

I may well be doing things wrong, but I often find myself wishing I could write constraints like

s += my_binary_matrix.sum(axis = 1) == 1

but it appears that the variables' sum() function doesn't support it. Is there another way of expressing sums across a subset of dimensions (that doesn't require writing loops)?

comparison to `None` will result in an elementwise object comparison in the future.

Hi,

CyLP is such a nice work that immediately relieved me from the heavy work of using clp as a C++ library.

I was trying the first example in the official documentation and got the following warning:

ipykernel/main.py:8: FutureWarning: comparison to None will result in an elementwise object comparison in the future.

It seems that inside CyLP, a numpy array is tested for None.
It should be a simple fix by replacing '== None' with 'is None'.

Keep up with the good work!

Expose version in the package and tag releases

Would it be possible to expose the cylp version in some manner during run time? module.version seem to be the standard in a number of Scientific Python modules, so cylp.version would be great.

For example with NumPy:

import numpy
print numpy.__version__

1.8.0

Also, would it be possible to tag the releases on GitHub so that a particular commit can be checked out without using the hash.

Thanks again for the great package!

If you need help with either of these feel free to let me know, I'd be happy to make a PR if needed.

Compilation problems with python 3.4

CyLP seems to be exactly what I'm looking for, but unfortunately I can't get it to compile with python 3.4 (using Anaconda 2.0.1).

First problem ("fixed" by deleting the contents of README.rst):

File "//anaconda/lib/python3.4/encodings/ascii.py", line 26, in decode

    return codecs.ascii_decode(input, self.errors)[0]

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 343: ordinal not in range(128)

Second problem: print statements in fixBinaries.py without parentheses. Just added some parentheses and this went away.

Third problem I don't know what to do with:

cylp/cy/CyClpDualRowPivotBase.cpp:5180:19: error: no member named 'f_tstate' in '_frame'
        (*frame)->f_tstate = tstate;

Solver claims solution is optimal, but violates constraints

tldr

I'm trying to add booleans together, hoping that the result is a boolean OR. I'm expecting a boolean OR, XOR, or an error, or INFEASIBLE. But what happens is that the solver violates other constraints to satisfy the addition.

Minimum working example

import cvxpy
from cvxopt.modeling import op
from cvxopt.modeling import variable, op, max, sum
import cylp

A = cvxpy.Bool(name='A')
B = cvxpy.Bool(name='B')
C = cvxpy.Bool(name='C')

constr = [] # constraints list

constr.append(A == 1)
constr.append(B == 1)

# trying to implement A or B
# not sure if addition works as boolean or
constr.append(C == A + B)

# I also tried this
#constr.append(1.0*C == 1.0*A + 1.0*B)

# I don't care what the objective is,
#all states are constrained to a single value
obj = cvxpy.Maximize(A)

problem = cvxpy.Problem(obj, constr)

ret = problem.solve(solver=cvxpy.CBC)

print('problem.status == %s' % problem.status)

assert(problem.status in [cvxpy.OPTIMAL, cvxpy.OPTIMAL_INACCURATE])

print('A:%f | B:%f | C:%f' % tuple([x.value for x in [A,B,C]]))

Expected output

  • A == 1 and B == 1, because that's what the constraints explicitly state.
  • If the solver does not know how to sum two true booleans (state C), it should throw an error, or return INFEASIBLE.

Observed output

  • A == 0 and B == 0, even though I specified exactly that through the constraints
  • Solver claims solution is 'optimal'

Comments

My third constraint seems to be causing issues. I understand that summing booleans is a bit odd, I was just wondering/hoping that it would work.
The issue here is that when the solver encounters this odd third constraint, it violates the first two constraints and claims the solution is optimal.

When I run this, I do see some FutureWarnings. They sound like they are not of consequence, but could they be the cause of the problem?

The output when I run this code is:

matt@machine:~/muckaround/opt$ python simple2.py
/usr/local/lib/python2.7/dist-packages/cvxpy/problems/solvers/cbc_intf.py:143: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  x = model.addVariable('x', n)
/usr/local/lib/python2.7/dist-packages/cylp/py/modeling/CyLPModel.py:193: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  if (other == None):
/usr/local/lib/python2.7/dist-packages/cylp/py/modeling/CyLPModel.py:516: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  if self.lower == None:
/usr/local/lib/python2.7/dist-packages/cvxpy/problems/solvers/cbc_intf.py:153: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  model += A[0:dims[s.EQ_DIM], :] * x == b[0:dims[s.EQ_DIM]]
problem.status == optimal
A:0.000000 | B:0.000000 | C:0.000000

Breaks with python-3.6

This error:

cylp/cy/CyClpPrimalColumnPivotBase.cpp:5019:19: error: no member named 'f_tstate' in '_frame'
        (*frame)->f_tstate = tstate;
        ~~~~~~~~  ^

And also non-ascii characters in README.rst cause this error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "setup.py", line 362, in <module>
    s_README = getBdistFriendlyString(open('README.rst').read())
  File "/usr/local/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 343: ordinal not in range(128)
*** Error code 1

CyLP : in-memory computations or via .mps/.lp

I wanted to know whether CyLP calls Cbc via in-memory computations (like JuMP) or does it follow the path of PuLP, i.e., writing a .mps file and then calling the Cbc executable with an .mps input?

Windows install error stdint.h not found

Getting error

...coin-or\cbc-2.9.9-x86_64-w64-mingw32\include\coin\CoinTypes.hpp(12) : 
     fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory
error: Setup script exited with error:  command 'cl.exe' failed with exit status 2

I think this stdint.h is kind of standard problem with Microsoft. Didn't COIN at some point have a workaround for this?

adding new variable resets bounds

adding new variables will reset previous variables bounds somehow

type(m)
cylp.cy.CyClpSimplex.CyClpSimplex
m.variablesLower
array([ -1.79769313e+308, -1.79769313e+308, 1.79769313e+308,
1.79769313e+308, 6.95066373e-310])
m.setColumnLower(0, 0)
m.variablesLower
array([ 0.00000000e+000, -1.79769313e+308, 1.79769313e+308,
1.79769313e+308, 6.95066373e-310])
m.addVariable('z', 1)
z
m.variablesLower
array([ -1.79769313e+308, -1.79769313e+308, -1.79769313e+308,
2.78136591e-309, 1.02095688e+248, 9.36366575e-076])

is this an expected behavior?

Constant Error CyLP install

Hi Dear All,

I am driving crazy because I have tried to install CyLP and I get the next statement:

MacBook-Pro-de-LUIS:~ luissanmartin$ export COIN_INSTALL_DIR=/Users/luissanmartin/Desktop/Cbc-2.9.6
MacBook-Pro-de-LUIS:~ luissanmartin$ cd /Users/luissanmartin/Desktop/CyLP
MacBook-Pro-de-LUIS:CyLP luissanmartin$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 86, in
libs = get_libs()
File "setup.py", line 57, in get_libs
'doc', 'Cbc', 'cbc_addlibs.txt')) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/luissanmartin/Desktop/Cbc-2.9.6/share/coin/doc/Cbc/cbc_addlibs.txt'

I have installed the Cbc successfully, but I cannot manage with this CyLP issue... may you give some idea about my failure??

Best Wishes!!

Luis

Is applying customized initial solution supported in CLP

I plan to use the CLP to solve some large-scale LPs. Especially, I can acquire some initial solution with good quality and want to accelerate the process using this information. Is there a way to feed a basic feasible solution to the solver and start to solve the problem from there.
Further, as there is a presolve function in CyClpSimplex module, how is the presolved solution is utilized by the package? Thanks.

Hard to use auxiliary variables

Sometimes it is necessary to use one-dimensional variables. These are currently not handled correctly in matrix-style constraint definitions. Let me provide an example based on this setInteger example (where "from CyLP" should be "from cylp"):

import numpy as np
from cylp.cy import CyClpSimplex
from cylp.py.modeling.CyLPModel import CyLPModel, CyLPArray
model = CyLPModel()

x = model.addVariable('x', 3)
y = model.addVariable('y', 1)

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

model += A*x <= a
model += 2 <= B * x + D * y <= b

IndexError: tuple index out of range

Installation issue

Hi,

I've been trying to install CyLP on a linux machine. I have completed step 1,2,4 of the install guide. After downloading/installing Cbc, I do:

~/Downloads/CyLP-master# python setup.py install

I get:

Traceback (most recent call last):
  File "setup.py", line 88, in <module>
    libs = get_libs()
  File "setup.py", line 59, in get_libs
    'doc', 'Cbc', 'cbc_addlibs.txt')) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/me/Downloads/Cbc-2.9.8/share/coin/doc/Cbc/cbc_addlibs.txt'

I do not see a file named addlibs anywhere in the Cbc folder. Yet, I have seen posts here by @tkralphs that CLP should work with recent versions of Cbc (#39).

Moreover, on line 33 of setup.py, it is written:

#Do "export CYLP_USE_CYTHON=" if you want to build cylp from scratch, using Cython

Can you please say what I should put after the '=' sign and where/how I should 'Do' export CYLP_USE_CYTHON= ?

Thanks in advance!

Memory leak from repeated CyClpSimplex instantiations

I have a program that repeatedly instantiates CyClpSimplex objects (ideally solving tens of thousands of LPs), but my kernel kills the program after ~6000 iterations. I think this is because these CyClpSimplex objects are not being freed from memory. In fact, the CyClpSimplex class's dealloc function is commented out in the source. I have already switched to GLPK to get around this problem, but I figured I should call attention to it here in case anyone else ever encounters it.

Using Cuts produce noisy output (model.logLevel=0) -> desired behaviour?

Hi,

i just implemented a prototype interface to Cbc for cvxpy using cylp (great project).

When using this to solve some naive tsp-model without using any cuts, loglevel=0 works and there is no output.

Activating LiftProjectCuts on the other hand results in the following (shortened) output:

Clp3003W Analysis indicates model infeasible or unbounded
Clp6003E Matrix has 144 large values, first at column 20, row 110 is -1.7976931e+308
Clp0004I Stopped due to errors - objective value 0
Clp0032I Errors objective 0 - 0 iterations time 0.002
Clp6003E Matrix has 144 large values, first at column 20, row 110 is -1.7976931e+308
Clp3003W Analysis indicates model infeasible or unbounded
Clp6003E Matrix has 144 large values, first at column 20, row 110 is -1.7976931e+308
Clp0004I Stopped due to errors - objective value 0
Clp0032I Errors objective 0 - 0 iterations time 0.002

Additional example with CliqueCuts:

rcl Found 0 new violated cliques with the row-clique method
rcl The largest admissible number was 0 (threshold 12)
rcl    all row cliques have been enumerated

scl Found 0 new violated cliques with the star-clique method
scl The largest star size was 4 (threshold 12)
scl Enumeration 6 times, found 0 maxl cliques
scl Greedy 0 times, found 0 maxl cliques
scl Skipped a star b/c of small solution value 0 times
scl    all cliques have been enumerated
  • (1) Is there any way to switch off this output too?
  • (2) Side-question: are LiftProjectCuts working correctly when the output looks like that? I'm asking because the result is correct.

Thanks
Sascha

How to locate the directory of COIN-OR or COINMP in macOS? `KeyError: 'COIN_INSTALL_DIR'`

I have installed COINMP through brew's homebrew/science tap such that

$ brew tap homebrew/science; brew install coinmp

and now I am trying to install CYLP in order to use it with CVXPY

$ easy_install cylp

but

Exception: Please set the environment variable COIN_INSTALL_DIR to the location of the COIN installation

so where is this directory located and how to specify it? Does there exist some settings file for setting up the envvar? .profile?

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!

clock_gettime missing on Ubuntu

When trying to run CyLP on Ubuntu you may get a 'clock_gettime' missing definition. This can be fixed by '-lrt' to extra_link_args when operatingSystem == 'linux'

Installing cylp in a robust, portable, neat way

This is following on from Issue #47
(I can't figure out how to reopen that issue)

Intro

I want to use cylp on a system for which pip cannot find precompiled binaries. pip install cylp should still work. It should compile things for me, but it does not.

As a user, I expect to be able to install cylp solely by doing

pip install cylp

Requiring more steps than that is not ideal. Requiring users to manually download and manually compile many dependencies is not user friendly, nor is it robust.

Furthermore, I expect that using pip install cylp with a virtual environment will install cylp and all dependencies into that environment. For context, I'm deploying my code into AWS Lambda functions. That involves zipping up a virtual environment. For every library except cylp, I can just use pip, and zip up the directory containing the virtual environment.

I understand that packaging binaries in python libraries neatly is non-trivial. However it is certainly possible. Numpy and pandas use C files too, and they work seamlessly. I realise I'm asking for a lot by requesting that pip work seamlessly. I realise that this library and it's dependencies are probably written by a one or two people in their spare time. I'm not trying to criticise. I'm trying to help. That's why I've included published 2 scripts which took me several weeks to write. This is what it takes to install cylp in a robust, reliable and reproducible way (on machines for which pip cannot find pre-compiled binaries).

This process involved me figuring out the extensive dependency tree (including dependencies which pip does not know about), and the fragile version incompatibilities (e.g. did you know that there are 2 different versions of numpy both numbered 1.12.1?), and then manually downloading the source code and compiling each of those dependencies in their own custom virtual environment, extracting .whl files from one virtual env and installing it in the next. In short, it is a nightmare.

The scripts

I've split up this script into 2 steps, because the first script takes a very long time, so you don't want to run it every time you rebuild your virtual environment.

  • compile.sh compiles all the libraries into .whl files
  • makeScript.sh script takes the .whl files compiled by compile.sh, and installs them into a virtual env, in such a way that pip is aware of (almost) all dependencies simultaneously

Details and Outstanding issues

  • This script needs to modify the LD_LIBRARY_PATH OS variable. That's messy and crude, and means this script can't easily go into a normal setup.py file.
  • This script works on my machine, which is an EC2 instance running Amazon's version of Redhat. When I try running it on a fresh machine, I still get some issues. I'm just posting what I have anyway.

Conclusion

I believe a user-friendly installation process is by far the most important issue facing this library, because the current process makes it near impossible to use.

I'm not sure whether the cause of all these issues is cylp itself, or rather CBC and SCS. I'm posting here first to see what you say.

What’s the best way to add these scripts to setup.py, so that pip does all this for the user? To restate my goal: I want to be able to install cylp and its dependencies into a self-contained virtual environment using a single pip command.

Or failing that, I just hope that other users struggling with the installation process can copy and paste my work here to save themselves weeks of hair pulling and confusion.

Incorrect basis inverse after solving small LP

I've encountered a small LP for which the the basis inverse (lp.basisInverse) automatically calculated by CyLP seems to be wrong (along with associated data attrictures lp.tableau and lp.rhs). However, if I calculate the basis inverse myself using getBinvACol, it is correct. Could this have something to do with scaling? Is the basis inverse computed by CyLP with respect to a scaled version of the matrix rather than the original?

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

A = [[ -8, 30], [ -2, -4], [-14, 8], [ 2, -36], [30, -8], [10, 10]]
b = [115,  -5, 1, -5, 191, 127]
c = [1, -1]

lp = CyClpSimplex()
A = np.matrix(A)
b = CyLPArray(b)
c = CyLPArray(c)

x = lp.addVariable('x', 2)

lp += x >= 0
lp += A * x <= b
lp.objective = -c * x if sense[0] == 'Max' else c * x
lp.primal(startFinishOptions = 'x')
Binv = np.zeros(shape = (lp.nConstraints, lp.nConstraints))
for i in range(lp.nVariables, lp.nVariables+lp.nConstraints):
   lp.getBInvACol(i, Binv[i-lp.nVariables,:])
print 'Correct basis inverse:')
print Binv
print 'Incorrect basis inverse:')
print lp.basisInverse
print 'Correct RHS:')
np.dot(lp.basisInverse, myb)
print 'Incorrect RHS:')
print lp.rhs

Cutoff API Implementation

I do not see an API for the -constraintFromCutoff option set in CBC 2.8.0 - is there a way to use this API in cylp?

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: scikit-learn/scikit-learn#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

Issues installing under sierra

This is mainly an informative issue.. I have fixed this for my own use and the issue seems to be in the Cbc install itself.

Platform: MacOS Sierra

Following instructions I get:

In file included from /Users/scollis/coin/include/coin/CoinHelperFunctions.hpp:24:
/Users/scollis/coin/include/coin/CoinTypes.hpp:15:10: fatal error: 'cstdint' file not found
#include <cstdint>
         ^
1 error generated.
error: command 'gcc' failed with exit status 1

Googling and clicking Stackoverflow yields:
http://stackoverflow.com/questions/32552249/opencv-cstdint-file-not-found

So I replaced:
#include
with
#include <tr1/cstdint>
in /Users/scollis/coin/include/coin/CoinHelperFunctions.hpp

The issue seems to come from the line above:
#ifdef COINUTILS_HAS_CSTDINT

Seems something is not being set right on ./configure

Cbc version 2.9.8

NOTE: Same Cbc version works 100% on linux.. and from other reports on earlier OSX

Again, likely not a thing for the devs on this package but an alert for those who may be stuck

Doesn't compile with CoinMP 1.7.1

CyLP does not compile with the current CoinMP release 1.7.1. It complains about ClpSimplexDual.hpp missing, and indeed that file is not (no longer?) installed by CoinMP - it's missing from "includecoin_HEADERS" in Clp/src/Makefile.am.

I am not sure if this is a CoinMP or a CyLP bug.

Unable to package CyLP with cx_Freeze

It's currently not possible to package a script that uses CyLP using cx_Freeze, due to the way it accesses data files (such as VERSION).

Traceback (most recent call last):
  File "d:\test\gui.py", line 377, in run
    import opt
  File "d:\test\opt.py", line 54, in <module>
    from cylp.cy import CyClpSimplex
  File "c:\Python27\lib\site-packages\cylp\__init__.py", line 4, in <module>
    __version__ = open(join(currentDir, 'VERSION')).read()
IOError: [Errno 2] No such file or directory: 'D:\\test\\build\\exe.win32-2.7\\library.zip\\cylp\\VERSION'

This is due to the way modules are stored in a zip file by cx_Freeze.

https://cx-freeze.readthedocs.org/en/latest/overview.html

Python modules for your executables are stored in zip files. These can go in three different places:

  • The default is to create a zip file called library.zip and place all modules in this zip file.
  • Each executable can have a private zip file with the same name as the executable (except for the .zip extension).
  • Each executable can have a zip file of modules appended to it. This was the default in earlier versions of cx_Freeze, but it doesn’t work with for creating an RPM, since the RPM builder strips executables.

This should be relatively easy to fix. If I can find some time and there is interest I will try to put in a PR.

https://cx-freeze.readthedocs.org/en/latest/faq.html#using-data-files
https://stackoverflow.com/questions/23351565/issue-packaging-scrapy-spider-with-cx-freeze-or-py2exe/25513413#25513413

Wrong output isRelaxationInfeasible

I just started using CyLP and I'm trying to understand how it works. The following code solves an instance of the famous subset-sum problem:

m = CyClpSimplex()
x = m.addVariable('x', 5)
c = scipy.matrix([-6,-9,11,12,13])
m += c*x == 0
m += x.sum() >= 1
m += 0 <= x <= 1
m.setInteger(x)
cbcModel = m.getCbcModel()
print(cbcModel.branchAndBound())
print(cbcModel.isRelaxationOptimal())
print(cbcModel.isRelaxationInfeasible())
print(cbcModel.primalVariableSolution['x'])

I expect the problem to be infeasible. The last few lines of output are:

Clp0006I 0 Obj 0 Primal inf 0.77777768 (1)
Clp0001I Primal infeasible - objective value 0
Cbc0001I Search completed - best objective 1e+050, took 7 iterations and 12 nodes (0.01 seconds)
Cbc0032I Strong branching done 18 times (17 iterations), fathomed 0 nodes and fixed 0 variables
Cbc0035I Maximum depth 2, 0 variables fixed on reduced cost
Clp0006I 0 Obj 0 Primal inf 1.4444443 (1)
Clp0006I 0 Obj 0 Primal inf 1.4444443 (1)
Clp0001I Primal infeasible - objective value 0
solution
True
False
[ 0. 1.44444444 0. 0. 1. ]

I expect the penultimate three lines to be 'infeasible', 'False, 'True'. What am I doing wrong? Is it possible to have Cbc display model statistics and supress other output?

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

`TypeError: a bytes-like object is required, not 'str'` in installation of CYLP?

I think I resolved the earlier COIN_INSTALL_DIR problem, more in #52, but getting now odd TypeError: a bytes-like object is required, not 'str' error. Can this problem be related to COINMP, CYLP or the Anaconda installation? Or is it related to something else? How to fix this?

$ export COIN_INSTALL_DIR=/usr/local/Cellar/coinmp/1.7.3_1/; easy_install cylp
Searching for cylp
Reading https://pypi.python.org/simple/cylp/
Downloading https://pypi.python.org/packages/60/90/90d2e23a6423d7461d34bedaf05978787f23b64b82d3619430ed10e468e9/cylp-0.2.3.6.tar.gz#md5=189b9c0ba97bd2e4e4196ed44610913b
Best match: cylp 0.2.3.6
Processing cylp-0.2.3.6.tar.gz
Writing /var/folders/hl/p85gqql56l5d_7729280zbch0000gn/T/easy_install-4wvvb_v5/cylp-0.2.3.6/setup.cfg
Running cylp-0.2.3.6/setup.py -q bdist_egg --dist-dir /var/folders/hl/p85gqql56l5d_7729280zbch0000gn/T/easy_install-4wvvb_v5/cylp-0.2.3.6/egg-dist-tmp-nljbeyta
Traceback (most recent call last):
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 156, in save_modules
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 246, in run_setup
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 276, in run
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 245, in runner
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 47, in _execfile
  File "/var/folders/hl/p85gqql56l5d_7729280zbch0000gn/T/easy_install-4wvvb_v5/cylp-0.2.3.6/setup.py", line 397, in <module>
  File "/Users/user/anaconda3/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/bdist_egg.py", line 152, in run
  File "/Users/user/anaconda3/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/egg_info.py", line 188, in run
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/egg_info.py", line 403, in write_pkg_info
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 1107, in write_pkg_info
    self.write_pkg_file(pkg_info)
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py", line 53, in write_pkg_file
  File "/Users/user/anaconda3/lib/python3.5/distutils/util.py", line 471, in rfc822_escape
    lines = header.split('\n')
TypeError: a bytes-like object is required, not 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/anaconda3/bin/easy_install", line 6, in <module>
    sys.exit(setuptools.command.easy_install.main())
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 2274, in main
  File "/Users/user/anaconda3/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 409, in run
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 664, in easy_install
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 694, in install_item
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 875, in install_eggs
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 1114, in build_and_install
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 1100, in run_setup
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 249, in run_setup
  File "/Users/user/anaconda3/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
  File "/Users/user/anaconda3/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 168, in save_modules
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 143, in resume
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/_vendor/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 156, in save_modules
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 246, in run_setup
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 276, in run
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 245, in runner
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 47, in _execfile
  File "/var/folders/hl/p85gqql56l5d_7729280zbch0000gn/T/easy_install-4wvvb_v5/cylp-0.2.3.6/setup.py", line 397, in <module>
  File "/Users/user/anaconda3/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/bdist_egg.py", line 152, in run
  File "/Users/user/anaconda3/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/egg_info.py", line 188, in run
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/egg_info.py", line 403, in write_pkg_info
  File "/Users/user/anaconda3/lib/python3.5/distutils/dist.py", line 1107, in write_pkg_info
    self.write_pkg_file(pkg_info)
  File "/Users/user/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py", line 53, in write_pkg_file
  File "/Users/user/anaconda3/lib/python3.5/distutils/util.py", line 471, in rfc822_escape
    lines = header.split('\n')
TypeError: a bytes-like object is required, not 'str'

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).

Very outdated gcc in conda-forge causing CyLP not to build.

When I try and build @jjhelmus's branch I get the following error:

gcc -pthread -B /home/rjackson/anaconda3/envs/adi_env3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I./cylp/cpp -I./cylp/cy -I/home/rjackson/anaconda3/envs/adi_env3/include/coin -I/home/rjackson/anaconda3/envs/adi_env3/lib/python3.6/site-packages/numpy/core/include -I. -I/home/rjackson/anaconda3/envs/adi_env3/include/python3.6m -c cylp/cpp/IClpPrimalColumnPivotBase.cpp -o build/temp.linux-x86_64-3.6/cylp/cpp/IClpPrimalColumnPivotBase.o -w
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /home/rjackson/anaconda3/envs/adi_env3/gcc/include/c++/cstdint:35:0,
from /home/rjackson/anaconda3/envs/adi_env3/include/coin/CoinTypes.hpp:15,
from /home/rjackson/anaconda3/envs/adi_env3/include/coin/CoinHelperFunctions.hpp:24,
from /home/rjackson/anaconda3/envs/adi_env3/include/coin/CoinIndexedVector.hpp:20,
from cylp/cpp/IClpPrimalColumnPivotBase.h:6,
from cylp/cpp/IClpPrimalColumnPivotBase.cpp:1:
/home/rjackson/anaconda3/envs/adi_env3/gcc/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \

I tracked this down to the very, very old version of gcc that is in conda-forge (4.8.5). I got it to build with gcc 6.3.0, so I would not use the conda-forge gcc to try and build CyLP. I wonder if there is a way to get gcc 6.3.0 as a conda package?

MILP in CBC: Use initial solution to start search from

I was wondering if it is possible to ask CBC to use a constraint satisfied solution as the initial integer solution, instead of starting from the continuous (relaxed) solution.

Does CyLP offer anything for doing this? Where in CBC code can we access change in order to implement this?

Thanks,
Sam

byte vs str breakage in setup

When I've cloned the repo into directory CyLP I'm seeing pip install git+file://$(readlink -f CyLP) break while trying to write pip-egg-info/cylp.egg-info/PKG-INFO because of TypeError: a bytes-like object is required, not 'str' way down in the Python 3.5 distutils in some rfc822_escape method.

Per http://stackoverflow.com/questions/33054527/python-3-5-typeerror-a-bytes-like-object-is-required-not-str this looks to be a problem with some README/LICENSE stuff. Indeed, removing such content from setup.py...

diff --git a/setup.py b/setup.py
index afef50a..ea350fb 100644
--- a/setup.py
+++ b/setup.py
@@ -403,12 +403,6 @@ extra_files = ['cpp/*.cpp', 'cpp/*.hpp', 'cpp/*.h', 'VERSION']

 setup(name='cylp',
       version=VERSION,
-      description=DESC,
-      long_description=s_README,
-      author=s_AUTHORS,
-      author_email=AUTHOR_EMAIL,
-      url=URL,
-      license=s_LICENSE,
       packages=['cylp', 'cylp.cy', 'cylp.py', 'cylp.py.pivots', 'cylp.py.modeling',
                 'cylp.py.utils', 'cylp.py.mip','cylp.py.QP'],
       cmdclass=cmdclass,

...gets past the problem.

Do you unintentionally have binary-ish characters somewhere in those files? Can you confirm/deny the installation behaves as expected on Python 3.5?

Adding Cbc threading support

Adding methods to the CbcModel to access the getNumberThreads and setNumberThreads calls will enable users to perform parallel calculations:

diff --git a/cy/CyCbcModel.pxd b/cy/CyCbcModel.pxd
index a2ee7f1..9209789 100644
--- a/cy/CyCbcModel.pxd
+++ b/cy/CyCbcModel.pxd
@@ -56,6 +56,9 @@ cdef extern from "ICbcModel.hpp":
         bint setMaximumNodes(int value)
         int getMaximumNodes()

+        int getNumberThreads()
+        void setNumberThreads(int value)
+
         void setLogLevel(int value)
         int logLevel()

diff --git a/cy/CyCbcModel.pyx b/cy/CyCbcModel.pyx
index 16943cc..159d5d9 100644
--- a/cy/CyCbcModel.pyx
+++ b/cy/CyCbcModel.pyx
@@ -209,4 +209,13 @@ cdef class CyCbcModel:

         def __set__(self, value):
            self.CppSelf.setMaximumNodes(value)
+
+    property numberThreads:
+        def __get__(self):
+            return self.CppSelf.getNumberThreads()
+
+        def __set__(self, value):
+            self.CppSelf.setNumberThreads(value)
+
+
     #TODO: add access to solver: getLower, getUpper,...

addConstraint ignored

I was wondering why the constraint "x[0] == 1" is violated in the following program:

m = CyClpSimplex()
x = m.addVariable('x', 2)
m.addConstraint( x[0] == 1 )
# does not work either:
# m += x[0] == 1
# this works:
# m += scipy.matrix([1, 0])*x == 1
m.objective = x[0]
m += 0 <= x[0]
cbcModel = m.getCbcModel()
cbcModel.solve()
print(cbcModel.primalVariableSolution['x'])
# output: [ 0.  0.]

It works when I remove the nonnegativity constraint or when I use the scipy.matrix constraint. Note that I use two variables instead of 1 for this example due to Issue #22.

Unable to specify optimization direction

It looks like you should be able to specify the direction of the optimisation (minimize or maximize) using the optimizationDirection property of the CyClpSimplex object:

property optimizationDirection:

However, this property doesn't appear to be accessible from Python. There appears to be a test that checks for this, which currently fails on my machine.

======================================================================
ERROR: test_direction (__main__.TestCyClpSimplex)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_CyClpSimplex.py", line 59, in test_direction
    self.assertEqual(self.s.optimizationDirection, 'min')
AttributeError: 'cylp.cy.CyClpSimplex.CyClpSimplex' object has no attribute 'optimizationDirection'

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.

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.

Build error relating to gfortran

Dears,
I encounter an error when build Cylp at its root directory by using "python setup.py install":

9801a7b319bb:CyLP baohuaw$ python setup.py install
/usr/local/lib/python2.7/site-packages/setuptools/dist.py:332: UserWarning: Normalizing '0.7.4
' to '0.7.4'
normalized_version,
running install
cylp/cy/CyClpDualRowPivotBase.cpp: if (std::isspace(*ts))
cylp/cy/CyDualPivotPythonBase.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
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I./cylp/cpp -I./cylp/cy -I/Users/baohuaw/OpenSouce/Cbc-2.9/include/coin -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I. -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cylp/cpp/IClpPrimalColumnPivotBase.cpp -o build/temp.macosx-10.11-x86_64-2.7/cylp/cpp/IClpPrimalColumnPivotBase.o -w
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I./cylp/cpp -I./cylp/cy -I/Users/baohuaw/OpenSouce/Cbc-2.9/include/coin -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I. -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cylp/cy/CyClpPrimalColumnPivotBase.cpp -o build/temp.macosx-10.11-x86_64-2.7/cylp/cy/CyClpPrimalColumnPivotBase.o -w
clang++ -bundle -undefined dynamic_lookup build/temp.macosx-10.11-x86_64-2.7/cylp/cpp/IClpPrimalColumnPivotBase.o build/temp.macosx-10.11-x86_64-2.7/cylp/cy/CyClpPrimalColumnPivotBase.o -L. -L./cylp/cy -L/Users/baohuaw/OpenSouce/Cbc-2.9/lib -L./cylp/cy -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -lCbcSolver -lCbc -lCgl -lOsiClp -lClpSolver -lClp -lcoinasl -lm -ldl -lcoinmumps -lgfortran -lSystem -lquadmath -lm -lcoinmetis -lOsi -lCoinUtils -lbz2 -lz -lm -lcoinglpk -ldl -lm -lgmp -o build/lib.macosx-10.11-x86_64-2.7/cylp/cy/CyClpPrimalColumnPivotBase.so -Wl,-framework -Wl,Accelerate -headerpad_max_install_names
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang++' failed with exit status 1

Can anybody help me?
Thanks.

Cutting Plane Usage

Hello, not sure if this is the right place to ask this, but I'll try anyways.

I am interested in solving integer programs using only cutting planes - I have no problems adding and modifying the cut generator, but I was curious to see if there was a way to strip out all pre- and post-processing, including the usage of branch and bound, and rely only on the iteration of generating cutting planes and adding them to the problem formulation.

Any help will be appreciated, thank you!

Additionally, you've built a wonderful and straightforward tool. Thank you for that as well!

Create constraints using sparse matrices

I would like to use sparse matrices when defining constraints, as the memory allocation of the equivalent numpy matrices is too large for my capacities.
Is this too difficult to implement, given the current state of CyLPModel.py? I am using version 0.7.4.

Note: I tried to use a lil_matrix from the scipy.sparsemodule and I got the following error in the line model += sp_matrix * x <= 1:

  File "/usr/lib/python2.7/dist-packages/scipy/sparse/base.py", line 344, in __mul__
    raise ValueError('could not interpret dimensions')

variableNames not working properly

see example, names of variable is never added to the buffer "variableNames"

type(m)
cylp.cy.CyClpSimplex.CyClpSimplex
m.addVariable('q', 1)
q
m.getVarByName('q')
q
m.variableNames
[]

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.