Skip to content

Commit

Permalink
Move clone() method to base class.
Browse files Browse the repository at this point in the history
  • Loading branch information
PytLab committed Dec 15, 2017
1 parent 0cb0f49 commit b3b926d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 0 additions & 8 deletions gaft/components/binary_individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ def __init__(self, ranges, eps=0.001):
# Initialize individual randomly.
self.init()

def clone(self):
'''
Clone a new individual from current one.
'''
indv = self.__class__(self.ranges, eps=self.eps)
indv.init(chromsome=self.chromsome)
return indv

def encode(self):
'''
Encode solution to gene sequence in individual using different encoding.
Expand Down
9 changes: 9 additions & 0 deletions gaft/components/individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ def init(self, chromsome=None, solution=None):

return self

def clone(self):
'''
Clone a new individual from current one.
'''
indv = self.__class__(self.ranges, eps=self.eps)
indv.init(chromsome=self.chromsome)
return indv


def encode(self):
''' *NEED IMPLIMENTATION*
Convert solution to chromsome sequence.
Expand Down

0 comments on commit b3b926d

Please sign in to comment.