Skip to content

Commit d30ba76

Browse files
authored
Merge branch 'main' into batches_multiprocess
2 parents fdfab16 + 8cfabff commit d30ba76

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

optimizer/objective.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def __init__(self, objective_functions, num_objectives = None) -> None:
99
self.num_objectives = num_objectives
1010
pass
1111

12+
1213
def evaluate(self, items, worker_id=0):
1314
return np.array([objective_function([item for item in items], worker_id) for objective_function in self.objective_functions])
1415

@@ -24,4 +25,4 @@ def evaluate(self, items, worker_id=0):
2425

2526
class BatchObjective(Objective):
2627
def __init__(self, objective_functions, num_objectives=None) -> None:
27-
super().__init__(objective_functions, num_objectives)
28+
super().__init__(objective_functions, num_objectives)

tests/schaffer.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ def f(params):
2424
optimizer.FileManager.working_dir="tmp/schaffer/"
2525
optimizer.FileManager.loading_enabled = True
2626

27-
pso = optimizer.MOPSO(objective_functions=[f],lower_bounds=lb, upper_bounds=ub,
28-
num_objectives=2, num_particles=num_agents, num_iterations=num_iterations,
27+
objective = optimizer.Objective([f])
28+
29+
pso = optimizer.MOPSO(objective=objective,lower_bounds=lb, upper_bounds=ub,
30+
num_particles=num_agents, num_iterations=num_iterations,
2931
inertia_weight=0.5, cognitive_coefficient=1, social_coefficient=1,
3032
max_iter_no_improv=None, optimization_mode='global')
3133

0 commit comments

Comments
 (0)