Skip to content

Commit

Permalink
paper;figure
Browse files Browse the repository at this point in the history
  • Loading branch information
Freakwill committed May 21, 2024
1 parent 8429da5 commit be47850
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
5 changes: 0 additions & 5 deletions pyrimidine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ def equal_to(self, other):
@classmethod
def random(cls, *args, **kwargs):
raise NotImplementedError

def op(self, s):
def _f(*args, **kwargs):
return getattr(self._population, s)(self, *args, **kwargs)
return _f


class BaseIndividual(FitnessMixin, metaclass=MetaContainer):
Expand Down
17 changes: 13 additions & 4 deletions pyrimidine/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,19 @@ def random_select(self, n_sel=None, copy=False):
ks = np.random.randint(len(self), size=n_sel)
return self[ks]

def observe(self, name='_system'):
for o in self:
setattr(o, name, self)

@property
def op(self):
class _C
def __getitem__(obj, s):
def _f(*args, **kwargs):
return getattr(self._system, s)(self, *args, **kwargs)
return _f
return _C()


class PopulationMixin(FitnessMixin, CollectiveMixin):
"""mixin class for population-based heuristic algorithm
Expand Down Expand Up @@ -530,7 +543,3 @@ def drop(self, n=1):
n = int(n)
ks = self.argsort()
self.elements = [self[k] for k in ks[n:]]

def observe(self, name='_population'):
for o in self:
setattr(o, name, self)

0 comments on commit be47850

Please sign in to comment.