def prepare_optimization(self, initial_optimization_parameters: np.ndarray): """Prepare for the next optimization. Parameters ---------- initial_optimization_parameters : array shape (num_t, num_ctrl) Data stored in this class might be overwritten. """ self._min_costs = np.inf self._min_costs_par = None self._n_cost_fkt_eval = 0 self._n_jac_fkt_eval = 0 self.pulse_shape = initial_optimization_parameters.shape if self.save_intermediary_steps: self.optim_iter_summary = \ optimization_data.OptimizationSummary( indices=self.system_simulator.cost_indices ) self._opt_start_time = time.time() if self.system_simulator.stats is not None: # If the system simulator wants to write down statistics, then # initialise a fresh instance self.system_simulator.stats = \ performance_statistics.PerformanceStatistics() self.system_simulator.stats.start_t_opt = float( self._opt_start_time) self.system_simulator.stats.indices = \ self.system_simulator.cost_indices
def __init__( self, solvers: Optional[Sequence[solver_algorithms.Solver]], cost_fktns: Optional[Sequence[cost_functions.CostFunction]], optimization_parameters=None, num_ctrl=None, times=None, num_times=None, record_performance_statistics: bool = True, numeric_jacobian: bool = False, cost_fktn_weights: Optional[Sequence[float]] = None ): self._num_ctrl = num_ctrl self._num_times = num_times self._optimization_parameteres = optimization_parameters self._times = times self.solvers = solvers self.cost_fktns = cost_fktns self.stats = (performance_statistics.PerformanceStatistics() if record_performance_statistics else None) self.numeric_jacobian = numeric_jacobian self.cost_fktn_weights = cost_fktn_weights if self.cost_fktn_weights is not None: if len(self.cost_fktn_weights) == 0: self.cost_fktn_weights = None elif not len(self.cost_fktns) == len(self.cost_fktn_weights): raise ValueError('A cost function weight must be specified for' 'each cost function or for none at all.')
def __init__(self, solvers: Optional[Sequence[solver_algorithms.Solver]], cost_fktns: Optional[Sequence[cost_functions.CostFunction]], optimization_parameters=None, num_ctrl=None, times=None, num_times=None, record_performance_statistics: bool = True, numeric_jacobian: bool = False): self._num_ctrl = num_ctrl self._num_times = num_times self._optimization_parameteres = optimization_parameters self._times = times self.solvers = solvers self.cost_fktns = cost_fktns self.stats = (performance_statistics.PerformanceStatistics() if record_performance_statistics else None) self.numeric_jacobian = numeric_jacobian