Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion popt/update_schemes/enopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ def calc_update(self):
improvement = False
success = False
resampling_iter = 0
self.optimizer.restore_parameters()

while not improvement: # resampling loop

# Shrink covariance each time we try resampling
# Shrink covariance and step size each time we try resampling
shrink = self.cov_factor ** resampling_iter
self.optimizer.apply_backtracking(np.sqrt(self.cov_factor)** resampling_iter)

# Calculate gradient
if self.nesterov:
Expand Down
1 change: 1 addition & 0 deletions popt/update_schemes/genopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def calc_update(self):
improvement = False
success = False
resampling_iter = 0
self.optimizer.restore_parameters()

while improvement is False: # resampling loop

Expand Down
4 changes: 3 additions & 1 deletion popt/update_schemes/smcopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ def calc_update(self,):
success = False
resampling_iter = 0
inflate = 2 * (self.inflation_factor + self.iteration)
self.optimizer.restore_parameters()

while improvement is False: # resampling loop

# Shrink covariance each time we try resampling
# Shrink covariance and step size each time we try resampling
shrink = self.cov_factor ** resampling_iter
self.optimizer.apply_backtracking(np.sqrt(self.cov_factor) ** resampling_iter)

# Calc sensitivity
(sens_matrix, self.best_state, best_func_tmp) = self.sens(self.mean_state, inflate,
Expand Down
6 changes: 3 additions & 3 deletions popt/update_schemes/subroutines/optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ def apply_smc_update(self, control, gradient, **kwargs):
new_control = (1-alpha) * control + alpha * gradient
return new_control

def apply_backtracking(self):
def apply_backtracking(self, shrink=0.5):
"""
Apply backtracking by reducing step size and momentum temporarily.
"""
self._step_size = 0.5*self._step_size
self._momentum = 0.5*self._momentum
self._step_size = shrink*self._step_size
self._momentum = shrink*self._momentum

def restore_parameters(self):
"""
Expand Down