From 57a2e9ce361b596ff880b5e2184dce64ae16d855 Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Tue, 19 Apr 2022 10:02:03 -0500 Subject: [PATCH] fix: Restore default number of workers OR-Tools 9.3 no longer seems to use more than one worker by default, so this parameter is once again set by the script. The parameter has also been changed from num_search_workers to num_workers internally, though the former is mapped to the latter. --- bonemarketsolver/solve.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bonemarketsolver/solve.py b/bonemarketsolver/solve.py index 7a1c3fa..27daaaa 100644 --- a/bonemarketsolver/solve.py +++ b/bonemarketsolver/solve.py @@ -4,6 +4,7 @@ __all__ = ['Adjustment', 'Appendage', 'Buyer', 'Declaration', 'DiplomatFascinati __author__ = "Jeremy Saklad" from functools import partialmethod +from os import cpu_count from ortools.sat.python import cp_model @@ -30,7 +31,7 @@ MAXIMUM_ATTRIBUTE = 100 DIFFICULTY_SCALER = 0.6 -def Solve(shadowy_level, bone_market_fluctuations = None, zoological_mania = None, occasional_buyer = None, diplomat_fascination = None, desired_buyers = [], maximum_cost = cp_model.INT32_MAX, maximum_exhaustion = cp_model.INT32_MAX, time_limit = float('inf'), workers = None, blacklist = [], stdscr = None): +def Solve(shadowy_level, bone_market_fluctuations = None, zoological_mania = None, occasional_buyer = None, diplomat_fascination = None, desired_buyers = [], maximum_cost = cp_model.INT32_MAX, maximum_exhaustion = cp_model.INT32_MAX, time_limit = float('inf'), workers = cpu_count(), blacklist = [], stdscr = None): model = BoneMarketModel() actions = {} @@ -1099,7 +1100,7 @@ Exhaustion: {solver.Value(exhaustion):n}""" solver = cp_model.CpSolver() if workers: - solver.parameters.num_search_workers = workers + solver.parameters.num_workers = workers solver.parameters.max_time_in_seconds = time_limit # There's no window in verbose mode