#7311: Improve the add_constraint method from MixedIntegerLinearProgram
-------------------------+--------------------------------------------------
   Reporter:  ncohen     |       Owner:  jkantor     
       Type:  defect     |      Status:  needs_review
   Priority:  critical   |   Milestone:  sage-4.3.4  
  Component:  numerical  |    Keywords:              
     Author:             |    Upstream:  N/A         
   Reviewer:             |      Merged:              
Work_issues:             |  
-------------------------+--------------------------------------------------

Comment(by abmasse):

 Here is what I did:

 1. I tested all sage with `sage -testall` and all tests passed.

 2. I tried `sage -t -optional` on the folder sage/numerical. Of course,
 some tests didn't pass.

 3. I installed CBC. All tests passed with `sage -t *` in the
 sage/numerical folder, but when I type `sage -t -optional *`, I get the
 following:

 {{{
 [~/Applications/sage/devel/sage-linear/sage/numerical]$ sage -t -optional
 *
 sage -t -optional "devel/sage-linear/sage/numerical/__init__.py"
          [0.2 s]
 sage -t -optional "devel/sage-linear/sage/numerical/all.py"
          [0.1 s]
 sage -t -optional "devel/sage-linear/sage/numerical/knapsack.py"
          [13.8 s]
 sage -t -optional "devel/sage-linear/sage/numerical/mip.pyx"
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip.pyx", line 444:
     sage: p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - requires
 GLPK
 Exception raised:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_12[6]>", line 1, in <module>
         p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - requires
 GLPK###line 444:
     sage: p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - requires
 GLPK
       File "mip.pyx", line 453, in
 sage.numerical.mip.MixedIntegerLinearProgram.write_mps
 (sage/numerical/mip.c:4108)
         raise NotImplementedError("You need GLPK installed to use this
 function. To install it, you can type in Sage: install_package('glpk')")
     NotImplementedError: You need GLPK installed to use this function. To
 install it, you can type in Sage: install_package('glpk')
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip.pyx", line 476:
     sage: p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - requires GLPK
 Exception raised:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_13[6]>", line 1, in <module>
         p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - requires
 GLPK###line 476:
     sage: p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - requires GLPK
       File "mip.pyx", line 484, in
 sage.numerical.mip.MixedIntegerLinearProgram.write_lp
 (sage/numerical/mip.c:4329)
         raise NotImplementedError("You need GLPK installed to use this
 function. To install it, you can type in Sage: install_package('glpk')")
     NotImplementedError: You need GLPK installed to use this function. To
 install it, you can type in Sage: install_package('glpk')
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip.pyx", line 978:
     sage: p.solve(solver='GLPK', objective_only=True) # optional -
 requires GLPK
 Expected:
     Traceback (most recent call last):
     ...
     RuntimeError
 Got:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_23[21]>", line 1, in <module>
         p.solve(solver='GLPK', objective_only=True) # optional - requires
 GLPK###line 978:
     sage: p.solve(solver='GLPK', objective_only=True) # optional -
 requires GLPK
       File "mip.pyx", line 1004, in
 sage.numerical.mip.MixedIntegerLinearProgram.solve
 (sage/numerical/mip.c:7627)
         raise NotImplementedError("GLPK is not installed and cannot be
 used to solve this MixedIntegerLinearProgram. To install it, you can type
 in Sage: install_package('glpk')")
     NotImplementedError: GLPK is not installed and cannot be used to solve
 this MixedIntegerLinearProgram. To install it, you can type in Sage:
 install_package('glpk')
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip.pyx", line 1175:
     sage: p.solve(solver="GLPK") # optional - requires GLPK
 Expected:
     Traceback (most recent call last):
     ...
     MIPSolverException: 'GLPK : Solution is undefined'
 Got:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_30[9]>", line 1, in <module>
         p.solve(solver="GLPK") # optional - requires GLPK###line 1175:
     sage: p.solve(solver="GLPK") # optional - requires GLPK
       File "mip.pyx", line 1004, in
 sage.numerical.mip.MixedIntegerLinearProgram.solve
 (sage/numerical/mip.c:7627)
         raise NotImplementedError("GLPK is not installed and cannot be
 used to solve this MixedIntegerLinearProgram. To install it, you can type
 in Sage: install_package('glpk')")
     NotImplementedError: GLPK is not installed and cannot be used to solve
 this MixedIntegerLinearProgram. To install it, you can type in Sage:
 install_package('glpk')
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip.pyx", line 1191:
     sage: p.solve(solver="GLPK") # optional - requires GLPK
 Expected:
     Traceback (most recent call last):
     ...
     MIPSolverException: 'GLPK : Solution is undefined'
 Got:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_30[16]>", line 1, in <module>
         p.solve(solver="GLPK") # optional - requires GLPK###line 1191:
     sage: p.solve(solver="GLPK") # optional - requires GLPK
       File "mip.pyx", line 1004, in
 sage.numerical.mip.MixedIntegerLinearProgram.solve
 (sage/numerical/mip.c:7627)
         raise NotImplementedError("GLPK is not installed and cannot be
 used to solve this MixedIntegerLinearProgram. To install it, you can type
 in Sage: install_package('glpk')")
     NotImplementedError: GLPK is not installed and cannot be used to solve
 this MixedIntegerLinearProgram. To install it, you can type in Sage:
 install_package('glpk')
 **********************************************************************
 4 items had failures:
    1 of   7 in __main__.example_12
    1 of   7 in __main__.example_13
    1 of  22 in __main__.example_23
    2 of  17 in __main__.example_30
 ***Test Failed*** 5 failures.
 For whitespace errors, see the file
 /Users/alexandre/.sage//tmp/.doctest_mip.py
          [3.1 s]
 sage -t -optional "devel/sage-linear/sage/numerical/mip_coin.pyx"
          [2.6 s]
 sage -t -optional "devel/sage-linear/sage/numerical/mip_glpk.pyx"
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip_glpk.pyx", line 41:
     sage: from sage.numerical.mip_glpk import solve_glpk    # optional -
 requires Glpk
 Exception raised:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_1[2]>", line 1, in <module>
         from sage.numerical.mip_glpk import solve_glpk    # optional -
 requires Glpk###line 41:
     sage: from sage.numerical.mip_glpk import solve_glpk    # optional -
 requires Glpk
     ImportError: No module named mip_glpk
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip_glpk.pyx", line 49:
     sage: solve_glpk(p, objective_only=True)     # optional - requires
 Glpk
 Exception raised:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_1[9]>", line 1, in <module>
         solve_glpk(p, objective_only=True)     # optional - requires
 Glpk###line 49:
     sage: solve_glpk(p, objective_only=True)     # optional - requires
 Glpk
     NameError: name 'solve_glpk' is not defined
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip_glpk.pyx", line 123:
     sage: p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - requires
 GLPK
 Exception raised:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_2[6]>", line 1, in <module>
         p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - requires
 GLPK###line 123:
     sage: p.write_mps(SAGE_TMP+"/lp_problem.mps") # optional - requires
 GLPK
       File "mip.pyx", line 453, in
 sage.numerical.mip.MixedIntegerLinearProgram.write_mps
 (sage/numerical/mip.c:4108)
         raise NotImplementedError("You need GLPK installed to use this
 function. To install it, you can type in Sage: install_package('glpk')")
     NotImplementedError: You need GLPK installed to use this function. To
 install it, you can type in Sage: install_package('glpk')
 **********************************************************************
 File "/Users/alexandre/Applications/sage/devel/sage-
 linear/sage/numerical/mip_glpk.pyx", line 164:
     sage: p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - requires GLPK
 Exception raised:
     Traceback (most recent call last):
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File "/Users/alexandre/Applications/sage/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_3[6]>", line 1, in <module>
         p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - requires
 GLPK###line 164:
     sage: p.write_lp(SAGE_TMP+"/lp_problem.lp") # optional - requires GLPK
       File "mip.pyx", line 484, in
 sage.numerical.mip.MixedIntegerLinearProgram.write_lp
 (sage/numerical/mip.c:4329)
         raise NotImplementedError("You need GLPK installed to use this
 function. To install it, you can type in Sage: install_package('glpk')")
     NotImplementedError: You need GLPK installed to use this function. To
 install it, you can type in Sage: install_package('glpk')
 **********************************************************************
 3 items had failures:
    2 of  10 in __main__.example_1
    1 of   7 in __main__.example_2
    1 of   7 in __main__.example_3
 ***Test Failed*** 4 failures.
 For whitespace errors, see the file
 /Users/alexandre/.sage//tmp/.doctest_mip_glpk.py
          [2.6 s]
 sage -t -optional "devel/sage-linear/sage/numerical/optimize.py"
          [5.7 s]
 sage -t -optional "devel/sage-linear/sage/numerical/test.py"
          [5.7 s]

 ----------------------------------------------------------------------
 The following tests failed:


         sage -t -optional "devel/sage-linear/sage/numerical/mip.pyx"
         sage -t -optional "devel/sage-linear/sage/numerical/mip_glpk.pyx"
 Total time for all tests: 33.9 seconds
 }}}

 4. I then installed GLPK, and then all tests passed, with the command
 `sage -t *` as well as the command `sage -t -optional *`.

 If I'm not mistaken and if my installation is not broken, it means that
 the examples you included in the docstring are based on GLPK and not CBC.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7311#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to