Skip to content

Add hv_approx_fpras() in R (FPRAS hypervolume approximation) - #77

Closed
MLopez-Ibanez with Copilot wants to merge 3 commits into
mainfrom
copilot/add-hv-approx-fpras
Closed

Add hv_approx_fpras() in R (FPRAS hypervolume approximation)#77
MLopez-Ibanez with Copilot wants to merge 3 commits into
mainfrom
copilot/add-hv-approx-fpras

Conversation

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Ports hv_approx_fpras() from PR #70 to R. The function implements Bringmann & Friedrich's FPRAS algorithm, returning with probability (1-δ) an ε-approximation of the hypervolume — unlike the Monte-Carlo methods in hv_approx(), which take a fixed sample count.

x <- matrix(c(5, 5, 4, 6, 2, 7, 7, 4), ncol = 2, byrow = TRUE)
hypervolume(x, ref = 10)          # 38.0 (exact)
hv_approx_fpras(x, ref = 10, epsilon = 0.01, delta = 0.1)  # ≈38.0

Runtime scales as O(nm/ε² · log(1/δ)) — halving epsilon quadruples runtime.

Changes

  • r/R/hv_approx.Rhv_approx_fpras() with roxygen2 docs (math, @warning, @seealso, @references, doctests)
  • r/src/Rmoocore.c + r/src/init.h — C wrapper hv_approx_fpras_C (seed, epsilon, delta)
  • r/NAMESPACE — export new function
  • r/tests/testthat/test-hv_approx.R — error tests and accuracy loop over dims 3–10
  • r/vignettes/articles/hv_approx.Rmd — new FPRAS section: error vs. epsilon boxplot and CPU time vs. epsilon line plot (ported from plot_hv_approx.py)
  • r/inst/REFERENCES.bib — add Vose1991alias (Walker-Vose alias method)
  • r/NEWS.md — entry for new function
  • c/hvapprox.c — add m == 0 guard before division to prevent undefined behaviour when budget is exhausted before any dominating pair is found
  • c/rng.h — fix DOI (10.1145/3230636)
  • c/hvapprox.h — fix spurious comma in comment

Copilot AI and others added 2 commits August 11, 2026 07:54
…n, and NEWS update

Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Copilot AI changed the title Add hv_approx_fpras() R function (FPRAS hypervolume approximation) Add hv_approx_fpras() in R (FPRAS hypervolume approximation) Aug 11, 2026
Copilot AI requested a review from MLopez-Ibanez August 11, 2026 08:01
@github-actions

Copy link
Copy Markdown

📚 Python docs preview for this PR

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.83234% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.32%. Comparing base (6e7ab00) to head (bc5d317).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
+ Coverage   77.13%   77.32%   +0.18%     
==========================================
  Files          69       70       +1     
  Lines        7195     7364     +169     
  Branches     1434     1465      +31     
==========================================
+ Hits         5550     5694     +144     
- Misses       1277     1298      +21     
- Partials      368      372       +4     
Flag Coverage Δ
R 71.70% <85.88%> (+0.45%) ⬆️
python 73.12% <0.00%> (-1.62%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
C 73.30% <81.02%> (+0.26%) ⬆️
R 81.50% <96.66%> (+0.57%) ⬆️
Python tests 100.00% <ø> (ø)
Python src 81.89% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MLopez-Ibanez

Copy link
Copy Markdown
Contributor

@copilot You need to run roxygen2 and doctest to generate the appropriate .Rd documentation and .R test file. Otherwise the CI tests will fail.

Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot You need to run roxygen2 and doctest to generate the appropriate .Rd documentation and .R test file. Otherwise the CI tests will fail.

Done in commit Fix test, generate hv_approx_fpras.Rd, update doctest file. Since R is not available in the sandbox, I generated the files manually:

  • r/man/hv_approx_fpras.Rd — created with the correct roxygen2 structure (description, details, arguments inherited from hv_approx, \section{Warning}, seealso, references, examples).
  • r/tests/testthat/test-doctest-hv_approx.R — added the "Doctest: hv_approx_fpras" test block matching the @doctest annotations in R/hv_approx.R.
  • r/tests/testthat/test-hv_approx.R line 16 — also fixed the failing CI test: matrix(c(0,0)) with reference=c(1,1) has HV=1 (not 0), so changed to matrix(c(2,2)) which correctly gives HV=0.

@github-actions

Copy link
Copy Markdown

📚 R docs preview for this PR

@MLopez-Ibanez
MLopez-Ibanez deleted the copilot/add-hv-approx-fpras branch August 11, 2026 13:30
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.

2 participants