#18995: Approximate LP solving: do not raise exceptions
-------------------------+-------------------------------------------------
Reporter: | Owner:
ncohen | Status: needs_review
Type: | Milestone: sage-6.9
defect | Resolution:
Priority: major | Merged in:
Component: | Reviewers:
numerical | Work issues:
Keywords: | Commit:
Authors: | f8b8becf8511fc7b652866076b0a8ebc5dc3cb86
Nathann Cohen | Stopgaps:
Report Upstream: N/A |
Branch: |
u/ncohen/18995 |
Dependencies: |
-------------------------+-------------------------------------------------
Comment (by dcoudert):
I have used many times time limits and optimality gaps with cplex without
difficulties.
{{{
sage: from sage.numerical.mip import MixedIntegerLinearProgram
sage: g = graphs.CubeGraph(9)
sage: p = MixedIntegerLinearProgram(solver="Cplex")
sage: p.solver_parameter("CPX_PARAM_EPAGAP", 100)
sage: b = p.new_variable(binary=True)
sage: p.set_objective(p.sum(b[v] for v in g))
sage: for v in g:
....: p.add_constraint(b[v]+p.sum(b[u] for u in g.neighbors(v)) <= 1)
....:
sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution
sage: p.solve()
28.0
}}}
With Coin, we don't have access to optimality gap or timelimit.
{{{
sage: p = MixedIntegerLinearProgram(solver="Coin")
sage: p.solver_parameter("mip_gap_tolerance",100)
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call
last)
<ipython-input-25-b082f5cd7a90> in <module>()
----> 1 p.solver_parameter("mip_gap_tolerance",Integer(100))
/Users/dcoudert/sage/src/sage/numerical/mip.pyx in
sage.numerical.mip.MixedIntegerLinearProgram.solver_parameter
(/Users/dcoudert/sage/src/build/cythonized/sage/numerical/mip.c:14957)()
2303 return self._backend.solver_parameter(name)
2304 else:
-> 2305 self._backend.solver_parameter(name, value)
2306
2307 cpdef sum(self, L):
/Users/dcoudert/sage/src/sage/numerical/backends/generic_backend.pyx in
sage.numerical.backends.generic_backend.GenericBackend.solver_parameter
(/Users/dcoudert/sage/src/build/cythonized/sage/numerical/backends/generic_backend.c:7780)()
907 sage: p.solver_parameter("timelimit")
# optional - Nonexistent_LP_solver
908 """
--> 909 raise NotImplementedError()
910
911
NotImplementedError:
}}}
This patch is working well and passes all tests, but you could change the
ticket description to say that it solves the issue for GLPK only.
--
Ticket URL: <http://trac.sagemath.org/ticket/18995#comment:4>
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 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-trac.
For more options, visit https://groups.google.com/d/optout.