Add worker/threads flag
This commit is contained in:
parent
c6c04c1025
commit
2da7ea85af
@ -1158,7 +1158,7 @@ class OccasionalBuyer(enum.Enum):
|
||||
]
|
||||
|
||||
|
||||
def Solve(bone_market_fluctuations, zoological_mania, occasional_buyer = None, desired_buyers = [], maximum_cost = cp_model.INT32_MAX, maximum_exhaustion = cp_model.INT32_MAX, time_limit = float('inf'), stdscr = None):
|
||||
def Solve(bone_market_fluctuations, zoological_mania, occasional_buyer = None, desired_buyers = [], maximum_cost = cp_model.INT32_MAX, maximum_exhaustion = cp_model.INT32_MAX, time_limit = float('inf'), workers = os.cpu_count(),stdscr = None):
|
||||
model = cp_model.CpModel()
|
||||
|
||||
actions = {}
|
||||
@ -2113,7 +2113,7 @@ def Solve(bone_market_fluctuations, zoological_mania, occasional_buyer = None, d
|
||||
printer = SkeletonPrinter()
|
||||
|
||||
solver = cp_model.CpSolver()
|
||||
solver.parameters.num_search_workers = os.cpu_count()
|
||||
solver.parameters.num_search_workers = workers
|
||||
solver.parameters.max_time_in_seconds = time_limit
|
||||
|
||||
# There's no window in verbose mode
|
||||
@ -2231,10 +2231,17 @@ def main():
|
||||
help='maximum number of seconds that solver runs for',
|
||||
dest='time_limit'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-w', '--workers',
|
||||
default=os.cpu_count(),
|
||||
type=int,
|
||||
help='number of search worker threads to run in parallel',
|
||||
dest='workers'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
arguments = (args.bone_market_fluctuations, args.zoological_mania, args.occasional_buyer, args.desired_buyers, args.maximum_cost, args.maximum_exhaustion, args.time_limit)
|
||||
arguments = (args.bone_market_fluctuations, args.zoological_mania, args.occasional_buyer, args.desired_buyers, args.maximum_cost, args.maximum_exhaustion, args.time_limit, args.workers)
|
||||
|
||||
if not args.verbose:
|
||||
def WrappedSolve(stdscr, arguments):
|
||||
|
Loading…
Reference in New Issue
Block a user