Skip to content

Commit

Permalink
Merge pull request #5 from opensbt/fix-pso
Browse files Browse the repository at this point in the history
Fix.
  • Loading branch information
Leviathan321 authored Dec 11, 2024
2 parents fa6aeb2 + 4d4ec4d commit 46d797d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
10 changes: 5 additions & 5 deletions opensbt/algorithm/nsga2dt_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def run(self) -> SimulationResult:
pop_size=None,
n_offsprings=None,
sampling = select_operator("init", config),
crossover = select_operator( "cx", config),
mutation = select_operator( "mut", config),
crossover = select_operator( "cx", config, **{"eta" : eta_crossover, "prob" : prob_crossover}),
mutation = select_operator( "mut", config, **{"eta" : eta_mutation, "prob" : prob_mutation}),
eliminate_duplicates = select_operator( "dup", config),
archive=MemoryArchive()
)
Expand Down Expand Up @@ -157,12 +157,12 @@ def run(self) -> SimulationResult:
pop_size=pop_size,
n_offsprings=num_offsprings,
sampling=initial_population,
crossover = select_operator("cx",config),
mutation = select_operator("mut", config),
crossover = select_operator( "cx", config, **{"eta" : eta_crossover, "prob" : prob_crossover}),
mutation = select_operator( "mut", config, **{"eta" : eta_mutation, "prob" : prob_mutation}),
eliminate_duplicates = select_operator( "dup", config),
archive=MemoryArchive()
)

print(select_operator("mut", config))

termination = get_termination("n_gen", inner_num_gen)

Expand Down
2 changes: 0 additions & 2 deletions opensbt/algorithm/pso_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def __init__(self,

# initialize algorithm
self.algorithm = PSO(
pop_size=config.population_size,
archive = MemoryArchive(),
pop_size = config.population_size,
sampling = select_operator("init",config),
archive = MemoryArchive()
Expand Down
3 changes: 0 additions & 3 deletions opensbt/utils/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ def select_operator(operation,
"""
Selects either the default operator or a custom operator based on the condition.
"""
if kwargs is not None:
kwargs = {}

if config.operators[operation] is None:
if operation == "mut":
operator = PM
Expand Down

0 comments on commit 46d797d

Please sign in to comment.