Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/construct-ae-p38-factorial-factors-l4-s1/environment/Dockerfile +7 -0
- tasks/construct-ae-p38-factorial-factors-l4-s1/environment/instance.json +1 -0
- tasks/construct-ae-p38-factorial-factors-l4-s1/solution/solve.sh +5 -0
- tasks/construct-ae-p38-factorial-factors-l4-s1/tests/check.py +12 -0
- tasks/construct-ae-p38-factorial-factors-l4-s1/tests/instance.json +1 -0
- tasks/construct-ae-p38-factorial-factors-l4-s1/tests/run.py +127 -0
- tasks/construct-ae-p38-factorial-factors-l4-s1/tests/test.sh +9 -0
- tasks/construct-ae-p38-factorial-factors-l4-s6/environment/Dockerfile +7 -0
- tasks/construct-ae-p38-factorial-factors-l4-s6/environment/instance.json +1 -0
- tasks/construct-ae-p38-factorial-factors-l4-s6/solution/solve.sh +5 -0
- tasks/construct-ae-p38-factorial-factors-l4-s6/tests/check.py +12 -0
- tasks/construct-ae-p38-factorial-factors-l4-s6/tests/instance.json +1 -0
- tasks/construct-ae-p38-factorial-factors-l4-s6/tests/run.py +127 -0
- tasks/construct-ae-p38-factorial-factors-l4-s6/tests/test.sh +9 -0
- tasks/construct-ae-p38-factorial-factors-l4-s8/environment/Dockerfile +7 -0
- tasks/construct-ae-p38-factorial-factors-l4-s8/environment/instance.json +1 -0
- tasks/construct-ae-p38-factorial-factors-l4-s8/solution/solve.sh +5 -0
- tasks/construct-ae-p38-factorial-factors-l4-s8/tests/check.py +12 -0
- tasks/construct-ae-p38-factorial-factors-l4-s8/tests/instance.json +1 -0
- tasks/construct-ae-p38-factorial-factors-l4-s8/tests/run.py +127 -0
- tasks/construct-ae-p38-factorial-factors-l4-s8/tests/test.sh +9 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s3/environment/Dockerfile +7 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s3/environment/instance.json +1 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s3/solution/solve.sh +5 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/check.py +38 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/instance.json +1 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/run.py +127 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/test.sh +9 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s4/environment/Dockerfile +7 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s4/environment/instance.json +1 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s4/solution/solve.sh +5 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/check.py +38 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/instance.json +1 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/run.py +127 -0
- tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/test.sh +9 -0
- tasks/construct-mc-all-interval-l4-s1/environment/Dockerfile +7 -0
- tasks/construct-mc-all-interval-l4-s1/environment/instance.json +1 -0
- tasks/construct-mc-all-interval-l4-s1/solution/solve.sh +5 -0
- tasks/construct-mc-all-interval-l4-s1/tests/check.py +17 -0
- tasks/construct-mc-all-interval-l4-s1/tests/instance.json +1 -0
- tasks/construct-mc-all-interval-l4-s1/tests/run.py +127 -0
- tasks/construct-mc-all-interval-l4-s1/tests/test.sh +9 -0
- tasks/construct-mc-all-interval-l4-s6/environment/Dockerfile +7 -0
- tasks/construct-mc-all-interval-l4-s6/environment/instance.json +1 -0
- tasks/construct-mc-all-interval-l4-s6/solution/solve.sh +5 -0
- tasks/construct-mc-all-interval-l4-s6/tests/check.py +17 -0
- tasks/construct-mc-all-interval-l4-s6/tests/instance.json +1 -0
- tasks/construct-mc-all-interval-l4-s6/tests/run.py +127 -0
- tasks/construct-mc-all-interval-l4-s6/tests/test.sh +9 -0
- tasks/construct-mc-bibd-l6-s2/environment/Dockerfile +7 -0
tasks/construct-ae-p38-factorial-factors-l4-s1/environment/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11.16-slim
|
| 2 |
+
RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \
|
| 3 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 4 |
+
RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \
|
| 5 |
+
python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755
|
| 6 |
+
WORKDIR /workdir
|
| 7 |
+
COPY instance.json /workdir/instance.json
|
tasks/construct-ae-p38-factorial-factors-l4-s1/environment/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 577, "t": 178, "family": "ae_p38_factorial_factors", "subset": "construct"}
|
tasks/construct-ae-p38-factorial-factors-l4-s1/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# oracle: a known valid construction (planted witness or published solution)
|
| 3 |
+
cat > /workdir/answer.json <<'RLMATH_EOF'
|
| 4 |
+
{"factors": [178, 178, 178, 178, 178, 178, 179, 179, 179, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 181, 181, 181, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 183, 183, 183, 183, 183, 183, 183, 183, 183, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 191, 191, 191, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 193, 193, 194, 194, 194, 194, 194, 196, 196, 196, 196, 196, 196, 196, 196, 197, 197, 199, 199, 201, 201, 201, 201, 201, 201, 201, 201, 202, 202, 202, 202, 202, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 206, 206, 206, 206, 206, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 211, 211, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 213, 213, 213, 213, 213, 213, 213, 213, 214, 214, 214, 214, 214, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 218, 218, 218, 218, 218, 219, 219, 219, 219, 219, 219, 219, 223, 223, 226, 226, 226, 226, 226, 227, 227, 229, 229, 233, 233, 236, 236, 236, 236, 236, 236, 236, 236, 236, 237, 237, 237, 237, 237, 237, 237, 239, 239, 241, 241, 242, 242, 249, 249, 249, 249, 249, 249, 251, 251, 253, 253, 254, 254, 254, 254, 257, 257, 262, 262, 262, 262, 263, 263, 269, 269, 271, 271, 274, 274, 274, 274, 277, 277, 278, 278, 278, 278, 281, 281, 283, 283, 293, 298, 298, 298, 302, 302, 302, 307, 311, 313, 314, 314, 314, 317, 326, 326, 326, 331, 334, 334, 334, 337, 346, 346, 346, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577]}
|
| 5 |
+
RLMATH_EOF
|
tasks/construct-ae-p38-factorial-factors-l4-s1/tests/check.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check."""
|
| 2 |
+
import math
|
| 3 |
+
|
| 4 |
+
from run import Invalid, int_list
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def check(inst, ans):
|
| 8 |
+
n, t = inst["N"], inst["t"]
|
| 9 |
+
f = int_list(ans.get("factors"), n, t, None, "factors")
|
| 10 |
+
if math.prod(f) != math.factorial(n):
|
| 11 |
+
raise Invalid(f"the product of the factors is not {n}!")
|
| 12 |
+
return None, {"min_factor": min(f)}
|
tasks/construct-ae-p38-factorial-factors-l4-s1/tests/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 577, "t": 178, "family": "ae_p38_factorial_factors", "subset": "construct"}
|
tasks/construct-ae-p38-factorial-factors-l4-s1/tests/run.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py.
|
| 2 |
+
|
| 3 |
+
Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only.
|
| 4 |
+
|
| 5 |
+
python3 /tests/run.py /tests/instance.json /workdir/answer.json
|
| 6 |
+
|
| 7 |
+
Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists.
|
| 8 |
+
|
| 9 |
+
check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer.
|
| 10 |
+
construct : value is ignored; a returned check means the witness is valid -> reward 1.0
|
| 11 |
+
optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where
|
| 12 |
+
progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize)
|
| 13 |
+
clip((baseline - s) / (baseline - best_known), 0, 1) (minimize)
|
| 14 |
+
inst must carry "direction", "baseline", "best_known".
|
| 15 |
+
"""
|
| 16 |
+
import json
|
| 17 |
+
import math
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
VALID_FLOOR = 0.1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Invalid(Exception):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# ------------------------------------------------------------ input helpers
|
| 29 |
+
|
| 30 |
+
def int_list(v, n=None, lo=None, hi=None, name="list"):
|
| 31 |
+
if not isinstance(v, list):
|
| 32 |
+
raise Invalid(f"{name} must be a list")
|
| 33 |
+
if n is not None and len(v) != n:
|
| 34 |
+
raise Invalid(f"{name} must have length {n}, got {len(v)}")
|
| 35 |
+
for x in v:
|
| 36 |
+
if isinstance(x, bool) or not isinstance(x, int):
|
| 37 |
+
raise Invalid(f"{name} must contain integers only")
|
| 38 |
+
if (lo is not None and x < lo) or (hi is not None and x > hi):
|
| 39 |
+
raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]")
|
| 40 |
+
return v
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def as_int(x, name="value", lo=None, hi=None):
|
| 44 |
+
return int_list([x], 1, lo, hi, name)[0]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def num(x, name="value"):
|
| 48 |
+
if isinstance(x, bool) or not isinstance(x, (int, float)):
|
| 49 |
+
raise Invalid(f"{name} must be a number")
|
| 50 |
+
if not math.isfinite(x):
|
| 51 |
+
raise Invalid(f"{name} is not finite")
|
| 52 |
+
return float(x)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def float_matrix(v, rows=None, cols=None, name="matrix"):
|
| 56 |
+
if not isinstance(v, list) or (rows is not None and len(v) != rows):
|
| 57 |
+
raise Invalid(f"{name} must be a list of {rows} rows")
|
| 58 |
+
out = []
|
| 59 |
+
for r in v:
|
| 60 |
+
if not isinstance(r, list) or (cols is not None and len(r) != cols):
|
| 61 |
+
raise Invalid(f"each row of {name} must have {cols} numbers")
|
| 62 |
+
out.append([num(x, name) for x in r])
|
| 63 |
+
return out
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def float_list(v, n=None, name="list"):
|
| 67 |
+
if not isinstance(v, list) or (n is not None and len(v) != n):
|
| 68 |
+
raise Invalid(f"{name} must be a list of length {n}")
|
| 69 |
+
return [num(x, name) for x in v]
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# ------------------------------------------------------------------ reward
|
| 73 |
+
|
| 74 |
+
def optimize_reward(inst, s):
|
| 75 |
+
b, best = inst["baseline"], inst["best_known"]
|
| 76 |
+
if inst.get("progress_scale") == "log":
|
| 77 |
+
# for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0);
|
| 78 |
+
# progress is measured in log10(value + floor)
|
| 79 |
+
f = inst.get("log_floor", 1e-3)
|
| 80 |
+
b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s))
|
| 81 |
+
if inst["direction"] == "maximize":
|
| 82 |
+
p = (s - b) / (best - b)
|
| 83 |
+
else:
|
| 84 |
+
p = (b - s) / (b - best)
|
| 85 |
+
return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p))
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def grade(inst, ans, check):
|
| 89 |
+
try:
|
| 90 |
+
if not isinstance(ans, dict):
|
| 91 |
+
raise Invalid("answer must be a JSON object")
|
| 92 |
+
value, extra = check(inst, ans)
|
| 93 |
+
if inst.get("subset") == "optimize":
|
| 94 |
+
s = float(value)
|
| 95 |
+
if not math.isfinite(s):
|
| 96 |
+
raise Invalid("non-finite score")
|
| 97 |
+
return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})}
|
| 98 |
+
return 1.0, {"valid": True, **(extra or {})}
|
| 99 |
+
except Invalid as e:
|
| 100 |
+
return 0.0, {"valid": False, "error": str(e)}
|
| 101 |
+
except Exception as e: # any malformed answer
|
| 102 |
+
return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def main():
|
| 106 |
+
here = os.path.dirname(os.path.abspath(__file__))
|
| 107 |
+
sys.path.insert(0, here)
|
| 108 |
+
# import ourselves as `run` so check.py's `from run import Invalid` is the same class
|
| 109 |
+
import run as R # noqa: E402
|
| 110 |
+
import check as family # noqa: E402
|
| 111 |
+
|
| 112 |
+
inst = json.load(open(sys.argv[1]))
|
| 113 |
+
try:
|
| 114 |
+
ans = json.load(open(sys.argv[2]))
|
| 115 |
+
except Exception as e:
|
| 116 |
+
reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"}
|
| 117 |
+
else:
|
| 118 |
+
reward, det = R.grade(inst, ans, family.check)
|
| 119 |
+
det["reward"] = reward
|
| 120 |
+
if os.path.isdir("/logs/verifier"):
|
| 121 |
+
with open("/logs/verifier/details.json", "w") as f:
|
| 122 |
+
json.dump(det, f)
|
| 123 |
+
print(reward)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__":
|
| 127 |
+
main()
|
tasks/construct-ae-p38-factorial-factors-l4-s1/tests/test.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
mkdir -p /logs/verifier
|
| 3 |
+
if [ ! -s /workdir/answer.json ]; then
|
| 4 |
+
echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json
|
| 5 |
+
echo 0 > /logs/verifier/reward.txt
|
| 6 |
+
exit 0
|
| 7 |
+
fi
|
| 8 |
+
timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \
|
| 9 |
+
> /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt
|
tasks/construct-ae-p38-factorial-factors-l4-s6/environment/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11.16-slim
|
| 2 |
+
RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \
|
| 3 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 4 |
+
RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \
|
| 5 |
+
python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755
|
| 6 |
+
WORKDIR /workdir
|
| 7 |
+
COPY instance.json /workdir/instance.json
|
tasks/construct-ae-p38-factorial-factors-l4-s6/environment/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 891, "t": 278, "family": "ae_p38_factorial_factors", "subset": "construct"}
|
tasks/construct-ae-p38-factorial-factors-l4-s6/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# oracle: a known valid construction (planted witness or published solution)
|
| 3 |
+
cat > /workdir/answer.json <<'RLMATH_EOF'
|
| 4 |
+
{"factors": [278, 278, 278, 278, 278, 278, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 281, 281, 281, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 283, 283, 283, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 291, 291, 291, 291, 291, 291, 291, 291, 291, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 293, 293, 293, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 298, 298, 298, 298, 298, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 300, 300, 300, 300, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 302, 302, 302, 302, 302, 303, 303, 303, 303, 303, 303, 303, 303, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 307, 307, 309, 309, 309, 309, 309, 309, 309, 309, 311, 311, 313, 313, 314, 314, 314, 314, 314, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 317, 317, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 319, 319, 319, 319, 321, 321, 321, 321, 321, 321, 321, 321, 326, 326, 326, 326, 326, 327, 327, 327, 327, 327, 327, 327, 327, 331, 331, 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, 334, 334, 334, 334, 334, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 337, 337, 339, 339, 339, 339, 339, 339, 339, 343, 343, 343, 346, 346, 346, 346, 346, 347, 347, 349, 349, 353, 353, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 357, 358, 358, 358, 358, 359, 359, 362, 362, 362, 362, 367, 367, 373, 373, 379, 379, 381, 381, 381, 381, 381, 381, 381, 382, 382, 382, 382, 383, 383, 386, 386, 386, 386, 389, 389, 393, 393, 393, 393, 393, 393, 394, 394, 394, 394, 397, 397, 398, 398, 398, 398, 401, 401, 409, 409, 411, 411, 411, 411, 411, 411, 419, 419, 421, 421, 422, 422, 422, 422, 431, 431, 433, 433, 439, 439, 443, 443, 446, 446, 446, 449, 454, 454, 454, 457, 458, 458, 458, 461, 463, 466, 466, 466, 467, 478, 478, 478, 479, 482, 482, 482, 487, 491, 499, 502, 502, 502, 503, 509, 514, 514, 514, 521, 523, 526, 526, 526, 538, 538, 538, 541, 542, 542, 542, 547, 554, 554, 554, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887]}
|
| 5 |
+
RLMATH_EOF
|
tasks/construct-ae-p38-factorial-factors-l4-s6/tests/check.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check."""
|
| 2 |
+
import math
|
| 3 |
+
|
| 4 |
+
from run import Invalid, int_list
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def check(inst, ans):
|
| 8 |
+
n, t = inst["N"], inst["t"]
|
| 9 |
+
f = int_list(ans.get("factors"), n, t, None, "factors")
|
| 10 |
+
if math.prod(f) != math.factorial(n):
|
| 11 |
+
raise Invalid(f"the product of the factors is not {n}!")
|
| 12 |
+
return None, {"min_factor": min(f)}
|
tasks/construct-ae-p38-factorial-factors-l4-s6/tests/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 891, "t": 278, "family": "ae_p38_factorial_factors", "subset": "construct"}
|
tasks/construct-ae-p38-factorial-factors-l4-s6/tests/run.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py.
|
| 2 |
+
|
| 3 |
+
Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only.
|
| 4 |
+
|
| 5 |
+
python3 /tests/run.py /tests/instance.json /workdir/answer.json
|
| 6 |
+
|
| 7 |
+
Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists.
|
| 8 |
+
|
| 9 |
+
check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer.
|
| 10 |
+
construct : value is ignored; a returned check means the witness is valid -> reward 1.0
|
| 11 |
+
optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where
|
| 12 |
+
progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize)
|
| 13 |
+
clip((baseline - s) / (baseline - best_known), 0, 1) (minimize)
|
| 14 |
+
inst must carry "direction", "baseline", "best_known".
|
| 15 |
+
"""
|
| 16 |
+
import json
|
| 17 |
+
import math
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
VALID_FLOOR = 0.1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Invalid(Exception):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# ------------------------------------------------------------ input helpers
|
| 29 |
+
|
| 30 |
+
def int_list(v, n=None, lo=None, hi=None, name="list"):
|
| 31 |
+
if not isinstance(v, list):
|
| 32 |
+
raise Invalid(f"{name} must be a list")
|
| 33 |
+
if n is not None and len(v) != n:
|
| 34 |
+
raise Invalid(f"{name} must have length {n}, got {len(v)}")
|
| 35 |
+
for x in v:
|
| 36 |
+
if isinstance(x, bool) or not isinstance(x, int):
|
| 37 |
+
raise Invalid(f"{name} must contain integers only")
|
| 38 |
+
if (lo is not None and x < lo) or (hi is not None and x > hi):
|
| 39 |
+
raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]")
|
| 40 |
+
return v
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def as_int(x, name="value", lo=None, hi=None):
|
| 44 |
+
return int_list([x], 1, lo, hi, name)[0]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def num(x, name="value"):
|
| 48 |
+
if isinstance(x, bool) or not isinstance(x, (int, float)):
|
| 49 |
+
raise Invalid(f"{name} must be a number")
|
| 50 |
+
if not math.isfinite(x):
|
| 51 |
+
raise Invalid(f"{name} is not finite")
|
| 52 |
+
return float(x)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def float_matrix(v, rows=None, cols=None, name="matrix"):
|
| 56 |
+
if not isinstance(v, list) or (rows is not None and len(v) != rows):
|
| 57 |
+
raise Invalid(f"{name} must be a list of {rows} rows")
|
| 58 |
+
out = []
|
| 59 |
+
for r in v:
|
| 60 |
+
if not isinstance(r, list) or (cols is not None and len(r) != cols):
|
| 61 |
+
raise Invalid(f"each row of {name} must have {cols} numbers")
|
| 62 |
+
out.append([num(x, name) for x in r])
|
| 63 |
+
return out
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def float_list(v, n=None, name="list"):
|
| 67 |
+
if not isinstance(v, list) or (n is not None and len(v) != n):
|
| 68 |
+
raise Invalid(f"{name} must be a list of length {n}")
|
| 69 |
+
return [num(x, name) for x in v]
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# ------------------------------------------------------------------ reward
|
| 73 |
+
|
| 74 |
+
def optimize_reward(inst, s):
|
| 75 |
+
b, best = inst["baseline"], inst["best_known"]
|
| 76 |
+
if inst.get("progress_scale") == "log":
|
| 77 |
+
# for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0);
|
| 78 |
+
# progress is measured in log10(value + floor)
|
| 79 |
+
f = inst.get("log_floor", 1e-3)
|
| 80 |
+
b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s))
|
| 81 |
+
if inst["direction"] == "maximize":
|
| 82 |
+
p = (s - b) / (best - b)
|
| 83 |
+
else:
|
| 84 |
+
p = (b - s) / (b - best)
|
| 85 |
+
return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p))
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def grade(inst, ans, check):
|
| 89 |
+
try:
|
| 90 |
+
if not isinstance(ans, dict):
|
| 91 |
+
raise Invalid("answer must be a JSON object")
|
| 92 |
+
value, extra = check(inst, ans)
|
| 93 |
+
if inst.get("subset") == "optimize":
|
| 94 |
+
s = float(value)
|
| 95 |
+
if not math.isfinite(s):
|
| 96 |
+
raise Invalid("non-finite score")
|
| 97 |
+
return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})}
|
| 98 |
+
return 1.0, {"valid": True, **(extra or {})}
|
| 99 |
+
except Invalid as e:
|
| 100 |
+
return 0.0, {"valid": False, "error": str(e)}
|
| 101 |
+
except Exception as e: # any malformed answer
|
| 102 |
+
return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def main():
|
| 106 |
+
here = os.path.dirname(os.path.abspath(__file__))
|
| 107 |
+
sys.path.insert(0, here)
|
| 108 |
+
# import ourselves as `run` so check.py's `from run import Invalid` is the same class
|
| 109 |
+
import run as R # noqa: E402
|
| 110 |
+
import check as family # noqa: E402
|
| 111 |
+
|
| 112 |
+
inst = json.load(open(sys.argv[1]))
|
| 113 |
+
try:
|
| 114 |
+
ans = json.load(open(sys.argv[2]))
|
| 115 |
+
except Exception as e:
|
| 116 |
+
reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"}
|
| 117 |
+
else:
|
| 118 |
+
reward, det = R.grade(inst, ans, family.check)
|
| 119 |
+
det["reward"] = reward
|
| 120 |
+
if os.path.isdir("/logs/verifier"):
|
| 121 |
+
with open("/logs/verifier/details.json", "w") as f:
|
| 122 |
+
json.dump(det, f)
|
| 123 |
+
print(reward)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__":
|
| 127 |
+
main()
|
tasks/construct-ae-p38-factorial-factors-l4-s6/tests/test.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
mkdir -p /logs/verifier
|
| 3 |
+
if [ ! -s /workdir/answer.json ]; then
|
| 4 |
+
echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json
|
| 5 |
+
echo 0 > /logs/verifier/reward.txt
|
| 6 |
+
exit 0
|
| 7 |
+
fi
|
| 8 |
+
timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \
|
| 9 |
+
> /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt
|
tasks/construct-ae-p38-factorial-factors-l4-s8/environment/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11.16-slim
|
| 2 |
+
RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \
|
| 3 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 4 |
+
RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \
|
| 5 |
+
python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755
|
| 6 |
+
WORKDIR /workdir
|
| 7 |
+
COPY instance.json /workdir/instance.json
|
tasks/construct-ae-p38-factorial-factors-l4-s8/environment/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 1117, "t": 350, "family": "ae_p38_factorial_factors", "subset": "construct"}
|
tasks/construct-ae-p38-factorial-factors-l4-s8/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# oracle: a known valid construction (planted witness or published solution)
|
| 3 |
+
cat > /workdir/answer.json <<'RLMATH_EOF'
|
| 4 |
+
{"factors": [350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 353, 353, 353, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 358, 358, 358, 358, 358, 358, 359, 359, 359, 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 362, 362, 362, 362, 362, 362, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 367, 367, 367, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 373, 373, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 379, 379, 380, 381, 381, 381, 381, 381, 381, 381, 381, 382, 382, 382, 382, 382, 383, 383, 386, 386, 386, 386, 386, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 389, 389, 391, 391, 393, 393, 393, 393, 393, 393, 393, 393, 394, 394, 394, 394, 394, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 397, 397, 398, 398, 398, 398, 398, 401, 401, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 406, 406, 406, 406, 406, 406, 406, 406, 409, 409, 411, 411, 411, 411, 411, 411, 411, 411, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, 417, 417, 417, 417, 417, 417, 417, 417, 419, 419, 421, 421, 422, 422, 422, 422, 422, 428, 428, 428, 428, 428, 428, 428, 428, 428, 428, 431, 431, 433, 433, 436, 436, 436, 436, 436, 436, 436, 436, 436, 436, 439, 439, 443, 443, 446, 446, 446, 446, 446, 447, 447, 447, 447, 447, 447, 447, 449, 449, 452, 452, 452, 452, 452, 452, 452, 452, 452, 453, 453, 453, 453, 453, 453, 453, 454, 454, 454, 454, 457, 457, 458, 458, 458, 458, 461, 461, 463, 463, 466, 466, 466, 466, 467, 467, 471, 471, 471, 471, 471, 471, 471, 478, 478, 478, 478, 479, 479, 482, 482, 482, 482, 487, 487, 489, 489, 489, 489, 489, 489, 491, 491, 499, 499, 501, 501, 501, 501, 501, 501, 502, 502, 502, 502, 503, 503, 509, 509, 514, 514, 514, 514, 519, 519, 519, 519, 519, 519, 521, 521, 523, 523, 526, 526, 526, 526, 538, 538, 538, 538, 541, 541, 542, 542, 542, 542, 547, 547, 554, 554, 554, 554, 557, 557, 562, 562, 562, 563, 566, 566, 566, 569, 571, 577, 586, 586, 586, 587, 593, 599, 601, 607, 613, 614, 614, 614, 617, 619, 622, 622, 622, 626, 626, 626, 631, 634, 634, 634, 641, 643, 647, 653, 659, 661, 662, 662, 662, 673, 674, 674, 674, 677, 683, 691, 694, 694, 694, 698, 698, 698, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117]}
|
| 5 |
+
RLMATH_EOF
|
tasks/construct-ae-p38-factorial-factors-l4-s8/tests/check.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check."""
|
| 2 |
+
import math
|
| 3 |
+
|
| 4 |
+
from run import Invalid, int_list
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def check(inst, ans):
|
| 8 |
+
n, t = inst["N"], inst["t"]
|
| 9 |
+
f = int_list(ans.get("factors"), n, t, None, "factors")
|
| 10 |
+
if math.prod(f) != math.factorial(n):
|
| 11 |
+
raise Invalid(f"the product of the factors is not {n}!")
|
| 12 |
+
return None, {"min_factor": min(f)}
|
tasks/construct-ae-p38-factorial-factors-l4-s8/tests/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 1117, "t": 350, "family": "ae_p38_factorial_factors", "subset": "construct"}
|
tasks/construct-ae-p38-factorial-factors-l4-s8/tests/run.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py.
|
| 2 |
+
|
| 3 |
+
Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only.
|
| 4 |
+
|
| 5 |
+
python3 /tests/run.py /tests/instance.json /workdir/answer.json
|
| 6 |
+
|
| 7 |
+
Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists.
|
| 8 |
+
|
| 9 |
+
check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer.
|
| 10 |
+
construct : value is ignored; a returned check means the witness is valid -> reward 1.0
|
| 11 |
+
optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where
|
| 12 |
+
progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize)
|
| 13 |
+
clip((baseline - s) / (baseline - best_known), 0, 1) (minimize)
|
| 14 |
+
inst must carry "direction", "baseline", "best_known".
|
| 15 |
+
"""
|
| 16 |
+
import json
|
| 17 |
+
import math
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
VALID_FLOOR = 0.1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Invalid(Exception):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# ------------------------------------------------------------ input helpers
|
| 29 |
+
|
| 30 |
+
def int_list(v, n=None, lo=None, hi=None, name="list"):
|
| 31 |
+
if not isinstance(v, list):
|
| 32 |
+
raise Invalid(f"{name} must be a list")
|
| 33 |
+
if n is not None and len(v) != n:
|
| 34 |
+
raise Invalid(f"{name} must have length {n}, got {len(v)}")
|
| 35 |
+
for x in v:
|
| 36 |
+
if isinstance(x, bool) or not isinstance(x, int):
|
| 37 |
+
raise Invalid(f"{name} must contain integers only")
|
| 38 |
+
if (lo is not None and x < lo) or (hi is not None and x > hi):
|
| 39 |
+
raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]")
|
| 40 |
+
return v
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def as_int(x, name="value", lo=None, hi=None):
|
| 44 |
+
return int_list([x], 1, lo, hi, name)[0]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def num(x, name="value"):
|
| 48 |
+
if isinstance(x, bool) or not isinstance(x, (int, float)):
|
| 49 |
+
raise Invalid(f"{name} must be a number")
|
| 50 |
+
if not math.isfinite(x):
|
| 51 |
+
raise Invalid(f"{name} is not finite")
|
| 52 |
+
return float(x)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def float_matrix(v, rows=None, cols=None, name="matrix"):
|
| 56 |
+
if not isinstance(v, list) or (rows is not None and len(v) != rows):
|
| 57 |
+
raise Invalid(f"{name} must be a list of {rows} rows")
|
| 58 |
+
out = []
|
| 59 |
+
for r in v:
|
| 60 |
+
if not isinstance(r, list) or (cols is not None and len(r) != cols):
|
| 61 |
+
raise Invalid(f"each row of {name} must have {cols} numbers")
|
| 62 |
+
out.append([num(x, name) for x in r])
|
| 63 |
+
return out
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def float_list(v, n=None, name="list"):
|
| 67 |
+
if not isinstance(v, list) or (n is not None and len(v) != n):
|
| 68 |
+
raise Invalid(f"{name} must be a list of length {n}")
|
| 69 |
+
return [num(x, name) for x in v]
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# ------------------------------------------------------------------ reward
|
| 73 |
+
|
| 74 |
+
def optimize_reward(inst, s):
|
| 75 |
+
b, best = inst["baseline"], inst["best_known"]
|
| 76 |
+
if inst.get("progress_scale") == "log":
|
| 77 |
+
# for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0);
|
| 78 |
+
# progress is measured in log10(value + floor)
|
| 79 |
+
f = inst.get("log_floor", 1e-3)
|
| 80 |
+
b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s))
|
| 81 |
+
if inst["direction"] == "maximize":
|
| 82 |
+
p = (s - b) / (best - b)
|
| 83 |
+
else:
|
| 84 |
+
p = (b - s) / (b - best)
|
| 85 |
+
return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p))
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def grade(inst, ans, check):
|
| 89 |
+
try:
|
| 90 |
+
if not isinstance(ans, dict):
|
| 91 |
+
raise Invalid("answer must be a JSON object")
|
| 92 |
+
value, extra = check(inst, ans)
|
| 93 |
+
if inst.get("subset") == "optimize":
|
| 94 |
+
s = float(value)
|
| 95 |
+
if not math.isfinite(s):
|
| 96 |
+
raise Invalid("non-finite score")
|
| 97 |
+
return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})}
|
| 98 |
+
return 1.0, {"valid": True, **(extra or {})}
|
| 99 |
+
except Invalid as e:
|
| 100 |
+
return 0.0, {"valid": False, "error": str(e)}
|
| 101 |
+
except Exception as e: # any malformed answer
|
| 102 |
+
return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def main():
|
| 106 |
+
here = os.path.dirname(os.path.abspath(__file__))
|
| 107 |
+
sys.path.insert(0, here)
|
| 108 |
+
# import ourselves as `run` so check.py's `from run import Invalid` is the same class
|
| 109 |
+
import run as R # noqa: E402
|
| 110 |
+
import check as family # noqa: E402
|
| 111 |
+
|
| 112 |
+
inst = json.load(open(sys.argv[1]))
|
| 113 |
+
try:
|
| 114 |
+
ans = json.load(open(sys.argv[2]))
|
| 115 |
+
except Exception as e:
|
| 116 |
+
reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"}
|
| 117 |
+
else:
|
| 118 |
+
reward, det = R.grade(inst, ans, family.check)
|
| 119 |
+
det["reward"] = reward
|
| 120 |
+
if os.path.isdir("/logs/verifier"):
|
| 121 |
+
with open("/logs/verifier/details.json", "w") as f:
|
| 122 |
+
json.dump(det, f)
|
| 123 |
+
print(reward)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__":
|
| 127 |
+
main()
|
tasks/construct-ae-p38-factorial-factors-l4-s8/tests/test.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
mkdir -p /logs/verifier
|
| 3 |
+
if [ ! -s /workdir/answer.json ]; then
|
| 4 |
+
echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json
|
| 5 |
+
echo 0 > /logs/verifier/reward.txt
|
| 6 |
+
exit 0
|
| 7 |
+
fi
|
| 8 |
+
timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \
|
| 9 |
+
> /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt
|
tasks/construct-ae-p52-erdos-squarefree-l4-s3/environment/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11.16-slim
|
| 2 |
+
RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \
|
| 3 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 4 |
+
RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \
|
| 5 |
+
python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755
|
| 6 |
+
WORKDIR /workdir
|
| 7 |
+
COPY instance.json /workdir/instance.json
|
tasks/construct-ae-p52-erdos-squarefree-l4-s3/environment/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 2865, "t": 115, "family": "ae_p52_erdos_squarefree", "subset": "construct"}
|
tasks/construct-ae-p52-erdos-squarefree-l4-s3/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# oracle: a known valid construction (planted witness or published solution)
|
| 3 |
+
cat > /workdir/answer.json <<'RLMATH_EOF'
|
| 4 |
+
{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232, 257, 282, 307, 332, 357, 382, 407, 432, 457, 482, 507, 532, 557, 582, 607, 632, 657, 682, 707, 732, 757, 782, 807, 832, 857, 882, 907, 932, 957, 982, 1007, 1032, 1057, 1082, 1107, 1132, 1157, 1182, 1207, 1232, 1257, 1282, 1307, 1332, 1357, 1382, 1407, 1432, 1457, 1482, 1507, 1532, 1557, 1582, 1607, 1632, 1657, 1682, 1707, 1732, 1757, 1782, 1807, 1832, 1857, 1882, 1907, 1932, 1957, 1982, 2007, 2032, 2057, 2082, 2107, 2132, 2157, 2182, 2207, 2232, 2257, 2282, 2307, 2332, 2357, 2382, 2407, 2432, 2457, 2482, 2507, 2532, 2557, 2582, 2607, 2632, 2657, 2682, 2707, 2732, 2757, 2782, 2807, 2832, 2857]}
|
| 5 |
+
RLMATH_EOF
|
tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/check.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A
|
| 2 |
+
(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for
|
| 3 |
+
"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1."""
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
from run import Invalid, int_list
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _primes(n):
|
| 10 |
+
s = np.ones(n + 1, dtype=bool)
|
| 11 |
+
s[:2] = False
|
| 12 |
+
for i in range(2, int(n ** .5) + 1):
|
| 13 |
+
if s[i]:
|
| 14 |
+
s[i * i::i] = False
|
| 15 |
+
return np.nonzero(s)[0]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def check(inst, ans):
|
| 19 |
+
n, t = inst["N"], inst["t"]
|
| 20 |
+
a = ans.get("A")
|
| 21 |
+
if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20):
|
| 22 |
+
raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers")
|
| 23 |
+
int_list(a, None, 1, n, "A")
|
| 24 |
+
if len(set(a)) != len(a):
|
| 25 |
+
raise Invalid("A must consist of distinct integers")
|
| 26 |
+
x = np.array(sorted(a), dtype=np.int64)
|
| 27 |
+
iu, ju = np.triu_indices(len(x))
|
| 28 |
+
va, vb = x[iu], x[ju]
|
| 29 |
+
left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet
|
| 30 |
+
for p in _primes(int((n * n + 1) ** .5) + 1):
|
| 31 |
+
q = int(p) * int(p)
|
| 32 |
+
idx = np.nonzero(left)[0]
|
| 33 |
+
hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0
|
| 34 |
+
left[idx[hit]] = False
|
| 35 |
+
if not left.any():
|
| 36 |
+
return None, {"size": len(a)}
|
| 37 |
+
k = int(np.nonzero(left)[0][0])
|
| 38 |
+
raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree")
|
tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 2865, "t": 115, "family": "ae_p52_erdos_squarefree", "subset": "construct"}
|
tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/run.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py.
|
| 2 |
+
|
| 3 |
+
Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only.
|
| 4 |
+
|
| 5 |
+
python3 /tests/run.py /tests/instance.json /workdir/answer.json
|
| 6 |
+
|
| 7 |
+
Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists.
|
| 8 |
+
|
| 9 |
+
check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer.
|
| 10 |
+
construct : value is ignored; a returned check means the witness is valid -> reward 1.0
|
| 11 |
+
optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where
|
| 12 |
+
progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize)
|
| 13 |
+
clip((baseline - s) / (baseline - best_known), 0, 1) (minimize)
|
| 14 |
+
inst must carry "direction", "baseline", "best_known".
|
| 15 |
+
"""
|
| 16 |
+
import json
|
| 17 |
+
import math
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
VALID_FLOOR = 0.1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Invalid(Exception):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# ------------------------------------------------------------ input helpers
|
| 29 |
+
|
| 30 |
+
def int_list(v, n=None, lo=None, hi=None, name="list"):
|
| 31 |
+
if not isinstance(v, list):
|
| 32 |
+
raise Invalid(f"{name} must be a list")
|
| 33 |
+
if n is not None and len(v) != n:
|
| 34 |
+
raise Invalid(f"{name} must have length {n}, got {len(v)}")
|
| 35 |
+
for x in v:
|
| 36 |
+
if isinstance(x, bool) or not isinstance(x, int):
|
| 37 |
+
raise Invalid(f"{name} must contain integers only")
|
| 38 |
+
if (lo is not None and x < lo) or (hi is not None and x > hi):
|
| 39 |
+
raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]")
|
| 40 |
+
return v
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def as_int(x, name="value", lo=None, hi=None):
|
| 44 |
+
return int_list([x], 1, lo, hi, name)[0]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def num(x, name="value"):
|
| 48 |
+
if isinstance(x, bool) or not isinstance(x, (int, float)):
|
| 49 |
+
raise Invalid(f"{name} must be a number")
|
| 50 |
+
if not math.isfinite(x):
|
| 51 |
+
raise Invalid(f"{name} is not finite")
|
| 52 |
+
return float(x)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def float_matrix(v, rows=None, cols=None, name="matrix"):
|
| 56 |
+
if not isinstance(v, list) or (rows is not None and len(v) != rows):
|
| 57 |
+
raise Invalid(f"{name} must be a list of {rows} rows")
|
| 58 |
+
out = []
|
| 59 |
+
for r in v:
|
| 60 |
+
if not isinstance(r, list) or (cols is not None and len(r) != cols):
|
| 61 |
+
raise Invalid(f"each row of {name} must have {cols} numbers")
|
| 62 |
+
out.append([num(x, name) for x in r])
|
| 63 |
+
return out
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def float_list(v, n=None, name="list"):
|
| 67 |
+
if not isinstance(v, list) or (n is not None and len(v) != n):
|
| 68 |
+
raise Invalid(f"{name} must be a list of length {n}")
|
| 69 |
+
return [num(x, name) for x in v]
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# ------------------------------------------------------------------ reward
|
| 73 |
+
|
| 74 |
+
def optimize_reward(inst, s):
|
| 75 |
+
b, best = inst["baseline"], inst["best_known"]
|
| 76 |
+
if inst.get("progress_scale") == "log":
|
| 77 |
+
# for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0);
|
| 78 |
+
# progress is measured in log10(value + floor)
|
| 79 |
+
f = inst.get("log_floor", 1e-3)
|
| 80 |
+
b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s))
|
| 81 |
+
if inst["direction"] == "maximize":
|
| 82 |
+
p = (s - b) / (best - b)
|
| 83 |
+
else:
|
| 84 |
+
p = (b - s) / (b - best)
|
| 85 |
+
return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p))
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def grade(inst, ans, check):
|
| 89 |
+
try:
|
| 90 |
+
if not isinstance(ans, dict):
|
| 91 |
+
raise Invalid("answer must be a JSON object")
|
| 92 |
+
value, extra = check(inst, ans)
|
| 93 |
+
if inst.get("subset") == "optimize":
|
| 94 |
+
s = float(value)
|
| 95 |
+
if not math.isfinite(s):
|
| 96 |
+
raise Invalid("non-finite score")
|
| 97 |
+
return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})}
|
| 98 |
+
return 1.0, {"valid": True, **(extra or {})}
|
| 99 |
+
except Invalid as e:
|
| 100 |
+
return 0.0, {"valid": False, "error": str(e)}
|
| 101 |
+
except Exception as e: # any malformed answer
|
| 102 |
+
return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def main():
|
| 106 |
+
here = os.path.dirname(os.path.abspath(__file__))
|
| 107 |
+
sys.path.insert(0, here)
|
| 108 |
+
# import ourselves as `run` so check.py's `from run import Invalid` is the same class
|
| 109 |
+
import run as R # noqa: E402
|
| 110 |
+
import check as family # noqa: E402
|
| 111 |
+
|
| 112 |
+
inst = json.load(open(sys.argv[1]))
|
| 113 |
+
try:
|
| 114 |
+
ans = json.load(open(sys.argv[2]))
|
| 115 |
+
except Exception as e:
|
| 116 |
+
reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"}
|
| 117 |
+
else:
|
| 118 |
+
reward, det = R.grade(inst, ans, family.check)
|
| 119 |
+
det["reward"] = reward
|
| 120 |
+
if os.path.isdir("/logs/verifier"):
|
| 121 |
+
with open("/logs/verifier/details.json", "w") as f:
|
| 122 |
+
json.dump(det, f)
|
| 123 |
+
print(reward)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__":
|
| 127 |
+
main()
|
tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/test.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
mkdir -p /logs/verifier
|
| 3 |
+
if [ ! -s /workdir/answer.json ]; then
|
| 4 |
+
echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json
|
| 5 |
+
echo 0 > /logs/verifier/reward.txt
|
| 6 |
+
exit 0
|
| 7 |
+
fi
|
| 8 |
+
timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \
|
| 9 |
+
> /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt
|
tasks/construct-ae-p52-erdos-squarefree-l4-s4/environment/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11.16-slim
|
| 2 |
+
RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \
|
| 3 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 4 |
+
RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \
|
| 5 |
+
python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755
|
| 6 |
+
WORKDIR /workdir
|
| 7 |
+
COPY instance.json /workdir/instance.json
|
tasks/construct-ae-p52-erdos-squarefree-l4-s4/environment/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 2532, "t": 102, "family": "ae_p52_erdos_squarefree", "subset": "construct"}
|
tasks/construct-ae-p52-erdos-squarefree-l4-s4/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# oracle: a known valid construction (planted witness or published solution)
|
| 3 |
+
cat > /workdir/answer.json <<'RLMATH_EOF'
|
| 4 |
+
{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232, 257, 282, 307, 332, 357, 382, 407, 432, 457, 482, 507, 532, 557, 582, 607, 632, 657, 682, 707, 732, 757, 782, 807, 832, 857, 882, 907, 932, 957, 982, 1007, 1032, 1057, 1082, 1107, 1132, 1157, 1182, 1207, 1232, 1257, 1282, 1307, 1332, 1357, 1382, 1407, 1432, 1457, 1482, 1507, 1532, 1557, 1582, 1607, 1632, 1657, 1682, 1707, 1732, 1757, 1782, 1807, 1832, 1857, 1882, 1907, 1932, 1957, 1982, 2007, 2032, 2057, 2082, 2107, 2132, 2157, 2182, 2207, 2232, 2257, 2282, 2307, 2332, 2357, 2382, 2407, 2432, 2457, 2482, 2507, 2532]}
|
| 5 |
+
RLMATH_EOF
|
tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/check.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A
|
| 2 |
+
(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for
|
| 3 |
+
"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1."""
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
from run import Invalid, int_list
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _primes(n):
|
| 10 |
+
s = np.ones(n + 1, dtype=bool)
|
| 11 |
+
s[:2] = False
|
| 12 |
+
for i in range(2, int(n ** .5) + 1):
|
| 13 |
+
if s[i]:
|
| 14 |
+
s[i * i::i] = False
|
| 15 |
+
return np.nonzero(s)[0]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def check(inst, ans):
|
| 19 |
+
n, t = inst["N"], inst["t"]
|
| 20 |
+
a = ans.get("A")
|
| 21 |
+
if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20):
|
| 22 |
+
raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers")
|
| 23 |
+
int_list(a, None, 1, n, "A")
|
| 24 |
+
if len(set(a)) != len(a):
|
| 25 |
+
raise Invalid("A must consist of distinct integers")
|
| 26 |
+
x = np.array(sorted(a), dtype=np.int64)
|
| 27 |
+
iu, ju = np.triu_indices(len(x))
|
| 28 |
+
va, vb = x[iu], x[ju]
|
| 29 |
+
left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet
|
| 30 |
+
for p in _primes(int((n * n + 1) ** .5) + 1):
|
| 31 |
+
q = int(p) * int(p)
|
| 32 |
+
idx = np.nonzero(left)[0]
|
| 33 |
+
hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0
|
| 34 |
+
left[idx[hit]] = False
|
| 35 |
+
if not left.any():
|
| 36 |
+
return None, {"size": len(a)}
|
| 37 |
+
k = int(np.nonzero(left)[0][0])
|
| 38 |
+
raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree")
|
tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"N": 2532, "t": 102, "family": "ae_p52_erdos_squarefree", "subset": "construct"}
|
tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/run.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py.
|
| 2 |
+
|
| 3 |
+
Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only.
|
| 4 |
+
|
| 5 |
+
python3 /tests/run.py /tests/instance.json /workdir/answer.json
|
| 6 |
+
|
| 7 |
+
Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists.
|
| 8 |
+
|
| 9 |
+
check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer.
|
| 10 |
+
construct : value is ignored; a returned check means the witness is valid -> reward 1.0
|
| 11 |
+
optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where
|
| 12 |
+
progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize)
|
| 13 |
+
clip((baseline - s) / (baseline - best_known), 0, 1) (minimize)
|
| 14 |
+
inst must carry "direction", "baseline", "best_known".
|
| 15 |
+
"""
|
| 16 |
+
import json
|
| 17 |
+
import math
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
VALID_FLOOR = 0.1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Invalid(Exception):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# ------------------------------------------------------------ input helpers
|
| 29 |
+
|
| 30 |
+
def int_list(v, n=None, lo=None, hi=None, name="list"):
|
| 31 |
+
if not isinstance(v, list):
|
| 32 |
+
raise Invalid(f"{name} must be a list")
|
| 33 |
+
if n is not None and len(v) != n:
|
| 34 |
+
raise Invalid(f"{name} must have length {n}, got {len(v)}")
|
| 35 |
+
for x in v:
|
| 36 |
+
if isinstance(x, bool) or not isinstance(x, int):
|
| 37 |
+
raise Invalid(f"{name} must contain integers only")
|
| 38 |
+
if (lo is not None and x < lo) or (hi is not None and x > hi):
|
| 39 |
+
raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]")
|
| 40 |
+
return v
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def as_int(x, name="value", lo=None, hi=None):
|
| 44 |
+
return int_list([x], 1, lo, hi, name)[0]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def num(x, name="value"):
|
| 48 |
+
if isinstance(x, bool) or not isinstance(x, (int, float)):
|
| 49 |
+
raise Invalid(f"{name} must be a number")
|
| 50 |
+
if not math.isfinite(x):
|
| 51 |
+
raise Invalid(f"{name} is not finite")
|
| 52 |
+
return float(x)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def float_matrix(v, rows=None, cols=None, name="matrix"):
|
| 56 |
+
if not isinstance(v, list) or (rows is not None and len(v) != rows):
|
| 57 |
+
raise Invalid(f"{name} must be a list of {rows} rows")
|
| 58 |
+
out = []
|
| 59 |
+
for r in v:
|
| 60 |
+
if not isinstance(r, list) or (cols is not None and len(r) != cols):
|
| 61 |
+
raise Invalid(f"each row of {name} must have {cols} numbers")
|
| 62 |
+
out.append([num(x, name) for x in r])
|
| 63 |
+
return out
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def float_list(v, n=None, name="list"):
|
| 67 |
+
if not isinstance(v, list) or (n is not None and len(v) != n):
|
| 68 |
+
raise Invalid(f"{name} must be a list of length {n}")
|
| 69 |
+
return [num(x, name) for x in v]
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# ------------------------------------------------------------------ reward
|
| 73 |
+
|
| 74 |
+
def optimize_reward(inst, s):
|
| 75 |
+
b, best = inst["baseline"], inst["best_known"]
|
| 76 |
+
if inst.get("progress_scale") == "log":
|
| 77 |
+
# for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0);
|
| 78 |
+
# progress is measured in log10(value + floor)
|
| 79 |
+
f = inst.get("log_floor", 1e-3)
|
| 80 |
+
b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s))
|
| 81 |
+
if inst["direction"] == "maximize":
|
| 82 |
+
p = (s - b) / (best - b)
|
| 83 |
+
else:
|
| 84 |
+
p = (b - s) / (b - best)
|
| 85 |
+
return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p))
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def grade(inst, ans, check):
|
| 89 |
+
try:
|
| 90 |
+
if not isinstance(ans, dict):
|
| 91 |
+
raise Invalid("answer must be a JSON object")
|
| 92 |
+
value, extra = check(inst, ans)
|
| 93 |
+
if inst.get("subset") == "optimize":
|
| 94 |
+
s = float(value)
|
| 95 |
+
if not math.isfinite(s):
|
| 96 |
+
raise Invalid("non-finite score")
|
| 97 |
+
return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})}
|
| 98 |
+
return 1.0, {"valid": True, **(extra or {})}
|
| 99 |
+
except Invalid as e:
|
| 100 |
+
return 0.0, {"valid": False, "error": str(e)}
|
| 101 |
+
except Exception as e: # any malformed answer
|
| 102 |
+
return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def main():
|
| 106 |
+
here = os.path.dirname(os.path.abspath(__file__))
|
| 107 |
+
sys.path.insert(0, here)
|
| 108 |
+
# import ourselves as `run` so check.py's `from run import Invalid` is the same class
|
| 109 |
+
import run as R # noqa: E402
|
| 110 |
+
import check as family # noqa: E402
|
| 111 |
+
|
| 112 |
+
inst = json.load(open(sys.argv[1]))
|
| 113 |
+
try:
|
| 114 |
+
ans = json.load(open(sys.argv[2]))
|
| 115 |
+
except Exception as e:
|
| 116 |
+
reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"}
|
| 117 |
+
else:
|
| 118 |
+
reward, det = R.grade(inst, ans, family.check)
|
| 119 |
+
det["reward"] = reward
|
| 120 |
+
if os.path.isdir("/logs/verifier"):
|
| 121 |
+
with open("/logs/verifier/details.json", "w") as f:
|
| 122 |
+
json.dump(det, f)
|
| 123 |
+
print(reward)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__":
|
| 127 |
+
main()
|
tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/test.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
mkdir -p /logs/verifier
|
| 3 |
+
if [ ! -s /workdir/answer.json ]; then
|
| 4 |
+
echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json
|
| 5 |
+
echo 0 > /logs/verifier/reward.txt
|
| 6 |
+
exit 0
|
| 7 |
+
fi
|
| 8 |
+
timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \
|
| 9 |
+
> /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt
|
tasks/construct-mc-all-interval-l4-s1/environment/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11.16-slim
|
| 2 |
+
RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \
|
| 3 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 4 |
+
RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \
|
| 5 |
+
python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755
|
| 6 |
+
WORKDIR /workdir
|
| 7 |
+
COPY instance.json /workdir/instance.json
|
tasks/construct-mc-all-interval-l4-s1/environment/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"n": 28, "fixed": [], "family": "mc_all_interval", "subset": "construct"}
|
tasks/construct-mc-all-interval-l4-s1/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# oracle: a known valid construction (planted witness or published solution)
|
| 3 |
+
cat > /workdir/answer.json <<'RLMATH_EOF'
|
| 4 |
+
{"x": [0, 27, 1, 26, 2, 25, 3, 24, 4, 23, 5, 22, 6, 21, 7, 20, 8, 19, 9, 18, 10, 17, 11, 16, 12, 15, 13, 14]}
|
| 5 |
+
RLMATH_EOF
|
tasks/construct-mc-all-interval-l4-s1/tests/check.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series."""
|
| 2 |
+
from run import Invalid, int_list
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def check(inst, ans):
|
| 6 |
+
n = inst["n"]
|
| 7 |
+
x = int_list(ans.get("x"), n, 0, n - 1, "x")
|
| 8 |
+
if sorted(x) != list(range(n)):
|
| 9 |
+
raise Invalid("x is not a permutation of 0..n-1")
|
| 10 |
+
d = [abs(x[i + 1] - x[i]) for i in range(n - 1)]
|
| 11 |
+
if sorted(d) != list(range(1, n)):
|
| 12 |
+
raise Invalid("consecutive differences are not a permutation of 1..n-1")
|
| 13 |
+
seqs = {"x": x, "d": d}
|
| 14 |
+
for name, i, v in inst.get("fixed", []):
|
| 15 |
+
if seqs[name][i] != v:
|
| 16 |
+
raise Invalid(f"fixed value {name}[{i}] = {v} not respected")
|
| 17 |
+
return None, {}
|
tasks/construct-mc-all-interval-l4-s1/tests/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"n": 28, "fixed": [], "family": "mc_all_interval", "subset": "construct"}
|
tasks/construct-mc-all-interval-l4-s1/tests/run.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py.
|
| 2 |
+
|
| 3 |
+
Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only.
|
| 4 |
+
|
| 5 |
+
python3 /tests/run.py /tests/instance.json /workdir/answer.json
|
| 6 |
+
|
| 7 |
+
Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists.
|
| 8 |
+
|
| 9 |
+
check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer.
|
| 10 |
+
construct : value is ignored; a returned check means the witness is valid -> reward 1.0
|
| 11 |
+
optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where
|
| 12 |
+
progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize)
|
| 13 |
+
clip((baseline - s) / (baseline - best_known), 0, 1) (minimize)
|
| 14 |
+
inst must carry "direction", "baseline", "best_known".
|
| 15 |
+
"""
|
| 16 |
+
import json
|
| 17 |
+
import math
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
VALID_FLOOR = 0.1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Invalid(Exception):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# ------------------------------------------------------------ input helpers
|
| 29 |
+
|
| 30 |
+
def int_list(v, n=None, lo=None, hi=None, name="list"):
|
| 31 |
+
if not isinstance(v, list):
|
| 32 |
+
raise Invalid(f"{name} must be a list")
|
| 33 |
+
if n is not None and len(v) != n:
|
| 34 |
+
raise Invalid(f"{name} must have length {n}, got {len(v)}")
|
| 35 |
+
for x in v:
|
| 36 |
+
if isinstance(x, bool) or not isinstance(x, int):
|
| 37 |
+
raise Invalid(f"{name} must contain integers only")
|
| 38 |
+
if (lo is not None and x < lo) or (hi is not None and x > hi):
|
| 39 |
+
raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]")
|
| 40 |
+
return v
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def as_int(x, name="value", lo=None, hi=None):
|
| 44 |
+
return int_list([x], 1, lo, hi, name)[0]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def num(x, name="value"):
|
| 48 |
+
if isinstance(x, bool) or not isinstance(x, (int, float)):
|
| 49 |
+
raise Invalid(f"{name} must be a number")
|
| 50 |
+
if not math.isfinite(x):
|
| 51 |
+
raise Invalid(f"{name} is not finite")
|
| 52 |
+
return float(x)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def float_matrix(v, rows=None, cols=None, name="matrix"):
|
| 56 |
+
if not isinstance(v, list) or (rows is not None and len(v) != rows):
|
| 57 |
+
raise Invalid(f"{name} must be a list of {rows} rows")
|
| 58 |
+
out = []
|
| 59 |
+
for r in v:
|
| 60 |
+
if not isinstance(r, list) or (cols is not None and len(r) != cols):
|
| 61 |
+
raise Invalid(f"each row of {name} must have {cols} numbers")
|
| 62 |
+
out.append([num(x, name) for x in r])
|
| 63 |
+
return out
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def float_list(v, n=None, name="list"):
|
| 67 |
+
if not isinstance(v, list) or (n is not None and len(v) != n):
|
| 68 |
+
raise Invalid(f"{name} must be a list of length {n}")
|
| 69 |
+
return [num(x, name) for x in v]
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# ------------------------------------------------------------------ reward
|
| 73 |
+
|
| 74 |
+
def optimize_reward(inst, s):
|
| 75 |
+
b, best = inst["baseline"], inst["best_known"]
|
| 76 |
+
if inst.get("progress_scale") == "log":
|
| 77 |
+
# for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0);
|
| 78 |
+
# progress is measured in log10(value + floor)
|
| 79 |
+
f = inst.get("log_floor", 1e-3)
|
| 80 |
+
b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s))
|
| 81 |
+
if inst["direction"] == "maximize":
|
| 82 |
+
p = (s - b) / (best - b)
|
| 83 |
+
else:
|
| 84 |
+
p = (b - s) / (b - best)
|
| 85 |
+
return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p))
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def grade(inst, ans, check):
|
| 89 |
+
try:
|
| 90 |
+
if not isinstance(ans, dict):
|
| 91 |
+
raise Invalid("answer must be a JSON object")
|
| 92 |
+
value, extra = check(inst, ans)
|
| 93 |
+
if inst.get("subset") == "optimize":
|
| 94 |
+
s = float(value)
|
| 95 |
+
if not math.isfinite(s):
|
| 96 |
+
raise Invalid("non-finite score")
|
| 97 |
+
return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})}
|
| 98 |
+
return 1.0, {"valid": True, **(extra or {})}
|
| 99 |
+
except Invalid as e:
|
| 100 |
+
return 0.0, {"valid": False, "error": str(e)}
|
| 101 |
+
except Exception as e: # any malformed answer
|
| 102 |
+
return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def main():
|
| 106 |
+
here = os.path.dirname(os.path.abspath(__file__))
|
| 107 |
+
sys.path.insert(0, here)
|
| 108 |
+
# import ourselves as `run` so check.py's `from run import Invalid` is the same class
|
| 109 |
+
import run as R # noqa: E402
|
| 110 |
+
import check as family # noqa: E402
|
| 111 |
+
|
| 112 |
+
inst = json.load(open(sys.argv[1]))
|
| 113 |
+
try:
|
| 114 |
+
ans = json.load(open(sys.argv[2]))
|
| 115 |
+
except Exception as e:
|
| 116 |
+
reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"}
|
| 117 |
+
else:
|
| 118 |
+
reward, det = R.grade(inst, ans, family.check)
|
| 119 |
+
det["reward"] = reward
|
| 120 |
+
if os.path.isdir("/logs/verifier"):
|
| 121 |
+
with open("/logs/verifier/details.json", "w") as f:
|
| 122 |
+
json.dump(det, f)
|
| 123 |
+
print(reward)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__":
|
| 127 |
+
main()
|
tasks/construct-mc-all-interval-l4-s1/tests/test.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
mkdir -p /logs/verifier
|
| 3 |
+
if [ ! -s /workdir/answer.json ]; then
|
| 4 |
+
echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json
|
| 5 |
+
echo 0 > /logs/verifier/reward.txt
|
| 6 |
+
exit 0
|
| 7 |
+
fi
|
| 8 |
+
timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \
|
| 9 |
+
> /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt
|
tasks/construct-mc-all-interval-l4-s6/environment/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11.16-slim
|
| 2 |
+
RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \
|
| 3 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 4 |
+
RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \
|
| 5 |
+
python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755
|
| 6 |
+
WORKDIR /workdir
|
| 7 |
+
COPY instance.json /workdir/instance.json
|
tasks/construct-mc-all-interval-l4-s6/environment/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"n": 20, "fixed": [], "family": "mc_all_interval", "subset": "construct"}
|
tasks/construct-mc-all-interval-l4-s6/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# oracle: a known valid construction (planted witness or published solution)
|
| 3 |
+
cat > /workdir/answer.json <<'RLMATH_EOF'
|
| 4 |
+
{"x": [0, 19, 1, 18, 2, 17, 3, 16, 4, 15, 5, 14, 6, 13, 7, 12, 8, 11, 9, 10]}
|
| 5 |
+
RLMATH_EOF
|
tasks/construct-mc-all-interval-l4-s6/tests/check.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series."""
|
| 2 |
+
from run import Invalid, int_list
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def check(inst, ans):
|
| 6 |
+
n = inst["n"]
|
| 7 |
+
x = int_list(ans.get("x"), n, 0, n - 1, "x")
|
| 8 |
+
if sorted(x) != list(range(n)):
|
| 9 |
+
raise Invalid("x is not a permutation of 0..n-1")
|
| 10 |
+
d = [abs(x[i + 1] - x[i]) for i in range(n - 1)]
|
| 11 |
+
if sorted(d) != list(range(1, n)):
|
| 12 |
+
raise Invalid("consecutive differences are not a permutation of 1..n-1")
|
| 13 |
+
seqs = {"x": x, "d": d}
|
| 14 |
+
for name, i, v in inst.get("fixed", []):
|
| 15 |
+
if seqs[name][i] != v:
|
| 16 |
+
raise Invalid(f"fixed value {name}[{i}] = {v} not respected")
|
| 17 |
+
return None, {}
|
tasks/construct-mc-all-interval-l4-s6/tests/instance.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"n": 20, "fixed": [], "family": "mc_all_interval", "subset": "construct"}
|
tasks/construct-mc-all-interval-l4-s6/tests/run.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py.
|
| 2 |
+
|
| 3 |
+
Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only.
|
| 4 |
+
|
| 5 |
+
python3 /tests/run.py /tests/instance.json /workdir/answer.json
|
| 6 |
+
|
| 7 |
+
Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists.
|
| 8 |
+
|
| 9 |
+
check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer.
|
| 10 |
+
construct : value is ignored; a returned check means the witness is valid -> reward 1.0
|
| 11 |
+
optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where
|
| 12 |
+
progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize)
|
| 13 |
+
clip((baseline - s) / (baseline - best_known), 0, 1) (minimize)
|
| 14 |
+
inst must carry "direction", "baseline", "best_known".
|
| 15 |
+
"""
|
| 16 |
+
import json
|
| 17 |
+
import math
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
VALID_FLOOR = 0.1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Invalid(Exception):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# ------------------------------------------------------------ input helpers
|
| 29 |
+
|
| 30 |
+
def int_list(v, n=None, lo=None, hi=None, name="list"):
|
| 31 |
+
if not isinstance(v, list):
|
| 32 |
+
raise Invalid(f"{name} must be a list")
|
| 33 |
+
if n is not None and len(v) != n:
|
| 34 |
+
raise Invalid(f"{name} must have length {n}, got {len(v)}")
|
| 35 |
+
for x in v:
|
| 36 |
+
if isinstance(x, bool) or not isinstance(x, int):
|
| 37 |
+
raise Invalid(f"{name} must contain integers only")
|
| 38 |
+
if (lo is not None and x < lo) or (hi is not None and x > hi):
|
| 39 |
+
raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]")
|
| 40 |
+
return v
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def as_int(x, name="value", lo=None, hi=None):
|
| 44 |
+
return int_list([x], 1, lo, hi, name)[0]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def num(x, name="value"):
|
| 48 |
+
if isinstance(x, bool) or not isinstance(x, (int, float)):
|
| 49 |
+
raise Invalid(f"{name} must be a number")
|
| 50 |
+
if not math.isfinite(x):
|
| 51 |
+
raise Invalid(f"{name} is not finite")
|
| 52 |
+
return float(x)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def float_matrix(v, rows=None, cols=None, name="matrix"):
|
| 56 |
+
if not isinstance(v, list) or (rows is not None and len(v) != rows):
|
| 57 |
+
raise Invalid(f"{name} must be a list of {rows} rows")
|
| 58 |
+
out = []
|
| 59 |
+
for r in v:
|
| 60 |
+
if not isinstance(r, list) or (cols is not None and len(r) != cols):
|
| 61 |
+
raise Invalid(f"each row of {name} must have {cols} numbers")
|
| 62 |
+
out.append([num(x, name) for x in r])
|
| 63 |
+
return out
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def float_list(v, n=None, name="list"):
|
| 67 |
+
if not isinstance(v, list) or (n is not None and len(v) != n):
|
| 68 |
+
raise Invalid(f"{name} must be a list of length {n}")
|
| 69 |
+
return [num(x, name) for x in v]
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# ------------------------------------------------------------------ reward
|
| 73 |
+
|
| 74 |
+
def optimize_reward(inst, s):
|
| 75 |
+
b, best = inst["baseline"], inst["best_known"]
|
| 76 |
+
if inst.get("progress_scale") == "log":
|
| 77 |
+
# for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0);
|
| 78 |
+
# progress is measured in log10(value + floor)
|
| 79 |
+
f = inst.get("log_floor", 1e-3)
|
| 80 |
+
b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s))
|
| 81 |
+
if inst["direction"] == "maximize":
|
| 82 |
+
p = (s - b) / (best - b)
|
| 83 |
+
else:
|
| 84 |
+
p = (b - s) / (b - best)
|
| 85 |
+
return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p))
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def grade(inst, ans, check):
|
| 89 |
+
try:
|
| 90 |
+
if not isinstance(ans, dict):
|
| 91 |
+
raise Invalid("answer must be a JSON object")
|
| 92 |
+
value, extra = check(inst, ans)
|
| 93 |
+
if inst.get("subset") == "optimize":
|
| 94 |
+
s = float(value)
|
| 95 |
+
if not math.isfinite(s):
|
| 96 |
+
raise Invalid("non-finite score")
|
| 97 |
+
return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})}
|
| 98 |
+
return 1.0, {"valid": True, **(extra or {})}
|
| 99 |
+
except Invalid as e:
|
| 100 |
+
return 0.0, {"valid": False, "error": str(e)}
|
| 101 |
+
except Exception as e: # any malformed answer
|
| 102 |
+
return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def main():
|
| 106 |
+
here = os.path.dirname(os.path.abspath(__file__))
|
| 107 |
+
sys.path.insert(0, here)
|
| 108 |
+
# import ourselves as `run` so check.py's `from run import Invalid` is the same class
|
| 109 |
+
import run as R # noqa: E402
|
| 110 |
+
import check as family # noqa: E402
|
| 111 |
+
|
| 112 |
+
inst = json.load(open(sys.argv[1]))
|
| 113 |
+
try:
|
| 114 |
+
ans = json.load(open(sys.argv[2]))
|
| 115 |
+
except Exception as e:
|
| 116 |
+
reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"}
|
| 117 |
+
else:
|
| 118 |
+
reward, det = R.grade(inst, ans, family.check)
|
| 119 |
+
det["reward"] = reward
|
| 120 |
+
if os.path.isdir("/logs/verifier"):
|
| 121 |
+
with open("/logs/verifier/details.json", "w") as f:
|
| 122 |
+
json.dump(det, f)
|
| 123 |
+
print(reward)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__":
|
| 127 |
+
main()
|
tasks/construct-mc-all-interval-l4-s6/tests/test.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
mkdir -p /logs/verifier
|
| 3 |
+
if [ ! -s /workdir/answer.json ]; then
|
| 4 |
+
echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json
|
| 5 |
+
echo 0 > /logs/verifier/reward.txt
|
| 6 |
+
exit 0
|
| 7 |
+
fi
|
| 8 |
+
timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \
|
| 9 |
+
> /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt
|
tasks/construct-mc-bibd-l6-s2/environment/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11.16-slim
|
| 2 |
+
RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \
|
| 3 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 4 |
+
RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \
|
| 5 |
+
python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755
|
| 6 |
+
WORKDIR /workdir
|
| 7 |
+
COPY instance.json /workdir/instance.json
|