-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parallel population processing #199
Changes from 45 commits
e989f1c
9107d68
25681d4
9be885d
47fc380
39101cb
f3d9907
db34ad1
106fe0a
4a67f81
83f3c0b
0d19cb7
b5abd1a
9cf88de
d19bcde
835d326
13f0ac1
fb39d95
0052e52
72ee29a
0845c11
1b19d34
97d6d9c
d14272f
1a4e5e1
cdbef7d
c3f8cf4
74bebbf
70af4c6
f3c1014
696e6e6
ebad0d6
3c77cfa
461bfe8
eb876ac
cb94833
8045085
14a458b
ce75592
063826e
5c95a71
7ed6107
cfe8e55
1a1aa61
cbc9f92
2112b4c
596cf52
47d92f1
aab0bcd
d301ade
0b0b549
1cea85d
2eb41e5
7f4194c
b03a979
1d40d90
30d03a6
eedbebe
bf6e283
8987b87
6ff8db4
1172caa
e62fa65
f68a039
fe38500
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ class GPAlgorithmParameters(AlgorithmParameters): | |
mutation_prob: float = 0.8 | ||
variable_mutation_num: bool = True | ||
max_num_of_operator_attempts: int = 100 | ||
max_num_of_mutation_attempts: int = 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Теперь получается есть два парметра, для которых не совсем понятно, как и где они применяются и для чего нужны. |
||
mutation_strength: MutationStrengthEnum = MutationStrengthEnum.mean | ||
min_pop_size_with_elitism: int = 5 | ||
required_valid_ratio: float = 0.9 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
if TYPE_CHECKING: | ||
from golem.core.optimisers.genetic.gp_params import GPAlgorithmParameters | ||
|
||
MutationType = Union[MutationTypesEnum, Callable] | ||
MutationFunc = Callable[[Graph, GraphRequirements, GraphGenerationParams, AlgorithmParameters], Graph] | ||
MutationIdType = Hashable | ||
MutationRepo = Mapping[MutationIdType, MutationFunc] | ||
|
@@ -81,11 +82,11 @@ def __call__(self, population: Union[Individual, PopulationT]) -> Union[Individu | |
if isinstance(population, Individual): | ||
population = [population] | ||
|
||
final_population, mutations_applied, application_attempts = tuple(zip(*map(self._mutation, population))) | ||
|
||
# drop individuals to which mutations could not be applied | ||
final_population = [ind for ind, init_ind, attempt in zip(final_population, population, application_attempts) | ||
if not attempt or ind.graph != init_ind.graph] | ||
final_population = [] | ||
kasyanovse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for individual in population: | ||
new_ind, _, applied = self._mutation(individual) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Вроде можно убрать возвращение |
||
if not applied or new_ind.graph != individual.graph: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Понимаю, что раньше такое же условие было, но я бы его переформулировала как |
||
final_population.append(new_ind) | ||
|
||
if len(population) == 1: | ||
return final_population[0] if final_population else final_population | ||
|
@@ -160,3 +161,18 @@ def _get_mutation_func(self, mutation_type: Union[MutationTypesEnum, Callable]) | |
mutation_func = self._mutations_repo[mutation_type] | ||
adapted_mutation_func = self.graph_generation_params.adapter.adapt_func(mutation_func) | ||
return adapted_mutation_func | ||
|
||
|
||
class SinglePredefinedMutation(Mutation): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не совсем понимаю, зачем нужен этот класс. Только он используется в There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Используется |
||
def __call__(self, individual: Individual, mutation_type: MutationType) -> Individual: | ||
new_graph = deepcopy(individual.graph) | ||
mutation_func = self._get_mutation_func(mutation_type) | ||
|
||
new_graph = mutation_func(new_graph, requirements=self.requirements, | ||
graph_gen_params=self.graph_generation_params, | ||
parameters=self.parameters) | ||
|
||
parent_operator = ParentOperator(type_='mutation', operators=mutation_type, parent_individuals=individual) | ||
individual = Individual(new_graph, parent_operator, | ||
metadata=self.requirements.static_individual_metadata) | ||
return individual, mutation_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Стоит
_mutate_over_population
сделать public, так как он внеReproductionController
используется