pymoo

Sampling

In the very beginning initial points needs to be sampled. pymoo offers different sampling methods depending on the variable type.

Random Sampling (‘real_random’, ‘bin_random’)

[1]:
from pymoo.factory import get_sampling
from pymoo.util import plotting
from pymoo.interface import sample

sampling = get_sampling('real_random')

X = sample(sampling, 100, 2)
plotting.plot(X, no_fill=True)
../_images/components_sampling_5_0.png

Latin Hypercube Sampling (‘real_lhs’)

[2]:
from pymoo.factory import get_sampling
from pymoo.util import plotting
from pymoo.interface import sample

sampling = get_sampling('real_lhs')

X = sample(sampling, 100, 2)
plotting.plot(X, no_fill=True)
../_images/components_sampling_8_0.png

API

pymoo.factory.get_sampling(name, kwargs)

A convenience method to get an sampling object just by providing a string.

Parameters
name{ ‘real_random’, ‘real_lhs’, ‘bin_random’, ‘int_random’ }

Name of the sampling.

kwargsdict

Dictionary that should be used to call the method mapped to the sampling factory function.

Returns
algorithmSampling

An sampling object based on the string. None if the sampling was not found.

pymoo.model.sampling.Sampling()

This abstract class represents any sampling strategy that can be used to create an initial population or an initial search point.