c3.optimizers.optimizer

Optimizer object, where the optimal control is done.

Module Contents

class c3.optimizers.optimizer.Optimizer(pmap: c3.parametermap.ParameterMap, initial_point: str = '', algorithm: Callable = None, store_unitaries: bool = False, logger: List = None)[source]

General optimizer class from which specific classes are inherited.

Parameters
  • algorithm (callable) – From the algorithm library

  • store_unitaries (boolean) – Store propagators as text and pickle

  • logger (List) – Logging classes

replace_logdir(self, new_logdir)[source]

Specify a new filepath to store the log.

Parameters

new_logdir

set_created_by(self, config) None[source]

Store the config file location used to created this optimizer.

load_best(self, init_point) None[source]

Load a previous parameter point to start the optimization from. Legacy wrapper. Method moved to Parametermap.

Parameters

init_point (str) – File location of the initial point

start_log(self) None[source]

Initialize the log with current time.

end_log(self) None[source]

Finish the log by recording current time and total runtime.

log_best_unitary(self) None[source]

Save the best unitary in the log.

log_parameters(self) None[source]

Log the current status. Write parameters to log. Update the current best parameters. Call plotting functions as set up.

abstract goal_run(self, current_params: Union[numpy.ndarray, tensorflow.constant]) Union[numpy.ndarray, tensorflow.constant][source]

Placeholder for the goal function. To be implemented by inherited classes.

lookup_gradient(self, x)[source]

Return the stored gradient for a given parameter set.

Parameters

x (np.array) – Parameter set.

Returns

Value of the gradient.

Return type

np.array

fct_to_min(self, input_parameters: Union[numpy.ndarray, tensorflow.constant]) Union[numpy.ndarray, tensorflow.constant][source]

Wrapper for the goal function.

Parameters

input_parameters ([np.array, tf.constant]) – Vector of parameters in the optimizer friendly way.

Returns

Value of the goal function. Float if input is np.array else tf.constant

Return type

[np.ndarray, tf.constant]

fct_to_min_autograd(self, x)[source]

Wrapper for the goal function, including evaluation and storage of the gradient.

Parameters
xnp.array

Vector of parameters in the optimizer friendly way.

float

Value of the goal function.