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

Commit

Permalink
warm-start interactive_backend.solve() by providing basic_variables
Browse files Browse the repository at this point in the history
  • Loading branch information
yuan-zhou committed Apr 11, 2022
1 parent 5abb5fe commit 725b31d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/sage/numerical/backends/interactivelp_backend.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ cdef class InteractiveLPBackend(GenericBackend):
coefficients=*) \
except -1

cpdef int solve(self, basic_variables=*) except -1

cpdef dictionary(self)

cpdef interactive_lp_problem(self)
16 changes: 14 additions & 2 deletions src/sage/numerical/backends/interactivelp_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -591,16 +591,28 @@ cdef class InteractiveLPBackend:
"""
self.add_variable(coefficients=zip(indices, coeffs))

cpdef int solve(self) except -1:
cpdef int solve(self, basic_variables=[]) except -1:
"""
Solve the problem.
INPUT:
- ``basic_variables`` -- optional list of basic variables for warm-start; The provided basis must be feasible.
.. NOTE::
This method raises ``MIPSolverException`` exceptions when
the solution cannot be computed for any reason (none
exists, or the LP solver was not able to find it, etc...)
``basic_variables`` can be one of the following:
- a list of indices. The indices (starting at 1) correspond to that of the vector formed by `self.interactive_lp_problem().decision_variables()` and `self.interactive_lp_problem().slack_variables()`. Remark that `self.interactive_lp_problem()` can have more variables and constraints than that of `self` if `self` has free variables or `==` constraints.
- a list of the names of the variables in `self.interactive_lp_problem()`.
If ``basic_variables`` is provided but is infeasible, then ValueError will be raised.
EXAMPLES::
sage: from sage.numerical.backends.generic_backend import get_solver
Expand All @@ -619,7 +631,7 @@ cdef class InteractiveLPBackend:
## FIXME: Perhaps also pass the problem name as objective name
lp_std_form, transformation = self.lp.standard_form(transformation=True)
self.lp_std_form, self.std_form_transformation = lp_std_form, transformation
output = lp_std_form.run_revised_simplex_method()
output = lp_std_form.run_revised_simplex_method(basic_variables)
## FIXME: Display output as a side effect if verbosity is high enough
d = self.final_dictionary = lp_std_form.final_revised_dictionary()
if d.is_optimal():
Expand Down

0 comments on commit 725b31d

Please sign in to comment.