krotov.result module

Summary

Data:

Result Result object for a Krotov optimization

__all__: Result

Reference

class krotov.result.Result[source]

Bases: object

Result object for a Krotov optimization

objectives

The control objectives

Type:list[Objective]
tlist

The time grid values

Type:numpy.ndarray
iters

Iteration numbers, starting at 0.

Type:list[int]
iter_seconds

for each iteration number, the number of seconds that were spent in the optimization

Type:list[int]
info_vals

For each iteration, the return value of info_hook, or None

Type:list
tau_vals

for each iteration, a list of complex overlaps between the forward-propagated state and the target state for each objective, assuming Objective.target contains the target state.

Type:list[list[complex]
guess_controls

List of the guess controls in array format

Type:list[numpy.ndarray]
optimized_controls

List of the optimized control fields, in the order corresponding to guess_controls

Type:list[numpy.ndarray]
controls_mapping

A nested list that indicates where in objectives the guess_controls and optimized_controls are used (as returned by extract_controls_mapping())

Type:list
all_pulses

If the optimization was performed with store_all_pulses=True, for each iteration, a list of the optimized pulses (in the order corresponding to guess_controls). These pulses are defined at midpoints of the tlist intervals. Empty list if store_all_pulses=False

Type:list
states

for each objective, a list of states for each value in tlist, obtained from propagation under the final optimized control fields.

Type:list[list[qutip.Qobj]]
start_local_time

Time stamp of when the optimization started

Type:time.struct_time
end_local_time

Time stamp of when the optimization ended

Type:time.struct_time
message

Description of why optimize_pulses() completed, E.g, “Reached 1000 iterations”

Type:str
time_fmt = '%Y-%m-%d %H:%M:%S'

Format used in start_local_time_str and end_local_time_str

start_local_time_str

The start_local_time attribute formatted as a string

end_local_time_str

The end_local_time attribute formatted as a string

optimized_objectives

A copy of the objectives with the optimized_controls plugged in

Type:list[Objective]
classmethod load(filename, objectives=None)[source]

Construct Result object from a dump() file

Parameters:
  • filename (str) – The file from which to load the Result. Must be in the format created by dump().
  • objectives (None or list[Objective]) – If given, after loading Result from the given filename, overwrite objectives with the given objectives. This is necessary because dump() does not preserve time-dependent controls that are Python functions.
Returns:

The Result instance loaded from filename

Return type:

Result

dump(filename)[source]

Dump the Result to a binary pickle file.

The original Result object can be restored from the resulting file using load(). However, time-dependent control fields that are callables/functions will not be preserved, as they are not “pickleable”.

Parameters:filename (str) – Name of file to which to dump the Result.