krotov.result module¶
Module defining the Result
object that is returned by
optimize_pulses()
.
Reference¶
-
class
krotov.result.
Result
[source]¶ Bases:
object
Result of a Krotov optimization with
optimize_pulses()
.-
tlist
¶ The time grid values
- Type
-
iter_seconds
¶ for each iteration number, the number of seconds that were spent in the optimization
-
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.
-
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
theguess_controls
andoptimized_controls
are used (as returned byextract_controls_mapping()
)- Type
-
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 toguess_controls
). These pulses are defined at midpoints of the tlist intervals. Empty list ifstore_all_pulses=False
- Type
-
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
-
end_local_time
¶ Time stamp of when the optimization ended
- Type
-
message
¶ Description of why
optimize_pulses()
completed, E.g, “Reached 1000 iterations”- Type
-
time_fmt
= '%Y-%m-%d %H:%M:%S'¶ Format used in
start_local_time_str
andend_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 theoptimized_controls
plugged in.
-
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 asguess_controls
andoptimized_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
andoptimized_controls
, or if any controls are not defined on the points of the time grid.
See also
For plugging in the optimized controls, the
optimized_objectives
attribute is equivalent toresult.objectives_with_controls(result.optimized_controls)
.
-
classmethod
load
(filename, objectives=None, finalize=False)[source]¶ Construct
Result
object from adump()
file- Parameters
filename (str) – The file from which to load the
Result
. Must be in the format created bydump()
.objectives (None or list[Objective]) – If given, after loading
Result
from the given filename, overwriteobjectives
with the given objectives. This is necessary becausedump()
does not preserve time-dependent controls that are Python functions.finalize (bool) – If given as True, make sure that the
optimized_controls
are properly finalized. This allows to load aResult
that was dumped beforeoptimize_pulses()
finished, e.g. bydump_result()
.
- Returns
The
Result
instance loaded from filename- Return type
-