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

Add basis status functions get_col_stat, get_row_stat to GLPK backend #18685

Closed
mkoeppe opened this issue Jun 11, 2015 · 21 comments
Closed

Add basis status functions get_col_stat, get_row_stat to GLPK backend #18685

mkoeppe opened this issue Jun 11, 2015 · 21 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 11, 2015

Expose the GLPK functions get_col_stat, get_row_stat in Sage's GLPKBackend class.

These functions are essential for any serious linear programming.
For example, if one wants to extract the exact rational basic solution from the dictionary, one needs the information returned by these functions.

CC: @nathanncohen @yuan-zhou

Component: numerical

Keywords: glpk

Author: Yuan Zhou

Branch/Commit: 30eef17

Reviewer: Nathann Cohen

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

@mkoeppe mkoeppe added this to the sage-6.8 milestone Jun 11, 2015
@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 11, 2015

comment:2

I am curious to know how you would use it in Sage, but you will not have any problem exposing them. That's easy Cython.

@yuan-zhou
Copy link
Contributor

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 11, 2015

Commit: e5c7095

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 11, 2015

New commits:

e5c7095Add Sage interface for retrieving the basis status from GLPK

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 12, 2015

comment:5

Your code needs documentation and doctests. You can mimic what is done on the other functions of the same file, and will find some documentation here:

http://doc.sagemath.org/html/en/developer/coding_basics.html#documentation-strings

Nathann

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 12, 2015

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

49dba6aget_col_stat, get_row_stat: Add docstrings

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 12, 2015

Changed commit from e5c7095 to 49dba6a

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 12, 2015

comment:8

Doctests have been added; please review

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 12, 2015

comment:10

Could you protect against reading out-of-bounds constraints? Right now it crashes Sage. Could you also add a doctest for that?

Nathann

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 13, 2015

comment:11

I am not sure if this ticket is the right place to introduce bounds checking for these functions.
Other GLPK backend functions don't do that either (below is an example) -- after all, GLPK does check the bounds; it only chooses to terminate the process with abort()....

Does this rather need to be handled with sig_on() / sig_off() somehow?

sage: lp.add_linear_constraint(zip([0, 1, 2], [8, 6, 1]), None, 48)
sage: lp.add_linear_constraint(zip([0, 1, 2], [4, 2, 1.5]), None, 20)
sage: lp.add_linear_constraint(zip([0, 1, 2], [2, 1.5, 0.5]), None, 8)
sage: lp.set_objective([60, 30, 20])
sage: import sage.numerical.backends.glpk_backend as backend
sage: lp.solver_parameter(backend.glp_simplex_or_intopt, backend.glp_simplex_only)
sage: lp.solve()
sage: lp.get_variable_value(-1)
glp_get_col_prim: j = 0; column number out of range
Error detected in file glpapi06.c at line 739
------------------------------------------------------------------------
Unhandled SIGABRT: An abort() occurred in Sage.
This probably occurred because a *compiled* component of Sage has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Sage will now terminate.
------------------------------------------------------------------------

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 13, 2015

comment:12

I am not sure if this ticket is the right place to introduce bounds checking for these functions.

If you are ready to pay for a Python function call, you may as well avoid segfaults.

Other GLPK backend functions don't do that either (below is an example)

Oh. Right. Well, that's because we hardly ever use this function by giving it integers, I'd say. We always give it symbolic LP variable, for which it is not a problem. You can fix both here if you like, but you should at least make the one you introduce check for this.

Does this rather need to be handled with sig_on() / sig_off() somehow?

No, sig_on/sig_off is only meant to handle KeyboardInterrupt.

Nathann

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 13, 2015

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

e96bce5check bounds for get_row_stat() and git_col_stat()

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 13, 2015

Changed commit from 49dba6a to e96bce5

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 13, 2015

comment:14

Looks good! The patchbot complains that there are 'tab' characters in glpk_backend.pxd, however.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 13, 2015

Changed commit from e96bce5 to 30eef17

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 13, 2015

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

30eef17replace tab by spaces

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 13, 2015

comment:16

Gooooooood to go!

Nathann

P.S.: Please fill the "Author" field with your full name

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 13, 2015

Reviewer: Nathann Cohen

@yuan-zhou
Copy link
Contributor

Author: Yuan Zhou

@yuan-zhou
Copy link
Contributor

comment:18

Thanks!

@vbraun
Copy link
Member

vbraun commented Jun 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

3 participants