doe_library module¶
Base DOE library.
- class gemseo.algos.doe.doe_library.DOEAlgorithmDescription(algorithm_name, internal_algorithm_name, library_name='', description='', website='', handle_integer_variables=True, require_gradient=False, minimum_dimension=1)[source]
Bases:
DriverDescription
The description of a DOE algorithm.
- Parameters:
algorithm_name (str) –
internal_algorithm_name (str) –
library_name (str) –
By default it is set to “”.
description (str) –
By default it is set to “”.
website (str) –
By default it is set to “”.
handle_integer_variables (bool) –
By default it is set to True.
require_gradient (bool) –
By default it is set to False.
minimum_dimension (int) –
By default it is set to 1.
- algorithm_name: str
The name of the algorithm in GEMSEO.
- handle_integer_variables: bool = True
Whether the optimization algorithm handles integer variables.
- internal_algorithm_name: str
The name of the algorithm in the wrapped library.
- minimum_dimension: int = 1
The minimum dimension of the parameter space.
- class gemseo.algos.doe.doe_library.DOELibrary[source]
Bases:
DriverLibrary
,Serializable
Abstract class to use for DOE library link See DriverLibrary.
- compute_doe(variables_space, size=None, unit_sampling=False, **options)[source]
Compute a design of experiments (DOE) in a variables space.
- Parameters:
variables_space (DesignSpace | int) – Either the variables space to be sampled or its dimension.
size (int | None) – The size of the DOE. If
None
, the size is deduced from theoptions
.unit_sampling (bool) –
Whether to sample in the unit hypercube. If the value provided in
variables_space
is the dimension, the samples will be generated in the unit hypercube whatever the value ofunit_sampling
.By default it is set to False.
**options (DOELibraryOptionType) – The options of the DOE algorithm.
- Returns:
The design of experiments whose rows are the samples and columns the variables.
- Return type:
RealArray
- evaluate_samples(eval_jac=False, n_processes=1, wait_time_between_samples=0.0, use_database=True, callbacks=())[source]
Evaluate all the functions of the optimization problem at the samples.
- Parameters:
eval_jac (bool) –
Whether to evaluate the Jacobian function.
By default it is set to False.
n_processes (int) –
The maximum simultaneous number of processes used to parallelize the execution.
By default it is set to 1.
wait_time_between_samples (float) –
The time to wait between each sample evaluation, in seconds.
By default it is set to 0.0.
use_database (bool) –
Whether to store the evaluations in the database.
By default it is set to True.
callbacks (Iterable[CallbackType]) –
The functions to be evaluated after each call to
OptimizationProblem.evaluate_functions()
; to be called ascallback(index, (output, jacobian))
.By default it is set to ().
- Return type:
None
Warning
This class relies on multiprocessing features when
n_processes > 1
, it is therefore necessary to protect its execution with anif __name__ == '__main__':
statement when working on Windows.
- export_samples(doe_output_file)[source]
Export the samples generated by DOE library to a CSV file.
- Parameters:
doe_output_file (Path | str) – The path to the output file.
- Return type:
None
- DESIGN_ALGO_NAME = 'Design algorithm'
- DIMENSION = 'dimension'
- EVAL_JAC = 'eval_jac'
- LEVEL_KEYWORD = 'levels'
- N_PROCESSES = 'n_processes'
- N_SAMPLES = 'n_samples'
- PHIP_CRITERIA = 'phi^p'
- SAMPLES_TAG = 'samples'
- SEED = 'seed'
- WAIT_TIME_BETWEEN_SAMPLES = 'wait_time_between_samples'
- descriptions: dict[str, AlgorithmDescription]
The description of the algorithms contained in the library.
- eval_jac: bool
Whether to evaluate the Jacobian.
- internal_algo_name: str | None
The internal name of the algorithm used currently.
It typically corresponds to the name of the algorithm in the wrapped library if any.
- lock: RLock
The lock protecting database storage in multiprocessing.
- opt_grammar: JSONGrammar | None
The grammar defining the options of the current algorithm.
- problem: OptimizationProblem
The optimization problem the driver library is bonded to.
- samples: RealArray
The design vector samples in the design space.
The design space variable types stored as dtype metadata.
To access those in the unit hypercube, use
unit_samples
.
- property seed: int
The default seed used for reproducibility reasons.
- unit_samples: RealArray
The design vector samples projected in the unit hypercube.
In the case of a design space of dimension \(d\), the unit hypercube is \([0,1]^d\).
To access those in the design space, use
samples
.
- gemseo.algos.doe.doe_library.DOELibraryOutputType
The type of the output value in an input-output sample.
- gemseo.algos.doe.doe_library.CallbackType(*args, **kwargs)
The type of a callback function in the context of a .
alias of
Callable
[[int
,tuple
[dict
[str
,Union
[float
,ndarray
]],dict
[str
,ndarray
]]],Any
]
- gemseo.algos.doe.doe_library.DOELibraryOptionType(*args, **kwargs)
The type of a DOE algorithm option.
alias of
Union
[str
,float
,int
,bool
,list
[str
],ndarray
,Iterable
[Callable
[[int
,Any
],Any
]]]