Coder Social home page Coder Social logo

bertcarnell / lhs Goto Github PK

View Code? Open in Web Editor NEW
36.0 3.0 7.0 26.03 MB

Provides a number of methods for creating and augmenting Latin Hypercube Samples and Orthogonal Array Latin Hypercube Samples

Home Page: https://bertcarnell.github.io/lhs/

License: GNU General Public License v3.0

R 22.39% C++ 67.03% C 4.51% Shell 0.35% TeX 4.11% CMake 0.52% Dockerfile 1.08%
r latin-hypercube-sample latin-hypercube latin-hypercube-sampling orthogonal-arrays r-package lhs

lhs's Introduction

Actions Windows Code Coverage Website Doxygen CRAN Downloads CRAN
R build status Build status Coverage status CRAN status

lhs

lhs provides a number of methods for creating and augmenting Latin Hypercube Samples and Orthogonal Array Latin Hypercube Samples.

Installation

You can install the released version of lhs from CRAN with:

install.packages("lhs")

You can also install the development version of lhs from github with:

if (!require(devtools)) install.packages("devtools")
devtools::install_github("bertcarnell/lhs")

Quick Start

Create a random LHS with 10 samples and 3 variables:

require(lhs)
## Loading required package: lhs
set.seed(1776)
X <- randomLHS(n = 10, k = 3)

Create a design that is more optimal than the random case:

X_gen <- geneticLHS(10, 3, pop = 100, gen = 5, pMut = 0.1)
X_max1 <- maximinLHS(10, 3, method = "build", dup = 5)
X_max2 <- maximinLHS(10, 3, method = "iterative", optimize.on = "result", eps = 0.01, maxIter = 300)
X_imp <- improvedLHS(10, 3, dup = 5)
X_opt <- optimumLHS(10, 3, maxSweeps = 10, eps = 0.01)
Method Mean Distance Minimum Distance
6 optimum 0.7289 0.4598
2 genetic 0.7190 0.4059
4 maximin 0.7246 0.3975
5 improved 0.7028 0.3872
3 maximin 0.7296 0.3611
1 random 0.7067 0.2709

Augment an existing design:

Y <- randomLHS(10, 5)
Z <- augmentLHS(Y, 2)
dim(Z)
## [1] 12  5

Build an orthogonal array LHS:

# a 9 row design is returned because a 10 row design is not possible with these algorithms
W9 <- create_oalhs(10, 3, bChooseLargerDesign = FALSE, bverbose = FALSE)
dim(W9)
## [1] 9 3
# a 16 row design is returned because a 10 row design is not possible with these algorithms
W16 <- create_oalhs(10, 3, bChooseLargerDesign = TRUE, bverbose = FALSE)
dim(W16)
## [1] 16  3

Help

R-Help Examples of using the LHS package

StackExchange Examples:

Other

lhs package announcement: R-pkgs New R-Packages: Triangle and LHS

lhs's People

Contributors

bertcarnell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lhs's Issues

Memory Error on CRAN checks

See https://cran.r-project.org/web/checks/check_results_lhs.html .

As the 'Additional issues' show, this corrupts memory, also seen in the
checks for package mlrMBO, with

── 1. Error: mbo works with rf (@test_mbo_rf.R#97) ────────────────────────────
   REAL() can only be applied to a 'numeric', not a 'NULL'
   1: mbo(f, des, learner, ctrl) at testthat/test_mbo_rf.R:97
   2: mboTemplate(opt.problem)
   3: mboTemplate.OptProblem(opt.problem)
   4: mboTemplate(opt.state)
   5: mboTemplate.OptState(opt.state)
   6: proposePoints(opt.state)
   7: proposePointsByInfillOptimization(opt.state)
   8: measureTime({
          prop.points = infill.opt.fun(infill.crit.fun, models = models, control = control,
              par.set = par.set, opt.path = opt.path, designs = designs, iter = iter, progress = progress,
              ...)
      })
   9: force(expr)
   10: infill.opt.fun(infill.crit.fun, models = models, control = control, par.set = par.set, opt.path = opt.path, designs = designs, iter = iter, progress = progress, ...)
   11: generateDesign(control$infill.opt.focussearch.points, ps.local, randomLHS)

(currently showing on its CRAN results page).

Please correct urgently, or we will need to roll lhs back to 0.16.

==14354== Memcheck, a memory error detector
==14354== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==14354== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==14354== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R --vanilla --encoding=UTF-8
==14354== 

R Under development (unstable) (2019-01-26 r76018) -- "Unsuffered Consequences"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

[snip]

> pkgname <- "lhs"
> source(file.path(R.home("share"), "R", "examples-header.R"))
> options(warn = 1)
> library('lhs')
> 
> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("augmentLHS")
> ### * augmentLHS
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: augmentLHS
> ### Title: Augment a Latin Hypercube Design
> ### Aliases: augmentLHS
> ### Keywords: design
> 
> ### ** Examples
> 
> a <- randomLHS(4,3)
> a
          [,1]       [,2]       [,3]
[1,] 0.1717557 0.09602593 0.44246035
[2,] 0.3744248 0.92940463 0.99797652
[3,] 0.5950088 0.44436131 0.73367631
[4,] 0.8030356 0.66291844 0.03138877
> augmentLHS(a, 2)
          [,1]       [,2]       [,3]
[1,] 0.1717557 0.09602593 0.44246035
[2,] 0.3744248 0.92940463 0.99797652
[3,] 0.5950088 0.44436131 0.73367631
[4,] 0.8030356 0.66291844 0.03138877
[5,] 0.1114111 0.68465727 0.53103627
[6,] 0.9657066 0.28728516 0.30456222
> 
> 
> 
> cleanEx()
> nameEx("createAddelKemp")
> ### * createAddelKemp
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: createAddelKemp
> ### Title: Create an orthogonal array using the Addelman-Kempthorne
> ###   algorithm
> ### Aliases: createAddelKemp
> 
> ### ** Examples
> 
> A <- createAddelKemp(3, 3, TRUE)
> B <- createAddelKemp(3, 5, FALSE)
> 
> 
> 
> cleanEx()
> nameEx("createAddelKemp3")
> ### * createAddelKemp3
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: createAddelKemp3
> ### Title: Create an orthogonal array using the Addelman-Kempthorne
> ###   algorithm with 2*q^3 rows
> ### Aliases: createAddelKemp3
> 
> ### ** Examples
> 
> A <- createAddelKemp3(3, 3, TRUE)
> B <- createAddelKemp3(3, 5, FALSE)
> 
> 
> 
> cleanEx()
> nameEx("createAddelKempN")
> ### * createAddelKempN
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: createAddelKempN
> ### Title: Create an orthogonal array using the Addelman-Kempthorne
> ###   algorithm with alternate strength
> ### Aliases: createAddelKempN
> 
> ### ** Examples
> 
> A <- createAddelKempN(3, 4, 3, TRUE)
> B <- createAddelKempN(3, 4, 4, TRUE)
> 
> 
> 
> cleanEx()
> nameEx("createBose")
> ### * createBose
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: createBose
> ### Title: Create an orthogonal array using the Bose algorithm
> ### Aliases: createBose
> 
> ### ** Examples
> 
> A <- createBose(3, 3, FALSE)
> B <- createBose(5, 4, TRUE)
> 
> 
> 
> cleanEx()
> nameEx("createBoseBush")
> ### * createBoseBush
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: createBoseBush
> ### Title: Create an orthogonal array using the Bose-Bush algorithm
> ### Aliases: createBoseBush
> 
> ### ** Examples
> 
> A <- createBoseBush(4, 3, FALSE)
> B <- createBoseBush(8, 3, TRUE)
> 
> 
> 
> cleanEx()
> nameEx("createBoseBushl")
> ### * createBoseBushl
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: createBoseBushl
> ### Title: Create an orthogonal array using the Bose-Bush algorithm with
> ###   alternate strength >= 3
> ### Aliases: createBoseBushl
> 
> ### ** Examples
> 
> A <- createBoseBushl(3, 3, 3, TRUE)
> B <- createBoseBushl(4, 4, 16, TRUE)
> 
> 
> 
> cleanEx()
> nameEx("createBush")
> ### * createBush
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: createBush
> ### Title: Create an orthogonal array using the Bush algorithm
> ### Aliases: createBush
> 
> ### ** Examples
> 
> A <- createBush(3, 3, FALSE)
> B <- createBush(4, 5, TRUE)
> 
> 
> 
> cleanEx()
> nameEx("createBusht")
> ### * createBusht
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: createBusht
> ### Title: Create an orthogonal array using the Bush algorithm with
> ###   alternate strength
> ### Aliases: createBusht
> 
> ### ** Examples
> 
> A <- createBusht(3, 4, 2, TRUE)
> B <- createBusht(3, 4, 3, FALSE)
> G <- createBusht(3, 4, 4, TRUE)
Bush's (1952) theorem has a condition t<q where t
is the strength of the array and q is the number of symbols.
Here we have t = 4 and q = 3.  The array may still
be useful, but a full factorial would have at least as
many columns.
> 
> 
> 
> cleanEx()
> nameEx("create_oalhs")
> ### * create_oalhs
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: create_oalhs
> ### Title: Create an orthogonal array Latin hypercube
> ### Aliases: create_oalhs
> 
> ### ** Examples
> 
> set.seed(34)
> create_oalhs(9, 4, TRUE, FALSE)
             [,1]       [,2]       [,3]       [,4]
 [1,] 0.003632133 0.17150080 0.26553757 0.28866172
 [2,] 0.229212575 0.45013396 0.66606157 0.62949057
 [3,] 0.126626850 0.96407594 0.67523742 0.99687371
 [4,] 0.518150814 0.32242415 0.53141189 0.81277846
 [5,] 0.353800789 0.61608533 0.92301963 0.15472936
 [6,] 0.600600869 0.69969353 0.20873296 0.45940919
 [7,] 0.690266113 0.07464877 0.87633828 0.44084307
 [8,] 0.901217408 0.40585179 0.05540391 0.76277613
 [9,] 0.862973336 0.78360157 0.36756312 0.03557133
> create_oalhs(9, 4, TRUE, FALSE)
           [,1]       [,2]       [,3]       [,4]
 [1,] 0.2390839 0.25420877 0.31468304 0.26184059
 [2,] 0.0169451 0.44020724 0.43299606 0.35601821
 [3,] 0.1663715 0.83212871 0.76571332 0.87048526
 [4,] 0.3502390 0.11975577 0.65774426 0.90019772
 [5,] 0.4550270 0.46598240 0.89298040 0.06234282
 [6,] 0.5815992 0.99797912 0.06886163 0.64594518
 [7,] 0.9777961 0.09996279 0.86133671 0.54012788
 [8,] 0.8609689 0.65296981 0.14619608 0.70387802
 [9,] 0.7435299 0.75548741 0.46797940 0.20704319
> 
> 
> 
> cleanEx()
> nameEx("geneticLHS")
> ### * geneticLHS
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: geneticLHS
> ### Title: Latin Hypercube Sampling with a Genetic Algorithm
> ### Aliases: geneticLHS
> ### Keywords: design
> 
> ### ** Examples
> 
> geneticLHS(4, 3, 50, 5, .25)
           [,1]      [,2]      [,3]
[1,] 0.37297615 0.8758705 0.7422324
[2,] 0.79200507 0.2702780 0.9689422
[3,] 0.54722364 0.6986741 0.1764633
[4,] 0.04788881 0.1428368 0.2788387
> 
> 
> 
> cleanEx()
> nameEx("improvedLHS")
> ### * improvedLHS
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: improvedLHS
> ### Title: Improved Latin Hypercube Sample
> ### Aliases: improvedLHS
> ### Keywords: design
> 
> ### ** Examples
> 
> improvedLHS(4, 3, 2)
          [,1]      [,2]      [,3]
[1,] 0.1028186 0.8882591 0.3693075
[2,] 0.7052366 0.6324299 0.1830784
[3,] 0.9117650 0.1973391 0.9231829
[4,] 0.4457332 0.2558328 0.6194049
> 
> 
> 
> cleanEx()
> nameEx("maximinLHS")
> ### * maximinLHS
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: maximinLHS
> ### Title: Maximin Latin Hypercube Sample
> ### Aliases: maximinLHS
> ### Keywords: design
> 
> ### ** Examples
> 
> maximinLHS(4, 3, dup=2)
          [,1]      [,2]      [,3]
[1,] 0.6028186 0.1382591 0.3693075
[2,] 0.2052366 0.6324299 0.9330784
[3,] 0.9117650 0.9473391 0.1731829
[4,] 0.4457332 0.2558328 0.6194049
> maximinLHS(4, 3, method="build", dup=2)
           [,1]      [,2]       [,3]
[1,] 0.55990735 0.6947287 0.70271756
[2,] 0.01473359 0.1993272 0.40123332
[3,] 0.41057206 0.8638186 0.91368098
[4,] 0.96906730 0.3525210 0.08829932
> maximinLHS(4, 3, method="iterative", eps=0.05, maxIter=100, optimize.on="grid")
           [,1]       [,2]       [,3]
[1,] 0.06756504 0.03234309 0.49404267
[2,] 0.99817102 0.86952951 0.93294813
[3,] 0.65837332 0.48101862 0.08918173
[4,] 0.30330203 0.64969024 0.60786842
> maximinLHS(4, 3, method="iterative", eps=0.05, maxIter=100, optimize.on="result")
           [,1]      [,2]       [,3]
[1,] 0.86328286 0.1392899 0.58219433
[2,] 0.05317488 0.3751102 0.31943898
[3,] 0.63240765 0.7688189 0.04521659
[4,] 0.40366124 0.5711976 0.97377353
> 
> 
> 
> cleanEx()
> nameEx("oa_to_oalhs")
> ### * oa_to_oalhs
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: oa_to_oalhs
> ### Title: Create a Latin hypercube from an orthogonal array
> ### Aliases: oa_to_oalhs
> 
> ### ** Examples
> 
> oa <- createBose(3, 4, TRUE)
> oa_to_oalhs(9, 4, oa, TRUE)
==14354== Invalid read of size 1
==14354==    at 0x4C322B6: __strlen_sse2 (/builddir/build/BUILD/valgrind-3.14.0/memcheck/../shared/vg_replace_strmem.c:463)
==14354==    by 0x7BA0BF7: printf_positional (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA1B35: vfprintf (in /usr/lib64/libc-2.27.so)
==14354==    by 0x46DCE7: stdout_vfprintf (svn/R-devel/src/main/connections.c:2631)
==14354==    by 0x5404EC: Rvprintf (svn/R-devel/src/main/printutils.c:930)
==14354==    by 0x5405CB: Rprintf (svn/R-devel/src/main/printutils.c:847)
==14354==    by 0x184BB136: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==  Address 0x1595fcf0 is 0 bytes inside a block of size 73 free'd
==14354==    at 0x4C3052C: operator delete(void*) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:586)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/ext/new_allocator.h:125)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/bits/alloc_traits.h:462)
==14354==    by 0x184BD8F2: _M_destroy (/usr/include/c++/8/bits/basic_string.h:226)
==14354==    by 0x184BD8F2: _M_dispose (/usr/include/c++/8/bits/basic_string.h:221)
==14354==    by 0x184BD8F2: ~basic_string (/usr/include/c++/8/bits/basic_string.h:657)
==14354==    by 0x184BD8F2: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BB125: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==    by 0x4D8895: Rf_eval (svn/R-devel/src/main/eval.c:743)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:260)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:200)
==14354==  Block was alloc'd at
==14354==    at 0x4C2F4B6: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
==14354==    by 0xA98531E: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0xA98629A: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:1932)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:2121)
==14354==    by 0x184BD9AD: assign<char*> (/usr/include/c++/8/bits/basic_string.h:1471)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:174)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:639)
==14354==    by 0x184BD9AD: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BB125: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354== 
==14354== Invalid read of size 1
==14354==    at 0x4C322C4: __strlen_sse2 (/builddir/build/BUILD/valgrind-3.14.0/memcheck/../shared/vg_replace_strmem.c:463)
==14354==    by 0x7BA0BF7: printf_positional (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA1B35: vfprintf (in /usr/lib64/libc-2.27.so)
==14354==    by 0x46DCE7: stdout_vfprintf (svn/R-devel/src/main/connections.c:2631)
==14354==    by 0x5404EC: Rvprintf (svn/R-devel/src/main/printutils.c:930)
==14354==    by 0x5405CB: Rprintf (svn/R-devel/src/main/printutils.c:847)
==14354==    by 0x184BB136: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==  Address 0x1595fcf1 is 1 bytes inside a block of size 73 free'd
==14354==    at 0x4C3052C: operator delete(void*) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:586)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/ext/new_allocator.h:125)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/bits/alloc_traits.h:462)
==14354==    by 0x184BD8F2: _M_destroy (/usr/include/c++/8/bits/basic_string.h:226)
==14354==    by 0x184BD8F2: _M_dispose (/usr/include/c++/8/bits/basic_string.h:221)
==14354==    by 0x184BD8F2: ~basic_string (/usr/include/c++/8/bits/basic_string.h:657)
==14354==    by 0x184BD8F2: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BB125: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==    by 0x4D8895: Rf_eval (svn/R-devel/src/main/eval.c:743)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:260)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:200)
==14354==  Block was alloc'd at
==14354==    at 0x4C2F4B6: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
==14354==    by 0xA98531E: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0xA98629A: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:1932)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:2121)
==14354==    by 0x184BD9AD: assign<char*> (/usr/include/c++/8/bits/basic_string.h:1471)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:174)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:639)
==14354==    by 0x184BD9AD: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BB125: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354== 
==14354== Invalid read of size 1
==14354==    at 0x4C36B98: mempcpy (/builddir/build/BUILD/valgrind-3.14.0/memcheck/../shared/vg_replace_strmem.c:1537)
==14354==    by 0x7BCDA64: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA0799: printf_positional (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA1B35: vfprintf (in /usr/lib64/libc-2.27.so)
==14354==    by 0x46DCE7: stdout_vfprintf (svn/R-devel/src/main/connections.c:2631)
==14354==    by 0x5404EC: Rvprintf (svn/R-devel/src/main/printutils.c:930)
==14354==    by 0x5405CB: Rprintf (svn/R-devel/src/main/printutils.c:847)
==14354==    by 0x184BB136: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==  Address 0x1595fcf0 is 0 bytes inside a block of size 73 free'd
==14354==    at 0x4C3052C: operator delete(void*) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:586)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/ext/new_allocator.h:125)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/bits/alloc_traits.h:462)
==14354==    by 0x184BD8F2: _M_destroy (/usr/include/c++/8/bits/basic_string.h:226)
==14354==    by 0x184BD8F2: _M_dispose (/usr/include/c++/8/bits/basic_string.h:221)
==14354==    by 0x184BD8F2: ~basic_string (/usr/include/c++/8/bits/basic_string.h:657)
==14354==    by 0x184BD8F2: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BB125: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==    by 0x4D8895: Rf_eval (svn/R-devel/src/main/eval.c:743)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:260)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:200)
==14354==  Block was alloc'd at
==14354==    at 0x4C2F4B6: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
==14354==    by 0xA98531E: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0xA98629A: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:1932)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:2121)
==14354==    by 0x184BD9AD: assign<char*> (/usr/include/c++/8/bits/basic_string.h:1471)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:174)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:639)
==14354==    by 0x184BD9AD: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BB125: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354== 
==14354== Invalid read of size 1
==14354==    at 0x4C36BA6: mempcpy (/builddir/build/BUILD/valgrind-3.14.0/memcheck/../shared/vg_replace_strmem.c:1537)
==14354==    by 0x7BCDA64: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA0799: printf_positional (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA1B35: vfprintf (in /usr/lib64/libc-2.27.so)
==14354==    by 0x46DCE7: stdout_vfprintf (svn/R-devel/src/main/connections.c:2631)
==14354==    by 0x5404EC: Rvprintf (svn/R-devel/src/main/printutils.c:930)
==14354==    by 0x5405CB: Rprintf (svn/R-devel/src/main/printutils.c:847)
==14354==    by 0x184BB136: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==  Address 0x1595fcf2 is 2 bytes inside a block of size 73 free'd
==14354==    at 0x4C3052C: operator delete(void*) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:586)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/ext/new_allocator.h:125)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/bits/alloc_traits.h:462)
==14354==    by 0x184BD8F2: _M_destroy (/usr/include/c++/8/bits/basic_string.h:226)
==14354==    by 0x184BD8F2: _M_dispose (/usr/include/c++/8/bits/basic_string.h:221)
==14354==    by 0x184BD8F2: ~basic_string (/usr/include/c++/8/bits/basic_string.h:657)
==14354==    by 0x184BD8F2: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BB125: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==    by 0x4D8895: Rf_eval (svn/R-devel/src/main/eval.c:743)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:260)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:200)
==14354==  Block was alloc'd at
==14354==    at 0x4C2F4B6: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
==14354==    by 0xA98531E: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0xA98629A: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:1932)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:2121)
==14354==    by 0x184BD9AD: assign<char*> (/usr/include/c++/8/bits/basic_string.h:1471)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:174)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:639)
==14354==    by 0x184BD9AD: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BB125: oalhslib::printOAandUnique(bclib::matrix<int> const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (packages/tests-vg/lhs/src/oaLHS.cpp:76)
==14354==    by 0x184BBB96: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:37)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==

initial oa:
0,2,2,0
0,0,1,2
0,1,0,1
1,2,1,1
1,0,0,0
1,1,2,2
2,2,0,2
2,0,2,1
2,1,1,0

unique values per row:
0,1,2,
2,0,1,
2,1,0,
0,2,1,
==14354== Invalid read of size 1
==14354==    at 0x4C36B50: mempcpy (/builddir/build/BUILD/valgrind-3.14.0/memcheck/../shared/vg_replace_strmem.c:1537)
==14354==    by 0x7BCDA64: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA0799: printf_positional (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA1B35: vfprintf (in /usr/lib64/libc-2.27.so)
==14354==    by 0x46DCE7: stdout_vfprintf (svn/R-devel/src/main/connections.c:2631)
==14354==    by 0x5404EC: Rvprintf (svn/R-devel/src/main/printutils.c:930)
==14354==    by 0x5405CB: Rprintf (svn/R-devel/src/main/printutils.c:847)
==14354==    by 0x184BBBB4: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:44)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==  Address 0x139f24c7 is 71 bytes inside a block of size 73 free'd
==14354==    at 0x4C3052C: operator delete(void*) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:586)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/ext/new_allocator.h:125)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/bits/alloc_traits.h:462)
==14354==    by 0x184BD8F2: _M_destroy (/usr/include/c++/8/bits/basic_string.h:226)
==14354==    by 0x184BD8F2: _M_dispose (/usr/include/c++/8/bits/basic_string.h:221)
==14354==    by 0x184BD8F2: ~basic_string (/usr/include/c++/8/bits/basic_string.h:657)
==14354==    by 0x184BD8F2: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BBBA3: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:44)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==    by 0x4D8895: Rf_eval (svn/R-devel/src/main/eval.c:743)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:260)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:200)
==14354==    by 0x506AC7: R_ReplConsole (svn/R-devel/src/main/main.c:310)
==14354==  Block was alloc'd at
==14354==    at 0x4C2F4B6: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
==14354==    by 0xA98531E: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0xA98629A: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:1932)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:2121)
==14354==    by 0x184BD9AD: assign<char*> (/usr/include/c++/8/bits/basic_string.h:1471)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:174)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:639)
==14354==    by 0x184BD9AD: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BBBA3: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:44)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==    by 0x4D8895: Rf_eval (svn/R-devel/src/main/eval.c:743)
==14354== 
==14354== Invalid read of size 1
==14354==    at 0x4C36B61: mempcpy (/builddir/build/BUILD/valgrind-3.14.0/memcheck/../shared/vg_replace_strmem.c:1537)
==14354==    by 0x7BCDA64: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA0799: printf_positional (in /usr/lib64/libc-2.27.so)
==14354==    by 0x7BA1B35: vfprintf (in /usr/lib64/libc-2.27.so)
==14354==    by 0x46DCE7: stdout_vfprintf (svn/R-devel/src/main/connections.c:2631)
==14354==    by 0x5404EC: Rvprintf (svn/R-devel/src/main/printutils.c:930)
==14354==    by 0x5405CB: Rprintf (svn/R-devel/src/main/printutils.c:847)
==14354==    by 0x184BBBB4: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:44)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==  Address 0x139f24c5 is 69 bytes inside a block of size 73 free'd
==14354==    at 0x4C3052C: operator delete(void*) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:586)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/ext/new_allocator.h:125)
==14354==    by 0x184BD8F2: deallocate (/usr/include/c++/8/bits/alloc_traits.h:462)
==14354==    by 0x184BD8F2: _M_destroy (/usr/include/c++/8/bits/basic_string.h:226)
==14354==    by 0x184BD8F2: _M_dispose (/usr/include/c++/8/bits/basic_string.h:221)
==14354==    by 0x184BD8F2: ~basic_string (/usr/include/c++/8/bits/basic_string.h:657)
==14354==    by 0x184BD8F2: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BBBA3: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:44)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==    by 0x4D8895: Rf_eval (svn/R-devel/src/main/eval.c:743)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:260)
==14354==    by 0x5067EC: Rf_ReplIteration (svn/R-devel/src/main/main.c:200)
==14354==    by 0x506AC7: R_ReplConsole (svn/R-devel/src/main/main.c:310)
==14354==  Block was alloc'd at
==14354==    at 0x4C2F4B6: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
==14354==    by 0xA98531E: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0xA98629A: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.25)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:1932)
==14354==    by 0x184BD9AD: replace (/usr/include/c++/8/bits/basic_string.h:2121)
==14354==    by 0x184BD9AD: assign<char*> (/usr/include/c++/8/bits/basic_string.h:1471)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:174)
==14354==    by 0x184BD9AD: str (/usr/include/c++/8/sstream:639)
==14354==    by 0x184BD9AD: bclib::matrix<int>::toString() const (packages/tests-vg/lhs/src/matrix.h:696)
==14354==    by 0x184BBBA3: oalhslib::oaLHS(int, int, bclib::matrix<int> const&, bclib::matrix<int>&, bclib::matrix<double>&, bool, bclib::CRandom<double>&) (packages/tests-vg/lhs/src/oaLHS.cpp:44)
==14354==    by 0x184C3628: oa_to_lhs (packages/tests-vg/lhs/src/oalhs_r.cpp:57)
==14354==    by 0x495A83: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==14354==    by 0x4C884F: bcEval (svn/R-devel/src/main/eval.c:6771)
==14354==    by 0x4D870F: Rf_eval (svn/R-devel/src/main/eval.c:620)
==14354==    by 0x4DA2BE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==14354==    by 0x4DB014: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==14354==    by 0x4D8895: Rf_eval (svn/R-devel/src/main/eval.c:743)
==14354== 

integer lhs:
2,3,1,1
1,6,4,6
3,9,8,8
4,1,6,9
5,4,9,3
6,7,3,5
7,2,7,4
8,5,2,7
9,8,5,2

            [,1]      [,2]       [,3]       [,4]
 [1,] 0.19247930 0.2991924 0.05306885 0.09568994
 [2,] 0.04867746 0.5827553 0.34118656 0.56660735
 [3,] 0.25736352 0.9465149 0.85133390 0.82298113
 [4,] 0.43476399 0.0326226 0.60656286 0.92582163
 [5,] 0.51676339 0.3620019 0.94206058 0.30736785
 [6,] 0.56491632 0.7639246 0.25989699 0.53771559
 [7,] 0.70518705 0.1481972 0.71959458 0.43246648
 [8,] 0.87381550 0.4877766 0.19748008 0.77340200
 [9,] 0.93718439 0.8569461 0.48888826 0.14726135
> 
> 
> 
> cleanEx()
> nameEx("optAugmentLHS")
> ### * optAugmentLHS
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: optAugmentLHS
> ### Title: Optimal Augmented Latin Hypercube Sample
> ### Aliases: optAugmentLHS
> ### Keywords: design
> 
> ### ** Examples
> 
> a <- randomLHS(4,3)
> a
          [,1]       [,2]       [,3]
[1,] 0.1717557 0.09602593 0.44246035
[2,] 0.3744248 0.92940463 0.99797652
[3,] 0.5950088 0.44436131 0.73367631
[4,] 0.8030356 0.66291844 0.03138877
> optAugmentLHS(a, 2, 3)
          [,1]       [,2]       [,3]
[1,] 0.1717557 0.09602593 0.44246035
[2,] 0.3744248 0.92940463 0.99797652
[3,] 0.5950088 0.44436131 0.73367631
[4,] 0.8030356 0.66291844 0.03138877
[5,] 0.9657066 0.28728516 0.53103627
[6,] 0.1114111 0.68465727 0.30456222
> 
> 
> 
> cleanEx()
> nameEx("optSeededLHS")
> ### * optSeededLHS
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: optSeededLHS
> ### Title: Optimum Seeded Latin Hypercube Sample
> ### Aliases: optSeededLHS
> ### Keywords: design
> 
> ### ** Examples
> 
>   a <- randomLHS(4,3)
>   a
          [,1]       [,2]       [,3]
[1,] 0.1717557 0.09602593 0.44246035
[2,] 0.3744248 0.92940463 0.99797652
[3,] 0.5950088 0.44436131 0.73367631
[4,] 0.8030356 0.66291844 0.03138877
>   optSeededLHS(a, 2, 2, .1)
          [,1]       [,2]       [,3]
[1,] 0.1717557 0.09602593 0.30456222
[2,] 0.3744248 0.44436131 0.99797652
[3,] 0.8030356 0.92940463 0.73367631
[4,] 0.5950088 0.66291844 0.03138877
[5,] 0.1114111 0.68465727 0.53103627
[6,] 0.9657066 0.28728516 0.44246035
> 
> 
> 
> cleanEx()
> nameEx("optimumLHS")
> ### * optimumLHS
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: optimumLHS
> ### Title: Optimum Latin Hypercube Sample
> ### Aliases: optimumLHS
> ### Keywords: design
> 
> ### ** Examples
> 
> optimumLHS(4, 3, 5, .05)
          [,1]      [,2]       [,3]
[1,] 0.1717557 0.1794046 0.48367631
[2,] 0.3460259 0.7479765 0.80303563
[3,] 0.9424604 0.3450088 0.66291844
[4,] 0.6244248 0.9443613 0.03138877
> 
> 
> 
> cleanEx()
> nameEx("randomLHS")
> ### * randomLHS
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: randomLHS
> ### Title: Construct a random Latin hypercube design
> ### Aliases: randomLHS
> 
> ### ** Examples
> 
> a <- randomLHS(5, 3)
> 
> 
> 
> ### * <FOOTER>
> ###
> cleanEx()
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed:  13.496 0.269 13.818 0 0 
> grDevices::dev.off()
null device 
          1 
> ###
> ### Local variables: ***
> ### mode: outline-minor ***
> ### outline-regexp: "\\(> \\)?### [*]+" ***
> ### End: ***
> quit('no')
==14354== 
==14354== HEAP SUMMARY:
==14354==     in use at exit: 57,663,684 bytes in 12,551 blocks
==14354==   total heap usage: 58,746 allocs, 46,195 frees, 98,064,571 bytes allocated
==14354== 
==14354== LEAK SUMMARY:
==14354==    definitely lost: 0 bytes in 0 blocks
==14354==    indirectly lost: 0 bytes in 0 blocks
==14354==      possibly lost: 0 bytes in 0 blocks
==14354==    still reachable: 57,663,684 bytes in 12,551 blocks
==14354==         suppressed: 0 bytes in 0 blocks
==14354== Reachable blocks (those to which a pointer was found) are not shown.
==14354== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==14354== 
==14354== For counts of detected and suppressed errors, rerun with: -v
==14354== ERROR SUMMARY: 290 errors from 6 contexts (suppressed: 0 from 0)

fix R CMD check warning in Linux on Travis.CI

checking compiled code ... NOTE
File ‘lhs/libs/lhs.so’:
Found ‘putchar’, possibly from ‘putchar’ (C)
Objects: ‘galois.o’, ‘oaLHS.o’
Found ‘puts’, possibly from ‘printf’ (C), ‘puts’ (C)
Objects: ‘COrthogonalArray.o’, ‘construct.o’, ‘geneticLHS.o’,
‘gfields.o’, ‘oa.o’, ‘oaLHS.o’, ‘optSeededLHS.o’, ‘optimumLHS.o’,
‘runif.o’
Compiled code should not call entry points which might terminate R nor
write to stdout/stderr instead of to the console, nor use Fortran I/O
nor system RNGs.
See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual.

CRAN packages with LENGTH_1 errors

That is

RcppSimdJson SISIR TESS brunnermunzel crseEventStudy denpro egcm
ergm expectreg fitdc fitdistrplus lhs nLTT oce oops pracma
rfordummies tcpl tframePlus

See their entries at

https://www.stats.ox.ac.uk/pub/bdr/LENGTH1_self/

which has reproduction instructions in 00README.txt (and after r81758
this will also be seen in Rdev CMD check --as-cran). These were missed
by --as-cran in the past as the package was misidentified.

Most, maybe all, of the issues are that && and || act on logical scalars.

Please correct before 2022-03-04 to safely retain your package on CRAN.

--
Brian D. Ripley, [email protected]
Emeritus Professor of Applied Statistics, University of Oxford

  • using log directory ‘/data/gannet/ripley/R/packages/tests-ATLAS/lhs.Rcheck’
  • using R Under development (unstable) (2022-01-22 r81552)
  • using platform: x86_64-pc-linux-gnu (64-bit)
  • using session charset: UTF-8
  • using option ‘--no-stop-on-test-error’
  • checking for file ‘lhs/DESCRIPTION’ ... OK
  • this is package ‘lhs’ version ‘1.1.3’
  • package encoding: UTF-8
  • checking package namespace information ... OK
  • checking package dependencies ... OK
  • checking if this is a source package ... OK
  • checking if there is a namespace ... OK
  • checking for executable files ... OK
  • checking for hidden files and directories ... OK
  • checking for portable file names ... OK
  • checking for sufficient/correct file permissions ... OK
  • checking whether package ‘lhs’ can be installed ... [236s/418s] OK
  • checking package directory ... OK
  • checking ‘build’ directory ... OK
  • checking DESCRIPTION meta-information ... OK
  • checking top-level files ... OK
  • checking for left-over files ... OK
  • checking index information ... OK
  • checking package subdirectories ... OK
  • checking R files for non-ASCII characters ... OK
  • checking R files for syntax errors ... OK
  • checking whether the package can be loaded ... OK
  • checking whether the package can be loaded with stated dependencies ... OK
  • checking whether the package can be unloaded cleanly ... OK
  • checking whether the namespace can be loaded with stated dependencies ... OK
  • checking whether the namespace can be unloaded cleanly ... OK
  • checking loading without being on the library search path ... OK
  • checking use of S3 registration ... OK
  • checking dependencies in R code ... OK
  • checking S3 generic/method consistency ... OK
  • checking replacement functions ... OK
  • checking foreign function calls ... OK
  • checking R code for possible problems ... [6s/16s] OK
  • checking Rd files ... OK
  • checking Rd metadata ... OK
  • checking Rd line widths ... OK
  • checking Rd cross-references ... OK
  • checking for missing documentation entries ... OK
  • checking for code/documentation mismatches ... OK
  • checking Rd \usage sections ... OK
  • checking Rd contents ... OK
  • checking for unstated dependencies in examples ... OK
  • checking line endings in C/C++/Fortran sources/headers ... OK
  • checking line endings in Makefiles ... OK
  • checking compilation flags in Makevars ... OK
  • checking for GNU extensions in Makefiles ... OK
  • checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK
  • checking use of PKG_*FLAGS in Makefiles ... OK
  • checking use of SHLIB_OPENMP_*FLAGS in Makefiles ... OK
  • checking pragmas in C/C++ headers and code ... OK
  • checking compilation flags used ... OK
  • checking compiled code ... OK
  • checking installed files from ‘inst/doc’ ... OK
  • checking files in ‘vignettes’ ... OK
  • checking examples ... OK
  • checking for unstated dependencies in ‘tests’ ... OK
  • checking tests ...
    Running ‘testthat.R’ [37s/90s]
    [38s/91s] OK
  • checking for unstated dependencies in vignettes ... OK
  • checking package vignettes in ‘inst/doc’ ... OK
  • checking re-building of vignette outputs ... [5s/15s] WARNING
    Error(s) in re-building vignettes:
    --- re-building ‘augment_lhs.Rmd’ using rmarkdown
    --- finished re-building ‘augment_lhs.Rmd’

--- re-building ‘lhs_basics.Rmd’ using rmarkdown
----------- FAILURE REPORT --------------
--- failure: length > 1 in coercion to logical ---
--- srcref ---
at #31:
--- package (from environment) ---
package:lhs
--- call from context ---
stopifnot(all(Alhs[, 1] <= max1 && Alhs[, 1] >= min1))
--- call from argument ---
Alhs[, 1] <= max1 && Alhs[, 1] >= min1
--- R stacktrace ---
where 1 at #31: stopifnot(all(Alhs[, 1] <= max1 && Alhs[, 1] >= min1))
where 2: graph2dLHSTransform(B[, 1:2], f, g, -4, 4, 0, 8)
where 3: eval(expr, envir, enclos)
where 4: eval(expr, envir, enclos)
where 5: withVisible(eval(expr, envir, enclos))
where 6: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler,
error = eHandler, message = mHandler)
where 7: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir,
enclos)), warning = wHandler, error = eHandler, message = mHandler))
where 8: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr,
envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
where 9: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,
debug = debug, last = i == length(out), use_try = stop_on_error !=
2L, keep_warning = keep_warning, keep_message = keep_message,
output_handler = output_handler, include_timing = include_timing)
where 10: evaluate::evaluate(...)
where 11: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning),
keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else {
if (options$error && options$include)
0L
else 2L
}, output_handler = knit_handlers(options$render, options))
where 12: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE,
keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message),
stop_on_error = if (is.numeric(options$error)) options$error else {
if (options$error && options$include)
0L
else 2L
}, output_handler = knit_handlers(options$render, options)))
where 13: eng_r(options)
where 14: block_exec(params)
where 15: call_block(x)
where 16: process_group.block(group)
where 17: process_group(group)
where 18: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),
error = function(e) {
setwd(wd)
cat(res, sep = "\n", file = output %n% "")
message("Quitting from lines ", paste(current_lines(i),
collapse = "-"), " (", knit_concord$get("infile"),
") ")
})
where 19: process_file(text, output)
where 20: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
where 21: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = globalenv(),
output_dir = getwd(), ...)
where 22: vweave_rmarkdown(...)
where 23: engine$weave(file, quiet = quiet, encoding = enc)
where 24: doTryCatch(return(expr), name, parentenv, handler)
where 25: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 26: tryCatchList(expr, classes, parentenv, handlers)
where 27: tryCatch({
engine$weave(file, quiet = quiet, encoding = enc)
setwd(startdir)
output <- find_vignette_product(name, by = "weave", engine = engine)
if (!have.makefile && vignette_is_tex(output)) {
texi2pdf(file = output, clean = FALSE, quiet = quiet)
output <- find_vignette_product(name, by = "texi2pdf",
engine = engine)
}
outputs <- c(outputs, output)
}, error = function(e) {
thisOK <<- FALSE
fails <<- c(fails, file)
message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s",
file, conditionMessage(e)))
})
where 28: tools:::buildVignettes(dir = "/data/gannet/ripley/R/packages/tests-ATLAS/lhs.Rcheck/vign_test/lhs")

--- value of length: 5 type: logical ---
[1] TRUE TRUE TRUE TRUE TRUE
--- function from context ---
function (..., exprs, exprObject, local = TRUE)
{
n <- ...length()
if ((has.e <- !missing(exprs)) || !missing(exprObject)) {
if (n || (has.e && !missing(exprObject)))
stop("Only one of 'exprs', 'exprObject' or expressions, not more")
envir <- if (isTRUE(local))
parent.frame()
else if (isFALSE(local))
.GlobalEnv
else if (is.environment(local))
local
else stop("'local' must be TRUE, FALSE or an environment")
E1 <- if (has.e && is.call(exprs <- substitute(exprs)))
exprs[[1]]
cl <- if (is.symbol(E1) && E1 == quote({)) {
exprs[[1]] <- quote(stopifnot)
exprs
}
else as.call(c(quote(stopifnot), if (!has.e) exprObject else as.expression(exprs)))
names(cl) <- NULL
return(eval(cl, envir = envir))
}
Dparse <- function(call, cutoff = 60L) {
ch <- deparse(call, width.cutoff = cutoff)
if (length(ch) > 1L)
paste(ch[1L], "....")
else ch
}
head <- function(x, n = 6L) x[seq_len(if (n < 0L) max(length(x) +
n, 0L) else min(n, length(x)))]
abbrev <- function(ae, n = 3L) paste(c(head(ae, n), if (length(ae) >
n) "...."), collapse = "\n ")
for (i in seq_len(n)) {
r <- ...elt(i)
if (!(is.logical(r) && !anyNA(r) && all(r))) {
dots <- match.call()[-1L]
if (is.null(msg <- names(dots)) || !nzchar(msg <- msg[i])) {
cl.i <- dots[[i]]
msg <- if (is.call(cl.i) && identical(cl.i[[1]],
quote(all.equal)) && (is.null(ni <- names(cl.i)) ||
length(cl.i) == 3L || length(cl.i <- cl.i[!nzchar(ni)]) ==
3L))
sprintf(gettext("%s and %s are not equal:\n %s"),
Dparse(cl.i[[2]]), Dparse(cl.i[[3]]), abbrev(r))
else sprintf(ngettext(length(r), "%s is not TRUE",
"%s are not all TRUE"), Dparse(cl.i))
}
stop(simpleError(msg, call = if (p <- sys.parent(1L))
sys.call(p)))
}
}
invisible()
}
<bytecode: 0x2f528e8>
<environment: namespace:base>
--- function search by body ---
Function stopifnot in namespace base has this body.
----------- END OF FAILURE REPORT --------------
Fatal error: length > 1 in coercion to logical

  • checking PDF version of manual ... OK
  • checking for non-standard things in the check directory ... OK
  • checking for detritus in the temp directory ... OK
  • DONE

Status: 1 WARNING
See
‘/data/gannet/ripley/R/packages/tests-ATLAS/lhs.Rcheck/00check.log’
for details.

Time 10:27.54, 297.77 + 22.28

FAQ Question 1 - possible error

FAQ question 1 reads as follows. Note line 35 with "Latin hypercube on [1,10]" and line 46 transforming the distribution.

The `lhs` package returns a uniformly distributed stratified sample from the
unit hypercube. The marginal distributions can then be transformed to your
distribution of choice. If you wanted a uniform Latin hypercube on [1,10] and
[20,30] with 22 samples, you could do:
```{r a1}
X <- randomLHS(22, 2)
X[,1] <- 1 + 9*X[,1]
X[,2] <- 20 + 10*X[,2]
# OR
Y <- randomLHS(22, 2)
Y[,1] <- qunif(Y[,1], 1, 9)

On line 46, Should the maximum in qunif be 10? i.e. Y[,1] <- qunif(Y[,1], 1, 10)

Consider improving user accessibility of OA algorithms

From U Groemping:

While looking for OAs for the creation of SOAs, I was thinking about
making your lhs functions for OA creation more visible in DoE.base - I
have incorporated some of the OAs explicitly, but it of course doesn't
make sense to create and store all conceivable maximum size OAs from
your create functions. But it would be nice to have a user-accessible
function that works like DoE.base::show.oas - or even to incorporate
this into show.oas eventually - to which you give your intention, e.g.
20 factors with at least 19 levels each, and receive an answer which
constructions would provide these.

funtion `runifint` is absent

I installed the lhs package from both CRAN & devtools::github (Rstudio in Windows 10 & MacOS 10.14, but none of the installations provided me the function runifint(), which can be used when the output of latin hypercube design needs to be integer numbers, mentioned at the end of the documentation of the package.

Thanks for your useful package (in other instances) of course!

Set minimal required R version to 3.3.0

I've just tested lhs with 3.3.3, it seems to work fine. If you'd change the minimal required version, this would be one less hoop to jump through in our CI setup for mlr3.

Deprecated C++ std methods

From CRAN:

Dear maintainer,

Please see the problems shown on
https://cran.r-project.org/web/checks/check_results_lhs.html.

Specifically, please see the installation warnings for
r-devel-linux-x86_64-debian-gcc: these can be reproduced by using a
current snapshot of the GCC 12 toolchain.

GCC 12 adds new warnings for use of C++ standard library features that
are deprecated (or no longer present at all) in recent C++ standards,
including std::unary_function and std::binary_function.

See "C++ Standard Library deprecations" in
https://gcc.gnu.org/gcc-12/porting_to.html for more information.

Can you please fix as necessary?

Please correct before 2022-03-29 to safely retain your package on CRAN.

Best,
-k

init.c compilation warning on CRAN

clang-15 -I"/home/hornik/tmp/R.check/r-devel-clang/Work/build/include" -DNDEBUG -DRCOMPILE -I'/home/hornik/tmp/R.check/r-devel-clang/Work/build/Packages/Rcpp/include' -I/usr/local/include -D_FORTIFY_SOURCE=2 -fpic -g -O3 -Wall -pedantic -c init.c -o init.o
init.c:14:33: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
extern SEXP get_library_versions();
^
void
1 warning generated.

Reproducibility of designs from old versions

Hi Rob,

good to see that there seems to be a lot of progress on your package.

I am not sure whether you are aware of the substantial change to random number generation with function sample with R version 3.6.0; I was made aware of this change, because this change caused a change in the test results of several of my packages:

The default method for generating from a discrete uniform distribution (used in sample(), for instance) has been changed. This addresses the fact, pointed out by Ottoboni and Stark, that the previous method made sample() noticeably non-uniform on large populations. See PR#17494 for a discussion. The previous method can be requested using RNGkind() or RNGversion() if necessary for reproduction of old results. Thanks to Duncan Murdoch for contributing the patch and Gabe Becker for further assistance.

The output of RNGkind() has been changed to also return the ‘kind’ used by sample().

While working on adjusting the documentation of my packages to reflect the new behavior of function sample in R 3.6.0 (i.e., telling users of all relevant functions to set the integer uniform random number generator to the old behavior (RNGkind(sample.kind="Rounding")), if needed for reproducing old designs, I discovered that I cannot make lhs results (in my package DoE.wrapper) reproducible in that way. It seems that the new version of your package consistently produces a different design from what the old version (I tried 0.13 and 0.14) would have produced under the same seed.

I observed this for
set.seed(1212)
maximinLHS(6,2)

Is that intentional / known to you? Do you plan to keep future behavior consistent again?
I am asking because I want to provide the adequate information with the documentation of my function lhs.design in package DoE.wrapper.

Best, Ulrike

Bug in createAddelKempN

Hi Rob,

thank you for providing access to the classical orthogonal array creation methods from Owen's C code. I just encountered a bug, however: createAddelKempN apparently does not always create an orthogonal array.

The function should provide OAs for ncol <= 2*(q^exponent-1)/(q-1) - 1 (not documented, but appropriately implemented with this limitation, in line with Theorem 3.16 of Hedayat, Sloane and Stufken 1999). If I request so many factors, I get unwarned non-orthogonality, however:

A <- createAddelKempN(3, 25, 3, TRUE)
table(A[,1], A[,5])

yields the unbalanced result (edited)

_____ A[,5]
A[,1] 0 1 2
___ 0 9 9 0
___ 1 9 0 9
___ 2 0 9 9

Function DoE.base::GWLP shows that there are 25 words of length 2 (with contribution 0.5 from the tabulated pair A[,1] and A[,5]). I have not tried to locate the root cause of the problem.

Kind regards,
Ulrike

Memory leak in bosebushl tests

Memory leak not found in R CMD check --use-valgrind.

https://cran.r-project.org/web/checks/check_results_lhs.html

https://www.stats.ox.ac.uk/pub/bdr/memtests/valgrind/lhs/tests/testthat.Rout

==2401262== Memcheck, a memory error detector
==2401262== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2401262== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==2401262== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R -f testthat.R --restore --save --no-readline --vanilla
==2401262== 

R Under development (unstable) (2020-09-28 r79268) -- "Unsuffered Consequences"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(testthat)
> library(lhs)
> 
> test_check("lhs")
==2401262== Invalid read of size 4
==2401262==    at 0x173CA725: oacpp::oaconstruct::bosebushl(oacpp::GF&, int, bclib::matrix<int>&, int) (packages/tests-vg/lhs/src/construct.cpp:422)
==2401262==    by 0x173C3A59: oacpp::COrthogonalArray::bosebushl(int, int, int, int*) (packages/tests-vg/lhs/src/COrthogonalArray.cpp:174)
==2401262==    by 0x173E7889: oa_type2 (packages/tests-vg/lhs/src/oa_r.cpp:158)
==2401262==    by 0x49CD87: R_doDotCall (svn/R-devel/src/main/dotcode.c:610)
==2401262==    by 0x49D2A3: do_dotcall (svn/R-devel/src/main/dotcode.c:1281)
==2401262==    by 0x4D2BE6: bcEval (svn/R-devel/src/main/eval.c:7121)
==2401262==    by 0x4EF6F7: Rf_eval (svn/R-devel/src/main/eval.c:727)
==2401262==    by 0x4F110D: R_execClosure (svn/R-devel/src/main/eval.c:1895)
==2401262==    by 0x4F1E03: Rf_applyClosure (svn/R-devel/src/main/eval.c:1821)
==2401262==    by 0x4EF8C3: Rf_eval (svn/R-devel/src/main/eval.c:850)
==2401262==    by 0x4F3B99: do_set (svn/R-devel/src/main/eval.c:2967)
==2401262==    by 0x4EFB44: Rf_eval (svn/R-devel/src/main/eval.c:802)
==2401262==  Address 0x142c5100 is 0 bytes after a block of size 128 alloc'd
==2401262==    at 0x483AE7D: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.16.1/coregrind/m_replacemalloc/vg_replace_malloc.c:342)
==2401262==    by 0x173C4299: allocate (/usr/include/c++/10/ext/new_allocator.h:115)
==2401262==    by 0x173C4299: allocate (/usr/include/c++/10/bits/alloc_traits.h:460)
==2401262==    by 0x173C4299: _M_allocate (/usr/include/c++/10/bits/stl_vector.h:346)
==2401262==    by 0x173C4299: _M_create_storage (/usr/include/c++/10/bits/stl_vector.h:361)
==2401262==    by 0x173C4299: _Vector_base (/usr/include/c++/10/bits/stl_vector.h:305)
==2401262==    by 0x173C4299: vector (/usr/include/c++/10/bits/stl_vector.h:511)
==2401262==    by 0x173C4299: bclib::matrix<int>::matrix(unsigned long, unsigned long) (packages/tests-vg/lhs/src/matrix.h:488)
==2401262==    by 0x173CA501: oacpp::oaconstruct::bosebushl(oacpp::GF&, int, bclib::matrix<int>&, int) (packages/tests-vg/lhs/src/construct.cpp:401)
==2401262==    by 0x173C3A59: oacpp::COrthogonalArray::bosebushl(int, int, int, int*) (packages/tests-vg/lhs/src/COrthogonalArray.cpp:174)
==2401262==    by 0x173E7889: oa_type2 (packages/tests-vg/lhs/src/oa_r.cpp:158)
==2401262==    by 0x49CD87: R_doDotCall (svn/R-devel/src/main/dotcode.c:610)
==2401262==    by 0x49D2A3: do_dotcall (svn/R-devel/src/main/dotcode.c:1281)
==2401262==    by 0x4D2BE6: bcEval (svn/R-devel/src/main/eval.c:7121)
==2401262==    by 0x4EF6F7: Rf_eval (svn/R-devel/src/main/eval.c:727)
==2401262==    by 0x4F110D: R_execClosure (svn/R-devel/src/main/eval.c:1895)
==2401262==    by 0x4F1E03: Rf_applyClosure (svn/R-devel/src/main/eval.c:1821)
==2401262==    by 0x4EF8C3: Rf_eval (svn/R-devel/src/main/eval.c:850)
==2401262== 
══ testthat results  ═══════════════════════════════════════════════════════════
[ OK: 395 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 0 ]
> 
> proc.time()
   user  system elapsed 
360.900   0.730 361.977 
==2401262== 
==2401262== HEAP SUMMARY:
==2401262==     in use at exit: 99,981,672 bytes in 19,556 blocks
==2401262==   total heap usage: 322,741 allocs, 303,185 frees, 364,624,316 bytes allocated
==2401262== 
==2401262== 11 bytes in 11 blocks are definitely lost in loss record 11 of 2,261
==2401262==    at 0x483AE7D: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.16.1/coregrind/m_replacemalloc/vg_replace_malloc.c:342)
==2401262==    by 0x173D5CD3: geneticLHS_cpp (packages/tests-vg/lhs/src/lhs_r.cpp:253)
==2401262==    by 0x49CD21: R_doDotCall (svn/R-devel/src/main/dotcode.c:624)
==2401262==    by 0x49D2A3: do_dotcall (svn/R-devel/src/main/dotcode.c:1281)
==2401262==    by 0x4D2BE6: bcEval (svn/R-devel/src/main/eval.c:7121)
==2401262==    by 0x4EF6F7: Rf_eval (svn/R-devel/src/main/eval.c:727)
==2401262==    by 0x4F110D: R_execClosure (svn/R-devel/src/main/eval.c:1895)
==2401262==    by 0x4F1E03: Rf_applyClosure (svn/R-devel/src/main/eval.c:1821)
==2401262==    by 0x4EF8C3: Rf_eval (svn/R-devel/src/main/eval.c:850)
==2401262==    by 0x49CDDB: R_doDotCall (svn/R-devel/src/main/dotcode.c:601)
==2401262==    by 0x4D99ED: bcEval (svn/R-devel/src/main/eval.c:7677)
==2401262==    by 0x4EF6F7: Rf_eval (svn/R-devel/src/main/eval.c:727)
==2401262== 
==2401262== LEAK SUMMARY:
==2401262==    definitely lost: 11 bytes in 11 blocks
==2401262==    indirectly lost: 0 bytes in 0 blocks
==2401262==      possibly lost: 0 bytes in 0 blocks
==2401262==    still reachable: 99,981,661 bytes in 19,545 blocks
==2401262==         suppressed: 0 bytes in 0 blocks
==2401262== Reachable blocks (those to which a pointer was found) are not shown.
==2401262== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==2401262== 
==2401262== For lists of detected and suppressed errors, rerun with: -s
==2401262== ERROR SUMMARY: 9 errors from 2 contexts (suppressed: 0 from 0)

Rare segfault when using randomLHS

There are some very rare and hard to reproduce segfaults caused by LHS, e.g. mlr-org/mlrMBO#484. When running the code described in mlr-org/mlrMBO#484 under R -d valgrind, the following errors appear multiple times:

==83832== Invalid read of size 8
==83832==    at [...]
==83832==  Address 0x26684f30 is 32 bytes inside a block of size 32,048 free'd
==83832==    at 0x483AA0C: free (vg_replace_malloc.c:540)
==83832==    by 0x49CB32E: ReleaseLargeFreeVectors (memory.c:1092)
==83832==    by 0x49CB32E: RunGenCollect (memory.c:1857)
==83832==    by 0x49CB32E: R_gc_internal (memory.c:3085)
==83832==    by 0x49CE5D0: Rf_allocVector3 (memory.c:2736)
==83832==    by 0x48BFB12: UnknownInlinedFun (Rinlinedfuns.h:580)
==83832==    by 0x48BFB12: PutRNGstate (RNG.c:444)
==83832==    by 0xEFD5C50: Rcpp::internal::exitRNGScope() (api.cpp:80)
==83832==    by 0x1C19D133: exitRNGScope (routines.h:88)
==83832==    by 0x1C19D133: ~RNGScope (RNGScope.h:30)
==83832==    by 0x1C19D133: randomLHS_cpp (lhs_r.cpp:179)
==83832==    by 0x4943885: do_dotcall (dotcode.c:1252)
==83832==    by 0x497CC14: bcEval (eval.c:6765)
==83832==    by 0x4991D6F: Rf_eval (eval.c:620)
==83832==    by 0x4993B0E: R_execClosure (eval.c:1780)
==83832==    by 0x4994992: Rf_applyClosure (eval.c:1706)
==83832==    by 0x4991E89: Rf_eval (eval.c:743)
==83832==  Block was alloc'd at
==83832==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==83832==    by 0x49CEAE4: Rf_allocVector3 (memory.c:2767)
==83832==    by 0x1C19E57B: Vector (Vector.h:136)
==83832==    by 0x1C19E57B: Rcpp::Matrix<14, Rcpp::PreserveStorage>::Matrix(int const&, int const&) (Matrix.h:60)
==83832==    by 0x1C19D026: randomLHS_cpp (lhs_r.cpp:195)
==83832==    by 0x4943885: do_dotcall (dotcode.c:1252)
==83832==    by 0x497CC14: bcEval (eval.c:6765)
==83832==    by 0x4991D6F: Rf_eval (eval.c:620)
==83832==    by 0x4993B0E: R_execClosure (eval.c:1780)
==83832==    by 0x4994992: Rf_applyClosure (eval.c:1706)
==83832==    by 0x4991E89: Rf_eval (eval.c:743)
==83832==    by 0x49105BC: do_docall (coerce.c:2638)
==83832==    by 0x497CC14: bcEval (eval.c:6765)
==83832==

The top part (Invalid read / write of size x) is variable, but the text starting from Address stays the same. We see that memory is being accessed that was free'd before. The memory in question was allocated as Rcpp::Matrix in randomLHS_cpp(), and then free'd immediately afterwards in a garbage collection run triggered by PutRNGState(), which gets executed by ~RNGScope() (while still in randomLHS_cpp()). The code that is to blame is here.

What is happening here? The problem is that the destructor of Rcpp::NumericMatrix rresult un-protects the rresult value, and that the destructor of Rcpp::RNGScope tempRNG is called after that. In very rare cases, the PutRNGstate() run by that may trigger a GC which can free the memory allocated by rresult.

This behaviour has been described on the Rcpp mailing list at least twice [1], [2]. The second of these actually hints at a solution of this problem which I implemented in a PR. (Another solution would be to use Rcpp Attributes which would apparently generate this kind of code automatically.)

Documentation createBoseBushl

Hi Rob,
in the documentation of createBoseBushl, it is stated that (ncol=) k <= lambdaq+1, but there is an error message with ncol>lambdaq (I believe that the "+1" only holds for the special case with lambda=2).
Best, Ulrike

P.S.: By the way, Theorem 6.28 of Hedayat, Sloane and Stufken discussed a Bose Bush construction with a larger number of factors (e.g. 13 instead of 9 for q=lambda=3, or 40 instead of 27 for q=3, lambda=9), i.e. the Owen code seems to miss out on opportunities.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.