Samples
The syntax for sampling in an interval or region is the following:
sample(n,lb,ub,S::SamplingAlgorithm)
where lb and ub are, respectively, the lower and upper bounds. There are many sampling algorithms to choose from:
- Grid sample
Surrogates.GridSample
— TypeGridSample{T}
T is the step dx for lb:dx:ub
Surrogates.sample
— Methodsample(n,lb,ub,S::GridSample)
Returns a tuple containing numbers in a grid.
- Uniform sample
Surrogates.sample
— Methodsample(n,lb,ub,::UniformRandom)
Returns a Tuple containing uniform random numbers.
- Sobol sample
Surrogates.sample
— Methodsample(n,lb,ub,::SobolSampling)
Returns a Tuple containing Sobol sequences.
- Latin Hypercube sample
Surrogates.sample
— Methodsample(n,lb,ub,::LatinHypercube)
Returns a Tuple containing LatinHypercube sequences.
- Low Discrepancy sample
Surrogates.LowDiscrepancySample
— TypeLowDiscrepancySample{T}
T is the base for the sequence
Surrogates.sample
— Methodsample(n,lb,ub,S::LowDiscrepancySample)
Low discrepancy sample:
- Dimension 1: Van der Corput sequence
- Dimension > 1: Halton sequence
If dimension d > 1, all bases must be coprime with each other.
- Sample on section
Missing docstring for SectionSample
. Check Documenter's build log for details.
Surrogates.sample
— Methodsample(n,d,K::SectionSample)
Returns Tuples constrained to a section.
In surrogate-based identification and control, optimization can alternate between unconstrained sampling in the full-dimensional parameter space, and sampling constrained on specific sections (e.g. a planes in a 3D volume),
A SectionSampler allows sampling and optimizing on a subset of 'free' dimensions while keeping 'fixed' ones constrained. The sampler is defined as in e.g.
sectionsampleryis10 = SectionSample([NaN64, NaN64, 10.0, 10.0], Surrogates.UniformSample())
where the first argument is a Vector{T} in which numbers are fixed coordinates and NaN
s correspond to free dimensions, and the second argument is a SamplingAlgorithm which is used to sample in the free dimensions.
Adding a new sampling method
Adding a new sampling method is a two- step process:
- Adding a new SamplingAlgorithm type
- Overloading the sample function with the new type.
Example
struct NewAmazingSamplingAlgorithm{OPTIONAL} <: SamplingAlgorithm end
function sample(n,lb,ub,::NewAmazingSamplingAlgorithm)
if lb is Number
...
return x
else
...
return Tuple.(x)
end
end