forked from heavywatal/practice-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
probrem heavywatal#14 solving (heavywatal#19)
* heavywatal#14 cleaned * heavywatal#14 print fitness * solved heavywatal#14 * heavywatal#14 modified * heavywatal#14 modified * solved heavywatal#14 * Reduce calculation and rename variables
- Loading branch information
1 parent
f1fdee2
commit a07961e
Showing
2 changed files
with
71 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
class Individual: | ||
def __init__(self, n): | ||
def __init__(self, n, f=1.0): | ||
self._id = n | ||
self._fitness = f | ||
|
||
def get_id(self): | ||
return self._id | ||
|
||
def get_fitness(self): | ||
return self._fitness | ||
|
||
def __repr__(self): | ||
return str(self._id) | ||
|
||
|
||
ind = Individual(42) | ||
print(ind.get_id()) | ||
print(ind) | ||
print(str(ind)) | ||
print(ind.get_fitness()) | ||
|
||
ind2 = Individual(30, 0.8) | ||
print(ind2.get_id()) | ||
print(ind2.get_fitness()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters