Skip to content

bertcarnell/lhslib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

144 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lhslib

C++ Latin hypercube sampling code. Used in the lhs pacakge in the R statistical software (www.r-project.org).
Link to the lhs project page here.

Code Coverage Actions CodeQL Linter
codecov CMake CodeQL CppLinter

Connections to Other Projects

Documentation

The API is primarily documented through the Doxygen documentation supplied here.

Examples

The following code illustrates how the API is called from C++. The bclib::matrix<T> class is a simple matrix class that only includes necessary operations (bclib). More robust matrix templates could be used in the future. lhslib is the namespace of this project.

randomLHS Algorithm

int n = 4;
int k = 3;
bool bPreserveDraw = false;
bclib::matrix<double> result = bclib::matrix<double>(n,k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::randomLHS(n, k, bPreserveDraw, result, oRandom);

improvedLHS Algorithm

int n = 4;
int k = 3;
int dup = 5;
bclib::matrix<int> result = bclib::matrix<int>(n,k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::improvedLHS(n, k, dup, result, oRandom);

maximinLHS Algorithm

int n = 4;
int k = 3;
int dup = 5;
bclib::matrix<int> result = bclib::matrix<int>(n, k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::maximinLHS(n, k, dup, result, oRandom);

optimumLHS Algorithm

int n = 4;
int k = 3;
int maxSweeps = 2;
double eps = 0.1;
int jLen = 7; // (4 choose 2) + 1
bclib::matrix<int> result = bclib::matrix<int>(n, k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::optimumLHS(n, k, maxSweeps, eps, result, jLen, oRandom, false);

geneticLHS Algorithm

int n = 10;
int k = 4;
int pop = 20;
int gen = 5;
double pMut = 0.10;
std::string crit = "S";
bool verbose = false;
bclib::matrix<double> result = bclib::matrix<double>(n, k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::geneticLHS(n, k, pop, gen, pMut, crit, verbose, result, oRandom);

About

Latin hypercube sampling code for the lhs pacakge in the statistical software package R (www.r-project.org)

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors