simba.Modules.optimisation package

Submodules

simba.Modules.optimisation.constraints module

class constraintsClass[source]

Bases: object

constraints(constraints={})[source]
constraintsList(constraints={})[source]
equalto(type, value, limit, weight=1)[source]
formatDict(d, tab=0)[source]
greaterthan(type, value, limit, weight=1)[source]
lessthan(type, value, limit, weight=1)[source]

simba.Modules.optimisation.nelder_mead module

Pure Python/Numpy implementation of the Nelder-Mead algorithm. Taken from fchollet; also see Wikipedia entry

nelder_mead(func, x_start, step=0.1, no_improve_thr=1e-05, no_improv_break=10, max_iter=0, alpha=1.0, gamma=2.0, rho=-0.5, sigma=0.5, converged=None, *args, **kwargs)[source]
@param f (function): function to optimize, must return a scalar score

and operate over a numpy array of the same dimensions as x_start

@param x_start (numpy array): initial position @param step (float): look-around radius in initial step @no_improv_thr, no_improv_break (float, int): break after no_improv_break iterations with

an improvement lower than no_improv_thr

@max_iter (int): always break after this number of iterations.

Set it to 0 to loop indefinitely.

@alpha, gamma, rho, sigma (floats): parameters of the algorithm

(see Wikipedia page for reference)

return: tuple (best parameter array, best score)

simba.Modules.optimisation.optimiser module

class optimiser[source]

Bases: object

eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen, stats=None, halloffame=None, hoffile=None, verbose=True)[source]
eaSimple(population, toolbox, cxpb, mutpb, ngen, stats=None, halloffame=None, hoffile=None, verbose=True)[source]
finish_running(signal, frame)[source]
gaSimple(pop, toolbox, nSelect=None, CXPB=0.5, MUTPB=0.2, ngen=100, stats=None, halloffame=None, hoffile=None, verbose=True)[source]
interrupt = False

simba.Modules.optimisation.xopt module

xopt_optimisation(settings, directory, settings_file, start_lattice=None, end_lattice=None, prefix=None, params=('sigma_x', 'sigma_y', 'sigma_t', 'sigma_z', 'sigma_cp', 'linear_chirp_z', 'beta_x', 'beta_y', 'alpha_x', 'alpha_y', 'peak_current', 'enx', 'eny', 'mean_cp'), sample_interval=1, **kwargs)[source]

Optimisation function for use with xopt.

Parameters:

settingsdict

Variables from the Xopt VOCS, i.e. parameters to be changed. The keys in this dictionary are formatted as elem:param with {elem} the name of the element and param the attribute to be changed. The values in the dictionary are the upper and lower bounds of param.

directorystr

The root framework run directory. Each iteration of the optimisation will produce a subdirectory.

settings_filestr

The .def file in <master_lattice>/Lattices/

start_latticeOptional[str]

The starting lattice line

end_latticeOptional[str]

The ending lattice line

prefix: Optional[list]

Used for framework.set_lattice_prefix(prefix[0], prefix[1]), with [0] the starting line and [1] the location of an existing beam file at the start of that section. prefix[0] will overwrite start_lattice if they are different.

params: list = beam_evaluate

List of attributes of the beam objects in the line. These are possible variables to be optimised at every point along the beamline where a beam is dumped. Can be customised to be any float attribute available to beam.

Returns:

: dict

A dictionary of elem:param : val with elem the beam file names, and param in params

param settings:

type settings:

dict

param directory:

type directory:

str

param settings_file:

type settings_file:

str

param start_lattice:

type start_lattice:

Optional[str]

param end_lattice:

type end_lattice:

Optional[str]

param prefix:

type prefix:

Optional[list]

param params:

type params:

list

param sample_interval:

type sample_interval:

int

Module contents