Skip to content

Commit 571fe87

Browse files
committed
v0.0.14 n_jobs==1 fix
1 parent 6717d74 commit 571fe87

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

examples/object_oriented/nqueens/score/NQueensScoreCalculator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def __init__(self):
2727
def all_different(self, planning_entity_dfs, problem_fact_dfs):
2828

2929
queens_df = planning_entity_dfs["queens"]
30-
#print(queens_df)
3130
same_row_id_counts = (
3231
queens_df
3332
.lazy()

greyjack/greyjack/Solver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def _setup_agents(self):
194194
agents[i].initial_solution = deepcopy(self.initial_solution)
195195
agents[i].score_precision = deepcopy(self.score_precision)
196196
agents[i].logging_level = deepcopy(self.logging_level)
197+
agents[i].total_agents_count = self.n_jobs
197198
self.agent_statuses[str(i)] = "alive"
198199

199200
for i in range(self.n_jobs):

greyjack/greyjack/agents/base/Agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self, migration_rate, migration_frequency, termination_strategy):
3939
self.steps_to_send_updates = migration_frequency
4040
self.agent_status = "alive"
4141
self.round_robin_status_dict = {}
42+
self.total_agents_count = None
4243

4344
# windows updates send/receive
4445
self.context = None
@@ -141,9 +142,10 @@ def solve(self):
141142
if self.logging_level in ["trace"] and self.agent_status == "alive":
142143
self.logger.info(f"Agent: {self.agent_id} Step: {step_id} Global best: {self.agent_top_individual.score}, Step time: {total_time:.6f}")
143144

144-
self.steps_to_send_updates -= 1
145-
if self.steps_to_send_updates <= 0:
146-
self.send_receive_updates()
145+
if self.total_agents_count > 1:
146+
self.steps_to_send_updates -= 1
147+
if self.steps_to_send_updates <= 0:
148+
self.send_receive_updates()
147149

148150
if self.termination_strategy.is_accomplish():
149151
self.agent_status = "dead"

0 commit comments

Comments
 (0)