diff --git a/tasks/construct-ae-p58-happy-ending-l3-s0/environment/Dockerfile b/tasks/construct-ae-p58-happy-ending-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l3-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p58-happy-ending-l3-s0/environment/instance.json b/tasks/construct-ae-p58-happy-ending-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b96c92cfd739f62ff522c0a714707326b046f50a --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 7, "max_abs": 1000000000000000000, "family": "ae_p58_happy_ending", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p58-happy-ending-l3-s0/solution/solve.sh b/tasks/construct-ae-p58-happy-ending-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..10aeddc3153353ef1072e917d3f3a83b5425fa1d --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l3-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0, 0], [846000, -846000000], [846001, -845999998], [846002, -845999990], [846003, -845999954], [846004, -845999762], [1692000, -3384000000], [1692001, -3383999990], [1692002, -3383999988], [1692003, -3383999924], [1692004, -3383999922], [1692005, -3383999914], [1692006, -3383999250], [1692007, -3383999248], [1692008, -3383999240], [1692009, -3383999204], [2538000, -7614000000], [2538001, -7613999944], [2538002, -7613999934], [2538003, -7613999932], [2538004, -7613999250], [2538005, -7613999240], [2538006, -7613999238], [2538007, -7613999174], [2538008, -7613999172], [2538009, -7613999164], [3384000, -13536000000], [3384001, -13535999638], [3384002, -13535999582], [3384003, -13535999572], [3384004, -13535999570], [4230000, -21150000000]]} +RLMATH_EOF diff --git a/tasks/construct-ae-p58-happy-ending-l3-s0/tests/check.py b/tasks/construct-ae-p58-happy-ending-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..47e4606e109bc165111a8138a5a2f60870d563c8 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l3-s0/tests/check.py @@ -0,0 +1,69 @@ +"""Erdos-Szekeres happy ending (AlphaEvolve problem 58): n = 2^(k-2) integer points in general position with no +k points in convex position. Exact integer orientation tests; the largest convex-position subset is computed by +the O(n^4) bottom-vertex / angular-order dynamic programme. + +Upstream bug: the notebook's verifier uses float orientations with a 1e-9 threshold (and numba fastmath); its +33- and 65-point sets (claimed to have "0 convex k-gons") contain a convex 7-gon / 8-gon under exact arithmetic.""" +import functools + +import numpy as np + +from run import Invalid, int_list + + +def orient_table(p): + n = len(p) + o = np.zeros((n, n, n), dtype=np.int8) + for i in range(n): + xi, yi = p[i] + for j in range(i + 1, n): + dx, dy = p[j][0] - xi, p[j][1] - yi + for k in range(j + 1, n): + c = dx * (p[k][1] - yi) - dy * (p[k][0] - xi) + if c == 0: + raise Invalid(f"points {p[i]}, {p[j]}, {p[k]} are collinear") + s = 1 if c > 0 else -1 + o[i, j, k] = o[j, k, i] = o[k, i, j] = s + o[i, k, j] = o[k, j, i] = o[j, i, k] = -s + return o + + +def max_convex(p, o): + n = len(p) + best = min(n, 3) + order = sorted(range(n), key=lambda i: (p[i][1], p[i][0])) + for bi, b in enumerate(order): + rest = order[bi + 1:] + m = len(rest) + if m < 2: + continue + rest = sorted(rest, key=functools.cmp_to_key(lambda u, v: -int(o[b, u, v]))) + r = np.array(rest) + chain = np.zeros((m, m), dtype=np.int32) # chain[i, j]: longest convex chain b .. r_i -> r_j + for j in range(1, m): + for i in range(j): + v = 3 + if i > 0: + ok = (chain[:i, i] > 0) & (o[r[:i], r[i], r[j]] > 0) + if ok.any(): + v = max(v, int(chain[:i, i][ok].max()) + 1) + chain[i, j] = v + close = o[r[:j], r[j], b] > 0 + if close.any(): + best = max(best, int(chain[:j, j][close].max())) + return best + + +def check(inst, ans): + n, k, lim = inst["n"], inst["k"], inst["max_abs"] + pts = ans.get("points") + if not isinstance(pts, list) or len(pts) != n: + raise Invalid(f"points must be a list of {n} [x, y] pairs") + p = [tuple(int_list(q, 2, -lim, lim, "point")) for q in pts] + if len(set(p)) != n: + raise Invalid("points must be distinct") + o = orient_table(p) + mc = max_convex(p, o) + if mc >= k: + raise Invalid(f"the set contains {mc} points in convex position (>= {k})") + return None, {"max_convex_subset": mc} diff --git a/tasks/construct-ae-p58-happy-ending-l3-s0/tests/instance.json b/tasks/construct-ae-p58-happy-ending-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b96c92cfd739f62ff522c0a714707326b046f50a --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 7, "max_abs": 1000000000000000000, "family": "ae_p58_happy_ending", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p58-happy-ending-l3-s0/tests/run.py b/tasks/construct-ae-p58-happy-ending-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l3-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p58-happy-ending-l3-s0/tests/test.sh b/tasks/construct-ae-p58-happy-ending-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l3-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-bibd-l3-s2/environment/Dockerfile b/tasks/construct-mc-bibd-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-l3-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-bibd-l3-s2/environment/instance.json b/tasks/construct-mc-bibd-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2708247052f7f74c0da46aa496ed1a48b65c5794 --- /dev/null +++ b/tasks/construct-mc-bibd-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"v": 15, "k": 3, "lambda": 1, "b": 35, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l3-s2/solution/solve.sh b/tasks/construct-mc-bibd-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8f38d60e587b6d3dfccf1c105a5246bf5f2ec508 --- /dev/null +++ b/tasks/construct-mc-bibd-l3-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"blocks": [[0, 1, 4], [1, 2, 5], [2, 3, 6], [3, 4, 7], [4, 5, 8], [5, 6, 9], [6, 7, 10], [7, 8, 11], [8, 9, 12], [9, 10, 13], [10, 11, 14], [0, 11, 12], [1, 12, 13], [2, 13, 14], [0, 3, 14], [0, 2, 8], [1, 3, 9], [2, 4, 10], [3, 5, 11], [4, 6, 12], [5, 7, 13], [6, 8, 14], [0, 7, 9], [1, 8, 10], [2, 9, 11], [3, 10, 12], [4, 11, 13], [5, 12, 14], [0, 6, 13], [1, 7, 14], [0, 5, 10], [1, 6, 11], [2, 7, 12], [3, 8, 13], [4, 9, 14]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l3-s2/tests/check.py b/tasks/construct-mc-bibd-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l3-s2/tests/check.py @@ -0,0 +1,25 @@ +"""Balanced incomplete block design BIBD(v, k, lambda) (MathConstraint bibd, CC-BY-4.0). +Answer = list of b blocks; every block is a k-subset of {0..v-1}, every pair of points lies in exactly +lambda blocks (which forces every point to lie in r blocks). Repeated blocks are allowed, as upstream +(its 0/1 incidence-matrix model does not forbid equal columns).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + v, k, lam, b = inst["v"], inst["k"], inst["lambda"], inst["b"] + blocks = ans.get("blocks") + if not isinstance(blocks, list) or len(blocks) != b: + raise Invalid(f"blocks must be a list of exactly {b} blocks") + pair = {} + for B in blocks: + B = int_list(B, k, 0, v - 1, "block") + if len(set(B)) != k: + raise Invalid("a block contains a repeated point") + for p in itertools.combinations(sorted(B), 2): + pair[p] = pair.get(p, 0) + 1 + for p in itertools.combinations(range(v), 2): + if pair.get(p, 0) != lam: + raise Invalid(f"points {p} lie together in {pair.get(p, 0)} blocks, need {lam}") + return None, {} diff --git a/tasks/construct-mc-bibd-l3-s2/tests/instance.json b/tasks/construct-mc-bibd-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2708247052f7f74c0da46aa496ed1a48b65c5794 --- /dev/null +++ b/tasks/construct-mc-bibd-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"v": 15, "k": 3, "lambda": 1, "b": 35, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l3-s2/tests/run.py b/tasks/construct-mc-bibd-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-l3-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-bibd-l3-s2/tests/test.sh b/tasks/construct-mc-bibd-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-l3-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-golomb-l1-s2/environment/Dockerfile b/tasks/construct-mc-golomb-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-golomb-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-golomb-l1-s2/environment/instance.json b/tasks/construct-mc-golomb-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6da28c12943dc8133c2c2f05b372f9fec198a65a --- /dev/null +++ b/tasks/construct-mc-golomb-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 7, "max_length": 25, "fixed": [["marks", 1, 2]], "family": "mc_golomb", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-golomb-l1-s2/solution/solve.sh b/tasks/construct-mc-golomb-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..59530840bb11de5d896ff428b8a6d387b3b95c2a --- /dev/null +++ b/tasks/construct-mc-golomb-l1-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"marks": [0, 2, 6, 9, 14, 24, 25]} +RLMATH_EOF diff --git a/tasks/construct-mc-golomb-l1-s2/tests/check.py b/tasks/construct-mc-golomb-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..84aedd6e33fee7271543bfa49ab05128e23c31ee --- /dev/null +++ b/tasks/construct-mc-golomb-l1-s2/tests/check.py @@ -0,0 +1,27 @@ +"""Golomb ruler with n marks and length <= L (MathConstraint golomb, CC-BY-4.0, reframed as a decision +problem with the target length stated). Accepts any valid ruler. +Upstream note: the upstream prompt states no length bound and its verifier re-solves the optimisation +model with the marks fixed, which returns OPTIMUM for any Golomb ruler, so any ruler (e.g. 0,1,3,7,15,..) +was accepted. Here the length bound is part of the instance and enforced.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, L = inst["n"], inst["max_length"] + a = int_list(ans.get("marks"), n, 0, L, "marks") + if a[0] != 0: + raise Invalid("first mark must be 0") + if any(a[i] >= a[i + 1] for i in range(n - 1)): + raise Invalid("marks must be strictly increasing") + for name, i, v in inst.get("fixed", []): + if a[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + seen = set() + for i, j in itertools.combinations(range(n), 2): + d = a[j] - a[i] + if d in seen: + raise Invalid(f"difference {d} occurs twice") + seen.add(d) + return None, {"length": a[-1]} diff --git a/tasks/construct-mc-golomb-l1-s2/tests/instance.json b/tasks/construct-mc-golomb-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6da28c12943dc8133c2c2f05b372f9fec198a65a --- /dev/null +++ b/tasks/construct-mc-golomb-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 7, "max_length": 25, "fixed": [["marks", 1, 2]], "family": "mc_golomb", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-golomb-l1-s2/tests/run.py b/tasks/construct-mc-golomb-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-golomb-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-golomb-l1-s2/tests/test.sh b/tasks/construct-mc-golomb-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-golomb-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l3-s6/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graph-k-coloring-l3-s6/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..23506e5bc5d3a594d65a9f4d9c0c57e65e511314 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 51, "k": 4, "edges": [[0, 1], [0, 2], [0, 7], [0, 10], [0, 21], [0, 23], [0, 27], [0, 38], [0, 43], [0, 44], [1, 2], [1, 7], [1, 11], [1, 13], [1, 14], [1, 18], [1, 21], [1, 22], [1, 23], [1, 32], [1, 36], [2, 14], [2, 21], [2, 30], [3, 8], [3, 12], [3, 15], [3, 19], [3, 22], [3, 23], [3, 27], [3, 28], [3, 30], [3, 31], [3, 33], [3, 35], [3, 45], [3, 48], [4, 20], [4, 25], [4, 26], [4, 43], [5, 9], [5, 15], [5, 16], [5, 28], [5, 34], [5, 35], [5, 49], [6, 8], [6, 9], [6, 33], [6, 42], [6, 44], [6, 47], [7, 13], [7, 32], [7, 35], [7, 36], [7, 47], [8, 12], [8, 15], [8, 18], [8, 20], [8, 23], [8, 31], [8, 37], [8, 38], [9, 10], [9, 19], [9, 26], [9, 31], [9, 37], [9, 40], [10, 16], [10, 24], [10, 25], [10, 33], [11, 14], [11, 32], [11, 33], [11, 34], [11, 35], [11, 43], [12, 38], [12, 48], [13, 20], [14, 15], [14, 17], [14, 20], [14, 31], [14, 39], [14, 41], [15, 16], [15, 19], [15, 27], [16, 19], [16, 43], [16, 44], [17, 22], [17, 28], [17, 44], [18, 31], [18, 40], [18, 45], [18, 46], [19, 20], [19, 23], [19, 25], [19, 35], [19, 37], [19, 38], [19, 47], [20, 24], [20, 31], [20, 33], [21, 31], [21, 33], [21, 45], [21, 50], [22, 23], [22, 41], [23, 26], [23, 30], [23, 34], [23, 37], [23, 48], [24, 27], [24, 29], [24, 39], [24, 41], [24, 43], [24, 44], [24, 47], [25, 50], [26, 34], [26, 35], [26, 36], [26, 47], [26, 49], [26, 50], [27, 32], [27, 38], [27, 40], [27, 43], [27, 44], [27, 48], [27, 50], [28, 33], [28, 41], [28, 47], [29, 31], [29, 39], [29, 47], [30, 31], [30, 48], [31, 32], [32, 34], [32, 44], [32, 47], [33, 34], [33, 39], [35, 47], [36, 41], [36, 43], [37, 38], [37, 43], [37, 49], [38, 47], [39, 42], [39, 46], [40, 43], [40, 44], [41, 46], [41, 48], [41, 49], [42, 43], [42, 47], [43, 47], [44, 49], [44, 50], [45, 48], [45, 50], [46, 47], [47, 48]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l3-s6/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..322936ed9654d3cc27cbcfa291fce825a1c134db --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l3-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [0, 1, 2, 0, 0, 0, 0, 3, 3, 1, 3, 3, 2, 0, 0, 1, 2, 2, 0, 3, 1, 3, 3, 2, 0, 1, 3, 2, 3, 3, 1, 2, 0, 2, 1, 1, 0, 0, 1, 1, 3, 1, 3, 1, 1, 1, 3, 2, 3, 2, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l3-s6/tests/check.py b/tasks/construct-mc-graph-k-coloring-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l3-s6/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l3-s6/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..23506e5bc5d3a594d65a9f4d9c0c57e65e511314 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 51, "k": 4, "edges": [[0, 1], [0, 2], [0, 7], [0, 10], [0, 21], [0, 23], [0, 27], [0, 38], [0, 43], [0, 44], [1, 2], [1, 7], [1, 11], [1, 13], [1, 14], [1, 18], [1, 21], [1, 22], [1, 23], [1, 32], [1, 36], [2, 14], [2, 21], [2, 30], [3, 8], [3, 12], [3, 15], [3, 19], [3, 22], [3, 23], [3, 27], [3, 28], [3, 30], [3, 31], [3, 33], [3, 35], [3, 45], [3, 48], [4, 20], [4, 25], [4, 26], [4, 43], [5, 9], [5, 15], [5, 16], [5, 28], [5, 34], [5, 35], [5, 49], [6, 8], [6, 9], [6, 33], [6, 42], [6, 44], [6, 47], [7, 13], [7, 32], [7, 35], [7, 36], [7, 47], [8, 12], [8, 15], [8, 18], [8, 20], [8, 23], [8, 31], [8, 37], [8, 38], [9, 10], [9, 19], [9, 26], [9, 31], [9, 37], [9, 40], [10, 16], [10, 24], [10, 25], [10, 33], [11, 14], [11, 32], [11, 33], [11, 34], [11, 35], [11, 43], [12, 38], [12, 48], [13, 20], [14, 15], [14, 17], [14, 20], [14, 31], [14, 39], [14, 41], [15, 16], [15, 19], [15, 27], [16, 19], [16, 43], [16, 44], [17, 22], [17, 28], [17, 44], [18, 31], [18, 40], [18, 45], [18, 46], [19, 20], [19, 23], [19, 25], [19, 35], [19, 37], [19, 38], [19, 47], [20, 24], [20, 31], [20, 33], [21, 31], [21, 33], [21, 45], [21, 50], [22, 23], [22, 41], [23, 26], [23, 30], [23, 34], [23, 37], [23, 48], [24, 27], [24, 29], [24, 39], [24, 41], [24, 43], [24, 44], [24, 47], [25, 50], [26, 34], [26, 35], [26, 36], [26, 47], [26, 49], [26, 50], [27, 32], [27, 38], [27, 40], [27, 43], [27, 44], [27, 48], [27, 50], [28, 33], [28, 41], [28, 47], [29, 31], [29, 39], [29, 47], [30, 31], [30, 48], [31, 32], [32, 34], [32, 44], [32, 47], [33, 34], [33, 39], [35, 47], [36, 41], [36, 43], [37, 38], [37, 43], [37, 49], [38, 47], [39, 42], [39, 46], [40, 43], [40, 44], [41, 46], [41, 48], [41, 49], [42, 43], [42, 47], [43, 47], [44, 49], [44, 50], [45, 48], [45, 50], [46, 47], [47, 48]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l3-s6/tests/run.py b/tasks/construct-mc-graph-k-coloring-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graph-k-coloring-l3-s6/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-low-autocorrelation-l5-s2/environment/Dockerfile b/tasks/construct-mc-low-autocorrelation-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l5-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-low-autocorrelation-l5-s2/environment/instance.json b/tasks/construct-mc-low-autocorrelation-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0773b10ee14f8debd9fbca60b3fcf150184634c5 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "bound": 108, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l5-s2/solution/solve.sh b/tasks/construct-mc-low-autocorrelation-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4ea00d037d59ef88eb60268c609ad1570ec57f8 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1]} +RLMATH_EOF diff --git a/tasks/construct-mc-low-autocorrelation-l5-s2/tests/check.py b/tasks/construct-mc-low-autocorrelation-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8456f7b1c0ff0c9fb4bc9ae5a49074c8afa7d1aa --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l5-s2/tests/check.py @@ -0,0 +1,20 @@ +"""+-1 sequence of length n with aperiodic autocorrelation energy sum_k C_k^2 <= bound +(MathConstraint low_autocorrelation, CC-BY-4.0). Exact integer arithmetic.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, bound = inst["n"], inst["bound"] + s = int_list(ans.get("seq"), n, -1, 1, "seq") + if any(v == 0 for v in s): + raise Invalid("entries must be -1 or +1") + c = [sum(s[i] * s[i + k] for i in range(n - k)) for k in range(1, n)] + e = sum(v * v for v in c) + # fixed values: seq[i] or c[k] (c[k] is the autocorrelation at shift k+1, as upstream) + seqs = {"seq": s, "c": c} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + if e > bound: + raise Invalid(f"energy {e} exceeds the bound {bound}") + return None, {"energy": e} diff --git a/tasks/construct-mc-low-autocorrelation-l5-s2/tests/instance.json b/tasks/construct-mc-low-autocorrelation-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0773b10ee14f8debd9fbca60b3fcf150184634c5 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "bound": 108, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l5-s2/tests/run.py b/tasks/construct-mc-low-autocorrelation-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l5-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-low-autocorrelation-l5-s2/tests/test.sh b/tasks/construct-mc-low-autocorrelation-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l5-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-number-partitioning-l2-s2/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-number-partitioning-l2-s2/environment/instance.json b/tasks/construct-mc-number-partitioning-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8335601bda06086d6bc6e3a0e33a755956e64238 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 3, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l2-s2/solution/solve.sh b/tasks/construct-mc-number-partitioning-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e382d8b17b812fd4ba9b55ffaf85f4f5737b3c89 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 2, 1, 1, 0, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l2-s2/tests/check.py b/tasks/construct-mc-number-partitioning-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s2/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l2-s2/tests/instance.json b/tasks/construct-mc-number-partitioning-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8335601bda06086d6bc6e3a0e33a755956e64238 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 3, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l2-s2/tests/run.py b/tasks/construct-mc-number-partitioning-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-number-partitioning-l2-s2/tests/test.sh b/tasks/construct-mc-number-partitioning-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-number-partitioning-l2-s5/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-number-partitioning-l2-s5/environment/instance.json b/tasks/construct-mc-number-partitioning-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ee0d8e647d28ccdc12bfdb9b4fc5618d6dd4c841 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 5, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l2-s5/solution/solve.sh b/tasks/construct-mc-number-partitioning-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ae620a06af7d2212a50e445f633d4c4d3aa6b55e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 2, 4, 1, 3, 1, 3, 0, 2, 4, 4, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l2-s5/tests/check.py b/tasks/construct-mc-number-partitioning-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s5/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l2-s5/tests/instance.json b/tasks/construct-mc-number-partitioning-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ee0d8e647d28ccdc12bfdb9b4fc5618d6dd4c841 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 5, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l2-s5/tests/run.py b/tasks/construct-mc-number-partitioning-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-number-partitioning-l2-s5/tests/test.sh b/tasks/construct-mc-number-partitioning-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l2-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-number-partitioning-l6-s3/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l6-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-number-partitioning-l6-s3/environment/instance.json b/tasks/construct-mc-number-partitioning-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9bb4d840fe9a4310e49ace419a0a1cd3db222684 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 111, "k": 7, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l6-s3/solution/solve.sh b/tasks/construct-mc-number-partitioning-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..44068298904d3af86b4df60090ce8ec7c854936e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l6-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l6-s3/tests/instance.json b/tasks/construct-mc-number-partitioning-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9bb4d840fe9a4310e49ace419a0a1cd3db222684 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 111, "k": 7, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l6-s3/tests/test.sh b/tasks/construct-mc-number-partitioning-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l6-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-chromatic-girth-l4-s3/environment/Dockerfile b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-chromatic-girth-l4-s3/environment/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e7d45e21d2f2ae6d397a29caba3e45f0093ce5c7 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 20, "required_edges": [], "max_chromatic_number": 3, "min_edges": 21, "min_girth": 7, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l4-s3/solution/solve.sh b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b231dd329b858140cdcb6bd4dd3412fd506c8334 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [1, 6], [1, 19], [2, 5], [2, 18], [3, 4], [3, 17], [4, 5], [4, 6]], "coloring": [0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/check.py b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e7d45e21d2f2ae6d397a29caba3e45f0093ce5c7 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 20, "required_edges": [], "max_chromatic_number": 3, "min_edges": 21, "min_girth": 7, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/run.py b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/test.sh b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l4-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-girth-degree-l3-s0/environment/Dockerfile b/tasks/construct-mc-pysms-girth-degree-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l3-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-girth-degree-l3-s0/environment/instance.json b/tasks/construct-mc-pysms-girth-degree-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..28d6388c4c03cf3a9d38e5a241c830b48331bd13 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 21, "required_edges": [], "max_degree": 5, "min_degree": 3, "min_girth": 6, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l3-s0/solution/solve.sh b/tasks/construct-mc-pysms-girth-degree-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d9e586d160e5932d3af60f4375d3db16ee649134 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l3-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 18], [0, 19], [0, 20], [1, 16], [1, 17], [1, 20], [2, 15], [2, 17], [2, 19], [3, 14], [3, 17], [3, 18], [4, 13], [4, 16], [4, 19], [5, 12], [5, 16], [5, 18], [6, 11], [6, 15], [6, 18], [7, 10], [7, 14], [7, 19], [8, 9], [8, 13], [8, 14], [9, 12], [9, 15], [9, 20], [10, 11], [10, 12], [11, 13]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/check.py b/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/instance.json b/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..28d6388c4c03cf3a9d38e5a241c830b48331bd13 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 21, "required_edges": [], "max_degree": 5, "min_degree": 3, "min_girth": 6, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/run.py b/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/test.sh b/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l3-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-van-der-waerden-l2-s3/environment/Dockerfile b/tasks/construct-mc-van-der-waerden-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-van-der-waerden-l2-s3/environment/instance.json b/tasks/construct-mc-van-der-waerden-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f16e2fdddfd76aebe14f55c72ebabc58d582ab78 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"k": 3, "L": 3, "n": 18, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l2-s3/solution/solve.sh b/tasks/construct-mc-van-der-waerden-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f0aee0627830319ac3f564ffbde9ece94f6635fb --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 2, 2, 1, 0, 0, 1, 0, 1, 2, 2, 1, 1, 2, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-van-der-waerden-l2-s3/tests/check.py b/tasks/construct-mc-van-der-waerden-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9853b089b6ac1773d80eac8e9e02ceb4019ad41f --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s3/tests/check.py @@ -0,0 +1,15 @@ +"""k-colouring of {1..n} with no monochromatic L-term arithmetic progression (MathConstraint +van_der_waerden, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k, L = inst["n"], inst["k"], inst["L"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for a in range(n): + for d in range(1, n): + if a + (L - 1) * d >= n: + break + if all(c[a + j * d] == c[a] for j in range(1, L)): + raise Invalid(f"monochromatic progression {[a + 1 + j * d for j in range(L)]}") + return None, {} diff --git a/tasks/construct-mc-van-der-waerden-l2-s3/tests/instance.json b/tasks/construct-mc-van-der-waerden-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f16e2fdddfd76aebe14f55c72ebabc58d582ab78 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"k": 3, "L": 3, "n": 18, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l2-s3/tests/run.py b/tasks/construct-mc-van-der-waerden-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-van-der-waerden-l2-s3/tests/test.sh b/tasks/construct-mc-van-der-waerden-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-van-der-waerden-l2-s4/environment/Dockerfile b/tasks/construct-mc-van-der-waerden-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-van-der-waerden-l2-s4/environment/instance.json b/tasks/construct-mc-van-der-waerden-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..907be801412825e45e33b499252f9d045df8a58a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"k": 2, "L": 4, "n": 24, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l2-s4/solution/solve.sh b/tasks/construct-mc-van-der-waerden-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a357ecda5d7d418326c30d7c2928582e23d58f34 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-van-der-waerden-l2-s4/tests/check.py b/tasks/construct-mc-van-der-waerden-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9853b089b6ac1773d80eac8e9e02ceb4019ad41f --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s4/tests/check.py @@ -0,0 +1,15 @@ +"""k-colouring of {1..n} with no monochromatic L-term arithmetic progression (MathConstraint +van_der_waerden, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k, L = inst["n"], inst["k"], inst["L"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for a in range(n): + for d in range(1, n): + if a + (L - 1) * d >= n: + break + if all(c[a + j * d] == c[a] for j in range(1, L)): + raise Invalid(f"monochromatic progression {[a + 1 + j * d for j in range(L)]}") + return None, {} diff --git a/tasks/construct-mc-van-der-waerden-l2-s4/tests/instance.json b/tasks/construct-mc-van-der-waerden-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..907be801412825e45e33b499252f9d045df8a58a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"k": 2, "L": 4, "n": 24, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l2-s4/tests/run.py b/tasks/construct-mc-van-der-waerden-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-van-der-waerden-l2-s4/tests/test.sh b/tasks/construct-mc-van-der-waerden-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l2-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l3-s3/environment/Dockerfile b/tasks/construct-nppc-3col-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l3-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l3-s3/environment/instance.json b/tasks/construct-nppc-3col-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..abdd08d246e583c882bf8837bcb07e5193320071 --- /dev/null +++ b/tasks/construct-nppc-3col-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "edges": [[0, 1], [0, 9], [0, 10], [0, 14], [1, 7], [1, 8], [1, 12], [1, 16], [1, 25], [1, 26], [2, 19], [2, 25], [3, 12], [3, 27], [4, 10], [4, 12], [4, 21], [5, 21], [5, 22], [6, 17], [6, 23], [6, 29], [7, 9], [7, 23], [7, 26], [8, 26], [10, 17], [11, 12], [11, 18], [11, 27], [12, 22], [12, 24], [12, 25], [13, 16], [13, 19], [13, 25], [13, 28], [14, 17], [14, 20], [14, 21], [14, 25], [15, 16], [15, 18], [15, 26], [16, 21], [16, 22], [17, 25], [18, 20], [18, 24], [18, 25], [18, 29], [19, 24], [21, 24], [21, 26], [21, 27], [22, 23], [22, 26], [23, 28], [25, 26], [25, 29]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l3-s3/solution/solve.sh b/tasks/construct-nppc-3col-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83da0fd816b860a820384802758e104e293a842d --- /dev/null +++ b/tasks/construct-nppc-3col-l3-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 0, 0, 1, 0, 0, 2, 1, 1, 2, 2, 1, 2, 0, 2, 1, 2, 0, 2, 2, 0, 1, 1, 0, 0, 1, 2, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l3-s3/tests/check.py b/tasks/construct-nppc-3col-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l3-s3/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l3-s3/tests/instance.json b/tasks/construct-nppc-3col-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..abdd08d246e583c882bf8837bcb07e5193320071 --- /dev/null +++ b/tasks/construct-nppc-3col-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "edges": [[0, 1], [0, 9], [0, 10], [0, 14], [1, 7], [1, 8], [1, 12], [1, 16], [1, 25], [1, 26], [2, 19], [2, 25], [3, 12], [3, 27], [4, 10], [4, 12], [4, 21], [5, 21], [5, 22], [6, 17], [6, 23], [6, 29], [7, 9], [7, 23], [7, 26], [8, 26], [10, 17], [11, 12], [11, 18], [11, 27], [12, 22], [12, 24], [12, 25], [13, 16], [13, 19], [13, 25], [13, 28], [14, 17], [14, 20], [14, 21], [14, 25], [15, 16], [15, 18], [15, 26], [16, 21], [16, 22], [17, 25], [18, 20], [18, 24], [18, 25], [18, 29], [19, 24], [21, 24], [21, 26], [21, 27], [22, 23], [22, 26], [23, 28], [25, 26], [25, 29]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l3-s3/tests/run.py b/tasks/construct-nppc-3col-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l3-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l3-s3/tests/test.sh b/tasks/construct-nppc-3col-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l3-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l4-s8/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l4-s8/environment/instance.json b/tasks/construct-nppc-dominating-set-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5654abbf2ebdf451b626ba7118ef19fbafbdab9 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 2], [0, 3], [0, 7], [0, 13], [0, 16], [0, 17], [0, 18], [0, 20], [0, 26], [0, 27], [0, 34], [0, 39], [0, 43], [0, 44], [0, 47], [0, 49], [0, 51], [0, 53], [0, 54], [0, 57], [0, 59], [0, 60], [0, 61], [0, 62], [0, 72], [0, 73], [0, 75], [0, 80], [0, 82], [0, 84], [0, 86], [0, 87], [0, 89], [0, 91], [0, 94], [0, 99], [1, 4], [1, 6], [1, 11], [1, 12], [1, 14], [1, 16], [1, 17], [1, 18], [1, 20], [1, 22], [1, 27], [1, 29], [1, 34], [1, 37], [1, 38], [1, 39], [1, 42], [1, 43], [1, 44], [1, 49], [1, 51], [1, 53], [1, 54], [1, 58], [1, 59], [1, 61], [1, 62], [1, 63], [1, 65], [1, 66], [1, 68], [1, 70], [1, 71], [1, 72], [1, 73], [1, 78], [1, 80], [1, 81], [1, 92], [1, 93], [1, 94], [2, 3], [2, 6], [2, 7], [2, 20], [2, 24], [2, 25], [2, 30], [2, 31], [2, 32], [2, 34], [2, 35], [2, 37], [2, 41], [2, 43], [2, 44], [2, 47], [2, 50], [2, 55], [2, 56], [2, 57], [2, 62], [2, 63], [2, 64], [2, 65], [2, 66], [2, 67], [2, 72], [2, 79], [2, 81], [2, 82], [2, 88], [2, 91], [2, 92], [2, 93], [3, 5], [3, 6], [3, 8], [3, 9], [3, 11], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 23], [3, 24], [3, 26], [3, 27], [3, 29], [3, 35], [3, 38], [3, 39], [3, 48], [3, 51], [3, 52], [3, 55], [3, 56], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 70], [3, 74], [3, 75], [3, 76], [3, 77], [3, 78], [3, 79], [3, 82], [3, 84], [3, 85], [3, 87], [3, 90], [3, 98], [4, 11], [4, 16], [4, 17], [4, 18], [4, 20], [4, 22], [4, 23], [4, 24], [4, 34], [4, 36], [4, 39], [4, 44], [4, 46], [4, 47], [4, 49], [4, 57], [4, 60], [4, 61], [4, 62], [4, 63], [4, 65], [4, 69], [4, 72], [4, 74], [4, 83], [4, 86], [4, 94], [4, 96], [5, 9], [5, 10], [5, 17], [5, 22], [5, 25], [5, 30], [5, 31], [5, 32], [5, 34], [5, 35], [5, 37], [5, 39], [5, 40], [5, 49], [5, 51], [5, 54], [5, 63], [5, 66], [5, 67], [5, 69], [5, 70], [5, 71], [5, 74], [5, 76], [5, 83], [5, 85], [5, 86], [5, 88], [5, 91], [5, 93], [5, 97], [5, 98], [5, 99], [6, 9], [6, 13], [6, 16], [6, 20], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 32], [6, 38], [6, 46], [6, 52], [6, 58], [6, 61], [6, 62], [6, 63], [6, 64], [6, 67], [6, 68], [6, 70], [6, 77], [6, 79], [6, 80], [6, 82], [6, 84], [6, 87], [6, 88], [6, 90], [6, 95], [6, 96], [7, 9], [7, 10], [7, 14], [7, 15], [7, 16], [7, 20], [7, 23], [7, 28], [7, 29], [7, 31], [7, 36], [7, 37], [7, 39], [7, 43], [7, 45], [7, 46], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 60], [7, 62], [7, 63], [7, 64], [7, 65], [7, 68], [7, 72], [7, 74], [7, 75], [7, 79], [7, 80], [7, 81], [7, 82], [7, 89], [7, 92], [7, 94], [7, 99], [8, 11], [8, 14], [8, 17], [8, 20], [8, 23], [8, 24], [8, 26], [8, 27], [8, 31], [8, 32], [8, 40], [8, 42], [8, 44], [8, 45], [8, 47], [8, 48], [8, 52], [8, 58], [8, 59], [8, 61], [8, 64], [8, 67], [8, 73], [8, 75], [8, 77], [8, 80], [8, 82], [8, 88], [8, 90], [8, 97], [8, 98], [9, 13], [9, 20], [9, 24], [9, 25], [9, 35], [9, 36], [9, 37], [9, 38], [9, 43], [9, 47], [9, 48], [9, 61], [9, 62], [9, 63], [9, 65], [9, 67], [9, 69], [9, 70], [9, 76], [9, 81], [9, 83], [9, 85], [9, 86], [9, 87], [9, 89], [9, 90], [9, 96], [10, 12], [10, 16], [10, 17], [10, 18], [10, 19], [10, 21], [10, 22], [10, 29], [10, 33], [10, 35], [10, 36], [10, 38], [10, 46], [10, 57], [10, 58], [10, 61], [10, 63], [10, 66], [10, 75], [10, 92], [10, 93], [10, 98], [11, 13], [11, 15], [11, 16], [11, 22], [11, 30], [11, 32], [11, 34], [11, 37], [11, 38], [11, 40], [11, 41], [11, 46], [11, 48], [11, 49], [11, 57], [11, 74], [11, 75], [11, 76], [11, 87], [11, 96], [11, 98], [11, 99], [12, 16], [12, 18], [12, 19], [12, 21], [12, 22], [12, 23], [12, 31], [12, 32], [12, 36], [12, 39], [12, 41], [12, 47], [12, 52], [12, 61], [12, 63], [12, 64], [12, 68], [12, 71], [12, 86], [12, 93], [12, 95], [12, 97], [13, 14], [13, 15], [13, 16], [13, 20], [13, 25], [13, 27], [13, 28], [13, 29], [13, 31], [13, 34], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 44], [13, 47], [13, 51], [13, 61], [13, 62], [13, 64], [13, 65], [13, 66], [13, 76], [13, 77], [13, 80], [13, 86], [13, 97], [13, 98], [14, 19], [14, 23], [14, 25], [14, 32], [14, 34], [14, 40], [14, 46], [14, 51], [14, 52], [14, 55], [14, 56], [14, 58], [14, 66], [14, 76], [14, 83], [14, 87], [14, 91], [14, 97], [14, 98], [14, 99], [15, 22], [15, 29], [15, 30], [15, 37], [15, 43], [15, 44], [15, 45], [15, 47], [15, 48], [15, 49], [15, 50], [15, 53], [15, 60], [15, 64], [15, 66], [15, 68], [15, 69], [15, 71], [15, 73], [15, 74], [15, 77], [15, 78], [15, 86], [15, 88], [15, 96], [16, 17], [16, 19], [16, 20], [16, 21], [16, 22], [16, 27], [16, 29], [16, 31], [16, 34], [16, 38], [16, 42], [16, 44], [16, 47], [16, 54], [16, 56], [16, 57], [16, 58], [16, 67], [16, 72], [16, 73], [16, 76], [16, 77], [16, 84], [16, 86], [16, 90], [16, 92], [16, 94], [16, 99], [17, 21], [17, 22], [17, 23], [17, 24], [17, 32], [17, 33], [17, 36], [17, 38], [17, 39], [17, 46], [17, 47], [17, 49], [17, 50], [17, 53], [17, 57], [17, 58], [17, 60], [17, 63], [17, 64], [17, 66], [17, 70], [17, 71], [17, 76], [17, 83], [17, 93], [17, 99], [18, 20], [18, 23], [18, 27], [18, 40], [18, 46], [18, 47], [18, 49], [18, 54], [18, 55], [18, 56], [18, 58], [18, 63], [18, 67], [18, 69], [18, 73], [18, 75], [18, 80], [18, 82], [18, 83], [18, 89], [18, 93], [18, 94], [19, 20], [19, 22], [19, 30], [19, 31], [19, 45], [19, 46], [19, 47], [19, 48], [19, 51], [19, 54], [19, 58], [19, 64], [19, 65], [19, 66], [19, 68], [19, 73], [19, 74], [19, 75], [19, 77], [19, 79], [19, 83], [19, 84], [19, 90], [19, 91], [19, 98], [19, 99], [20, 24], [20, 29], [20, 33], [20, 35], [20, 39], [20, 44], [20, 46], [20, 52], [20, 55], [20, 56], [20, 57], [20, 58], [20, 60], [20, 61], [20, 62], [20, 65], [20, 68], [20, 71], [20, 73], [20, 74], [20, 76], [20, 81], [20, 85], [20, 87], [20, 89], [20, 92], [20, 96], [20, 99], [21, 24], [21, 28], [21, 29], [21, 30], [21, 35], [21, 43], [21, 45], [21, 48], [21, 51], [21, 53], [21, 54], [21, 56], [21, 59], [21, 61], [21, 64], [21, 65], [21, 66], [21, 72], [21, 76], [21, 79], [21, 80], [21, 81], [21, 82], [21, 84], [21, 91], [21, 95], [22, 24], [22, 26], [22, 28], [22, 30], [22, 33], [22, 40], [22, 43], [22, 49], [22, 51], [22, 57], [22, 58], [22, 59], [22, 66], [22, 67], [22, 68], [22, 70], [22, 71], [22, 72], [22, 76], [22, 77], [22, 84], [22, 85], [22, 88], [22, 89], [22, 99], [23, 24], [23, 27], [23, 28], [23, 31], [23, 32], [23, 33], [23, 39], [23, 40], [23, 43], [23, 45], [23, 46], [23, 50], [23, 55], [23, 56], [23, 60], [23, 61], [23, 64], [23, 67], [23, 69], [23, 73], [23, 74], [23, 78], [23, 79], [23, 81], [23, 92], [23, 99], [24, 32], [24, 34], [24, 40], [24, 49], [24, 51], [24, 52], [24, 54], [24, 56], [24, 57], [24, 62], [24, 67], [24, 71], [24, 76], [24, 77], [24, 78], [24, 83], [24, 86], [24, 88], [24, 89], [24, 90], [24, 92], [24, 97], [24, 98], [24, 99], [25, 27], [25, 30], [25, 33], [25, 34], [25, 39], [25, 40], [25, 41], [25, 43], [25, 45], [25, 46], [25, 49], [25, 50], [25, 54], [25, 55], [25, 60], [25, 61], [25, 62], [25, 65], [25, 71], [25, 77], [25, 78], [25, 79], [25, 80], [25, 84], [25, 87], [25, 90], [25, 91], [25, 92], [25, 96], [26, 29], [26, 30], [26, 32], [26, 34], [26, 37], [26, 40], [26, 48], [26, 59], [26, 62], [26, 63], [26, 68], [26, 69], [26, 70], [26, 72], [26, 77], [26, 82], [26, 83], [26, 84], [26, 86], [26, 89], [26, 92], [26, 94], [26, 95], [26, 99], [27, 29], [27, 32], [27, 33], [27, 36], [27, 40], [27, 42], [27, 43], [27, 47], [27, 49], [27, 51], [27, 54], [27, 61], [27, 62], [27, 64], [27, 65], [27, 72], [27, 73], [27, 74], [27, 78], [27, 80], [27, 81], [27, 82], [27, 83], [27, 84], [27, 92], [27, 93], [27, 96], [28, 30], [28, 31], [28, 32], [28, 34], [28, 36], [28, 37], [28, 39], [28, 40], [28, 44], [28, 45], [28, 46], [28, 48], [28, 56], [28, 57], [28, 61], [28, 65], [28, 68], [28, 69], [28, 70], [28, 72], [28, 73], [28, 74], [28, 77], [28, 79], [28, 84], [28, 88], [28, 89], [28, 90], [28, 93], [28, 97], [29, 31], [29, 33], [29, 34], [29, 36], [29, 40], [29, 45], [29, 52], [29, 53], [29, 54], [29, 58], [29, 62], [29, 65], [29, 69], [29, 73], [29, 74], [29, 77], [29, 81], [29, 88], [29, 91], [29, 96], [30, 31], [30, 32], [30, 36], [30, 37], [30, 46], [30, 49], [30, 59], [30, 61], [30, 63], [30, 67], [30, 70], [30, 73], [30, 78], [30, 82], [30, 84], [30, 86], [30, 91], [30, 96], [30, 97], [30, 99], [31, 32], [31, 37], [31, 41], [31, 42], [31, 48], [31, 51], [31, 61], [31, 65], [31, 68], [31, 71], [31, 72], [31, 79], [31, 80], [31, 84], [31, 87], [31, 88], [31, 89], [31, 97], [31, 98], [32, 33], [32, 35], [32, 36], [32, 43], [32, 45], [32, 53], [32, 56], [32, 58], [32, 59], [32, 67], [32, 68], [32, 69], [32, 80], [32, 82], [32, 85], [32, 88], [32, 91], [32, 93], [32, 96], [32, 98], [33, 36], [33, 37], [33, 38], [33, 39], [33, 40], [33, 42], [33, 49], [33, 51], [33, 55], [33, 58], [33, 59], [33, 63], [33, 69], [33, 74], [33, 75], [33, 77], [33, 81], [33, 85], [33, 86], [33, 89], [33, 92], [33, 94], [33, 98], [33, 99], [34, 41], [34, 42], [34, 43], [34, 44], [34, 52], [34, 53], [34, 56], [34, 57], [34, 61], [34, 63], [34, 64], [34, 65], [34, 66], [34, 68], [34, 70], [34, 71], [34, 78], [34, 83], [34, 86], [34, 88], [34, 90], [34, 91], [34, 93], [35, 36], [35, 41], [35, 47], [35, 49], [35, 50], [35, 54], [35, 56], [35, 58], [35, 62], [35, 63], [35, 67], [35, 69], [35, 70], [35, 82], [35, 83], [35, 87], [35, 91], [35, 99], [36, 39], [36, 41], [36, 44], [36, 46], [36, 53], [36, 56], [36, 58], [36, 59], [36, 63], [36, 65], [36, 69], [36, 74], [36, 76], [36, 78], [36, 80], [36, 81], [36, 83], [36, 86], [36, 88], [36, 90], [36, 92], [36, 93], [36, 95], [36, 99], [37, 41], [37, 43], [37, 44], [37, 46], [37, 50], [37, 56], [37, 58], [37, 66], [37, 68], [37, 70], [37, 75], [37, 77], [37, 78], [37, 79], [37, 80], [37, 83], [37, 85], [37, 86], [37, 90], [37, 91], [37, 94], [37, 96], [37, 98], [38, 40], [38, 42], [38, 51], [38, 52], [38, 55], [38, 57], [38, 58], [38, 62], [38, 65], [38, 68], [38, 71], [38, 75], [38, 76], [38, 82], [38, 89], [38, 92], [38, 99], [39, 44], [39, 45], [39, 50], [39, 53], [39, 57], [39, 63], [39, 66], [39, 67], [39, 68], [39, 70], [39, 73], [39, 78], [39, 81], [39, 82], [39, 83], [39, 84], [39, 86], [39, 87], [39, 88], [39, 89], [39, 91], [39, 93], [39, 94], [40, 45], [40, 53], [40, 57], [40, 70], [40, 74], [40, 75], [40, 77], [40, 78], [40, 83], [40, 90], [40, 96], [40, 97], [40, 98], [40, 99], [41, 45], [41, 61], [41, 62], [41, 65], [41, 74], [41, 75], [41, 76], [41, 77], [41, 80], [41, 84], [41, 88], [41, 89], [41, 91], [41, 97], [41, 99], [42, 44], [42, 47], [42, 48], [42, 49], [42, 54], [42, 55], [42, 57], [42, 64], [42, 65], [42, 67], [42, 70], [42, 72], [42, 75], [42, 76], [42, 83], [42, 84], [42, 85], [42, 86], [42, 87], [42, 88], [42, 92], [42, 94], [42, 98], [43, 45], [43, 46], [43, 49], [43, 51], [43, 54], [43, 55], [43, 57], [43, 61], [43, 63], [43, 64], [43, 68], [43, 69], [43, 72], [43, 76], [43, 78], [43, 80], [43, 84], [43, 89], [43, 91], [43, 93], [43, 94], [43, 99], [44, 47], [44, 48], [44, 49], [44, 54], [44, 66], [44, 72], [44, 74], [44, 80], [44, 81], [44, 83], [44, 84], [44, 87], [44, 88], [44, 90], [44, 94], [44, 95], [45, 47], [45, 54], [45, 55], [45, 58], [45, 59], [45, 70], [45, 71], [45, 73], [45, 75], [45, 77], [45, 80], [45, 81], [45, 82], [45, 83], [45, 86], [45, 87], [45, 90], [45, 91], [45, 93], [45, 97], [46, 48], [46, 49], [46, 54], [46, 56], [46, 66], [46, 71], [46, 72], [46, 76], [46, 77], [46, 80], [46, 81], [46, 82], [46, 86], [46, 89], [46, 92], [46, 93], [46, 94], [46, 97], [47, 49], [47, 53], [47, 54], [47, 57], [47, 59], [47, 61], [47, 62], [47, 63], [47, 65], [47, 67], [47, 69], [47, 70], [47, 72], [47, 73], [47, 75], [47, 76], [47, 77], [47, 79], [47, 82], [47, 84], [47, 87], [47, 90], [47, 95], [47, 96], [47, 97], [48, 51], [48, 54], [48, 59], [48, 64], [48, 67], [48, 73], [48, 75], [48, 81], [48, 84], [48, 86], [48, 88], [48, 92], [48, 94], [48, 96], [48, 99], [49, 50], [49, 53], [49, 54], [49, 55], [49, 58], [49, 60], [49, 66], [49, 67], [49, 68], [49, 73], [49, 74], [49, 78], [49, 79], [49, 85], [49, 90], [49, 93], [49, 97], [50, 51], [50, 58], [50, 59], [50, 67], [50, 68], [50, 73], [50, 75], [50, 82], [50, 83], [50, 84], [50, 85], [50, 88], [50, 93], [50, 99], [51, 52], [51, 54], [51, 56], [51, 57], [51, 61], [51, 62], [51, 67], [51, 68], [51, 74], [51, 79], [51, 80], [51, 83], [51, 84], [51, 86], [51, 87], [51, 88], [51, 90], [51, 95], [51, 96], [51, 97], [52, 59], [52, 61], [52, 63], [52, 65], [52, 68], [52, 80], [52, 83], [52, 84], [52, 85], [52, 86], [52, 88], [52, 89], [52, 91], [52, 92], [52, 93], [52, 94], [52, 95], [53, 54], [53, 56], [53, 57], [53, 59], [53, 60], [53, 61], [53, 66], [53, 73], [53, 77], [53, 81], [53, 82], [53, 83], [53, 85], [53, 86], [53, 91], [53, 92], [53, 94], [54, 60], [54, 67], [54, 72], [54, 73], [54, 74], [54, 80], [54, 81], [54, 83], [54, 85], [54, 86], [54, 89], [54, 90], [54, 91], [54, 93], [54, 95], [54, 98], [55, 59], [55, 60], [55, 63], [55, 65], [55, 69], [55, 70], [55, 73], [55, 76], [55, 77], [55, 78], [55, 81], [55, 83], [55, 84], [55, 85], [55, 93], [55, 98], [55, 99], [56, 59], [56, 64], [56, 68], [56, 70], [56, 79], [56, 81], [56, 84], [56, 88], [56, 92], [56, 93], [56, 94], [56, 96], [56, 97], [57, 58], [57, 69], [57, 71], [57, 72], [57, 75], [57, 78], [57, 83], [57, 88], [58, 60], [58, 62], [58, 70], [58, 77], [58, 78], [58, 81], [58, 83], [58, 86], [58, 92], [58, 99], [59, 60], [59, 67], [59, 69], [59, 72], [59, 75], [59, 82], [59, 83], [59, 84], [59, 85], [59, 92], [59, 95], [59, 98], [60, 63], [60, 69], [60, 70], [60, 71], [60, 74], [60, 75], [60, 77], [60, 78], [60, 81], [60, 87], [60, 89], [60, 90], [60, 93], [60, 95], [60, 99], [61, 62], [61, 66], [61, 67], [61, 69], [61, 79], [61, 83], [61, 88], [61, 89], [61, 92], [61, 94], [61, 96], [62, 65], [62, 69], [62, 70], [62, 76], [62, 89], [62, 91], [62, 92], [63, 65], [63, 70], [63, 73], [63, 74], [63, 78], [63, 79], [63, 81], [63, 86], [63, 90], [63, 94], [63, 97], [63, 99], [64, 70], [64, 72], [64, 74], [64, 75], [64, 76], [64, 79], [64, 80], [64, 82], [64, 85], [64, 86], [64, 89], [64, 93], [65, 71], [65, 75], [65, 77], [65, 85], [65, 86], [65, 93], [65, 97], [66, 67], [66, 70], [66, 72], [66, 74], [66, 79], [66, 80], [66, 83], [66, 85], [66, 92], [66, 94], [66, 95], [66, 96], [67, 70], [67, 71], [67, 74], [67, 78], [67, 80], [67, 82], [67, 87], [67, 88], [67, 90], [67, 91], [67, 93], [67, 99], [68, 69], [68, 71], [68, 73], [68, 78], [68, 80], [68, 81], [68, 92], [68, 93], [68, 94], [68, 96], [68, 97], [69, 75], [69, 76], [69, 84], [69, 93], [69, 97], [70, 74], [70, 77], [70, 81], [70, 82], [70, 83], [70, 85], [70, 91], [70, 93], [70, 95], [70, 97], [70, 98], [71, 73], [71, 84], [71, 85], [71, 89], [71, 91], [71, 93], [71, 98], [72, 73], [72, 74], [72, 78], [72, 85], [72, 87], [72, 88], [72, 90], [72, 91], [72, 93], [72, 94], [72, 96], [73, 75], [73, 78], [73, 82], [73, 83], [73, 85], [73, 86], [73, 88], [73, 90], [73, 93], [73, 95], [73, 99], [74, 76], [74, 78], [74, 81], [74, 82], [74, 86], [74, 87], [74, 95], [74, 99], [75, 85], [75, 87], [75, 88], [75, 90], [75, 92], [75, 93], [75, 94], [76, 77], [76, 78], [76, 79], [76, 86], [76, 88], [76, 91], [76, 93], [76, 94], [76, 98], [77, 81], [77, 89], [78, 79], [78, 80], [78, 86], [78, 88], [78, 92], [78, 95], [78, 98], [79, 80], [79, 82], [79, 85], [79, 86], [79, 90], [79, 91], [79, 92], [79, 93], [79, 96], [79, 99], [80, 81], [80, 85], [80, 86], [80, 87], [80, 88], [80, 92], [81, 82], [81, 83], [81, 85], [81, 86], [81, 89], [81, 91], [81, 92], [81, 98], [82, 85], [82, 86], [82, 92], [82, 93], [82, 95], [82, 99], [83, 84], [83, 91], [83, 92], [83, 93], [84, 85], [84, 87], [84, 95], [84, 98], [84, 99], [85, 87], [85, 88], [85, 90], [85, 92], [85, 99], [86, 88], [86, 90], [86, 91], [86, 92], [87, 89], [87, 91], [87, 96], [88, 89], [88, 91], [88, 92], [88, 93], [88, 95], [89, 90], [89, 91], [89, 93], [89, 95], [89, 96], [89, 97], [89, 98], [89, 99], [90, 92], [90, 96], [90, 99], [91, 92], [91, 93], [91, 96], [92, 93], [92, 94], [92, 97], [92, 99], [93, 96], [93, 98], [94, 97], [95, 96], [95, 97], [95, 98], [97, 98], [97, 99], [98, 99]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l4-s8/solution/solve.sh b/tasks/construct-nppc-dominating-set-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b61b55772d3e231899698789f7f8df5eff811822 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"dominating_set": [3, 25, 32, 36, 42, 46, 47, 49, 60, 68, 70, 71, 73, 75, 80, 81, 83, 88, 91, 99]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l4-s8/tests/check.py b/tasks/construct-nppc-dominating-set-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l4-s8/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l4-s8/tests/instance.json b/tasks/construct-nppc-dominating-set-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5654abbf2ebdf451b626ba7118ef19fbafbdab9 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 2], [0, 3], [0, 7], [0, 13], [0, 16], [0, 17], [0, 18], [0, 20], [0, 26], [0, 27], [0, 34], [0, 39], [0, 43], [0, 44], [0, 47], [0, 49], [0, 51], [0, 53], [0, 54], [0, 57], [0, 59], [0, 60], [0, 61], [0, 62], [0, 72], [0, 73], [0, 75], [0, 80], [0, 82], [0, 84], [0, 86], [0, 87], [0, 89], [0, 91], [0, 94], [0, 99], [1, 4], [1, 6], [1, 11], [1, 12], [1, 14], [1, 16], [1, 17], [1, 18], [1, 20], [1, 22], [1, 27], [1, 29], [1, 34], [1, 37], [1, 38], [1, 39], [1, 42], [1, 43], [1, 44], [1, 49], [1, 51], [1, 53], [1, 54], [1, 58], [1, 59], [1, 61], [1, 62], [1, 63], [1, 65], [1, 66], [1, 68], [1, 70], [1, 71], [1, 72], [1, 73], [1, 78], [1, 80], [1, 81], [1, 92], [1, 93], [1, 94], [2, 3], [2, 6], [2, 7], [2, 20], [2, 24], [2, 25], [2, 30], [2, 31], [2, 32], [2, 34], [2, 35], [2, 37], [2, 41], [2, 43], [2, 44], [2, 47], [2, 50], [2, 55], [2, 56], [2, 57], [2, 62], [2, 63], [2, 64], [2, 65], [2, 66], [2, 67], [2, 72], [2, 79], [2, 81], [2, 82], [2, 88], [2, 91], [2, 92], [2, 93], [3, 5], [3, 6], [3, 8], [3, 9], [3, 11], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 23], [3, 24], [3, 26], [3, 27], [3, 29], [3, 35], [3, 38], [3, 39], [3, 48], [3, 51], [3, 52], [3, 55], [3, 56], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 70], [3, 74], [3, 75], [3, 76], [3, 77], [3, 78], [3, 79], [3, 82], [3, 84], [3, 85], [3, 87], [3, 90], [3, 98], [4, 11], [4, 16], [4, 17], [4, 18], [4, 20], [4, 22], [4, 23], [4, 24], [4, 34], [4, 36], [4, 39], [4, 44], [4, 46], [4, 47], [4, 49], [4, 57], [4, 60], [4, 61], [4, 62], [4, 63], [4, 65], [4, 69], [4, 72], [4, 74], [4, 83], [4, 86], [4, 94], [4, 96], [5, 9], [5, 10], [5, 17], [5, 22], [5, 25], [5, 30], [5, 31], [5, 32], [5, 34], [5, 35], [5, 37], [5, 39], [5, 40], [5, 49], [5, 51], [5, 54], [5, 63], [5, 66], [5, 67], [5, 69], [5, 70], [5, 71], [5, 74], [5, 76], [5, 83], [5, 85], [5, 86], [5, 88], [5, 91], [5, 93], [5, 97], [5, 98], [5, 99], [6, 9], [6, 13], [6, 16], [6, 20], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 32], [6, 38], [6, 46], [6, 52], [6, 58], [6, 61], [6, 62], [6, 63], [6, 64], [6, 67], [6, 68], [6, 70], [6, 77], [6, 79], [6, 80], [6, 82], [6, 84], [6, 87], [6, 88], [6, 90], [6, 95], [6, 96], [7, 9], [7, 10], [7, 14], [7, 15], [7, 16], [7, 20], [7, 23], [7, 28], [7, 29], [7, 31], [7, 36], [7, 37], [7, 39], [7, 43], [7, 45], [7, 46], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 60], [7, 62], [7, 63], [7, 64], [7, 65], [7, 68], [7, 72], [7, 74], [7, 75], [7, 79], [7, 80], [7, 81], [7, 82], [7, 89], [7, 92], [7, 94], [7, 99], [8, 11], [8, 14], [8, 17], [8, 20], [8, 23], [8, 24], [8, 26], [8, 27], [8, 31], [8, 32], [8, 40], [8, 42], [8, 44], [8, 45], [8, 47], [8, 48], [8, 52], [8, 58], [8, 59], [8, 61], [8, 64], [8, 67], [8, 73], [8, 75], [8, 77], [8, 80], [8, 82], [8, 88], [8, 90], [8, 97], [8, 98], [9, 13], [9, 20], [9, 24], [9, 25], [9, 35], [9, 36], [9, 37], [9, 38], [9, 43], [9, 47], [9, 48], [9, 61], [9, 62], [9, 63], [9, 65], [9, 67], [9, 69], [9, 70], [9, 76], [9, 81], [9, 83], [9, 85], [9, 86], [9, 87], [9, 89], [9, 90], [9, 96], [10, 12], [10, 16], [10, 17], [10, 18], [10, 19], [10, 21], [10, 22], [10, 29], [10, 33], [10, 35], [10, 36], [10, 38], [10, 46], [10, 57], [10, 58], [10, 61], [10, 63], [10, 66], [10, 75], [10, 92], [10, 93], [10, 98], [11, 13], [11, 15], [11, 16], [11, 22], [11, 30], [11, 32], [11, 34], [11, 37], [11, 38], [11, 40], [11, 41], [11, 46], [11, 48], [11, 49], [11, 57], [11, 74], [11, 75], [11, 76], [11, 87], [11, 96], [11, 98], [11, 99], [12, 16], [12, 18], [12, 19], [12, 21], [12, 22], [12, 23], [12, 31], [12, 32], [12, 36], [12, 39], [12, 41], [12, 47], [12, 52], [12, 61], [12, 63], [12, 64], [12, 68], [12, 71], [12, 86], [12, 93], [12, 95], [12, 97], [13, 14], [13, 15], [13, 16], [13, 20], [13, 25], [13, 27], [13, 28], [13, 29], [13, 31], [13, 34], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 44], [13, 47], [13, 51], [13, 61], [13, 62], [13, 64], [13, 65], [13, 66], [13, 76], [13, 77], [13, 80], [13, 86], [13, 97], [13, 98], [14, 19], [14, 23], [14, 25], [14, 32], [14, 34], [14, 40], [14, 46], [14, 51], [14, 52], [14, 55], [14, 56], [14, 58], [14, 66], [14, 76], [14, 83], [14, 87], [14, 91], [14, 97], [14, 98], [14, 99], [15, 22], [15, 29], [15, 30], [15, 37], [15, 43], [15, 44], [15, 45], [15, 47], [15, 48], [15, 49], [15, 50], [15, 53], [15, 60], [15, 64], [15, 66], [15, 68], [15, 69], [15, 71], [15, 73], [15, 74], [15, 77], [15, 78], [15, 86], [15, 88], [15, 96], [16, 17], [16, 19], [16, 20], [16, 21], [16, 22], [16, 27], [16, 29], [16, 31], [16, 34], [16, 38], [16, 42], [16, 44], [16, 47], [16, 54], [16, 56], [16, 57], [16, 58], [16, 67], [16, 72], [16, 73], [16, 76], [16, 77], [16, 84], [16, 86], [16, 90], [16, 92], [16, 94], [16, 99], [17, 21], [17, 22], [17, 23], [17, 24], [17, 32], [17, 33], [17, 36], [17, 38], [17, 39], [17, 46], [17, 47], [17, 49], [17, 50], [17, 53], [17, 57], [17, 58], [17, 60], [17, 63], [17, 64], [17, 66], [17, 70], [17, 71], [17, 76], [17, 83], [17, 93], [17, 99], [18, 20], [18, 23], [18, 27], [18, 40], [18, 46], [18, 47], [18, 49], [18, 54], [18, 55], [18, 56], [18, 58], [18, 63], [18, 67], [18, 69], [18, 73], [18, 75], [18, 80], [18, 82], [18, 83], [18, 89], [18, 93], [18, 94], [19, 20], [19, 22], [19, 30], [19, 31], [19, 45], [19, 46], [19, 47], [19, 48], [19, 51], [19, 54], [19, 58], [19, 64], [19, 65], [19, 66], [19, 68], [19, 73], [19, 74], [19, 75], [19, 77], [19, 79], [19, 83], [19, 84], [19, 90], [19, 91], [19, 98], [19, 99], [20, 24], [20, 29], [20, 33], [20, 35], [20, 39], [20, 44], [20, 46], [20, 52], [20, 55], [20, 56], [20, 57], [20, 58], [20, 60], [20, 61], [20, 62], [20, 65], [20, 68], [20, 71], [20, 73], [20, 74], [20, 76], [20, 81], [20, 85], [20, 87], [20, 89], [20, 92], [20, 96], [20, 99], [21, 24], [21, 28], [21, 29], [21, 30], [21, 35], [21, 43], [21, 45], [21, 48], [21, 51], [21, 53], [21, 54], [21, 56], [21, 59], [21, 61], [21, 64], [21, 65], [21, 66], [21, 72], [21, 76], [21, 79], [21, 80], [21, 81], [21, 82], [21, 84], [21, 91], [21, 95], [22, 24], [22, 26], [22, 28], [22, 30], [22, 33], [22, 40], [22, 43], [22, 49], [22, 51], [22, 57], [22, 58], [22, 59], [22, 66], [22, 67], [22, 68], [22, 70], [22, 71], [22, 72], [22, 76], [22, 77], [22, 84], [22, 85], [22, 88], [22, 89], [22, 99], [23, 24], [23, 27], [23, 28], [23, 31], [23, 32], [23, 33], [23, 39], [23, 40], [23, 43], [23, 45], [23, 46], [23, 50], [23, 55], [23, 56], [23, 60], [23, 61], [23, 64], [23, 67], [23, 69], [23, 73], [23, 74], [23, 78], [23, 79], [23, 81], [23, 92], [23, 99], [24, 32], [24, 34], [24, 40], [24, 49], [24, 51], [24, 52], [24, 54], [24, 56], [24, 57], [24, 62], [24, 67], [24, 71], [24, 76], [24, 77], [24, 78], [24, 83], [24, 86], [24, 88], [24, 89], [24, 90], [24, 92], [24, 97], [24, 98], [24, 99], [25, 27], [25, 30], [25, 33], [25, 34], [25, 39], [25, 40], [25, 41], [25, 43], [25, 45], [25, 46], [25, 49], [25, 50], [25, 54], [25, 55], [25, 60], [25, 61], [25, 62], [25, 65], [25, 71], [25, 77], [25, 78], [25, 79], [25, 80], [25, 84], [25, 87], [25, 90], [25, 91], [25, 92], [25, 96], [26, 29], [26, 30], [26, 32], [26, 34], [26, 37], [26, 40], [26, 48], [26, 59], [26, 62], [26, 63], [26, 68], [26, 69], [26, 70], [26, 72], [26, 77], [26, 82], [26, 83], [26, 84], [26, 86], [26, 89], [26, 92], [26, 94], [26, 95], [26, 99], [27, 29], [27, 32], [27, 33], [27, 36], [27, 40], [27, 42], [27, 43], [27, 47], [27, 49], [27, 51], [27, 54], [27, 61], [27, 62], [27, 64], [27, 65], [27, 72], [27, 73], [27, 74], [27, 78], [27, 80], [27, 81], [27, 82], [27, 83], [27, 84], [27, 92], [27, 93], [27, 96], [28, 30], [28, 31], [28, 32], [28, 34], [28, 36], [28, 37], [28, 39], [28, 40], [28, 44], [28, 45], [28, 46], [28, 48], [28, 56], [28, 57], [28, 61], [28, 65], [28, 68], [28, 69], [28, 70], [28, 72], [28, 73], [28, 74], [28, 77], [28, 79], [28, 84], [28, 88], [28, 89], [28, 90], [28, 93], [28, 97], [29, 31], [29, 33], [29, 34], [29, 36], [29, 40], [29, 45], [29, 52], [29, 53], [29, 54], [29, 58], [29, 62], [29, 65], [29, 69], [29, 73], [29, 74], [29, 77], [29, 81], [29, 88], [29, 91], [29, 96], [30, 31], [30, 32], [30, 36], [30, 37], [30, 46], [30, 49], [30, 59], [30, 61], [30, 63], [30, 67], [30, 70], [30, 73], [30, 78], [30, 82], [30, 84], [30, 86], [30, 91], [30, 96], [30, 97], [30, 99], [31, 32], [31, 37], [31, 41], [31, 42], [31, 48], [31, 51], [31, 61], [31, 65], [31, 68], [31, 71], [31, 72], [31, 79], [31, 80], [31, 84], [31, 87], [31, 88], [31, 89], [31, 97], [31, 98], [32, 33], [32, 35], [32, 36], [32, 43], [32, 45], [32, 53], [32, 56], [32, 58], [32, 59], [32, 67], [32, 68], [32, 69], [32, 80], [32, 82], [32, 85], [32, 88], [32, 91], [32, 93], [32, 96], [32, 98], [33, 36], [33, 37], [33, 38], [33, 39], [33, 40], [33, 42], [33, 49], [33, 51], [33, 55], [33, 58], [33, 59], [33, 63], [33, 69], [33, 74], [33, 75], [33, 77], [33, 81], [33, 85], [33, 86], [33, 89], [33, 92], [33, 94], [33, 98], [33, 99], [34, 41], [34, 42], [34, 43], [34, 44], [34, 52], [34, 53], [34, 56], [34, 57], [34, 61], [34, 63], [34, 64], [34, 65], [34, 66], [34, 68], [34, 70], [34, 71], [34, 78], [34, 83], [34, 86], [34, 88], [34, 90], [34, 91], [34, 93], [35, 36], [35, 41], [35, 47], [35, 49], [35, 50], [35, 54], [35, 56], [35, 58], [35, 62], [35, 63], [35, 67], [35, 69], [35, 70], [35, 82], [35, 83], [35, 87], [35, 91], [35, 99], [36, 39], [36, 41], [36, 44], [36, 46], [36, 53], [36, 56], [36, 58], [36, 59], [36, 63], [36, 65], [36, 69], [36, 74], [36, 76], [36, 78], [36, 80], [36, 81], [36, 83], [36, 86], [36, 88], [36, 90], [36, 92], [36, 93], [36, 95], [36, 99], [37, 41], [37, 43], [37, 44], [37, 46], [37, 50], [37, 56], [37, 58], [37, 66], [37, 68], [37, 70], [37, 75], [37, 77], [37, 78], [37, 79], [37, 80], [37, 83], [37, 85], [37, 86], [37, 90], [37, 91], [37, 94], [37, 96], [37, 98], [38, 40], [38, 42], [38, 51], [38, 52], [38, 55], [38, 57], [38, 58], [38, 62], [38, 65], [38, 68], [38, 71], [38, 75], [38, 76], [38, 82], [38, 89], [38, 92], [38, 99], [39, 44], [39, 45], [39, 50], [39, 53], [39, 57], [39, 63], [39, 66], [39, 67], [39, 68], [39, 70], [39, 73], [39, 78], [39, 81], [39, 82], [39, 83], [39, 84], [39, 86], [39, 87], [39, 88], [39, 89], [39, 91], [39, 93], [39, 94], [40, 45], [40, 53], [40, 57], [40, 70], [40, 74], [40, 75], [40, 77], [40, 78], [40, 83], [40, 90], [40, 96], [40, 97], [40, 98], [40, 99], [41, 45], [41, 61], [41, 62], [41, 65], [41, 74], [41, 75], [41, 76], [41, 77], [41, 80], [41, 84], [41, 88], [41, 89], [41, 91], [41, 97], [41, 99], [42, 44], [42, 47], [42, 48], [42, 49], [42, 54], [42, 55], [42, 57], [42, 64], [42, 65], [42, 67], [42, 70], [42, 72], [42, 75], [42, 76], [42, 83], [42, 84], [42, 85], [42, 86], [42, 87], [42, 88], [42, 92], [42, 94], [42, 98], [43, 45], [43, 46], [43, 49], [43, 51], [43, 54], [43, 55], [43, 57], [43, 61], [43, 63], [43, 64], [43, 68], [43, 69], [43, 72], [43, 76], [43, 78], [43, 80], [43, 84], [43, 89], [43, 91], [43, 93], [43, 94], [43, 99], [44, 47], [44, 48], [44, 49], [44, 54], [44, 66], [44, 72], [44, 74], [44, 80], [44, 81], [44, 83], [44, 84], [44, 87], [44, 88], [44, 90], [44, 94], [44, 95], [45, 47], [45, 54], [45, 55], [45, 58], [45, 59], [45, 70], [45, 71], [45, 73], [45, 75], [45, 77], [45, 80], [45, 81], [45, 82], [45, 83], [45, 86], [45, 87], [45, 90], [45, 91], [45, 93], [45, 97], [46, 48], [46, 49], [46, 54], [46, 56], [46, 66], [46, 71], [46, 72], [46, 76], [46, 77], [46, 80], [46, 81], [46, 82], [46, 86], [46, 89], [46, 92], [46, 93], [46, 94], [46, 97], [47, 49], [47, 53], [47, 54], [47, 57], [47, 59], [47, 61], [47, 62], [47, 63], [47, 65], [47, 67], [47, 69], [47, 70], [47, 72], [47, 73], [47, 75], [47, 76], [47, 77], [47, 79], [47, 82], [47, 84], [47, 87], [47, 90], [47, 95], [47, 96], [47, 97], [48, 51], [48, 54], [48, 59], [48, 64], [48, 67], [48, 73], [48, 75], [48, 81], [48, 84], [48, 86], [48, 88], [48, 92], [48, 94], [48, 96], [48, 99], [49, 50], [49, 53], [49, 54], [49, 55], [49, 58], [49, 60], [49, 66], [49, 67], [49, 68], [49, 73], [49, 74], [49, 78], [49, 79], [49, 85], [49, 90], [49, 93], [49, 97], [50, 51], [50, 58], [50, 59], [50, 67], [50, 68], [50, 73], [50, 75], [50, 82], [50, 83], [50, 84], [50, 85], [50, 88], [50, 93], [50, 99], [51, 52], [51, 54], [51, 56], [51, 57], [51, 61], [51, 62], [51, 67], [51, 68], [51, 74], [51, 79], [51, 80], [51, 83], [51, 84], [51, 86], [51, 87], [51, 88], [51, 90], [51, 95], [51, 96], [51, 97], [52, 59], [52, 61], [52, 63], [52, 65], [52, 68], [52, 80], [52, 83], [52, 84], [52, 85], [52, 86], [52, 88], [52, 89], [52, 91], [52, 92], [52, 93], [52, 94], [52, 95], [53, 54], [53, 56], [53, 57], [53, 59], [53, 60], [53, 61], [53, 66], [53, 73], [53, 77], [53, 81], [53, 82], [53, 83], [53, 85], [53, 86], [53, 91], [53, 92], [53, 94], [54, 60], [54, 67], [54, 72], [54, 73], [54, 74], [54, 80], [54, 81], [54, 83], [54, 85], [54, 86], [54, 89], [54, 90], [54, 91], [54, 93], [54, 95], [54, 98], [55, 59], [55, 60], [55, 63], [55, 65], [55, 69], [55, 70], [55, 73], [55, 76], [55, 77], [55, 78], [55, 81], [55, 83], [55, 84], [55, 85], [55, 93], [55, 98], [55, 99], [56, 59], [56, 64], [56, 68], [56, 70], [56, 79], [56, 81], [56, 84], [56, 88], [56, 92], [56, 93], [56, 94], [56, 96], [56, 97], [57, 58], [57, 69], [57, 71], [57, 72], [57, 75], [57, 78], [57, 83], [57, 88], [58, 60], [58, 62], [58, 70], [58, 77], [58, 78], [58, 81], [58, 83], [58, 86], [58, 92], [58, 99], [59, 60], [59, 67], [59, 69], [59, 72], [59, 75], [59, 82], [59, 83], [59, 84], [59, 85], [59, 92], [59, 95], [59, 98], [60, 63], [60, 69], [60, 70], [60, 71], [60, 74], [60, 75], [60, 77], [60, 78], [60, 81], [60, 87], [60, 89], [60, 90], [60, 93], [60, 95], [60, 99], [61, 62], [61, 66], [61, 67], [61, 69], [61, 79], [61, 83], [61, 88], [61, 89], [61, 92], [61, 94], [61, 96], [62, 65], [62, 69], [62, 70], [62, 76], [62, 89], [62, 91], [62, 92], [63, 65], [63, 70], [63, 73], [63, 74], [63, 78], [63, 79], [63, 81], [63, 86], [63, 90], [63, 94], [63, 97], [63, 99], [64, 70], [64, 72], [64, 74], [64, 75], [64, 76], [64, 79], [64, 80], [64, 82], [64, 85], [64, 86], [64, 89], [64, 93], [65, 71], [65, 75], [65, 77], [65, 85], [65, 86], [65, 93], [65, 97], [66, 67], [66, 70], [66, 72], [66, 74], [66, 79], [66, 80], [66, 83], [66, 85], [66, 92], [66, 94], [66, 95], [66, 96], [67, 70], [67, 71], [67, 74], [67, 78], [67, 80], [67, 82], [67, 87], [67, 88], [67, 90], [67, 91], [67, 93], [67, 99], [68, 69], [68, 71], [68, 73], [68, 78], [68, 80], [68, 81], [68, 92], [68, 93], [68, 94], [68, 96], [68, 97], [69, 75], [69, 76], [69, 84], [69, 93], [69, 97], [70, 74], [70, 77], [70, 81], [70, 82], [70, 83], [70, 85], [70, 91], [70, 93], [70, 95], [70, 97], [70, 98], [71, 73], [71, 84], [71, 85], [71, 89], [71, 91], [71, 93], [71, 98], [72, 73], [72, 74], [72, 78], [72, 85], [72, 87], [72, 88], [72, 90], [72, 91], [72, 93], [72, 94], [72, 96], [73, 75], [73, 78], [73, 82], [73, 83], [73, 85], [73, 86], [73, 88], [73, 90], [73, 93], [73, 95], [73, 99], [74, 76], [74, 78], [74, 81], [74, 82], [74, 86], [74, 87], [74, 95], [74, 99], [75, 85], [75, 87], [75, 88], [75, 90], [75, 92], [75, 93], [75, 94], [76, 77], [76, 78], [76, 79], [76, 86], [76, 88], [76, 91], [76, 93], [76, 94], [76, 98], [77, 81], [77, 89], [78, 79], [78, 80], [78, 86], [78, 88], [78, 92], [78, 95], [78, 98], [79, 80], [79, 82], [79, 85], [79, 86], [79, 90], [79, 91], [79, 92], [79, 93], [79, 96], [79, 99], [80, 81], [80, 85], [80, 86], [80, 87], [80, 88], [80, 92], [81, 82], [81, 83], [81, 85], [81, 86], [81, 89], [81, 91], [81, 92], [81, 98], [82, 85], [82, 86], [82, 92], [82, 93], [82, 95], [82, 99], [83, 84], [83, 91], [83, 92], [83, 93], [84, 85], [84, 87], [84, 95], [84, 98], [84, 99], [85, 87], [85, 88], [85, 90], [85, 92], [85, 99], [86, 88], [86, 90], [86, 91], [86, 92], [87, 89], [87, 91], [87, 96], [88, 89], [88, 91], [88, 92], [88, 93], [88, 95], [89, 90], [89, 91], [89, 93], [89, 95], [89, 96], [89, 97], [89, 98], [89, 99], [90, 92], [90, 96], [90, 99], [91, 92], [91, 93], [91, 96], [92, 93], [92, 94], [92, 97], [92, 99], [93, 96], [93, 98], [94, 97], [95, 96], [95, 97], [95, 98], [97, 98], [97, 99], [98, 99]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l4-s8/tests/run.py b/tasks/construct-nppc-dominating-set-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l4-s8/tests/test.sh b/tasks/construct-nppc-dominating-set-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-graph-color-l1-s1/environment/Dockerfile b/tasks/construct-rg-graph-color-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-graph-color-l1-s1/environment/instance.json b/tasks/construct-rg-graph-color-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d47b164a180fc793c00af45a5276b3d626a8c877 --- /dev/null +++ b/tasks/construct-rg-graph-color-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 6, "num_colors": 4, "edges": [[0, 2], [0, 4], [0, 5], [1, 5], [2, 3]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l1-s1/solution/solve.sh b/tasks/construct-rg-graph-color-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cb2dac66b799653557cdebf68849d53f1013e407 --- /dev/null +++ b/tasks/construct-rg-graph-color-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 1, 2, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l1-s1/tests/check.py b/tasks/construct-rg-graph-color-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l1-s1/tests/check.py @@ -0,0 +1,13 @@ +"""Proper colouring with colours 1..k (Reasoning Gym graph_color, Apache-2.0). Any valid colouring. +Upstream note: its verifier checks `color in allowed_colors`, so True (== 1) and 1.0 were accepted as +colours, and extra keys were ignored. Here colours must be ints in 1..k, one per vertex.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_vertices"], inst["num_colors"] + c = int_list(ans.get("coloring"), n, 1, k, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"adjacent vertices {u} and {v} share colour {c[u]}") + return None, {} diff --git a/tasks/construct-rg-graph-color-l1-s1/tests/instance.json b/tasks/construct-rg-graph-color-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d47b164a180fc793c00af45a5276b3d626a8c877 --- /dev/null +++ b/tasks/construct-rg-graph-color-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 6, "num_colors": 4, "edges": [[0, 2], [0, 4], [0, 5], [1, 5], [2, 3]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l1-s1/tests/run.py b/tasks/construct-rg-graph-color-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-graph-color-l1-s1/tests/test.sh b/tasks/construct-rg-graph-color-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-graph-color-l5-s0/environment/Dockerfile b/tasks/construct-rg-graph-color-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-graph-color-l5-s0/environment/instance.json b/tasks/construct-rg-graph-color-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f5de745df4bb2e47f6fc5137ddd4beb9e11fcd1e --- /dev/null +++ b/tasks/construct-rg-graph-color-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 25, "num_colors": 3, "edges": [[0, 15], [0, 18], [0, 20], [1, 3], [1, 4], [1, 11], [1, 13], [2, 4], [2, 6], [2, 13], [2, 19], [3, 4], [3, 12], [3, 14], [3, 20], [4, 5], [4, 8], [4, 9], [4, 15], [4, 23], [5, 9], [5, 12], [5, 14], [6, 12], [6, 14], [6, 17], [7, 10], [8, 11], [8, 19], [8, 23], [9, 14], [9, 18], [9, 22], [10, 11], [10, 12], [10, 18], [11, 17], [11, 21], [12, 13], [12, 24], [13, 14], [13, 19], [13, 20], [14, 23], [14, 24], [16, 20], [16, 23], [17, 20], [19, 21], [20, 22], [21, 23], [22, 23]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l5-s0/solution/solve.sh b/tasks/construct-rg-graph-color-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7266bc4b6d1ffcf8d1dc05929ed19d012d3a981c --- /dev/null +++ b/tasks/construct-rg-graph-color-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 1, 1, 2, 3, 1, 2, 1, 1, 2, 2, 3, 3, 2, 3, 2, 1, 1, 3, 3, 3, 1, 1, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l5-s0/tests/check.py b/tasks/construct-rg-graph-color-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l5-s0/tests/check.py @@ -0,0 +1,13 @@ +"""Proper colouring with colours 1..k (Reasoning Gym graph_color, Apache-2.0). Any valid colouring. +Upstream note: its verifier checks `color in allowed_colors`, so True (== 1) and 1.0 were accepted as +colours, and extra keys were ignored. Here colours must be ints in 1..k, one per vertex.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_vertices"], inst["num_colors"] + c = int_list(ans.get("coloring"), n, 1, k, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"adjacent vertices {u} and {v} share colour {c[u]}") + return None, {} diff --git a/tasks/construct-rg-graph-color-l5-s0/tests/instance.json b/tasks/construct-rg-graph-color-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f5de745df4bb2e47f6fc5137ddd4beb9e11fcd1e --- /dev/null +++ b/tasks/construct-rg-graph-color-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 25, "num_colors": 3, "edges": [[0, 15], [0, 18], [0, 20], [1, 3], [1, 4], [1, 11], [1, 13], [2, 4], [2, 6], [2, 13], [2, 19], [3, 4], [3, 12], [3, 14], [3, 20], [4, 5], [4, 8], [4, 9], [4, 15], [4, 23], [5, 9], [5, 12], [5, 14], [6, 12], [6, 14], [6, 17], [7, 10], [8, 11], [8, 19], [8, 23], [9, 14], [9, 18], [9, 22], [10, 11], [10, 12], [10, 18], [11, 17], [11, 21], [12, 13], [12, 24], [13, 14], [13, 19], [13, 20], [14, 23], [14, 24], [16, 20], [16, 23], [17, 20], [19, 21], [20, 22], [21, 23], [22, 23]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l5-s0/tests/run.py b/tasks/construct-rg-graph-color-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-graph-color-l5-s0/tests/test.sh b/tasks/construct-rg-graph-color-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-simple-integration-l1-s7/environment/Dockerfile b/tasks/construct-rg-simple-integration-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-simple-integration-l1-s7/environment/instance.json b/tasks/construct-rg-simple-integration-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5580b2487b0f47641395e0b99a3a89fd7364a48d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*x - 5/6", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l1-s7/solution/solve.sh b/tasks/construct-rg-simple-integration-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4dfd68a27a5cadf9dda43c1ed74831f4d44398f8 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "x**2 - 5*x/6 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l1-s7/tests/check.py b/tasks/construct-rg-simple-integration-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s7/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-simple-integration-l1-s7/tests/instance.json b/tasks/construct-rg-simple-integration-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5580b2487b0f47641395e0b99a3a89fd7364a48d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*x - 5/6", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l1-s7/tests/run.py b/tasks/construct-rg-simple-integration-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-simple-integration-l1-s7/tests/test.sh b/tasks/construct-rg-simple-integration-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-simple-integration-l1-s9/environment/Dockerfile b/tasks/construct-rg-simple-integration-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-simple-integration-l1-s9/environment/instance.json b/tasks/construct-rg-simple-integration-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2a96458196b31150f5613646e5eb718890a6fead --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "65*x**2/2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l1-s9/solution/solve.sh b/tasks/construct-rg-simple-integration-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2be816baf56ddcb6b68bca7f218118743b27a9ab --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "65*x**3/6 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l1-s9/tests/check.py b/tasks/construct-rg-simple-integration-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s9/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-simple-integration-l1-s9/tests/instance.json b/tasks/construct-rg-simple-integration-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2a96458196b31150f5613646e5eb718890a6fead --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "65*x**2/2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l1-s9/tests/run.py b/tasks/construct-rg-simple-integration-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-simple-integration-l1-s9/tests/test.sh b/tasks/construct-rg-simple-integration-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-simple-integration-l5-s8/environment/Dockerfile b/tasks/construct-rg-simple-integration-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l5-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-simple-integration-l5-s8/environment/instance.json b/tasks/construct-rg-simple-integration-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3fa2cdb19d5cf05cd5189dbc96d6e074c5e59b3b --- /dev/null +++ b/tasks/construct-rg-simple-integration-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-9*X**8/5 + 4*X**7 - 7*X**6 + 24*X**3 + 2/3", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l5-s8/solution/solve.sh b/tasks/construct-rg-simple-integration-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b68c58e8c77117d1411c5cf80d1f58c43584fad7 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l5-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "-X**9/5 + X**8/2 - X**7 + 6*X**4 + 2*X/3 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l5-s8/tests/check.py b/tasks/construct-rg-simple-integration-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l5-s8/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-simple-integration-l5-s8/tests/instance.json b/tasks/construct-rg-simple-integration-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3fa2cdb19d5cf05cd5189dbc96d6e074c5e59b3b --- /dev/null +++ b/tasks/construct-rg-simple-integration-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-9*X**8/5 + 4*X**7 - 7*X**6 + 24*X**3 + 2/3", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l5-s8/tests/run.py b/tasks/construct-rg-simple-integration-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l5-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-simple-integration-l5-s8/tests/test.sh b/tasks/construct-rg-simple-integration-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l5-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-antiderivative-l4-s1/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-antiderivative-l4-s1/environment/instance.json b/tasks/construct-rlve-antiderivative-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..377c25e9a7683c148e89631ac0725d98d9f56e8b --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "36*x + 6", "max_ops": 40, "max_len": 740, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l4-s1/solution/solve.sh b/tasks/construct-rlve-antiderivative-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d70a168b14201e2ab5349858fada43ecfe227ccb --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"F": "18*x**2 + 6*x - 2"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l4-s1/tests/check.py b/tasks/construct-rlve-antiderivative-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l4-s1/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l4-s1/tests/instance.json b/tasks/construct-rlve-antiderivative-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..377c25e9a7683c148e89631ac0725d98d9f56e8b --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "36*x + 6", "max_ops": 40, "max_len": 740, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l4-s1/tests/run.py b/tasks/construct-rlve-antiderivative-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-antiderivative-l4-s1/tests/test.sh b/tasks/construct-rlve-antiderivative-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-bezout-identity-l1-s3/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-bezout-identity-l1-s3/environment/instance.json b/tasks/construct-rlve-bezout-identity-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa18656182ab774d4a082c0915033288beed1631 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": [4, 6], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l1-s3/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..21915d963eee988e3c3e4400b8e77b252e6054ca --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [-1, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l1-s3/tests/check.py b/tasks/construct-rlve-bezout-identity-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s3/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l1-s3/tests/instance.json b/tasks/construct-rlve-bezout-identity-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa18656182ab774d4a082c0915033288beed1631 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": [4, 6], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l1-s3/tests/run.py b/tasks/construct-rlve-bezout-identity-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-bezout-identity-l1-s3/tests/test.sh b/tasks/construct-rlve-bezout-identity-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-bezout-identity-l1-s4/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-bezout-identity-l1-s4/environment/instance.json b/tasks/construct-rlve-bezout-identity-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..53a6c2b5f281c0b2226c2b4d9322d7cd15d1d046 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": [-7, -7], "target": 7, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l1-s4/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac9af345c90a4a9109b47c2fae0aa39fc703e603 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [0, -1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l1-s4/tests/check.py b/tasks/construct-rlve-bezout-identity-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s4/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l1-s4/tests/instance.json b/tasks/construct-rlve-bezout-identity-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..53a6c2b5f281c0b2226c2b4d9322d7cd15d1d046 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": [-7, -7], "target": 7, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l1-s4/tests/run.py b/tasks/construct-rlve-bezout-identity-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-bezout-identity-l1-s4/tests/test.sh b/tasks/construct-rlve-bezout-identity-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l1-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-bezout-identity-l5-s5/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l5-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-bezout-identity-l5-s5/environment/instance.json b/tasks/construct-rlve-bezout-identity-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..272a8b75d7ba55e85ece52061fa8953385ee5a0e --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": [-4625, 3800, 5765, -960, 15, -4540, -2205, 5725, 8050, -7925], "target": 5, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l5-s5/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..980e1b5ee33e3ba8b642e532de052a490f16c131 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l5-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [-10603, -12908, 2, 0, 0, 0, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l5-s5/tests/check.py b/tasks/construct-rlve-bezout-identity-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l5-s5/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l5-s5/tests/instance.json b/tasks/construct-rlve-bezout-identity-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..272a8b75d7ba55e85ece52061fa8953385ee5a0e --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": [-4625, 3800, 5765, -960, 15, -4540, -2205, 5725, 8050, -7925], "target": 5, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l5-s5/tests/run.py b/tasks/construct-rlve-bezout-identity-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l5-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-bezout-identity-l5-s5/tests/test.sh b/tasks/construct-rlve-bezout-identity-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l5-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-crt-l2-s1/environment/Dockerfile b/tasks/construct-rlve-crt-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-crt-l2-s1/environment/instance.json b/tasks/construct-rlve-crt-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..464f610b5bde3c8a9aeef8a18cbfdad0dae5d2fa --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [145, 51, 6], "residues": [25, 17, 2], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l2-s1/solution/solve.sh b/tasks/construct-rlve-crt-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3ca08af426b362bfe404dc974553e3d9bfa0ad32 --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 170} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l2-s1/tests/check.py b/tasks/construct-rlve-crt-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s1/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l2-s1/tests/instance.json b/tasks/construct-rlve-crt-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..464f610b5bde3c8a9aeef8a18cbfdad0dae5d2fa --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [145, 51, 6], "residues": [25, 17, 2], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l2-s1/tests/run.py b/tasks/construct-rlve-crt-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-crt-l2-s1/tests/test.sh b/tasks/construct-rlve-crt-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-crt-l2-s8/environment/Dockerfile b/tasks/construct-rlve-crt-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-crt-l2-s8/solution/solve.sh b/tasks/construct-rlve-crt-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c1f5886e7b527d8b054219672f87823e8cd1ec26 --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 82} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l2-s8/tests/check.py b/tasks/construct-rlve-crt-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s8/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l2-s8/tests/instance.json b/tasks/construct-rlve-crt-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1fa6a0aeabf4d6883711d91daf58e3e7d5a6e4d2 --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [28, 19, 23], "residues": [26, 6, 13], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l2-s8/tests/run.py b/tasks/construct-rlve-crt-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-crt-l2-s8/tests/test.sh b/tasks/construct-rlve-crt-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-l2-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-crt-l6-s0/environment/Dockerfile b/tasks/construct-rlve-crt-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-l6-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-crt-l6-s0/environment/instance.json b/tasks/construct-rlve-crt-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2de1c5f52f426e96c8f90926236c5822270b8423 --- /dev/null +++ b/tasks/construct-rlve-crt-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [16799074560376, 100070206328936, 24184244031781, 129796305786173, 38650282490168, 69001652881486, 13273824092374, 117741933522324], "residues": [15623008382971, 33146323976667, 12295310146698, 3420224519430, 17265682835099, 64214877424117, 478289381863, 15474596783279], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l6-s0/solution/solve.sh b/tasks/construct-rlve-crt-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f0c212d2b6aac34329d8e937e214758ac256efee --- /dev/null +++ b/tasks/construct-rlve-crt-l6-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 133216530305603} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l6-s0/tests/check.py b/tasks/construct-rlve-crt-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l6-s0/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l6-s0/tests/instance.json b/tasks/construct-rlve-crt-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2de1c5f52f426e96c8f90926236c5822270b8423 --- /dev/null +++ b/tasks/construct-rlve-crt-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [16799074560376, 100070206328936, 24184244031781, 129796305786173, 38650282490168, 69001652881486, 13273824092374, 117741933522324], "residues": [15623008382971, 33146323976667, 12295310146698, 3420224519430, 17265682835099, 64214877424117, 478289381863, 15474596783279], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l6-s0/tests/run.py b/tasks/construct-rlve-crt-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-l6-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-crt-l6-s0/tests/test.sh b/tasks/construct-rlve-crt-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-l6-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9811702b1c08e0b85458979f3564ed41200af84d --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": [6, 0, 13, 7, 4, 14, 17, 5, 15, 11], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6200ed7ea855c165dd7e3d486a98d14997965b2e --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [7, 4, 14, 11, 5, 15, 0, 6, 17, 13]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9811702b1c08e0b85458979f3564ed41200af84d --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": [6, 0, 13, 7, 4, 14, 17, 5, 15, 11], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l3-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-even-degree-partition-l2-s6/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-even-degree-partition-l2-s6/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..35c02b59b224b017fc90f924bc7726ec412769e5 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges": [[0, 2], [0, 5], [1, 3], [1, 4], [1, 5], [1, 7], [3, 4], [3, 5], [4, 5], [4, 6], [5, 7], [6, 7]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l2-s6/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..17286e9331acad813ade7c15ae8a2d8f3efeed2c --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"groups": [2, 1, 1, 1, 2, 1, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l2-s6/tests/check.py b/tasks/construct-rlve-even-degree-partition-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s6/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = int_list(ans.get("groups"), n, 1, 2, "groups") + deg = [0] * n + for u, v in inst["edges"]: + if g[u] == g[v]: + deg[u] += 1 + deg[v] += 1 + for v in range(n): + if deg[v] % 2: + raise Invalid(f"vertex {v} has {deg[v]} same-group neighbours") + return None, {} diff --git a/tasks/construct-rlve-even-degree-partition-l2-s6/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..35c02b59b224b017fc90f924bc7726ec412769e5 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges": [[0, 2], [0, 5], [1, 3], [1, 4], [1, 5], [1, 7], [3, 4], [3, 5], [4, 5], [4, 6], [5, 7], [6, 7]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l2-s6/tests/run.py b/tasks/construct-rlve-even-degree-partition-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-even-degree-partition-l2-s6/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-even-degree-partition-l2-s8/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-even-degree-partition-l2-s8/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ffdf56aee7b83bfe641f7ddf96bb217898084dbc --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges": [[0, 2], [0, 3], [0, 5], [0, 6], [1, 2], [1, 6], [2, 3], [2, 4], [4, 6], [5, 6]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l2-s8/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0419f203f071de7fbbe59c2d55e74f91423395d1 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"groups": [1, 1, 1, 1, 1, 1, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l2-s8/tests/check.py b/tasks/construct-rlve-even-degree-partition-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s8/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = int_list(ans.get("groups"), n, 1, 2, "groups") + deg = [0] * n + for u, v in inst["edges"]: + if g[u] == g[v]: + deg[u] += 1 + deg[v] += 1 + for v in range(n): + if deg[v] % 2: + raise Invalid(f"vertex {v} has {deg[v]} same-group neighbours") + return None, {} diff --git a/tasks/construct-rlve-even-degree-partition-l2-s8/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ffdf56aee7b83bfe641f7ddf96bb217898084dbc --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges": [[0, 2], [0, 3], [0, 5], [0, 6], [1, 2], [1, 6], [2, 3], [2, 4], [4, 6], [5, 6]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l2-s8/tests/run.py b/tasks/construct-rlve-even-degree-partition-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-even-degree-partition-l2-s8/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l2-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-even-degree-partition-l6-s9/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l6-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-even-degree-partition-l6-s9/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0884db07359314bbb9ab83822d82f882979844d3 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges": [[0, 2], [0, 3], [0, 5], [0, 6], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 39], [1, 3], [1, 8], [1, 10], [1, 22], [1, 29], [1, 35], [2, 4], [2, 9], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 18], [2, 19], [2, 21], [2, 24], [2, 27], [2, 28], [2, 29], [2, 30], [2, 32], [2, 34], [2, 35], [2, 38], [2, 39], [3, 5], [3, 6], [3, 7], [3, 9], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 21], [3, 26], [3, 27], [3, 28], [3, 29], [3, 31], [3, 35], [3, 36], [3, 37], [3, 38], [4, 6], [4, 8], [4, 9], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 28], [4, 30], [4, 31], [4, 32], [4, 34], [4, 35], [4, 36], [4, 37], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 22], [5, 23], [5, 24], [5, 26], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [6, 8], [6, 10], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 22], [6, 28], [6, 29], [6, 31], [6, 35], [6, 37], [6, 38], [6, 39], [7, 10], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 21], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 32], [7, 36], [7, 39], [8, 9], [8, 15], [8, 16], [8, 20], [8, 21], [8, 22], [8, 25], [8, 27], [8, 28], [8, 29], [8, 33], [8, 36], [8, 37], [8, 38], [9, 13], [9, 15], [9, 21], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 34], [9, 36], [9, 37], [9, 38], [9, 39], [10, 15], [10, 16], [10, 24], [10, 26], [10, 27], [10, 29], [10, 32], [10, 33], [10, 35], [10, 36], [10, 38], [11, 12], [11, 14], [11, 15], [11, 21], [11, 22], [11, 23], [11, 25], [11, 26], [11, 27], [11, 31], [11, 34], [11, 36], [11, 37], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 19], [12, 21], [12, 22], [12, 27], [12, 28], [12, 33], [12, 34], [12, 35], [12, 37], [13, 14], [13, 15], [13, 17], [13, 18], [13, 19], [13, 21], [13, 28], [13, 31], [13, 33], [13, 34], [13, 37], [14, 15], [14, 16], [14, 19], [14, 23], [14, 24], [14, 26], [14, 28], [14, 31], [14, 32], [14, 35], [14, 36], [14, 39], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 27], [15, 30], [15, 32], [15, 33], [15, 34], [15, 36], [15, 39], [16, 18], [16, 20], [16, 21], [16, 22], [16, 28], [16, 30], [16, 33], [16, 34], [16, 35], [16, 36], [16, 37], [17, 21], [17, 22], [17, 23], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 38], [18, 21], [18, 22], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 34], [18, 37], [19, 21], [19, 26], [19, 28], [19, 29], [19, 31], [19, 32], [19, 35], [19, 37], [19, 39], [20, 22], [20, 23], [20, 28], [20, 31], [20, 33], [20, 35], [20, 37], [20, 38], [20, 39], [21, 22], [21, 24], [21, 25], [21, 26], [21, 28], [21, 30], [21, 32], [21, 34], [21, 35], [21, 39], [22, 23], [22, 27], [22, 29], [22, 30], [22, 31], [22, 33], [22, 34], [22, 36], [22, 37], [22, 38], [23, 24], [23, 29], [23, 31], [23, 32], [23, 33], [23, 36], [23, 37], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 32], [24, 34], [24, 38], [25, 27], [25, 28], [25, 29], [25, 39], [26, 27], [26, 28], [26, 30], [26, 31], [26, 32], [26, 34], [26, 35], [27, 28], [27, 29], [27, 30], [27, 31], [27, 36], [27, 37], [28, 29], [28, 30], [28, 32], [28, 34], [28, 36], [28, 38], [29, 34], [29, 37], [30, 34], [30, 37], [31, 34], [31, 37], [32, 34], [32, 36], [32, 37], [32, 38], [32, 39], [33, 35], [33, 36], [33, 37], [34, 38], [35, 36], [35, 37], [36, 39]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l6-s9/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cdbedc5feecfcdedd8cf697ad43cd3dce98995ba --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l6-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"groups": [2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l6-s9/tests/check.py b/tasks/construct-rlve-even-degree-partition-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l6-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = int_list(ans.get("groups"), n, 1, 2, "groups") + deg = [0] * n + for u, v in inst["edges"]: + if g[u] == g[v]: + deg[u] += 1 + deg[v] += 1 + for v in range(n): + if deg[v] % 2: + raise Invalid(f"vertex {v} has {deg[v]} same-group neighbours") + return None, {} diff --git a/tasks/construct-rlve-even-degree-partition-l6-s9/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0884db07359314bbb9ab83822d82f882979844d3 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges": [[0, 2], [0, 3], [0, 5], [0, 6], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 39], [1, 3], [1, 8], [1, 10], [1, 22], [1, 29], [1, 35], [2, 4], [2, 9], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 18], [2, 19], [2, 21], [2, 24], [2, 27], [2, 28], [2, 29], [2, 30], [2, 32], [2, 34], [2, 35], [2, 38], [2, 39], [3, 5], [3, 6], [3, 7], [3, 9], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 21], [3, 26], [3, 27], [3, 28], [3, 29], [3, 31], [3, 35], [3, 36], [3, 37], [3, 38], [4, 6], [4, 8], [4, 9], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 28], [4, 30], [4, 31], [4, 32], [4, 34], [4, 35], [4, 36], [4, 37], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 22], [5, 23], [5, 24], [5, 26], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [6, 8], [6, 10], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 22], [6, 28], [6, 29], [6, 31], [6, 35], [6, 37], [6, 38], [6, 39], [7, 10], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 21], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 32], [7, 36], [7, 39], [8, 9], [8, 15], [8, 16], [8, 20], [8, 21], [8, 22], [8, 25], [8, 27], [8, 28], [8, 29], [8, 33], [8, 36], [8, 37], [8, 38], [9, 13], [9, 15], [9, 21], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 34], [9, 36], [9, 37], [9, 38], [9, 39], [10, 15], [10, 16], [10, 24], [10, 26], [10, 27], [10, 29], [10, 32], [10, 33], [10, 35], [10, 36], [10, 38], [11, 12], [11, 14], [11, 15], [11, 21], [11, 22], [11, 23], [11, 25], [11, 26], [11, 27], [11, 31], [11, 34], [11, 36], [11, 37], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 19], [12, 21], [12, 22], [12, 27], [12, 28], [12, 33], [12, 34], [12, 35], [12, 37], [13, 14], [13, 15], [13, 17], [13, 18], [13, 19], [13, 21], [13, 28], [13, 31], [13, 33], [13, 34], [13, 37], [14, 15], [14, 16], [14, 19], [14, 23], [14, 24], [14, 26], [14, 28], [14, 31], [14, 32], [14, 35], [14, 36], [14, 39], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 27], [15, 30], [15, 32], [15, 33], [15, 34], [15, 36], [15, 39], [16, 18], [16, 20], [16, 21], [16, 22], [16, 28], [16, 30], [16, 33], [16, 34], [16, 35], [16, 36], [16, 37], [17, 21], [17, 22], [17, 23], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 38], [18, 21], [18, 22], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 34], [18, 37], [19, 21], [19, 26], [19, 28], [19, 29], [19, 31], [19, 32], [19, 35], [19, 37], [19, 39], [20, 22], [20, 23], [20, 28], [20, 31], [20, 33], [20, 35], [20, 37], [20, 38], [20, 39], [21, 22], [21, 24], [21, 25], [21, 26], [21, 28], [21, 30], [21, 32], [21, 34], [21, 35], [21, 39], [22, 23], [22, 27], [22, 29], [22, 30], [22, 31], [22, 33], [22, 34], [22, 36], [22, 37], [22, 38], [23, 24], [23, 29], [23, 31], [23, 32], [23, 33], [23, 36], [23, 37], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 32], [24, 34], [24, 38], [25, 27], [25, 28], [25, 29], [25, 39], [26, 27], [26, 28], [26, 30], [26, 31], [26, 32], [26, 34], [26, 35], [27, 28], [27, 29], [27, 30], [27, 31], [27, 36], [27, 37], [28, 29], [28, 30], [28, 32], [28, 34], [28, 36], [28, 38], [29, 34], [29, 37], [30, 34], [30, 37], [31, 34], [31, 37], [32, 34], [32, 36], [32, 37], [32, 38], [32, 39], [33, 35], [33, 36], [33, 37], [34, 38], [35, 36], [35, 37], [36, 39]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l6-s9/tests/run.py b/tasks/construct-rlve-even-degree-partition-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l6-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-even-degree-partition-l6-s9/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l6-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-graph-isomorphism-l4-s5/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l4-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-graph-isomorphism-l4-s5/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..df506ad43f0c4aa2dd82a7d0c4dcfa673f84af8c --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges1": [[1, 4], [3, 9], [12, 17], [3, 14], [0, 16], [12, 16], [0, 5], [0, 1], [2, 7], [9, 15], [4, 13], [3, 7], [1, 2], [3, 10], [7, 9], [1, 14], [15, 17], [10, 15], [14, 15], [2, 10], [9, 11], [4, 12], [6, 7], [5, 16], [10, 11], [1, 13], [9, 13], [7, 14], [15, 16], [12, 13], [5, 14], [9, 12], [7, 10], [4, 14], [5, 17], [13, 15], [7, 12], [3, 12], [4, 7], [0, 13], [2, 14], [1, 10], [6, 11], [7, 16], [3, 11], [4, 11], [11, 15], [0, 12], [7, 11], [4, 9], [0, 11], [9, 14], [10, 17], [3, 13], [13, 14], [5, 12], [11, 16], [1, 6], [0, 8], [10, 12], [2, 4], [3, 4], [9, 16], [2, 12], [1, 8], [12, 15], [0, 10], [3, 16], [1, 9], [12, 14], [3, 8], [11, 13], [8, 17], [6, 15], [10, 13], [6, 8], [5, 6], [11, 12], [7, 13], [5, 7], [8, 15], [9, 10], [2, 5], [4, 16], [5, 11], [8, 13], [1, 11], [2, 3], [0, 3], [6, 12], [1, 3], [0, 17], [1, 16], [5, 10], [7, 15], [0, 7], [16, 17], [4, 10], [14, 17]], "edges2": [[8, 10], [0, 3], [3, 6], [1, 9], [2, 13], [7, 13], [15, 17], [1, 11], [0, 4], [12, 16], [8, 13], [9, 15], [3, 16], [3, 11], [4, 17], [8, 9], [0, 16], [6, 11], [1, 15], [11, 17], [6, 9], [1, 5], [6, 8], [0, 1], [3, 7], [1, 3], [6, 7], [6, 17], [14, 15], [5, 7], [0, 5], [6, 16], [5, 13], [4, 15], [10, 16], [3, 4], [2, 12], [2, 4], [2, 6], [6, 12], [3, 17], [7, 10], [14, 16], [5, 16], [13, 15], [3, 5], [0, 2], [7, 8], [2, 9], [5, 11], [6, 13], [0, 10], [3, 12], [5, 12], [9, 14], [7, 11], [5, 17], [4, 11], [1, 13], [5, 9], [4, 12], [13, 14], [6, 10], [9, 17], [6, 14], [14, 17], [7, 14], [12, 15], [1, 12], [0, 11], [3, 13], [0, 17], [0, 7], [1, 8], [9, 10], [3, 10], [10, 11], [0, 14], [13, 17], [10, 15], [1, 7], [12, 14], [1, 6], [8, 11], [2, 5], [7, 16], [1, 17], [9, 13], [0, 8], [11, 13], [12, 13], [1, 16], [10, 12], [5, 6], [11, 16], [5, 14], [13, 16], [10, 13], [11, 14]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l4-s5/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..00e7692b8fe7af4c31c3ebc652d07365e951bc54 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l4-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [17, 0, 8, 11, 7, 9, 2, 6, 4, 16, 1, 5, 13, 3, 10, 12, 14, 15]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..df506ad43f0c4aa2dd82a7d0c4dcfa673f84af8c --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges1": [[1, 4], [3, 9], [12, 17], [3, 14], [0, 16], [12, 16], [0, 5], [0, 1], [2, 7], [9, 15], [4, 13], [3, 7], [1, 2], [3, 10], [7, 9], [1, 14], [15, 17], [10, 15], [14, 15], [2, 10], [9, 11], [4, 12], [6, 7], [5, 16], [10, 11], [1, 13], [9, 13], [7, 14], [15, 16], [12, 13], [5, 14], [9, 12], [7, 10], [4, 14], [5, 17], [13, 15], [7, 12], [3, 12], [4, 7], [0, 13], [2, 14], [1, 10], [6, 11], [7, 16], [3, 11], [4, 11], [11, 15], [0, 12], [7, 11], [4, 9], [0, 11], [9, 14], [10, 17], [3, 13], [13, 14], [5, 12], [11, 16], [1, 6], [0, 8], [10, 12], [2, 4], [3, 4], [9, 16], [2, 12], [1, 8], [12, 15], [0, 10], [3, 16], [1, 9], [12, 14], [3, 8], [11, 13], [8, 17], [6, 15], [10, 13], [6, 8], [5, 6], [11, 12], [7, 13], [5, 7], [8, 15], [9, 10], [2, 5], [4, 16], [5, 11], [8, 13], [1, 11], [2, 3], [0, 3], [6, 12], [1, 3], [0, 17], [1, 16], [5, 10], [7, 15], [0, 7], [16, 17], [4, 10], [14, 17]], "edges2": [[8, 10], [0, 3], [3, 6], [1, 9], [2, 13], [7, 13], [15, 17], [1, 11], [0, 4], [12, 16], [8, 13], [9, 15], [3, 16], [3, 11], [4, 17], [8, 9], [0, 16], [6, 11], [1, 15], [11, 17], [6, 9], [1, 5], [6, 8], [0, 1], [3, 7], [1, 3], [6, 7], [6, 17], [14, 15], [5, 7], [0, 5], [6, 16], [5, 13], [4, 15], [10, 16], [3, 4], [2, 12], [2, 4], [2, 6], [6, 12], [3, 17], [7, 10], [14, 16], [5, 16], [13, 15], [3, 5], [0, 2], [7, 8], [2, 9], [5, 11], [6, 13], [0, 10], [3, 12], [5, 12], [9, 14], [7, 11], [5, 17], [4, 11], [1, 13], [5, 9], [4, 12], [13, 14], [6, 10], [9, 17], [6, 14], [14, 17], [7, 14], [12, 15], [1, 12], [0, 11], [3, 13], [0, 17], [0, 7], [1, 8], [9, 10], [3, 10], [10, 11], [0, 14], [13, 17], [10, 15], [1, 7], [12, 14], [1, 6], [8, 11], [2, 5], [7, 16], [1, 17], [9, 13], [0, 8], [11, 13], [12, 13], [1, 16], [10, 12], [5, 6], [11, 16], [5, 14], [13, 16], [10, 13], [11, 14]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l4-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-grid-parity-construction-l4-s2/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l4-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-grid-parity-construction-l4-s2/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1c3b4d36a7c4ec8c22821a1200875e32fdec6fc9 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["1111", "0111", "0100", "1001", "1011", "0110", "0111", "1010", "1100"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l4-s2/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cc75d4e78a1305822de2604da3e0b16043b8de44 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l4-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"grid": ["0100", "0001", "0000", "0101", "0100", "0000", "0010", "0000", "1000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1c3b4d36a7c4ec8c22821a1200875e32fdec6fc9 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["1111", "0111", "0100", "1001", "1011", "0110", "0111", "1010", "1100"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l4-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s3/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s3/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc51423b5eae6da8256f520b93ce611a82552cbf --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 1], [9, 6], [0, 9], [4, 2], [5, 7], [9, 8], [5, 3], [6, 3], [7, 8]], "k": 7, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s3/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f5c6ef1ca4ed73ea6e828967a981270b3e6c8670 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [0, 4, 8, 5, 1, 7, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc51423b5eae6da8256f520b93ce611a82552cbf --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 1], [9, 6], [0, 9], [4, 2], [5, 7], [9, 8], [5, 3], [6, 3], [7, 8]], "k": 7, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s4/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s4/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..72c3b491f6e4796827b1e024fa7b6f71cd60eccd --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"points": [[6, 2], [4, 3], [6, 8], [1, 8], [5, 1], [4, 5], [3, 3], [9, 7], [8, 5]], "k": 7, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s4/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..45bee877de940bc09e64ec4cdec1f74940d39074 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1, 5, 2, 7, 8, 0, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..72c3b491f6e4796827b1e024fa7b6f71cd60eccd --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"points": [[6, 2], [4, 3], [6, 8], [1, 8], [5, 1], [4, 5], [3, 3], [9, 7], [8, 5]], "k": 7, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l2-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-convex-polygon-l6-s2/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l6-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-largest-convex-polygon-l6-s2/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f0235ecb335d8ea4ed22e6502887a2f04f3175d3 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"points": [[25, 35], [26, 24], [14, 1], [31, 32], [34, 31], [1, 0], [19, 12], [2, 5], [20, 1], [23, 9], [31, 16], [18, 25], [21, 33], [8, 5], [0, 7], [30, 14], [9, 19], [10, 8], [0, 19], [17, 29], [1, 20], [28, 32], [26, 10], [25, 18], [18, 6], [35, 22], [29, 24], [3, 14], [8, 7], [32, 4], [24, 6], [19, 25], [33, 21], [30, 31], [2, 30]], "k": 14, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l6-s2/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8807d02b0e20b9014a8a7c62d99cff0f7cbc3102 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l6-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [14, 18, 20, 19, 21, 3, 4, 32, 10, 15, 22, 9, 13, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f0235ecb335d8ea4ed22e6502887a2f04f3175d3 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"points": [[25, 35], [26, 24], [14, 1], [31, 32], [34, 31], [1, 0], [19, 12], [2, 5], [20, 1], [23, 9], [31, 16], [18, 25], [21, 33], [8, 5], [0, 7], [30, 14], [9, 19], [10, 8], [0, 19], [17, 29], [1, 20], [28, 32], [26, 10], [25, 18], [18, 6], [35, 22], [29, 24], [3, 14], [8, 7], [32, 4], [24, 6], [19, 25], [33, 21], [30, 31], [2, 30]], "k": 14, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l6-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-rectangle-l4-s2/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l4-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-largest-rectangle-l4-s2/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..90a94eb4a4d6fd47393d3b685d18ca17822d7b0b --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-25, 20], [1, -6], [4, -5], [-7, 6], [22, -7], [25, -5], [-7, -13], [-1, -5], [14, 13], [-19, 4], [-8, -9], [-11, 12], [20, 22], [-9, 11], [16, 5], [-20, -22], [9, 4], [5, 0], [-23, 18], [5, 4], [24, 3], [-14, 17], [24, -21], [7, -1], [9, 0]], "area": 16, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l4-s2/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..96c901b6e71207ead64d9d24406d915ab2efc8b1 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l4-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [16, 19, 17, 24]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l4-s2/tests/check.py b/tasks/construct-rlve-largest-rectangle-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l4-s2/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid, int_list + + +def check(inst, ans): + P = inst["points"] + idx = int_list(ans.get("indices"), 4, 0, len(P) - 1, "indices") + if len(set(idx)) != 4: + raise Invalid("indices must be distinct") + A, *rest = [tuple(P[i]) for i in idx] + if len(set([A] + rest)) != 4: + raise Invalid("points must be distinct") + # the vertex farthest from A is opposite; the other two are A's neighbours + rest.sort(key=lambda X: (X[0] - A[0]) ** 2 + (X[1] - A[1]) ** 2) + B, D, C = rest + u = (B[0] - A[0], B[1] - A[1]) + v = (D[0] - A[0], D[1] - A[1]) + if u[0] * v[0] + u[1] * v[1] != 0: + raise Invalid("not a rectangle (no right angle at the first vertex)") + if (B[0] + D[0] - A[0], B[1] + D[1] - A[1]) != C: + raise Invalid("not a rectangle") + area = abs(u[0] * v[1] - u[1] * v[0]) + if area < inst["area"]: + raise Invalid(f"area {area} < {inst['area']}") + return None, {"area": area} diff --git a/tasks/construct-rlve-largest-rectangle-l4-s2/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..90a94eb4a4d6fd47393d3b685d18ca17822d7b0b --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-25, 20], [1, -6], [4, -5], [-7, 6], [22, -7], [25, -5], [-7, -13], [-1, -5], [14, 13], [-19, 4], [-8, -9], [-11, 12], [20, 22], [-9, 11], [16, 5], [-20, -22], [9, 4], [5, 0], [-23, 18], [5, 4], [24, 3], [-14, 17], [24, -21], [7, -1], [9, 0]], "area": 16, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l4-s2/tests/run.py b/tasks/construct-rlve-largest-rectangle-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l4-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-largest-rectangle-l4-s2/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l4-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-max-achromatic-coloring-l2-s2/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-max-achromatic-coloring-l2-s2/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..10b001e552efe8beaad76b32a8d06b1e16346981 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "edges": [[0, 6], [0, 7], [1, 2], [1, 4], [1, 5], [1, 6], [2, 4], [2, 6], [2, 7], [3, 4], [3, 5], [4, 6], [4, 7], [5, 7]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l2-s2/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..758be8f66694ae0c0579f48642d36b062164dc07 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 0, 2, 3, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + if len(set(c)) != k: + raise Invalid(f"uses {len(set(c))} colours, need all {k}") + pairs = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pairs.add((min(c[u], c[v]), max(c[u], c[v]))) + if len(pairs) != k * (k - 1) // 2: + raise Invalid("some pair of colours is not joined by an edge") + return None, {} diff --git a/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..10b001e552efe8beaad76b32a8d06b1e16346981 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "edges": [[0, 6], [0, 7], [1, 2], [1, 4], [1, 5], [1, 6], [2, 4], [2, 6], [2, 7], [3, 4], [3, 5], [4, 6], [4, 7], [5, 7]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l3-s1/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-harmonious-coloring-l3-s1/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..40dbbc94ede8d28b9ca92e52fe463ae13b305193 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 4, "edges": [[2, 5], [3, 4], [3, 7], [4, 5], [4, 9], [5, 8]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l3-s1/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e99936ec1772394a77e2c3cbd3091749a103a9a1 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 0, 0, 1, 2, 0, 3, 3, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..40dbbc94ede8d28b9ca92e52fe463ae13b305193 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 4, "edges": [[2, 5], [3, 4], [3, 7], [4, 5], [4, 9], [5, 8]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ce4b18e80b1d4d2c5acf47aa79398568e727eee --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 3, "sums": [5, 7, 4], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2eedfc48b7117196f68c3763e26bc88fd98dc7fb --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [1, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ce4b18e80b1d4d2c5acf47aa79398568e727eee --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 3, "sums": [5, 7, 4], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..000b43dd9fca7b682c51ea4be0e4d4f1caba2873 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 3, "sums": [11, 8, 7], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e6e2331856fd9589c1b93bdcbee1aac0fb35ce3c --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [2, 5, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..000b43dd9fca7b682c51ea4be0e4d4f1caba2873 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 3, "sums": [11, 8, 7], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..63ce08a861287f728ac9f6991b918317ca924f3e --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 3, "sums": [5, 6, 3], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..680694ab1cf1aa9f0934ef3d740da266de1129d7 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [1, 2, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..63ce08a861287f728ac9f6991b918317ca924f3e --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 3, "sums": [5, 6, 3], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f0d0c34f6e06d05276060b7f826d1817d316fda --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "sums": [27, 36, 8, 14, 17, 32, 56, 52, 64, 10, 47, 25, 26, 24, 40, 45, 15, 5, 21, 33, 47, 56, 26, 37, 45, 35, 39, 33, 39, 33, 13, 49, 47, 9, 22, 50, 36, 61, 22, 44, 37, 11, 50, 54, 35, 36, 58, 29, 55, 35, 66, 41, 37, 27, 37, 54, 46, 30, 52, 17, 20, 54, 36, 35, 45, 16, 52, 27, 31, 59, 68, 38, 43, 15, 28, 16, 26, 25, 14, 34, 36, 43, 26, 43, 32, 42, 44, 21, 45, 19, 38, 31, 48, 25, 50, 47, 43, 46, 36, 28, 42, 25, 34, 7, 29, 26, 41, 38, 27, 30, 23, 6, 19, 45, 28, 34, 34, 31, 30, 24, 15, 59, 24, 4, 20, 57, 57, 48, 35, 21, 3, 53, 18, 40, 38, 38, 18, 16, 33, 57, 20, 49, 29, 48, 23, 23, 55, 39, 25, 5, 24, 40, 40], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..40d5005641c22ab03c880ef8f9843d58b1d61c7b --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [1, 2, 3, 4, 7, 12, 13, 14, 17, 19, 21, 22, 23, 24, 26, 31, 33, 35]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f0d0c34f6e06d05276060b7f826d1817d316fda --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "sums": [27, 36, 8, 14, 17, 32, 56, 52, 64, 10, 47, 25, 26, 24, 40, 45, 15, 5, 21, 33, 47, 56, 26, 37, 45, 35, 39, 33, 39, 33, 13, 49, 47, 9, 22, 50, 36, 61, 22, 44, 37, 11, 50, 54, 35, 36, 58, 29, 55, 35, 66, 41, 37, 27, 37, 54, 46, 30, 52, 17, 20, 54, 36, 35, 45, 16, 52, 27, 31, 59, 68, 38, 43, 15, 28, 16, 26, 25, 14, 34, 36, 43, 26, 43, 32, 42, 44, 21, 45, 19, 38, 31, 48, 25, 50, 47, 43, 46, 36, 28, 42, 25, 34, 7, 29, 26, 41, 38, 27, 30, 23, 6, 19, 45, 28, 34, 34, 31, 30, 24, 15, 59, 24, 4, 20, 57, 57, 48, 35, 21, 3, 53, 18, 40, 38, 38, 18, 16, 33, 57, 20, 49, 29, 48, 23, 23, 55, 39, 25, 5, 24, 40, 40], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1ceeb1c4a00faebdb14fcb75f018bcb21ce5c209 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "sums": [32, 19, 51, 32, 43, 30, 42, 28, 49, 21, 47, 53, 43, 49, 47, 31, 22, 41, 49, 15, 19, 22, 47, 65, 55, 39, 29, 28, 59, 50, 35, 60, 15, 48, 62, 14, 48, 25, 13, 44, 66, 31, 31, 42, 64, 45, 64, 36, 34, 35, 29, 57, 30, 41, 37, 38, 32, 25, 41, 51, 18, 52, 9, 36, 48, 26, 25, 26, 38, 63, 59, 58, 20, 29, 40, 44, 63, 37, 54, 24, 37, 50, 7, 31, 12, 35, 58, 42, 34, 38, 44, 40, 50, 41, 33, 27, 43, 54, 42, 34, 36, 10, 33, 8, 31, 44, 35, 38, 16, 52, 22, 47, 40, 40, 37, 35, 51, 25, 29, 23, 51, 24, 53, 28, 41, 34, 57, 47, 30, 38, 45, 14, 57, 70, 61, 45, 44, 36, 3, 17, 46, 57, 56, 53, 37, 23, 55, 19, 27, 56, 30, 21, 50], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..825c8a575f59082b09653f739335161297513b5b --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [1, 2, 6, 8, 11, 13, 14, 17, 20, 21, 23, 24, 27, 28, 29, 30, 34, 36]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1ceeb1c4a00faebdb14fcb75f018bcb21ce5c209 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "sums": [32, 19, 51, 32, 43, 30, 42, 28, 49, 21, 47, 53, 43, 49, 47, 31, 22, 41, 49, 15, 19, 22, 47, 65, 55, 39, 29, 28, 59, 50, 35, 60, 15, 48, 62, 14, 48, 25, 13, 44, 66, 31, 31, 42, 64, 45, 64, 36, 34, 35, 29, 57, 30, 41, 37, 38, 32, 25, 41, 51, 18, 52, 9, 36, 48, 26, 25, 26, 38, 63, 59, 58, 20, 29, 40, 44, 63, 37, 54, 24, 37, 50, 7, 31, 12, 35, 58, 42, 34, 38, 44, 40, 50, 41, 33, 27, 43, 54, 42, 34, 36, 10, 33, 8, 31, 44, 35, 38, 16, 52, 22, 47, 40, 40, 37, 35, 51, 25, 29, 23, 51, 24, 53, 28, 41, 34, 57, 47, 30, 38, 45, 14, 57, 70, 61, 45, 44, 36, 3, 17, 46, 57, 56, 53, 37, 23, 55, 19, 27, 56, 30, 21, 50], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l5-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s0/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s0/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0895f9554d76279662634004cdb56830e2ed5bd --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [2, 4, 2], "fmin": "0", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s0/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..587fa712d6f4b33e8db46fca5bf29f5627f2be44 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x0": -1.0} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0895f9554d76279662634004cdb56830e2ed5bd --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [2, 4, 2], "fmin": "0", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s9/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s9/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..af1e915380e4fc267f631eb0e20aa6b90a36049d --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [0, 0, 2], "fmin": "0", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s9/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..48ffae347b6a0545978b9cdd566b602d31a7dd61 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x0": 0.0} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..af1e915380e4fc267f631eb0e20aa6b90a36049d --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [0, 0, 2], "fmin": "0", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-global-minimum-l5-s1/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-global-minimum-l5-s1/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ecbad3cb7e818d9192a27842d4270aa171bfe9c0 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [1029, -5118, 11549, -15348, 13457, -8058, 3361, -960, 182, -20, 1], "fmin": "43.7499870326427411535594836745528629069513310", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l5-s1/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..29855357e240e4ea2c6772434c302651c4622344 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x0": 0.7132231041589705} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ecbad3cb7e818d9192a27842d4270aa171bfe9c0 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [1029, -5118, 11549, -15348, 13457, -8058, 3361, -960, 182, -20, 1], "fmin": "43.7499870326427411535594836745528629069513310", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s3/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s3/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..07b23e2b5804b55a9b7b946990af9145a1e97efa --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [-288, 48, 82, -19, -4, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s3/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..88fa92881322a73d89ce0e15a48ab616ed76cafb --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"roots": [-4, -2, 3, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..07b23e2b5804b55a9b7b946990af9145a1e97efa --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [-288, 48, 82, -19, -4, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s4/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s4/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e8411020a6ba1331ce723b83916628dc36712291 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [0, 12, 31, 27, 9, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s4/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..597e76daeab37e46179a022c18f8633ce0dd1407 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"roots": [-4, -3, -1, -1, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e8411020a6ba1331ce723b83916628dc36712291 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [0, 12, 31, 27, 9, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l2-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-interpolation-l1-s5/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l1-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-interpolation-l1-s5/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4984e010c5e55582d31ed3b82cb7ae19cdec9fb3 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"X": [1, 0, -1], "Y": [-5, -5, -1], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l1-s5/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..02501d04623fce44bb9b40fa964ad5f19aff4f8b --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l1-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coeffs": [-5, -2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4984e010c5e55582d31ed3b82cb7ae19cdec9fb3 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"X": [1, 0, -1], "Y": [-5, -5, -1], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l1-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-interpolation-l5-s4/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l5-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-interpolation-l5-s4/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9512c9bf340d499bea15fa6b918c40f1a9235fef --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"X": [-2, 11, -6, -4, -8, 7, -3, 12, 5, -11, 13, 1, -5, -9], "Y": [-4890, 77507000033071, -18783042518, -76610024, -872363813076, 228330928599, -1391201, 238271298958024, 2992044079, -58886086900593, 669744205842495, -9, -1609355121, -4157621775689], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l5-s4/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e5474b2b8792941ca513eeb1361954ce5bead6c5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coeffs": [4, -5, 4, -3, 1, -1, -4, -1, -5, 3, -4, -3, 3, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9512c9bf340d499bea15fa6b918c40f1a9235fef --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"X": [-2, 11, -6, -4, -8, 7, -3, 12, 5, -11, 13, 1, -5, -9], "Y": [-4890, 77507000033071, -18783042518, -76610024, -872363813076, 228330928599, -1391201, 238271298958024, 2992044079, -58886086900593, 669744205842495, -9, -1609355121, -4157621775689], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l5-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s0/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s0/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..316ad0d82868c5435595a4e6eff9e60e815fc6b3 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 3, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s0/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bd4797073caf713e347298ffdb964f51e79c360e --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..316ad0d82868c5435595a4e6eff9e60e815fc6b3 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 3, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s7/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s7/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e3c4a72f7f982f656ea99a998a98b15f7fa93b7f --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 19, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s7/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..09d40570890af35dfd2f06beb38aded00386482a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [1, 2, 11, 14, 6, 5, 17, 12, 13, 18, 3, 8, 9, 4, 16, 15, 7, 10, 19]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e3c4a72f7f982f656ea99a998a98b15f7fa93b7f --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 19, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l1-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s3/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s3/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f8e378c67601b10357b4810067c10c5b5c50050 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"n1": 7, "n2": 12, "edges1": [[1, 4], [1, 2], [2, 6]], "edges2": [[2, 7], [1, 11], [0, 5], [4, 6], [1, 3], [1, 10], [2, 8], [5, 7], [8, 11], [0, 2], [6, 11], [6, 10], [7, 9], [3, 5], [5, 11], [7, 8]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s3/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8e3b6c7496e579664539ae66f09ba89aca03de6f --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [11, 2, 7, 3, 0, 10, 9]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f8e378c67601b10357b4810067c10c5b5c50050 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"n1": 7, "n2": 12, "edges1": [[1, 4], [1, 2], [2, 6]], "edges2": [[2, 7], [1, 11], [0, 5], [4, 6], [1, 3], [1, 10], [2, 8], [5, 7], [8, 11], [0, 2], [6, 11], [6, 10], [7, 9], [3, 5], [5, 11], [7, 8]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s4/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s4/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d63e78f0527bc01f8d2e53b187b8fb6cf171ca5f --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"n1": 11, "n2": 12, "edges1": [[2, 9], [3, 4], [3, 5], [9, 10], [1, 5], [0, 8], [1, 2], [7, 8], [2, 4], [0, 2], [7, 9], [1, 9], [2, 8], [8, 9], [4, 10], [7, 10], [4, 5], [5, 9], [1, 10], [3, 10], [6, 9], [6, 10], [6, 7], [0, 6], [4, 7], [1, 7], [5, 7], [3, 8], [0, 3], [0, 10], [5, 6], [1, 3], [0, 7], [0, 9], [0, 1], [1, 4], [3, 9], [4, 8], [2, 6], [8, 10], [2, 3]], "edges2": [[8, 9], [2, 4], [0, 5], [3, 10], [8, 10], [1, 7], [0, 3], [2, 9], [6, 9], [7, 8], [2, 11], [4, 7], [0, 6], [9, 11], [1, 3], [2, 7], [2, 3], [3, 9], [1, 10], [4, 11], [2, 8], [4, 10], [1, 11], [1, 2], [5, 6], [7, 9], [0, 4], [5, 8], [0, 1], [4, 6], [3, 6], [1, 6], [6, 11], [3, 4], [4, 9], [0, 2], [10, 11], [0, 8], [3, 11], [4, 5], [5, 11], [9, 10], [2, 5], [5, 10], [0, 7], [1, 9], [5, 9], [6, 7], [7, 11]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s4/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c84fe42127439418280855b410a1c51ff3266a2 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [11, 2, 1, 7, 0, 8, 10, 5, 6, 9, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d63e78f0527bc01f8d2e53b187b8fb6cf171ca5f --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"n1": 11, "n2": 12, "edges1": [[2, 9], [3, 4], [3, 5], [9, 10], [1, 5], [0, 8], [1, 2], [7, 8], [2, 4], [0, 2], [7, 9], [1, 9], [2, 8], [8, 9], [4, 10], [7, 10], [4, 5], [5, 9], [1, 10], [3, 10], [6, 9], [6, 10], [6, 7], [0, 6], [4, 7], [1, 7], [5, 7], [3, 8], [0, 3], [0, 10], [5, 6], [1, 3], [0, 7], [0, 9], [0, 1], [1, 4], [3, 9], [4, 8], [2, 6], [8, 10], [2, 3]], "edges2": [[8, 9], [2, 4], [0, 5], [3, 10], [8, 10], [1, 7], [0, 3], [2, 9], [6, 9], [7, 8], [2, 11], [4, 7], [0, 6], [9, 11], [1, 3], [2, 7], [2, 3], [3, 9], [1, 10], [4, 11], [2, 8], [4, 10], [1, 11], [1, 2], [5, 6], [7, 9], [0, 4], [5, 8], [0, 1], [4, 6], [3, 6], [1, 6], [6, 11], [3, 4], [4, 9], [0, 2], [10, 11], [0, 8], [3, 11], [4, 5], [5, 11], [9, 10], [2, 5], [5, 10], [0, 7], [1, 9], [5, 9], [6, 7], [7, 11]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p11/environment/Dockerfile b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p11/environment/instance.json b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..50a16cd5716984f756cfdecd14f6df24b537e7b9 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/environment/instance.json @@ -0,0 +1 @@ +{"p": 11, "d": 3, "direction": "minimize", "family": "ae_p1_ff_kakeya", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p11/solution/solve.sh b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..48317f2729945747ade7ee63ded00a8efd2cfbed --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3], [0, 0, 4], [0, 0, 5], [0, 0, 6], [0, 0, 7], [0, 0, 8], [0, 0, 9], [0, 0, 10], [0, 1, 0], [0, 1, 2], [0, 1, 3], [0, 1, 5], [0, 1, 7], [0, 1, 9], [0, 1, 10], [0, 2, 2], [0, 2, 3], [0, 2, 4], [0, 2, 6], [0, 2, 7], [0, 2, 9], [0, 3, 1], [0, 3, 2], [0, 3, 4], [0, 3, 5], [0, 3, 8], [0, 3, 9], [0, 3, 10], [0, 4, 1], [0, 4, 5], [0, 4, 6], [0, 4, 7], [0, 4, 9], [0, 4, 10], [0, 5, 0], [0, 5, 4], [0, 5, 5], [0, 5, 6], [0, 5, 8], [0, 5, 9], [0, 5, 10], [0, 6, 0], [0, 6, 1], [0, 6, 5], [0, 6, 6], [0, 6, 7], [0, 6, 9], [0, 6, 10], [0, 7, 1], [0, 7, 2], [0, 7, 4], [0, 7, 8], [0, 7, 9], [0, 7, 10], [0, 8, 1], [0, 8, 2], [0, 8, 3], [0, 8, 4], [0, 8, 6], [0, 8, 7], [0, 8, 9], [0, 9, 0], [0, 9, 2], [0, 9, 3], [0, 9, 5], [0, 9, 8], [0, 9, 9], [0, 9, 10], [0, 10, 0], [0, 10, 1], [0, 10, 3], [0, 10, 5], [0, 10, 7], [0, 10, 8], [0, 10, 9], [1, 0, 0], [1, 0, 3], [1, 0, 8], [1, 1, 0], [1, 2, 1], [1, 2, 5], [1, 2, 6], [1, 2, 10], [1, 3, 0], [1, 3, 5], [1, 3, 6], [1, 4, 3], [1, 4, 4], [1, 4, 7], [1, 4, 8], [1, 5, 2], [1, 5, 4], [1, 5, 7], [1, 5, 9], [1, 6, 3], [1, 6, 5], [1, 6, 6], [1, 6, 8], [1, 7, 0], [1, 7, 4], [1, 7, 7], [1, 8, 0], [1, 8, 1], [1, 8, 10], [1, 9, 0], [1, 9, 2], [1, 9, 9], [1, 10, 1], [1, 10, 2], [1, 10, 9], [1, 10, 10], [2, 0, 6], [2, 1, 0], [2, 1, 1], [2, 1, 5], [2, 1, 7], [2, 2, 0], [2, 2, 1], [2, 2, 6], [2, 3, 2], [2, 3, 3], [2, 3, 9], [2, 3, 10], [2, 4, 2], [2, 4, 4], [2, 4, 8], [2, 4, 10], [2, 5, 0], [2, 5, 1], [2, 5, 3], [2, 5, 9], [2, 6, 2], [2, 6, 6], [2, 6, 10], [2, 7, 5], [2, 7, 6], [2, 7, 7], [2, 8, 4], [2, 8, 6], [2, 8, 8], [2, 9, 4], [2, 9, 5], [2, 9, 7], [2, 9, 8], [2, 10, 3], [2, 10, 6], [2, 10, 9], [3, 0, 1], [3, 0, 4], [3, 0, 9], [3, 1, 1], [3, 2, 0], [3, 2, 2], [3, 2, 6], [3, 2, 7], [3, 3, 1], [3, 3, 6], [3, 3, 7], [3, 4, 4], [3, 4, 5], [3, 4, 8], [3, 4, 9], [3, 5, 3], [3, 5, 5], [3, 5, 8], [3, 5, 10], [3, 6, 4], [3, 6, 6], [3, 6, 7], [3, 6, 9], [3, 7, 1], [3, 7, 5], [3, 7, 8], [3, 8, 0], [3, 8, 1], [3, 8, 2], [3, 9, 1], [3, 9, 3], [3, 9, 10], [3, 10, 0], [3, 10, 2], [3, 10, 3], [3, 10, 10], [4, 0, 6], [4, 0, 7], [4, 0, 8], [4, 1, 5], [4, 1, 7], [4, 1, 9], [4, 2, 5], [4, 2, 6], [4, 2, 8], [4, 2, 9], [4, 3, 4], [4, 3, 7], [4, 3, 10], [4, 4, 7], [4, 5, 1], [4, 5, 2], [4, 5, 6], [4, 5, 8], [4, 6, 1], [4, 6, 2], [4, 6, 7], [4, 7, 0], [4, 7, 3], [4, 7, 4], [4, 7, 10], [4, 8, 0], [4, 8, 3], [4, 8, 5], [4, 8, 9], [4, 9, 1], [4, 9, 2], [4, 9, 4], [4, 9, 10], [4, 10, 0], [4, 10, 3], [4, 10, 7], [5, 0, 2], [5, 0, 7], [5, 0, 8], [5, 1, 5], [5, 1, 6], [5, 1, 9], [5, 1, 10], [5, 2, 0], [5, 2, 4], [5, 2, 6], [5, 2, 9], [5, 3, 5], [5, 3, 7], [5, 3, 8], [5, 3, 10], [5, 4, 2], [5, 4, 6], [5, 4, 9], [5, 5, 1], [5, 5, 2], [5, 5, 3], [5, 6, 0], [5, 6, 2], [5, 6, 4], [5, 7, 0], [5, 7, 1], [5, 7, 3], [5, 7, 4], [5, 8, 2], [5, 8, 5], [5, 8, 10], [5, 9, 2], [5, 10, 1], [5, 10, 3], [5, 10, 7], [5, 10, 8], [6, 0, 1], [6, 0, 4], [6, 0, 8], [6, 1, 7], [6, 1, 8], [6, 1, 9], [6, 2, 6], [6, 2, 8], [6, 2, 10], [6, 3, 6], [6, 3, 7], [6, 3, 9], [6, 3, 10], [6, 4, 0], [6, 4, 5], [6, 4, 8], [6, 5, 8], [6, 6, 2], [6, 6, 3], [6, 6, 7], [6, 6, 9], [6, 7, 2], [6, 7, 3], [6, 7, 8], [6, 8, 0], [6, 8, 1], [6, 8, 4], [6, 8, 5], [6, 9, 1], [6, 9, 4], [6, 9, 6], [6, 9, 10], [6, 10, 0], [6, 10, 2], [6, 10, 3], [6, 10, 5], [7, 0, 1], [7, 0, 3], [7, 0, 5], [7, 1, 1], [7, 1, 2], [7, 1, 4], [7, 1, 5], [7, 2, 0], [7, 2, 3], [7, 2, 6], [7, 3, 3], [7, 4, 2], [7, 4, 4], [7, 4, 8], [7, 4, 9], [7, 5, 3], [7, 5, 8], [7, 5, 9], [7, 6, 0], [7, 6, 6], [7, 6, 7], [7, 6, 10], [7, 7, 1], [7, 7, 5], [7, 7, 7], [7, 7, 10], [7, 8, 0], [7, 8, 6], [7, 8, 8], [7, 8, 9], [7, 9, 3], [7, 9, 7], [7, 9, 10], [7, 10, 2], [7, 10, 3], [7, 10, 4], [8, 0, 0], [8, 0, 7], [8, 0, 9], [8, 1, 0], [8, 1, 7], [8, 1, 8], [8, 1, 10], [8, 2, 1], [8, 2, 6], [8, 2, 9], [8, 3, 9], [8, 4, 3], [8, 4, 4], [8, 4, 8], [8, 4, 10], [8, 5, 3], [8, 5, 4], [8, 5, 9], [8, 6, 1], [8, 6, 2], [8, 6, 5], [8, 6, 6], [8, 7, 0], [8, 7, 2], [8, 7, 5], [8, 7, 7], [8, 8, 1], [8, 8, 3], [8, 8, 4], [8, 8, 6], [8, 9, 2], [8, 9, 5], [8, 9, 9], [8, 10, 8], [8, 10, 9], [8, 10, 10], [9, 0, 0], [9, 0, 4], [9, 0, 8], [9, 1, 3], [9, 1, 4], [9, 1, 5], [9, 2, 2], [9, 2, 4], [9, 2, 6], [9, 3, 2], [9, 3, 3], [9, 3, 5], [9, 3, 6], [9, 4, 1], [9, 4, 4], [9, 4, 7], [9, 5, 4], [9, 6, 3], [9, 6, 5], [9, 6, 9], [9, 6, 10], [9, 7, 4], [9, 7, 9], [9, 7, 10], [9, 8, 0], [9, 8, 1], [9, 8, 7], [9, 8, 8], [9, 9, 0], [9, 9, 2], [9, 9, 6], [9, 9, 8], [9, 10, 1], [9, 10, 7], [9, 10, 9], [9, 10, 10], [10, 0, 4], [10, 0, 5], [10, 0, 10], [10, 1, 2], [10, 1, 3], [10, 1, 6], [10, 1, 7], [10, 2, 1], [10, 2, 3], [10, 2, 6], [10, 2, 8], [10, 3, 2], [10, 3, 4], [10, 3, 5], [10, 3, 7], [10, 4, 3], [10, 4, 6], [10, 4, 10], [10, 5, 0], [10, 5, 9], [10, 5, 10], [10, 6, 1], [10, 6, 8], [10, 6, 10], [10, 7, 0], [10, 7, 1], [10, 7, 8], [10, 7, 9], [10, 8, 2], [10, 8, 7], [10, 8, 10], [10, 9, 10], [10, 10, 0], [10, 10, 4], [10, 10, 5], [10, 10, 9]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/check.py b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..dac5049b59a505ff843bc5e086d0c1c303695b2a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/check.py @@ -0,0 +1,32 @@ +"""Finite-field Kakeya set in F_p^d: every direction contains a full line. Score = |K| (minimize). + +Upstream (AlphaEvolve notebook `finite_field_kakeya.ipynb`) silently deduplicated points and only checked +d in {3, 4}; here duplicates, out-of-range or non-integer coordinates are rejected and every projective +direction (first non-zero coordinate = 1) is checked for any d. +""" +import itertools + +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + p, d = inst["p"], inst["d"] + pts = ans.get("points") + if not isinstance(pts, list) or not pts: + raise Invalid("points must be a non-empty list") + if len(pts) > p ** d: + raise Invalid("more points than the whole space") + K = np.array([int_list(x, d, 0, p - 1, "point") for x in pts], dtype=np.int64) + w = p ** np.arange(d - 1, -1, -1, dtype=np.int64) + codes = K @ w + if len(np.unique(codes)) != len(codes): + raise Invalid("duplicate points") + for i in range(d): # directions v = (0,..,0,1,*,..,*) with the 1 in position i + for tail in itertools.product(range(p), repeat=d - 1 - i): + v = np.array([0] * i + [1] + list(tail), dtype=np.int64) + base = (K - K[:, i:i + 1] * v) % p # canonical point of the line through x with direction v + if np.bincount(base @ w, minlength=p ** d).max() < p: + raise Invalid(f"no full line in direction {v.tolist()}") + return len(pts), {"size": len(pts)} diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/instance.json b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1ea95025b667dde8a7a6ba6adb1207d2a060685d --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/instance.json @@ -0,0 +1 @@ +{"p": 11, "d": 3, "direction": "minimize", "best_known": 438, "baseline": 1331, "family": "ae_p1_ff_kakeya", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/run.py b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/test.sh b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p11/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ea-kissing-d11-n594/environment/Dockerfile b/tasks/optimize-ea-kissing-d11-n594/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n594/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ea-kissing-d11-n594/environment/instance.json b/tasks/optimize-ea-kissing-d11-n594/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..649f1edf02bad42774a9ae537b51f0f4b738bd0a --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n594/environment/instance.json @@ -0,0 +1 @@ +{"dim": 11, "n": 594, "direction": "minimize", "progress_scale": "log", "log_floor": 0.001, "family": "ea_kissing_number", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-kissing-d11-n594/solution/solve.sh b/tasks/optimize-ea-kissing-d11-n594/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..77d0f0630d695b412480d3a6c50d69584b59dab8 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n594/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"vectors": [[-0.0012796143172260348, -0.43097946236159174, 0.040719204738478995, 0.03274945702596552, -0.021560319234006618, 0.6326840110056644, -0.5625549190405538, -0.1265042640276578, 0.021812675970412376, 0.2759126246055087, -0.041178208902289404], [0.5021579734609095, -0.3680257406117832, -0.285682074949256, 0.1377329940524021, -0.10392797475405148, 0.24376680830367692, -0.33313517919850255, -0.46160124564700633, 0.18241031006467834, -0.2330163807334923, -0.1730942086300843], [-0.0024567882483350002, 0.6065006359447115, 0.3331645187880122, -0.3821454411294956, -0.20517048589304554, 0.07517338672220683, -0.19160130946478396, -0.31619176807346927, -0.026086049598889438, 0.2721361266253117, 0.3405060826147371], [-0.3899388049355217, -0.05219897300929178, 0.45691118043701134, 0.4479174355082373, 0.2689213776253298, -0.07998773525537979, -0.0740856683769688, 0.29264754312737007, 0.025835767614177125, 0.04840267864455735, 0.5128029033662868], [0.18984062675499758, 0.2598688860200382, -0.6067426110658066, -0.07926058646400609, -0.10874143819383854, -0.24393973866575522, 0.027202726851561932, 0.007141717133268652, -0.3119082998578554, -0.18303461089214365, 0.5648885877809832], [0.29227059239126363, -0.826045489399456, 0.021597757314462642, -0.04260998841781152, -0.29536827549348665, 0.09247796716598748, -0.12024149697961614, -0.042763045690612844, 0.10351715684288164, 0.06487782858015091, 0.3208402302988156], [0.4079453053932998, 0.014767179275908801, 0.780303955621878, 0.2623581888119741, 0.21072441354177082, 0.1436844171094798, 0.07340659206260494, 0.10793440796505684, -0.10784704990749704, -0.23761490003931493, -0.07400199031026182], [-0.3971377338298424, -0.06643152279027353, -0.11883440689036302, -0.20947076512966778, -0.3276349028841237, 0.3858542764791487, -0.13524046625944325, -0.3964693869437415, -0.09771637680451671, 0.444731834368276, 0.3752703690462936], [0.3745591955776854, -0.09329889760476055, -0.2921745856160785, 0.04330776679758007, -0.3087038166407341, 0.6406452175611732, 0.29183570343360815, 0.06265212125868609, 0.33046663310762175, -0.12710498810803328, -0.20875246748295279], [-0.546791182247656, -0.12195828253189141, -0.3826382362886259, -0.06740324776341189, -0.06375044425457695, 0.02119367330622293, 0.003018258762791444, -0.4025967318851652, -0.45456754028856117, -0.28185414565782696, 0.28724627971310257], [0.613094199057025, 0.27785267901697713, 0.1774861779104015, -0.3400709266872094, -0.22983368797581036, -0.09393837125683217, -0.09916643611247154, -0.016319488798624895, -0.23010450167423774, 0.4907594826609746, -0.18499354669098841], [0.545948541796591, 0.12164645124892066, 0.38321776549058556, 0.06688474579423509, 0.06387634303812346, -0.021264170323818644, -0.00291884282302308, 0.4022005625446777, 0.4558063551723749, 0.28119819160923776, -0.28753240674255726], [0.11616569102878939, -0.042497919340331, -0.10032001317497796, 0.20775169453595116, 0.47844177768770707, 0.4582841138093052, 0.011790548718181212, -0.2832402129310564, 0.2524463392104055, 0.5807307631366649, -0.1058409899437445], [0.24702359022895887, -0.4438729784376344, 0.12320743892424041, -0.7042825189917222, -0.27884528534116754, -0.15172062951166224, 0.041698284453442896, 0.21901309026957688, -0.2675912737602186, -0.08976376001132565, 0.024904612093212142], [0.1533784758044706, 0.1659068211259319, -0.307569869578294, -0.4422696350222123, 0.05850327915312414, 0.011634601589001913, -0.20942155082742814, -0.5111038820547465, 0.17768876726337585, 0.5640726835290156, -0.018827187397275125], [-0.2156340433055088, -0.35113384557698957, -0.25786801613050236, -0.48678701059614926, 0.13244861076932138, -0.5048497209661864, 0.1424565135319863, -0.1030408345153271, -0.24381011195369126, 0.1282369615620523, 0.38410185934021984], [-0.16109058404337975, 0.013397812031282035, 0.038662296132740234, 0.46297389681064705, -0.0880435564011917, 0.37050813766374713, -0.4245399572499453, -0.25385323392854914, 0.15585662563324837, 0.008435061276551274, 0.5864850334884327], [-0.09420456789053215, -0.42241341107777264, -0.07522249263142836, 0.13253712726954053, 0.14275156039967493, 0.5092801479672266, -0.08530767308865696, 0.44385016208441, 0.15914312092505542, 0.08388600544540288, 0.5225704341044158], [0.12492600179505929, -0.32279522530419585, 0.4509962562903883, 0.013503681166892887, 0.6567042128866393, 0.26371707142480344, -0.25418304076730447, 0.07176036759995066, -0.050981548760632565, 0.23769593494282434, 0.21668549246594032], [-0.2819880432557585, 0.3993928099067587, -0.5403807518604711, 0.07012645616358314, 0.029131347366619174, 0.41385480502895367, 0.12932003394839864, -0.246332780824931, 0.12111751041589501, -0.04659423165963367, 0.4446016544420622], [0.2992650068391946, -0.04219028068813363, -0.09892784136123958, 0.23541045089478554, 0.20517696544937541, -0.1990622296628764, 0.10907588162632066, -0.8014546091607546, 0.09471694485554064, 0.2075045564730129, -0.23553301293732928], [-0.0028598607141394096, -0.14584474851324045, -0.26011271651954176, 0.7494139802668642, -0.03332935066975616, -0.20674972444239945, -0.15784121071052257, -0.35313919977046426, -0.06784689005710906, -0.2962719912396246, -0.252157612900204], [-0.4627444398654398, -0.4610506846036249, -0.21257847450670905, -0.3719718178577695, -0.1339441288851235, -0.1338033576258343, -0.25798959594207976, 0.4234463554407113, -0.21265251837115365, 0.21876749253260644, -0.12229915540353425], [-0.4886352397887943, -0.21854624211124074, -0.334918924095199, 0.2994339866053577, -0.40721690968279406, -0.07247650148700703, -0.11933540516430766, 0.22240667078776497, -0.31156573639454455, -0.3384274320708541, -0.2554433178514639], [0.36277467021787, 0.1522307247317126, -0.5151669980427717, -0.5110958815942701, 0.1872363836057403, -0.0935698449853642, -0.13604797426404192, 0.3572637439698018, -0.26829352981829924, 0.23798392719224348, -0.005227619317780799], [0.014754822451494839, -0.14446972284886292, -0.1789911833206974, 0.37482407622528524, -0.47573888217361615, -0.006759848899310205, 0.29363936133688584, -0.19174580241959766, -0.20514202081488198, -0.5772964944123856, 0.28576505133423796], [0.07526555903517536, 0.5342480186128303, 0.11369755110454523, 0.4279512777362297, -0.23576591836180913, -0.19200940647470732, 0.016814685243347588, -0.009707385030626873, -0.11103849121983352, -0.606145937793175, -0.2006791697034801], [-0.2841474795770836, 0.12010452505828106, -0.07357117005796188, 0.25385115299919014, 0.6475060773294514, 0.019994998940960258, -0.5880977088956649, -0.049187393448317816, -0.05553640961668968, -0.1054598794715181, 0.22985576771694782], [0.2475673965801852, 0.1878959508044948, 0.22633008315499067, 0.0045011895025821504, 0.364156777102137, -0.04247078980143986, -0.48095091447694693, -0.0502923048852945, -0.26931151339105447, -0.6203808094314545, -0.16279393187534383], [0.16642851341012913, 0.06138282351673982, 0.5088345764011485, 0.3877283151492128, -0.10137120900296363, -0.6728861013934548, 0.0034387533790439166, 0.13898802636849272, -0.05138434226858086, -0.1867253692118809, 0.1984937991271266], [0.1213876983418183, 0.13913002677317612, -0.3639451282890405, -0.42162782157188794, 0.14804361832026885, 0.48105141752541003, 0.13424317603492028, 0.3784475642816174, 0.233827100331956, -0.3070541635065636, 0.30356753018896415], [0.23294084513574578, 0.07870642083754976, 0.15975905908170157, 0.6703908990669064, 0.23994680421103745, -0.015605775069557907, -0.2888864000902409, 0.1412112875046769, 0.2582378735088689, -0.4388183827284833, 0.21008233195278092], [-0.2651001856150643, -0.1906074466962405, 0.45738343182885016, -0.06444915493754096, -0.18311393572636897, -0.1557555821227282, 0.40292287558685086, -0.15871617468143695, 0.05880694191416251, -0.2185249216797137, -0.6192720041778104], [-0.2888833797406465, -0.293698123597949, 0.058574380532453514, -0.03205816355607492, 0.18360462257132262, 0.46160386666322, 0.5115697832914389, 0.07826582117469372, -0.15410962257970356, 0.44245104710330424, -0.3028175147772251], [0.3957659285790607, 0.6731920300207446, 0.45124831168653295, -0.17184807476537783, 0.12207821525768202, -0.31108534829511303, -0.05617744399050594, 0.08100002356561276, 0.0697338376328481, -0.17191812511855029, -0.034817774790735306], [-0.018195676886895905, 0.033172460929117895, -0.4906235456847768, 0.3626015352459991, 0.16047575486204235, 0.22662030826357218, -0.4035063835260326, -0.4347687503528554, -0.3521943560304535, 0.2701864740337161, 0.01962328258315248], [0.26174594951771774, -0.3343433311962284, 0.1292814861006911, 0.0779263272904282, 0.6344164367466798, -0.1044029628075923, 0.27338894156927124, 0.1462284270672147, 0.07109105315331135, 0.292311508213699, -0.44374425503594905], [0.05195160890181187, -0.12795123297797284, 0.21355773241313983, -0.45752518796602754, 0.28098493462858826, -0.5951033160128198, 0.022826473874317663, -0.18740029398542465, 0.1163204446780416, -0.47186278706411083, -0.14514808175131366], [-0.3952198718746158, 0.3643910696873325, 0.3926017975925641, -0.22891533683962825, -0.06333093763508564, -0.12062071386584135, -0.14489533749767872, -0.10235870101495938, -0.3400530043649852, 0.4349907412237298, -0.38677755983112283], [-0.09932700618350063, -0.32023809175995976, 0.00442117702137612, -0.5455981124252554, 0.27076385575432144, 0.4824639828764238, -0.27585951609642306, 0.24316125954875054, -0.33956683367299817, -0.11221645014039822, 0.14379244070976588], [-0.17972505163976416, -0.2979335251698338, 0.019086098654407288, 0.00946391485428549, 0.17508863020610638, -0.6691297956587091, 0.17882254798214176, 0.5562184609974751, -0.22528901407875998, -0.08753534460472262, -0.017773779568692485], [0.14390188749188243, -0.4448959159479631, -0.6328396867035664, -0.06799137772041801, 0.265625216332482, -0.06384358024234511, -0.01701366387404157, -0.20090661762584805, 0.22189934196792377, 0.2829847100520458, -0.36283001267060844], [-0.3627273655489438, -0.35766454713742374, 0.012001858749886189, 0.17546346382647846, -0.5004320030288596, 0.05601615703241071, -0.3865469307776008, 0.21512731418117148, 0.3005082836616753, 0.34684299630021237, 0.22293468800329733], [0.10555824317972252, -0.15069782277874888, 0.1797809397413087, 0.1561734033053379, 0.12535799660409355, 0.26355227030462897, 0.2160579198780438, -0.09687431608531906, 0.25284596512477836, -0.7894741057857222, -0.28459756705201744], [-0.39631068257926366, 0.3642470497386871, -0.15927012084449885, -0.2423616322264076, -0.30607768546790987, -0.24716037232063476, 0.4274138461848012, -0.270243701260098, -0.11886369302436874, 0.1684623639588733, 0.416126902161634], [0.6939229297498213, 0.2812325031323131, -0.13459692756406674, 0.23357116934833905, 0.07755599835884877, -0.36250188572347974, 0.05302060340721861, 0.18743207857156258, 0.14255329819322346, 0.18602958129448202, 0.3693432769778218], [0.30300692520569744, 0.12272213260125274, -0.6964118574890268, -0.13168405537588046, -0.12254645537401727, -0.12882394160359603, 0.09664829123941145, 0.24406459658930926, 0.5271623946829556, -0.055335737502599285, -0.09649881025166705], [-0.09453599240763648, 0.11189233476466907, -0.038806573575622456, -0.5760090545473184, 0.29167438499656373, -0.15037465537003478, 0.28639111905906706, 0.37141395005362743, -0.36667609638011384, -0.3854094176941438, 0.18602207495944542], [0.13064163260703285, -0.5000288828933216, -0.5128779151205476, -0.18940476112610075, -0.09721607966909791, 0.3188882010380805, -0.3424116795451556, 0.359462391981119, 0.17593244316006895, -0.17476751514049785, -0.12202635533638728], [-0.16169092354703526, 0.44363194406802475, -0.0006639788135224385, 0.42901801873700435, -0.06627598660305456, -0.2625078364985004, 0.1382296430270537, -0.12825927680884577, 0.1369542825370164, -0.2689549426220057, 0.6269257201517263], [-0.055787815567169476, 0.015681930399192336, 0.1347420844687927, 0.14316182096388955, -0.028641061254760118, -0.2645575772500454, 0.3501577969996992, 0.03440625669449589, -0.7124360782619357, -0.13204697128028328, 0.48824604123468407], [-0.040281076515660624, -0.10543602614062168, 0.28418234717631863, -0.026921655710771406, 0.5476509494473223, 0.4192098046745478, 0.03054385203831129, 0.028395343183091906, -0.4248505791925795, -0.17717312361681406, -0.4652852047115873], [0.42118960869667577, 0.10204509706438361, -0.09794912545568406, -0.3226281423698277, 0.016526488685626985, 0.5194920332357882, 0.383040817871696, 0.2052854758798849, -0.47598856970857273, 0.05194702775403157, -0.10115363509065564], [0.1939454379757794, -0.10383228176275422, -0.13815810236743303, 0.2315624778056665, -0.04104172129528456, -0.33768555960984303, 0.6087467808381891, 0.4672667032511582, 0.3025228451520136, 0.21185818210354596, -0.19458788659114423], [-0.360115173839165, -0.22898772167634956, -0.515807531153032, 0.16006052808897583, -0.10456606722986476, -0.3179422681528127, 0.6136358525793124, 0.061446967679501176, -0.1417580440860681, -0.07633546924370486, 0.0890865782055266], [-0.21770412532374597, -0.048295813438276027, -0.1354117258042802, -0.07423530521499157, -0.18685894825530813, 0.4063285182772221, -0.23623802384995518, 0.04616821095467898, -0.7571087914356722, 0.21631606739622375, -0.2201358902792068], [-0.14089433552600678, -0.14769932317111933, 0.3778003970815086, 0.41014274092392533, -0.1462552516701879, -0.48471846157338844, -0.13071024143033996, -0.38726364751958015, -0.20606235726516092, 0.29128482325330934, -0.310924523491516], [0.17725546044957605, -0.07398039591733035, 0.35592569669860724, 0.4098786867949436, 0.09469934970425074, 0.23420467162701128, -0.2043164897822731, 0.11706724358010788, -0.3299514537176719, 0.586693505022097, -0.30996253014413006], [-0.15030413612572488, -0.09232053750037533, 0.46999820274258586, -0.08974387345367124, 0.2832017195149772, 0.42811241023986557, 0.41176595589516835, 0.36614882328546616, -0.2709321930018416, -0.09079536642500229, 0.3019696125128399], [-0.34580710273231907, -0.13551324827447403, 0.08118532583058351, 0.47634838532482204, 0.32373902151194234, -0.2011590858733013, 0.03024456180618994, -0.5846367527108031, -0.13042189450019442, 0.0469457835714107, 0.3483592839757111], [0.3947668805006811, -0.3645773974017991, -0.3923018709141451, 0.22866018653039094, 0.06339130286270617, 0.12056367341572527, 0.14496577671625874, 0.10216610452656255, 0.34069059858560163, -0.43535457226094165, 0.38658176240520087], [0.35305105827220223, 0.1368712453331985, 0.22436585505938736, -0.17983492794946804, 0.4058473910851968, 0.615015015751004, -0.016058152171896708, -0.18512488475500496, -0.1118244205007829, -0.33948566728233737, 0.26210817091351646], [-0.23453818285072747, -0.6139145911648625, 0.06114888910445647, 0.5564851655359347, -0.2230552898777324, -0.3626104434163399, 0.06065375710801804, 0.05558336197954536, -0.11364016739383469, -0.019093293152228165, 0.23108172483711353], [-0.05883209985188951, 0.06372920987688094, 0.06280416071741762, -0.17192422855056103, -0.48709790514413054, -0.4541201462432421, -0.018184443418956708, 0.30996145917234763, -0.3386997186247819, -0.5372478213214273, 0.1254037135962974], [-0.0939049468253188, -0.38013719374542165, 0.12699525673768502, -0.15999489307979206, -0.5045603758259389, 0.17521592333753383, -0.5758749525702563, 0.16770427741797594, -0.2675745020850144, -0.28842131701254237, 0.0716237758540755], [-0.03953097190409241, -0.13696704119770342, 0.259515749347786, -0.2844294167340793, -0.37614382412035846, 0.07758076100902646, -0.5122947436614596, -0.4253631915466473, 0.4583340355967131, 0.006955247490139595, 0.17443523428504348], [0.28425930580653574, -0.48887280288384144, 0.24350419974306312, -0.08310110472393577, 0.26982484966674175, -0.11825178002041668, 0.4687007443057904, 0.12661212081469328, -0.3884295636732746, -0.3635285622102789, -0.09202961186639153], [0.5147784563181133, 0.022391306423667684, -0.019020695678782933, -0.20044067492399406, 0.09544645280751596, -0.644143890822074, -0.11670561006657812, -0.0006448915327803095, -0.4850638741908337, -0.10858800939850972, 0.0960895868765218], [0.10862443696810206, -0.1118137099574882, 0.12224559505795624, 0.20004026895232316, -0.7335617703156116, 0.34973300408902736, 0.1651668003570326, -0.21133397756047423, 0.2327244292725635, 0.10263671117135756, 0.3516748636959715], [-0.44655183736987275, -0.2854749908201468, 0.44443858445480244, -0.5156279892311606, 0.4278768971731168, -0.10738846102020416, 0.08808667366456661, 0.07430088649722581, -0.056569219622825094, 0.08079459659199784, -0.19513830883126665], [-0.3184829291281439, -0.12326486164858402, -0.24829817817150776, 0.20063474377449497, -0.4093492546163226, -0.6104662893644767, 0.010579105257320195, 0.2010567446511564, 0.061597569558368655, 0.36777686345189287, -0.24827886626698256], [0.2157578967871892, -0.43179685926424616, -0.45478848569070773, 0.3594359594759002, -0.4992756322243592, -0.14137613141043884, 0.24249607730157238, -0.13202045267447374, 0.2644339979636602, 0.05217814957187882, -0.11326170206148616], [-0.2727725833630586, -0.10194113216824348, -0.022492666043023787, -0.3188010488981275, 0.5206243452641769, -0.17690378620630848, -0.22028357031025542, 0.5104321893148968, 0.04564223860857888, 0.1682946700348999, 0.413819108950711], [-0.35999695728004816, -0.07757859203850347, -0.34594343324712185, -0.2067522479023167, 0.36972875698513624, -0.307853709517531, 0.31640572464491823, 0.2598941715230387, 0.04201011506893266, 0.5145825923982771, -0.19044548940399394], [-0.11709173552186958, -0.054529870783021614, -0.42495857883281457, 0.6090959197873785, 0.227001811835712, 0.13735849901296507, 0.06908202043552203, 0.1548439980715739, -0.33974399534309413, -0.11313985078880712, 0.4520570850206747], [0.3318444791961832, -0.22890649760111084, 0.12426617754713244, -0.4189966921464578, 0.19611558338857332, -0.5259318357301968, 0.13933511093078166, 0.29988026650639255, 0.20978668354263447, 0.4106414024399835, 0.09713839004765493], [0.26169996253398436, 0.02406080701860522, 0.3848206820419092, 0.10616607477106418, -0.0018333453077009076, -0.2313482506263193, -0.2242513941193135, -0.4090271702562444, 0.5133517149079514, -0.2734176987175873, -0.40270523370042166], [0.10692093625571529, -0.003637944849276485, 0.10692165896204023, -0.09120790749280905, -0.16726060374685994, 0.12312709660139663, -0.4780137585501515, -0.5639818961754903, -0.1575982436997551, 0.20196595984856552, -0.559881215784264], [0.2706602417753677, 0.20867427443131478, 0.23476283909363016, -0.08507568832367352, -0.03657950703647357, -0.6658664109476616, -0.19947636909800193, -0.3951279678811234, 0.19830680679971796, 0.33864145269446116, 0.1618947925344105], [-0.10427399591088432, -0.16692927265813928, 0.47204979649212714, -0.036122556312875774, 0.4554477275654122, 0.24205761837691864, 0.48683133097447623, -0.4333303813236672, 0.17929452427922732, -0.09001390520608953, -0.07792422820600825], [0.18510422441721044, -0.5273350743096289, 0.4612167486859387, -0.0016659448277224881, 0.1926728217369135, -0.4290462761708918, 0.07221614862332452, -0.27625278889026383, -0.19090767499589117, 0.19159660033823214, 0.31470809396621896], [-0.2993799495568993, -0.011120969606265725, -0.27702230655115, -0.042929277505917345, -0.44655246251862635, 0.4608915521400146, 0.5606179922464807, -0.2597262006531608, -0.18722503184650843, -0.03258799440769846, -0.04436374153631946], [0.12750099601909182, -0.4565394223648629, 0.02446503006410708, -0.4468537271915713, 0.06910258532951263, 0.25640919809696705, -0.13382451238922138, 0.11153344067179637, -0.08687536420173927, 0.24027572577032552, -0.6394444109287095], [0.01882830697743576, 0.24359201710291115, 0.244785853474244, -0.3857008347884033, -0.04945342408270029, -0.4934138522816533, 0.029022461774957237, 0.17446929800445377, 0.05672653581857332, -0.06505999186875529, 0.6685714349446922], [0.3705146210451146, -0.23428512463054257, 0.08605909855068103, 0.4520751709142425, -0.19669418984175527, -0.2750712259189725, -0.06388601484402293, -0.468193935346682, 0.24965558257080278, -0.11787165376062145, 0.4268370450944756], [0.23874556823921733, 0.106425441743259, 0.5133692856022414, -0.10693760206793657, 0.5100391147289565, -0.24584266298956367, -0.17022154024275263, -0.36305049480496987, -0.2385468016640766, 0.16803802854359268, -0.30031583574474635], [0.015326464321287746, 0.1864293374734205, 0.3096548978821132, 0.005419160761010885, -0.4345343380466712, 0.24795256170576263, 0.30554190948266813, 0.0430381451791146, -0.4552293373689638, 0.5043153381534871, 0.24903265739207794], [-0.05317083872297069, -0.5256733054671929, -0.12893987594493717, -0.414484541279858, 0.23325829616949006, 0.19464767567215024, -0.02015610504611755, 0.020066318103505308, 0.0788196661301209, 0.6239658304946821, 0.209202145775117], [0.10360264672035353, 0.3910536427980319, -0.010066999019401966, 0.3472889030175837, 0.4892428467237128, -0.56970387113773, -0.09399545096455601, -0.2987233071728684, 0.025046922009972016, -0.2292674309377327, -0.021210547319389463], [0.24348511313828147, -0.19956403169069328, -0.4458157241074134, -0.17486204994638477, 0.5273728754867177, -0.3868232810082382, 0.4225438961523963, 0.1345982199483355, 0.10022231533861561, -0.18606180695326982, 0.04982837089411111], [-0.2183913452048358, -0.10359978028434189, 0.36818275535025463, -0.25988586113023904, -0.22710271250598676, -0.12880892246681092, 0.20375290729877132, 0.45728746179141905, 0.19400371888880724, 0.46055999500366235, -0.4122204522976852], [0.18926452614489978, 0.30020554305896363, -0.27072875295861837, -0.037123607420028966, 0.232847291145799, 0.37482116673880145, -0.39192933803492264, 0.1343141277913595, -0.11239775435726079, 0.3780028029082126, 0.5267886843850907], [-0.4663122996093655, 0.13354630211820268, -0.1651769807651919, -0.3365599074788326, 0.45575223454150776, 0.25781898616312954, -0.09936454478112854, -0.1414660007418225, 0.01571191223060301, -0.5523485311183616, -0.12148984760445121], [-0.2512560373733652, -0.007832981293593467, 0.23511219456819518, -0.11048001298870627, -0.6334092928060667, 0.28891866099143254, 0.10347985755676155, 0.20020458691464374, 0.2648318588774266, -0.477952250193072, -0.18782950092555203], [0.3921026821494781, 0.24161533616902622, 0.4936826148496802, -0.14086363979677874, 0.10115865452838806, 0.32205092381171346, -0.6187143224794321, -0.046755350362865836, 0.09525140219391406, 0.10226356816229244, -0.07640951002067671], [0.09552220125360364, -0.08568073692741333, -0.2221384018282269, -0.060022796620054476, -0.27096044649116524, 0.036829906946729864, 0.19264280534327188, 0.5119986464558697, -0.31904238028998266, 0.6032799400384181, -0.3013660866801871], [-0.5810054282863881, -0.15141239090546335, 0.5574936619421267, -0.0005602345087673611, -0.2750837084796211, -0.3085494798620734, -0.2785364265843411, 0.20647945084027453, 0.08604717617937747, -0.1213115250887116, -0.12448593421816156], [-0.09882040516142263, -0.03488640665295281, -0.29874251608067987, 0.1726383917676942, 0.2583829616550284, -0.3574847677793333, 0.12970716528420972, 0.01824833351000538, -0.4306825159372197, -0.6842529988412905, -0.0675477645898654], [-0.4141048253033209, -0.30723412059495064, 0.011259369836431334, 0.3849068658892046, 0.14450523916963307, -0.11533758871564333, 0.3465699950377524, -0.23782174412685167, 0.4820722064511676, 0.2350934906806509, -0.29551191419917755], [0.010630892071540136, -0.08998766102882441, 0.07620084659392304, -0.3321089284675229, 0.13552150959858125, -0.13563282126727397, 0.8586305557418692, 0.07452232772479463, -0.10265384859192285, 0.21923000042029844, 0.19371200153815707], [0.1078512178256403, -0.002948661216379831, -0.4463363408585555, -0.10340925635797141, -0.41019098303260654, -0.0031202015145083495, 0.09390197317144863, -0.730940968242353, 0.06061326468917086, -0.06287482128330642, 0.24385230753890735], [0.09063582065925427, -0.3788004792006627, -0.5737069213452749, -0.23684617729622906, -0.22177000205797504, -0.5169245568533418, -0.03632993601007074, 0.11141466280032687, -0.12455660027243039, -0.24956559979589082, -0.2348110810211656], [-0.0017429401365645317, 0.06111410130999444, -0.12512074873824305, -0.38310289217996657, 0.7746676762700628, 0.30738714794016614, 0.2997162990082306, 0.07719995192692244, -0.0775711770746876, 0.17907442172464158, 0.07326325917779514], [-0.2475473695647384, -0.0009912056703823258, -0.5236958784961417, -0.18852585279127182, 0.05694460040714391, 0.01818806837790964, -0.47179710176827633, 0.007133995544412526, -0.1414574811090283, -0.07462580393179312, -0.6141040831634134], [-0.10734773921271147, 0.003470672911827015, -0.10664175201417901, 0.09092315818830303, 0.16730379667045178, -0.12321167151089288, 0.47810595109585197, 0.5637584792861787, 0.1582558863109407, -0.20230021599708803, 0.5597088802101946], [0.1402645246351796, 0.038246269894399956, 0.08332936384090041, 0.2752740356175505, 0.2452252632193026, 0.06244939131938589, 0.24618150052606452, 0.45785918383192564, -0.09221206515080553, 0.645314806337109, 0.37004530067251706], [-0.020294787560252665, 0.2712702230636342, 0.10016912145363745, -0.18541492491076597, -0.37206196713494627, 0.5200993588146318, 0.14686174976256375, -0.03955068487373317, -0.010109225390181498, 0.30817756509296973, -0.5953539717636817], [-0.2828357219566412, 0.3033456504205907, -0.030008152125890558, 0.09808620810059167, -0.20570653676043874, -0.18412765859713637, 0.6479600071610062, -0.021926499902197093, -0.16539365052418825, 0.3472040295441756, -0.4159412979889011], [0.199608745909217, -0.16169733029280756, 0.3104199511365292, -0.09135942285504708, -0.1314387488384292, 0.049082507116480247, 0.3101720256132095, -0.2815748193464429, -0.6113765919024793, 0.22783114326337026, -0.4565507235715396], [-0.012194885249341902, -0.7421104499593205, -0.05029574163776088, -0.11797216832919151, -0.1081278649491648, -0.3030828612194367, 0.38735167171512724, 0.041618135878778495, -0.11385365118384427, 0.32403332814361496, -0.24370428045907036], [-0.5024375898757698, 0.36792597051843384, 0.28586500787690466, -0.13791255606874023, 0.10397327656613886, -0.2437835327594847, 0.33316275366211046, 0.4614735826348691, -0.18199759661011417, 0.2328073374607313, 0.17300216795876425], [0.43481359418306564, -0.25952361553288134, -0.12367935527518692, 0.26824487725850443, -0.24141186606893092, -0.17232652528574036, -0.45764533089294923, 0.2410210682374602, 0.5462882807293377, 0.007239555066835346, 0.048403644072161446], [0.26705843556632197, 0.5643741527898347, 0.04266560029413724, -0.15427747337392198, -0.5555074859167977, 0.05831971934453829, -0.36450695376857817, -0.11850992166462217, 0.14623066830891296, -0.13546003555443004, -0.29309931487025975], [0.14524480546745036, -0.38889905398689906, 0.5928023990822946, 0.07246681971134714, -0.5315530839919668, -0.05386698934039751, 0.18555913669143992, 0.007488508629505985, -0.3101488318991323, -0.19495448263748028, 0.1298352615202688], [-0.12522211706043276, -0.4486396027290119, 0.1082490834653638, 0.287398994776103, -0.38949191679667977, 0.16739195632261678, -0.2256611442942984, -0.6107031720146459, -0.27497947293259933, -0.06055751087387351, 0.07641742399934563], [0.2557739018861046, 0.10765172538898712, 0.5947827099514624, -0.4811868368576819, 0.06789700685517056, -0.04599996655221073, 0.2808220683943291, -0.201620355206446, -0.3767122625519791, -0.11227425930545114, 0.23859617109096207], [0.18328931535143214, 0.19674995120207125, -0.290389203766673, 0.11518769464566693, -0.2536545043504521, 0.014686684740959976, 0.7241285884270922, -0.12312083427679389, 0.3548866732410892, -0.10175341149803477, 0.299541019938778], [-0.14375239786359173, -0.5669921109829986, 0.1461182552552533, -0.31159016870792927, -0.053789180429523756, 0.26464456643244655, 0.3375826519262163, -0.28437999238432143, -0.44098258557441083, 0.056675084627916046, 0.2719824645381027], [0.2796495132544361, 0.2431510577089931, 0.390537959585557, -0.053172530068256056, 0.26934798335838206, 0.19854196009658492, -0.1400634285152837, 0.5145289665605156, 0.261184322962283, -0.10407339311623864, 0.48161489577144795], [0.29509174665958104, -0.4699145828390348, -0.47109281764833166, 0.1547915778227131, 0.09772899694633405, -0.1624291232482937, 0.1462791256234756, -0.31623488495517715, -0.5085656019671383, -0.05961142821024682, 0.16335089417365467], [0.1572898622313073, -0.5968202933337863, -0.16633759396537917, -0.0645355357072713, -0.4077109386051841, 0.251653998447909, 0.159859492966822, -0.0722068248336387, -0.31453171292137055, -0.32546511209390516, -0.34935346156601704], [-0.06374252622160076, -0.21647605417465732, -0.27649402768505615, -0.5217053322503094, -0.2761573806495372, 0.06301412020558828, -0.30591255592474403, 0.21258686598311144, 0.09217710097999497, 0.06132688034090106, 0.6076040300928699], [0.049496931657565524, 0.22338420667817968, -0.4411186085339759, 0.021218973217162724, -0.4356864500624905, -0.08681070425709865, -0.5428669811778912, 0.45747132092832304, -0.22406083857613826, 0.03234387047984749, 0.0045763671263448534], [0.6843914893657232, -0.041826709542685685, 0.1544526794652087, 0.3532604229646817, -0.03508187038231195, 0.4837960535818555, -0.04705789621991628, 0.016482984425581857, 0.0043015288542141965, 0.24674087431150574, 0.2872894069676487], [-0.2233032135705535, -0.5060955878786166, 0.13000276676319444, -0.11137352876583832, -0.09860246622120217, -0.3901333210319185, -0.13078901163191606, -0.13752138605724723, -0.6362355943363173, -0.20347367213865117, -0.1433754860423833], [0.25115603448800805, 0.41335580148343276, 0.42434823918967723, 0.33900165882154465, -0.3346630962914855, -0.05579781958193504, -0.2606798435352602, 0.007186946527865761, 0.42600194027246757, 0.12777644518060757, 0.30023521472129944], [-0.391299755385817, -0.15017452874593037, -0.2040793453926207, -0.0103029059510703, -0.1036897751370894, 0.13840965962182986, -0.22236552891601738, -0.09693429643961132, 0.08104528507536529, 0.7146186250914212, -0.420211822873377], [0.3482304117069112, 0.24669722515891326, 0.36785285625915665, 0.21655855461205545, 0.20091398982930853, -0.11052448735375012, -0.2790847341861417, -0.21649152919089873, -0.32379405776000103, 0.08988225951226694, 0.5877094102792843], [0.5092058710185419, -0.0402564736324932, 0.31074940745612234, -0.514618985971221, 0.46349107603619794, 0.045408896498838405, -0.07019310351375355, 0.3193233566792639, -0.06429369662255177, -0.13277797224619148, -0.17929531395745563], [0.21437966912786685, -0.3849472151974761, -0.5954569189057407, 0.12341056702732568, -0.06969124368397141, -0.18463751957263322, -0.049743131277832975, 0.35659292990282226, -0.03719017411630648, 0.38066033021607565, 0.34812600125879944], [0.346467059803031, 0.0891311869767757, -0.46174164208633905, -0.09928860855613571, -0.17524007563315885, -0.46552871272889185, 0.38806550044520427, -0.13906254350862868, -0.2089406472521962, 0.43331034476343977, -0.013390185770312178], [-0.7133054411450842, -0.18860765440667915, -0.1628185586187338, -0.38559697318815883, 0.11340341950415049, 0.23381431835980465, 0.29439295990231357, 0.18079768795644818, 0.1499023071844615, -0.014822987170803577, 0.2661816655704306], [0.03544884172299256, 0.10438852004021279, -0.04633294042313898, -0.1800454853561915, -0.06690802419931215, -0.21633867902583354, -0.0759908481840084, -0.5821428294412908, -0.6438335175264481, 0.31406578397114066, 0.21019132418939257], [-0.2014726628188676, -0.20523283660464844, 0.3028122379158899, -0.12482060057059435, 0.25426127620601674, -0.019181172626350277, -0.7215170012807255, 0.11498652742935171, -0.3299438242373207, 0.08575197755482103, -0.3081737947358844], [0.13008561079392716, 0.3321774137680376, -0.025730049812635904, 0.5643438414444645, -0.27421777068197595, -0.47885808932521146, 0.2711484892575091, -0.22899116919885285, 0.29485006645007994, 0.13696488052641712, -0.13204180533523854], [0.11902341429421814, 0.10488511126497213, 0.41523013537656595, -0.023312379436163738, 0.678166357430203, -0.3707871261920842, 0.3099513205502889, 0.19488360557263376, -0.0627287522128952, -0.04431308969146002, 0.2540321230098312], [-0.1618811374940367, -0.7404689356528515, 0.3359146192452442, 0.1303613214712309, 0.039800205216834965, 0.26218283756246186, -0.06154670329903502, 0.3373825624692364, -0.2997504240999895, 0.02494985665423906, -0.13136151723500392], [-0.16366874896945482, -0.06022211063154029, -0.5106930050961437, -0.38621475644353653, 0.10136081853249353, 0.6734576112241766, -0.004138972075101811, -0.13777166373747757, 0.04751244852664066, 0.1889960138069437, -0.19703399804321245], [-0.21051143866383887, -0.45828409386186963, 0.3077286374628736, -0.18072015907467034, -0.19136729169641367, -0.15140082904638824, 0.2130042240307737, 0.4185465428421276, -0.07799242165119923, 0.2973661021088548, 0.4936586446407273], [-0.10899575089130427, -0.39327228485687854, 0.013876468901191642, -0.3504681358739456, -0.4887754002452249, 0.5688165651473612, 0.09498903281125366, 0.29630083894253734, -0.017223420361389973, 0.2247431727758974, 0.018959047899454257], [-0.278249526407135, 0.39582913320604085, 0.1018447930068742, -0.30002846712508097, -0.1680327918227856, 0.7402409166736409, 0.008910034604593053, 0.07679056967358922, -0.2172637985312043, -0.07068630911288247, 0.17646282557601065], [0.500790241506474, 0.398159297805908, 0.03533010579347714, -0.3110139687401993, -0.1714681099627821, 0.17072290288682604, -0.3143138905118205, 0.21350650622605707, -0.3863167786871083, -0.235847236198162, 0.2913931328366244], [-0.07955360790812163, 0.08453556505439315, 0.5442063557492652, -0.08054840938354986, 0.34885935366792753, -0.05973008372129239, -0.2440311498169229, -0.3871593296811988, 0.2550265075385802, -0.390586358179175, 0.36272035356663107], [-0.2573537414145453, -0.4157960528127661, -0.41985259574429223, -0.3427079763699069, 0.3351267427285496, 0.05500023567631535, 0.26178123383634594, -0.01021252434019195, -0.41686148579077775, -0.13301479225311763, -0.30285744513231083], [-0.09269888554737077, 0.33553605749366705, -0.47337280966981676, 0.006031413934357467, -0.6601158277738731, -0.2595784027695315, 0.2490589877931503, -0.05685236216488178, 0.003982811638546565, -0.21141607730264572, -0.20394909064349676], [-0.20172344349061747, -0.6394990746291652, 0.019530642972193164, 0.04030618484227318, -0.1708959805104098, -0.17962449967940927, -0.3741285242148026, -0.1586137727798645, 0.3486033414750088, -0.0004883034319819754, -0.4474563047149945], [0.192097866471257, 0.037203280951109, -0.24564915125080064, -0.3485808263178889, 0.32826821966655334, 0.26268415819337126, 0.2040382410672302, -0.4571859395176752, 0.5310802889210794, -0.26533403160537034, 0.00047735650108721574], [0.017747537908753695, 0.0012362572419360666, 0.6335260776866257, -0.36104267315838157, -0.1993686528113782, 0.32632880933166636, -0.12119882379330671, 0.3291472149192952, -0.35882198293995526, -0.014063212818100593, -0.2641212008121904], [0.03214330647714527, 0.1060333268117935, -0.1090670542654982, 0.6366043187870817, -0.02028610029450405, -0.36228851036204185, -0.4935956672576982, 0.07899937899146091, -0.10088279997126491, 0.34381905722250333, 0.24623586612817833], [0.2568113645763932, 0.5186056771492462, -0.15309025894886455, 0.1322483785991387, 0.09385551679501043, 0.3928733524216143, 0.12659332866956796, 0.15323156665176654, 0.5870943304074286, 0.2297524221361084, 0.1550476455604643], [0.28226531887861067, 0.35316295354636723, -0.18030435286666324, -0.35421378337254333, 0.5919552100579718, -0.1544754117147608, -0.21127744278392102, -0.003270044266677335, 0.08373426158216574, -0.26714228027554976, 0.3746014615233541], [0.26164158358335654, 0.09684607082920427, 0.031050086910468105, 0.31094961383467273, -0.5192309455187187, 0.17646157188237216, 0.22197193701438678, -0.5163478093366914, -0.028001115710714293, -0.17729757170261715, -0.4191255140014617], [0.19021287272077478, 0.012516951929995699, -0.301007713284187, 0.06776356594344846, 0.5831199796006706, -0.3617103641029827, -0.09616619947784595, -0.12973646622895516, -0.2442983947908645, 0.476868860644243, 0.29057949340864564], [0.110930040791287, 0.3810848944542132, 0.5070315273182654, -0.201503099946086, 0.30529243769753767, 0.15103231888719618, 0.4547691946654812, 0.16109800792246118, -0.09018223152415529, 0.27377094056889517, -0.33603448493660754], [-0.435362657764984, 0.25932403858047276, 0.1240540642494444, -0.2685922626265152, 0.24148964378223203, 0.17229012785625264, 0.4577035212421217, -0.2412765124781217, -0.5454831009580907, -0.0076666780079760535, -0.04858588698498905], [-0.24638222001721868, 0.19839716122049025, 0.44774842250602775, 0.17339234385580585, -0.5273251777191051, 0.3862339298132009, -0.4220166222387568, -0.13583507226225378, -0.0962107340777563, 0.18363775575931718, -0.05112528459340343], [-0.2093308055585617, 0.0010542961206686777, -0.4575224673901062, -0.1798099521266825, 0.06008340230680141, 0.2274563539512244, 0.3160390755173276, 0.16221038490541226, -0.48520226751282597, 0.3840504466746057, 0.3873832402831284], [0.3492126255052328, 0.0732008994353278, 0.35329262279964496, 0.20036278951491313, -0.3687068896520209, 0.3061764056327718, -0.31444261569220494, -0.26467205484133294, -0.02688086430172693, -0.5232729597445066, 0.18595660105790127], [0.09753080145015076, 0.4377460339507097, -0.08946085434672042, -0.30230613574542137, 0.3908521109782113, -0.17109558928281454, 0.22970240572374848, 0.5980180310366493, 0.3127481539198289, 0.03883485744168128, -0.08790062831389947], [0.4523696779140375, -0.28497519331472315, 0.32195769884504716, 0.0033797301850422927, -0.5614397376514688, 0.28488301473402877, -0.2439526999700974, 0.03947009786330556, 0.14143995564632106, 0.08051299089706329, -0.35574050791961054], [0.14848463448826002, 0.05504011441204611, 0.26469576735897116, -0.14277994836134086, -0.26363039392307785, 0.36462346238802584, -0.13808664876254056, 0.005476969837939596, 0.358626847607999, 0.7256965740594251, 0.08760724341510294], [0.2572768001568055, -0.11097228393429863, -0.10796645898737654, -0.06726445176659991, 0.04846565367030828, -0.01914772927054019, -0.18216845173803084, 0.5481170349870879, -0.6370914501715575, -0.2953694427206091, -0.27541011240219404], [0.3404492209837777, -0.1475318571469491, -0.16261661453762716, -0.30768776859562563, 0.05027416011767022, -0.32262919172637927, -0.17132374987025914, 0.612515229689327, 0.17937688818305308, -0.3780023202468452, 0.23453594663614466], [0.051550584584656695, 0.2133088956627562, -0.21526248255358396, -0.641035005529919, -0.4230368039548484, -0.4465069071528839, -0.22203924738579633, -0.2214847006847891, -0.09771956277452026, -0.007165376396953155, 0.09106111315945145], [0.15429300846175525, -0.2671146269256754, 0.1546188372373473, 0.5125556947114386, 0.4482739062364797, -0.28425307747067596, -0.13951996813524367, 0.12264853893590398, -0.5484520539250721, -0.03226634710776707, -0.011160346163119027], [-0.08158140377790056, -0.06541932172371231, 0.041264029809086535, -0.2931269018797452, -0.6173251080756708, -0.20803656532161374, -0.16059384744525348, 0.10676561711592127, -0.2790919754215012, 0.007903415465854243, -0.6016021185248324], [0.050182202787530716, -0.40389601842306916, 0.22822589305441082, -0.5424580964045151, 0.31638168086951396, 0.04911722801332729, 0.22075617965022945, -0.013093268932791153, 0.28675206406545023, -0.169392609122831, 0.475043904619573], [-0.34763162868899244, -0.35631203180688625, 0.04173653517657791, 0.44065191759639755, 0.08161952238732176, 0.15505897793954534, 0.4032373077048037, -0.2164140613097881, -0.47619631257358214, -0.22858638759455363, -0.19267295046411778], [0.14642913421945103, -0.5530445493529181, -0.06545018307460272, 0.23649298793305562, -0.05786015752401809, 0.28931065963923464, 0.05387805694742693, 0.3194883418289489, 0.39147751941668885, 0.45007073210416415, -0.25425412873089986], [0.11996744183573244, -0.27771008837653094, 0.011752065619403269, 0.0897557538524178, 0.20564139498716424, -0.39772037850254605, -0.6237125581561306, -0.5276639021840339, -0.13690282810124577, -0.11212266568811219, 0.03256386242450059], [-0.05978888521828944, 0.5001126424115528, -0.016707567151748783, -0.047609916832571375, 0.541831899378308, 0.16812598356775407, -0.03993131137565216, -0.6165315381038715, -0.09329695806222647, 0.10970543097533755, 0.1395470620076609], [-0.4491667237855934, 0.15045745960225834, 0.05689996217869452, 0.3978299277064142, 0.11716296749192236, 0.19923743988880654, 0.6496363407172222, -0.04935655092771304, -0.01919196024203168, 0.1745795790161783, 0.3246121170976588], [0.19591036367557557, -0.4895373565002558, -0.26720964811235937, 0.3073815394168659, -0.21768414894894472, -0.12010037855256028, -0.44471016364181964, 0.08150880754096722, -0.383716105016638, 0.20842045469635267, -0.3149435806719657], [-0.06638402945225562, -0.2031665653141525, 0.09570597436778323, -0.22931355720649302, 0.6352172214868976, -0.07192323040891407, -0.052158886137942485, -0.3299273405565675, -0.48363293072775265, -0.2722785055228388, 0.25355334956142067], [-0.248324602918459, 0.2603117370170869, 0.3742807880114952, -0.007422579474927108, 0.26763532948109664, -0.5761125935890454, 0.1306541633091174, 0.030275767724256882, 0.40739387821870326, 0.11090622925257304, -0.3614415608631897], [-0.10791372393063833, 0.002959031813047668, 0.44640323045037494, 0.10339639970985401, 0.410205926109621, 0.003106426181768052, -0.0939390202308721, 0.7308840673931626, -0.06053742329480662, 0.06284531139067923, -0.24386530855271527], [0.4084869678985826, -0.2557764497722734, -0.3250981078492649, -0.43776268151371756, 0.18767060716731573, 0.09351369184068174, -0.04689802696370033, -0.08979363207038825, -0.18551709147927845, -0.6177146664542478, 0.013284227954404258], [0.15840737992853993, 0.07295945562517853, 0.42689445849169494, -0.701045646874238, -0.06043532847055239, -0.08620904576586377, 0.011779553430565137, -0.19321850189500256, 0.3631610934791481, 0.14505942722914097, -0.30723826101093327], [0.2388934672791224, 0.12150801129400815, 0.13279824129613552, -0.060270477861208156, 0.24319704189652655, -0.3501542255598538, 0.13983351171987865, 0.036965664951426856, 0.7669510343930712, -0.2045469310356386, 0.27234503976979707], [0.6206332303744713, 0.22604920945139856, -0.5233762145010002, -0.02039832947867984, 0.2565681279855882, 0.23196964927508454, 0.14922418850426755, -0.32319065192128327, -0.10422810674667568, 0.11828537760894353, 0.13477866044535913], [0.5028653394023639, -0.04047874189333799, -0.14868407688208618, 0.4817213058762712, 0.14812996227447348, 0.3318785891481428, 0.15354538724737826, -0.025577628389862373, -0.3982275325700115, -0.382189799412539, -0.17422702281755126], [0.3949218576627185, -0.3648114695359146, 0.16024176314788405, 0.24153361518760855, 0.3062034459118572, 0.2469551194097459, -0.42717178425442204, 0.26959993658653136, 0.12088283548209766, -0.16961612808836266, -0.41670598379374185], [0.27952523283653247, -0.6345595323336692, -0.14169997586940336, -0.043708023694660814, 0.3910440261692903, 0.5478960531425435, 0.17851591491671892, -0.07585002755928603, -0.0002397141503307187, -0.058189422003600326, -0.05565814700764515], [0.03158097054680886, 0.16388394382504998, 0.14812150998835288, -0.34800652612256144, 0.47107325280316414, 0.014185915154066872, -0.3022506318910091, 0.21284664253819705, 0.13810477034855947, 0.6164350080590096, -0.2669470680550689], [-0.2007007654437735, 0.3386928877483674, 0.2826102840440879, 0.40285168202508753, 0.48126239323883774, 0.156873591390411, 0.16855781485588087, -0.09923330977442281, -0.2897650762581705, -0.44508353783531834, 0.1621829940858506], [-0.12061221328022277, -0.2316340992736241, 0.5660414428432012, 0.3567941318342815, 0.08209543287496308, -0.21101890997959413, 0.514817809588666, 0.2180598424216365, -0.2081151804395197, 0.25726564503738064, -0.10363260912258064], [0.26014709475701686, -0.1797114908905602, 0.23351265492788725, 0.17374238373882994, -0.09150853754161159, 0.2794328034251224, 0.37752896551737086, 0.44762450461859427, -0.1030205562831364, -0.06098701805590278, -0.609612762999374], [-0.08240732356505696, -0.13782915148319577, -0.35914891112240144, 0.18774818931832482, 0.4639597425844894, 0.18269922898994467, -0.27837511241358015, 0.47352899985686736, -0.3509149170708289, 0.35394325018659795, -0.10581901420239297], [0.3546096493069722, -0.336142879644752, -0.2906392955454625, 0.02914174304161368, -0.2713714991049071, 0.3316977144865341, 0.0891620990675639, -0.32381619272901807, -0.2125947212825864, 0.5725977710896799, -0.08001328577229055], [-0.4073763600303051, -0.01451960698017241, -0.7806843756046148, -0.26204701052370544, -0.21072204931564567, -0.143573158333744, -0.0734809752271001, -0.10771631698891108, 0.1070790316068762, 0.23811126149820647, 0.07426148311335966], [0.21583344397851076, 0.06885110700302448, 0.27503997540561503, 0.3754580678801495, -0.1470077360051596, 0.3009490122303575, 0.5729621743174493, -0.1050459536333247, 0.3065026452964691, 0.38945118234367987, -0.18692703853024914], [-0.4002215348102614, 0.3370204683917241, 0.03843953252853897, 0.5488550962619717, -0.33347432004465205, 0.10976570996894772, -0.2637199915078852, 0.40227506372348026, 0.15560532265946717, -0.17118858366535533, 0.12399504409130406], [0.08997617294685353, 0.22674304811491564, 0.2583491994784998, 0.5375385065009642, 0.2734161205744614, -0.059623969147708816, 0.301729309163714, -0.200492761295974, -0.13026172881093348, -0.04003424779080367, -0.5972267145519576], [-0.07966105769477948, -0.11380279249242561, 0.016549820349529773, 0.19324919895671708, 0.04351555254294078, 0.1544324631770563, 0.011896717555568169, 0.5816217755486238, 0.6741376628830265, -0.3076610913240075, -0.1726225493607692], [-0.25933330113414166, 0.12399789892033891, 0.0026791585830917603, -0.11561101912890462, 0.20431726274576764, 0.22009978222834736, -0.13781159511597582, 0.11565413563692743, -0.20515560203775446, -0.37973807576286267, 0.7714599628552955], [-0.13109707001088897, -0.23424524073669117, 0.014142041129218965, 0.24441502928691589, -0.22890991011185385, -0.5403213158374888, 0.19500927880706925, 0.0023985447703864567, 0.4498218906809364, -0.5133784683866138, -0.1404478311891871], [0.28655167922450664, 0.2928026566334267, -0.056968796020792065, 0.030625730227468805, -0.18333503289369074, -0.46187587780015715, -0.5112275393507661, -0.07934686405413999, 0.1574995043672119, -0.4443181974945697, 0.30192055780220767], [0.5673239729513161, 0.01647912123749089, 0.38724898625492654, 0.019297698180538052, 0.0628369290742591, -0.4203243779319078, 0.5201960116500152, -0.18416873793723362, 0.0622299787122479, 0.07121911522359413, -0.1828933028691203], [0.2706368727340072, -0.06173807816843211, 0.14464174972993746, 0.29296176150844, 0.4220165099840941, 0.2082927420185891, 0.41765470190365556, -0.31378047078754434, -0.4507696699669771, 0.27694745457727304, 0.20475751620912314], [0.034374374339246276, -0.2714459256052999, 0.5358583840317924, -0.17788019488086904, 0.17312477248497754, -0.19415048940270616, -0.2675418810404222, 0.3669882357254191, -0.3433644119886787, -0.32516592214076556, 0.3298368102505742], [0.15127710187298427, 0.486541364343135, 0.22282415924337604, -0.17452884275137967, -0.24238568735453442, -0.2681735312263959, 0.42421830407131506, 0.13272734765150157, 0.33456094260065633, 0.45099133816270714, 0.1292749872064932], [-0.2082822959756396, -0.04232049141129193, 0.048514955952001296, 0.2201958631384958, 0.11908859886279459, -0.643373217555218, 0.3698983298403508, 0.010915597333973992, 0.1619790559348664, 0.37672955821871335, 0.4132433319098782], [-0.046556963518286414, 0.21277498742645395, -0.1043793685703221, -0.20398942688772936, -0.20348026912181502, -0.34559827301893636, -0.2132004453717373, 0.21076192999929969, -0.26303523214870694, 0.6691919421701331, 0.36377152020499465], [-0.1037626815232926, -0.461984553738411, 0.41475425260357024, -0.27202137064889836, -0.3586028352848368, -0.028255191275121022, -0.2650034306859408, -0.14549119107406308, -0.23536788344505769, 0.4992064010066027, -0.06627922948110515], [-0.41025624800649985, -0.03013808362615947, 0.025196651685587542, 0.00666414172910784, 0.4590457803327332, -0.04955865578227881, 0.5594164882042133, 0.2704599871659439, 0.2044083233921044, -0.3107195581498383, -0.30413536068705954], [0.019703938730547207, -0.27148108535662135, -0.09976364998759833, 0.18502128838237641, 0.37215842235623553, -0.5201157709338265, -0.1468241451186562, 0.039274329534786837, 0.011003463998806612, -0.3086092938669399, 0.5951816786012022], [0.10807491305142071, 0.032668171699635776, -0.3774533383385787, 0.30808867482576885, 0.3360843790475936, 0.6611364753339579, -0.29754917344088133, 0.021523450369526628, 0.2488789733510708, -0.2194491814467808, 0.02667104321118185], [-0.12835655412060393, 0.27443318074408085, -0.005947007941585366, -0.09487368398236146, -0.20470410968066077, 0.3967786216654503, 0.6250844259644495, 0.523906381397004, 0.14917140392091546, 0.10528070655118675, -0.03595863460672581], [-0.005612782009410144, 0.10695143420813823, -0.5652628346369915, -0.30634715098376264, 0.32385333257477217, -0.35352717612896883, -0.07043847199150095, -0.5218082486735903, -0.1651054563896163, -0.16953893912232998, -0.10976384947270978], [0.4674442016536215, -0.02140423748057629, -0.5396242375046457, 0.24666741066788947, 0.3272471569412665, -0.1608223090566805, -0.45573123279771915, 0.12307937975427222, -0.1777293013886956, -0.20201211551084097, 0.028426067270079545], [0.056541671004606185, -0.061758973677412475, -0.1677752461640066, -0.39638758330190244, -0.23679027334385572, -0.2599946003390745, 0.5073595722977139, -0.33686101967333687, -0.43701375219299826, -0.3474416191480463, -0.03827026174161894], [-0.1165151085424802, 0.05114607560781017, -0.2608507299975258, 0.4774593755549776, -0.28082096839305165, 0.555968051387584, -0.07137797094576628, 0.21933146026206046, -0.12935680271955924, 0.4641410751832369, 0.12031473331909047], [0.09197310797076977, 0.29599012938962704, -0.3113362387457034, -0.06686766222969952, 0.33791678018655485, 0.07956047836253355, 0.12005351829106232, -0.14049550423077806, -0.42470903770480684, 0.5100357958707669, -0.45535208258665716], [-0.009369892314972124, -0.08165629356570867, 0.2874166457476824, -0.11177921968631051, 0.14594564265667326, -0.20339015130390373, 0.3107613992148607, -0.31298638083712566, 0.03151028745632448, 0.7880295535378047, -0.1376853335639681], [0.2453703475522827, 0.6543478482377743, 0.00021218961411888782, 0.050940983874513866, 0.14056553188591767, 0.17928275774652408, 0.39367569170716005, 0.10217466381281749, -0.25936368554365336, 0.06103055284200864, 0.46979976509274635], [-0.4105019548831361, 0.43500518403003485, 0.12326441493635035, -0.13237111733217166, -0.20632973202131377, 0.07842788981683191, -0.44975831594359844, 0.19929926040756005, -0.3354400136013467, -0.3730918773536246, -0.259035179776989], [0.1306209849286436, 0.4538851037340685, -0.32351818360126194, -0.37143733729351325, 0.02143344820654918, -0.3007796674959031, -0.11661846820169147, 0.17951746107042957, -0.002597831396716099, -0.5398656672377702, -0.325700607648083], [-0.25055994539564924, 0.47878418358059893, 0.22909384011366787, -0.36213932912669455, 0.26213433246375123, 0.1268159992308484, 0.42839361432432504, -0.021247287326902328, 0.3062669507211524, -0.2772937301494651, 0.2913692472174213], [-0.32075496708235957, -0.01529542318589867, 0.1969597141505963, 0.3993744452550137, -0.10534205770079107, -0.20322228461402017, -0.42876731280250363, -0.10797362505374736, -0.34487684701218363, -0.497184055567106, 0.29079415669128916], [0.2305203855841341, -0.04847339291738839, 0.34906898136071346, 0.25538648843287576, 0.036199321973628754, -0.2575253413961348, 0.1287437760266441, -0.5651108928331041, -0.41064406312263824, -0.42970971046067785, -0.02460314020801565], [0.3581699658075284, -0.1902502588525534, 0.010211501068422373, -0.20122298200020675, -0.2926434518590186, 0.12054940074504475, 0.26014840087978325, 0.4258105074527678, 0.5447459709114312, 0.14575910279744883, 0.3574438918415678], [0.22721377185838265, 0.459396991279379, -0.22612129328889408, -0.1937292105713059, -0.250760659915379, 0.35120497094676256, 0.2380882363348388, -0.257262632213144, -0.059695635249796965, -0.5779013298150565, 0.04513350984631985], [0.0638392135631401, 0.05828509989528917, -0.028617248612934815, 0.27913717092692014, 0.6201608923069998, 0.20716453086363754, 0.1628587731322911, -0.115787985667031, 0.3074084294699483, -0.021034524340000253, 0.5927916904792423], [-0.4698307985563153, -0.36572908384667463, -0.45173655741735275, 0.21322839886372844, 0.318476638687522, -0.45187117450400577, -0.2280142246775801, -0.07096281459375767, -0.16120989192900148, 0.029988245242790146, -0.08024918075043819], [0.09089029235913339, -0.11332851218856593, 0.04132593639046798, 0.5738987705181569, -0.291382152720716, 0.1497416290518579, -0.28570981731098216, -0.3730879582638877, 0.3719001867501383, 0.38233946304977895, -0.18757376854070296], [-0.27772792332743035, -0.023253427114231107, 0.42274604947667604, 0.14955655777545682, -0.42351739316135567, -0.29211660334976497, -0.12453972916159223, -0.278968981401038, -0.08066457265716973, 0.2201081596714503, 0.555209679479393], [-0.3443203955787666, 0.6136071906071346, -0.30594507985458574, -0.47148874524246287, 0.01730804785477693, -0.02912376085707516, -0.18656425537267074, 0.2605701527001485, -0.02872582350887015, 0.005188808927568521, 0.29038382796545237], [0.05425848499406455, -0.21707262338848976, -0.2296625243491897, 0.5363161255024864, 0.013098086407499756, 0.44318306874148844, 0.31629471149515814, -0.5103730265440488, 0.16137406790783934, -0.057395182970026715, 0.15203312653978088], [0.024073810077651834, 0.38780380410655746, -0.3957027906732979, -0.05923563039788647, 0.40886349661820026, 0.28929636714381207, -0.11189594441595013, 0.03604348107523749, -0.6074949677657817, -0.2257079845014396, 0.06529388019470245], [0.45154480795987223, -0.03951767715621908, -0.24891301256258874, 0.5342057785967362, 0.24471963221108126, 0.05029353723777058, 0.13641425565340778, -0.04372618218589274, 0.5053868740921935, -0.013577881800475792, -0.3296572766938765], [-0.6537211773897245, -0.11866913083252222, 0.06308989624916747, 0.03660595588239304, 0.3463193881790118, 0.024365125746692782, -0.09103720134521648, 0.32873545269316506, -0.5165666057698667, -0.2181931167056149, 0.043715973774510274], [-0.27745837469443774, 0.31982178067979766, 0.11298869007258136, -0.3753506310362965, 0.2145381459222383, -0.24874584821711113, -0.5909277306390359, -0.2560165868296286, 0.27750209470216247, -0.10590802322507158, -0.23708907193802684], [0.5172177378703496, -0.21995436403259722, -0.10297464977036826, -0.14174670992963864, 0.32261471852166695, 0.09222470657859536, 0.14808250464160258, 0.2469426161195992, -0.3129371597107763, -0.0027960714872224375, 0.5999814665581205], [-0.39985177528387944, -0.6748166875943749, -0.4484367998571098, 0.16941576190801869, -0.12167667620556472, 0.31053407137649, 0.05683758145060704, -0.08285850539856414, -0.06385141232202621, 0.16862208140644808, 0.033176155654844185], [-0.10473690469780798, -0.14571588141792735, -0.5606584703015496, 0.18332188335158436, 0.31709421552354033, 0.33513689962072096, 0.47431109658898196, 0.21538882549405458, 0.3393200133106519, 0.13508433474764367, 0.04730259012030187], [-0.01154957514174603, 0.7323242950584515, 0.06676137382284081, 0.10371908444397866, 0.10918735606340445, 0.3011064202046524, -0.38344364984605617, -0.05263180234391377, 0.15017038437382652, -0.3440410163247075, 0.2346306569356302], [0.12345677647870873, -0.0499461145570622, 0.3053286977986091, 0.4677043867941611, 0.3547046790256791, 0.36375472048750185, -0.3360021123510013, -0.5158908977268505, -0.05159564702868628, -0.11357028813331126, -0.1325018409526792], [-0.20664488330840092, 0.24520355839624777, -0.1876848105791378, -0.5803378556876072, -0.4202989745008615, 0.23499066060564172, 0.1556781161660422, -0.13948958478716747, 0.4919160083064627, 0.013832507958184746, 0.08612744119051546], [-0.1799554468280921, -0.6055013936532724, -0.23928942498190311, -0.12243133385170317, -0.06712022950514425, -0.020096677633208417, 0.08758906735235594, 0.3257477177538389, -0.27083369208727925, -0.4532449992118601, 0.3622994603109101], [-0.06603460494794493, -0.0782353399693267, -0.21216545150415414, -0.3526526250449646, -0.07856080366852398, -0.5010381140571679, 0.4117413296517067, -0.3304646479032043, 0.5007493295647821, 0.1079194353567841, -0.14763236945442887], [-0.3414607396948222, 0.14715090819128557, 0.16331512044035806, 0.30707053107847376, -0.05013132105039505, 0.322523451350599, 0.17145923029213436, -0.612981930713893, -0.1778948178285623, 0.3771921719308352, -0.23491890518359507], [0.23950495309155484, -0.17941920821334315, 0.1380403069695816, -0.48172725219093276, -0.33592597328014484, -0.12184415258476736, 0.2282536075876727, -0.31673125071720165, 0.08964712353652493, 0.39277008968450927, 0.4657405410815052], [-0.15370132161408917, 0.11993565095948429, 0.11037243672735428, -0.2076086516565688, 0.03724620907299471, 0.3432970637805648, -0.6158111147480887, -0.44890381900647314, -0.3608401695020398, -0.1787147513111578, 0.21115208787080164], [0.4482021117580018, -0.150848336758969, -0.05623898386395877, -0.3984006452889573, -0.11707529611146729, -0.1993884646967204, -0.649462609246036, 0.048914378033829115, 0.020584645628613653, -0.1753747081387099, -0.325018539392463], [0.3610141719867635, 0.04121723968381368, -0.4368096702347395, -0.4673125545179142, -0.26628248751501066, 0.07822921539532582, 0.07863427364283636, -0.3061974216452065, 0.01821114790497483, -0.07397412194211064, -0.5253722444322085], [-0.14021416146718818, -0.16193438995241646, 0.2974631797571615, 0.4513631921940332, -0.061920797070194884, -0.014815273197607434, 0.21031839607926867, 0.5164000490121361, -0.1964116652185048, -0.554940587421966, 0.020274469536819627], [0.006328050289932858, -0.20133665985012994, -0.30417041899303315, 0.01234789987374886, 0.38464592532522923, -0.2065812574580293, -0.3774899707394783, -0.049141576645420515, 0.5186468776176022, -0.4826703795656958, -0.17100946002873213], [-0.0614692437352994, 0.18911032117638188, -0.5439715477768708, 0.24896264751084315, 0.1873162513370949, -0.4383573722234352, 0.21480440594483605, 0.032991514280179844, 0.054318653977670904, -0.0680831831233862, -0.5661374402326829], [-0.1501504922640122, 0.38659819825845526, -0.5890557149382731, -0.07574284795348593, 0.5321675520468044, 0.05277120676124706, -0.18487554724151178, -0.009580144625293174, 0.31848344095802716, 0.19033789568362391, -0.13173830463268457], [-0.14121399872659507, -0.0051946728684553745, -0.20978607315790915, 0.16764946344604373, -0.25416171645797403, -0.763499024385343, 0.014176679828134139, -0.3911528005922466, -0.20328015165053964, -0.17138913337904263, 0.19101727080252667], [0.6786082468706924, 0.24619590860337756, -0.05432943960539232, -0.06960576245155076, 0.07590691169990729, 0.1967587172875329, -0.20416141989249786, 0.12014287544697679, 0.398018002147028, -0.4545891834483944, -0.07362111099891247], [-0.2381153891261322, -0.10120465252783153, -0.009406831025556405, -0.17313898710263573, -0.3248573188960648, -0.150571464046654, -0.3189400088237545, -0.4203049978286249, 0.04837640222230662, -0.6637968296379335, -0.2311785268144651], [-0.12866419441285623, 0.5455823492995783, -0.5312079740819083, 0.2973774049513037, -0.035258315195388655, -0.14661390951264078, 0.19753506606996535, 0.31231769646384666, -0.04324981159908223, 0.3796221580699512, 0.09942550125232602], [0.29549550195758995, -0.29581608553067923, 0.021378928206262856, -0.09311089408088044, 0.2051394078224368, 0.1914706028383491, -0.6512336551479848, 0.027529315264296094, 0.1444082816379985, -0.3321207074187046, 0.425774979778124], [-0.23372816033754729, -0.4619305229550627, 0.23068868101888046, 0.18979807591387493, 0.2513770811201376, -0.35210538640168937, -0.23691362633545565, 0.2542387895820777, 0.06923474514916192, 0.5724849819570222, -0.04779318819149499], [-0.22892085674483095, 0.30255642839148084, -0.35257965189984797, -0.14121701065163902, -0.08063362571127951, -0.4263550858331005, 0.03373122289639692, 0.15893484737286015, -0.6876271951351779, 0.060728913393005256, -0.14353575033773097], [-0.14394122355309105, -0.18581162384279284, -0.3283785580031108, -0.7809112664333225, 0.27154234038824016, -0.08978631343158891, -0.13208769255571534, 0.07605174925296126, 0.320399910059584, -0.029081968576822385, -0.13627313070985794], [-0.02397328094524585, 0.2038183682383882, -0.16065195700247784, 0.20533098501770852, -0.3096805321548249, 0.15234041762768005, -0.10049585377077332, -0.2624332444630481, 0.7031864089376783, -0.43613603996401645, 0.0845426492306739], [-0.408742938890368, 0.2556751398108812, 0.3252821599888697, 0.43759915706393454, -0.1876471062947313, -0.0935402075641972, 0.04691080799819474, 0.08966163642912622, 0.18587237797733122, 0.6175197429751087, -0.013330910499170134], [0.23835231679906244, 0.10654361021268467, -0.03899865777931092, -0.11993115549655319, 0.2672356235486667, -0.37227038695666287, 0.4019734363454874, -0.5306098795850375, -0.018434849591041743, -0.0978916239206528, 0.5028717866214187], [0.4412387994690021, 0.4525256544359781, 0.22735326441337855, 0.35946724529055296, 0.1360296186860962, 0.13069978614612907, 0.26174861709895964, -0.4332506146206869, 0.24308617893361323, -0.2362454878280262, 0.11364374534328463], [0.07151862641031141, -0.21598767213775835, 0.40425820228787324, 0.1749649561232306, -0.18620122089405514, 0.7694300049599069, 0.1952103284157513, -0.18147925175108043, -0.19667935932263947, -0.07189964908403591, -0.1122917330854743], [0.43844378223488467, 0.17239904811980375, 0.2556441265857766, -0.08591511306462259, -0.21245303906988966, -0.19902369621218619, 0.34723220076787986, 0.6117792937711517, -0.32408068530629425, 0.05173844891967648, 0.13421737305507378], [0.23854985920565688, -0.32376998781568417, 0.0003697435617954701, -0.08626708419934277, 0.24567188412551055, 0.26080602503007105, -0.1607264882254208, -0.6562646651469756, 0.0009829941008863742, 0.17921495503281162, 0.4624014215721089], [-0.23932219398821306, -0.10693473826664825, 0.03967415062298223, 0.11931242473269864, -0.2671559679263283, 0.37210317446517427, -0.4017942439857563, 0.5301783538485305, 0.019890853600794976, 0.09705976136051493, -0.5032924874519743], [-0.07597478948020028, 0.3846166292087276, -0.1876543096036786, 0.4838573160708532, -0.3366741415659371, -0.05427053745991123, -0.19939484467454985, -0.042552052381515, -0.34880419297625576, 0.2672020397804107, -0.475437474848994], [-0.11468853840392952, -0.3825063420396302, -0.5044048445645631, 0.19924482770795762, -0.3048663745731235, -0.1514318888555834, -0.45419830237917935, -0.1628359412710148, 0.09566891970900288, -0.27677250002332654, 0.3346197318460637], [-0.029212386307623378, -0.23866706261530019, -0.3232467457016474, -0.032238752247881586, -0.6933618707413375, -0.14381091391775652, 0.03811980414164691, -0.009096617859348788, -0.5104533534804047, 0.1630462845951971, 0.21573601060518316], [0.21793124298274263, -0.08822549364788643, -0.32826001517001185, 0.041254797405971204, -0.23309475313583586, 0.5862165943479684, -0.06744498365992235, -0.179581408155567, -0.4429892341115257, -0.1272534951825868, 0.4336488887969718], [0.3979850038335755, 0.24393711524115763, -0.06283295781132713, -0.1498542548767212, -0.14260267942429888, 0.19588686156398016, -0.0471934816281727, -0.21123368639738713, 0.3062497319639893, -0.15901750026264994, 0.7287446719064523], [-0.2928289697515936, 0.82584206175377, -0.021217053223106002, 0.04225807903345121, 0.2954407260107495, -0.09251977270872844, 0.12030919339017272, 0.042506384526767, -0.10269822667332171, -0.06531424656341597, -0.32103126434644425], [0.05232255715176991, 0.1664838134172058, 0.22699174947779371, -0.7199167346841029, 0.02836417489688649, 0.21432319992500332, 0.14838557894648616, 0.37598614514498857, -0.0056101733636666935, 0.3390264983596592, 0.27321579056640466], [-0.33779574893973885, 0.5245907665606706, -0.3108568051023499, -0.2973502143927993, -0.23222643577449117, 0.1795405515343763, -0.09947993901745555, -0.4816303929550365, -0.21918771170295778, 0.029036574615900177, -0.22076018646918633], [-0.3048324099448606, 0.10900130197538646, -0.07493627355538371, -0.3161017402301269, 0.34487051630797505, 0.0748806475240684, 0.18872706921421287, -0.34173182531411733, 0.24520748835635378, 0.11919071537303316, -0.6621070096955421], [0.2517907331252797, 0.14611958024151123, 0.41415161055581845, 0.11247760101225655, -0.27691188562402175, -0.08686654303503766, -0.4458413141436629, 0.5398455283194946, 0.0787726569261322, -0.3602957143501174, -0.14361731763945676], [0.12948375193190031, -0.38317293697985755, 0.5743016865278057, 0.39854846085196866, -0.11871067494636164, -0.04384679094276777, -0.5539238133292376, -0.004164231235162776, 0.022442658068189125, 0.06059379526028317, 0.14391031030929857], [-0.23880192815313656, 0.5056689103728133, -0.2739123253507835, 0.11202988903024388, -0.27623237641653114, 0.12128049213814948, -0.4736510254935941, -0.10542583631306277, 0.32131968163050234, 0.3981396039094734, 0.10704796918090623], [0.2551136181367743, -0.03432901396517348, 0.03553756885526641, 0.3151178195083916, -0.4185105343203147, 0.0024305538865081917, -0.13133687583758644, 0.35241917911722964, -0.20069443129299164, -0.06928643966732907, 0.6866526840419217], [0.06688089574052897, -0.1086802839745773, -0.1616286761525181, -0.13077781909307937, 0.13755914374128592, 0.41599234349610464, 0.12457602294723769, -0.7028773327487914, -0.36318751655365317, -0.24067040937115866, -0.22166095360184193], [0.10193082253522505, -0.17346485706041942, 0.5160565751226865, -0.22429517440643654, -0.1918863869947319, 0.442778717382334, -0.2208693677924252, -0.014263710327274021, -0.11329607925186644, 0.10062582359726334, 0.5814427484305694], [-0.054098772732192914, 0.2171236533391771, 0.22951393798375447, -0.5362225897094551, -0.01311879024431075, -0.44313808372554747, -0.31634295194782697, 0.5104642063084479, -0.16164444460553704, 0.05756351219826829, -0.15194344679175192], [0.24914885180436042, -0.09598458220479594, -0.1811208661225631, -0.2929428414709994, 0.6041394259480425, 0.2670738305025558, -0.48237548560797006, -0.2939981118672825, -0.04403220707167982, 0.009702945717886702, -0.22940068629594695], [-0.24765680582480906, -0.3478137531972185, 0.07960629415667357, -0.29620703877983884, 0.0758347059729004, -0.05884818325074523, -0.15920796895340464, 0.3828091002497098, 0.04198162605135517, -0.5487552252431307, -0.48950707620187905], [-0.2658500619087073, 0.12197775898820414, 0.07332786773431409, -0.40009578275369023, 0.3422297470001289, 0.46780707511898956, -0.32080938781001206, -0.10758165803506962, 0.4381762656795508, 0.10074813465761627, 0.3104606209714393], [-0.013165708623943126, -0.10856156767279278, -0.06756763423559575, 0.6667454959439277, -0.12436173714672517, 0.02711228274225521, 0.19180217507943878, 0.1922001403630697, 0.5254442913230991, 0.18277830072470827, 0.3734924526959883], [0.25848655681642585, -0.21356507135140465, -0.29824508819291196, 0.09945896546935877, 0.09643781478350638, 0.07768029355621585, 0.7340512527803914, -0.23655134821227608, -0.057378311747032014, -0.0309982322533427, -0.4175607962464246], [-0.6354300575930453, 0.2574113147397299, -0.11975245169214943, -0.12289519579712967, -0.5731944677136858, 0.1250547986013108, 0.025529638188870656, 0.2600072756702715, -0.09934125215520397, 0.2657799851534979, -0.08700774062512483], [-0.26928274067465663, -0.5652643669563203, -0.04109807044467476, 0.15291519955941885, 0.555749260898839, -0.05860069011947214, 0.36486590509358974, 0.11746565976606278, -0.142916863777096, 0.13363871596946597, 0.2922152686285746], [-0.3914563379233594, 0.49320467801579915, -0.06190174008085919, -0.23707674258552916, 0.14065501590052468, 0.30208907376876437, 0.2531288981379985, -0.07342246401036057, 0.12698463198265145, 0.5888741196310919, 0.008325200870934933], [-0.6920507436887413, 0.1512788360374603, -0.470079682518458, 0.21206180403984123, 0.17367143644545316, 0.21811763584983143, 0.17705672689350682, -0.040087974905011155, -0.16744978451641382, 0.10380401292294184, -0.2876238179780177], [-0.2078548198403809, 0.057345240635689215, -0.36478519011891136, -0.24146847143706332, -0.03892111360085053, 0.26003232293348777, -0.13200542175930968, 0.5756525329790392, 0.37742474232549217, 0.44793721508177026, 0.0332042570988439], [-0.16449384742376721, 0.21464388076292754, 0.20276625540475182, 0.008189706496037487, 0.005475117911505234, 0.067631128217558, 0.20097518065675893, -0.555567822132715, 0.6199940013720482, 0.25514681360624286, 0.2873073617351782], [-0.27502020718165593, 0.04018015717558945, 0.2940884777737914, -0.231233920630709, 0.35115742076478057, 0.016388531491026762, 0.1734786897716376, -0.20031831812339845, -0.16434782459398897, 0.4035048117038158, 0.6317939053056496], [-0.11715209721745266, 0.5581606143687956, 0.20854857987016642, -0.5330869663610881, -0.36835391076572827, -0.05415894946049668, 0.3245810932197696, 0.11451892787063477, -0.1823949850841891, -0.14515410658121616, -0.18877229477432964], [-0.15141448887217532, -0.48658200924672873, -0.22274687932519538, 0.1744441873010092, 0.2423986039396322, 0.2681458120580792, -0.4242098950550251, -0.13278990123225187, -0.334370800040645, -0.45109239276892005, -0.12934458907478466], [-0.4539722512763383, -0.17499129514759607, 0.2457753127554661, -0.2997114665308774, 0.0714177416431728, 0.012929204881383629, 0.03657192745348478, -0.1515673402487796, 0.6855985538175529, -0.30895459723621965, -0.13408441872708815], [0.15031757442796884, 0.1340320959095671, -0.01759250775131802, -0.03576588882337417, -0.40835009625416013, 0.5677204536270063, -0.4481768754658793, 0.31485496887481074, 0.33828579236277045, -0.06810489811816299, 0.22298721215560693], [-0.02950104551272023, -0.20869697906284268, -0.32686514094424896, 0.6201238118130552, 0.11212234347262853, -0.15344691479393466, 0.25983804807822997, -0.04417844175087745, -0.23788962082619247, 0.5283747981299696, -0.15107804736531197], [0.1345246580336247, 0.7288451179121103, -0.3169369392745647, -0.1474536207133968, -0.03658071152465712, -0.2656898790856287, 0.06597510711100558, -0.3479610376042837, 0.33827388213992055, -0.047055687654357914, 0.12039103333146318], [-0.029004209676193382, 0.44514562252329526, 0.043059209843618024, -0.5873582174791436, 0.350074846248175, -0.41708256456999165, 0.19873667616169877, -0.14789333465330282, -0.13284682801563868, 0.27990969117991515, 0.016842681374505036], [-0.6141019028863739, -0.013447830432969406, -0.22063983905217804, 0.06314793527185607, -0.20124863153763187, -0.3949071783444867, -0.12149170671254297, 0.3000329818547909, -0.09074779702629393, -0.04156530354261192, 0.5087561843298014], [0.03464981189793275, 0.20061966233287415, 0.09511615116809308, 0.3637071479226615, -0.10604933319340126, 0.5821939116633843, 0.2755622584432753, 0.17397694016200485, 0.17021757128897888, -0.40048097484714473, 0.4140813824993891], [0.029669003632618384, -0.0474430070487564, 0.5922517418937275, -0.29710076445795414, -0.004880642223748859, -0.17456770379459882, 0.3411217423968787, 0.4539611065505409, 0.28000275590385443, -0.3539628172804404, -0.034702574601821995], [0.25122059993697765, 0.5695078656590314, 0.2988080516455021, 0.17644486353463978, -0.02487434124095505, 0.2982825175213464, -0.07413185726247261, -0.28261651038512153, -0.5397404136214647, -0.043307201423809435, -0.1548415784533911], [0.44735678720173416, -0.027149818649356828, -0.16635572794940007, -0.013059403656752322, -0.40157806594824413, -0.04540855778555052, -0.5737945993684738, -0.2622981351304838, -0.13412186410395913, 0.2716802637809332, 0.34369134664601814], [0.4863295959050687, 0.008298315288542885, 0.12763890902017966, 0.016422637164616585, 0.3692796310737772, 0.26836428630669457, 0.6031728518237774, 0.25473362762170865, 0.2766289473219482, -0.17747751264844053, 0.04168788434455736], [0.557311339647117, -0.2006585538870198, -0.060657953918902385, -0.5802883334845915, -0.0758364774294139, 0.4581320150813767, -0.18501334837340902, -0.08412991961316917, 0.17285721984821362, 0.1082149190608885, 0.10095689148276103], [-0.0744321601390759, 0.0631692969140245, -0.01955825908963653, 0.20312914571213594, -0.04504538812794943, -0.6536283116178874, -0.4695386019827898, 0.14912853275204618, -0.20264543914651156, -0.2556559594093232, -0.4128383458048643], [-0.1518989017953982, -0.2657950751354811, 0.31550463236593296, 0.017229159858442818, -0.2669750086536301, -0.06982548358375337, -0.13836103328020524, 0.20127032188458616, 0.4535806362420268, -0.40807651441972614, 0.5462353687499636], [-0.23144752582380818, -0.13899052321038946, 0.6051515365543363, 0.060625331340783226, 0.11562965463726887, 0.2700903756740941, -0.17393766191608592, -0.14497922482301281, 0.3447629483897667, 0.28260234310554205, -0.47001273963150686], [0.3161520690382188, 0.34075704313307575, 0.021803360449778025, -0.20856761657347825, 0.5058602858625455, -0.06305755141172803, 0.3960595987821687, -0.23793844355078292, -0.2304105861690025, -0.39246508137855374, -0.24390571735396757], [0.013361359634666585, 0.16839469892713999, -0.1468401861667434, 0.27575114784149835, 0.3539648918808852, -0.015270729991148643, 0.5297528012465189, 0.424474795904431, -0.5117137552067492, 0.018617382403638742, -0.15913882861154827], [0.21403156293825581, 0.3505148303528575, 0.2589789041758551, 0.48580789731536844, -0.1322638843989003, 0.5046686547305417, -0.14223638225372712, 0.10230035369675468, 0.2461417772810419, -0.12952062531725128, -0.3847185386412214], [-0.007809354777985758, 0.1462763284375979, -0.23046335263940707, -0.7065060181673529, 0.10612956348730483, 0.23556488398404632, 0.10352849894931293, -0.36806988814989944, -0.20937310010283497, -0.06801928047330788, 0.4060375968647548], [0.25449174097772737, -0.005900086243062387, 0.3065851861172939, 0.01658514106532649, 0.44843532675174563, -0.4665364523198367, -0.5511261702813647, 0.2388614812024227, 0.24663978287097282, -0.002392379981474733, 0.023395023739199976], [0.01788404691769278, 0.0015844094337857328, 0.08081663045532783, -0.37373779565286, -0.4422371491572399, 0.19995511191416362, 0.45091075707994965, 0.16182745283481806, -0.13941585406233792, -0.27958376969714943, 0.539257025912721], [0.22537061316821738, -0.002239057620810813, 0.44589960102093135, 0.5597254796473892, 0.3856995999133549, -0.21877111290397452, 0.021577736554385114, -0.17098374830726157, 0.2870978192671166, 0.3506844070169466, 0.07316606670231943], [0.3394421840417147, -0.6131239362435112, 0.30878542992612606, 0.4707441198673966, -0.01817323030513476, 0.026666064934331744, 0.18840380977680743, -0.26133926974075417, 0.03387692848738695, -0.010306263986399097, -0.29295077102972883], [-0.40508243507872554, 0.20890094327244593, 0.2293650789969088, 0.13238782228388093, -0.5369806499444799, -0.13247527719263658, 0.15428820632669696, -0.3051891703414353, -0.5097775092583502, -0.16412599694268193, -0.11171433271028486], [-0.4141805233085362, -0.1494568757415797, -0.019386358845207646, 0.12945525539217953, 0.424160218537513, 0.6494749284263333, -8.566693703864723e-05, -0.24888036022283536, -0.24530038599550774, 0.04887688977126176, 0.2505002952824456], [-0.3443182761694546, -0.023123948133118997, 0.1490702672825814, 0.3406921384536586, 0.0470937680722509, -0.39844665097653037, -0.40639188995934317, -0.18963280471074778, 0.594511526561201, 0.009916951179512365, 0.16426290901761992], [-0.3760025724123699, 0.09274460199898048, 0.29317781399664333, -0.04419639640501518, 0.30889320288072875, -0.6407763322021414, -0.2916558393456786, -0.06330395606711854, -0.32833230217061976, 0.12598470093147907, 0.20823032577488446], [-0.4131511053198221, 0.36309747660479524, -0.24081167250995275, 0.1319993202030256, 0.13606882752150326, -0.44694285762045216, -0.02367863732135809, -0.4315856605481257, 0.019025147879568882, 0.44893025538713105, -0.12268850799554502], [-0.4036016200898392, -0.4948982042885807, -0.008106439444059416, -0.3530616492575157, -0.5704504896554873, -0.21869331786241497, 0.12271767215104251, -0.14848525949780772, 0.16988250759220952, -0.10911204014619388, 0.12786604573950722], [0.09380129027402934, 0.011828069627130535, -0.13534333295778425, -0.23485062760602982, -0.04317829436932544, 0.3218726574506441, -0.3586435647416623, -0.05091365048276263, 0.6746716593810299, 0.04570710319231111, -0.47289958060829224], [-0.07167795306792843, 0.21591794509819442, -0.4041491154413364, -0.17506431058557312, 0.186219379469751, -0.7694457776166631, -0.19520661252037863, 0.1813976915287241, 0.19691340642618546, 0.07177913940310432, 0.11222901205166173], [0.4035467385225909, -0.44486056432953497, 0.5283915243080818, -0.24390589464216028, 0.009877561297282376, 0.24349930156993863, 0.33450149493223275, 0.11849145983294197, 0.012826541056556269, 0.33889128748218755, -0.015120932381860724], [-0.06686733622710068, -0.017438078193880026, 0.34921142248074616, -0.283075450141785, -0.3412825742620161, -0.657317634428573, 0.2923913878430308, -0.0025222983524653044, -0.30911084822945056, 0.2518289670044816, -0.011732258763109706], [-0.09959757715395887, 0.18666962608840335, -0.38951037915378994, 0.12995966802205483, 0.1318827671131829, -0.0274388072471061, -0.35377051155803646, 0.31369658178006155, 0.500836533202335, -0.1510631983863484, 0.5208306125509468], [0.16011286270585204, -0.4439559599256141, -0.5508709801419979, -0.44276401611626576, -0.17638090639856174, 0.13593146844910578, 0.43412465122194954, -0.03984124336807699, 0.08492970680497348, 0.0020670877873757943, 0.17581727001165587], [0.20553808362830997, 0.3135294457344701, 0.10328916681926946, 0.2270358834851677, 0.1531678360570489, -0.5701285311755719, 0.034854577950702535, 0.30708052151978904, -0.25041841191663905, 0.46283478179651216, -0.27621333391502056], [-0.2171626143978713, -0.06928154519778892, -0.2741582868451045, -0.3762106431051065, 0.14717998449807726, -0.3010612891095753, -0.5727857097998773, 0.10452629908606301, -0.3047042950348193, -0.39041782679154674, 0.18644945989043685], [-0.16468204892930494, 0.4421368825264608, 0.5539874641950302, 0.44003206385313953, 0.1768638814612914, -0.13649242159019784, -0.433359920384967, 0.03773909542502866, -0.07834644066127579, -0.0057575530990820285, -0.17764313763126655], [0.45663542514410715, -0.1755946762484556, 0.13573685573497957, -0.06238059458015378, -0.012714831425550204, 0.015097335298032394, -0.470017919874776, 0.5795864584574729, -0.18412913768753458, 0.34978867311759543, 0.1576458248821598], [0.3522167693150451, 0.35764362304274055, -0.04527077684155717, -0.43806220729169587, -0.08128228532741621, -0.15397311271858682, -0.40397666638011887, 0.21799644155028644, 0.47021062711018147, 0.23211447178185912, 0.1951336949443195], [-0.5119805064780248, 0.042961807508300635, -0.2367533617962973, -0.4133006711407961, 0.40676770439626897, 0.03545637240932741, -0.2996136387416606, -0.1881977816067325, -0.32124097433646054, 0.3370591819545409, 0.02126339710366144], [-0.19373507183763033, -0.3436781655117325, -0.21999318200556023, 0.09621503644255636, -0.12351701017193778, 0.008741179204136883, 0.27533697209415164, -0.21270047944259418, 0.09534471924944923, 0.024125603194413307, 0.8004000529316295], [-0.24615125797863271, -0.07052252885774464, 0.3518178312857202, -0.05456005549074525, 0.3781568544671454, 0.13317116526735925, 0.3097936974893418, 0.2853369591072816, 0.5812491526532891, 0.3315692700522016, 0.14754086103289463], [-0.18725128678160746, 0.3988175138068502, 0.4686304978504943, -0.2227208340865039, -0.05581258298854999, 0.34561422848021994, -0.018589647691622614, -0.4094924673851579, 0.12500989574836457, -0.3576775828669003, -0.32016840929880147], [-0.059227554811352244, 0.3912007730820594, 0.551976312141195, 0.2555365213553682, 0.21869265597886148, 0.521314252967558, 0.031125097847358372, -0.09720199361687501, 0.07945042690448689, 0.2752760295913177, 0.24774179859581882], [0.04440671794543107, 0.2467618944960928, -0.14155676463545339, -0.2339089579646086, 0.32448326401187455, 0.21773312220830063, -0.6132779501952794, 0.5275302343972331, 0.10149421186254257, -0.1690192908263559, -0.12814524319508408], [-0.4543178747017763, 0.03843740553002818, 0.2508536451021899, -0.5358480541537418, -0.24452853462728835, -0.050740865300424834, -0.1358932039320012, 0.04246353516928073, -0.5013568745153744, 0.011271525538638826, 0.3285307122888202], [0.13890618362502996, 0.4388886008706653, 0.04475203510578784, -0.1049487275589931, -0.1496041584452005, -0.5067810569547816, 0.08032576038068048, -0.4231219220073998, -0.22442548996638134, -0.049439638259352534, -0.5075046572791416], [0.035930841922109547, 0.165701030582369, -0.40752804008175003, -0.35789587855628435, 0.2274690404300647, -0.11195730343475059, 0.269425837393066, 0.04752567751376455, 0.3510019457827873, 0.35426556828342665, 0.5378211104848225], [0.05743530460891947, 0.10643939855058245, 0.3497596495820447, -0.33446217791552324, -0.7469654283567004, -0.09296181305483127, -0.15167521626866734, 0.3004723032075445, 0.06689753774042712, 0.16261907550447516, 0.20091443189506134], [0.4531759787702371, -0.19060243119260073, -0.26171904051349426, -0.10242519233776304, 0.5292745080712804, 0.13492798418076343, -0.15890134415056714, 0.32723923578655834, 0.4386251442935764, 0.20027551970402868, 0.12704309456593163], [0.47450542060184386, 0.16871665279561324, -0.3911747006232658, 0.16877932707907975, -0.01579493457515752, 0.22788075915548497, -0.37632596183646816, 0.17102806129637182, 0.09278424007972008, 0.47425725666535995, -0.3290826353221433], [0.052981843747372706, -0.21373354465982722, -0.03261829399324739, 0.05069825951944627, 0.676798374046627, 0.17128375923322484, -0.0203299867526302, 0.4113624812406833, -0.02602926343073348, -0.5187470688997298, 0.14516893892654512], [0.6448459624458114, 0.11503941246071202, -0.05700116449525486, -0.04187016546630157, -0.34541460654969025, -0.02563884989547237, 0.09266637898131432, -0.33256909153376357, 0.5291811334065173, 0.21096319987867557, -0.04734312677296707], [0.2558122070225587, -0.3608205920500848, -0.1552503132342515, 0.330433043916991, -0.25222624287147893, 0.23885805461852533, 0.5749994051013478, 0.25505960903621155, -0.30218861041567197, 0.12250682465185626, 0.2200070739549967], [0.11914879466957741, 0.4623017766788595, 0.22040506528233986, -0.09043680601928829, 0.15948245935243707, 0.35430299160090356, 0.14417139748131033, 0.47354768269043257, -0.12001909696268186, -0.5151774726863247, -0.19877863816925362], [-0.49742737382581254, -0.060851838403160316, 0.322376966282847, -0.10139008605351994, 0.08120090509545197, 0.38896119571216126, -0.22984513626601116, 0.337841033732667, -0.1692779510196757, 0.5131523606079801, 0.13351435951321355], [-0.15413067404456318, 0.1830475678760626, 0.27103813022321194, 0.03852172360883363, -0.13780670615598736, 0.331236732040257, 0.25462906180764333, -0.5965572274168139, -0.18302040306066988, -0.20494561283208684, 0.49281600442597084], [-0.18159568343482976, 0.7150586866052225, 0.09922954389343237, 0.24385961424556205, -0.4383805042586749, 0.2576122375350962, 0.28505728342776954, -0.1676116004270349, 0.12625518918736064, 0.03952517415981683, 0.03169576569507916], [-0.30312078463596254, -0.12278959605396413, 0.6964814495749827, 0.13163004499613482, 0.12247723792051654, 0.12873850453819966, -0.09663842386494391, -0.2441767544546722, -0.5270335547776667, 0.05513172836883777, 0.09637532151864026], [0.2190079860259893, 0.3782104034813443, 0.06052151717048642, -0.3047997775051341, -0.10492998499179614, 0.14792511500859407, 0.5486653725561502, -0.5697210101273172, -0.029888162521742166, 0.21104546159606014, -0.09211559805455306], [-0.2419736727979793, -0.010700000919681854, -0.359739645695626, -0.3635738931193072, -0.014335717387375397, -0.28296347231710917, 0.1491657431140505, -0.07249755099546602, 0.32304672993180206, -0.5532829522789, 0.40183864290268556], [0.5612424290140563, 0.08648907815677392, -0.36416037669339124, 0.1383156843989223, -0.08853977606043863, -0.3802896923806805, 0.218561719602913, -0.30923949202413464, 0.07807542019976113, -0.4603944645696535, -0.10893071974920131], [-0.04800472908553348, -0.25536293469560856, -0.22408176063562388, 0.3672163285983002, 0.0523771955572199, 0.4922357034281236, -0.024705466539145716, -0.18791616462050956, -0.013716244503054026, 0.040723723509626296, -0.6816275300808506], [-0.16147313789614356, -0.5685147564773914, 0.06518395155281496, 0.06223325345617879, 0.38843470276758174, 0.0647082692411571, -0.11335375748887194, -0.4460995135843994, -0.3018371719265801, 0.33637758626095154, -0.2672403119943839], [-0.09877316096169349, -0.31497044573473604, -0.641137027312077, -0.1724732867872453, 0.4668935869830534, 0.15596251799440664, -0.15556932107617993, -0.07742910395091418, -0.008614674655585984, -0.08466013788120784, 0.41289368921339253], [0.033496098345149945, -0.04907051537223411, 0.10316807126694215, 0.40288654411669317, -0.7786107764834043, -0.30414230695452155, -0.3041632281835196, -0.06245646232259429, 0.031039675604720162, -0.1536359243156406, -0.061547182347962665], [-0.09154202966832935, -0.14584984471561097, 0.11095485148671301, -0.6314842905668788, 0.03656805080057887, 0.405609969990747, 0.4546048657505753, 0.02615732910062595, 0.08833254326348694, -0.3166396123642057, -0.2792754000209589], [-0.4728309649787129, 0.01659203159886095, 0.020327553044978217, 0.159795820122403, -0.16142901703323678, 0.6548744997287334, 0.1256122020298633, -0.022060967705705353, 0.5147142507322294, 0.10776212511801489, -0.04979140946351512], [0.14472082818200002, -0.2734108093669925, 0.08784046205158304, -0.27971915594873276, -0.23740462924661168, -0.19701101111065664, -0.17398368195215907, -0.36275414283544966, -0.28639883944358185, -0.3859946479922994, 0.5747106302337631], [0.09386228733782832, 0.3801126763451815, -0.12696745942692067, 0.15996746657129343, 0.5045617799354191, -0.17522984675472195, 0.5758905388534804, -0.16772051090819998, 0.267629622379923, 0.2883866418195981, -0.07164674969671053], [-0.5727321794188615, -0.23594516214717623, 0.11130979473087362, 0.6040116852944306, 0.055590054959233894, 0.17286592103022017, -0.37500770789858406, -0.04886269443123148, -0.13010049521944456, 0.15587366412851333, -0.14789787680219232], [-0.4332019371718276, -0.40153750620065265, -0.12218301695441203, -0.029129231234609244, 0.5243098119239105, 0.3186186837598828, -0.17572235992310792, 0.17551533809145217, 0.32797995081308245, 0.05957791930957549, -0.2934339929061656], [-0.09882389560441779, 0.42103367219013027, 0.13979764008812748, 0.3087792634072796, -0.22954673615386553, -0.14512739791255547, -0.32867070388594544, -0.7085227231448822, 0.0420998326636471, -0.10256869890009511, 0.044734667110192625], [-0.058622924473236825, 0.06121308147647089, 0.16821301899554464, 0.3950106366790433, 0.23675232317820458, 0.2593060941428435, -0.5072481459145187, 0.33592571661991705, 0.4400183706340505, 0.34637083421393944, 0.038213683850955395], [-0.144438341113783, -0.08391402653308185, 0.25444051597594736, -0.18053734284250156, -0.08437430850073278, 0.2978873845900444, 0.0707792713521872, -0.06469854705938696, -0.5406012529624266, -0.6892720453916208, 0.04863230506624487], [0.5512452866135993, 0.07553556687842018, 0.2862114075838582, -0.2373924656977467, -0.28562799736858185, -0.05990949899998246, 0.10417657982374645, 0.008102622150818336, -0.24219750864391132, -0.49904610599449445, -0.3851665837000448], [0.4925096338664173, -0.4231182085616603, 0.18992634480192394, -0.07052223710772268, 0.16268906521563709, -0.09055753259683956, -0.3571627226033233, -0.24412733357238076, 0.2606275820978611, 0.4673345705588039, -0.17087930916567468], [0.07469335288853206, 0.09594915923437934, 0.2627475293505956, 0.8229336242194101, -0.2464781880423969, 0.08288288961881156, 0.1442611234968251, -0.09676494566555718, -0.33669814875158727, 0.07341487794610167, 0.14969122591090922], [0.11187852179685828, -0.20031631159095797, -0.24117183581491047, -0.06826561983260858, 0.14614154922693912, -0.3336734551200527, -0.24720238005497974, 0.5811162206915244, 0.24873483027203513, 0.17470342256337096, -0.510530914897438], [0.07011738170270596, -0.5358717251060345, 0.5495628519195874, -0.3349004268800869, 0.015239283832074397, 0.18065796150281288, -0.16942245655974336, -0.28654323989752, 0.02462891215448847, -0.331868040684938, -0.19830257485680666], [0.5856556754957843, -0.2835610740398051, 0.11614300783114294, -0.10232286660158461, -0.18023155206681293, 0.23211866072484513, 0.42556708052444064, -0.4063073599356873, -0.009439277241147558, -0.27895083368855256, 0.20538553113559918], [0.11113924950857798, -0.04904688750295052, -0.005816599182836551, -0.18036111658090617, 0.04063857972141847, 0.657677631081639, 0.4642071587218993, -0.13192009537309224, 0.14891592719655644, 0.2851399993363123, 0.4267495446880064], [-0.09273690984224321, 0.48692837758810525, -0.30340857686979883, -0.3609577226197839, -0.18575203925040126, -0.24945573677650876, -0.04815669475250996, 0.14148733760578555, 0.18794496852134868, 0.3793172039357623, -0.483403359082786], [0.3315798484358191, -0.3731035414756393, -0.1396812283886451, 0.33133347264822344, 0.164651475556224, -0.7317942036850555, -0.018095859406964124, -0.05221700050306596, 0.13663634015461154, 0.11688441978713256, -0.15341915959032568], [0.08725521654792313, 0.6358633594649122, 0.14987549084920707, 0.0351696794349139, -0.08624377788695362, 0.241509719058286, -0.18597672754575797, 0.5188422168157668, -0.23498561820248204, 0.3646835362218164, -0.0812582368152246], [0.39171817679076276, 0.11338546690962596, -0.2695378738996155, 0.32571527681366813, 0.045922216001925885, 0.31219831538962634, 0.05748257316466197, 0.7394071809430253, -0.0004381783588939453, -0.04742049783525175, 0.05573813534439287], [-0.007637285960232628, 0.004321477968583932, 0.357175322198288, -0.4642630153651648, 0.21528847318538186, 0.5147696330062871, -0.043097120126273376, -0.36528203008959725, -0.21207485921183702, 0.3955498027763353, -0.09353085619370811], [-0.014855488207945024, -0.23540407426302393, 0.12120935324508776, 0.2521129549309799, -0.32802861938830224, -0.2144788504293527, 0.609130382721501, -0.5138136746048408, -0.14465160672257668, 0.19268991058914203, 0.13931916658310572], [-0.12101055403523385, -0.4630388511071034, -0.2190899947584644, 0.08935546669587417, -0.1592792682987068, -0.35456728120153563, -0.14388323989553922, -0.4743784557010095, 0.12271444217393615, 0.5136701942615673, 0.19805451772299787], [-0.086074221603399, 0.20034212432839762, 0.05446484804294922, -0.06953445498771613, -0.674932567693644, -0.17770593532383344, 0.02503399993338489, -0.4278330902063737, 0.07322875814974683, 0.49297303650010915, -0.15964557978480853], [-0.184374364739283, 0.44502678502642884, 0.43299928377488534, -0.34136123151007075, 0.49659192204639385, 0.14720950031292385, -0.24874114808510236, 0.14614525945198906, -0.30926052637506823, -0.025793487335113396, 0.12700093429027787], [0.38580521425372266, -0.3427777244515642, -0.028693092603321264, -0.557115666570351, 0.3347354188511565, -0.11177272945216506, 0.26568072679077454, -0.4088494126970766, -0.13439948677141564, 0.15927319015704533, -0.12938470965492935], [0.12567165516599416, -0.011138571446333671, -0.8355640188007416, 0.16486313968787447, -0.1471066030529199, 0.2444652621380667, 0.10308679211824875, 0.14823234107965902, -0.3139767056398024, 0.0029893841182637056, -0.21480652728621805], [-0.13079464257719076, 0.6073466456794191, 0.14783361353117414, 0.08055777738222093, 0.4048337881350904, -0.24818671902288988, -0.1640763856510748, 0.08429625515750251, 0.27607535940502753, 0.3470108163852968, 0.3599033306772201], [0.09527519020065119, 0.09225512726109925, 0.14803356917044644, 0.4054180841340713, 0.08085815332495075, 0.46452359759656764, -0.4928962122038692, 0.3033460871147217, -0.4425583330722961, -0.13388637741359433, 0.15831832047305147], [0.10991845884683608, -0.2404875859626801, -0.4864136184859037, 0.02447740908993385, -0.15233467782383295, 0.3469858784137256, -0.15498367193705487, -0.18252661844138168, 0.5521136077579972, 0.29733586896609654, 0.3141771599908611], [-0.43759506826864997, 0.14876382491114296, 0.25553436260567813, 0.24749198296061256, 0.668645334647973, -0.0031344043202927154, 0.09537798981979004, -0.02936730326183803, -0.16545518062826117, 0.39497107454794833, -0.13927101104151118], [-0.5479268751498995, -0.25241579333074143, -0.08172105585843449, 0.35633743993224165, -0.03408536515668358, 0.04906426122810028, 0.23466310212227198, 0.6278258245599836, 0.04254952603662329, 0.21664657096700451, -0.029331799980571685], [-0.6691556905773414, -0.2851565964123092, 0.10255318476726896, -0.27592401611366424, -0.17674977382233065, 0.36975954508825026, -0.1337872541974784, -0.18941017240370445, -0.08052637111325157, -0.08379817424441709, -0.38603197009978607], [-0.0631065361800534, -0.6560679602915798, -0.09829374296038752, -0.012551612084425076, 0.18618596888092356, -0.1630375516594188, 0.17939169510139058, -0.5391477883928614, 0.21353897220503895, -0.3467474244139674, 0.07636981374553109], [0.10561757573882295, 0.14612989641061017, 0.5599879248179259, -0.18284300237718162, -0.3171413924918225, -0.3350164964396943, -0.47451284336500704, -0.21501676791266797, -0.3406343232412623, -0.13430703278755565, -0.04683434277669736], [0.027723651887942503, -0.39636830539761775, 0.09610988475359099, -0.15205904098752235, -0.2949521993584451, -0.6595647012914825, -0.44661898219785884, 0.15506360667577557, -0.002185697560549156, 0.06731392859470522, 0.24432136415239386], [-0.2994850100952505, 0.04208824907417776, 0.09909417639798813, -0.23555930057154215, -0.2051092116047069, 0.1990176470708993, -0.10905107211477758, 0.8013626459619484, -0.09438710102064135, -0.20768146479917066, 0.23545044759545258], [-0.2868746013570105, 0.32366592331138533, -0.11230833761184951, -0.09396828776421522, -0.6308074137283165, 0.10172735163896364, -0.2679875001191957, -0.15803008128595541, -0.03376075753758244, -0.3124456477672006, 0.43322142805397545], [-0.03919744462142022, -0.42313524762929533, 0.3511289331771185, -0.39877333937641835, 0.03069013334115872, 0.11719334782571095, -0.3922976822003918, 0.39632662833140675, 0.44709899685806265, 0.10751108744471839, 0.0019593057075531265], [-0.06756522400053008, 0.1084292215911505, 0.16215294344124884, 0.13035630974484466, -0.13745045445427131, -0.41607832253262594, -0.12450335723750947, 0.7025258430451857, 0.3642089607569266, 0.24009964981982063, 0.22144581028705465], [-0.011472251808480856, 0.3153271866189495, 0.25634773696290303, 0.04774261849131516, 0.6366168640711418, 0.2123571711283026, -0.07242026679472774, 0.012197893630527427, 0.5053804941438346, -0.21634177129872165, -0.2728742268523105], [0.5582936451721533, -0.34189674537398757, 0.20322053300375664, -0.06910317447581497, 0.09147862419674663, 0.19161121703677148, -0.34724629208858154, -0.17947743979612532, -0.5693906592131108, -0.04917964751941641, 0.029005017368399708], [0.43228192281406413, 0.15670790192981232, 0.006764771130160862, -0.11876664625025733, -0.426024150202765, -0.6468933395887111, -0.0030953926853509255, 0.2572270997892016, 0.21907163246123504, -0.033924379352539794, -0.24318206953886454], [-0.24237349810134082, 0.17842418088445056, -0.13613966208884445, 0.47992855668310913, 0.3363322640702939, 0.12171068878331417, -0.2279313223668943, 0.3153865956935872, -0.08528196130210614, -0.3949937551865053, -0.4668052231311196], [0.21356914027392762, 0.31081022487807475, -0.04253768367099345, 0.011225511772893996, -0.17898555827351298, 0.6729158472360802, -0.18377619198621978, -0.5404839285364242, 0.17607689643590718, 0.1147154446235215, 0.03064179848687792], [0.17022157019615142, 0.3423431278854424, 0.592284451579643, 0.21558578697694564, -0.4739344800774234, -0.14816056456715612, 0.14480516573304097, 0.10860445544507769, -0.09574557266883728, 0.1399524832942472, -0.3853114018162185], [0.41292058543843896, -0.3631761294893423, 0.2409708895723012, -0.13214748816934144, -0.1360367507629111, 0.44692920688505344, 0.023700683805228932, 0.43147720969495845, -0.01868112718093794, -0.4491102600003145, 0.12261619903287099], [0.3478701736584488, -0.005232088324156875, 0.6352674464118744, 0.09339234247349909, -0.22357789913160578, 0.1039609231682274, -0.0051025907242549465, -0.5741521266957185, -0.006543490523800911, 0.27111233140044755, 0.051533914796260835], [-0.40034824844178696, -0.12197291014485931, -0.24443840794151925, 0.08221107902537683, 0.1458832521519588, 0.23869152220152484, -0.31551990729208723, -0.6516091972714653, 0.3763090710038417, -0.023145182333435498, -0.11742211072953845], [-0.27945097831808857, 0.0013545859339754696, -0.2072662903827987, -0.274456288512777, -0.38945130694987273, -0.2829073320351716, -0.40769291881463965, 0.29124578239740256, 0.5027221420391369, -0.24019804629502128, -0.10221835461546791], [0.004090347874578263, -0.10754999253682701, 0.5663181607689525, 0.3054193865601774, -0.323674260983036, 0.35336091777031153, 0.07064063183831279, 0.5211024987200814, 0.16733066656726844, 0.1683177193920761, 0.10918663907114932], [-0.2564380143831392, -0.10791047556944278, -0.5943207086603952, 0.48078932887909887, -0.06782062285365116, 0.0459211650469345, -0.28071880065991967, 0.20131240588208826, 0.37768321859955734, 0.11171792338290454, -0.23886348073489164], [-0.1571021986538389, 0.13830845167585026, -0.013012958793662387, -0.6105074334848558, -0.27352151491469145, 0.28579455840605406, -0.5634025379966126, 0.0697949012685325, -0.03458629948491138, 0.27802682143271473, -0.16130587586458567], [-0.3535064436795856, -0.22665811513029574, 0.032228507908768744, 0.17660884450205794, 0.13791212680959009, -0.19012932248014733, 0.0400776938569412, 0.2319459109104506, -0.3704487643997624, 0.19477016950448664, -0.7111175608499801], [-0.2956622320447599, 0.39433288613539214, 0.02075113760146199, 0.07401383861251427, 0.27412823778397716, 0.5402934148291321, -0.44203963559296866, -0.08478598409371416, -0.0785911099114448, 0.20933671224537923, -0.36266702689041563], [-0.3097509876984146, -0.1688946247727458, -0.36545534001015445, -0.147448755500584, 0.28100462270862775, 0.08177154081376939, 0.45810205316533925, -0.5642761291481933, 0.017057116178111818, 0.305210246493467, 0.11344922482662065], [0.22442482162278662, -0.052437535835280324, -0.3284802102275118, -0.08905765315196995, -0.1980719842340861, -0.007347921759130329, 0.5314710677169843, 0.42792084337227376, -0.049139767338724966, -0.5549874244004968, -0.12555192271319648], [0.20122855939636966, 0.03947358585881795, -0.04381148152858462, -0.22409144086149455, -0.1188982578372299, 0.6421841395081446, -0.3684665865688834, -0.014000563908673503, -0.1518540683269964, -0.3829955167834866, -0.4166129537326679], [0.2708421211951072, 0.13247937781221544, -0.34365255875226713, 0.03424735938396566, -0.32342789914458514, -0.07017277569763652, -0.32091368594870157, -0.29702167194356277, -0.5851133168558329, -0.33820043276463596, -0.17985933105492447], [-0.7125250163525549, 0.05894650077443528, -0.1439975541278576, -0.34776071089847255, -0.02390481352596746, -0.45645397463380954, 0.09470086580594878, -0.03836121867902137, 0.00450681162774156, -0.21085031241642455, -0.2886536501241979], [0.3003438552737663, -0.03007988845585598, -0.311888439892766, 0.24658942411973997, -0.35382960360447907, -0.013027169054518548, -0.17772223608009793, 0.21187247708418397, 0.12753269893739796, -0.38266406424931937, -0.6215073734507787], [0.5443302716688205, 0.5708896828195056, -0.19728404786665998, 0.1838796791830064, -0.12014967347112895, 0.005080679177381168, 0.3303751184168918, 0.1576962243104338, -0.11083214920610733, 0.03656594272309865, -0.378098379531511], [0.17693893876242128, -0.10927108663595426, 0.23545086243434535, -0.6274392170325173, 0.23362727335488734, -0.18275436983534105, -0.4763265220279652, -0.14966719306188292, -0.14912167648951447, 0.23086568604555552, 0.3079464818370386], [0.06078537071880994, 0.4235901198901367, -0.011773474512868065, 0.17765973590685102, 0.2693225527973211, -0.32651752626388214, -0.21408119591427333, 0.5344455414704791, -0.3716050986035848, -0.14801799078101463, 0.3384732633841276], [0.3651628186928601, -0.40282624857233607, 0.11196176679196744, -0.1847293968258851, -0.43747901804956124, -0.4197477091576995, -0.02677545689669795, -0.4926248776272738, -0.03232808402878399, -0.036638002749245654, -0.2106349164837238], [-0.5326323468162578, 0.30754020573084334, -0.19650085118947755, 0.08551034265412866, -0.10246665696797631, -0.21616360378545854, 0.311874625663179, 0.18977224680541893, 0.6146896434135511, -0.011162334035727728, 0.08557943188747141], [-0.23895543989493528, -0.10647200126296175, -0.5132494606582075, 0.10682375062611077, -0.5100090541211553, 0.2458205986225401, 0.17026682323304793, 0.3629287806030141, 0.23883535143599063, -0.16820614163639128, 0.3002448402081015], [-0.5296945151042379, 0.03045137729694965, -0.2960971060576196, 0.5011687476601487, -0.4619446625846254, -0.05077610506508525, 0.07529339341128884, -0.32802179829764894, 0.09543381618184188, 0.1138738675836642, 0.16834332201474547], [-0.8372047043274656, 0.3245011903223056, 0.2487658886763775, 0.037651278509372985, 0.1098091391372704, 0.07541319814187629, -0.10835930084000313, -0.24491021317335165, 0.13460399364470854, -0.03767895369131693, 0.14655813742487056], [0.40271605897942025, -0.48817126556992185, 0.054180341165735155, 0.24336253905739882, -0.14128970698694837, -0.2997462664375344, -0.2558028327315146, 0.07841171846679629, -0.14271227610225096, -0.5792921021017189, -0.002744239211397378], [0.18724164967618387, 0.20565239254988923, -0.013552444490601782, 0.23141669479597585, -0.6298390232988967, 0.3528945261242163, 0.07687051095892294, 0.3099585871032641, -0.4344869693478462, -0.20942845122571993, -0.11426266649488839], [-0.16884946410690585, -0.1381337757940911, 0.028622768120196065, 0.026496020429848464, 0.40616210303041533, -0.5701995948751734, 0.4526762255724747, -0.3190219324389345, -0.3111487551028624, 0.051300829886020194, -0.23378687525955302], [0.053876773368491754, -0.3809765373683523, 0.4916059112044871, 0.01835473528745589, -0.286766871383371, -0.31863124455623587, 0.1413939370635504, -0.09593761199524142, 0.5848465845311478, 0.23149994268437718, 0.036684775626843226], [0.5395026427089429, 0.2495279436285113, 0.08734211462100751, -0.3613430605873341, 0.035150141799927266, -0.04962137368264978, -0.2336944625855304, -0.6315348900383234, -0.030398346228185713, -0.222948967776495, 0.026414340384037917], [0.5404245270808548, 0.2286033934075693, -0.18210445389705673, -0.23939962744605076, 0.3876723954775483, -0.37482351157835175, -0.07331535238366907, -0.11956118076951387, 0.29056632590981424, 0.11168018756250009, -0.39730817178285244], [-0.15147692879179958, 0.5510338335297399, 0.06893674767123842, -0.23950330002279213, 0.05841626377284572, -0.28994273036804635, -0.05309957808983868, -0.3217887458024316, -0.3841721865472441, -0.4541291123785014, 0.2522578441535055], [-0.017796234303405083, -0.0012461571587874987, -0.6334660940778608, 0.3609965568068955, 0.19939618344062343, -0.326316549586049, 0.12116760923035734, -0.32919503655779064, 0.35894797506678255, 0.014018708165999783, 0.2641050390578615], [-0.4739293956092683, 0.2764369491353244, -0.306723201020267, -0.017489267158774507, 0.5629927997951953, -0.2863106967608773, 0.2470212528720089, -0.04923810710080527, -0.10977849141838797, -0.09785745839673493, 0.3472499777049559], [0.15363836662101654, 0.24403188839450396, -0.5890307594459401, -0.3364140444906053, -0.08589050294664315, 0.2145855121840694, -0.519582770260442, -0.20271503942340283, 0.15980440707030916, -0.23065545968953907, 0.11614169081467297], [-0.5751650369069069, -0.019595392169864983, -0.3818561756446947, -0.023554740619685027, -0.06219845676246788, 0.4189398612727431, -0.5190491708515491, 0.1808009307866663, -0.05072406710844571, -0.07740619826630742, 0.1799647521210886], [-0.19922410768693746, -0.4850908055918925, 0.3707558983468559, 0.3284605630525411, -0.0116038691057215, 0.29241015519196145, 0.12835286124014564, -0.21441762915007198, 0.10839958122696566, 0.48144824666344826, 0.29668127488064766], [0.4542874142027167, 0.17906894279387622, -0.22734843414356207, 0.2883273202018725, -0.05891885279242368, 0.0021222262854528016, -0.0604490604005045, 0.14094737874739555, -0.6897863956337338, 0.3145508590427983, 0.15809365223683747], [0.18057716528554466, -0.7154725451516771, -0.09851315896530277, -0.24446270203309473, 0.43847517084786974, -0.25776289674017283, -0.28488214456255034, 0.16713643773389633, -0.12477337723723952, -0.04036513525005408, -0.03212036785506125], [0.30572481858151307, -0.11154604307177438, 0.05843777747112737, -0.24077279010950725, -0.6498656042173047, -0.01707343882802989, 0.5846205742231464, 0.05931700555499482, 0.02419913101711325, 0.12313400516858042, -0.2214479516804344], [0.21002569281064282, 0.4580861516036551, -0.30737202607965497, 0.18043773925141718, 0.19141467937643825, 0.1513114236546882, -0.21291717366263438, -0.4187774853819752, 0.07870206789441665, -0.29778515564377084, -0.4938602028719441], [0.0020522153835602725, 0.3904692809490811, -0.3912874142992527, 0.37916126661172866, -0.021682232511914406, -0.062396824053647, 0.3941501657691194, -0.40374120871749897, -0.4736975706216166, -0.058267704856517145, 0.012292634635435477], [-0.2847014147163437, 0.6322375112259006, 0.14533970156119982, 0.040720072753572076, -0.3905423092010968, -0.548880174816715, -0.17737089580991985, 0.07351906052960515, 0.007837361869766598, 0.05361978855858941, 0.053332412206551924], [-0.04244746103714372, -0.10601543225325952, -0.2669242815311449, -0.041006097847611, 0.30501236332605725, 0.2925181573804945, 0.6030291681838202, -0.13996895606676218, -0.20210383051219802, -0.44459686944887916, 0.33716707118383626], [0.09361117020767266, -0.4868338243615994, -0.006788613513799881, 0.06798305135584666, -0.5453995284217323, -0.16362159898208906, 0.03455531109287747, 0.6320796994028756, 0.04418135286943664, -0.08203661168024011, -0.12620819683884016], [0.24239326932192257, -0.0010259931940406397, 0.5273467556494092, 0.185456323521599, -0.05643928802690509, -0.018915238495276643, 0.47265860354370653, -0.009519424603650736, 0.14897603320870811, 0.07036011954978448, 0.6120224198300578], [0.031564987852850876, -0.5951505834748924, -0.35337632510469974, 0.39986273211787676, 0.20182043094643584, -0.07155183624945438, 0.1871586570665101, 0.3296826147966337, -0.016145959321025364, -0.24869294194311048, -0.3291737997520383], [-0.19055515166156975, -0.5882429964983147, 0.20076106107771266, 0.07276958834139237, -0.13372839733535477, 0.23632861225410992, 0.563907970219031, 0.151934829451636, 0.34023868392043405, -0.18943412242506633, 0.07483286268578776], [0.4378413526254487, 0.3533922167683849, 0.47287052288444714, -0.23152018829843424, -0.3157328427451631, 0.4463049135228686, 0.23333398730465937, 0.05637416191481124, 0.20511840229068196, -0.05474024971296947, 0.06806326889950175], [-0.24831888195255342, -0.1881648310838809, -0.22580832348097343, -0.004956560232470212, -0.3640813844465518, 0.04240359385682323, 0.48102423772653274, 0.049962513381399676, 0.2703717363547722, 0.6198110013254996, 0.16253405885074934], [0.0402054089484704, 0.10543633530563844, -0.28414169703570546, 0.02688805643629604, -0.5476424242503946, -0.4192026070093485, -0.030560544566961903, -0.02843284495685849, 0.42494652796396526, 0.17713605334811316, 0.46525807416112946], [0.027196888950324346, -0.44588230740502227, -0.04184862476773423, 0.5862687059192313, -0.34984376006640866, 0.4168290374352238, -0.19836364108189636, 0.14710112977330037, 0.1354993691280652, -0.28141390456893167, -0.017582665616277558], [0.49019373837223573, 0.37920972137067455, 0.07378797287770186, 0.26795053955225345, 0.6443145268313535, 0.1375477185299694, -0.0916234318121754, 0.19234385776926705, -0.1723144042199553, 0.14612585429066255, -0.09039531547438939], [-0.3102719250293571, 0.4881647625641698, 0.4083242200684986, -0.20553557989150054, -0.12386659037467311, 0.15123291618564194, -0.19980808005258818, 0.33874890891230247, 0.5009125572109157, 0.03155086998179396, -0.10796150782819511], [0.14182200147506122, 0.5662628655706778, -0.14478329446527172, 0.3104171588367775, 0.05401660734196912, -0.26485810822535455, -0.33730365296034587, 0.2834661724847894, 0.4438120317537586, -0.058200551836572634, -0.2726921556412593], [-0.12574149260120532, -0.1870142160755021, 0.05724106170724731, -0.18271365168756604, 0.6864225641630779, -0.25659217597744793, -0.08477866374477078, -0.3626916886873056, 0.4356371618981558, 0.21238327827189732, 0.04381077966956527], [-0.6148526351283516, 0.27105836661712973, -0.09548688187219517, 0.0843003497732023, 0.1825562472319431, -0.23655022950272103, -0.4184320353126707, 0.39122370846955495, 0.0558045626693713, 0.25417955398290676, -0.21705703807426233], [0.1749888047186994, 0.6035531110478559, 0.24277423110070256, 0.11953632429102182, 0.06756931484309713, 0.01927798224532221, -0.08671667351053541, -0.32809379410165224, 0.27812134976557956, 0.44906404222066754, -0.36436482945595844], [-0.48856927892960234, 0.2532966082411206, 0.02817753828015511, 0.22328535731830754, -0.2783590793298492, -0.07679539753600256, -0.17990333944753942, -0.16613269984755455, 0.39071499460361375, -0.07801827620421485, -0.5868551008744761], [-0.3338433965401994, 0.22811154100465, -0.12287401657059267, 0.41779331666705216, -0.19591016276681048, 0.5256583478472056, -0.1390129569687531, -0.30080385782135893, -0.20687643348621243, -0.41227407579523584, -0.0979367455052963], [-0.19162780464635684, 0.3424565270768598, -0.032606393810372114, 0.11422811697844139, -0.25051287363269414, -0.25467372496365087, 0.15314405000616724, 0.6776069550562968, -0.06876280308813242, -0.141262653572459, -0.4438332118090277], [-0.5451683771631737, -0.5373371020253996, 0.14946315561707155, -0.15951671533717102, 0.18072233343378485, -0.024749874040494724, -0.4276976407712205, -0.17238078295328674, 0.09155248470252793, -0.07923825501046237, 0.3251174851300765], [0.10513648484819202, 0.22726602935221374, 0.3410340336392171, 0.16222660729114455, -0.16859564631308457, 0.13981904713802493, 0.7532432208950778, -0.03986917561780585, -0.26570932411954223, -0.3219142058836857, -0.05921002855834933], [-0.2481855419107652, -0.08432269223195511, -0.14859830243667463, -0.6794255473767391, -0.23847089449546782, 0.013457518946903066, 0.2914637113498869, -0.14811626480855689, -0.23578920721783295, 0.4257716224354701, -0.21627776229159956], [0.10083315327013839, 0.46084232804749903, -0.4127075883651731, 0.27020505533256267, 0.3589448892405783, 0.027874062965889325, 0.2654537013193269, 0.14412416664959476, 0.23964994402951806, -0.501585556024585, 0.06513595719202027], [-0.05799816236661298, -0.10666554532206762, -0.34936455255786353, 0.3341207241025404, 0.7470265108613392, 0.09288868404748316, 0.1517668978274937, -0.300731304437769, -0.06606999853475422, -0.16307935288412526, -0.20113896042843019], [-0.1320112778101679, -0.11012252282245284, -0.4063162156707459, 0.015629123700586816, -0.6772686754267647, 0.36897354855885683, -0.3077847919057335, -0.20101244495846424, 0.08120514350738213, 0.03377731847176157, -0.25961878570555813], [0.0998066426369805, 0.05100602585797907, -0.4261396766158206, 0.5067006875271459, -0.20813844809087434, -0.4675103063058088, 0.01876746464545324, 0.41628106850682506, 0.07883098612073529, -0.29571064896167343, 0.1410944740259445], [-0.4950488708198124, 0.42212321961341653, -0.1880876271626663, 0.06895459637369272, -0.16247347189043707, 0.09024184221118509, 0.3575619471445945, 0.2429585113687198, -0.25684083435891725, -0.46939592782809514, 0.16996045542586893], [0.26201998748643834, 0.01700586424599108, -0.41172247435532017, -0.15905131133255657, 0.42523556235532417, 0.29033687224511845, 0.12730641449864347, 0.2721770360185702, 0.10337990349246122, -0.23301679995814725, -0.5620065237335357], [0.3185111073149336, 0.014388005226899208, -0.19545990423276272, -0.4006457361274782, 0.10562118187852458, 0.20284029987129673, 0.4291886998862316, 0.10697820073618376, 0.34810707646081906, 0.49535587127052966, -0.2917512759910962], [0.6726029430333512, 0.13690315014102997, 0.1642952093597273, 0.4534567835291187, -0.07759748301271473, -0.23003406532206014, -0.3365083890384005, -0.12430347345267442, -0.1577170769326074, 0.0205825490140617, -0.28865590327066354], [-0.13940619741093496, 0.04401492112353408, -0.29415755026474083, -0.4783772592414645, -0.3527090973148606, -0.36500404481505755, 0.338020755222994, 0.5092698682816879, 0.07516161730143724, 0.10149827848567468, 0.1267220315993756], [0.45010006618112275, 0.391238899693414, 0.09576454799142946, 0.1068873633494229, -0.5434811734295167, -0.2668952357135087, 0.16432246635310782, -0.26212510577428366, -0.2923239481890582, -0.04098489525365317, 0.2725746643149501], [0.2942069094510024, -0.11031905267898921, -0.026773561941855917, 0.13667560749858562, -0.20808450323524233, -0.21577821097331665, 0.1324064249302393, -0.0995582986187074, 0.15434845870965566, 0.4081319163830038, -0.757744768944311], [0.38663716225876354, -0.4457662485030126, -0.10572564088227575, 0.11764781350507188, 0.20917217907300564, -0.08270139590430331, 0.45556546024424643, -0.2102638380890284, 0.3704084276003107, 0.3536467380364924, 0.2493461994380737], [0.03961007842183061, 0.10489799297911892, 0.26891692115625204, 0.03929586882746516, -0.3047198499427511, -0.2929247469880985, -0.6025733643632141, 0.13864263192437526, 0.20624573977950272, 0.4422703162137066, -0.3383062311135355], [-0.040959917557095674, 0.07695036484475576, -0.055545464901494035, 0.3124379259442221, -0.13210717020420934, 0.1323017495696829, -0.8514273280613883, -0.08721034345526464, 0.1484890004005038, -0.24430702953692457, -0.2060899464057495], [0.3822414871872386, -0.509712874468242, 0.02492640910473352, -0.29984036063216585, 0.07656147324673761, -0.0898960977050006, 0.1956914214663154, 0.09040319912116945, 0.5362333650926927, -0.20985025150127093, -0.33401268693030245], [-0.11499822523136702, 0.23912685357505672, 0.4921853387539046, -0.02855867616424191, 0.1538511913313412, -0.34699817400650823, 0.1539633970716021, 0.18010058432657886, -0.5446276493452312, -0.30069365151789823, -0.31508242093041755], [0.42295563948634946, -0.25395068963167344, 0.1802873046420558, 0.3287644740875701, -0.44055596751932613, -0.31439224426419793, 0.05828756194257394, 0.1042168307352558, -0.11345190004982993, 0.5331602188283041, 0.10819518752271688], [-0.511596238509046, -0.061002497499940876, -0.31301365817765486, 0.26216115320504485, 0.2801975774745041, 0.06294893923803965, -0.10841023414538073, 0.0099303550095494, 0.18479204803028873, 0.5297807207091974, 0.3983737043836807], [-0.2690118785544151, 0.43519442242497036, -0.10867488871836173, 0.6903413370611194, 0.28041648200393254, 0.14811455852552904, -0.03760381326396708, -0.22807371076019334, 0.2991753149678606, 0.07233080096542606, -0.033412973536194275], [-0.037727235654939795, 0.27014940194585524, -0.5335846984801113, 0.1758351722091432, -0.1727417508395488, 0.19379101132297846, 0.2680396360004967, -0.368542183691313, 0.34822102372504704, 0.3224947359131785, -0.3311213159016445], [-0.13033163329157157, 0.5001801168564516, 0.5126580510078994, 0.18956811408489282, 0.0972482098737242, -0.31885054173322286, 0.3422924818865104, -0.3592964350585034, -0.17637079658654226, 0.17509072725679237, 0.12220799718194811], [-0.3996050146731032, 0.1736426261729514, 0.017498646869777985, 0.17812452269427897, 0.29700948219169054, -0.1285300335938614, -0.25411890594896763, -0.4446191552853861, -0.4886272291516497, -0.1782151962553538, -0.3749867777628602], [-0.12512507533402387, 0.0018668827085655986, -0.18748532974593365, 0.4646915011197458, 0.6095348948413983, -0.3231436480756913, 0.02719851474273716, 0.401984884130923, 0.29760690331213396, 0.07731370318128852, 0.020440180898356874], [-0.025643612315663773, -0.39790056780157235, 0.06832754379145824, -0.22366286052091208, -0.27333598397614123, 0.3164199184841031, 0.2650952248842304, -0.5322424588042218, 0.3921857044575618, 0.15231704192900283, -0.28446804507829687], [0.689444147730523, -0.1523219415209918, 0.4718780267262241, -0.21361579357903948, -0.17342317674502397, -0.21848672959518076, -0.17661564605332739, 0.038892200016191904, 0.1712121276632086, -0.10594142411438344, 0.28654719859240774], [0.012671727658975082, 0.10840382351231655, 0.0679009058322814, -0.6670794577951971, 0.12444758963055795, -0.027116346913781866, -0.19175766446623937, -0.19242890212255317, -0.5246896942540437, -0.18315073951120414, -0.37365311535235957], [-0.34911018641818, -0.23059672138249523, 0.12230771046102923, -0.2047395708042724, -0.3034967186832797, 0.007158802363095386, 0.49382898256486035, 0.3875364068702238, -0.4908261601629842, -0.09592445948521695, -0.17817099408652334], [-0.20860096608661238, 0.5179675170891421, -0.44458832902928025, -0.011827623356184376, -0.18964466267512248, 0.42495375456918844, -0.06746102058613077, 0.26528990009793935, 0.2246205635798412, -0.2096699157755817, -0.3232649533193553], [0.09172700767383954, -0.4873136706313846, 0.30410533071965234, 0.36033483070112776, 0.18587792754903354, 0.24935469642875413, 0.048290116873645456, -0.14194994664725746, -0.18647147058079402, -0.38011799903523213, 0.48303095784588], [0.1981930727774449, -0.33966681702764556, -0.28096882306382565, -0.40431976157675875, -0.48096852738522755, -0.15719430417570157, -0.1682252008169087, 0.09816674870593953, 0.29328308211315623, 0.44309713974609566, -0.16309741362522864], [0.6338294861405998, -0.2580013676161428, 0.12087549100520846, 0.12192509146745743, 0.5733764930259565, -0.12523745543768441, -0.025304397517911276, -0.2607460420912812, 0.10168202197804645, -0.26709798939554097, 0.08639711233540895], [0.1579304747332823, -0.13792328211605842, 0.012661457694825342, 0.6109087323282387, 0.2738212580550038, -0.28546967429976816, 0.56285254821478, -0.06962705239546545, 0.03419689753560568, -0.2775466674749961, 0.16230165576072003], [0.1614050877090017, 0.2554275412344459, -0.1884386255348591, 0.3463033761319983, -0.12405805381338464, 0.00867089914971851, 0.13203507759302097, -0.3789011566003317, -0.031009484311406103, 0.5697958511459389, 0.5011748112487399], [0.06946796536837123, -0.12180627203840629, 0.20891490904804397, -0.29942445278863417, 0.3340486101956497, -0.14976706266445525, 0.07391395008026687, 0.2941264346283063, -0.6802590110383244, 0.3952992338239526, 0.04506558301302832], [0.15757524466537248, -0.16621536978472137, -0.00749006657346404, 0.3648959580356214, -0.3439882586381138, -0.4704280048153532, 0.37900902616784105, 0.08254144823556585, -0.36928294915867155, -0.1887943535663077, -0.3901701743613494], [-0.18959727643864793, -0.024431384791302996, 0.2667581703348119, 0.2994412741986594, -0.3320706146735985, -0.22286452071507734, -0.1880671507207842, 0.48443552239802234, -0.5778143928978903, 0.19661175956347496, 0.010899961788369172], [0.063729040166685, 0.11951330274514964, 0.8008838872126774, -0.11585817457323108, 0.05470672236230607, -0.21021555312013332, -0.1240415048504123, 0.19840945254248576, -0.011746359959924383, 0.4355864216018621, 0.18710303260191266], [0.5427911368742481, -0.031131395014067847, 0.21545679337385115, 0.43200289133116804, -0.4102451714701064, -0.0319681770930371, 0.2950028500544842, 0.20237463305460557, 0.27651867658222296, -0.31225243263526087, -0.009544168635466286], [-0.36829731092672324, -0.10913811690527024, 0.3309161981235009, -0.3252251168033594, 0.007783410186791248, -0.24462215751399197, -0.0015236021810814111, -0.7555392430549602, 0.009383438212210306, 0.032470189232717286, -0.07269279703072157], [0.11794448384756213, 0.3713701945249054, 0.06809942589530715, -0.14561395597421328, -0.12019778509737687, 0.017772227875160442, 0.42920231144991683, 0.040821399789308564, 0.5877781009896229, -0.2469613937867534, -0.4639126263446602], [-0.0544183158222611, -0.21439527617689008, 0.21725793814066877, 0.6392684326169661, 0.4233929049479212, 0.44620977068216433, 0.22243515267770161, 0.22015274190787193, 0.10192048146723612, 0.0048786162332707435, -0.09212626152610602], [-0.03590608005796449, 0.393040357940921, -0.09027433370595873, 0.14752443094273615, 0.2956636241899975, 0.6580955964136556, 0.4485524880489489, -0.15891538516751363, 0.014287875926002261, -0.07467009851693253, -0.24814738265082506], [0.12463972755383997, -0.0021049217384917504, 0.18784751055080517, -0.4650435759842206, -0.6094644684231102, 0.3230882296839543, -0.02712023452711755, -0.4022219789325088, -0.2967940279916108, -0.07774394774210507, -0.020652033451347036], [0.007979438884430172, 0.08112696806569061, -0.28646464032622976, 0.11090644788483421, -0.1457773938694459, 0.20325306680093483, -0.31058461424722733, 0.31234554412405163, -0.02946204409780456, -0.7891310694970209, 0.13715413632608944], [-0.14301130956192332, 0.44524160798783013, 0.632230012044768, 0.06851280885772398, -0.2657160329120681, 0.06395894716758706, 0.016839760451511993, 0.20131227865433204, -0.2231724598551035, -0.2822722950606419, 0.3631932257230794], [0.12254624158634102, 0.31480546102735046, 0.2713200900935898, -0.12853971926607966, 0.12243820817346134, -0.021987554373042402, -0.25293006140795593, 0.17978655330780532, 0.006820548426795804, -0.077523532835562, -0.8233559883529762], [-0.14555383100494287, 0.27312699658195505, -0.08724254592656959, 0.2792823982075142, 0.23745294522009042, 0.19689819719840423, 0.17409126905388406, 0.36237625213545294, 0.28755790729958436, 0.3854165771737161, -0.5749723462155285], [-0.5604029176995458, -0.2357234904007647, -0.14659961741971478, 0.41509445606711576, 0.21431606545875334, 0.12268963191612368, 0.0627374859037909, -0.013466003060561633, 0.35099538403917596, -0.43668978464773, 0.23998119909687873], [-0.4017138714838304, 0.39819627362641447, -0.08678014437477038, 0.1659645262607336, 0.4411633540083437, 0.4171762399629672, 0.035964946617966724, 0.47948073573044353, 0.07767260695299072, 0.00810700269473027, 0.19757415037883191], [0.3507783608594299, 0.3291182719987053, -0.4299233430335821, -0.20111244330040268, -0.5153430549917457, 0.2769240954174073, 0.11356600042581126, 0.15106999433270574, -0.017899704574739626, 0.3306216501076818, 0.23609221782762277], [-0.14292852456298907, 0.12288973373634417, -0.25902881993185956, 0.6477817836716291, -0.23699697646112142, 0.18733805255160693, 0.4705889184097592, 0.16524915253515357, 0.099823555972649, -0.20309051694752223, -0.2941386674106904], [0.4247375013845869, -0.15433840029177046, -0.24682325936065447, -0.2539664139045434, -0.6674291904004519, 0.00038263480058046355, -0.09229761108247163, 0.023978335123454802, 0.18332844468436965, -0.4055323191219944, 0.1331750415893853], [-0.3087310112756217, -0.3456826714015485, 0.41160796976731023, 0.30127372535474306, 0.47800182023317406, -0.2367141034748693, -0.1201025886143607, -0.11387116903819175, 0.11163402051483017, -0.3339536995173041, -0.2985027054929255], [-0.2797067130207213, -0.21212756367050423, -0.22870838354565165, 0.07958806206057611, 0.037684883448526205, 0.6649736678439632, 0.20085422442148929, 0.39113133653967014, -0.18529855972010575, -0.3457629637160745, -0.16522836477438935], [-0.1869357586787477, 0.06703631796779393, 0.3026823797410578, 0.11191735778771805, 0.19372632236262868, 0.011554614083312131, -0.5368899280696066, -0.41047359841011305, -0.005601054238707231, 0.5851594995052319, 0.13990445887723554], [0.0837318477230668, 0.05610748062215052, -0.21145320229541698, 0.14136552008929607, 0.091730842752334, -0.30638752630184474, -0.05658230237137317, 0.03660023749916611, 0.6350476381630336, 0.6394574279519996, -0.07825572344896446], [-0.43223297829479823, -0.026120646066512283, 0.5995605620348908, -0.33465764107295676, -0.292892249020701, 0.24374084306307348, 0.3525814135048375, -0.1266144371912249, 0.14291000443414156, 0.14545968253515, 0.11790519271411042], [-0.25247814343942526, -0.3416281219725068, 0.15967875145184096, 0.37252508255106365, -0.5952008748715694, 0.157958993599106, 0.20698451251946098, 0.017093192171648022, -0.12716651995908515, 0.29118587520256406, -0.36326621657370817], [-0.3595332723344809, -0.31059106510613377, -0.3748565532902044, -0.21125447291795788, -0.23397485404260765, 0.08190325469911502, 0.2813049791821709, 0.21788824622012776, 0.3958044264281376, 0.008146596895749715, -0.4943030071312738], [0.06806412917858058, -0.5837979173978225, -0.174395676163738, 0.5128190392046017, 0.37426578083520395, 0.04151891442951338, -0.3117600901198343, -0.13616524303834004, 0.25359933948378177, 0.10604387262476296, 0.1675055135066117], [-0.37669112745296285, 0.31406682780713047, 0.17977951280384746, 0.040830697781384526, 0.24085966486382582, -0.32490071604266174, -0.15232333610342413, 0.31303367079327676, 0.26740327963668964, -0.6035105023169425, 0.07058492389620785], [-0.40405318348786834, 0.4446752064287958, -0.5280600423878348, 0.24356934247069212, -0.009882499717086659, -0.24356579599457134, -0.334384239617874, -0.11873053689719644, -0.012064211174068898, -0.33931121882158566, 0.014905819577918982], [0.4409116468971722, -0.30016350490148996, -0.36142867495315506, -0.34031837888381256, 0.05957496860476545, -0.37718251025847455, -0.2019508016766723, -0.2688629902320011, 0.3367912442569889, -0.038537125705819776, 0.30862727498044185], [-0.19183223235336155, -0.3901344590839511, -0.12354762076584395, -0.263884825829615, -0.18264496669953673, 0.5555128106422093, -0.05347217283731372, -0.232030719853393, 0.2477820211068365, -0.43779590957734843, 0.27273411826761945], [0.025921351905402342, -0.1388108316360693, 0.2176354792743149, 0.7173539397026382, -0.10750450786140295, -0.2324325248190792, -0.10695373863793578, 0.37681099605629637, 0.18322934170118912, 0.08305345527084601, -0.3982702161039667], [0.3277324313039134, -0.3823818766224567, 0.5097297103011929, -0.041530469761680615, -0.03508245012544278, -0.41040315409849687, -0.13470915670861716, 0.2669699332945775, -0.18785266079510887, 0.08201781348125528, -0.4286371695719414], [0.19469095215871488, 0.6217720928757005, -0.18838205400742383, -0.046431681690607365, 0.14500379152242526, -0.2484762300306234, -0.5501925193616548, -0.13403531529877294, -0.29983248458618766, 0.20521582082617357, -0.04893195118189459], [-0.11440442550308579, -0.41853338654902084, -0.015572860902062178, 0.15256483916620614, 0.035770166814800226, 0.048592444712337084, -0.3412756338076403, 0.0011611570419839984, -0.537401022772701, 0.3481858685262309, 0.5080142638455715], [0.13660716155734212, 0.08661858940546133, -0.4604386995224378, 0.08256584634334856, -0.28224469445401856, -0.4304896919778878, -0.40823096462803776, -0.3717506891339247, 0.28986359809106615, 0.07906802248937285, -0.30807075957046404], [-0.36013755265296815, 0.2988295611076513, -0.033288114801716145, 0.15059164436726363, 0.08818774701071709, -0.18623246234110666, 0.4383110048968721, -0.5466411863035148, 0.23110162829941874, -0.38083630695584114, -0.1593075861632664], [-0.2217661116015667, 0.22821838882769127, 0.27287259373892064, -0.0775276562306215, -0.10013457268781162, -0.07279921236615698, -0.7402484925107446, 0.2534229427285727, 0.004069240715463331, 0.060925166330483144, 0.43245815717252284], [-0.22569390477821558, 0.002120787356424912, -0.4457257555230955, -0.5599032847985841, -0.38566847084925154, 0.2186914316411658, -0.021556368896651797, 0.17080544568390937, -0.28665576447586016, -0.3509262632264606, -0.07327050987262736], [0.371926576715709, 0.3938499995772586, -0.4133359798923342, 0.5571661007716281, -0.31224805185209187, 0.1914720092447356, -0.20263481184626286, -0.10732609057148618, 0.014523943918048954, -0.11414127821948684, 0.15903708373654937], [-0.30471867836418637, 0.3070549120293592, 0.11212479160542743, -0.011333344518111505, -0.2624580349651693, 0.22881064946913338, 0.07718254746053071, 0.2665060840873954, 0.25920961189019676, 0.2764644100978154, 0.6769933748573469], [-0.38445936930083613, -0.10874103555799468, 0.47490148867495097, 0.04426817514962901, 0.14855278756614254, 0.5018225220416399, -0.31083833602565997, 0.2133860847054508, 0.14515338572518763, -0.41863908597778515, 0.022343432121951425], [0.383988651498104, 0.24365979613593688, -0.14625316966654472, 0.2263839708650753, 0.2990016959409687, -0.003914210508707949, -0.49838337671473393, -0.3711294261296943, 0.43970862356774737, 0.12366947623330125, 0.19069540641932148], [-0.21950018102049246, -0.3784025002200599, -0.06018388524505252, 0.30450410142314227, 0.10497707760660278, -0.14800885600145336, -0.5485863833293156, 0.5694915782874457, 0.030592979225558332, -0.2114455974140406, 0.0919060035930801], [0.24105248979217445, -0.31121817814905206, 0.339891735368334, 0.13501753363424931, 0.14035819880183872, 0.4320777619953772, -0.06385991975656309, -0.14166546267154922, 0.6701613148575871, -0.10756240701906121, 0.14161973101136682], [0.43171663612096584, 0.07982347635621277, 0.09487162209505105, 0.23051176185496994, 0.3235960791322443, -0.38204737205403083, 0.1301390186634248, 0.41262076889467325, 0.04727591041745352, -0.41693551918168864, -0.3621819194827532], [-0.01039274022448891, -0.15601251802705465, 0.38982504064783685, 0.37377809959036234, -0.2307438967364337, 0.1144165082774801, -0.27281868078851645, -0.03572297046633576, -0.38854720648856866, -0.33393418325078517, -0.5285427496928934], [-0.13374621693803704, 0.22977966748775774, -0.18873422671381546, -0.02120905108351421, -0.11241469880293123, 0.15945600900165235, 0.2798011800176739, -0.028733133254942957, -0.419927373599018, -0.3891454499615679, -0.6695461632775412], [-0.2514400363710137, -0.2318553815320386, -0.41006837343296476, 0.06996237156968642, -0.27185110957086234, -0.19449386574378946, 0.1352033998445185, -0.50167295953291, -0.3019886470608249, 0.1273097633937318, -0.4699772970972861], [0.25716048134470326, 0.6226652181154302, -0.07704614744652202, -0.5427368210541926, 0.22050244810734249, 0.3654785405296992, -0.06411814603714218, -0.045053298912699255, 0.0811189253188663, 0.03732893193409124, -0.22214092016561673], [-0.22638750531256419, 0.10501383509875095, 0.1654041333861688, 0.30661414651783153, -0.6064061245205489, -0.2639649091662803, 0.4786461670883526, 0.30451364912966933, 0.011098782024426867, 0.008906197326942507, 0.23856015902709712], [0.5258375102082656, 0.23278135204803768, 0.3093207001566474, -0.276311411370954, 0.40264729316379755, 0.07628736948739806, 0.11427442813484895, -0.20520878141174267, 0.2568155974600524, 0.3682194139145114, 0.2694935642750371], [-0.5138728344867519, 0.27042128195201703, 0.4116774578127579, 0.29747526253020096, -0.05393207530958611, 0.36067001090314343, 0.22001350244038062, 0.2336900407752472, -0.2271270779967845, -0.021864763227579385, -0.3417073306198504], [-0.04135115432155686, -0.20326605377718876, -0.09045505496328225, -0.36777210124382204, 0.10676329550644618, -0.583081541682361, -0.2744779578491837, -0.17704784816608815, -0.160470231882257, 0.3950181293463214, -0.41674688332419324], [0.06395272599155573, 0.15304122119914204, 0.3759630139368491, -0.27843095496389114, -0.412347356265943, -0.24456118346380357, 0.265091257298846, -0.3772818858475673, 0.3289351899178235, -0.40683833763621297, 0.19350748311876736], [0.12392153066430572, 0.09193687496884916, -0.28286288971569823, 0.22727670303673392, 0.24542361949261193, 0.0829766804623508, -0.18923223707853506, -0.5197077769616487, -0.050061763939386286, -0.5776751989009286, 0.36781413786543515], [0.1967203178558013, 0.00020451816178254095, -0.06351924715059719, -0.4410942811944553, 0.0838237333938079, -0.36672890344710296, 0.4193874913687183, 0.2704353344200391, -0.2079576113861651, 0.020146718335744256, -0.5731599355658482], [-0.022350287175939315, -0.5030122005114129, -0.36229205272441667, -0.48861797794947054, -0.13685082316767774, 0.06929812037250324, -0.3695511230287761, -0.3986473069095185, -0.23363929646013848, 0.04553626865903834, -0.02823425608135686], [0.14082869539189716, 0.005255980287191953, 0.21000404136753079, -0.16764631452946901, 0.2545097407362603, 0.7634796907501972, -0.014842400891707734, 0.39082979189719946, 0.2036720910979701, 0.1716305720098184, -0.19065315550102138], [0.05871145080018173, 0.19944776905257094, -0.09042373509907221, 0.22532373824355797, -0.6346209269968022, 0.0699264291298873, 0.05399446615148136, 0.3266254172283849, 0.493901581166009, 0.26567973115440985, -0.2570385780914421], [0.1650612092946808, -0.21745076785967293, 0.16702729817113188, 0.04020186612627432, 0.1090551093517163, -0.15549186304109694, -0.28469530790912756, 0.043249864913454256, 0.3742616517975707, 0.4146742240540783, 0.6818624866934124], [0.6137196218091794, 0.013294490544679353, 0.22091013950629365, -0.06337735591753155, 0.20127786028447614, 0.39484115125616104, 0.12156512930167052, -0.30021004873307555, 0.09130277181862645, 0.041239196929622524, -0.5089205930733872], [0.3879910323790489, 0.14890363483699523, 0.2063449873667268, 0.008434918522874505, 0.10399085798748119, -0.13895508340182208, 0.22289403780931236, 0.09548250374989699, -0.07634027878780376, -0.7172544440225114, 0.4188534524950213], [0.31603186356230195, 0.12210226430644386, -0.059502402363639406, -0.4955719855879797, -0.3213277956932971, 0.1968378662477107, -0.023756130803374922, 0.5710016910470118, 0.1753038561382574, -0.07320803179993256, -0.36247472846751494], [0.33545117506221594, -0.5254690480437841, 0.3125195106075323, 0.2959532941873917, 0.23234271266144624, -0.17997861827702716, 0.09997998605910359, 0.4805255975880554, 0.22265353092572743, -0.031034714489179827, 0.21973610717393544], [0.05267260712738702, -0.4408274376762455, -0.10480579224576832, -0.33908034703546525, 0.2337172513881275, 0.13908042827942424, 0.3400998546324861, 0.6912768743303488, 0.023667734828899698, 0.06530806849947027, -0.06791890827595913], [-0.5073445560920772, -0.017129378803787742, -0.1135926571888091, -0.02821343459745521, -0.36848969150504296, -0.2717886632248311, -0.5994994187970344, -0.26403865850915387, -0.24808128772631624, 0.1602419206158052, -0.05115956563168809], [-0.060047221453249484, 0.1298018784338065, 0.25211803967052776, -0.6907223151240188, -0.10374059804846016, 0.1166928506862118, -0.2860791852073237, 0.10333878825500727, 0.16862497462544412, -0.5156069165161787, 0.16643487655784772], [-0.2515305817914533, -0.555356787569846, -0.238800147552205, -0.06454151717897774, 0.11877317448875599, -0.31558351970863197, 0.05191966397351965, 0.22193914132893283, 0.5902039866718266, 0.06350203455014373, 0.22157205123150636], [-0.5422660092009975, -0.2293274990049837, 0.18337899377598457, 0.23829214185365383, -0.3874752208935602, 0.37459897854271595, 0.07360031428106212, 0.11870454207173128, -0.28789210211368216, -0.11316118346857423, 0.3965966984632064], [0.8384371597921866, -0.31467730550181156, -0.25182369946205274, -0.029642761453806177, -0.1146799874571534, -0.05120365442581401, 0.10850007343274035, 0.22535245652817412, -0.13411425370856883, 0.0529902105628981, -0.18596652589414928], [0.15919504381134608, 0.5676474329262746, -0.06361178037573909, -0.06364209678689571, -0.3881504966268543, -0.06494181326372439, 0.11366003267267732, 0.4450464058951834, 0.3051708508585994, -0.33819110740090774, 0.26640369352594956], [-0.3903630240681487, 0.5080887707482237, -0.04390004162579323, 0.27335652655676007, -0.0839130412797283, 0.08811644231920461, -0.20605728723724226, -0.0489693974749189, -0.5237094178756597, 0.1947745315647125, 0.3754188597815185], [-0.11264520059592154, 0.11021269051708554, -0.1194606186984289, -0.20242613563426604, 0.7339592635202762, -0.3503348869125147, -0.1644997625425375, 0.20947927194391044, -0.22691403159676068, -0.1059950959636065, -0.35329822101773084], [-0.5129312757340079, -0.21887513502116762, 0.3864506992069794, -0.04819768931176527, 0.09268758237183468, -0.35336153903318007, 0.39330359407404475, -0.12176200473200102, -0.0027310100234510947, -0.3652776397436008, 0.31768497109028926], [-0.35401410578798237, 0.002849818963322584, -0.6310100086706324, -0.09709771173432635, 0.22423352753606354, -0.10473608436933199, 0.006078758399663553, 0.5713186379325687, 0.015467501557561051, -0.276086663810576, -0.053934642270781236], [0.020163737595236583, 0.5021466834099703, 0.36382428076557943, 0.4872770541829604, 0.13709119429263686, -0.06967812256543109, 0.3698627672724646, 0.3976227940397869, 0.2368359985025638, -0.047342341585264396, 0.027406576838118396], [0.5596732600497311, 0.23073128814549576, -0.10222346925738916, -0.6123184022613599, -0.05465284998831328, -0.1746654356713837, 0.37737118855512486, 0.04289924348183704, 0.14920972464053744, -0.16681222639043805, 0.14251765844106712], [0.03689563871618973, 0.44468794471559014, -0.06544317042889528, -0.010912386263305467, 0.017369560201437678, -0.6289977775335355, 0.557241119470208, 0.14305713199614353, -0.07373422088845419, -0.24726777278134043, 0.054666755393390824], [-0.5158447864526012, -0.019661279905659277, 0.12046348220124446, -0.4443170420719334, -0.06687943177406407, -0.28218112435361675, -0.14955805703589148, -0.06206288134386205, 0.3978478932941342, 0.4779965846813057, 0.15654509182986234], [-0.2869766845337186, 0.023553161949198674, 0.6022988932923936, 0.4849122584802298, -0.19127502335808816, 0.09004538921018856, 0.16032508917636848, -0.21827071104465398, 0.35984392634280915, -0.26652224874343405, 0.02496940551001364], [-0.06068691032955572, -0.2110035179409364, -0.3706709546356376, -0.13448346030626426, 0.1619802310859759, -0.13668784874687556, -0.7582372635295349, 0.060708528189751594, 0.2005330379264921, 0.3562646010046106, 0.0751229321733347], [-0.5258376644854628, 0.21264965099960054, 0.03887285630948623, 0.5997146933361189, 0.07223472734363459, -0.45483798995598324, 0.18060051997537227, 0.09877725403345812, -0.21856535177066674, -0.08302221324626982, -0.08929510971498342], [-0.7006684768276071, -0.25525121534959, 0.06857353087269627, 0.057272904326403765, -0.07362145542312032, -0.20038100020441707, 0.2074271927173063, -0.1301205536654024, -0.36752976029224554, 0.43720645387227336, 0.06457799332551323], [-0.2553637284885505, 0.18251898592599922, -0.2354662976718876, -0.17363379617737032, 0.09504634734831457, -0.2702240900651672, -0.3824998377128374, -0.44604259015367875, 0.096177941511261, 0.07168437425780014, 0.6117019555400088], [-0.13208799534093923, 0.38212208319214824, -0.5725090111329907, -0.4000783704997634, 0.11893774247125886, 0.04346720656425459, 0.5543919998950205, 0.0029672701967437434, -0.01868867009312332, -0.06274323388640728, -0.14500119307933346], [0.3466927059300463, -0.3739494625433681, -0.05646983449646257, -0.0442563549516102, -0.27802478851330464, -0.5321078816945056, 0.43265571543242154, 0.10849830345971412, 0.004321164852577189, -0.16691101837879987, 0.3841108026280677], [0.3032671760706211, -0.30788158878141636, -0.1115550455495548, 0.011100725093315056, 0.2622939008258675, -0.22948936751116286, -0.07706611480275231, -0.2668861704114827, -0.2565728086932226, -0.2783411994775163, -0.6773004423564836], [-0.3745117538568612, 0.2326775524193805, -0.08329279093700068, -0.45439312505588764, 0.19703977089063215, 0.27430221826926215, 0.06465948464662205, 0.46649414961655206, -0.24388937997552998, 0.11457654251020398, -0.4286227584990153], [-0.01797829151315648, -0.0016352879642489986, -0.08075089552612938, 0.3736918774051826, 0.4422359655011548, -0.19998652737582642, -0.45087801293070867, -0.16187421576474972, 0.1395439769028149, 0.2794951727286464, -0.5393108591932977], [-0.1575425249795079, -0.1407310053042248, -0.693907134010758, 0.07961894483721287, -0.048321302445742946, 0.1599719357678772, 0.16501375850321334, -0.26668482723917286, 0.1379430874826579, -0.5196797790270358, -0.228379455663096]]} +RLMATH_EOF diff --git a/tasks/optimize-ea-kissing-d11-n594/tests/check.py b/tasks/optimize-ea-kissing-d11-n594/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e67c43884a1e3216148fc027eaa31c36e4ff51a4 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n594/tests/check.py @@ -0,0 +1,70 @@ +"""Kissing configurations with an overlap loss (EinsteinArena kissing-number-d11 / -d11-605 / -d12, MIT). + +Sphere centres c_i = 2 v_i / |v_i|; loss = sum_{i= max |v_i|^2 (in 30-80 digit Decimal arithmetic, so huge integer inputs can round) and +otherwise sums float-ish Decimal overlaps. Here every number is read as an exact rational (floats via their +shortest decimal repr), and a pair is overlapping iff > 0 and 4 ^2 > |v_i|^2 |v_j|^2, +decided in exact integer arithmetic (necessary and sufficient). The loss is 0 exactly for valid +configurations, and every overlapping pair contributes a strictly positive amount computed from the exact +excess 4^2 - |v_i|^2|v_j|^2 (so an invalid configuration can never round to 0).""" +import math +import re +from fractions import Fraction + +from run import Invalid + +DEC = re.compile(r"^[+-]?\d{1,40}(\.\d{1,80})?$") + + +def _rat(x): + if isinstance(x, bool): + raise Invalid("coordinates must be numbers") + if isinstance(x, int): + return Fraction(x) + if isinstance(x, float): + if not math.isfinite(x): + raise Invalid("non-finite coordinate") + return Fraction(repr(x)) + if isinstance(x, str) and DEC.fullmatch(x): + return Fraction(x) + raise Invalid("coordinates must be numbers or decimal strings") + + +def check(inst, ans): + n, d = inst["n"], inst["dim"] + vs = ans.get("vectors") + if not isinstance(vs, list) or len(vs) != n: + raise Invalid(f"vectors must be a list of exactly {n} vectors") + rows = [] + for v in vs: + if not isinstance(v, list) or len(v) != d: + raise Invalid(f"each vector must have exactly {d} coordinates") + rows.append([_rat(x) for x in v]) + den = 1 + for r in rows: + for q in r: + den = den * q.denominator // math.gcd(den, q.denominator) + R = [[int(q * den) for q in r] for r in rows] + N = [sum(x * x for x in r) for r in R] + if min(N) == 0: + raise Invalid("all vectors must be non-zero") + loss, bad = 0.0, 0 + for i in range(n): + ri, Ni = R[i], N[i] + for j in range(i + 1, n): + p = sum(a * b for a, b in zip(ri, R[j])) + if p <= 0: + continue + NN = Ni * N[j] + ex = 4 * p * p - NN + if ex <= 0: + continue + bad += 1 + q = float(Fraction(ex, NN)) # 4 cos^2 - 1 > 0 + c = min(1.0, float(Fraction(p * p, NN)) ** 0.5) + ov = 2.0 * (q / (2 * c + 1)) / (1.0 + math.sqrt(max(0.0, 2 - 2 * c))) + loss += max(ov, 1e-300) + return loss, {"overlapping_pairs": bad} diff --git a/tasks/optimize-ea-kissing-d11-n594/tests/instance.json b/tasks/optimize-ea-kissing-d11-n594/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d2d403852b04bd96211f4dafb47d9d92058671b2 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n594/tests/instance.json @@ -0,0 +1 @@ +{"dim": 11, "n": 594, "direction": "minimize", "best_known": 0.0, "progress_scale": "log", "log_floor": 0.001, "baseline": 1842.7998465288015, "family": "ea_kissing_number", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-kissing-d11-n594/tests/run.py b/tasks/optimize-ea-kissing-d11-n594/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n594/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ea-kissing-d11-n594/tests/test.sh b/tasks/optimize-ea-kissing-d11-n594/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n594/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ea-no-three-in-line-n75/environment/Dockerfile b/tasks/optimize-ea-no-three-in-line-n75/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ea-no-three-in-line-n75/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ea-no-three-in-line-n75/environment/instance.json b/tasks/optimize-ea-no-three-in-line-n75/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..356e89e3a8cae38e65355030dba0d00998c0ec79 --- /dev/null +++ b/tasks/optimize-ea-no-three-in-line-n75/environment/instance.json @@ -0,0 +1 @@ +{"grid": 75, "max_points": 150, "direction": "maximize", "family": "ea_no_three_in_line_75", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-no-three-in-line-n75/solution/solve.sh b/tasks/optimize-ea-no-three-in-line-n75/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b8bb617c74ec66f4f35962844803f37eb1d0c59 --- /dev/null +++ b/tasks/optimize-ea-no-three-in-line-n75/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[25, 0], [45, 0], [44, 1], [54, 1], [22, 2], [40, 2], [15, 3], [69, 3], [3, 4], [18, 4], [30, 5], [50, 5], [36, 6], [46, 6], [40, 7], [50, 7], [19, 8], [55, 8], [11, 9], [53, 9], [37, 10], [44, 10], [32, 11], [64, 11], [21, 12], [25, 12], [14, 13], [27, 13], [51, 14], [60, 14], [42, 15], [70, 15], [16, 16], [57, 16], [39, 17], [53, 17], [8, 18], [69, 18], [1, 19], [65, 19], [9, 20], [17, 20], [45, 21], [61, 21], [14, 22], [71, 22], [5, 23], [7, 23], [26, 24], [30, 24], [61, 25], [73, 25], [34, 26], [49, 26], [6, 27], [60, 27], [0, 28], [21, 28], [1, 29], [10, 29], [49, 30], [68, 30], [15, 31], [38, 31], [35, 32], [62, 32], [2, 33], [7, 33], [17, 34], [47, 34], [31, 35], [41, 35], [10, 36], [67, 36], [6, 37], [63, 37], [32, 38], [42, 38], [26, 39], [56, 39], [66, 40], [71, 40], [11, 41], [38, 41], [35, 42], [58, 42], [5, 43], [24, 43], [63, 44], [72, 44], [52, 45], [73, 45], [13, 46], [67, 46], [24, 47], [39, 47], [0, 48], [12, 48], [43, 49], [47, 49], [66, 50], [68, 50], [2, 51], [59, 51], [12, 52], [28, 52], [56, 53], [64, 53], [8, 54], [72, 54], [4, 55], [65, 55], [20, 56], [34, 56], [16, 57], [57, 57], [3, 58], [31, 58], [13, 59], [22, 59], [46, 60], [59, 60], [48, 61], [52, 61], [9, 62], [41, 62], [29, 63], [36, 63], [20, 64], [62, 64], [18, 65], [54, 65], [23, 66], [33, 66], [27, 67], [37, 67], [23, 68], [43, 68], [55, 69], [70, 69], [4, 70], [58, 70], [33, 71], [51, 71], [19, 72], [29, 72], [28, 73], [48, 73]]} +RLMATH_EOF diff --git a/tasks/optimize-ea-no-three-in-line-n75/tests/check.py b/tasks/optimize-ea-no-three-in-line-n75/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..5c7878ef4268634632328aae2c655529ed7426c2 --- /dev/null +++ b/tasks/optimize-ea-no-three-in-line-n75/tests/check.py @@ -0,0 +1,31 @@ +"""No-three-in-line on the 75x75 grid (EinsteinArena no-three-in-line-75, MIT). + +Audit: upstream verifier is exact integer arithmetic over all triples; sound. Re-implemented with a +slope-hash per anchor point (same result, O(n^2) instead of O(n^3)).""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + g, cap = inst["grid"], inst["max_points"] + pts = ans.get("points") + if not isinstance(pts, list) or not 1 <= len(pts) <= cap: + raise Invalid(f"points must be a list of 1..{cap} pairs") + P = [tuple(int_list(p, 2, 0, g - 1, "point")) for p in pts] + if len(set(P)) != len(P): + raise Invalid("points must be distinct") + for i, (x1, y1) in enumerate(P): + seen = set() + for j, (x2, y2) in enumerate(P): + if j == i: + continue + dx, dy = x2 - x1, y2 - y1 + d = math.gcd(dx, dy) + dx, dy = dx // d, dy // d + if dx < 0 or (dx == 0 and dy < 0): + dx, dy = -dx, -dy + if (dx, dy) in seen: + raise Invalid(f"three collinear points including {P[i]}") + seen.add((dx, dy)) + return float(len(P)), {} diff --git a/tasks/optimize-ea-no-three-in-line-n75/tests/instance.json b/tasks/optimize-ea-no-three-in-line-n75/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..123378f9559f671b40bd53c24138bd6b77f060d5 --- /dev/null +++ b/tasks/optimize-ea-no-three-in-line-n75/tests/instance.json @@ -0,0 +1 @@ +{"grid": 75, "max_points": 150, "direction": "maximize", "best_known": 148, "baseline": 73.0, "family": "ea_no_three_in_line_75", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-no-three-in-line-n75/tests/run.py b/tasks/optimize-ea-no-three-in-line-n75/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ea-no-three-in-line-n75/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ea-no-three-in-line-n75/tests/test.sh b/tasks/optimize-ea-no-three-in-line-n75/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ea-no-three-in-line-n75/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt