Optimization

Guide for beginners

  • Test your optimization problem without collective effects first;

  • Try to find a trade-off between speed and accuracy. In ASTRA simulation, for instance, the knobs are “H_MAX”, “MAX_SCALE”, “MAX_COUNT”, “NRAD”, “NLONG_IN”, etc.;

  • Run some small optimization problems first to familiarize yourself with different optimizers and your problem;

  • Your “Objective” should be much larger than “Absolute tolerance” in the optimizer setup.

class liso.optimization.linac_optimization.Optimization(name='opt_prob', *, opt_func=None)

Bases: object

Inherited from Operation.

variables

variable set.

Type

OrderedDict

covariables

covariable set.

Type

OrderedDict

objectives

objective set.

Type

OrderedDict

e_constraints

equality constraint set.

Type

OrderedDict

i_constraints

inequality constraint set.

Type

OrderedDict

__init__(name='opt_prob', *, opt_func=None)

Initialization.

Parameters
  • name (str) – Name of the optimization problem.

  • opt_func (callable) – A callable object which returns (objective, constraints).

add_var(name, **kwargs)

Add a variable.

del_var(name)

Delete a variable by name.

add_covar(name, *args, **kwargs)

Add a covariable.

del_covar(name)

Delete a covariable by name.

add_obj(name, *args, **kwargs)

Add an objective.

del_obj(name)

Delete an objective by name

add_econ(name, *args, **kwargs)

Add an equality constraint.

del_econ(name)

Delete an equality constraint by name.

add_icon(name, *args, **kwargs)

Add an inequality constraint.

del_icon(name)

Delete an inequality constraint by name.

solve(optimizer, *args, **kwargs)

Run the optimization and print the result.

Parameters

optimizer (Optimizer) – Optimizer instance.

class liso.optimization.linac_optimization.LinacOptimization(linac, *, max_nf=20, **kwargs)

Bases: liso.optimization.linac_optimization.Optimization

Inherited from Optimization.

__init__(linac, *, max_nf=20, **kwargs)

Initialization.

Parameters
  • linac (Linac) – Linac instance.

  • max_nf (int) – Max number of allowed successive failures of of calling Linac.update() method. Default = 20.

solve(optimizer, *args, **kwargs)

Run the optimization and print the result.

Override.