nsga module
Define the NSGA-III many-objective optimisation algorithm.
- class _LightWinProblem(n_var, n_obj, n_constr, xl, xu, eval_fn, **kwargs)[source]
Bases:
ProblemWrap LightWin’s residual evaluation into a pymoo
Problem.- Parameters:
- __init__(n_var, n_obj, n_constr, xl, xu, eval_fn, **kwargs)[source]
Init the object.
- Parameters:
n_var (
int) – Number of variables.n_obj (
int) – Number of objectives.n_constr (
int) – Number of constraints.xl (
ndarray[tuple[Any,...],dtype[double]]) –(n_var, )array of lower limits for variables.xu (
ndarray[tuple[Any,...],dtype[double]]) –(n_var, )array of upper limits for variables.eval_fn (
Callable) – Residue function.
- Return type:
None
- class NSGA3Algorithm(*, compensating_elements, objective_factory, design_space, compute_beam_propagation, cavity_settings_factory, reference_simulation_output, optimisation_algorithm_kwargs=None, history_kwargs=None, **kwargs)[source]
Bases:
OptimisationAlgorithmNSGA-III many-objective optimisation algorithm, powered by pymoo.
Suitable for problems with 4+ objectives. Uses structured reference points on a Das-Dennis simplex lattice to maintain diversity across the Pareto front.
All attributes but
solutionare inherited fromOptimisationAlgorithm.See also
pymoo.algorithms.moo.nsga3.NSGA3- Parameters:
compensating_elements (
Collection[FieldMap])objective_factory (
ObjectiveFactory)design_space (
DesignSpace)compute_beam_propagation (
Callable[[Mapping[FieldMap,CavitySettings]],SimulationOutput])cavity_settings_factory (
CavitySettingsFactory)reference_simulation_output (
SimulationOutput)optimisation_algorithm_kwargs (
dict[str,Any] |None, default:None)
- optimize()[source]
Set up the optimisation and solve the problem.
- Return type:
- Returns:
Gives list of solutions, corresponding objectives, constraint violations if applicable, etc.
- property _default_kwargs: dict[str, Any]
Compute sensible NSGA-III defaults from the problem dimensions.
n_partitionsis the smallest value that yields at least_MIN_REF_DIRSDas-Dennis reference directions, ensuring enough diversity pressure across the Pareto front.pop_sizeis set to the number of reference directions (the natural lower bound for NSGA-III) rounded up to the nearest hundred.n_genscales with the number of variables: more variables generally need more generations to converge.
- _evaluate_individual(var)[source]
Evaluate objectives and constraints for a single individual.
Mirrors the logic of
OptimisationAlgorithm._wrapper_residuals()but also returns constraint values so that a single beam propagation call covers both, avoiding redundant simulations.- Parameters:
var (
ndarray[tuple[Any,...],dtype[double]]) – Array of variable values for one candidate solution.- Return type:
tuple[ndarray[tuple[Any,...],dtype[double]],ndarray[tuple[Any,...],dtype[double]] |None]- Returns:
residuals – Objective values.
constraints – Constraint values (
<= 0means feasible), orNoneif no constraints are defined.
- _generate_opti_sol(result)[source]
Pick the best solution from the Pareto front and format it.
“Best” is defined as the Pareto-front member with the smallest Euclidean norm of its objective vector - a reasonable neutral choice when no preference ordering over objectives is specified.
- Parameters:
result (
Result) – The pymooResultobject returned byminimize().- Return type:
- _abc_impl = <_abc._abc_data object at 0x7318f8d5eac0>
- class _LightWinProblemMulti(*args, n_workers=1, **kwargs)[source]
Bases:
_LightWinProblemWrap LightWin’s residual evaluation into a pymoo Problem.
- class NSGA3AlgorithmMulti(*args, **kwargs)[source]
Bases:
NSGA3AlgorithmNSGA-III many-objective optimisation algorithm, powered by pymoo.
Suitable for problems with 4+ objectives. Uses structured reference points on a Das-Dennis simplex lattice to maintain diversity across the Pareto front.
All attributes but
solutionare inherited fromOptimisationAlgorithm.See also
pymoo.algorithms.moo.nsga3.NSGA3- __init__(*args, **kwargs)[source]
Create object.
Also set
_history_lock, which guards history writes, as they are not thread-safe.- Return type:
None
- property _default_kwargs: dict[str, Any]
Compute sensible NSGA-III defaults from the problem dimensions.
n_partitionsis the smallest value that yields at least_MIN_REF_DIRSDas-Dennis reference directions, ensuring enough diversity pressure across the Pareto front.pop_sizeis set to the number of reference directions (the natural lower bound for NSGA-III) rounded up to the nearest hundred.n_genscales with the number of variables: more variables generally need more generations to converge.
- _evaluate_individual(var)[source]
Evaluate one candidate — thread-safe via lock on history writes.
The simulation runs outside the lock (fully parallel). History writes are batched and serialised via
_history_lock.
- _abc_impl = <_abc._abc_data object at 0x7318f8d5efc0>