The GEMSEO concepts#

GEMSEO-based optimization relies on three main concepts: the Design space, the Optimization problem and the Driver.

Design space#

class DesignSpace(name='')[source]

Description of a design space.

It defines a set of variables from their names, sizes, types and bounds.

In addition, it provides the current values of these variables that can be used as the initial solution of an OptimizationProblem.

Parameters:

name (str) --

The name to be given to the design space. If empty, the design space is unnamed.

By default it is set to "".

DesignVariableType

alias of DataType

add_variable(name, size=1, type_=DataType.FLOAT, lower_bound=-inf, upper_bound=inf, value=None)[source]

Add a variable to the design space.

Parameters:
  • name (str) -- The name of the variable.

  • size (int) --

    The size of the variable.

    By default it is set to 1.

  • type -- Either the type of the variable or the types of its components.

  • lower_bound (Number | Iterable[Number]) --

    The lower bound of the variable. If None, use \(-\infty\).

    By default it is set to -inf.

  • upper_bound (Number | Iterable[Number]) --

    The upper bound of the variable. If None, use \(+\infty\).

    By default it is set to inf.

  • value (Number | Iterable[Number] | None) -- The default value of the variable. If None, do not use a default value.

  • type_ (DataType) --

    By default it is set to "float".

Raises:

ValueError -- Either if the variable already exists or if the size is not a positive integer.

Return type:

None

add_variables_from(space, *names)[source]

Add variables from another variable space.

Parameters:
  • space (DesignSpace) -- The other variable space.

  • *names (str) -- The names of the variables.

Return type:

None

check()[source]

Check the state of the design space.

Raises:

ValueError -- If the design space is empty.

Return type:

None

check_membership(x_vect, variable_names=None)[source]

Check whether the variables satisfy the design space requirements.

Parameters:
  • x_vect (Mapping[str, ndarray] | ndarray) -- The values of the variables.

  • variable_names (Sequence[str] | None) -- The names of the variables. If None, use the names of the variables of the design space.

Raises:

ValueError -- Either if the dimension of the values vector is wrong, if the values are not specified as an array or a dictionary, if the values are outside the bounds of the variables or if the component of an integer variable is not an integer.

Return type:

None

convert_array_to_dict(x_array)[source]

Convert a design array into a dictionary indexed by the variables names.

Parameters:

x_array (ndarray) -- A design value expressed as a NumPy array.

Returns:

The design value expressed as a dictionary of NumPy arrays.

Return type:

dict[str, ndarray]

convert_dict_to_array(design_values, variable_names=())[source]

Convert a mapping of design values into a NumPy array.

Parameters:
  • design_values (Mapping[str, ndarray]) -- The mapping of design values.

  • variable_names (Iterable[str]) --

    The design variables to be considered. If empty, consider all the design variables.

    By default it is set to ().

Returns:

The design values as a NumPy array.

Return type:

ndarray

Notes

The data type of the returned NumPy array is the most general data type of the values of the mapping design_values corresponding to the keys iterable from variables_names.

extend(other)[source]

Extend the design space with another design space.

Parameters:

other (DesignSpace) -- The design space to be appended to the current one.

Return type:

None

filter(keep_variables, copy=False)[source]

Filter the design space to keep a subset of variables.

Parameters:
  • keep_variables (str | Iterable[str]) -- The names of the variables to be kept.

  • copy (bool) --

    If True, then a copy of the design space is filtered, otherwise the design space itself is filtered.

    By default it is set to False.

Returns:

Either the filtered original design space or a copy.

Raises:

ValueError -- If the variable is not in the design space.

Return type:

DesignSpace

filter_dimensions(name, dimensions)[source]

Filter the design space to keep a subset of dimensions for a variable.

Parameters:
  • name (str) -- The name of the variable.

  • dimensions (Sequence[int]) -- The dimensions of the variable to be kept, between \(0\) and \(d-1\) where \(d\) is the number of dimensions of the variable.

Returns:

The filtered design space.

Raises:

ValueError -- If a dimension does not exist.

Return type:

DesignSpace

classmethod from_csv(file_path, header=())[source]

Create a design space from a CSV file.

Parameters:
  • file_path (str | Path) -- The path to the CSV file.

  • header (Iterable[str]) --

    The names of the fields saved in the file. If empty, read them in the file.

    By default it is set to ().

Returns:

The design space defined in the file.

Raises:

ValueError -- If the file does not contain the minimal variables in its header.

Return type:

DesignSpace

classmethod from_file(file_path, hdf_node_path='', **options)[source]

Create a design space from a file.

Parameters:
  • file_path (str | Path) -- The path to the file. If the extension starts with "hdf", the file will be considered as an HDF file.

  • hdf_node_path (str) --

    The path of the HDF node from which the database should be imported. If empty, the root node is considered.

    By default it is set to "".

  • **options (Any) -- The keyword reading options.

Returns:

The design space defined in the file.

Return type:

DesignSpace

classmethod from_hdf(file_path, hdf_node_path='')[source]

Create a design space from an HDF file.

Parameters:
  • file_path (str | Path) -- The path to the HDF file.

  • hdf_node_path (str) --

    The path of the HDF node from which the database should be imported. If empty, the root node is considered.

    By default it is set to "".

Returns:

The design space defined in the file.

Return type:

DesignSpace

get_active_bounds(x_vec=None, tol=1e-08)[source]

Determine which bound constraints of a design value are active.

Parameters:
  • x_vec (ndarray | None) -- The design value at which to check the bounds. If None, use the current design value.

  • tol (float) --

    The tolerance of comparison of a scalar with a bound.

    By default it is set to 1e-08.

Returns:

Whether the components of the lower and upper bound constraints are active, the first returned value representing the lower bounds and the second one the upper bounds, e.g.

(
    {
        "x": array(are_x_lower_bounds_active),
        "y": array(are_y_lower_bounds_active),
    },
    {
        "x": array(are_x_upper_bounds_active),
        "y": array(are_y_upper_bounds_active),
    },
)

where:

are_x_lower_bounds_active = [True, False]
are_x_upper_bounds_active = [False, False]
are_y_lower_bounds_active = [False]
are_y_upper_bounds_active = [True]

Return type:

tuple[dict[str, ndarray], dict[str, ndarray]]

get_current_value(variable_names=None, complex_to_real=False, as_dict=False, normalize=False)[source]

Return the current design value.

If the names of the variables are empty then an empty data is returned.

Parameters:
  • variable_names (Sequence[str] | None) -- The names of the design variables. If None, use all the design variables.

  • complex_to_real (bool) --

    Whether to cast complex numbers to real ones.

    By default it is set to False.

  • as_dict (bool) --

    Whether to return the current design value as a dictionary of the form {variable_name: variable_value}.

    By default it is set to False.

  • normalize (bool) --

    Whether to normalize the design values in \([0,1]\) with the bounds of the variables.

    By default it is set to False.

Returns:

The current design value.

Raises:

ValueError -- If names in variable_names are not in the design space.

Return type:

ndarray | dict[str, ndarray]

Warning

For performance purposes, get_current_value() does not return a copy of the current value. This means that modifying the returned object will make the DesignSpace inconsistent (the current design value stored as a NumPy array and the current design value stored as a dictionary of NumPy arrays will be different). To modify the returned object without impacting the DesignSpace, you shall copy this object and modify the copy.

See also

To modify the current value, please use set_current_value() or set_current_variable().

get_indexed_variable_names(variable_names=())[source]

Create the names of the components of variables.

If the size of the variable is equal to 1, its name remains unaltered. Otherwise, it concatenates the name of the variable and the index of the component.

Parameters:

variable_names (str | Sequence[str]) --

The names of the design variables. If empty, use all the design variables.

By default it is set to ().

Returns:

The name of the components of the variables.

Return type:

list[str]

get_lower_bound(name)[source]

Return the lower bound of a variable.

Parameters:

name (str) -- The name of the variable.

Returns:

The lower bound of the variable (possibly infinite).

Return type:

ndarray

get_lower_bounds(variable_names: Sequence[str] = (), as_dict: Literal[False] = False) ndarray[source]
get_lower_bounds(variable_names: Sequence[str] = (), as_dict: Literal[True] = False) dict[str, ndarray]

Return the lower bounds of design variables.

Parameters:
  • variable_names -- The names of the design variables. If empty, the lower bounds of all the design variables are returned.

  • as_dict -- Whether to return the lower bounds as a dictionary of the form {variable_name: variable_lower_bound}.

Returns:

The lower bounds of the design variables.

get_pretty_table(fields=(), with_index=False, capitalize=False, simplify=False)[source]

Build a tabular view of the design space.

Parameters:
  • fields (Sequence[str]) --

    The name of the fields to be exported. If empty, export all the fields.

    By default it is set to ().

  • with_index (bool) --

    Whether to show index of names for arrays. This is ignored for scalars.

    By default it is set to False.

  • capitalize (bool) --

    Whether to capitalize the field names and replace "_" by " ".

    By default it is set to False.

  • simplify (bool) --

    Whether to return a simplified tabular view.

    By default it is set to False.

Returns:

A tabular view of the design space.

Return type:

PrettyTable

get_size(name)[source]

Get the size of a variable.

Parameters:

name (str) -- The name of the variable.

Raises:

ValueError -- If the variable is not known.

Returns:

The size of the variable.

Return type:

int

get_type(name)[source]

Return the type of a variable.

Parameters:

name (str) -- The name of the variable.

Raises:

ValueError -- If the variable is not known.

Returns:

The type of the variable.

Return type:

str

get_upper_bound(name)[source]

Return the upper bound of a variable.

Parameters:

name (str) -- The name of the variable.

Returns:

The upper bound of the variable (possibly infinite).

Return type:

ndarray

get_upper_bounds(variable_names: Sequence[str] = (), as_dict: Literal[False] = False) ndarray[source]
get_upper_bounds(variable_names: Sequence[str] = (), as_dict: Literal[True] = False) dict[str, ndarray]

Return the upper bounds of design variables.

Parameters:
  • variable_names -- The names of the design variables. If empty, the upper bounds of all the design variables are returned.

  • as_dict -- Whether to return the upper bounds as a dictionary of the form {variable_name: variable_upper_bound}.

Returns:

The upper bounds of the design variables.

get_variables_indexes(variable_names, use_design_space_order=True)[source]

Return the indexes of a design array corresponding to variables names.

Parameters:
  • variable_names (Iterable[str]) -- The names of the variables.

  • use_design_space_order (bool) --

    Whether to order the indexes according to the order of the variables names in the design space. Otherwise, the indexes will be ordered in the same order as the variables names were required.

    By default it is set to True.

Returns:

The indexes of a design array corresponding to the variables names.

Return type:

IntegerArray

initialize_missing_current_values()[source]

Initialize the current values of the design variables when missing.

Use:

  • the center of the design space when the lower and upper bounds are finite,

  • the lower bounds when the upper bounds are infinite,

  • the upper bounds when the lower bounds are infinite,

  • zero when the lower and upper bounds are infinite.

Return type:

None

normalize_grad(g_vect)[source]

Normalize an unnormalized gradient.

This method is based on the chain rule:

\[\frac{df(x)}{dx} = \frac{df(x)}{dx_u}\frac{dx_u}{dx} = \frac{df(x)}{dx_u}\frac{1}{u_b-l_b}\]

where \(x_u = \frac{x-l_b}{u_b-l_b}\) is the normalized input vector, \(x\) is the unnormalized input vector and \(l_b\) and \(u_b\) are the lower and upper bounds of \(x\).

Then, the normalized gradient reads:

\[\frac{df(x)}{dx_u} = (u_b-l_b)\frac{df(x)}{dx}\]

where \(\frac{df(x)}{dx}\) is the unnormalized one.

Parameters:

g_vect (RealOrComplexArrayT) -- The gradient to be normalized.

Returns:

The normalized gradient.

Return type:

RealOrComplexArrayT

normalize_vect(x_vect, minus_lb=True, out=None)[source]

Normalize a vector of the design space.

If minus_lb is True:

\[x_u = \frac{x-l_b}{u_b-l_b}\]

where \(l_b\) and \(u_b\) are the lower and upper bounds of \(x\).

Otherwise:

\[x_u = \frac{x}{u_b-l_b}\]

Unbounded variables are not normalized.

Parameters:
  • x_vect (RealOrComplexArrayT) -- The values of the design variables.

  • minus_lb (bool) --

    If True, remove the lower bounds at normalization.

    By default it is set to True.

  • out (RealOrComplexArrayT | None) -- The array to store the normalized vector. If None, create a new array.

Returns:

The normalized vector.

Return type:

RealOrComplexArrayT

project_into_bounds(x_c, normalized=False)[source]

Project a vector onto the bounds, using a simple coordinate wise approach.

Parameters:
  • normalized (bool) --

    If True, then the vector is assumed to be normalized.

    By default it is set to False.

  • x_c (ndarray) -- The vector to be projected onto the bounds.

Returns:

The projected vector.

Return type:

ndarray

remove_variable(name)[source]

Remove a variable from the design space.

Parameters:

name (str) -- The name of the variable to be removed.

Return type:

None

rename_variable(current_name, new_name)[source]

Rename a variable.

Parameters:
  • current_name (str) -- The name of the variable to rename.

  • new_name (str) -- The new name of the variable.

Return type:

None

round_vect(x_vect, copy=True)[source]

Round the vector where variables are of integer type.

Parameters:
  • x_vect (ndarray) -- The values to be rounded.

  • copy (bool) --

    Whether to round a copy of x_vect.

    By default it is set to True.

Returns:

The rounded values.

Return type:

ndarray

set_current_value(value)[source]

Set the current design value.

Parameters:

value (ndarray | Mapping[str, ndarray] | OptimizationResult) -- The value of the current design.

Raises:
Return type:

None

set_current_variable(name, current_value)[source]

Set the current value of a single variable.

Parameters:
  • name (str) -- The name of the variable.

  • current_value (ndarray) -- The current value of the variable.

Return type:

None

set_lower_bound(name, lower_bound)[source]

Set the lower bound of a variable.

Parameters:
  • name (str) -- The name of the variable.

  • lower_bound (Number | Iterable[Number]) -- The value of the lower bound.

Raises:

ValueError -- If the variable does not exist.

Return type:

None

set_upper_bound(name, upper_bound)[source]

Set the upper bound of a variable.

Parameters:
  • name (str) -- The name of the variable.

  • upper_bound (Number | Iterable[Number]) -- The value of the upper bound.

Raises:

ValueError -- If the variable does not exist.

Return type:

None

to_complex()[source]

Cast the current value to complex.

Return type:

None

to_csv(output_file, fields=(), header_char='', **table_options)[source]

Export the design space to a CSV file.

Parameters:
  • output_file (str | Path) -- The path to the file.

  • fields (Sequence[str]) --

    The fields to be exported. If empty, export all fields.

    By default it is set to ().

  • header_char (str) --

    The header character.

    By default it is set to "".

  • **table_options (Any) -- The names and values of additional attributes for the PrettyTable view generated by DesignSpace.get_pretty_table().

Return type:

None

to_file(file_path, **options)[source]

Save the design space.

Parameters:
  • file_path (str | Path) -- The file path to save the design space. If the extension starts with "hdf", the design space will be saved in an HDF file.

  • **options -- The keyword reading options.

Return type:

None

to_hdf(file_path, append=False, hdf_node_path='')[source]

Export the design space to an HDF file.

Parameters:
  • file_path (str | Path) -- The path to the file to export the design space.

  • append (bool) --

    If True, appends the data in the file.

    By default it is set to False.

  • hdf_node_path (str) --

    The path of the HDF node in which the design space should be exported. If empty, the root node is considered.

    By default it is set to "".

Return type:

None

to_scalar_variables()[source]

Create a new design space with the variables splitted into scalar variables.

Returns:

The design space of scalar variables.

Return type:

DesignSpace

transform_vect(vector, out=None)[source]

Map a point of the design space to a vector with components in \([0,1]\).

Parameters:
  • vector (ndarray) -- A point of the design space.

  • out (ndarray | None) -- The array to store the transformed vector. If None, create a new array.

Returns:

A vector with components in \([0,1]\).

Return type:

ndarray

unnormalize_grad(g_vect)[source]

Unnormalize a normalized gradient.

This method is based on the chain rule:

\[\frac{df(x)}{dx} = \frac{df(x)}{dx_u}\frac{dx_u}{dx} = \frac{df(x)}{dx_u}\frac{1}{u_b-l_b}\]

where \(x_u = \frac{x-l_b}{u_b-l_b}\) is the normalized input vector, \(x\) is the unnormalized input vector, \(\frac{df(x)}{dx_u}\) is the unnormalized gradient \(\frac{df(x)}{dx}\) is the normalized one, and \(l_b\) and \(u_b\) are the lower and upper bounds of \(x\).

Parameters:

g_vect (RealOrComplexArrayT) -- The gradient to be unnormalized.

Returns:

The unnormalized gradient.

Return type:

RealOrComplexArrayT

unnormalize_vect(x_vect, minus_lb=True, no_check=False, out=None)[source]

Unnormalize a normalized vector of the design space.

If minus_lb is True:

\[x = x_u(u_b-l_b) + l_b\]

where \(x_u\) is the normalized input vector, \(x\) is the unnormalized input vector and \(l_b\) and \(u_b\) are the lower and upper bounds of \(x\).

Otherwise:

\[x = x_u(u_b-l_b)\]
Parameters:
  • x_vect (RealOrComplexArrayT) -- The values of the design variables.

  • minus_lb (bool) --

    Whether to remove the lower bounds at normalization.

    By default it is set to True.

  • no_check (bool) --

    Whether to check if the components are in \([0,1]\).

    By default it is set to False.

  • out (ndarray | None) -- The array to store the unnormalized vector. If None, create a new array.

Returns:

The unnormalized vector.

Return type:

RealOrComplexArrayT

untransform_vect(vector, no_check=False, out=None)[source]

Map a vector with components in \([0,1]\) to the design space.

Parameters:
  • vector (ndarray) -- A vector with components in \([0,1]\).

  • no_check (bool) --

    Whether to check if the components are in \([0,1]\).

    By default it is set to False.

  • out (ndarray | None) -- The array to store the untransformed vector. If None, create a new array.

Returns:

A point of the variables space.

Return type:

ndarray

VARIABLE_TYPES_TO_DTYPES: Final[dict[str, type[int64 | float64]]] = {DataType.FLOAT: <class 'numpy.float64'>, DataType.INTEGER: <class 'numpy.int64'>}

One NumPy dtype per design variable type.

dimension: int

The total dimension of the space, corresponding to the sum of the sizes of the variables.

property enable_integer_variables_normalization: bool

Whether to enable the normalization of integer variables.

Note

Switching the normalization of integer variables shall trigger the (re-)computation of the normalization data at the next normalization (or unnormalization).

property has_current_value: bool

Check if each variable has a current value.

Returns:

Whether the current design value is defined for all variables.

property has_integer_variables: bool

Check if the design space has at least one integer variable.

Returns:

Whether the design space has at least one integer variable.

name: str | None

The name of the space.

property names_to_indices: dict[str, range]

The names bound to the indices.

normalize: dict[str, BooleanArray]

The normalization policies of the variables components indexed by the variables names; if True, the component can be normalized.

property variable_names: list[str]

The variable names.

property variable_sizes: dict[str, int]

The variable sizes.

property variable_types: dict[str, str]

The variable types.

Optimization problem#

class OptimizationProblem(design_space, is_linear=True, database=None, differentiation_method=DifferentiationMethod.USER_GRAD, differentiation_step=1e-07, parallel_differentiation=False, use_standardized_objective=True, **parallel_differentiation_options)[source]

An optimization problem.

Parameters:
  • pb_type -- The type of the optimization problem.

  • use_standardized_objective (bool) --

    Whether to use standardized objective for logging and post-processing.

    By default it is set to True.

  • design_space (DesignSpace)

  • is_linear (bool) --

    By default it is set to True.

  • database (Database | None)

  • differentiation_method (DifferentiationMethod) --

    By default it is set to "user".

  • differentiation_step (float) --

    By default it is set to 1e-07.

  • parallel_differentiation (bool) --

    By default it is set to False.

  • parallel_differentiation_options (int | bool)

AggregationFunction

alias of EvaluationFunction

class DifferentiationMethod(value)

The differentiation methods.

CENTERED_DIFFERENCES = 'centered_differences'
COMPLEX_STEP = 'complex_step'
FINITE_DIFFERENCES = 'finite_differences'
NO_DERIVATIVE = 'no_derivative'
USER_GRAD = 'user'
class HistoryFileFormat(value)[source]

The format of the history file.

add_constraint(function, value=0.0, constraint_type=None, positive=False)[source]

Add an equality or inequality constraint to the optimization problem.

An equality constraint is written as \(c(x)=a\), a positive inequality constraint is written as \(c(x)\geq a\) and a negative inequality constraint is written as \(c(x)\leq a\).

Parameters:
  • function (MDOFunction) -- The function \(c\).

  • value (float) --

    The value \(a\).

    By default it is set to 0.0.

  • constraint_type (MDOFunction.ConstraintType | None) -- The type of the constraint.

  • positive (bool) --

    Whether the inequality constraint is positive.

    By default it is set to False.

Raises:
Return type:

None

apply_exterior_penalty(objective_scale=1.0, scale_inequality=1.0, scale_equality=1.0)[source]

Reformulate the optimization problem using exterior penalty.

Given the optimization problem with equality and inequality constraints:

\[ \begin{align}\begin{aligned}min_x f(x)\\s.t.\\g(x)\leq 0\\h(x)=0\\l_b\leq x\leq u_b\end{aligned}\end{align} \]

The exterior penalty approach consists in building a penalized objective function that takes into account constraints violations:

\[ \begin{align}\begin{aligned}min_x \tilde{f}(x) = \frac{f(x)}{o_s} + s[\sum{H(g(x))g(x)^2}+\sum{h(x)^2}]\\s.t.\\l_b\leq x\leq u_b\end{aligned}\end{align} \]

Where \(H(x)\) is the Heaviside function, \(o_s\) is the objective_scale parameter and \(s\) is the scale parameter. The solution of the new problem approximate the one of the original problem. Increasing the values of objective_scale and scale, the solutions are closer but the optimization problem requires more and more iterations to be solved.

Parameters:
  • scale_equality (float | RealArray) --

    The equality constraint scaling constant.

    By default it is set to 1.0.

  • objective_scale (float) --

    The objective scaling constant.

    By default it is set to 1.0.

  • scale_inequality (float | RealArray) --

    The inequality constraint scaling constant.

    By default it is set to 1.0.

Return type:

None

check()[source]

Check if the optimization problem is ready for run.

Raises:

ValueError -- If the objective function is missing.

Return type:

None

classmethod from_hdf(file_path, x_tolerance=0.0, hdf_node_path='')[source]

Import an optimization history from an HDF file.

Parameters:
  • file_path (str | Path) -- The file containing the optimization history.

  • x_tolerance (float) --

    The tolerance on the design variables when reading the file.

    By default it is set to 0.0.

  • hdf_node_path (str) --

    The path of the HDF node from which the database should be imported. If empty, the root node is considered.

    By default it is set to "".

Returns:

The read optimization problem.

Return type:

OptimizationProblem

get_function_dimension(name)[source]

Return the dimension of a function of the problem (e.g. a constraint).

Parameters:

name (str) -- The name of the function.

Returns:

The dimension of the function.

Raises:
  • ValueError -- If the function name is unknown to the problem.

  • RuntimeError -- If the function dimension is not available.

Return type:

int

get_function_names(names)[source]

Return the names of the functions stored in the database.

Parameters:

names (Iterable[str]) -- The names of the outputs or constraints specified by the user.

Returns:

The names of the constraints stored in the database.

Return type:

list[str]

get_functions(no_db_no_norm=False, observable_names=(), jacobian_names=None, evaluate_objective=True, constraint_names=())[source]
Parameters:
  • evaluate_objective (bool) --

    Whether to evaluate the objective.

    By default it is set to True.

  • constraint_names (Iterable[str] | None) --

    The names of the constraints to evaluate. If empty, then all the constraints are returned. If None, then no constraint is returned.

    By default it is set to ().

  • no_db_no_norm (bool) --

    By default it is set to False.

  • observable_names (Iterable[str] | None) --

    By default it is set to ().

  • jacobian_names (Iterable[str] | None)

Return type:

tuple[list[MDOFunction], list[MDOFunction]]

get_functions_dimensions(names=None)[source]

Return the dimensions of the outputs of the problem functions.

Parameters:

names (Iterable[str] | None) -- The names of the functions. If None, then the objective and all the constraints are considered.

Returns:

The output dimensions of the functions associated with their names.

Return type:

dict[str, int]

get_reformulated_problem_with_slack_variables()[source]

Add slack variables and replace inequality constraints with equality ones.

Given the original optimization problem,

\[ \begin{align}\begin{aligned}min_x f(x)\\s.t.\\g(x)\leq 0\\h(x)=0\\l_b\leq x\leq u_b\end{aligned}\end{align} \]

Slack variables are introduced for all inequality constraints that are non-positive. An equality constraint for each slack variable is then defined.

\[ \begin{align}\begin{aligned}min_{x,s} F(x,s) = f(x)\\s.t.\\H(x,s) = h(x)=0\\G(x,s) = g(x)-s=0\\l_b\leq x\leq u_b\\s\leq 0\end{aligned}\end{align} \]
Returns:

An optimization problem without inequality constraints.

Return type:

OptimizationProblem

reset(database=True, current_iter=True, design_space=True, function_calls=True, preprocessing=True)[source]

Partially or fully reset the problem.

Parameters:
  • database (bool) --

    Whether to clear the database.

    By default it is set to True.

  • current_iter (bool) --

    Whether to reset the counter of evaluations to the initial iteration.

    By default it is set to True.

  • design_space (bool) --

    Whether to reset the current value of the design space which can be None.

    By default it is set to True.

  • function_calls (bool) --

    Whether to reset the number of calls of the functions.

    By default it is set to True.

  • preprocessing (bool) --

    Whether to turn the pre-processing of functions to False.

    By default it is set to True.

Return type:

None

to_dataset(name: str = '', categorize: Literal[True] = True, export_gradients: bool = False, input_values: Iterable[RealArray] = (), opt_naming: Literal[False] = True) IODataset[source]
to_dataset(name: str = '', categorize: Literal[True] = True, export_gradients: bool = False, input_values: Iterable[RealArray] = (), opt_naming: Literal[True] = True) OptimizationDataset
Parameters:
to_hdf(file_path, append=False, hdf_node_path='')[source]

Export the optimization problem to an HDF file.

Parameters:
  • file_path (str | Path) -- The HDF file path.

  • append (bool) --

    Whether to append the data to the file if not empty. Otherwise, overwrite data.

    By default it is set to False.

  • hdf_node_path (str) --

    The path of the HDF node in which the optimization problem should be exported. If empty, the root node is considered.

    By default it is set to "".

Return type:

None

property constraints: Constraints

The constraints.

database: Database

The database to store the function evaluations.

design_space: DesignSpace

The design space on which the functions are evaluated.

differentiation_step: float

The differentiation step.

evaluation_counter: EvaluationCounter

The counter of function evaluations.

Every execution of a DriverLibrary handling this problem increments this counter by 1.

property functions: list[MDOFunction]

All the functions except new_iter_observables.

property is_linear: bool

Whether the optimization problem is linear.

property is_mono_objective: bool

Whether the optimization problem is mono-objective.

Raises:

ValueError -- When the dimension of the objective cannot be determined.

property minimize_objective: bool

Whether to minimize the objective.

property objective: MDOFunction

The objective function.

property objective_name: str

The name of the objective.

property optimum: Solution

The optimum solution within a given feasibility tolerance.

This solution is defined by:

  • the value of the objective function,

  • the value of the design variables,

  • the indicator of feasibility of the optimal solution,

  • the value of the constraints,

  • the value of the gradients of the constraints.

property original_functions: list[MDOFunction]

All the original functions except those of new_iter_observables.

property scalar_constraint_names: list[str]

The names of the scalar constraints.

A scalar constraint is a constraint whose output is of dimension 1.

solution: OptimizationResult | None

The solution of the optimization problem if solved; otherwise None.

property standardized_objective_name: str

The name of the standardized objective.

Given an objective named "f", the name of the standardized objective is "f" in the case of minimization and "-f" in the case of maximization.

property tolerances: ConstraintTolerances

The constraint tolerances.

use_standardized_objective: bool

Whether to use standardized objective for logging and post-processing.

The standardized objective corresponds to the original one expressed as a cost function to minimize. A BaseDriverLibrary works with this standardized objective and the Database stores its values. However, for convenience, it may be more relevant to log the expression and the values of the original objective.

Driver#

class BaseDriverLibrary(algo_name)[source]

Base class for libraries of drivers.

Parameters:

algo_name (str) -- The algorithm name.

Raises:

KeyError -- When the algorithm is not in the library.

class ApproximationMode(value)

The approximation derivation modes.

CENTERED_DIFFERENCES = 'centered_differences'

The centered differences method used to approximate the Jacobians by perturbing each variable with a small real number.

COMPLEX_STEP = 'complex_step'

The complex step method used to approximate the Jacobians by perturbing each variable with a small complex number.

FINITE_DIFFERENCES = 'finite_differences'

The finite differences method used to approximate the Jacobians by perturbing each variable with a small real number.

class DifferentiationMethod(value)

The differentiation methods.

CENTERED_DIFFERENCES = 'centered_differences'
COMPLEX_STEP = 'complex_step'
FINITE_DIFFERENCES = 'finite_differences'
NO_DERIVATIVE = 'no_derivative'
USER_GRAD = 'user'
execute(problem, eval_obs_jac=False, skip_int_check=False, max_design_space_dimension_to_log=40, settings_model=None, **settings)[source]

Solve a problem with an algorithm from this library.

Parameters:
  • problem (EvaluationProblem) -- The problem to be solved.

  • eval_obs_jac (bool) --

    Whether to evaluate the Jacobian of the observables.

    By default it is set to False.

  • skip_int_check (bool) --

    Whether to skip the integer variable handling check of the selected algorithm.

    By default it is set to False.

  • max_design_space_dimension_to_log (int) --

    The maximum dimension of a design space to be logged. If this number is higher than the dimension of the design space then the design space will not be logged.

    By default it is set to 40.

  • settings_model (BaseDriverSettings | None) -- The algorithm settings as a Pydantic model. If None, use **settings.

  • **settings (Any) -- The algorithm settings. These arguments are ignored when settings_model is not None.

Returns:

The solution found by the algorithm.

Return type:

OptimizationResult

ALGORITHM_INFOS: ClassVar[dict[str, DriverDescription]] = {}

The description of the algorithms contained in the library.

enable_progress_bar: bool = True

Whether to enable the progress bar in the evaluation log.