nsga module

Define NSGA, a genetic algorithm for optimisation.

Warning

Implementation not modified since v0.0.0.0.0.1 or so

class NSGA(*args, history_kwargs=None, **kwargs)[source]

Bases: OptimisationAlgorithm

Non-dominated Sorted Genetic Algorithm.

Parameters:

history_kwargs (dict | None, default: None)

supports_constraints: bool = True
__init__(*args, history_kwargs=None, **kwargs)[source]

Set additional information.

Parameters:

history_kwargs (dict | None, default: None)

optimize()[source]

Set up the optimization and solve the problem.

Return type:

OptiSol

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.

property _problem_arguments: dict[str, int | ndarray]

Gather arguments required for ElementwiseProblem.

_format_variables()[source]

Format Variable for this algorithm.

Return type:

tuple[ndarray, ndarray]

property x_0: ndarray

Return initial value used in LeastSquares.

property x_max_k_e: ndarray

Return a solution with maximum electric fields.

_wrapper_residuals(var)[source]

Compute residuals from an array of variable values.

Parameters:

var (ndarray)

Return type:

tuple[ndarray, ndarray]

_set_algorithm(*args, **kwargs)[source]

Set pymoo`s `Algorithm object.

Return type:

Algorithm

_set_termination()[source]

Set the termination condition.

Return type:

DefaultMultiObjectiveTermination

_set_population(problem, n_pop)[source]

Set population, with some predefined individuals.

Parameters:
  • problem (Problem)

  • n_pop (int)

Return type:

Population

_best_solution(result)[source]

Take the “best” solution.

Parameters:

result (Result)

Return type:

tuple[SetOfCavitySettings, dict[str, ndarray]]

_abc_impl = <_abc._abc_data object at 0x70e2500c0100>
class MyElementwiseProblem(_wrapper_residuals, **kwargs)[source]

Bases: ElementwiseProblem

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

Parameters:
__init__(_wrapper_residuals, **kwargs)[source]

Create object.

Parameters:
_evaluate(x, out, *args, **kwargs)[source]

Calculate and return the objectives.

Parameters:
Return type:

dict[str, ndarray]

_characteristic_points(result)[source]

Give the ideal and Nadir points as a dict.

Parameters:

result (Result)

Return type:

dict[str, ndarray]