Sage: Ticket #14195: Bad error management in the CPLEX interface
https://trac.sagemath.org/ticket/14195
<p>
Helloooooooooooo !!!
</p>
<p>
Recently a test did not pass in <code>generic_graph.py</code> when using CPLEX. And I got the same problem with a MILP I am work on, the two of them being probably related by their common use of constants with many decimals.
</p>
<pre class="wiki">**********************************************************************
File "/home/ncohen/.Sage/devel/sage-2/sage/graphs/generic_graph.py", line 5779:
sage: for i in range(20):
g = DiGraph()
g.allow_multiple_edges(False)
for u,v in digraphs.RandomDirectedGNP(n,RealNumber('.2')).edges(labels = False):
g.add_edge(u,v,round(random(),Integer(5)))
for u,v in digraphs.Circuit(n).edges(labels = False):
if not g.has_edge(u,v):
g.add_edge(u,v,round(random(),Integer(5)))
v2 = g.traveling_salesman_problem(use_edge_labels = True)
v1 = g.traveling_salesman_problem(constraint_generation = False, use_edge_labels = True)
c1 = sum(map(itemgetter(Integer(2)), v1.edges()))
c2 = sum(map(itemgetter(Integer(2)), v2.edges()))
if c1 != c2:
print "Error !",c1,c2
print "With constraint generation :",c2
print "Without constraint generation :",c1
break
Exception raised:
Traceback (most recent call last):
File "/home/ncohen/.Sage/local/bin/ncadoctest.py", line 1231, in run_one_test
self.run_one_example(test, example, filename, compileflags)
File "/home/ncohen/.Sage/local/bin/sagedoctest.py", line 38, in run_one_example
OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
File "/home/ncohen/.Sage/local/bin/ncadoctest.py", line 1172, in run_one_example
compileflags, 1) in test.globs
File "<doctest __main__.example_74[24]>", line 9, in <module>
v2 = g.traveling_salesman_problem(use_edge_labels = True)
File "/home/ncohen/.Sage/local/lib/python/site-packages/sage/graphs/generic_graph.py", line 5922, in traveling_salesman_problem
raise ValueError("The given graph is not hamiltonian")
ValueError: The given graph is not hamiltonian
**********************************************************************
</pre><p>
This is because the two variables that are currently used in Sage to detect whether the problem is unfeasible or unbounded do not actually say whether the PROBLEM has this property, but whether the "current solution" has "been checked to satisfy" this property. Hence, a difference.
</p>
<p>
This patch uses the correct variable. And the doctest pass, and my MILP which are NEVER unbounded are not unbounded either <code>:-P</code>
</p>
<p>
Nathann
</p>
<p>
<a class="ext-link" href="http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r5/index.jsp?topic=%2Filog.odms.cplex.help%2Frefcallablelibrary%2Fhtml%2Ffunctions%2FCPXsolninfo.html"><span class="icon"></span>http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r5/index.jsp?topic=%2Filog.odms.cplex.help%2Frefcallablelibrary%2Fhtml%2Ffunctions%2FCPXsolninfo.html</a>
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/14195
Trac 1.1.6ncohenWed, 27 Feb 2013 11:27:26 GMTstatus changed
https://trac.sagemath.org/ticket/14195#comment:1
https://trac.sagemath.org/ticket/14195#comment:1
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
</ul>
TicketncohenWed, 27 Feb 2013 11:27:36 GMTcomponent changed
https://trac.sagemath.org/ticket/14195#comment:2
https://trac.sagemath.org/ticket/14195#comment:2
<ul>
<li><strong>component</strong>
changed from <em>PLEASE CHANGE</em> to <em>linear programming</em>
</li>
</ul>
TicketdcoudertSun, 03 Mar 2013 22:41:25 GMTstatus changed; reviewer set
https://trac.sagemath.org/ticket/14195#comment:3
https://trac.sagemath.org/ticket/14195#comment:3
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>needs_info</em>
</li>
<li><strong>reviewer</strong>
set to <em>David Coudert</em>
</li>
</ul>
<p>
The patch is working and solves the issue. However, I don't understand why you put commas after some declarations. Is it a mistake or is it useful?
</p>
<pre class="wiki">+ # Solution quality
+ #
+ # The problem either has a simplex basis
+ int CPX_BASIC_SOLN,
+
+ # The problem has a primal and dual solution but no basis
+ int CPX_NONBASIC_SOLN,
+
+ # The problem has a primal solution but no corresponding dual solution
+ int CPX_PRIMAL_SOLN
+
+ # The problem has no solution
+ int CPX_NO_SOLN
</pre>
TicketncohenSun, 03 Mar 2013 23:00:05 GMTattachment set
https://trac.sagemath.org/ticket/14195
https://trac.sagemath.org/ticket/14195
<ul>
<li><strong>attachment</strong>
set to <em>trac_14195.patch</em>
</li>
</ul>
TicketncohenSun, 03 Mar 2013 23:00:49 GMTstatus changed
https://trac.sagemath.org/ticket/14195#comment:4
https://trac.sagemath.org/ticket/14195#comment:4
<ul>
<li><strong>status</strong>
changed from <em>needs_info</em> to <em>needs_review</em>
</li>
</ul>
<blockquote class="citation">
<p>
The patch is working and solves the issue. However, I don't understand why you put commas after some declarations. Is it a mistake or is it useful?
</p>
</blockquote>
<p>
Mistake ! It has no interest that I know of, and seems to be ignored by Cython. Patch updated !
</p>
<p>
Nathann
</p>
TicketdcoudertSun, 03 Mar 2013 23:30:12 GMTstatus changed
https://trac.sagemath.org/ticket/14195#comment:5
https://trac.sagemath.org/ticket/14195#comment:5
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>positive_review</em>
</li>
</ul>
<p>
Review updated as well! Good to go ;-)
</p>
TicketjdemeyerWed, 06 Mar 2013 10:27:29 GMTstatus changed; resolution, merged set
https://trac.sagemath.org/ticket/14195#comment:6
https://trac.sagemath.org/ticket/14195#comment:6
<ul>
<li><strong>status</strong>
changed from <em>positive_review</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
<li><strong>merged</strong>
set to <em>sage-5.8.beta3</em>
</li>
</ul>
Ticket