bluemira.equilibria.optimisation.problem._nested_position

OptimisationProblems for coilset design.

New optimisation schemes for the coilset can be provided by subclassing from CoilsetOP, which is an abstract base class for OptimisationProblems that use a coilset as their parameterisation object.

Subclasses must provide an optimise() method that returns an optimised coilset according to a given optimisation objective function. As the exact form of the state vector that is optimised is often specific to each objective function, each subclass of CoilsetOP is generally also specific to a given objective function, since the method used to map the coilset object to the state vector (and additional required arguments) will generally differ in each case.

Classes

NestedCoilsetPositionCOP

Coilset OptimisationProblem for coil currents and positions

PulsedNestedPositionCOP

Coilset position optimisation problem for multiple sub-optimisation problems.

Module Contents

class bluemira.equilibria.optimisation.problem._nested_position.NestedCoilsetPositionCOP(sub_opt: bluemira.equilibria.optimisation.problem.base.EqCoilsetOptimisationProblem, position_mapper: bluemira.utilities.positioning.PositionMapper, opt_algorithm: bluemira.optimisation.AlgorithmType = Algorithm.SBPLX, opt_conditions: dict[str, float] | None = None, opt_parameters: dict[str, float] | None = None, constraints: list[bluemira.equilibria.optimisation.constraints.UpdateableConstraint] | None = None)

Bases: bluemira.equilibria.optimisation.problem.base.EqCoilsetOptimisationProblem

Inheritance diagram of bluemira.equilibria.optimisation.problem._nested_position.NestedCoilsetPositionCOP

Coilset OptimisationProblem for coil currents and positions subject to maximum current bounds and positions bounded within a provided region. Performs a nested optimisation for coil currents within each position optimisation function call.

Parameters:

Notes

Setting stopval and maxeval is the most reliable way to stop optimisation at the desired figure of merit and number of iterations respectively. Some NLOpt optimisers display unexpected behaviour when setting xtol and ftol, and may not terminate as expected when those criteria are reached.

position_mapper
bounds
sub_opt
_get_initial_vector() numpy.typing.NDArray
Returns:

A vector representation of the initial coilset state from the PositionMapper.

Return type:

numpy.typing.NDArray

optimise(x0: numpy.typing.NDArray | None = None, *, keep_history: bool = False, check_constraints: bool = False)

Run the optimisation.

Return type:

Optimised CoilSet object.

Parameters:
  • x0 (numpy.typing.NDArray | None)

  • keep_history (bool)

  • check_constraints (bool)

objective(vector: numpy.typing.NDArray[numpy.float64]) float

Objective function to minimise.

Parameters:

vector (numpy.typing.NDArray[numpy.float64])

Return type:

float

class bluemira.equilibria.optimisation.problem._nested_position.PulsedNestedPositionCOP(coilset: bluemira.equilibria.coils.CoilSet, position_mapper: bluemira.utilities.positioning.PositionMapper, sub_opt_problems: list[bluemira.equilibria.optimisation.problem.base.EqCoilsetOptimisationProblem], opt_algorithm: bluemira.optimisation.AlgorithmType = Algorithm.COBYLA, opt_conditions: dict[str, float] | None = None, opt_parameters: dict[str, float] | None = None, constraints=None, initial_currents=None, current_bounder: bluemira.equilibria.run.MovingCurrentBoundStrategy | None = None, *, debug: bool = False, keep_history: bool = True, check_constraints: bool = True)

Bases: bluemira.equilibria.optimisation.problem.base.CoilsetOptimisationProblem

Inheritance diagram of bluemira.equilibria.optimisation.problem._nested_position.PulsedNestedPositionCOP

Coilset position optimisation problem for multiple sub-optimisation problems.

Parameters:
  • coilset (bluemira.equilibria.coils.CoilSet) – Coilset for which to optimise positions

  • position_mapper (bluemira.utilities.positioning.PositionMapper) – Position mapper tool to parameterise coil positions

  • sub_opt_problems (list[bluemira.equilibria.optimisation.problem.base.EqCoilsetOptimisationProblem]) – The list of sub-optimisation problems to solve

  • opt_algorithm (bluemira.optimisation.AlgorithmType) – The optimisation algorithm to use (e.g. SLSQP)

  • opt_conditions (dict[str, float] | None) – The stopping conditions for the optimiser. for defaults see AlgorithDefaultTolerances along with max_eval=100

  • constraints – Constraints to use. Note these should be applicable to the parametric position vector

  • initial_currents – Initial currents to use when solving the current sub-optimisation problems

  • debug (bool) – Whether or not to run in debug mode (will affect run-time noticeably)

  • opt_parameters (dict[str, float] | None)

  • current_bounder (bluemira.equilibria.run.MovingCurrentBoundStrategy | None)

  • keep_history (bool)

  • check_constraints (bool)

position_mapper
sub_opt_problems
debug
iter
bounds
current_bounder = None
keep_history = True
check_constraints = True
static _run_reporting(itern, max_fom, verbose)

Keep track of objective function value over iterations.

static _run_diagnostics(debug, sub_opt_prob: bluemira.equilibria.optimisation.problem.base.EqCoilsetOptimisationProblem, opt_result: bluemira.equilibria.optimisation.problem.base.CoilsetOptimiserResult)

In debug mode, store the LCFS at each iteration for each of the sub-optimisation problems.

Notes

This can significantly impact run-time.

Parameters:
sub_opt_objective(vector: numpy.typing.NDArray[numpy.float64], *, verbose: bool = False) float

Run the sub-optimisations

Returns:

The largest figure of merit.

Parameters:
  • vector (numpy.typing.NDArray[numpy.float64])

  • verbose (bool)

Return type:

float

objective(vector: numpy.typing.NDArray[numpy.float64], *, verbose: bool = False) float

The objective function of the parent optimisation.

Returns:

Results of the sub-optimisations.

Parameters:
  • vector (numpy.typing.NDArray[numpy.float64])

  • verbose (bool)

Return type:

float

_get_initial_vector() numpy.typing.NDArray[numpy.float64]
Returns:

A vector representation of the initial coilset state from the PositionMapper.

Return type:

numpy.typing.NDArray[numpy.float64]

optimise(x0: numpy.typing.NDArray | None = None, *, verbose: bool = False, keep_history: bool = False, check_constraints: bool = False) bluemira.equilibria.optimisation.problem.base.CoilsetOptimiserResult

Run the PulsedNestedPositionCOP

Parameters:
  • x0 (numpy.typing.NDArray | None) – Initial solution vector (parameterised positions)

  • verbose (bool) – Whether or not to print progress information

  • keep_history (bool)

  • check_constraints (bool)

Returns:

Optimised CoilSet

Return type:

coilset