Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#6765 closed enhancement (wontfix)

Linear Programming in Tutorial's Tour !

Reported by: ncohen Owned by: tba
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: documentation Keywords:
Cc: mvngu Merged in:
Authors: Reviewers: John Palmieri
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by ncohen)

Hello !!!

Following http://groups.google.com/group/sage-devel/browse_thread/thread/9d9b09274f1eab83/79938a2139ba25d9?lnk=gst&q=isr#79938a2139ba25d9 , here is the requested Tutorial page for Linear Programming.

To doctest it, you will need the spkg GLPK from #6867 and numerical.MIP from #6869

I hope you will like it !!! And thanks to Minh for helping me with Sphinx !

Attachments (2)

trac_6765-tutorial-lp-folded.patch (7.4 KB) - added by mvngu 11 years ago.
folded patch
tutorial_lp.patch (8.2 KB) - added by ncohen 11 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 11 years ago by mvngu

  • Cc mvngu added

Changed 11 years ago by mvngu

folded patch

comment:2 Changed 11 years ago by mvngu

The patch trac_6765-tutorial-lp-folded.patch folds all three patches in tutorial_lp.patch. With the folded patch, changes are easier to review. Only trac_6765-tutorial-lp-folded.patch should be reviewed.

comment:3 Changed 11 years ago by mvngu

  • Summary changed from [with patch, needs review] Linear Programming in Tutorial's Tour ! to [with patch, needs work] Linear Programming in Tutorial's Tour !

I get the following error even after installing both GLPK and CBC:

----------------------------------------------------------------------
| Sage Version 4.1.1, Release Date: 2009-08-14                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: linear_function = {"variable1" : 2, "variable2" : -1}
sage: linear_function = {1 : 2, 2 : -1}
sage: linear_function={(1,1) : 1, (1,2) : 2, (2,1) : 3, (2,2) : 4}
sage: p = MIP(sense=1)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/28962/_home_mvngu__sage_init_sage_0.py in <module>()

NameError: name 'MIP' is not defined

Nathann, you need to give commands on how to use the MIP capabilities of CBC. Where is MIP() defined? How do I import and use it? Please include those information in your patch.

comment:4 Changed 11 years ago by mvngu

Here's a conversion in IRC with Nathann:

05:00 < ncohen> mvngu: I do not understand the problem you have with MIP. It seems you copied some part of the examples into Sage
05:00 < ncohen> mvngu: and Sage answered it did not know where to find the class MIP
05:01 < ncohen> mvngu: even though I have added in sage/numerical/all.py a line : from MIP import *
05:01 < mvngu> ncohen: David Joyner replied to me in an email that it depends on #6502.
05:01 < mvngu> So I'll mark #6765 as depending on #6502.
05:02 < ncohen> ooooops
05:02 < ncohen> sorry ^^;
05:02 < mvngu> This means that #6502 must be merged first.
05:02 < ncohen> I've been working on this for some timme so sometimes I forget about it... ^^;
05:02 < ncohen> indeed
05:02 < ncohen> the thing is that I already posted something like 5 or 6 patches based upon #6502
05:02 < ncohen> LP is so useful for graphs !
05:03 < mvngu> Since GLPK is an optional spkg at the moment, so the doctests that depends on GLPK should be flagged as optional.
05:03 < mvngu> Do so with the flag "# optional" in doctests.
05:04 < mvngu> That way, when the test suite is run, anything with the flag "# optional" would be skipped over.
05:04 < mvngu> Unless you have the required optional spkg installed.
05:05 < ncohen> I see... :-/
05:05 < mvngu> And any doctests that depend on CBC must also be flagged as "# optional".

Also, this ticket depends on #6502.

comment:5 Changed 11 years ago by ncohen

  • Summary changed from [with patch, needs work] Linear Programming in Tutorial's Tour ! to [with patch, needs review] Linear Programming in Tutorial's Tour !

I just updated tutorial_lp.patch. Please do not use trac_6765-tutorial-lp-folded.patch which is now an outdated version !

comment:6 Changed 11 years ago by ncohen

  • Summary changed from [with patch, needs review] Linear Programming in Tutorial's Tour ! to [with patch, needs work] Linear Programming in Tutorial's Tour !

As the functions dealing with LP have not been reviewed, I prefer to rewrite the MIP class for Sage to make it easier to use. I will post a new version of the MIP patch as soon as possible, along with all the patches for functions using it.

Sorry for the trouble, I'll try to make it quick !

Nathann

comment:7 Changed 11 years ago by ncohen

  • Description modified (diff)

comment:8 Changed 11 years ago by ncohen

  • Summary changed from [with patch, needs work] Linear Programming in Tutorial's Tour ! to [with patch, needs review] Linear Programming in Tutorial's Tour !

comment:9 Changed 11 years ago by ncohen

The new LP tutorial matching the Trac ticket #6869 is here, ready for review ;-)

Nathann

Changed 11 years ago by ncohen

comment:10 Changed 11 years ago by ncohen

New version coherent with the changes from #7012

comment:11 Changed 11 years ago by jhpalmieri

  • Reviewers set to John Palmieri
  • Status changed from needs_review to needs_work
  • Summary changed from [with patch, needs review] Linear Programming in Tutorial's Tour ! to Linear Programming in Tutorial's Tour !

Some comments:

(1) When I run "sage -docbuild tutorial html", it complains

/Applications/sage/devel/sage/doc/en/tutorial/tour_LP.rst:64: (WARNING/2) Title underline too short.

Variables in ``MixedIntegerLinearProgram``
""""""""""""""""""""""""""

The string of double quotes should line up exactly with the previous line. (Maybe it's good enough it is at least as long, but I think it should be the same length.)

(2) In a string like minimized ( for example `2 x + y` ), you shouldn't have a space after ( or before ): it should say minimized (for example `2 x + y`). This happens throughout the document. Along the same lines, there should be no space before "?" or before ":". Before a block of examples (like lines 69-70), I think you want a visible colon, and you achieve that by having "::" with no preceding space. (Using "::" with a preceding space signals a block of examples but doesn't print a colon at all.)

(3) On line 75, "remperature" should presumably be "temperature". Try running a spell check.

(4) You don't have a period at the sentence ending the paragraph "What is a Mixed Integer Linear Program ?" I haven't done any more careful proofreading, but you should check for other spelling, usage, and grammar errors.

(5) In multiline doctests, you need to change "....:" to "...". As it stands, doctesting bombs on these lines.

(6) If I don't have GLPK or numerical.MIP installed, doctests have to pass anyway. Also, if I don't have them, I absolutely don't want doctesting to try to install them, which the lines

     sage: # To install GLPK
     sage: install_package('glpk')
     sage: # To install Coin-OR Branch and Cut ( CBC )
     sage: install_package('cbc')

will do. Maybe mark those lines as "# not tested"?

comment:12 Changed 11 years ago by jhpalmieri

One more thing: since the content depends on the optional packages, you should say that at the *beginning* of the section, not the end. Otherwise, someone may start working through the examples, only to have nothing go as advertised, and they quit trying before they get to the disclaimer at the end.

comment:13 Changed 11 years ago by was

  • Resolution set to wontfix
  • Status changed from needs_work to closed

We (me, John P., and Minh) discussed this on irc and think that optional packages shouldn't be required to work through the main Sage tutorial.

comment:14 Changed 11 years ago by mvngu

  • Milestone changed from sage-4.3 to sage-duplicate/invalid/wontfix
  • Report Upstream set to N/A

Feel free to open another ticket to put the linear programming tutorial in the Constructions document.

comment:15 follow-up: Changed 11 years ago by ncohen

Could I do the same with my former ( and refused ) Graph Tour ?

comment:16 in reply to: ↑ 15 Changed 11 years ago by mvngu

Replying to ncohen:

Could I do the same with my former ( and refused ) Graph Tour ?

Sure! Go for it.

Note: See TracTickets for help on using tickets.