Skip to content

Commit

Permalink
Merge branch 'main' into batches_multiprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
waredjeb authored Nov 7, 2023
2 parents fdfab16 + 8cfabff commit d30ba76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion optimizer/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def __init__(self, objective_functions, num_objectives = None) -> None:
self.num_objectives = num_objectives
pass


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

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

class BatchObjective(Objective):
def __init__(self, objective_functions, num_objectives=None) -> None:
super().__init__(objective_functions, num_objectives)
super().__init__(objective_functions, num_objectives)
6 changes: 4 additions & 2 deletions tests/schaffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ def f(params):
optimizer.FileManager.working_dir="tmp/schaffer/"
optimizer.FileManager.loading_enabled = True

pso = optimizer.MOPSO(objective_functions=[f],lower_bounds=lb, upper_bounds=ub,
num_objectives=2, num_particles=num_agents, num_iterations=num_iterations,
objective = optimizer.Objective([f])

pso = optimizer.MOPSO(objective=objective,lower_bounds=lb, upper_bounds=ub,
num_particles=num_agents, num_iterations=num_iterations,
inertia_weight=0.5, cognitive_coefficient=1, social_coefficient=1,
max_iter_no_improv=None, optimization_mode='global')

Expand Down

0 comments on commit d30ba76

Please sign in to comment.