Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
InteractiveLPBackend.dictionary, .interactive_lp_problem: Add docstri…
Browse files Browse the repository at this point in the history
…ngs and tests
  • Loading branch information
Matthias Koeppe committed Mar 30, 2016
1 parent 95aa6d8 commit aa21bc6
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/sage/numerical/backends/interactivelp_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1232,9 +1232,52 @@ cdef class InteractiveLPBackend:
# which would for other solvers return backend dictionaries (#18804)
"""
Return a dictionary representing the current basis.
EXAMPLE::
sage: p = MixedIntegerLinearProgram(maximization=True,\
solver="InteractiveLP")
sage: x = p.new_variable(nonnegative=True)
sage: p.add_constraint(-x[0] + x[1] <= 2)
sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17)
sage: p.set_objective(11/2 * x[0] - 3 * x[1])
sage: b = p.get_backend()
sage: # Backend-specific commands to instruct solver to use simplex method here
sage: b.solve()
0
sage: d = b.dictionary(); d
LP problem dictionary ...
sage: set(d.basic_variables())
{x1, x3}
sage: d.basic_solution()
(17/8, 0)
TESTS:
Compare with a dictionary obtained in another way::
sage: lp, basis = p.interactive_lp_problem()
sage: lp.dictionary(*basis).basic_solution()
(17/8, 0)
"""
return self.final_dictionary

cpdef interactive_lp_problem(self):

"""
Return the :class:`InteractiveLPProblem` object associated with this backend.
EXAMPLE::
sage: p = MixedIntegerLinearProgram(maximization=True,\
solver="InteractiveLP")
sage: x = p.new_variable(nonnegative=True)
sage: p.add_constraint(-x[0] + x[1] <= 2)
sage: p.add_constraint(8 * x[0] + 2 * x[1] <= 17)
sage: p.set_objective(11/2 * x[0] - 3 * x[1])
sage: b = p.get_backend()
sage: b.interactive_lp_problem()
LP problem ...
"""
return self.lp

0 comments on commit aa21bc6

Please sign in to comment.