{"id":23484,"library":"cylp","title":"CyLP","description":"CyLP is a Python interface for the COIN-OR Linear Programming (CLP), COIN-OR Branch and Cut (CBC), and COIN-OR Cut Generation Library (CGL) solvers. It provides a modeling layer similar to PuLP but directly wraps the COIN-OR solvers for efficient linear and mixed-integer programming. Version 0.94.0 is current; release cadence is intermittent.","status":"active","version":"0.94.0","language":"python","source_language":"en","source_url":"https://github.com/coin-or/CyLP","tags":["linear programming","mixed integer programming","coin-or","clp","cbc","optimization"],"install":[{"cmd":"pip install cylp","lang":"bash","label":"default"},{"cmd":"pip install cython numpy pyscipopt  # build deps often needed","lang":"bash","label":"dependencies for source build"}],"dependencies":[{"reason":"required for data structures and matrix operations","package":"numpy","optional":false},{"reason":"required to compile the C extensions from source","package":"cython","optional":true}],"imports":[{"note":"CyClpSimplex is in the cy submodule, not top-level cylp.","wrong":"from cylp import CyClpSimplex","symbol":"CyClpSimplex","correct":"from cylp.cy import CyClpSimplex"},{"note":"Same as above, CbcModel is in cylp.cy.","wrong":"from cylp import CbcModel","symbol":"CbcModel","correct":"from cylp.cy import CbcModel"}],"quickstart":{"code":"from cylp.cy import CyClpSimplex\nfrom cylp.py.modeling.CyLPModel import CyLPModel, CyLPArray\n\nmodel = CyLPModel()\nx = model.addVariable('x', 1)\ny = model.addVariable('y', 1)\nmodel += 2*x + 3*y <= 10\nmodel += x - y >= 1\nmodel.objective = x + 2*y\n\nsolver = CyClpSimplex()\nsolver.setModel(model)\nsolver.primal()\nprint('x =', solver.primalVariableSolution['x'])\nprint('y =', solver.primalVariableSolution['y'])","lang":"python","description":"Standard quickstart: define a CyLP model, create a CyClpSimplex solver, solve, and print solution."},"warnings":[{"fix":"For new code, consider using CyClpSimplex.addColumn/addRow methods or switch to a more actively maintained package like PuLP if needed.","message":"The 'cylp.py.modeling.CyLPModel' approach is older; newer examples use 'CyClpSimplex' directly with matrix input. The modeling module may see less development.","severity":"deprecated","affected_versions":"0.94.0"},{"fix":"Use 'pip install cylp' and if it fails, ensure build dependencies are installed. Check PyPI for wheel availability.","message":"Installation from source requires Cython, NumPy, and a compatible C++ compiler. Pre-built wheels may not be available for all platforms (e.g., Python 3.11+ or ARM).","severity":"gotcha","affected_versions":"all"},{"fix":"Update imports: change 'from cylp import CyClpSimplex' to 'from cylp.cy import CyClpSimplex'.","message":"In versions prior to 0.90, the import path was 'cylp.CyClpSimplex' not 'cylp.cy.CyClpSimplex'. Code written for old versions will break.","severity":"breaking","affected_versions":"<0.90"},{"fix":"Always use 1-based indexing when referring to variable IDs in lower-level API calls.","message":"The CyLP modeling layer (CyLPModel) uses 1-indexed variable IDs internally. Supplying 0-based indices may cause silent errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from cylp.cy import CyClpSimplex' instead of 'from cylp import CyClpSimplex'.","cause":"Commonly occurs when using the wrong import path; CyClpSimplex is in the cylp.cy submodule.","error":"ImportError: cannot import name 'CyClpSimplex' from 'cylp'"},{"fix":"After calling solver.primal(), access solution via solver.primalVariableSolution if using CyLPModel; otherwise use solver.getColSolution().","cause":"This attribute exists only after solving with a model set via setModel. If solving directly with matrix input, use getColSolution/getRowPrice instead.","error":"AttributeError: 'CyClpSimplex' object has no attribute 'primalVariableSolution'"},{"fix":"Ensure column/row indices start from 1, not 0. For example, in addColumn, the column numbers are 1-indexed.","cause":"Often caused by passing invalid column indices (0-based) when API expects 1-based indices.","error":"RuntimeError: CoinAssert or incorrect argument"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}