Skip to content

Commit 5843402

Browse files
committed
feat: msv solver threads
1 parent 517c184 commit 5843402

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

rules/cba.smk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ rule solve_cba_msv_extraction:
343343
solver=RESULTS + "logs/cba/msv/{planning_horizons}_solver.log",
344344
memory=RESULTS + "logs/cba/msv/{planning_horizons}_memory.log",
345345
python=RESULTS + "logs/cba/msv/{planning_horizons}_python.log",
346-
threads: solver_threads
346+
threads: msv_solver_threads
347347
resources:
348348
mem_mb=config_provider("cba", "msv_extraction", "solving", "mem_mb"),
349349
runtime=config_provider(

rules/common.smk

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,31 @@ def solver_threads(w):
167167
return threads
168168

169169

170+
def msv_solver_threads(w):
171+
"""Return solver thread count for the CBA MSV extraction solve.
172+
173+
Resolves threads from the effective MSV solving config, obtained by merging
174+
`cba.msv_extraction.solving` over the top-level `solving` config, mirroring
175+
the merge performed in `solve_cba_msv_extraction.py`.
176+
177+
Parameters
178+
----------
179+
w : snakemake.io.Wildcards
180+
Rule wildcards used to resolve the active scenario config.
181+
182+
Returns
183+
-------
184+
int
185+
Number of solver threads, defaulting to 4 when unset.
186+
"""
187+
solving = copy.deepcopy(config_provider("solving")(w))
188+
update_config(solving, config_provider("cba", "msv_extraction", "solving")(w))
189+
option_set = solving["solver"]["options"]
190+
solver_option_set = solving.get("solver_options", {}).get(option_set, {})
191+
threads = solver_option_set.get("threads") or solver_option_set.get("Threads") or 4
192+
return threads
193+
194+
170195
def memory(w):
171196
factor = 3.0
172197
for o in w.opts.split("-"):

0 commit comments

Comments
 (0)