# SLHD

##### Sliced Latin Hypercube Design (SLHD)

`SLHD`

returns a maximin distance LHD constructed by "improved two-stage algorithm" from Ba et al. (2015).

##### Usage

`SLHD(n, k, t, N, T0, rate, Tmin, Imax, p = 50, q = 1, stage2 = FALSE)`

##### Arguments

- n
A positive integer.

- k
A positive integer.

- t
A positive integer.

- N
A positive integer.

- T0
A positive number.

- rate
A positive percentage.

- Tmin
A positive number.

- Imax
A positive integer.

- p
A positive integer.

- q
The default is set to be 1, and it could be either 1 or 2.

- stage2
The default is set to be FALSE, and it could be either FALSE or TRUE.

##### Details

`n`

stands for the number of rows (or run size).`k`

stands for the number of columns (or the number of factors).`t`

stands for the number of slices.`n`

/`t`

must be an integer, that is, n is divisible by t. Since S(**X**) needs to be 0 for the algorithm to continue,`t`

must not exceed`k`

for`n`

is 9 or larger, and`t`

must be smaller than`k`

for`n`

is smaller than 9. Otherwise, the funtion will never stop.`N`

stands for the number of iterations.`T0`

stands for the user-defined initial temperature.`rate`

stands for temperature decrease rate, and it should be in (0,1). For example, rate=0.25 means the temperature decreases by 25% each time.`Tmin`

stands for the minimium temperature allowed. When current temperature becomes smaller or equal to`Tmin`

, the stopping criterion for current loop is met.`Imax`

stands for the maximum perturbations the algorithm will try without improvements before temperature is reduced. For the computation complexity consideration,`Imax`

is recommended to be smaller or equal to 5.`p`

is the parameter in the phi_p formula, and`p`

is prefered to be large.If

`q`

is 1 (the default setting),`dij`

is the rectangular distance. If`q`

is 2,`dij`

is the Euclidean distance.If

`stage2`

is FALSE (the default setting),`SLHD`

will only implement the first stage of the algorithm. If`stage2`

is TRUE,`SLHD`

will implement the whole algorithm.

##### Value

If all inputs are logical, then the output will be a `n`

by `k`

LHD.

##### Note

As mentioned from the original paper, the first stage plays a much more important role since it optimizes the slice level. More resources should be given to the first stage if computational budgets are limited. Let m=n/t, where m is the number of rows for each slice, if (m)^k >> n, the second stage becomes optional. That is the reason why we add a `stage2`

parameter to let users decide if the second stage is needed. If `stage2`

is FALSE, randomly generated `\Pi_l`

's will be used.

##### References

Ba, S., Myers, W.R., and Brenneman, W.A. (2015) Optimal Sliced Latin Hypercube Designs. *Technometrics*, **57**, 479-487.

##### Examples

```
# NOT RUN {
#Try SLHD without stage II: create a 5 by 3 maximin distance LHD, with # of
#slices is 1, # of iterations = 5, initial temperature is set to be 5,
#decrease rate is 20%, minimium temperature is 1, maximum perturbations the
#algorithm will try without improvements is 3, and p=50
trySLHD1=SLHD(n=5,k=3,t=1,N=5,T0=5,rate=0.2,Tmin=1,Imax=3,p=50,q=1)
trySLHD1
phi_p(trySLHD1,p=50) #calculate the phi_p of "trySLHD1".
#Try SLHD with stage II
trySLHD2=SLHD(n=5,k=3,t=1,N=5,T0=5,rate=0.2,Tmin=1,Imax=3,p=50,q=1,stage2=TRUE)
trySLHD2
phi_p(trySLHD2,p=50) #calculate the phi_p of "trySLHD2".
# }
```

*Documentation reproduced from package LHD, version 0.1.0, License: MIT + file LICENSE*