mfpml.design_of_experiment

mfpml.design_of_experiment.mf_samplers

class MFLatinHyperCube(design_space, num_fidelity=None, nested=False)[source]

Bases: MultiFidelitySampler

Multi-fidelity Latin HyperCube sampling

Initialization

Parameters:
  • design_space (List) – design space of the problem

  • num_fidelity (int, optional) – number of fidelity levels, by default None

  • nested (bool, optional) – nested sampling or not, by default False

__init__(design_space, num_fidelity=None, nested=False)[source]

Initialization

Parameters:
  • design_space (List) – design space of the problem

  • num_fidelity (int, optional) – number of fidelity levels, by default None

  • nested (bool, optional) – nested sampling or not, by default False

_get_nested_samples(num_sample, data_higher_fidelity)[source]
Return type:

None

_get_non_nested_samples(num_sample, fidelity=0)[source]

get low fidelity samples

Returns:

lf_samples – a numpy array contains low fidelity samples

Return type:

np.ndarray

class MFSobolSequence(design_space, num_fidelity=None, nested=False, num_skip=None)[source]

Bases: MultiFidelitySampler

Multi-fidelity Sobol Sequence sampling

Initialization

Parameters:
  • design_space (List) – design space of the problem

  • nested (bool, optional) – nested sampling or not, by default False

  • num_skip (int, optional) – number of skip, by default None

__init__(design_space, num_fidelity=None, nested=False, num_skip=None)[source]

Initialization

Parameters:
  • design_space (List) – design space of the problem

  • nested (bool, optional) – nested sampling or not, by default False

  • num_skip (int, optional) – number of skip, by default None

_get_nested_samples(num_sample, data_higher_fidelity)[source]
Returns:

hf_sample – a numpy array contains high fidelity samples

Return type:

np.ndarray

_get_non_nested_samples(num_sample, fidelity=0)[source]

get low fidelity samples

Returns:

lf_samples – a numpy array contains low fidelity samples

Return type:

np.ndarray

class MultiFidelitySampler(design_space, num_fidelity=None, nested=False)[source]

Bases: object

Base class for multi-fidelity sampling

Parameters:

design_space (List) – design space

__init__(design_space, num_fidelity=None, nested=False)[source]
Parameters:

design_space (List) – design space

_mf_samples_rules(num_samples)[source]

number of low fidelity samples should larger than high fidelity samples

Parameters:

num_samples (List) – number of samples for each fidelity level

Return type:

None

get_samples(num_samples, seed=123456, **kwargs)[source]

Get the samples

Parameters:
  • num_samples (List) – number of samples for each fidelity level

  • seed (int, optional) – random seed, by default 123456

Return type:

List

lb(fidelity=0)[source]

lower bound of the design space

Parameters:

fidelity (int, optional) – fidelity level, by default 0

Returns:

lower bound of the design space at fidelity level fidelity

Return type:

np.ndarray

save_data(file_name='mf_data')[source]

This function is used to save the design_of_experiment to Json files

Parameters:

file_name (str) – name for the pickle.file

Return type:

None

transfer_design_space_list(design_space)[source]

transfer design space to list

Returns:

design space

Return type:

List

ub(fidelity=0)[source]

upper bound of the design space

Parameters:

fidelity (int, optional) – fidelity level, by default 0

Returns:

upper bound of the design space at fidelity level fidelity

Return type:

np.ndarray

mfpml.design_of_experiment.sf_samplers

class FixNumberSampler(design_space)[source]

Bases: SingleFidelitySampler

Fix number of samples from design space

Parameters:
  • SingleFidelitySampler (class) – base class for sampling

  • design_space (np.ndarray) – design space

__init__(design_space)[source]
Parameters:

design_space (np.ndarray) – design space

_abc_impl = <_abc._abc_data object>
get_samples(num_samples, seed=123456, **kwargs)[source]
Parameters:
  • num_samples (int) – number of samples

  • seed (int) – seed for reproducibility

  • kwargs (additional info)

Returns:

samples – samples

Return type:

np.ndarray

class LatinHyperCube(design_space)[source]

Bases: SingleFidelitySampler

Latin Hyper cube sampling via scipy

Parameters:

design_space (dict) – design space

__init__(design_space)[source]
Parameters:

design_space (dict) – design space

_abc_impl = <_abc._abc_data object>
get_samples(num_samples, seed=123456, **kwargs)[source]

get samples

Parameters:

num_samples (int) – number of samples

Returns:

sample – a numpy array of samples

Return type:

np.ndarray

class RandomSampler(design_space)[source]

Bases: SingleFidelitySampler

Random sampling

Parameters:
  • design_space (dict) – design space

  • seed (int) – seed

__init__(design_space)[source]
Parameters:
  • design_space (dict) – design space

  • seed (int) – seed

_abc_impl = <_abc._abc_data object>
get_samples(num_samples, seed=123456, **kwargs)[source]

get samples

Parameters:
  • num_samples (int) – number of samples

  • seed (int) – seed for reproducibility

Returns:

sample – a numpy array of samples

Return type:

np.ndarray

class SingleFidelitySampler(design_space)[source]

Bases: ABC

Class for drawing samples from design space

Initialization of sampler class

Parameters:

design_space (np.ndarray) – design space

__init__(design_space)[source]

Initialization of sampler class

Parameters:

design_space (np.ndarray) – design space

_abc_impl = <_abc._abc_data object>
get_samples(num_samples, seed=123456, **kwargs)[source]

Get the samples

Parameters:
  • num_samples (int) – number of samples

  • kwargs (int,int) – num_lf_samples: int num_hf_samples: int

Returns:

samples – samples

Return type:

any

Notes

The function should be completed at the sub-sclass

property lb: ndarray[Any, Any]

return the lower bound of the design space

Returns:

lower bound of the design space

Return type:

np.ndarray[Any, Any]

save_data(file_name='data')[source]

This function is used to save the design_of_experiment to Json files

Parameters:

file_name (str) – name for the pickle.file

Return type:

None

scale_samples(samples)[source]

Scale the samples to the design space

Parameters:

samples (np.ndarray) – samples

Returns:

scaled_samples – scaled samples

Return type:

np.ndarray

property ub: ndarray[Any, Any]
class SobolSequence(design_space, num_skip=None)[source]

Bases: SingleFidelitySampler

Sobol Sequence sampling

Parameters:
  • design_space (dict) – design space

  • seed (int) – seed

  • num_skip (int) – cut the first several samples s

__init__(design_space, num_skip=None)[source]
Parameters:
  • design_space (dict) – design space

  • seed (int) – seed

  • num_skip (int) – cut the first several samples s

_abc_impl = <_abc._abc_data object>
get_samples(num_samples, seed=123456, **kwargs)[source]

get samples

Parameters:
  • num_samples (int) – number of samples

  • seed (int) – seed for reproducibility

Returns:

sample – a numpy array of samples

Return type:

np.ndarray