gemseo_pseven

Hide inherited members

pseven_problem_adapter module

An adapter from .OptimizationProblem to a pSeven ProblemGeneric.

class gemseo_pseven.pseven_problem_adapter.Outputs(output_values, output_mask, values, jacobian_values)[source]

Bases: NamedTuple

The outputs of a worker.

Create new instance of Outputs(output_values, output_mask, values, jacobian_values)

Parameters:
  • output_values (OutputValues) –

  • output_mask (OutputMask) –

  • values (dict[str, float | ndarray]) –

  • jacobian_values (dict[str, ndarray]) –

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

jacobian_values: dict[str, ndarray]

The Jacobians computed by GEMSEO.

output_mask: OutputMask

The mask of the output values to be passed to pSeven.

output_values: OutputValues

The output values to be passed to pSeven.

values: dict[str, float | ndarray]

The function values computed by GEMSEO.

class gemseo_pseven.pseven_problem_adapter.PSevenProblem(*args, **kwargs)[source]

Bases: ProblemGeneric

Adapter of OptimizationProblem to da.p7core.gtopt.ProblemGeneric.

The methods prepare_problem() and evaluate() are defined according to pSeven’s requirements. Refer to the API documentation of pSeven Core for more information.

Parameters:
  • problem (OptimizationProblem) – The optimization problem to be adapted to pSeven.

  • evaluation_cost_type (str | Mapping[str, str] | None) – The evaluation cost type of each function of the problem: “Cheap” or “Expensive”. If a string, then the same cost type is set for all the functions. If None, the evaluation cost types are set by pSeven.

  • expensive_evaluations (Mapping[str, int] | None) – The maximal number of expensive evaluations for each function of the problem. If None, this number is set automatically by pSeven.

  • lower_bounds (ndarray | None) – The lower bounds on the design variables. If None, the lower bounds are read from the design space.

  • upper_bounds (ndarray | None) – The upper bounds on the design variables. If None, the upper bounds are read from the design space.

  • initial_point (ndarray | None) – The initial values of the design variables. If None, the initial values are read from the design space.

  • use_gradient (bool) –

    Whether to use the derivatives of the functions. If the functions have no derivative then this value has no effect.

    By default it is set to True.

  • use_threading (bool) –

    Whether to use threads instead of processes to parallelize the execution.

    By default it is set to False.

  • normalize_design_space (bool) –

    Whether the design variables are normalized.

    By default it is set to True.

evaluate(queryx, querymask)[source]

Compute the values of the objectives and the constraints for pSeven.

Parameters:
  • queryx (ndarray) – The points to evaluate. (2D-array where each row is a point.)

  • querymask (ndarray) – The evaluation request mask.

Returns:

The evaluation result. (2D-array-like with one row per point.), The evaluation masks. (Idem.)

Return type:

tuple[list[list[float | None]], list[list[bool]]]

prepare_problem()[source]

Initialize the problem for pSeven.

Return type:

None

class gemseo_pseven.pseven_problem_adapter.Worker(problem, use_gradient)[source]

Bases: object

A worker to evaluate the functions of a problem.

Parameters:
  • problem (OptimizationProblem) – The optimization problem to be adapted to pSeven.

  • use_gradient (bool) – Whether to use the derivatives of the functions. If the functions have no derivative then this value has no effect.