Repository navigation
Migrated to HiGHS - #507
Conversation
vissarion
left a comment
There was a problem hiding this comment.
Thanks @DimitriosPavlouGR for this PR!
In general it is in good shape and very useful for volesti! I have a number of comments though:
-
Five of the eight new ctest entries run nothing. The
-tc=filters in
test/CMakeLists.txtdon't match theTEST_CASEnames, so doctest runs zero
cases and exits 0:- L420
max_inner_ball_lpvstest_max_inner_ball_lp - L429/430
test_v_membership,test_v_line_intersectionvstest_membership,line_intersection - L434/435
test_z_membership,testz_line_intersectionvs the same two names
- L420
-
A failed inner-ball solve is no longer reported (
hpolytope.h~L160).
Ifcompute_chebychev_ballfails,has_ball = falsebut the function returns the
old_inner_ball(empty, or the ball of an earlierA, b). It used to return
radius −1. The volume functions only rejectInnerBall().second < 0, so they carry
on with a wrong or 0-dimensional ball. What if we return(Point(1), -1)again. -
is_feasible()reports feasible when the LP fails (vpolyintersectvpoly.h~L136).
point_in_intersectionsets empty only forkInfeasible. Every other non-optimal
status gives{Point(d), false}, so!res.value.secondistrue. The lp_solve
version treated every non-OPTIMAL result as empty. Is this needed like this for your preprocessing work? -
Downstream bindings break (this should not be a blocker but should be fixed in downstream projects when we upgrade volesti there):
- volestipy builds with
-DDISABLE_LPSOLVE(CMakeLists.txt L81). That macro is
now ignored, soHighs.his required and the build fails. - Rvolesti
src/inner_ball.cpp:77calls the removedComputeChebychevBall. It
also exposesinner_ball(P, lpsolve = TRUE)to R users. CRAN forbids downloads at
install time, soFetchContentcan't work there. Rvolesti needs vendored HiGHS
sources, orLinkingToan R package that ships them (to be verified). Otherwise R
loses V-polytope and zonotope support. - dingo vendors lp_solve only (
setup.py) and pins volesti atc3109bb. The
first bump past this PR fails onHighs.h. dingo already depends on HiGHS through
pyoptinterface[highs], which may be a route.
- volestipy builds with
-
Callers ignore
.solved(vpolytope.h~L444,zpolytope.h~L428,
vpolyintersectvpoly.h~L155). On failureintersect_line_Vpolyreturns 0 (it used
to return −1) and leavesconv_combholding the previous call's values. A billiard
step can then reflect off the wrong facet.IntersectionOfVpoly::ComputeInnerBall
can loop forever when the LP keeps failing. The new result type is the PR's main
improvement, but no caller uses it. -
Tiny solution values are not zeroed (
vpolyoracles.hpp~L161).compute_reflection
selects facet vertices withconv_comb[j] > 0.0into a fixedd×dmatrix. lp_solve
zeroed values below its epsilon; HiGHS can return values like 1e-17. With more than
d positive weights this writes out of bounds. Use a tolerance.
(inferred, not reproduced) -
Zonotopeis now limited todouble. The members aredouble*, but some
constructors still allocatenew NT[...], soZonotope<Cartesian<float>>no longer
compiles. Therow,colno,*_membuffers in VPolytope and Zonotope are now
unused but still allocated and copied. Their move constructors keep the existing
colno = nullptrslip, which should beother.colno = nullptr. Delete the buffers
and makeconv_combastd::vector<double>; that also removes the bug. -
GetHighs()uses HiGHS's default build options (external/cmake-files/HiGHS.cmake).
HiGHS v1.10.0 by default builds its own unit tests (and adds them to our ctest), its
examples, thehighsexecutable and a shared library.FETCHCONTENT_BASE_DIR
points into the source tree, so every example and the test build share one
external/_deps/highs-build, despite different flags. The new.gitignoreentries
(*.so,examples/*/lib/) hide the shared-library output instead of fixing it.
BeforeFetchContent_MakeAvailable, setBUILD_TESTING,BUILD_EXAMPLESand
BUILD_SHARED_LIBSto OFF. Also addGIT_SHALLOW TRUE, try
find_package(highs CONFIG)first, and keep the build directory inside the caller's
binary directory. -
Each oracle call constructs a
Highsobject and adds rows one at a time.
intersect_double_line_Vpolyandintersect_line_zononow build and solve two
separate models. The lp_solve version built one model, solved it, flipped the
objective sense and re-solved, which reused the first solution. Ray shooting runs on
every walk step. Please build the model once withpassModel(CSC format), call
changeObjectiveSenseandrun()again on the same instance, and post timings of
volume_cb_vpolytope,volume_cb_zonotopesand the V∩V test before and after.
…ance and HiGHS build options
…pped objective sense
Use HiGHS and DISABLE_HIGHS in the new edge-case and standalone-header tests
|
Thanks @vissarion for the detailed review! Here's the status of each point. 1. Test filters - You can consider this fixed, the filters now match the names.
|
vissarion
left a comment
There was a problem hiding this comment.
Thanks @DimitriosPavlouGR, nice work! Points 1, 2, 3, 6 and 8 look good to me, and so does the passModel change. On your question in 7: yes, the default copy constructors are fine, copying _inner_ball (and sigma/Q0) is actually the correct behaviour. For 4, let's open issues in Rvolesti, volestipy and dingo once this is merged.
A few things remain:
- IntersectionOfVpoly::ComputeInnerBall still ignores .solved (vpolyintersectvpoly.h ~L152-169). This is the loop I mentioned in 5. On the first failed solve the default Point(d) is pushed as a vertex; every later failure returns the same point, hits continue and never increments num, so the loop never terminates if the LP keeps failing. Please check res.solved, skip failed solves, and give up after a bounded number of attempts by returning radius -1 (callers already check InnerBall().second < 0).
- VPolytope::ComputeInnerBall ignores .solved (vpolytope.h ~L303). A failed intersect_double_line_Vpoly yields (0, 0), so the radius silently becomes 0 instead of -1. Please return (Point(_d), -1) on failure, as Zonotope::ComputeInnerBall now does.
I'm fine with keeping the (0, 0) lp_solve behaviour in the line_intersect* wrappers for this PR; we can use .solved there in a follow-up. - New in 5916a0f: input coefficients are dropped (vpolyoracles.hpp ~L63 and ~L77). line_intersection_lp now skips constraint-matrix entries with |V(j,i)| < 1e-9, and the same for v. The lp_solve version kept every entry. Since the threshold is absolute, the oracle now depends on scale: a V-polytope or zonotope with coordinates of order 1e-10 loses all its coefficients and the LP solves a different problem. The tolerance belongs on the solution (as you did for conv_comb), not on the input. Could you add every entry and let HiGHS handle tiny values.
- Dead code (zpolytope.h ~L59-75): please delete the commented-out constructor.
- Zonotope<Cartesian>: nothing in the tests instantiates it, so please add a small compile check (e.g. a test case that builds a float zonotope and calls line_positive_intersect) so it doesn't break again.
- Timings: both columns in your table are HiGHS. Could you add a column for develop (lp_solve) on the same machine for the same five tests? That tells us whether the migration itself costs or saves time on the walk-heavy V/Z tests.
|
Thanks @vissarion for the feedback. I have addressed all the issues.
On these walk-heavy V/Z tests the migration currently costs time: HiGHS is 1.6–3.5× slower than lp_solve. Should I try to close the gap in this PR, or in a later one? I suspect that the inefficiency might have to do with us using default HiGHS settings. But fine tuning could take time. So let me know if you consider this a blocker. |
|
Thanks @DimitriosPavlouGR for the fixes. Performance could be fixed in a next PR indeed. But clang should be fixed here, please use |
|
Looking at the performance issue once more I think it make sense to try the following fix in this PR. Each oracle call still creates a new Highs object and model on every walk step. Try keeping one Highs instance per polytope (a mutable member like conv_comb), and per call only update the row bounds (p) and the v column, re-solving warm from the previous basis. Consecutive walk points are close, so the old basis should be nearly optimal. If that doesn't close most of the gap, we merge and open an issue to track it. |
|
Thanks @vissarion! Updates since our last discussion:
Volume tests (CPU time, same machine, each test run alone)
Reusing the model reduced the gap. These tests only go up to d = 20, where each LP is tiny and the fixed per-call cost of HiGHS dominates. So based on our last discussion I created a custom benchmark to check the behavior on higher dimensions. Scaling with d (
|
| d | line_intersect lp_solve |
HiGHS | speedup | line_positive_intersect lp_solve |
HiGHS | speedup | billiard lp_solve | HiGHS | speedup |
|---|---|---|---|---|---|---|---|---|---|
| 10 | 128 µs | 136 µs | 0.94× | 47 µs | 43 µs | 1.09× | 0.004 s | 0.004 s | 0.97× |
| 20 | 155 µs | 161 µs | 0.96× | 83 µs | 67 µs | 1.25× | 0.017 s | 0.015 s | 1.18× |
| 40 | 382 µs | 370 µs | 1.03× | 206 µs | 146 µs | 1.41× | 0.056 s | 0.040 s | 1.40× |
| 60 | 721 µs | 605 µs | 1.19× | 388 µs | 263 µs | 1.48× | 0.151 s | 0.108 s | 1.40× |
| 80 | 1140 µs | 942 µs | 1.21× | 603 µs | 411 µs | 1.47× | 0.391 s | 0.268 s | 1.46× |
| 100 | 1635 µs | 1344 µs | 1.22× | 868 µs | 608 µs | 1.43× | 0.660 s | 0.421 s | 1.57× |
| 150 | 3307 µs | 2331 µs | 1.42× | 1729 µs | 1066 µs | 1.62× | 2.19 s | 1.39 s | 1.57× |
| 200 | 5509 µs | 3744 µs | 1.47× | 2847 µs | 1787 µs | 1.59× | 4.75 s | 3.01 s | 1.58× |
Zonotope (2d generators)
| d | line_intersect lp_solve |
HiGHS | speedup | line_positive_intersect lp_solve |
HiGHS | speedup | billiard lp_solve | HiGHS | speedup |
|---|---|---|---|---|---|---|---|---|---|
| 10 | 0.10 ms | 0.08 ms | 1.15× | 0.08 ms | 0.05 ms | 1.51× | 0.009 s | 0.006 s | 1.49× |
| 20 | 0.35 ms | 0.19 ms | 1.87× | 0.32 ms | 0.14 ms | 2.25× | 0.062 s | 0.028 s | 2.24× |
| 40 | 2.20 ms | 0.74 ms | 2.99× | 2.09 ms | 0.63 ms | 3.31× | 0.42 s | 0.14 s | 3.12× |
| 60 | 6.18 ms | 2.00 ms | 3.08× | 5.97 ms | 1.80 ms | 3.31× | 1.29 s | 0.42 s | 3.09× |
| 80 | 14.5 ms | 4.5 ms | 3.21× | 14.1 ms | 4.2 ms | 3.39× | 4.24 s | 1.25 s | 3.39× |
| 100 | 29.8 ms | 8.7 ms | 3.41× | 29.4 ms | 8.3 ms | 3.53× | 11.1 s | 2.79 s | 3.97× |
| 150 | 110.9 ms | 34.0 ms | 3.26× | 109.4 ms | 33.2 ms | 3.29× | 58.3 s | 12.1 s | 4.81× |
| 200 | 290.8 ms | 89.5 ms | 3.25× | 288.5 ms | 88.2 ms | 3.27× | 250.8 s | 31.3 s | 8.00× |
So our intuition was correct that HiGHS should overtake lp_solve as d grows. Please let me know if you'd like further changes. After you approve the workflow runs, we can check if the changes covered all the compiling issues.
vissarion
left a comment
There was a problem hiding this comment.
Great work Dimitris! I approved the RP. I left two minor comments inline. Another one is about the Highs version, it seems that v1.10.0 fails to compile on GCC ≥ 15, why not bumping to v.1.15.1?
| int is_in(Point const& p, NT tol=NT(0)) const | ||
| { | ||
| if(memLP_Zonotope(V, p, row_mem, colno_mem)) | ||
| if(memLP_Zonotope(V, p).value) |
There was a problem hiding this comment.
here you should test .solved and only if it is correct to use the value.
There was a problem hiding this comment.
I updated the code to reflect this.
There was a problem hiding this comment.
this should be deleted, there is not ComputeChebychevBall anymore
Thanks @vissarion, I addressed the comments. As for the version, I bumped it to the one you quoted. I was under the impression v1.10.0 was the latest version that's why I had picked it. I ran the tests locally to make sure nothing breaks by using the latest version. I think you should also approve another workflow run here on github before merging just to be safe. |
|
Thanks Dimitris! It is ready now. We have to fix bindings that still use lp_solve at some point. |
Migrated to HiGHS
This PR replaces LPSolve with HiGHS (v1.10.0) as Volesti's LP solver backend. HiGHS is downloaded automatically by CMake.
Build
external/cmake-files/HiGHS.cmake:GetHighs()fetches HiGHS v1.10.0 withFetchContentand provides thehighs::highstarget.external/cmake-files/LPSolve.cmake,test/LpSolve.cmakeandexternal/cmake-files/lpsolve_modified_header_files/lp_rlp.h.test/CMakeLists.txt: every target now linkshighs::highsinstead of lp_solve, and the new LP oracle tests are registered.CMakeLists.txtfiles (all 20 that use LP code): they callGetHighs()and linkhighs::highs.crhmc_preparedidn't link an LP library at all before but it relied on lp_solve's include folder being added globally, so it now linkshighs::highsexplicitly.test/SDP/CMakeLists.txt: removed the include path toexternal/LPsolve_src/run_headers, a folder that no longer exists..gitignore: now ignores example build output (examples/*/bin/,examples/*/lib/,CPack*.cmake,*.dylib,*.so).Oracles (include/lp_oracles/)
The LPSolve based oracles have been replaced by HiGHS implementations
solve_lp.h,misc_lp.hsolve_lp.hppvpolyoracles.hvpolyoracles.hppzpolyoracles.hzpolyoracles.hpplp_oracle_options.hppAPI changes:
LPOracleResult<T>, which holdsvalueand asolvedflag (it also converts tobool). Before, a failed solve couldn't be told apart from a real answer.row,colnoorREAL*arrays; each oracle builds its own LP.ComputeChebychevBall→compute_chebychev_ballandPointInIntersection→point_in_intersection. The membership and intersection oracles keep their names:memLP_Vpoly,intersect_line_Vpoly,intersect_double_line_Vpoly,memLP_Zonotopeandintersect_line_zono.LPOracleOptionscallback (std::function<void(Highs&)>) can be passed to configure HiGHS. Without one, the oracles turn logging off and use the simplex solver, because they need vertex solutions.Callers updated
convex_bodies/hpolytope.h,orderpolytope.h:DISABLE_LPSOLVEis nowDISABLE_HIGHS. When the interior-point method fails, the Chebyshev-ball fallback now usescompute_chebychev_ball, and it reports when the LP isn't solved instead of using an invalid ball.convex_bodies/vpolytope.h,zpolytope.h,vpolyintersectvpoly.h: use the new oracle signatures, and theREALbuffers are nowdoubleorNT.generators/v_polytopes_generators.h: usespoint_in_intersection.random_walks/compute_diameter.hpp,uniform_billiard_walk.hpp,uniform_dikin_walk.hpp,volume/volume_cooling_balls.hpp,volume_sequence_of_balls.hpp: small updates for the renamed headers and functions.Tests
test/test_highs.cpp: checks the HiGHS integration on a small LP, an infeasible LP, an unbounded LP and a max-inscribed-ball LP.test/lp_oracles/:test_solve_lp.cpp(Chebyshev ball and polytope intersection),test_vpolyoracles.cpp(V-polytope membership and line intersection) andtest_zpolyoracles.cpp(zonotope membership and line intersection).Documentation
CONTRIBUTING.md: the build steps are nowcmake ..with no lp_solve path.docs/getting_started/cpp_example.md: the example usesHiGHS.cmake,GetHighs()andhighs::highs.bsb_sampling,correlation_matrices,count-linear-extensions-using-hpolytope,crhmc_prepare,crhmc_sampling,ellipsoid-sampling,full_dimensional_polytope,hpolytope-volume,logconcave,order-polytope-basics,sampling-hpolytope-with-billiard-walks,sb_sampling,vpolytope-volume): the-DLP_SOLVEinstructions are removed and each notes that HiGHS is downloaded automatically. The README forcorrelation_matricesalso fixes an existing brokencmake . … ../command.Test results
Tested on macOS with Apple clang 21. All 139 tests build; 136 pass, and the 3 failures behave the same on
develop. I compared those with a separate build ofdevelop, running each test alone:develop(lp_solve)crhmc_polytope_test_preparationvolume_cg_hpolytope_simplextest_max_ball_sparseThese come from code this PR doesn't touch: CRHMC, a random volume estimate, and volesti's own interior-point max-ball solver.
Notes
walk.template f(...)without template arguments ininclude/sampling/mmcs.hppandparallel_mmcs.hpp. That code is already ondevelopand isn't changed here; build with-Wno-error=missing-template-arg-list-after-template-kwor fix it separately.