optimisation.algorithms.nsga module

Define :class:.NSGA, a genetic algorithm for optimisation.

class MyElementwiseProblem(_wrapper_residuals: Callable[[ndarray], ndarray], **kwargs: int | ndarray)

Bases: ElementwiseProblem

A first test implementation, eval single solution at a time.

__init__(_wrapper_residuals: Callable[[ndarray], ndarray], **kwargs: int | ndarray) None

Create object.

_evaluate(x: ndarray, out: dict[str, ndarray], *args, **kwargs) dict[str, ndarray]

Calculate and return the objectives.

class NSGA

Bases: OptimisationAlgorithm

Non-dominated Sorted Genetic Algorithm.

__init__() None

Instantiate the object.

_abc_impl = <_abc._abc_data object>
_best_solution(result: Result) tuple[SetOfCavitySettings, dict[str, ndarray]]

Take the “best” solution.

_format_variables() tuple[ndarray, ndarray]

Format Variable for this algorithm.

property _problem_arguments: dict[str, int | ndarray]

Gather arguments required for ElementwiseProblem.

_set_algorithm(*args, **kwargs) Algorithm

Set pymoo`s `Algorithm object.

_set_population(problem: Problem, n_pop: int) Population

Set population, with some predefined individuals.

_set_termination() DefaultMultiObjectiveTermination

Set the termination condition.

_wrapper_residuals(var: ndarray) tuple[ndarray, ndarray]

Compute residuals from an array of variable values.

optimise(keep_history: bool = False, save_history: bool = False) tuple[bool, SetOfCavitySettings | None, OptiInfo]

Set up the optimisation and solve the problem.

Returns:

  • success (bool) – Tells if the optimisation algorithm managed to converge.

  • optimized_cavity_settings (SetOfCavitySettings) – Best solution found by the optimization algorithm.

  • info (dict[str, list[float]]] | None) – Gives list of solutions, corresponding objective, convergence violation if applicable, etc.

supports_constraints: bool = True
property x_0: ndarray

Return initial value used in `LeastSquares’.

property x_max_k_e: ndarray

Return a solution with maximum electric fields.

_characteristic_points(result: Result) dict[str, ndarray]

Give the ideal and Nadir points as a dict.