Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COIN backend should support basis status and tableau data functions #18763

Closed
mkoeppe opened this issue Jun 22, 2015 · 20 comments
Closed

COIN backend should support basis status and tableau data functions #18763

mkoeppe opened this issue Jun 22, 2015 · 20 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 22, 2015

This is for COIN backend support in #18733 and #18688.

Should add
(1) getBasisStatus, setBasisStatus,
(2) getBInvARow, getBInvACol, getBasics,
to src/sage/numerical/backends/coin_backend.{pxd,pyx}

Possible that one needs to add other functions as well, such as enableSimplexInterface...

Reference to the relevant Clp header file:
https://projects.coin-or.org/Osi/browser/trunk/Osi/src/OsiClp/OsiClpSolverInterface.hpp?rev=1472

CC: @yuan-zhou @nathanncohen

Component: numerical

Author: Yuan Zhou

Branch/Commit: c2488a8

Reviewer: Vincent Delecroix

Issue created by migration from https://trac.sagemath.org/ticket/18763

@mkoeppe mkoeppe added this to the sage-6.8 milestone Jun 22, 2015
@mkoeppe

This comment has been minimized.

@yuan-zhou
Copy link

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 3, 2015

Commit: 9fdbd84

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 3, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

9fdbd84Fix bugs in CoinBackend::get/set_basis_status(); Add doctests

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 5, 2015

Changed commit from 9fdbd84 to 3644950

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 5, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

3644950Add CoinBackend::get_binva_row, get_binva_col

@videlec
Copy link
Contributor

videlec commented Sep 13, 2015

comment:6

Please fill the Authors field with your full name.

Instead of sage_malloc you could use check_malloc (that checks that the memory is indeed allocated and raises an error if not).

Otherwise, everything looks clean and tests run smoothly on my computer (with Coin installed).

Vincent

@videlec
Copy link
Contributor

videlec commented Sep 13, 2015

Reviewer: Vincent Delecroix

@yuan-zhou
Copy link

comment:7

Instead of sage_malloc you could use check_malloc (that checks that the memory is indeed allocated and raises an error if not).

Thanks a lot for reviewing the ticket.
Does one call sage_free to free the memory allocated by check_malloc?
Since sage_malloc is used throughout the file, I was trying to be consistent. Would you suggest replacing them all by check_malloc? Or perhaps better to update them using #18868?

@yuan-zhou
Copy link

Author: Yuan Zhou

@videlec
Copy link
Contributor

videlec commented Sep 13, 2015

comment:9

Hi Yuan,

Replying to @yuan-zhou:

Instead of sage_malloc you could use check_malloc (that checks that the memory is indeed allocated and raises an error if not).

Thanks a lot for reviewing the ticket.
Does one call sage_free to free the memory allocated by check_malloc?
Since sage_malloc is used throughout the file, I was trying to be consistent. Would you suggest replacing them all by check_malloc? Or perhaps better to update them using #18868?

I do not think that #18868 is good idea in this case. You will create a Python object for nothing.

check_malloc is equivalent to sage_malloc except that it will raise an error in case the memory was not allocated (where sage_malloc just returns NULL). So the memory should be freed with sage_free. You can safely replace occurrences of sage_malloc by check_malloc. Moreover you can always replace

my_ptr = sage_malloc(12)
if my_ptr == NULL:
    raise MemoryError("allocation failed")

by

my_ptr = check_malloc(12)

Vincent

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 13, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

3ab6b33replace sage_malloc by check_malloc

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 13, 2015

Changed commit from 3644950 to 3ab6b33

@yuan-zhou
Copy link

comment:11

Thank you, Vincent.
I changed sage_malloc to check_malloc.

@videlec
Copy link
Contributor

videlec commented Sep 13, 2015

comment:12

The patchbot reported some errors (when cbc is not installed)

sage -t --long src/sage/numerical/backends/coin_backend.pyx
**********************************************************************
File "src/sage/numerical/backends/coin_backend.pyx", line 1260, in sage.numerical.backends.coin_backend.CoinBackend.get_basis_status
Failed example:
    p.solve()
    ...
    NameError: name 'p' is not defined
**********************************************************************
File "src/sage/numerical/backends/coin_backend.pyx", line 1285, in sage.numerical.backends.coin_backend.CoinBackend.get_basis_status
Failed example:
    lp_coin = lp.get_backend()
    ...
    NameError: name 'lp' is not defined
**********************************************************************

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 13, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

c2488a8specify optional-cbc in doctests

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 13, 2015

Changed commit from 3ab6b33 to c2488a8

@yuan-zhou
Copy link

comment:14

Oops, I forgot to indicate optional - cbc at some places

@videlec
Copy link
Contributor

videlec commented Sep 13, 2015

comment:15

Good to go!

@vbraun
Copy link
Member

vbraun commented Sep 14, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants