sage-numerical-backends-coin


Namesage-numerical-backends-coin JSON
Version 10.4rc2 PyPI version JSON
download
home_pagehttps://github.com/mkoeppe/sage-numerical-backends-coin
SummaryCOIN-OR backend for Sage MixedIntegerLinearProgram
upload_time2024-06-30 07:34:22
maintainerNone
docs_urlNone
authorNathann Cohen, Yuan Zhou, John Perry, Zeyi Wang, Martin Albrecht, Jori Mäntysalo, Matthias Koeppe, Erik M. Bray, Jeroen Demeyer, Nils Bruin, Julien Puydt, Dima Pasechnik, and others
requires_pythonNone
licenseGPLv2+
keywords milp linear-programming optimization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # sage-numerical-backends-coin: COIN-OR mixed integer linear programming backend for SageMath

[![PyPI](https://img.shields.io/pypi/v/sage-numerical-backends-coin)](https://pypi.org/project/sage-numerical-backends-coin/ "PyPI: sage-numerical-backends-coin")
[![GitHub Workflow Status](https://github.com/sagemath/sage-numerical-backends-coin/workflows/Build%20and%20test%20Python%20package/badge.svg)](https://github.com/sagemath/sage-numerical-backends-coin/actions "GitHub Actions: sage-numerical-backends-coin")

`CoinBackend` has previously been available as part of the [SageMath](http://www.sagemath.org/) source tree,
from which it is built as an "optional extension" when the `cbc` Sage package is installed.

However, it is not available in binary distributions such as:
- the Sage binary distribution (which does not package any optional packages),
- homebrew (which just uses the Sage binary distribution),
- Ubuntu (bionic 18.04LTS and several newer versions ship versions of SageMath, with various optional packages including CBC, but not the optional extension module CoinBackend),
- conda-forge (which ships SageMath and CBC but not the optional extension).
- Fedora

The present standalone Python package `sage-numerical-backends-coin` has been created from the SageMath sources, version 9.0.beta10.  It can be installed on top of various Sage installations using pip, including all of the above, including older versions of Sage such as 8.1 (as shipped by Ubuntu bionic 18.04LTS).

Sage ticket https://trac.sagemath.org/ticket/28175 uses this package to remove the in-tree version of `CoinBackend`.

## Installation

CBC can either be installed using its Sage package using

    $ sage -i cbc

or any of the methods explained at https://github.com/coin-or/Cbc .

This package finds the CBC installation by means of ``pkgconfig``.

Install this package from PyPI using

    $ sage -python -m pip install sage-numerical-backends-coin

or from GitHub using

    $ sage -python -m pip install git+https://github.com/sagemath/sage-numerical-backends-coin

(See [`.github/workflows/build.yml`](.github/workflows/build.yml) for details about package prerequisites on various systems.)

## Using this package

To obtain a solver (backend) instance:

    sage: from sage_numerical_backends_coin.coin_backend import CoinBackend
    sage: CoinBackend()
    <sage_numerical_backends_coin.coin_backend.CoinBackend object at 0x7fb72c2c7528>

Equivalently:

    sage: from sage_numerical_backends_coin.coin_backend import CoinBackend
    sage: from sage.numerical.backends.generic_backend import get_solver
    sage: get_solver(solver=CoinBackend)
    <sage_numerical_backends_coin.coin_backend.CoinBackend object at 0x7fe21ffbe2b8>

To use this solver (backend) with [`MixedIntegerLinearProgram`](http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/mip.html):

    sage: from sage_numerical_backends_coin.coin_backend import CoinBackend
    sage: M = MixedIntegerLinearProgram(solver=CoinBackend)
    sage: M.get_backend()
    <sage_numerical_backends_coin.coin_backend.CoinBackend object at 0x7fb72c2c7868>

To make it available as the solver named `'Coin'`, we need to make the new module
known as `sage.numerical.backends.coin_backend` (note dots, not underscores), using
the following commands:

    sage: import sage_numerical_backends_coin.coin_backend as coin_backend, sage.numerical.backends as backends, sys
    sage: sys.modules['sage.numerical.backends.coin_backend'] = backends.coin_backend = coin_backend

If these commands are executed in a Sage session before any `MixedIntegerLinearProgram` is created, then
the new `'Coin'` solver wins over the `'GLPK'` solver in the selection of the default MIP backend.
To select the `'Coin'` solver explicitly as the default MIP backend, additionally use the following command.

    sage: default_mip_solver('Coin')

To make these settings permanent, add the above 2 + 1 commands to your `~/.sage/init.sage` file.
Note that this setting will not affect doctesting (`sage -t`) because this file is ignored in doctesting mode.

## Running doctests

To run the (limited) testsuite of this package, use:

    $ sage setup.py test

To run the Sage testsuite with the default MIP solver set to the backend provided by this package, use:

    $ sage setup.py check_sage_testsuite

## Running tests with tox

The doctests can also be invoked using `tox`:

    $ tox -e local
    $ tox -e local-sage_testsuite

If you have `docker` installed, more tests can be run:

    $ tox -e docker-sage_binary-cbc_coinbrew

See `tox.ini` for the available options.

## Overriding the default solver by patching the Sage installation

Another method is to patch the module in permanently to the sage installation (at your own risk).
This method will affect doctesting.

    $ sage -c 'import os; import sage.numerical.backends as dm; import sage_numerical_backends_coin.coin_backend as sm; s = sm.__file__; f = os.path.basename(s); d = os.path.join(dm.__path__[0], f); (os.path.exists(d) or os.path.lexists(d)) and os.remove(d); os.symlink(s, d);'

Or use the script [`patch_into_sage_module.py`](patch_into_sage_module.py) in the source distribution that does the same:

    $ sage -c 'load("patch_into_sage_module.py")'
    Success: Patched in the module as sage.numerical.backends.coin_backend

Verify with [`check_get_solver_with_name.py`](check_get_solver_with_name.py) that the patching script has worked:

    $ sage -c 'load("check_get_solver_with_name.py")'
    Success: get_solver(solver='coin') gives <sage_numerical_backends_coin.coin_backend.CoinBackend object at 0x7f8f20218528>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mkoeppe/sage-numerical-backends-coin",
    "name": "sage-numerical-backends-coin",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "milp, linear-programming, optimization",
    "author": "Nathann Cohen, Yuan Zhou, John Perry, Zeyi Wang, Martin Albrecht, Jori M\u00e4ntysalo, Matthias Koeppe, Erik M. Bray, Jeroen Demeyer, Nils Bruin, Julien Puydt, Dima Pasechnik, and others",
    "author_email": "mkoeppe@math.ucdavis.edu",
    "download_url": "https://files.pythonhosted.org/packages/87/40/dbe53ed4d9e72ed864140d0c53112f7aa8c712dfe84ef207f58d4905a44d/sage_numerical_backends_coin-10.4rc2.tar.gz",
    "platform": null,
    "description": "# sage-numerical-backends-coin: COIN-OR mixed integer linear programming backend for SageMath\n\n[![PyPI](https://img.shields.io/pypi/v/sage-numerical-backends-coin)](https://pypi.org/project/sage-numerical-backends-coin/ \"PyPI: sage-numerical-backends-coin\")\n[![GitHub Workflow Status](https://github.com/sagemath/sage-numerical-backends-coin/workflows/Build%20and%20test%20Python%20package/badge.svg)](https://github.com/sagemath/sage-numerical-backends-coin/actions \"GitHub Actions: sage-numerical-backends-coin\")\n\n`CoinBackend` has previously been available as part of the [SageMath](http://www.sagemath.org/) source tree,\nfrom which it is built as an \"optional extension\" when the `cbc` Sage package is installed.\n\nHowever, it is not available in binary distributions such as:\n- the Sage binary distribution (which does not package any optional packages),\n- homebrew (which just uses the Sage binary distribution),\n- Ubuntu (bionic 18.04LTS and several newer versions ship versions of SageMath, with various optional packages including CBC, but not the optional extension module CoinBackend),\n- conda-forge (which ships SageMath and CBC but not the optional extension).\n- Fedora\n\nThe present standalone Python package `sage-numerical-backends-coin` has been created from the SageMath sources, version 9.0.beta10.  It can be installed on top of various Sage installations using pip, including all of the above, including older versions of Sage such as 8.1 (as shipped by Ubuntu bionic 18.04LTS).\n\nSage ticket https://trac.sagemath.org/ticket/28175 uses this package to remove the in-tree version of `CoinBackend`.\n\n## Installation\n\nCBC can either be installed using its Sage package using\n\n    $ sage -i cbc\n\nor any of the methods explained at https://github.com/coin-or/Cbc .\n\nThis package finds the CBC installation by means of ``pkgconfig``.\n\nInstall this package from PyPI using\n\n    $ sage -python -m pip install sage-numerical-backends-coin\n\nor from GitHub using\n\n    $ sage -python -m pip install git+https://github.com/sagemath/sage-numerical-backends-coin\n\n(See [`.github/workflows/build.yml`](.github/workflows/build.yml) for details about package prerequisites on various systems.)\n\n## Using this package\n\nTo obtain a solver (backend) instance:\n\n    sage: from sage_numerical_backends_coin.coin_backend import CoinBackend\n    sage: CoinBackend()\n    <sage_numerical_backends_coin.coin_backend.CoinBackend object at 0x7fb72c2c7528>\n\nEquivalently:\n\n    sage: from sage_numerical_backends_coin.coin_backend import CoinBackend\n    sage: from sage.numerical.backends.generic_backend import get_solver\n    sage: get_solver(solver=CoinBackend)\n    <sage_numerical_backends_coin.coin_backend.CoinBackend object at 0x7fe21ffbe2b8>\n\nTo use this solver (backend) with [`MixedIntegerLinearProgram`](http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/mip.html):\n\n    sage: from sage_numerical_backends_coin.coin_backend import CoinBackend\n    sage: M = MixedIntegerLinearProgram(solver=CoinBackend)\n    sage: M.get_backend()\n    <sage_numerical_backends_coin.coin_backend.CoinBackend object at 0x7fb72c2c7868>\n\nTo make it available as the solver named `'Coin'`, we need to make the new module\nknown as `sage.numerical.backends.coin_backend` (note dots, not underscores), using\nthe following commands:\n\n    sage: import sage_numerical_backends_coin.coin_backend as coin_backend, sage.numerical.backends as backends, sys\n    sage: sys.modules['sage.numerical.backends.coin_backend'] = backends.coin_backend = coin_backend\n\nIf these commands are executed in a Sage session before any `MixedIntegerLinearProgram` is created, then\nthe new `'Coin'` solver wins over the `'GLPK'` solver in the selection of the default MIP backend.\nTo select the `'Coin'` solver explicitly as the default MIP backend, additionally use the following command.\n\n    sage: default_mip_solver('Coin')\n\nTo make these settings permanent, add the above 2 + 1 commands to your `~/.sage/init.sage` file.\nNote that this setting will not affect doctesting (`sage -t`) because this file is ignored in doctesting mode.\n\n## Running doctests\n\nTo run the (limited) testsuite of this package, use:\n\n    $ sage setup.py test\n\nTo run the Sage testsuite with the default MIP solver set to the backend provided by this package, use:\n\n    $ sage setup.py check_sage_testsuite\n\n## Running tests with tox\n\nThe doctests can also be invoked using `tox`:\n\n    $ tox -e local\n    $ tox -e local-sage_testsuite\n\nIf you have `docker` installed, more tests can be run:\n\n    $ tox -e docker-sage_binary-cbc_coinbrew\n\nSee `tox.ini` for the available options.\n\n## Overriding the default solver by patching the Sage installation\n\nAnother method is to patch the module in permanently to the sage installation (at your own risk).\nThis method will affect doctesting.\n\n    $ sage -c 'import os; import sage.numerical.backends as dm; import sage_numerical_backends_coin.coin_backend as sm; s = sm.__file__; f = os.path.basename(s); d = os.path.join(dm.__path__[0], f); (os.path.exists(d) or os.path.lexists(d)) and os.remove(d); os.symlink(s, d);'\n\nOr use the script [`patch_into_sage_module.py`](patch_into_sage_module.py) in the source distribution that does the same:\n\n    $ sage -c 'load(\"patch_into_sage_module.py\")'\n    Success: Patched in the module as sage.numerical.backends.coin_backend\n\nVerify with [`check_get_solver_with_name.py`](check_get_solver_with_name.py) that the patching script has worked:\n\n    $ sage -c 'load(\"check_get_solver_with_name.py\")'\n    Success: get_solver(solver='coin') gives <sage_numerical_backends_coin.coin_backend.CoinBackend object at 0x7f8f20218528>\n",
    "bugtrack_url": null,
    "license": "GPLv2+",
    "summary": "COIN-OR backend for Sage MixedIntegerLinearProgram",
    "version": "10.4rc2",
    "project_urls": {
        "Homepage": "https://github.com/mkoeppe/sage-numerical-backends-coin"
    },
    "split_keywords": [
        "milp",
        " linear-programming",
        " optimization"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8740dbe53ed4d9e72ed864140d0c53112f7aa8c712dfe84ef207f58d4905a44d",
                "md5": "8cb0a82b975ecd06be11c29a020a9e18",
                "sha256": "8251112b9d609a686bd0f074417039e5882110736ec831b4b8c41305935a1ce7"
            },
            "downloads": -1,
            "filename": "sage_numerical_backends_coin-10.4rc2.tar.gz",
            "has_sig": false,
            "md5_digest": "8cb0a82b975ecd06be11c29a020a9e18",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 26062,
            "upload_time": "2024-06-30T07:34:22",
            "upload_time_iso_8601": "2024-06-30T07:34:22.573197Z",
            "url": "https://files.pythonhosted.org/packages/87/40/dbe53ed4d9e72ed864140d0c53112f7aa8c712dfe84ef207f58d4905a44d/sage_numerical_backends_coin-10.4rc2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-30 07:34:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mkoeppe",
    "github_project": "sage-numerical-backends-coin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "sage-numerical-backends-coin"
}
        
Elapsed time: 1.29677s