lp_cache.hpp file
LpCache — post-solve scalar + vector cache for LinearInterface.
LpCache owns the 9 post-solve cache fields that previously lived directly on LinearInterface as m_cached_*_. Extraction is Phase 1 of the LinearInterface split.
Lifecycle:
- Default-constructed: all empty / zero / nullopt / false.
- After a successful solve: scalars (
obj_value,kappa,numrows,numcols) are set,is_optimalis true,backend_solution_freshis true, and the three vectors hold the post-solve primal / dual values (compress mode only — underLowMemoryMode::offthe live backend is the source of truth and the vectors stay empty). - On structural mutation:
invalidate_optimal_on_mutation()flipsis_optimalto false; the vectors are not touched (callers may still read them via the empty-fallback path used by cut-construction code after backend release). - On backend reconstruct:
mark_solution_fresh(false)— scalars + vectors stay; only the "live backend has fresh solution" gate is cleared until the nextresolve()lands.
Invariants (asserted in debug, see validate_consistency()):
- C1.
is_optimal()⇒col_sol().size() == numcols(). - C2.
invalidate_optimal_on_mutation()is idempotent and does NOT clear the col_sol / col_cost / row_dual vectors. - C3.
drop_solution_caches()clearscol_sol+col_cost, leavesrow_dualand the scalars intact. - C4.
set_is_optimal(true)is the only path that flips the optimality flag to true. - C5.
mark_solution_fresh(true)fires insidetimed_solvebefore the optimality check;mark_solution_fresh(false)fires on everyreconstruct_backend(). - C6.
size_bytes()reports the total bytes held by the three vectors. - C7.
col_sol_buffer(n)/col_cost_buffer(n)/row_dual_buffer(n)resizethe underlying vector and return a span over it — the only write entry- point that backends use viaSolverBackend::fill_*. - C8. Default-constructed
LpCache{}reportsis_optimal() == false,obj_value() == 0.0,numrows() == 0,numcols() == 0,kappa() == std::nullopt, all spans empty.
Namespaces
- namespace gtopt
Classes
- class gtopt::LpCache
- Post-solve cache for LinearInterface.