Skip to content

Commit

Permalink
Avoid retrying the same solutions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pdb5627 committed Dec 21, 2023
1 parent 34bd37c commit 0c9ee78
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mpisppy/cylinders/xhatshufflelooper_bounder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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}")

Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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()

Expand Down

0 comments on commit 0c9ee78

Please sign in to comment.