in cfvpy/utils.py [0:0]
def compute_exploitability(model_path, cfg_cfr_eval, cfr_binary="build/cfr"):
root_dir = pathlib.Path(__file__).parent.parent.resolve()
if cfg_cfr_eval.args.num_threads:
num_threads = cfg_cfr_eval.args.num_threads
else:
num_threads = 10 if heyhi.is_on_slurm() else 40
cmd = ("%s -t %d -linear -alternate -decompose -cfr_ave -cfvnet ") % (
cfr_binary,
num_threads,
)
for k, v in cfg_cfr_eval.args.items():
if k == "num_threads":
continue
if v is True:
cmd += f" -{k}"
elif v is False:
pass
else:
cmd += f" -{k} {v}"
logging.debug("Going to run: %s", cmd)
output = subprocess.check_output(
cmd.split() + ["-model", str(model_path.resolve())], cwd=root_dir
)
values = []
for line in output.decode("utf8").split("\n"):
line = line.strip()
if line.startswith("Summed Exploitability:"):
values.append(float(line.split()[-1]))
return values