designLHD: Latin Hypercube Design Generator

Description Usage Arguments Value Author(s) Examples

View source: R/designLHD.R

Description

Creates a latin Hypercube Design (LHD) with user-specified dimension and number of design points. LHDs are created repeatedly created at random. For each each LHD, the minimal pair-wise distance between design points is computed. The design with the maximum of that minimal value is chosen.

Usage

1
designLHD(x = NULL, lower, upper, control = list())

Arguments

x

optional matrix x, rows for points, columns for dimensions. This can contain one or more points which are part of the design, but specified by the user. These points are added to the design, and are taken into account when calculating the pair-wise distances. They do not count for the design size. E.g., if x has two rows, control$replicates is one and control$size is ten, the returned design will have 12 points (12 rows). The first two rows will be identical to x. Only the remaining ten rows are guaranteed to be a valid LHD.

lower

vector with lower boundary of the design variables (in case of categorical parameters, please map the respective factor to a set of contiguous integers, e.g., with lower = 1 and upper = number of levels)

upper

vector with upper boundary of the design variables (in case of categorical parameters, please map the respective factor to a set of contiguous integers, e.g., with lower = 1 and upper = number of levels)

control

list of controls:

size

number of design points

retries

number of retries during design creation

types

this specifies the data type for each design parameter, as a vector of either "numeric","integer","factor". (here, this only affects rounding)

inequalityConstraint

inequality constraint function, smaller zero for infeasible points. Used to replace infeasible points with random points.

replicates

integer for replications of each design point. E.g., if replications is two, every design point will occur twice in the resulting matrix.

Value

matrix design
- design has length(lower) columns and (size + nrow(x))*control$replicates rows. All values should be within lower <= design <= upper

Author(s)

Original code by Christian Lasarczyk, adaptations by Martin Zaefferer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
set.seed(1) #set RNG seed to make examples reproducible 
design <- designLHD(,1,2) #simple, 1-D case
design
design <- designLHD(,1,2,control=list(replicates=3)) #with replications
design
design <- designLHD(,c(-1,-2,1,0),c(1,4,9,1),
	control=list(size=5, retries=100, types=c("numeric","integer","factor","factor")))
design
x <- designLHD(,c(1,-10),c(2,10),control=list(size=5,retries=100))
x2 <- designLHD(x,c(1,-10),c(2,10),control=list(size=5,retries=100))
plot(x2)
points(x, pch=19)

Example output

          [,1]
 [1,] 1.263041
 [2,] 1.884061
 [3,] 1.385613
 [4,] 1.539136
 [5,] 1.638049
 [6,] 1.989545
 [7,] 1.064432
 [8,] 1.174108
 [9,] 1.460530
[10,] 1.790308
          [,1]
 [1,] 1.234723
 [2,] 1.113144
 [3,] 1.937449
 [4,] 1.363142
 [5,] 1.539008
 [6,] 1.768963
 [7,] 1.868941
 [8,] 1.055490
 [9,] 1.442962
[10,] 1.645272
[11,] 1.234723
[12,] 1.113144
[13,] 1.937449
[14,] 1.363142
[15,] 1.539008
[16,] 1.768963
[17,] 1.868941
[18,] 1.055490
[19,] 1.442962
[20,] 1.645272
[21,] 1.234723
[22,] 1.113144
[23,] 1.937449
[24,] 1.363142
[25,] 1.539008
[26,] 1.768963
[27,] 1.868941
[28,] 1.055490
[29,] 1.442962
[30,] 1.645272
            [,1] [,2] [,3] [,4]
[1,]  0.47650936    1    3    0
[2,] -0.69078219    3    6    0
[3,] -0.49528255   -2    1    1
[4,]  0.07150406    4    7    1
[5,]  0.99685732    0    9    0

SPOT documentation built on Oct. 23, 2021, 1:06 a.m.