Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MixedIntegerLinearProgram/HybridBackend: Reconstruct exact rational/algebraic basic solution #18735

Open
mkoeppe opened this issue Jun 19, 2015 · 55 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 19, 2015

Sometimes one can use a fast numerical LP solver to solve a problem to "optimality",
then reconstruct the primal and dual solution in rational arithmetic (or over whatever base_ring was used...) and in this way prove that this basis is indeed optimal.
MixedIntegerLinearProgram should support this mode of operation.

The current branch, on top of #20296, attempts to do this by implementing a HybridBackend, which delegates to two backends:

Ideally, in pure LP mode, both backends would support the basis-status functions that can transplant the (hopefully) optimal (hopefully-)basis from the inexact LP to the exact LP.

If the inexact LP cannot provide a basis (because its "basis" is not a basis due to numerics, or because basis-status functions are not available), one could at least try to make use of the numerical solution vector and try to reconstruct a basis, like in interior-point-to-simplex crossover (a classical paper: http://www.caam.rice.edu/caam/trs/91/TR91-32.pdf)

In MIP mode, could at least try to set the cleaned-up numerical solution vector as a known solution, to speed up branch-and-cut in the exact solver.

Sounds like a big ticket; we'll do this step by step.

#18685 provides the necessary basis-status functions (for the GLPK backend).
#18688 provides a solver-independent interface to these functions.
#18804 exposes basis status via backend dictionaries.

Depends on #18685
Depends on #18688
Depends on #20296

CC: @yuan-zhou @nathanncohen @dimpase

Component: numerical

Author: Matthias Koeppe, Yuan Zhou

Branch/Commit: u/yzh/hybrid_backend @ 50773ff

Issue created by migration from https://trac.sagemath.org/ticket/18735

@mkoeppe mkoeppe added this to the sage-6.8 milestone Jun 19, 2015
@dimpase
Copy link
Member

dimpase commented Jun 20, 2015

comment:2

Is ppl (pplLP backend, which works with exact arithmetic) too slow for you?

@dimpase
Copy link
Member

dimpase commented Jun 20, 2015

comment:3

On the other hand, a solver-independent way to get an optimal dual solution is very much welcome, as this is lacking currently, and often needed.

@dimpase

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 22, 2015

comment:5

Replying to @dimpase:

Is ppl (pplLP backend, which works with exact arithmetic) too slow for you?

Dima, ppl's implementation of the double description method is very good, but its LP solver is not suitable for problems of even moderate sizes.

@dimpase
Copy link
Member

dimpase commented Jun 23, 2015

comment:6

Replying to @mkoeppe:

Replying to @dimpase:

Is ppl (pplLP backend, which works with exact arithmetic) too slow for you?

Dima, ppl's implementation of the double description method is very good, but its LP solver is not suitable for problems of even moderate sizes.

Would you mind providing an example of PPL choking on an LP doable in exact arithmetic by another solver? We use PPL's LP solver in codesize_upper_bound(...,algorithm="LP") and never saw a problem... (Although perhaps the difficulty from entry sizes dominate the the one from the dimension in this case).

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 26, 2015

comment:7

Replying to @dimpase:

Would you mind providing an example of PPL choking on an LP doable in exact arithmetic by another solver? We use PPL's LP solver in codesize_upper_bound(...,algorithm="LP") and never saw a problem... (Although perhaps the difficulty from entry sizes dominate the the one from the dimension in this case).

In our experiments here, we don't actually have numerical difficulties with floating-point based solvers; we just want to be sure that we have an exact optimal solution. With #18764 (glp_exact; please review) we have now run some tests to compare performance:

                                glp_simplex                glp_simplex+glp_exact
   glp_simplex    glp_exact     +glp_exact    ppl          + reconstruction in Sage
10  4.20            51.92             7.78    207.07          289.00
11  5.08            58.49             9.43    3451.42         574.72
12  7.55           101.72            11.32    1252.91         808.73
13  7.21           279.08            13.57    1424.28        1019.95
14  8.41           562.97            15.91    7343.37        1628.54
15 13.10           550.46            18.48    3667.93        2550.94

As you can see, PPL is much slower than pure glp_exact, and orders of magnitudes slower than glp_simplex followed by glp_exact.

However, currently when we try to reconstruct the solution from the combinatorial basis information, Sage's super slow matrix functions over the rationals get us back to roughly the same order of magnitude as PPL.

It would be interesting to know how the solvers perform on the kind of LPs that you have in mind.

@dimpase
Copy link
Member

dimpase commented Jun 29, 2015

comment:8

Replying to @mkoeppe:

It would be interesting to know how the solvers perform on the kind of LPs that you have in mind.

LPs I get would be not possible to even enter into a solver without long integers/rationals.
That's e.g. behind this function call:

sage:  codesize_upper_bound(70,8,2,algorithm="LP")
9695943911863423

more explicitly, you can do

sage: v,p,r=delsarte_bound_hamming_space(70,8,2,return_data=True)
sage: p
Mixed Integer Program  ( maximization, 71 variables, 148 constraints )

constrains of p have entries as big as 112186277816662845432.

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe changed the title MixedIntegerLinearProgram: Reconstruct exact rational basic solution MixedIntegerLinearProgram: Reconstruct exact rational/algebraic basic solution Mar 27, 2016
@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 28, 2016

Changed dependencies from #18685, #18688 to #18685, #18688, #20296

@mkoeppe mkoeppe changed the title MixedIntegerLinearProgram: Reconstruct exact rational/algebraic basic solution MixedIntegerLinearProgram/HybridBackend: Reconstruct exact rational/algebraic basic solution Mar 28, 2016
@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 28, 2016

Branch: u/mkoeppe/hybrid_backend

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 6, 2016

Commit: 0b8b78a

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 6, 2016

Last 10 new commits:

e2319b5InteractiveLPBackend.get_variable_value: Guard against standard-form transformations
e27f297InteractiveLPBackend: Make base_ring an init argument
5b0954fInteractiveLPBackend._variable_type_from_bounds: Add doctests
c4b93aaInteractiveLPBackend: Fix old-style raise statements
b0a3c1cGenericBackend: Add a missing '# optional - Nonexistent_LP_solver'
3770be0default_mip_solver: Handle 'InteractiveLP'
d91c776default_mip_solver, get_solver: Mention InteractiveLP in the documentation
eaede28get_solver: Add optional base_ring argument
184249dMixedIntegerLinearProgram: New base_ring init argument
0b8b78aHybridBackend: first draft

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 10, 2016

Changed commit from 0b8b78a to 26dad94

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 10, 2016

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

26dad94HybridBackend: first draft

@mkoeppe mkoeppe modified the milestones: sage-6.8, sage-7.4 Aug 10, 2016
@yuan-zhou
Copy link

Changed branch from u/mkoeppe/hybrid_backend to u/yzh/hybrid_backend

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 30, 2021

Changed commit from 26dad94 to 5ee7738

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 30, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

5ee7738change Cython to Python code

@yuan-zhou
Copy link

comment:35

Replying to @mkoeppe:

I still have concerns about the new interface as well. The problem now is that set_basis is not defined for any backend other than InteractiveLPBackend (and also its interface refers to internal details of that).

Do you mean set_dictionary? It has a different interface than set_basis (in #18688 to be written) since the interactive_simplex_method is indeed very special in running the simplex method on the standard form where more auxiliary variables are introduced. I couldn't think of a way to unify InteractiveLPBackend.set_dictionary with other backends' set basis methods.

But more importantly, there should be at least one example that illustrates that this new backend does something useful.

True. The current implementation enables what the first paragraph of this ticket states, by using solver = ("GLPK", "InteractiveLP") as in the examples in solve. However, it is hard to argue with doctests that this new hybrid backend is useful. Shall we close the ticket with the tag "wontfix" as in #18804?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 8, 2021

comment:36

Replying to @yuan-zhou:

Replying to @mkoeppe:

I still have concerns about the new interface as well. The problem now is that set_basis is not defined for any backend other than InteractiveLPBackend (and also its interface refers to internal details of that).

Do you mean set_dictionary?

Yes, that's what I meant.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 15, 2021

comment:37

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Mar 15, 2021
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 28, 2021

Changed commit from dc36f82 to 71ae94d

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 28, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

71ae94dReplace not hasattr(self, 'xyz') by self.xyz is None

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jul 19, 2021

comment:39

Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@dimpase
Copy link
Member

dimpase commented Dec 4, 2021

comment:40

please rebase

@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 14, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Mar 5, 2022
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 11, 2022

Changed commit from 71ae94d to b6dd9ab

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 11, 2022

Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:

c4fb42badd method objective_constant_term()
c40ac50make iterable coefficients a list so that each backend can loop over coefficients
5abb5fefix docstrings
725b31dwarm-start interactive_backend.solve() by providing basic_variables
b323cd3warm-start LPProblemStandardForm.run_revised_simplex_method by providing basic_variables
084fd16HybridBackend.solve() reconstruct exact solution
b8042f6Revert "warm-start LPProblemStandardForm.run_revised_simplex_method by providing basic_variables"
0c4a3darevise interactive_backend.solve() given starting basis
3674768set InteractiveLPBackend.current_dictionary and warm start solve from there
b6dd9abReplace not hasattr(self, 'xyz') by self.xyz is None

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 11, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

1ab3f86fix double def in interactivelp_backend.pxd

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 11, 2022

Changed commit from b6dd9ab to 1ab3f86

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 11, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

50773fffix typo in docstring of variable_upper/lower_bound

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 11, 2022

Changed commit from 1ab3f86 to 50773ff

@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.8, sage-9.9 Jan 7, 2023
@mkoeppe mkoeppe modified the milestones: sage-10.0, sage-10.1 Apr 30, 2023
@mkoeppe mkoeppe removed this from the sage-10.1 milestone Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants