From 0c9ee782949fcf34103f2ec12bd78a3595d264c8 Mon Sep 17 00:00:00 2001 From: Paul Brown Date: Thu, 21 Dec 2023 15:48:43 +0300 Subject: [PATCH] Avoid retrying the same solutions Partially fixes #357. Instead of starting a new epoch immediately at the end of the last one, start epochs when new solution sets are loaded. Scenario index is set at instantiation and does not reset with new epoch. --- mpisppy/cylinders/xhatshufflelooper_bounder.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mpisppy/cylinders/xhatshufflelooper_bounder.py b/mpisppy/cylinders/xhatshufflelooper_bounder.py index 9b98d3861..9af20b711 100644 --- a/mpisppy/cylinders/xhatshufflelooper_bounder.py +++ b/mpisppy/cylinders/xhatshufflelooper_bounder.py @@ -139,6 +139,8 @@ def _vb(msg): # update the caches self.opt._put_nonant_cache(self.localnonants) self.opt._restore_nonants() + + scenario_cycler.begin_epoch() next_scendict = scenario_cycler.get_next() if next_scendict is not None: @@ -147,8 +149,6 @@ def _vb(msg): if update: _vb(f" Updating best to {next_scendict}") scenario_cycler.best = next_scendict - else: - scenario_cycler.begin_epoch() #_vb(f" scenario_cycler._scenarios_this_epoch {scenario_cycler._scenarios_this_epoch}") @@ -174,6 +174,7 @@ def __init__(self, shuffled_scenarios,nonleaves,reverse,iter_step): self._shuffled_scenarios = shuffled_scenarios self._num_scenarios = len(shuffled_scenarios) + self._cycle_idx = 0 self._begin_normal_epoch() self._best = None @@ -249,7 +250,6 @@ def _begin_normal_epoch(self): self._reversed = False self._shuffled_snames = [s[1] for s in self._shuffled_scenarios] self._original_order = [s[0] for s in self._shuffled_scenarios] - self._cycle_idx = 0 self._cur_ROOTscen = self._shuffled_snames[0] self.create_nodescen_dict() @@ -259,7 +259,6 @@ def _begin_reverse_epoch(self): self._reversed = True self._shuffled_snames = [s[1] for s in reversed(self._shuffled_scenarios)] self._original_order = [s[0] for s in reversed(self._shuffled_scenarios)] - self._cycle_idx = 0 self._cur_ROOTscen = self._shuffled_snames[0] self.create_nodescen_dict()