gemseo / algos / doe

lib_custom module

Design of experiments from custom data.

Classes:

CustomDOE()

A design of experiments from samples provided as a file or an array.

class gemseo.algos.doe.lib_custom.CustomDOE[source]

Bases: gemseo.algos.doe.doe_lib.DOELibrary

A design of experiments from samples provided as a file or an array.

The samples are provided either as a file in text or csv format or as a sequence of sequences of numbers, e.g. a 2D numpy array.

A csv file format is assumed to have a header whereas a text file (extension .txt) does not.

Constructor Abstract class.

Attributes:

ALGO_LIST

COMMENTS_KEYWORD

COMPLEX_STEP_METHOD

DELIMITER_KEYWORD

DESCRIPTION

DESIGN_ALGO_NAME

DIFFERENTIATION_METHODS

DIMENSION

DOE_FILE

EQ_TOLERANCE

EVAL_JAC

FINITE_DIFF_METHOD

HANDLE_EQ_CONS

HANDLE_INEQ_CONS

INEQ_TOLERANCE

INTERNAL_NAME

LIB

MAX_DS_SIZE_PRINT

MAX_TIME

MIN_DIMS

NORMALIZE_DESIGN_SPACE_OPTION

N_PROCESSES

N_SAMPLES

OPTIONS_DIR

OPTIONS_MAP

PHIP_CRITERIA

POSITIVE_CONSTRAINTS

PROBLEM_TYPE

REQUIRE_GRAD

ROUND_INTS_OPTION

SAMPLES

SAMPLES_TAG

SEED

SKIPROWS_KEYWORD

USER_DEFINED_GRADIENT

USE_DATABASE_OPTION

WAIT_TIME_BETWEEN_SAMPLES

WEBSITE

algorithms

Return the available algorithms.

Methods:

compute_phip_criteria(samples)

Compute the phi^p criteria (see Morris & Mitchell, Exploratory designs for computational experiments, 1995)

driver_has_option(option_key)

Checks if the option key exists.

ensure_bounds(orig_func[, normalize])

Project the design vector onto the design space before execution.

evaluate_samples([eval_jac, n_processes, …])

Evaluates all functions of optimization problem at the samples.

execute(problem[, algo_name])

Executes the driver.

export_samples(doe_output_file)

Export samples generated by DOE library to a csv file.

filter_adapted_algorithms(problem)

Filters the algorithms capable of solving the problem.

finalize_iter_observer()

Finalize the iteration observer.

get_optimum_from_database([message, status])

Retrieves the optimum from the database and builds an optimization result object from it.

get_x0_and_bounds_vects(normalize_ds)

Gets x0, bounds, normalized or not depending on algo options, all as numpy arrays.

init_iter_observer(max_iter, message)

Initialize the iteration observer.

init_options_grammar(algo_name)

Initializes the options grammar.

is_algo_requires_grad(algo_name)

Returns True if the algorithm requires a gradient evaluation.

is_algorithm_suited(algo_dict, problem)

Checks if the algorithm is suited to the problem according to its algo dict.

new_iteration_callback()

Callback called at each new iteration, ie every time a design vector that is not already in the database is proposed by the optimizer.

read_file(doe_file[, delimiter, comments, …])

Read a file containing several samples (one per line) and return them.

Return type

None

ALGO_LIST = ['CustomDOE']
COMMENTS_KEYWORD = 'comments'
COMPLEX_STEP_METHOD = 'complex_step'
DELIMITER_KEYWORD = 'delimiter'
DESCRIPTION = 'description'
DESIGN_ALGO_NAME = 'Design algorithm'
DIFFERENTIATION_METHODS = ['user', 'complex_step', 'finite_differences']
DIMENSION = 'dimension'
DOE_FILE = 'doe_file'
EQ_TOLERANCE = 'eq_tolerance'
EVAL_JAC = 'eval_jac'
FINITE_DIFF_METHOD = 'finite_differences'
HANDLE_EQ_CONS = 'handle_equality_constraints'
HANDLE_INEQ_CONS = 'handle_inequality_constraints'
INEQ_TOLERANCE = 'ineq_tolerance'
INTERNAL_NAME = 'internal_algo_name'
LIB = 'lib'
MAX_DS_SIZE_PRINT = 40
MAX_TIME = 'max_time'
MIN_DIMS = 'min_dims'
NORMALIZE_DESIGN_SPACE_OPTION = 'normalize_design_space'
N_PROCESSES = 'n_processes'
N_SAMPLES = 'n_samples'
OPTIONS_DIR = 'options'
OPTIONS_MAP = {}
PHIP_CRITERIA = 'phi^p'
POSITIVE_CONSTRAINTS = 'positive_constraints'
PROBLEM_TYPE = 'problem_type'
REQUIRE_GRAD = 'require_grad'
ROUND_INTS_OPTION = 'round_ints'
SAMPLES = 'samples'
SAMPLES_TAG = 'samples'
SEED = 'seed'
SKIPROWS_KEYWORD = 'skiprows'
USER_DEFINED_GRADIENT = 'user'
USE_DATABASE_OPTION = 'use_database'
WAIT_TIME_BETWEEN_SAMPLES = 'wait_time_between_samples'
WEBSITE = 'website'
property algorithms

Return the available algorithms.

static compute_phip_criteria(samples)

Compute the phi^p criteria (see Morris & Mitchell, Exploratory designs for computational experiments, 1995)

Parameters

samples – design variables list

driver_has_option(option_key)

Checks if the option key exists.

Parameters

option_key – the name of the option

Returns

True if the option is in the grammar

ensure_bounds(orig_func, normalize=True)

Project the design vector onto the design space before execution.

Parameters
  • orig_func – the original function

  • normalize – if True, use the normalized design space

Returns

the wrapped function

evaluate_samples(eval_jac=False, n_processes=1, wait_time_between_samples=0)

Evaluates all functions of optimization problem at the samples.

Parameters

eval_jac – if True, the jacobian is also evaluated (Default value = False)

execute(problem, algo_name=None, **options)

Executes the driver.

Parameters
  • problem – the problem to be solved

  • algo_name – name of the algorithm if None, use self.algo_name which may have been set by the factory (Default value = None)

  • options – the options dict for the algorithm

export_samples(doe_output_file)

Export samples generated by DOE library to a csv file.

Parameters

doe_output_file (string) – export file name

filter_adapted_algorithms(problem)

Filters the algorithms capable of solving the problem.

Parameters

problem – the opt_problem to be solved

Returns

the list of adapted algorithms names

finalize_iter_observer()

Finalize the iteration observer.

get_optimum_from_database(message=None, status=None)

Retrieves the optimum from the database and builds an optimization result object from it.

Parameters
  • message – Default value = None)

  • status – Default value = None)

get_x0_and_bounds_vects(normalize_ds)

Gets x0, bounds, normalized or not depending on algo options, all as numpy arrays.

Parameters

normalize_ds – if True, normalizes all input vars that are not integers, according to design space normalization policy

Returns

x, lower bounds, upper bounds

init_iter_observer(max_iter, message)

Initialize the iteration observer.

It will handle the stopping criterion and the logging of the progress bar.

Parameters
  • max_iter – maximum number of calls

  • message – message to display at the beginning

init_options_grammar(algo_name)

Initializes the options grammar.

Parameters

algo_name – name of the algorithm

is_algo_requires_grad(algo_name)

Returns True if the algorithm requires a gradient evaluation.

Parameters

algo_name – name of the algorithm

static is_algorithm_suited(algo_dict, problem)

Checks if the algorithm is suited to the problem according to its algo dict.

Parameters
  • algo_dict – the algorithm characteristics

  • problem – the opt_problem to be solved

new_iteration_callback()

Callback called at each new iteration, ie every time a design vector that is not already in the database is proposed by the optimizer.

Iterates the progress bar, implements the stop criteria.

read_file(doe_file, delimiter=',', comments='#', skiprows=0)[source]

Read a file containing several samples (one per line) and return them.

Parameters
  • doe_file (Union[str, pathlib.Path, TextIO]) – Either the file, the filename, or the generator to read.

  • delimiter (Optional[str]) – The string used to separate values. If None, use whitespace.

  • comments (Optional[Union[str, Sequence[str]]]) – The characters or list of characters used to indicate the start of a comment. None implies no comments.

  • skiprows (int) – Skip the first skiprows lines.

Returns

The samples.

Return type

numpy.ndarray