Repository navigation
Pre-processing (exfoliation, centers, Dikin rounding), and lim.redpol() without limSolve::lsei - #17
Open
morgancolet wants to merge 6 commits into
Open
morgancolet wants to merge 6 commits into
morgancolet wants to merge 6 commits into
Conversation
src/include/sampling/random_point_generators.hpp calls the walks as "walk.template apply(...)". The keyword is only allowed before an explicit template argument list, and clang 19 and above reject it: error: a template argument list is expected after a name prefixed by the template keyword Removing it changes nothing: apply() deduces its template parameter from its arguments. Five call sites.
roxygen2 8.1.0 is the current release, which any fresh installation gets. Run against this package, it rewrites DESCRIPTION and NAMESPACE at each build. This commit records that state once, so that the documentation can then be regenerated without unrelated changes. The NAMESPACE on main was also out of date with the sources: roxygen drops S3method(plot, lim), so that plot() no longer dispatches to plot.lim(). The tag @method alone does not register the method; @export does. Everything else is generated by roxygen: - DESCRIPTION: RoxygenNote becomes Config/roxygen2/version; - NAMESPACE: the imports from Rcpp are grouped in one directive, and importFrom(igraph, ...) disappears, plot.lim() calling igraph:: explicitly (igraph stays in Imports); - man/plot.lim.Rd: current wording of the argument x; - man/samplelim-package.Rd: the maintainer is also listed among the authors (role c("aut", "cre")). Regenerating the documentation now requires roxygen2 >= 8.1.0; an older version would revert these lines.
…olytope
A constraint of {x : Gx >= H} is redundant when it is implied by the
others. pol.exfoliate() finds them with one linear program per constraint
(Rglpk): constraint i is redundant if the minimum of g_i x under the
constraints still kept is at least H_i, rows being normalised. Testing
against the constraints still kept, rather than all of them, removes one
copy of a duplicated constraint, not both.
A zero row of G, which lim.redpol() leaves for an inequality constant on
{Ax = B}, always holds when H <= 0 and is removed; with H > 0 the polytope
is empty, an error. The reduced polytopes of the BOWF and REEF models have
six such rows.
lim.exfoliate() applies it to a reduced polytope, as returned by
lim.redpol(), and refuses a lim that still has equality constraints.
R/pol_utils.R holds the checks of the input, shared with the functions of
the next commits.
On BOWF-short, 28 of the 72 constraints of the reduced polytope are
redundant.
…ut equalities
pol.center(A, B, G, H) computes a center of {x : Ax = B, Gx >= H}, the
equalities being optional (arguments in the order of pol.ranges()).
lim.center() takes a lim object, full or reduced by lim.redpol().
- Chebyshev center: one linear program (Rglpk), maximise r subject to
Ax = B and g_i x - s_i r >= H_i. The ball is taken within {Ax = B}: s_i
is the norm of g_i projected on the kernel of A, zero for an inequality
constant on {Ax = B}, or for a zero row of G. A zero radius (empty or
flat polytope) is an error.
- Analytic center: damped Newton iterations on the log-barrier, in the
coordinates z of {Ax = B} (x = c + Z z, Z an orthonormal basis of the
kernel of A), from the Chebyshev center or from x0. Inequalities with
s_i = 0 are left out of the barrier. The analytic center being
affinely invariant, this is the same point as on the reduced polytope.
On the 18 declaration files at hand (BOWF-short, Aurore, 8 BOWF, 8 REEF),
both centers take less than 0.2 s, and the analytic center satisfies
Ax = B to 2e-12.
pol.round() applies to {x : Gx >= H} the change of coordinates
x = x0 + Z y, x0 being the analytic center and Z = M^(-1/2), M the Hessian
of the log-barrier at x0: the Dikin ellipsoid at x0 becomes the unit ball,
and the rounded polytope is close to isotropic. Zero rows play no part.
The result has the components G, H, x0 and Z, as for lim.redpol(): a sample
of the rounded polytope is mapped back by red2full(). lim.round() composes
x0 and Z with those of the reduction, so that red2full() maps it directly
onto the unknowns of the lim.
On the 18 declaration files at hand, after lim.redpol() and
lim.exfoliate(), the ratio of the largest to the smallest range of the
coordinates goes from 150 to 67000 down to 3 to 6.4.
lim.redpol() reduces {x : Ax = B, Gx >= H} around a point x0 of the
polytope, which lsei() provided. It is now a Chebyshev center, computed by
pol.center() with one linear program: x0 is strictly interior, and the
origin of the reduced polytope is a Chebyshev center of it.
limSolve moves from Imports to Suggests: it only serves the comparison with
xsample() in the vignette. That chunk is no longer evaluated: with limSolve
2.0.3 (CRAN, June 2026), xsample() fails in lsei(), which made the
vignette, hence R CMD check, fail.
With the Chebyshev center at the origin, the lp_solve call by which
volesti computes its inner ball may fail, and volesti does not check it:
the chain then starts from a meaningless point. This happens on two of the
18 declaration files at hand (REEFCEP and REEFTOT, points 114 away from the
polytope with BiW). rlim() therefore starts from the origin, and gives BiW
the step length volesti would take, 4 sqrt(d) r, so that lp_solve is no
longer called on this path. Zero rows (inequalities constant on {Ax = B})
are left out.
A hidden equality that fixes no unknown (x1 + x2 = 1 forced by the
inequalities, each xi still ranging over [0, 1]) is not detected by
test = TRUE. The polytope then has no interior point in {Ax = B}, and
lim.redpol() now stops with an error, instead of returning a reduced
polytope of the wrong dimension.
morgancolet
force-pushed
the
dev_morgan
branch
from
October 6, 2026 17:11
a097da5 to
2db861f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{x : Ax = B, Gx >= H}:pol.exfoliate()/lim.exfoliate()(redundant constraints),pol.center()/lim.center()(Chebyshev and analytic centers, with or without equality constraints),pol.round()/lim.round()(rounding by the Dikin ellipsoid).lim.redpol()no longer callslimSolve::lsei(): its reference pointx0is aChebyshev center, computed by
pol.center(). limSolve moves from Imports to Suggests.rlim()starts from the origin of the reduced polytope, which is now a Chebyshev center,so that volesti does not call lp_solve there: it fails on some models, unchecked.
Commits
One task per commit, to be read in order. No commit modifies a line added by an earlier one.
d94ec04Build fix for clang >= 19 (5 lines inrandom_point_generators.hpp).cc4bb46roxygen2 8.1.0, and@exportonplot.lim(generated changes only).31f1be9pol.exfoliate(),lim.exfoliate().bc87f5dpol.center(),lim.center().27f8099pol.round(),lim.round().a097da5lim.redpol()withoutlsei(), andrlim()starting from the origin.Points for review
mainwas out of date with the sources: roxygen dropped
S3method(plot, lim).pol.center(A = NULL, B = NULL, G, H, ...)follows the argument order ofpol.ranges().lim.redpol()(inequalities constant on{Ax = B}, six in theBOWF and REEF models) are handled in the new functions: removed by the exfoliation,
ignored by the centers and the rounding.
lim.redpol()itself is unchanged, except forx0.pol.round()returnsG,H,x0andZ, aslim.redpol()does:red2full()maps asample of the rounded polytope back, onto the unknowns of the lim for
lim.round().lim.redpol()stopwith an error, instead of returning a reduced polytope of the wrong dimension.
rlim()is compatible with fix: project starting_point into reduced space #16: the default starting point is passed tothe walk directly, and the argument
starting_pointis left as it is.Known issues, not addressed here
lim.redpol(test = TRUE)does not detect a hidden equality that fixes no unknown.rlim(Hpol = ...)is still affected.starting_pointand nojmp, the BiW walk does not move (L = 0).Tests
rounding succeed, and
rlim()samples 200 points with BiW and MiW within the polytope(deviations below 3e-12, that is, rounding errors).