Skip to content

Pre-processing (exfoliation, centers, Dikin rounding), and lim.redpol() without limSolve::lsei - #17

Open
morgancolet wants to merge 6 commits into
mainfrom
dev_morgan
Open

morgancolet wants to merge 6 commits into
mainfrom
dev_morgan

Conversation

@morgancolet

Copy link
Copy Markdown
Collaborator

Summary

  • New pre-processing functions for a polytope {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 calls limSolve::lsei(): its reference point x0 is a
    Chebyshev 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.

  1. d94ec04 Build fix for clang >= 19 (5 lines in random_point_generators.hpp).
  2. cc4bb46 roxygen2 8.1.0, and @export on plot.lim (generated changes only).
  3. 31f1be9 pol.exfoliate(), lim.exfoliate().
  4. bc87f5d pol.center(), lim.center().
  5. 27f8099 pol.round(), lim.round().
  6. a097da5 lim.redpol() without lsei(), and rlim() starting from the origin.

Points for review

  • Regenerating the documentation now requires roxygen2 >= 8.1.0. The NAMESPACE on main
    was out of date with the sources: roxygen dropped S3method(plot, lim).
  • pol.center(A = NULL, B = NULL, G, H, ...) follows the argument order of pol.ranges().
  • Zero rows of G left by lim.redpol() (inequalities constant on {Ax = B}, six in the
    BOWF 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 for
    x0.
  • pol.round() returns G, H, x0 and Z, as lim.redpol() does: red2full() maps a
    sample of the rounded polytope back, onto the unknowns of the lim for lim.round().
  • Behaviour change: a hidden equality that fixes no unknown now makes lim.redpol() stop
    with an error, instead of returning a reduced polytope of the wrong dimension.
  • The change in rlim() is compatible with fix: project starting_point into reduced space #16: the default starting point is passed to
    the walk directly, and the argument starting_point is left as it is.
  • The help pages are kept short.

Known issues, not addressed here

  • lim.redpol(test = TRUE) does not detect a hidden equality that fixes no unknown.
  • volesti does not check the inner ball computed by lp_solve (radius -1 on failure):
    rlim(Hpol = ...) is still affected.
  • With a starting_point and no jmp, the BiW walk does not move (L = 0).

Tests

  • 41 tests, 226 assertions, all passing (R 4.6.1, macOS, clang 21).
  • On 18 declaration files (BOWF-short, Aurore, 8 BOWF, 8 REEF): reduction, exfoliation and
    rounding succeed, and rlim() samples 200 points with BiW and MiW within the polytope
    (deviations below 3e-12, that is, rounding errors).

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 morgancolet changed the title Dev morgan Pre-processing (exfoliation, centers, Dikin rounding), and lim.redpol() without limSolve::lsei Oct 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant