bluemira.equilibria.optimisation.problem.base

Equilibria Optimisation base module

Classes

CoilsetOptimiserResult

Coilset optimisation result object

CoilsetOptimisationProblem

Abstract base class for coilset optimisation problems.

EqCoilsetOptimisationProblem

Initialise the optimisation problem for a CoilSetMHDState.

Module Contents

class bluemira.equilibria.optimisation.problem.base.CoilsetOptimiserResult

Coilset optimisation result object

coilset: bluemira.equilibria.coils.CoilSet

The optimised coilset.

f_x: float

The evaluation of the optimised parameterisation.

n_evals: int

The number of evaluations of the objective function in the optimisation.

history: list[tuple[numpy.ndarray, float]]

The history of the parameterisation at each iteration.

The first element of each tuple is the parameterisation (x), the second is the evaluation of the objective function at x (f(x)).

constraints_satisfied: bool | None = None

Whether all constraints have been satisfied to within the required tolerance.

Is None if constraints have not been checked.

classmethod from_opt_result(coilset: bluemira.equilibria.coils.CoilSet, opt_result: bluemira.optimisation._optimiser.OptimiserResult) CoilsetOptimiserResult

Make a coilset optimisation result from a normal optimisation result.

Parameters:
Return type:

CoilsetOptimiserResult

class bluemira.equilibria.optimisation.problem.base.CoilsetOptimisationProblem(coilset: bluemira.equilibria.coils.CoilSet, opt_algorithm: bluemira.optimisation._algorithm.AlgorithmType, *, max_currents: numpy.typing.ArrayLike | None = None, targets: bluemira.equilibria.optimisation.constraints.MagneticConstraintSet | None = None, constraints: list[bluemira.equilibria.optimisation.constraints.UpdateableConstraint] | None = None, opt_conditions: dict[str, float | int] | None = None, opt_parameters: dict[str, float] | None = None)

Bases: abc.ABC

Inheritance diagram of bluemira.equilibria.optimisation.problem.base.CoilsetOptimisationProblem

Abstract base class for coilset optimisation problems.

Subclasses should provide an optimise() method that returns an optimised coilset object, optimised according to a specific objective function for that subclass.

Parameters:
_coilset
max_currents = None
bounds
targets
constraints = []
opt_algorithm
opt_conditions
opt_parameters
property coilset: bluemira.equilibria.coils.CoilSet

The optimisation problem coilset

Return type:

bluemira.equilibria.coils.CoilSet

property scale: float

Problem scaling value

Return type:

float

_opt_condition_defaults(default_cond: dict[str, float | int]) dict[str, float | int]
Parameters:

default_cond (dict[str, float | int])

Return type:

dict[str, float | int]

abstract optimise(**kwargs) CoilsetOptimiserResult

Run the coilset optimisation.

Return type:

CoilsetOptimiserResult

get_current_bounds(max_currents: numpy.typing.ArrayLike | None, current_scale: float) tuple[numpy.ndarray, numpy.ndarray]

Gets the scaled current vector bounds. Must be called prior to optimise.

Parameters:
  • max_currents (numpy.typing.ArrayLike | None) – Maximum magnitude of currents in each coil [A] permitted during optimisation. If max_current is supplied as a float, the float will be set as the maximum allowed current magnitude for all coils. If the coils have current density limits that are more restrictive than these coil currents, the smaller current limit of the two will be used for each coil.

  • current_scale (float) – Factor to scale coilset currents down when returning scaled current limits.

Returns:

current_bounds – Tuple of arrays containing lower and upper bounds for currents permitted in each control coil.

Return type:

(np.narray, np.narray)

Raises:

EquilibriaError – Number of max currents not equal to number of optimisable currents

set_current_bounds(max_currents: numpy.typing.NDArray[numpy.float64])

Set the current bounds on this instance.

Parameters:

max_currents (numpy.typing.NDArray[numpy.float64]) – Vector of maximum currents [A]

Raises:

ValueError – Length of max current vector must be equal to controls

_make_numerical_constraints() tuple[list[bluemira.optimisation.typed.ConstraintT], list[bluemira.optimisation.typed.ConstraintT]]

Build the numerical equality and inequality constraint dictionaries.

Returns:

  • equality constraints

  • inequality constriants

Return type:

tuple[list[bluemira.optimisation.typed.ConstraintT], list[bluemira.optimisation.typed.ConstraintT]]

class bluemira.equilibria.optimisation.problem.base.EqCoilsetOptimisationProblem(eq: bluemira.equilibria.equilibrium.Equilibrium, opt_algorithm: bluemira.optimisation._algorithm.AlgorithmType, *, max_currents: numpy.typing.ArrayLike | None = None, targets: bluemira.equilibria.optimisation.constraints.MagneticConstraintSet | None = None, constraints: list[bluemira.equilibria.optimisation.constraints.UpdateableConstraint] | None = None, opt_conditions: dict[str, float | int] | None = None, opt_parameters: dict[str, float] | None = None)

Bases: CoilsetOptimisationProblem

Inheritance diagram of bluemira.equilibria.optimisation.problem.base.EqCoilsetOptimisationProblem

Initialise the optimisation problem for a CoilSetMHDState.

Raises:

ValueError – If the equilibrium does not have a coilset to optimise.

Parameters:
eq
update_magnetic_constraints(*, I_not_dI: bool = True, fixed_coils: bool = True)

Update the magnetic optimisation constraints with the state of the Equilibrium

Parameters:
  • I_not_dI (bool)

  • fixed_coils (bool)