Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read SPSA from File #1926

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions worker/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,32 +1150,41 @@ def launch_cutechess(
w_params = req["w_params"]
b_params = req["b_params"]

def generate_tune_options(params):
peregrineshahin marked this conversation as resolved.
Show resolved Hide resolved
# Stochastic rounding and probability for float N.p: (N, 1-p); (N+1, p)
options = [
"{},{}".format(
param["name"], math.floor(param["value"] + random.uniform(0, 1))
)
for param in params
]
return ",".join(options)

# Generate option strings for white and black parameters
w_tune_options = generate_tune_options(w_params)
b_tune_options = generate_tune_options(b_params)

# Write option names and values to a file
with open("w_tune_options.csv", "w") as f:
f.write(w_tune_options)

with open("b_tune_options.csv", "w") as f:
f.write(b_tune_options)
else:
w_params = []
b_params = []

# Run cutechess-cli binary.
# Stochastic rounding and probability for float N.p: (N, 1-p); (N+1, p)
idx = cmd.index("_spsa_")
cmd = (
cmd[:idx]
+ [
"option.{}={}".format(
x["name"], math.floor(x["value"] + random.uniform(0, 1))
)
for x in w_params
]
+ (["option.TuneFile=w_tune_options.csv"] if len(w_params) != 0 else [])
+ cmd[idx + 1 :]
)
idx = cmd.index("_spsa_")
cmd = (
cmd[:idx]
+ [
"option.{}={}".format(
x["name"], math.floor(x["value"] + random.uniform(0, 1))
)
for x in b_params
]
+ (["option.TuneFile=b_tune_options.csv"] if len(b_params) != 0 else [])
+ cmd[idx + 1 :]
)

Expand Down
2 changes: 1 addition & 1 deletion worker/sri.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"__version": 241, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "BMuQUpxZAKF0aP6ByTZY1r06MfPoIbdG2xraTrDQQRKgvhzJo6CKmeX2P8vX/QDm", "games.py": "9dFaa914vpqT7q4LLx2LlDdYwK6QFVX3h7+XRt18ATX0lt737rvFeBIiqakkttNC"}
{"__version": 241, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "BMuQUpxZAKF0aP6ByTZY1r06MfPoIbdG2xraTrDQQRKgvhzJo6CKmeX2P8vX/QDm", "games.py": "EPw6bVCRgJT/e7COnAzV+OSUn/yXbhybzfU9oNnBxf/ommjXTByBzUMsh+V+D7Ic"}
Loading