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 residue 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: Collection[Element], elts: ListOfElements, objectives: Collection[Objective], variables: Collection[Variable], compute_beam_propagation: Callable[[SetOfCavitySettings], SimulationOutput], compute_residuals: Callable[[SimulationOutput], Any], cavity_settings_factory: CavitySettingsFactory, reference_simulation_output: SimulationOutput, constraints: Collection[Constraint] | None = None, compute_constraints: Callable[[SimulationOutput], ndarray] | None = None, optimisation_algorithm_kwargs: dict[str, Any] | None = None, history_kwargs: dict[str, Any] | None = None, **kwargs)
Bases:
OptimisationAlgorithmMethod that tries all the possible solutions.
Notes
Very inefficient for optimization. It is however useful to study a specific case.
All the attributes but
solutionare inherited from the Abstract Base ClassOptimisationAlgorithm.- compute_constraints: Callable[[SimulationOutput], ndarray]
- optimize() OptiSol
Set up the optimization and solve the problem.
- Returns:
opti_sol – Gives list of solutions, corresponding objective, convergence violation if applicable, etc.
- Return type:
- _generate_combinations(n_points: int = 10, **kwargs) tuple[ndarray, ndarray]
Generate all the possible combinations of the variables.
- _array_of_values_to_mesh(objectives_values: ndarray, n_points: int = 10, **kwargs) ndarray
Reformat the results for plotting purposes.
- _generate_opti_sol(variables_values: ndarray, objectives_values: ndarray, criterion: Literal['minimize norm of objective']) OptiSol
Create the dictionary holding all relatable information.
- _take_best_solution(variable_comb: ndarray, objectives_values: ndarray, criterion: Literal['minimize norm of objective']) tuple[ndarray | None, ndarray | None]
Take the “best” of the calculated solutions.
- Parameters:
variable_comb (numpy.ndarray) – All the set of variables (cavity parameters) that were tried.
objectives_values (numpy.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.
- Returns:
best_solution (numpy.ndarray | None) – “Best” solution.
best_objective (numpy.ndarray | None) – Objective values corresponding to
best_solution.
- _abc_impl = <_abc._abc_data object at 0x7f36f75b1a40>