gemseo_pymoo / algos

Hide inherited members

opt_result_mo module

Multi-objective optimization result.

class gemseo_pymoo.algos.opt_result_mo.MultiObjectiveOptimizationResult(x_0=None, x_0_as_dict=<factory>, x_opt=None, x_opt_as_dict=<factory>, f_opt=None, objective_name='', status=None, optimizer_name=None, message=None, n_obj_call=None, n_grad_call=None, n_constr_call=None, is_feasible=False, optimum_index=None, constraint_values=None, constraints_grad=None, pareto=None)[source]

Bases: OptimizationResult

The result of a multi-objective optimization.

Parameters:
  • x_0 (ndarray | None) –

  • x_0_as_dict (dict[str, ndarray]) –

    By default it is set to <factory>.

  • x_opt (ndarray | None) –

  • x_opt_as_dict (dict[str, ndarray]) –

    By default it is set to <factory>.

  • f_opt (ndarray | None) –

  • objective_name (str) –

    By default it is set to “”.

  • status (int | None) –

  • optimizer_name (str | None) –

  • message (str | None) –

  • n_obj_call (int | None) –

  • n_grad_call (int | None) –

  • n_constr_call (int | None) –

  • is_feasible (bool) –

    By default it is set to False.

  • optimum_index (int | None) –

  • constraint_values (Mapping[str, ndarray] | None) –

  • constraints_grad (Mapping[str, ndarray | None] | None) –

  • pareto (Pareto | None) –

classmethod from_dict(dict_)

Create an optimization result from a dictionary.

Parameters:
  • dict – The dictionary representation of the optimization result. The keys are the names of the optimization result fields, except for the constraint values and gradients. The value associated with the key "constr:y" will be stored in result.constraint_values["y"] while the value associated with the key "constr_grad:y" will be stored in result.constraints_grad["y"].

  • dict_ (Mapping[str, Value]) –

Returns:

An optimization result.

Return type:

OptimizationResult

classmethod from_optimization_problem(problem, **fields_)

Create an optimization result from an optimization problem.

Parameters:
  • problem (OptimizationProblem) – The optimization problem.

  • **fields_ – The fields of the OptimizationResult that cannot be deduced from the optimization problem; e.g. "optimizer_name".

Returns:

The optimization result associated with the optimization problem.

Return type:

OptimizationResult

get_data_dict_repr()

Convert the multi-objective optimization result to a dictionary.

The keys are the names of the optimization result fields, except for the constraint values, gradients and the pareto. The key "constr:y" maps to result.constraint_values["y"], "constr_grad:y" maps to result.constraints_grad["y"] and "pareto:y" maps to result.pareto.y.

Returns:

A dictionary representation of the optimization result.

Return type:

dict[str, str | int | bool | ndarray]

to_dict()[source]

Convert the multi-objective optimization result to a dictionary.

The keys are the names of the optimization result fields, except for the constraint values, gradients and the pareto. The key "constr:y" maps to result.constraint_values["y"], "constr_grad:y" maps to result.constraints_grad["y"] and "pareto:y" maps to result.pareto.y.

Returns:

A dictionary representation of the optimization result.

Return type:

dict[str, str | int | bool | ndarray]

constraint_values: Mapping[str, ndarray] | None = None

The values of the constraints at the optimum.

constraints_grad: Mapping[str, ndarray | None] | None = None

The values of the gradients of the constraints at the optimum.

f_opt: ndarray | None = None

The value of the objective function at the optimum.

is_feasible: bool = False

Whether the solution is feasible.

message: str | None = None

The message returned by the optimizer.

n_constr_call: int | None = None

The number of calls to the constraints function.

n_grad_call: int | None = None

The number of calls to the gradient function.

n_obj_call: int | None = None

The number of calls to the objective function.

objective_name: str = ''

The name of the objective function.

optimizer_name: str | None = None

The name of the optimizer.

optimum_index: int | None = None

The zero-based position of the optimum in the optimization history.

pareto: Pareto | None = None

The pareto efficient solutions.

status: int | None = None

The status of the optimization.

x_0: ndarray | None = None

The initial values of the design variables.

x_0_as_dict: dict[str, ndarray]

The design variable names bound to the initial design values.

x_opt: ndarray | None = None

The optimal values of the design variables, called the optimum.

x_opt_as_dict: dict[str, ndarray]

The design variable names bound to the optimal design values.

class gemseo_pymoo.algos.opt_result_mo.Pareto(problem)[source]

Bases: object

Hold data from multi-objective optimization problems.

Initialize an object containing pareto related data.

Parameters:

problem (OptimizationProblem) – The optimization problem.

static get_lowest_norm(pareto_front, pareto_set, reference=None, order=2)[source]

Get Pareto points with the lowest norm relative to a reference point.

Parameters:
  • pareto_front (ndarray) – The objectives’ value of all non-dominated points.

  • pareto_set (ndarray) – The design variables’ value of all non-dominated points.

  • reference (ndarray | None) – The reference point. If None, the origin (0, 0, …, 0) will be used.

  • order (int) –

    The order of the norm.

    By default it is set to 2.

Returns:

The objectives’ values of the point(s) with the lowest norm. The design variables’ values of the point(s) with the lowest norm. The lowest norm value.

Raises:

ValueError – If the reference point does not have the appropriate dimension.

Return type:

tuple[ndarray, ndarray, float]

static get_pareto(gemseo_problem)[source]

Get Pareto Front and Pareto Set from the database.

Parameters:

gemseo_problem (OptimizationProblem) – The optimization problem containing the results from an optimization run.

Returns:

The objectives’ value of all non-dominated points and the design variables’ value of all non-dominated points.

None if a single-objective OptimizationProblem is provided.

Raises:

RuntimeError – If the optimization problem is single-objective.

Return type:

tuple[None, None] | tuple[ndarray, ndarray]

static get_pareto_anchor(pareto_front, pareto_set)[source]

Get Pareto’s anchor points.

Parameters:
  • pareto_front (ndarray) – The objectives’ value of all non-dominated points.

  • pareto_set (ndarray) – The design variables’ value of all non-dominated points.

Returns:

The objectives’ values of all anchor points. The design variables’ values of all anchor points.

Return type:

tuple[ndarray, ndarray]

static get_pretty_table_from_df(df)[source]

Build a tabular view of the Pareto problem.

Parameters:

df (DataFrame) – The Pareto data.

Returns:

A PrettyTable

representing the dataframe.

Return type:

PrettyTable

property anchor_front: ndarray

The values of the objectives of all anchor points.

At those points, each objective is minimized one at a time.

property anchor_set: ndarray

The values of the design variables values of all anchor points.

At those points, each objective is minimized one at a time.

property anti_utopia: ndarray

The point where every objective reaches its maximum simultaneously.

property front: ndarray

The values of the objectives of all pareto efficient solutions.

property min_norm: float

The shortest distance (2-norm) from the pareto front to the utopia point.

property min_norm_f: ndarray

The objectives value of the closest point(s) to the utopia.

property min_norm_x: ndarray

The design variables value of the closest point(s) to the utopia.

property problem: OptimizationProblem

The optimization problem whose Pareto data is represented.

property set: ndarray

The values of the design variables of all pareto efficient solutions.

property utopia: ndarray

The ideal point where every objective reaches its minimum simultaneously.