# krotov.result module¶

Module defining the Result object that is returned by optimize_pulses().

## Summary¶

Classes:

 Result Result of a Krotov optimization with optimize_pulses().

__all__: Result

## Reference¶

class krotov.result.Result[source]

Bases: object

Result of a Krotov optimization with optimize_pulses().

objectives

The control objectives

Type
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 target state and the forward-propagated state for each objective, assuming Objective.target contains the target state. If there is no target state, an empty list.

Type
guess_controls

List of the guess controls in array format

Type
optimized_controls

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

Type
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
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

property start_local_time_str

The start_local_time attribute formatted as a string

property end_local_time_str

The end_local_time attribute formatted as a string

property optimized_objectives

A copy of the objectives with the optimized_controls plugged in.

Type
objectives_with_controls(controls)[source]

List of objectives with the given controls plugged in.

Parameters

controls (list[numpy.ndarray]) – A list of control fields, defined on the points of tlist. Must be of the same length as guess_controls and optimized_controls.

Returns

A copy of objectives, where all control fields are replaced by the elements of the controls.

Return type
Raises

ValueError – If controls does not have the same number controls as guess_controls and optimized_controls, or if any controls are not defined on the points of the time grid.

For plugging in the optimized controls, the optimized_objectives attribute is equivalent to result.objectives_with_controls(result.optimized_controls).

classmethod load(filename, objectives=None, finalize=False)[source]

Construct Result object from a dump() file

Parameters
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.