On 02/23/2014 09:29 PM, Dima Pasechnik wrote:
On 2014-02-23, Dima Pasechnik <[email protected]> wrote:
On 2014-02-23, Dima Pasechnik <[email protected]> wrote:
On 2014-02-21, Benoît Darties <[email protected]> wrote:
Here is the code I run

sage: p = MixedIntegerLinearProgram("Coin")
sage: x=p.new_variable(binary=True,dim=1)
sage: p.set_min(x[0], 0.0)
sage:
sage: result=p.get_values(x);

works for me in Sage 6.1.1 on OSX 10.6.8.
oops, in fact, this does crash in the latter case, too.
(I did get_values() instead of get_values(x)...)

As well as it does crash on Linux x86_64.

the remedy is very simple: Coin's getColSolution() returns NULL
in this case, and thus
return solution[variable]
in get_variable_value() produces this crash.
So one has to check for NULL and so something meaningful if it is
NULL, e.g.
        if solution == NULL:
            return []
         else:
            return solution[variable]


Not sure whether [] is the right value, perhaps 0 might be more
uniform accross different backends...









ideally, one should simply use "if solution" or "if not solution". In this case, the following patch fixes the segv:

diff --git a/src/sage/numerical/backends/coin_backend.pyx b/src/sage/numerical/backends/coin_backend.pyx
index 4083c79..96e47d3 100644
--- a/src/sage/numerical/backends/coin_backend.pyx
+++ b/src/sage/numerical/backends/coin_backend.pyx
@@ -826,7 +826,10 @@ cdef class CoinBackend(GenericBackend):

         cdef double * solution
         solution = <double*> self.model.solver().getColSolution()
-        return solution[variable]
+        if solution:
+            return solution[variable]
+        else:
+            return []

     cpdef int ncols(self):
         r"""


--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to