#7268 closed enhancement (fixed)
GLPK: named constraints and variables, export functions
Reported by: | ncohen | Owned by: | tbd |
---|---|---|---|
Priority: | major | Milestone: | sage-4.3 |
Component: | packages: optional | Keywords: | |
Cc: | Merged in: | ||
Authors: | Nathann Cohen | Reviewers: | Martin Albrecht |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
Hello everybody !
This is an update of the GLPK package to match the changes in numerical.mip
. Here is the list of changes :
- Names for the objective function, the whole problem, variables and constraints can be set through the newly exposed GLPK functions
- A problem can be exported to MPS or LP files
- GLPK now returns Exceptions when it fails ( it used to silently return the 0 solution ).
- As solveGLPK, write_mps and write_lp all need the problem to be built as a GLPK structure, a new function
build_glp_prob
does this job and is used by the three of them.
Comments have also been added when felt necessary. The code should be more efficient (and Cythonized) in this version ( this was the whole purpose of redefining the structure of numerical.mip
)
The spkg is available on sagemath at : ~ncohen/glpk-4.38.p4.spkg or at http://www-sop.inria.fr/members/Nathann.Cohen/glpk-4.38.p4.spkg or http://sage.math.washington.edu/home/malb/spkgs/glpk-4.38.p4.spkg
Nathann
Attachments (1)
Change History (18)
comment:1 Changed 11 years ago by
- Status changed from new to needs_review
comment:2 Changed 11 years ago by
- Description modified (diff)
comment:3 Changed 11 years ago by
- Report Upstream set to N/A
- Status changed from needs_review to needs_work
comment:4 Changed 11 years ago by
- Status changed from needs_work to needs_review
Sorry !! :-)
I wrote these in the wrappers for these functions in class MixedIntegerLinearProgram? but forgot to copy them there.... Both files updated ! :-)
comment:5 Changed 11 years ago by
A new SPKG is available at
http://sage.math.washington.edu/home/malb/spkgs/glpk-4.38.p4.spkg
I give Nathan's SPKG a positive review if my referee patch is accepted. The referee patch fixes a mem leak and makes some of the code in the Cython wrapper more Pythonic (I also reverted some pre-mature optimisation which wouldn't speed things up)
I am attaching the patch here for convenience (it is applied in p4 linked above).
comment:6 Changed 11 years ago by
- Status changed from needs_review to needs_work
Your new spkg file contains a build/ directory and a file .cpp in the patch/ directory ( it seems you installed the patch then packaged it without removing these temporary files ). Coild you update it ?
Besides, is there any way for me to get the diff files since the last version ? I am still not that used to mercurial :-)
Thank youuuuuuuuuu !!!
Nathann
comment:7 Changed 11 years ago by
I've updated the SPKG and I'll attach the diff.
Changed 11 years ago by
comment:8 follow-up: ↓ 9 Changed 11 years ago by
- Status changed from needs_work to needs_info
Looks good :-)
Two questions though :
- Why do you replace == and != by is and is not ?
- is enumerating range(500) faster than 0<= i< 500 or is there another reason ?
- Why did you remove the leading 'r' before the docstrings ? I was under the impression they were requried for the docstring to display correctly...
I knew nothing about enumerate()... I'll remember this one ! :-)
Nathann
comment:9 in reply to: ↑ 8 Changed 11 years ago by
Why do you replace == and != by is and is not ?
False and None are unique objects thus it is sufficient to compare by checking identities. Feel free to change it back, though.
- is enumerating range(500) faster than 0<= i< 500 or is there another reason ?
Cython will write 0<= i < 500 automatically, so you can just write proper Python code and Cython will optimise it for you.
Why did you remove the leading 'r' before the docstrings ? I was under the impression they were requried for the docstring to display correctly...
Only if they contain a backslash.
comment:10 Changed 11 years ago by
- Status changed from needs_info to needs_review
Then.... Positive review ! And thank you for your answers and your help ! :-)
Nathann
comment:11 Changed 11 years ago by
- Status changed from needs_review to positive_review
comment:12 Changed 11 years ago by
- Description modified (diff)
comment:13 Changed 11 years ago by
Depends on #7270 !!!!!!!!!!!!!!!
comment:14 Changed 11 years ago by
- Resolution set to fixed
- Reviewers set to Martin Albrecht
- Status changed from positive_review to closed
Merged in the with the optional packages.
comment:15 Changed 11 years ago by
FYI: enumerate is now recognized and sped up by Cython (in version 0.12, which will be in the next version of Sage). See http://trac.cython.org/cython_trac/ticket/316
So hooray!
comment:16 Changed 11 years ago by
Thank you !! :-)
If you are interested by (shorter) reviews, I am splitting the big Flow patch into small ones... The flow is already available, the matching will be available soon too, and the others ( less important ) will follow.
comment:17 Changed 11 years ago by
- Summary changed from GLPK : named constraints and variables, export functions ... to GLPK: named constraints and variables, export functions
The package installs OK on Sage 4.3.alpha0. Here are some documentation issues in the file
patch/mipGlpk.pyx
that I think need to be addressed:solve_glpk()
--- document the inputlog
andobjective_only
, and explain the expected output (if any).write_mps()
--- document the inputfilename
andmodern
, and explain the expected output (if any).write_lp()
--- document what this function does. Also document the inputfilename
and explain the expected output (if any).