Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alexander R. Hankin
EE194_Manduca_Simulator
Commits
24af9984
Commit
24af9984
authored
May 07, 2018
by
David A.. Werner
Browse files
Population is now sized based on evolution parameter values
parent
21b69633
Changes
1
Hide whitespace changes
Inline
Side-by-side
manduca/Population.py
View file @
24af9984
...
...
@@ -32,10 +32,14 @@ class EvolutionSimulator(object):
def
__init__
(
self
,
population
,
evolution_parameters
=
None
,
random_number_generator
=
None
,
random_seed
=
None
,
pool
=
None
):
"""Population can be array of manducas or tuple of (f, num_pop), where each call to f()
produces a member of the population"""
if
isinstance
(
population
,
tuple
)
:
self
.
population
=
[
population
[
0
]()
for
_
in
range
(
population
[
1
])]
if
evolution_parameters
is
None
:
self
.
evolution_parameters
=
copy
.
copy
(
self
.
__class__
.
default_evolution_parameters
)
else
:
self
.
evolution_parameters
=
copy
.
copy
(
evolution_parameters
)
if
isinstance
(
population
,
list
):
self
.
population
=
population
else
:
self
.
population
=
[
population
()
for
_
in
range
(
self
.
evolution_parameters
.
max_population
)]
n_before
=
len
(
self
.
population
)
self
.
population
=
list
(
set
(
self
.
population
))
n_after
=
len
(
self
.
population
)
...
...
@@ -43,10 +47,6 @@ class EvolutionSimulator(object):
self
.
_children
=
[]
self
.
_mutants
=
[]
self
.
history
=
[]
if
evolution_parameters
is
None
:
self
.
evolution_parameters
=
copy
.
copy
(
self
.
__class__
.
default_evolution_parameters
)
else
:
self
.
evolution_parameters
=
copy
.
copy
(
evolution_parameters
)
if
random_number_generator
is
None
:
self
.
random_number_generator
=
np
.
random
.
RandomState
()
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment