krotov.optimize module¶
Summary¶
Data:
optimize_pulses |
Use Krotov’s method to optimize towards the given objectives |
__all__
: optimize_pulses
Reference¶
-
krotov.optimize.
optimize_pulses
(objectives, pulse_options, tlist, *, propagator, chi_constructor, mu=None, sigma=None, iter_start=0, iter_stop=5000, check_convergence=None, state_dependent_constraint=None, info_hook=None, modify_params_after_iter=None, storage='array', parallel_map=None, store_all_pulses=False)[source]¶ Use Krotov’s method to optimize towards the given objectives
Optimize all time-dependent controls found in the Hamiltonians of the given objectives.
Parameters: - objectives (list[Objective]) – List of objectives
- pulse_options (dict) – Mapping of time-dependent controls found in the
Hamiltonians of the objectives to
PulseOptions
instances. There must be a mapping for each control. As numpy arrays are unhashable and thus cannot be used as dict keys, the options for acontrol
that is an array must set usingpulse_options[id(control)] = ...
- tlist (numpy.ndarray) – Array of time grid values, cf.
mesolve()
- propagator (callable) – Function that propagates the state backward or forwards in time by a single time step, between two points in tlist
- chi_constructor (callable) – Function that calculates the boundary condition for the backward propagation. This is where the final-time functional (indirectly) enters the optimization.
- mu (None or callable) – Function that calculates the derivative
\(\frac{\partial H}{\partial\epsilon}\) for an equation of motion
\(\dot{\phi}(t) = -i H[\phi(t)]\) of an abstract operator \(H\) and an
abstract state \(\phi\). If None, defaults to
krotov.mu.derivative_wrt_pulse()
, which covers the standard Schrödinger and master equations. Seekrotov.mu
for a full explanation of the role of mu in the optimization, and the required function signature. - sigma (None or callable) – Function that calculates the second-order Krotov term. If None, the first-order Krotov method is used.
- iter_start (int) – The formal iteration number at which to start the optimization
- iter_stop (int) – The iteration number after which to end the optimization, whether or not convergence has been reached
- check_convergence (None or callable) – Function that determines whether
the optimization has converged. If None, the optimization will only
end when iter_stop is reached. See
krotov.convergence
for details. - state_dependent_constraint (None or callable) – Function that evaluates a state-dependent constraint. If None, optimize without any state-dependent constraint. Currently not implemented.
- info_hook (None or callable) – Function that is called after each
iteration of the optimization, for the purpose of analysis. Any
value returned by info_hook (e.g. an evaluated functional J_T)
will be stored, for each iteration, in the info_vals attribute of
the returned
Result
. The info_hook must have the same signature askrotov.info_hooks.print_debug_information()
. It should not modify its arguments except for shared_data in any way. - modify_params_after_iter (None or callable) – Function that is called after each iteration, which may modify its arguments for certain advanced use cases, such as dynamically adjusting lambda_vals, or applying spectral filters to the optimized_pulses. It has the same interface as info_hook but should not return anything. The modify_params_after_iter function is called immediately before info_hook, and can transfer arbitrary data to any subsequent info_hook via the shared_data argument.
- storage (callable) – Storage constructor for the storage of
propagated states. Must accept an integer parameter N and return
an empty array of length N. The default value ‘array’ is
equivalent to
functools.partial(numpy.empty, dtype=object)
. - parallel_map (callable or None) – Parallel function evaluator. The
argument must have the same specification as
qutip.parallel.serial_map()
, which is used when None is passed. Alternatives arequtip.parallel.parallel_map()
orqutip.ipynbtools.parallel_map()
. - store_all_pulses (bool) – Whether or not to store the optimized pulses
from all iterations in
Result
.
Returns: The result of the optimization.
Return type: Raises: ValueError
– If any controls are not real-valued, or if any update shape is not a real-valued function in the range [0, 1].