Skip to content

Commit 197b56f

Browse files
committed
implement 'strategy' setter such that it can be changed dynamically
1 parent 722f61a commit 197b56f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

adaptive/learner/balancing_learner.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class BalancingLearner(BaseLearner):
4040
The points that the 'BalancingLearner' choses can be either based on:
4141
the best 'loss_improvements', the smallest total 'loss' of the
4242
child learners, or the number of points per learner, using 'npoints'.
43+
One can dynamically change the strategy while the simulation is
44+
running by changing the 'learner.strategy' attribute.
4345
4446
Notes
4547
-----
@@ -69,6 +71,15 @@ def __init__(self, learners, *, cdims=None, strategy='loss_improvements'):
6971
raise TypeError('A BalacingLearner can handle only one type'
7072
' of learners.')
7173

74+
self.strategy = strategy
75+
76+
@property
77+
def strategy(self):
78+
return self._strategy
79+
80+
@strategy.setter
81+
def strategy(self, strategy):
82+
self._strategy = strategy
7283
if strategy == 'loss_improvements':
7384
self._ask_and_tell = self._ask_and_tell_based_on_loss_improvements
7485
elif strategy == 'loss':

0 commit comments

Comments
 (0)