explorator module

Define Explorator, a module to explore the design space.

In order to be consistent with the ABC OptimisationAlgorithm, it also returns the solution with the lowest residual value – hence it is also a “brute-force” optimisation algorithm.

Todo

Make this class more robust. In particular: save all objectives (not just the norm), handle export when there is more than two variables, also save complementary data (e.g.: always save phi_s even it is not in the constraints nor variables).

Todo

Allow for different number of points according to variable.

class Explorator(*, 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: OptimisationAlgorithm

Method that tries all the possible solutions.

Notes

Very inefficient for optimization. It is however useful to study a specific case.

All the attributes but solution are inherited from the Abstract Base Class OptimisationAlgorithm.

Parameters:
supports_constraints: bool = True
compute_constraints: Callable[[SimulationOutput], ndarray[tuple[Any, ...], dtype[float64]]]
optimize()[source]

Set up the optimization and solve the problem.

Return type:

OptiSol

Returns:

Gives list of solutions, corresponding objective, convergence violation if applicable, etc.

_algorithm_parameters()[source]

Create the kwargs for the optimisation.

Return type:

dict

_generate_combinations(n_points=10, **kwargs)[source]

Generate all the possible combinations of the variables.

Parameters:

n_points (int, default: 10)

Return type:

tuple[ndarray, ndarray]

_array_of_values_to_mesh(objectives_values, n_points=10, **kwargs)[source]

Reformat the results for plotting purposes.

Parameters:
  • objectives_values (ndarray)

  • n_points (int, default: 10)

Return type:

ndarray

_generate_opti_sol(variables_values, objectives_values, criterion)[source]

Create the dictionary holding all relatable information.

Parameters:
  • variables_values (ndarray)

  • objectives_values (ndarray)

  • criterion (Literal['minimize norm of objective'])

Return type:

OptiSol

_take_best_solution(variable_comb, objectives_values, criterion)[source]

Take the “best” of the calculated solutions.

Parameters:
  • variable_comb (ndarray) – All the set of variables (cavity parameters) that were tried.

  • objectives_values (ndarray) – The values of the objective corresponding to variable_comb.

  • criterion (Literal['minimize norm of objective']) – Name of the criterion that will determine which solution is the “best”. Only one is implemented for now, may add others in the future.

Return type:

tuple[ndarray | None, ndarray | None]

Returns:

  • best_solution – “Best” solution.

  • best_objective – Objective values corresponding to best_solution.

_abc_impl = <_abc._abc_data object at 0x7318f903e580>