Ticket #10505: trac_10505.patch

File trac_10505.patch, 1.7 KB (added by ncohen, 10 years ago)
  • sage/numerical/backends/cplex_backend.pyx

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1292861612 -3600
    # Node ID 200c9860d061c5387564b66f5a91ae4bdf1defeb
    # Parent  d740726a92bc0eef8e372e0a59c37b6cdf0a84b0
    trac 10505 - round values returned by CPLEX before forwarding them
    
    diff --git a/sage/numerical/backends/cplex_backend.pyx b/sage/numerical/backends/cplex_backend.pyx
    a b  
    870870
    871871        cdef int status
    872872        cdef int zero
     873        cdef char ctype
    873874        cdef double value
    874875        status = CPXgetx(self.env, self.lp, &value, variable, variable)
    875876        check(status)
    876877
    877         return value
     878        status = CPXgetctype(self.env, self.lp, &ctype, variable, variable)
    878879
     880        return value if (status == 3003 or ctype=='C') else round(value)
    879881
    880882    cpdef int ncols(self):
    881883        r"""
  • sage/numerical/mip.pyx

    diff --git a/sage/numerical/mip.pyx b/sage/numerical/mip.pyx
    a b  
    55is an `optimization problem <http://en.wikipedia.org/wiki/Optimization_%28mathematics%29>`_
    66in the following form
    77
    8 .. centered::
    9      `\max \{ c^T x \;|\; A x \leq b, x \geq 0 \}`
     8.. MATH::
     9     \max \{ c^T x \;|\; A x \leq b, x \geq 0 \}
    1010
    1111with given `A \in \mathbb{R}^{m,n}`, `b \in \mathbb{R}^m`,
    1212`c \in \mathbb{R}^n` and unknown `x \in \mathbb{R}^{n}`.
     
    572572        - Each element of an instance of a ``MIPVariable`` is replaced
    573573          by its corresponding numerical value.
    574574
     575        .. NOTE::
     576
     577            While a variable may be declared as binary or integer, its value as
     578            returned by the solver is of type ``float``.
     579
    575580        EXAMPLE::
    576581
    577582            sage: p = MixedIntegerLinearProgram()