3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-05-17 07:29:28 +00:00

Add LLL cube heuristic for integer LP (experimental, default off)

Generalize int_cube from the unit cube C = [-1/2, 1/2]^n to a
parallelepiped K = B * C where B is an n x n unimodular integer matrix
found by a monotone pairwise basis-reduction that directly minimizes
the actual cube cost

    C(B) = (1/2) * (||A * B||_1 + ||B||_1)
         = sum_r delta_row(r, B) + sum_j delta_col(j, B)

The atomic move is a single elementary column op col_j -= q * col_k
with q chosen to minimize C(B) analytically (floor/ceil of the weighted
median of breakpoints {H[r,j]/H[r,k]} and {B[i,j]/B[i,k]}).  Starting
from B = I and accepting only strict improvements makes the heuristic
*monotone-safe*: never worse than the plain int_cube.  This addresses
the regression of int_cube_hnf (branch hnf_cube), whose triangulation
can blow up the column-delta term ||B||_1.  In a 153-instance random
matrix study the HNF basis was worse than B=I by an average factor
3x-50x, while pairwise-greedy LLL was uniformly >= plain cube.

Implementation:
* src/math/lp/int_cube_lll.{h,cpp} -- the heuristic.
* The infrastructure (collect J/terms, tighten bounds, round on a
  saved x_J snapshot, lar_solver::apply_lattice_assignment) mirrors
  the earlier hnf_cube experiment; the only algorithmic change is
  swapping HNF column-reduction for the cost-minimizing pairwise
  reduction with bail-on-overflow.

New parameters:
* lp.enable_lll_cube (bool, default false) -- feature gate.
* lp.int_find_lll_cube_period (uint, default 4) -- the LLL cube is
  invoked every Nth final-check call after a plain cube failure.
  Because it is monotone-safe it runs at cube's period (4) rather
  than the throttled 16 the HNF variant used.

Statistics: arith-lll-cube-{calls,success,bail-collect,bail-build,
bail-basis,bail-tighten,bail-infeasible}.

Resource limits: rows <= 75, cols <= 150, bitsize <= 4096, max_passes
<= 8; bail above.

Validation:
* test-z3 /a: 89/89 unit tests pass.
* Smoke run on QF_LIA cut_lemmas and CAV_2009/Bromberger samples:
  no result disagreements vs. plain cube; one timeout-to-sat win on
  20180326-Bromberger/.../unbd-sage0.smt2 (-T:15).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Lev Nachmanson 2026-05-15 11:34:16 -07:00
parent 2c7b256db2
commit 5336b2c601
11 changed files with 597 additions and 2 deletions

View file

@ -1124,6 +1124,7 @@ X(kernel, qe_core, "qe core")
X(lar_solver, lar_solver, "lar solver")
X(lar_solver, add_var, "add var")
X(lar_solver, cube, "cube")
X(lar_solver, lll_cube, "lll cube")
X(lar_solver, dump_terms, "dump terms")
X(lar_solver, lar_solver_details, "lar solver details")
X(lar_solver, lar_solver_improve_bounds, "lar solver improve bounds")