diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s2/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s2/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6bfd975962b95b15ca6e2a1faec00d443c7f000c --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"N": 97, "t": 28, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s2/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd3f9afa673c421fbdb16a4e03cb91941674d7da --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [336, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 36, 36, 36, 36, 37, 37, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 41, 41, 43, 43, 46, 46, 46, 46, 47, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6bfd975962b95b15ca6e2a1faec00d443c7f000c --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"N": 97, "t": 28, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s2/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s5/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s5/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6490bbc66db765f6d199fd9a46609f3d49430df3 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"N": 119, "t": 35, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s5/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f398aacbe28aff155c1f917d8f9c995e3b0357da --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 46, 46, 46, 46, 46, 47, 47, 49, 49, 51, 51, 51, 51, 51, 51, 51, 53, 53, 58, 58, 58, 58, 59, 59, 61, 62, 62, 67, 71, 73, 79, 83, 89, 93, 97, 101, 103, 107, 109, 113]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6490bbc66db765f6d199fd9a46609f3d49430df3 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"N": 119, "t": 35, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s5/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p52-erdos-squarefree-l2-s9/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-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-ae-p52-erdos-squarefree-l2-s9/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a2faadb61a42e7bf5afc857c3f50e03e55e9d6d0 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"N": 127, "t": 5, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s9/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b6c050b7f1a69fce328d246ba66a8611e0c1111e --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-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' +{"A": [7, 32, 57, 82, 107]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a2faadb61a42e7bf5afc857c3f50e03e55e9d6d0 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"N": 127, "t": 5, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-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-ae-p52-erdos-squarefree-l2-s9/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-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-mc-all-interval-l6-s3/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l6-s3/environment/instance.json b/tasks/construct-mc-all-interval-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5189e5ab251d5915bcf888d246641bdbe502de37 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 96, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s3/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2501609faa98b4bbee76039e000f9a1c0e09c268 --- /dev/null +++ b/tasks/construct-mc-all-interval-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": [0, 95, 1, 94, 2, 93, 3, 92, 4, 91, 5, 90, 6, 89, 7, 88, 8, 87, 9, 86, 10, 85, 11, 84, 12, 83, 13, 82, 14, 81, 15, 80, 16, 79, 17, 78, 18, 77, 19, 76, 20, 75, 21, 74, 22, 73, 23, 72, 24, 71, 25, 70, 26, 69, 27, 68, 28, 67, 29, 66, 30, 65, 31, 64, 32, 63, 33, 62, 34, 61, 35, 60, 36, 59, 37, 58, 38, 57, 39, 56, 40, 55, 41, 54, 42, 53, 43, 52, 44, 51, 45, 50, 46, 49, 47, 48]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s3/tests/check.py b/tasks/construct-mc-all-interval-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s3/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l6-s3/tests/instance.json b/tasks/construct-mc-all-interval-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5189e5ab251d5915bcf888d246641bdbe502de37 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 96, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s3/tests/run.py b/tasks/construct-mc-all-interval-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-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-all-interval-l6-s3/tests/test.sh b/tasks/construct-mc-all-interval-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l6-s4/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-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-all-interval-l6-s4/environment/instance.json b/tasks/construct-mc-all-interval-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f5080dd847c357171098181778dcadb5488969da --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 112, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s4/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..36d0fc0ca95c3057131c7c460350716113ff4948 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-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, 111, 1, 110, 2, 109, 3, 108, 4, 107, 5, 106, 6, 105, 7, 104, 8, 103, 9, 102, 10, 101, 11, 100, 12, 99, 13, 98, 14, 97, 15, 96, 16, 95, 17, 94, 18, 93, 19, 92, 20, 91, 21, 90, 22, 89, 23, 88, 24, 87, 25, 86, 26, 85, 27, 84, 28, 83, 29, 82, 30, 81, 31, 80, 32, 79, 33, 78, 34, 77, 35, 76, 36, 75, 37, 74, 38, 73, 39, 72, 40, 71, 41, 70, 42, 69, 43, 68, 44, 67, 45, 66, 46, 65, 47, 64, 48, 63, 49, 62, 50, 61, 51, 60, 52, 59, 53, 58, 54, 57, 55, 56]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s4/tests/check.py b/tasks/construct-mc-all-interval-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s4/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l6-s4/tests/instance.json b/tasks/construct-mc-all-interval-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f5080dd847c357171098181778dcadb5488969da --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 112, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s4/tests/run.py b/tasks/construct-mc-all-interval-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-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-all-interval-l6-s4/tests/test.sh b/tasks/construct-mc-all-interval-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-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-mc-bibd-l1-s0/environment/Dockerfile b/tasks/construct-mc-bibd-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-bibd-l1-s0/environment/instance.json b/tasks/construct-mc-bibd-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd23f60378d49bafb8d8c55de75674fe7f536493 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"v": 7, "k": 3, "lambda": 1, "b": 7, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l1-s0/solution/solve.sh b/tasks/construct-mc-bibd-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e7caf945d573cc482405f6635a09ed698fc5e45d --- /dev/null +++ b/tasks/construct-mc-bibd-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' +{"blocks": [[0, 1, 3], [1, 2, 4], [2, 3, 5], [3, 4, 6], [0, 4, 5], [1, 5, 6], [0, 2, 6]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l1-s0/tests/check.py b/tasks/construct-mc-bibd-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s0/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-l1-s0/tests/instance.json b/tasks/construct-mc-bibd-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd23f60378d49bafb8d8c55de75674fe7f536493 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"v": 7, "k": 3, "lambda": 1, "b": 7, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l1-s0/tests/run.py b/tasks/construct-mc-bibd-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-bibd-l1-s0/tests/test.sh b/tasks/construct-mc-bibd-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-bibd-l5-s1/environment/Dockerfile b/tasks/construct-mc-bibd-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-bibd-l5-s1/environment/instance.json b/tasks/construct-mc-bibd-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e00dd2ed02291360a853cab2ad424ed10a96a0a5 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"v": 25, "k": 5, "lambda": 1, "b": 30, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l5-s1/solution/solve.sh b/tasks/construct-mc-bibd-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc7689932698bb17e344c2f1533859852ee8e4f2 --- /dev/null +++ b/tasks/construct-mc-bibd-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' +{"blocks": [[0, 5, 10, 15, 20], [1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], [0, 6, 12, 18, 24], [1, 7, 13, 19, 20], [2, 8, 14, 15, 21], [3, 9, 10, 16, 22], [4, 5, 11, 17, 23], [0, 7, 14, 16, 23], [1, 8, 10, 17, 24], [2, 9, 11, 18, 20], [3, 5, 12, 19, 21], [4, 6, 13, 15, 22], [0, 8, 11, 19, 22], [1, 9, 12, 15, 23], [2, 5, 13, 16, 24], [3, 6, 14, 17, 20], [4, 7, 10, 18, 21], [0, 9, 13, 17, 21], [1, 5, 14, 18, 22], [2, 6, 10, 19, 23], [3, 7, 11, 15, 24], [4, 8, 12, 16, 20], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l5-s1/tests/check.py b/tasks/construct-mc-bibd-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s1/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-l5-s1/tests/instance.json b/tasks/construct-mc-bibd-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e00dd2ed02291360a853cab2ad424ed10a96a0a5 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"v": 25, "k": 5, "lambda": 1, "b": 30, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l5-s1/tests/run.py b/tasks/construct-mc-bibd-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-bibd-l5-s1/tests/test.sh b/tasks/construct-mc-bibd-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-debruijn-l1-s0/environment/Dockerfile b/tasks/construct-mc-debruijn-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-mc-debruijn-l1-s0/environment/instance.json b/tasks/construct-mc-debruijn-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca7b80584ef6c3794b9fddac4cfed374f80f348c --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"b": 2, "n": 4, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l1-s0/solution/solve.sh b/tasks/construct-mc-debruijn-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..de347a63f9d7971979f8ea56e710ade23350d7c8 --- /dev/null +++ b/tasks/construct-mc-debruijn-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' +{"seq": [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l1-s0/tests/check.py b/tasks/construct-mc-debruijn-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s0/tests/check.py @@ -0,0 +1,15 @@ +"""De Bruijn sequence B(b, n) (MathConstraint debruijn, CC-BY-4.0). Accepts any valid cyclic sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + b, n = inst["b"], inst["n"] + m = b ** n + x = int_list(ans.get("seq"), m, 0, b - 1, "seq") + seen = set() + for i in range(m): + w = tuple(x[(i + k) % m] for k in range(n)) + if w in seen: + raise Invalid(f"window {w} occurs twice") + seen.add(w) + return None, {} diff --git a/tasks/construct-mc-debruijn-l1-s0/tests/instance.json b/tasks/construct-mc-debruijn-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca7b80584ef6c3794b9fddac4cfed374f80f348c --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"b": 2, "n": 4, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l1-s0/tests/run.py b/tasks/construct-mc-debruijn-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-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-mc-debruijn-l1-s0/tests/test.sh b/tasks/construct-mc-debruijn-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-mc-graceful-graph-l5-s2/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l5-s2/environment/instance.json b/tasks/construct-mc-graceful-graph-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2834204680c0a6ff66d37d03a9c5e46c2e22acd1 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"k": 5, "p": 3, "num_vertices": 15, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l5-s2/solution/solve.sh b/tasks/construct-mc-graceful-graph-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6175dc670815eeccef8d8ed0d2fef1ede8987c8b --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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' +{"labels": [1, 3, 6, 26, 37, 0, 22, 32, 39, 4, 40, 10, 16, 2, 31]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l5-s2/tests/check.py b/tasks/construct-mc-graceful-graph-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s2/tests/check.py @@ -0,0 +1,19 @@ +"""Graceful labelling of K_k x P_p (MathConstraint graceful_graph, CC-BY-4.0): distinct vertex labels in +0..m (m = number of edges) whose edge differences |l(u) - l(v)| are all distinct.""" +from run import Invalid, int_list + + +def check(inst, ans): + nv, edges = inst["num_vertices"], inst["edges"] + m = len(edges) + x = int_list(ans.get("labels"), nv, 0, m, "labels") + if len(set(x)) != nv: + raise Invalid("vertex labels must be distinct") + d = [abs(x[u] - x[v]) for u, v in edges] + if len(set(d)) != m: + raise Invalid("edge labels are not distinct") + seqs = {"labels": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-graceful-graph-l5-s2/tests/instance.json b/tasks/construct-mc-graceful-graph-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2834204680c0a6ff66d37d03a9c5e46c2e22acd1 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"k": 5, "p": 3, "num_vertices": 15, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l5-s2/tests/run.py b/tasks/construct-mc-graceful-graph-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l5-s2/tests/test.sh b/tasks/construct-mc-graceful-graph-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graph-k-coloring-l1-s3/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l1-s3/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb91c0aa6f9e142e371de85f808946be3c075cef --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 4], [0, 7], [0, 13], [0, 14], [1, 6], [1, 10], [1, 14], [1, 18], [2, 4], [2, 9], [2, 16], [4, 11], [4, 12], [4, 14], [5, 8], [5, 16], [6, 7], [6, 13], [6, 14], [6, 15], [7, 12], [7, 19], [8, 14], [10, 12], [10, 19], [11, 16], [11, 17], [12, 13], [13, 18], [18, 19]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s3/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..951b7416a0066f206ad51b89dffc6d0e9adf2773 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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' +{"coloring": [0, 0, 0, 2, 2, 1, 2, 1, 0, 1, 2, 1, 0, 1, 1, 1, 2, 0, 2, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l1-s3/tests/check.py b/tasks/construct-mc-graph-k-coloring-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s3/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-l1-s3/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb91c0aa6f9e142e371de85f808946be3c075cef --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 4], [0, 7], [0, 13], [0, 14], [1, 6], [1, 10], [1, 14], [1, 18], [2, 4], [2, 9], [2, 16], [4, 11], [4, 12], [4, 14], [5, 8], [5, 16], [6, 7], [6, 13], [6, 14], [6, 15], [7, 12], [7, 19], [8, 14], [10, 12], [10, 19], [11, 16], [11, 17], [12, 13], [13, 18], [18, 19]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s3/tests/run.py b/tasks/construct-mc-graph-k-coloring-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l1-s3/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l5-s2/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s2/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb672b5a62d848fc50329f927749e05344776fac --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 18], [0, 19], [0, 54], [0, 56], [0, 67], [0, 74], [0, 78], [1, 54], [1, 87], [2, 12], [2, 14], [2, 24], [2, 30], [2, 77], [3, 14], [3, 19], [3, 25], [3, 37], [3, 46], [3, 55], [3, 69], [3, 83], [4, 33], [4, 50], [4, 53], [4, 58], [4, 74], [4, 78], [4, 83], [4, 90], [5, 12], [5, 24], [5, 30], [5, 35], [5, 49], [5, 51], [5, 76], [5, 87], [6, 38], [6, 42], [6, 55], [6, 58], [6, 60], [6, 79], [6, 86], [6, 93], [7, 12], [7, 19], [7, 41], [7, 82], [8, 14], [8, 17], [8, 20], [8, 26], [8, 30], [8, 54], [8, 55], [8, 79], [8, 81], [8, 86], [9, 12], [9, 17], [9, 25], [9, 53], [9, 55], [9, 71], [9, 72], [9, 77], [9, 96], [10, 15], [10, 35], [10, 44], [10, 51], [10, 58], [10, 84], [10, 87], [10, 88], [10, 93], [11, 28], [11, 29], [11, 37], [11, 45], [11, 50], [11, 76], [12, 15], [12, 27], [12, 30], [12, 36], [12, 51], [13, 31], [13, 48], [13, 77], [13, 94], [13, 96], [14, 23], [14, 38], [14, 61], [15, 21], [15, 22], [15, 25], [15, 35], [15, 67], [15, 70], [15, 85], [15, 86], [15, 92], [16, 45], [16, 54], [16, 69], [16, 80], [17, 23], [17, 35], [17, 38], [17, 47], [17, 54], [17, 72], [17, 99], [18, 55], [18, 62], [18, 68], [18, 69], [18, 79], [18, 87], [18, 94], [19, 57], [19, 61], [19, 62], [19, 67], [19, 73], [19, 79], [19, 84], [19, 87], [19, 97], [19, 98], [20, 24], [20, 28], [20, 31], [20, 54], [20, 59], [20, 60], [20, 88], [21, 25], [21, 28], [21, 33], [21, 50], [21, 59], [21, 97], [22, 34], [22, 37], [22, 47], [22, 56], [22, 74], [22, 77], [22, 79], [23, 29], [23, 37], [23, 54], [23, 76], [23, 86], [23, 87], [23, 94], [24, 26], [24, 67], [24, 72], [24, 91], [25, 28], [25, 29], [25, 44], [25, 69], [25, 71], [25, 82], [25, 86], [26, 41], [26, 43], [26, 49], [26, 80], [26, 85], [26, 88], [26, 98], [27, 57], [27, 61], [27, 68], [27, 73], [27, 87], [27, 95], [27, 97], [27, 98], [28, 46], [28, 56], [28, 62], [28, 68], [28, 75], [28, 91], [29, 32], [29, 34], [29, 36], [29, 50], [29, 73], [29, 81], [30, 31], [30, 40], [30, 59], [30, 95], [31, 45], [31, 50], [31, 52], [31, 68], [32, 36], [32, 74], [32, 76], [32, 81], [32, 83], [32, 85], [32, 89], [32, 97], [33, 44], [33, 55], [33, 57], [33, 67], [33, 95], [34, 49], [34, 51], [34, 60], [34, 61], [34, 67], [34, 79], [34, 96], [35, 42], [35, 58], [35, 77], [35, 91], [35, 92], [36, 37], [36, 40], [36, 49], [36, 51], [36, 60], [36, 66], [36, 97], [36, 98], [37, 43], [37, 46], [37, 50], [37, 56], [37, 91], [38, 49], [38, 57], [38, 62], [38, 71], [39, 44], [39, 59], [39, 62], [39, 63], [39, 66], [39, 75], [39, 91], [40, 47], [40, 60], [40, 67], [40, 75], [40, 86], [41, 43], [41, 44], [41, 50], [41, 61], [41, 63], [41, 73], [41, 95], [41, 98], [42, 59], [42, 60], [42, 69], [42, 80], [42, 83], [43, 45], [43, 47], [43, 49], [43, 72], [43, 81], [43, 94], [43, 96], [44, 56], [44, 57], [45, 74], [45, 85], [45, 94], [45, 95], [46, 50], [46, 99], [47, 57], [47, 78], [47, 88], [47, 93], [47, 96], [47, 99], [48, 64], [48, 84], [49, 50], [49, 54], [49, 73], [49, 90], [49, 98], [49, 99], [50, 66], [50, 92], [51, 58], [51, 63], [51, 80], [51, 90], [51, 96], [52, 58], [52, 97], [53, 61], [53, 67], [53, 68], [53, 84], [53, 98], [54, 62], [54, 70], [54, 85], [54, 97], [55, 57], [55, 59], [55, 62], [55, 65], [55, 72], [55, 79], [55, 91], [55, 94], [56, 57], [56, 61], [56, 95], [57, 67], [57, 82], [57, 98], [57, 99], [58, 69], [58, 78], [58, 88], [58, 91], [59, 71], [59, 77], [59, 80], [61, 70], [61, 86], [62, 65], [62, 77], [62, 85], [62, 93], [63, 67], [63, 69], [63, 89], [64, 77], [64, 94], [65, 82], [65, 89], [66, 70], [66, 83], [67, 70], [67, 77], [67, 80], [67, 90], [67, 95], [67, 98], [68, 70], [68, 80], [69, 77], [69, 90], [69, 92], [69, 94], [70, 87], [70, 92], [71, 76], [71, 81], [71, 88], [71, 99], [72, 76], [72, 95], [73, 79], [73, 89], [73, 96], [75, 92], [75, 96], [76, 95], [77, 81], [78, 85], [78, 96], [80, 92], [80, 93], [81, 87], [81, 95], [81, 97], [83, 92], [84, 88], [85, 90], [87, 98], [89, 95], [92, 95], [92, 99], [94, 99]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s2/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8f1d45e21c928769c9b5ec1f51f68f2af967b8ca --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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' +{"coloring": [0, 0, 1, 1, 2, 1, 1, 1, 1, 1, 3, 3, 0, 1, 2, 1, 1, 0, 3, 3, 3, 2, 2, 3, 0, 3, 2, 3, 0, 2, 2, 0, 1, 3, 3, 2, 3, 0, 3, 0, 0, 0, 0, 1, 1, 2, 3, 3, 2, 0, 1, 2, 2, 3, 2, 2, 3, 0, 0, 1, 2, 1, 1, 1, 3, 0, 2, 2, 2, 2, 3, 0, 3, 1, 3, 3, 2, 0, 1, 0, 3, 3, 2, 3, 0, 3, 2, 2, 1, 2, 1, 1, 0, 0, 0, 1, 0, 0, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l5-s2/tests/check.py b/tasks/construct-mc-graph-k-coloring-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s2/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-l5-s2/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb672b5a62d848fc50329f927749e05344776fac --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 18], [0, 19], [0, 54], [0, 56], [0, 67], [0, 74], [0, 78], [1, 54], [1, 87], [2, 12], [2, 14], [2, 24], [2, 30], [2, 77], [3, 14], [3, 19], [3, 25], [3, 37], [3, 46], [3, 55], [3, 69], [3, 83], [4, 33], [4, 50], [4, 53], [4, 58], [4, 74], [4, 78], [4, 83], [4, 90], [5, 12], [5, 24], [5, 30], [5, 35], [5, 49], [5, 51], [5, 76], [5, 87], [6, 38], [6, 42], [6, 55], [6, 58], [6, 60], [6, 79], [6, 86], [6, 93], [7, 12], [7, 19], [7, 41], [7, 82], [8, 14], [8, 17], [8, 20], [8, 26], [8, 30], [8, 54], [8, 55], [8, 79], [8, 81], [8, 86], [9, 12], [9, 17], [9, 25], [9, 53], [9, 55], [9, 71], [9, 72], [9, 77], [9, 96], [10, 15], [10, 35], [10, 44], [10, 51], [10, 58], [10, 84], [10, 87], [10, 88], [10, 93], [11, 28], [11, 29], [11, 37], [11, 45], [11, 50], [11, 76], [12, 15], [12, 27], [12, 30], [12, 36], [12, 51], [13, 31], [13, 48], [13, 77], [13, 94], [13, 96], [14, 23], [14, 38], [14, 61], [15, 21], [15, 22], [15, 25], [15, 35], [15, 67], [15, 70], [15, 85], [15, 86], [15, 92], [16, 45], [16, 54], [16, 69], [16, 80], [17, 23], [17, 35], [17, 38], [17, 47], [17, 54], [17, 72], [17, 99], [18, 55], [18, 62], [18, 68], [18, 69], [18, 79], [18, 87], [18, 94], [19, 57], [19, 61], [19, 62], [19, 67], [19, 73], [19, 79], [19, 84], [19, 87], [19, 97], [19, 98], [20, 24], [20, 28], [20, 31], [20, 54], [20, 59], [20, 60], [20, 88], [21, 25], [21, 28], [21, 33], [21, 50], [21, 59], [21, 97], [22, 34], [22, 37], [22, 47], [22, 56], [22, 74], [22, 77], [22, 79], [23, 29], [23, 37], [23, 54], [23, 76], [23, 86], [23, 87], [23, 94], [24, 26], [24, 67], [24, 72], [24, 91], [25, 28], [25, 29], [25, 44], [25, 69], [25, 71], [25, 82], [25, 86], [26, 41], [26, 43], [26, 49], [26, 80], [26, 85], [26, 88], [26, 98], [27, 57], [27, 61], [27, 68], [27, 73], [27, 87], [27, 95], [27, 97], [27, 98], [28, 46], [28, 56], [28, 62], [28, 68], [28, 75], [28, 91], [29, 32], [29, 34], [29, 36], [29, 50], [29, 73], [29, 81], [30, 31], [30, 40], [30, 59], [30, 95], [31, 45], [31, 50], [31, 52], [31, 68], [32, 36], [32, 74], [32, 76], [32, 81], [32, 83], [32, 85], [32, 89], [32, 97], [33, 44], [33, 55], [33, 57], [33, 67], [33, 95], [34, 49], [34, 51], [34, 60], [34, 61], [34, 67], [34, 79], [34, 96], [35, 42], [35, 58], [35, 77], [35, 91], [35, 92], [36, 37], [36, 40], [36, 49], [36, 51], [36, 60], [36, 66], [36, 97], [36, 98], [37, 43], [37, 46], [37, 50], [37, 56], [37, 91], [38, 49], [38, 57], [38, 62], [38, 71], [39, 44], [39, 59], [39, 62], [39, 63], [39, 66], [39, 75], [39, 91], [40, 47], [40, 60], [40, 67], [40, 75], [40, 86], [41, 43], [41, 44], [41, 50], [41, 61], [41, 63], [41, 73], [41, 95], [41, 98], [42, 59], [42, 60], [42, 69], [42, 80], [42, 83], [43, 45], [43, 47], [43, 49], [43, 72], [43, 81], [43, 94], [43, 96], [44, 56], [44, 57], [45, 74], [45, 85], [45, 94], [45, 95], [46, 50], [46, 99], [47, 57], [47, 78], [47, 88], [47, 93], [47, 96], [47, 99], [48, 64], [48, 84], [49, 50], [49, 54], [49, 73], [49, 90], [49, 98], [49, 99], [50, 66], [50, 92], [51, 58], [51, 63], [51, 80], [51, 90], [51, 96], [52, 58], [52, 97], [53, 61], [53, 67], [53, 68], [53, 84], [53, 98], [54, 62], [54, 70], [54, 85], [54, 97], [55, 57], [55, 59], [55, 62], [55, 65], [55, 72], [55, 79], [55, 91], [55, 94], [56, 57], [56, 61], [56, 95], [57, 67], [57, 82], [57, 98], [57, 99], [58, 69], [58, 78], [58, 88], [58, 91], [59, 71], [59, 77], [59, 80], [61, 70], [61, 86], [62, 65], [62, 77], [62, 85], [62, 93], [63, 67], [63, 69], [63, 89], [64, 77], [64, 94], [65, 82], [65, 89], [66, 70], [66, 83], [67, 70], [67, 77], [67, 80], [67, 90], [67, 95], [67, 98], [68, 70], [68, 80], [69, 77], [69, 90], [69, 92], [69, 94], [70, 87], [70, 92], [71, 76], [71, 81], [71, 88], [71, 99], [72, 76], [72, 95], [73, 79], [73, 89], [73, 96], [75, 92], [75, 96], [76, 95], [77, 81], [78, 85], [78, 96], [80, 92], [80, 93], [81, 87], [81, 95], [81, 97], [83, 92], [84, 88], [85, 90], [87, 98], [89, 95], [92, 95], [92, 99], [94, 99]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s2/tests/run.py b/tasks/construct-mc-graph-k-coloring-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s2/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s5/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l5-s5/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1598847181fdf6528ac65beca0f682b5d8b29f6f --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 2], [0, 23], [0, 33], [0, 61], [0, 87], [1, 26], [1, 36], [1, 52], [1, 63], [1, 71], [1, 76], [1, 79], [1, 85], [1, 97], [2, 28], [2, 42], [2, 45], [2, 95], [3, 6], [3, 13], [3, 15], [3, 27], [3, 31], [3, 33], [3, 58], [4, 12], [4, 17], [4, 21], [4, 34], [4, 42], [4, 58], [4, 85], [4, 88], [4, 97], [4, 98], [5, 23], [5, 55], [5, 56], [5, 76], [5, 79], [5, 91], [5, 96], [6, 15], [6, 21], [6, 45], [6, 56], [6, 65], [6, 76], [6, 89], [7, 8], [7, 20], [7, 36], [7, 43], [7, 93], [7, 96], [7, 97], [8, 26], [8, 68], [8, 70], [8, 71], [8, 74], [8, 75], [8, 77], [8, 91], [9, 36], [9, 48], [9, 50], [9, 58], [9, 93], [9, 99], [10, 12], [10, 19], [10, 25], [10, 26], [10, 50], [10, 58], [10, 62], [10, 66], [10, 79], [10, 89], [10, 96], [10, 98], [11, 18], [11, 41], [11, 43], [11, 54], [11, 69], [11, 74], [11, 94], [12, 22], [12, 24], [12, 27], [12, 32], [12, 49], [12, 65], [12, 67], [12, 70], [12, 75], [12, 82], [13, 25], [13, 45], [13, 48], [13, 49], [13, 68], [13, 69], [13, 87], [13, 98], [14, 53], [14, 70], [14, 72], [14, 81], [14, 84], [14, 90], [15, 22], [15, 40], [15, 57], [15, 71], [15, 73], [16, 39], [16, 96], [17, 22], [17, 23], [17, 32], [17, 36], [17, 42], [17, 79], [17, 86], [17, 87], [18, 24], [18, 29], [18, 54], [19, 46], [19, 69], [19, 74], [19, 87], [20, 35], [20, 38], [20, 54], [20, 68], [20, 96], [21, 48], [21, 60], [21, 69], [21, 70], [21, 78], [22, 25], [22, 37], [22, 45], [22, 67], [22, 74], [22, 88], [22, 99], [23, 32], [23, 45], [23, 66], [23, 68], [23, 77], [24, 30], [24, 38], [24, 45], [24, 48], [24, 66], [24, 71], [24, 73], [24, 78], [24, 93], [25, 31], [25, 33], [25, 37], [25, 40], [25, 65], [25, 97], [26, 36], [26, 57], [26, 67], [26, 74], [26, 85], [26, 97], [27, 30], [27, 62], [27, 99], [28, 29], [28, 58], [28, 59], [28, 65], [28, 78], [28, 79], [28, 87], [28, 96], [29, 45], [29, 56], [29, 59], [29, 66], [29, 75], [29, 76], [29, 85], [29, 93], [29, 94], [30, 42], [30, 68], [31, 40], [31, 49], [31, 53], [31, 62], [31, 63], [31, 85], [31, 91], [31, 92], [32, 43], [32, 62], [32, 63], [33, 44], [33, 48], [33, 49], [33, 54], [33, 81], [34, 47], [34, 54], [34, 58], [34, 59], [34, 74], [34, 76], [34, 88], [35, 44], [35, 60], [35, 87], [35, 99], [36, 68], [36, 83], [36, 91], [36, 94], [37, 47], [37, 48], [37, 56], [37, 62], [37, 80], [37, 89], [38, 45], [38, 50], [38, 54], [38, 63], [38, 65], [38, 96], [38, 99], [39, 47], [39, 58], [39, 76], [39, 83], [39, 84], [39, 97], [40, 50], [40, 56], [40, 60], [40, 68], [40, 69], [40, 82], [40, 92], [41, 44], [41, 45], [41, 47], [41, 89], [42, 48], [42, 49], [42, 57], [42, 61], [42, 64], [42, 69], [42, 83], [42, 87], [42, 89], [42, 91], [43, 50], [43, 62], [43, 74], [43, 85], [44, 69], [44, 73], [44, 82], [44, 93], [44, 99], [45, 46], [45, 50], [45, 54], [45, 72], [45, 77], [45, 95], [46, 56], [46, 57], [46, 71], [47, 85], [47, 89], [47, 94], [48, 53], [48, 59], [48, 65], [48, 89], [48, 98], [49, 61], [49, 67], [49, 70], [49, 87], [50, 69], [51, 55], [51, 56], [51, 78], [51, 84], [51, 93], [52, 65], [52, 68], [52, 70], [52, 90], [52, 99], [53, 64], [53, 73], [53, 84], [53, 87], [54, 65], [54, 68], [54, 70], [54, 80], [55, 56], [55, 64], [55, 70], [56, 57], [56, 60], [56, 68], [56, 79], [57, 70], [57, 81], [57, 88], [57, 92], [58, 74], [58, 83], [58, 94], [59, 82], [59, 90], [59, 91], [60, 65], [60, 68], [60, 77], [60, 82], [61, 71], [61, 76], [61, 86], [61, 94], [62, 69], [62, 78], [62, 84], [62, 88], [62, 91], [63, 80], [63, 85], [63, 89], [64, 70], [64, 81], [64, 89], [64, 90], [64, 94], [64, 95], [66, 68], [66, 86], [66, 88], [67, 73], [68, 76], [68, 84], [68, 87], [69, 71], [69, 78], [69, 90], [70, 94], [72, 79], [72, 86], [72, 93], [73, 93], [74, 89], [75, 80], [75, 81], [76, 87], [76, 98], [77, 99], [78, 80], [79, 81], [79, 85], [79, 86], [80, 92], [80, 99], [81, 87], [81, 92], [82, 89], [83, 86], [85, 87], [85, 94], [85, 97], [88, 92], [88, 99], [89, 96], [91, 99], [92, 94], [95, 96], [95, 97]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s5/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d8ba36bcab846b76e9c3d9f7c7ee7189cf7594fb --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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' +{"coloring": [3, 2, 1, 0, 0, 3, 1, 3, 1, 3, 3, 0, 2, 2, 1, 3, 2, 2, 2, 0, 0, 2, 1, 1, 1, 0, 0, 3, 2, 1, 0, 1, 3, 2, 2, 2, 1, 3, 2, 3, 2, 1, 3, 2, 3, 3, 2, 0, 0, 0, 0, 1, 1, 3, 1, 2, 0, 1, 1, 3, 1, 1, 0, 0, 1, 3, 0, 3, 3, 1, 3, 0, 0, 0, 3, 0, 0, 2, 3, 1, 2, 3, 0, 0, 2, 3, 3, 1, 3, 2, 2, 2, 0, 2, 2, 2, 1, 1, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l5-s5/tests/check.py b/tasks/construct-mc-graph-k-coloring-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s5/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-l5-s5/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1598847181fdf6528ac65beca0f682b5d8b29f6f --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 2], [0, 23], [0, 33], [0, 61], [0, 87], [1, 26], [1, 36], [1, 52], [1, 63], [1, 71], [1, 76], [1, 79], [1, 85], [1, 97], [2, 28], [2, 42], [2, 45], [2, 95], [3, 6], [3, 13], [3, 15], [3, 27], [3, 31], [3, 33], [3, 58], [4, 12], [4, 17], [4, 21], [4, 34], [4, 42], [4, 58], [4, 85], [4, 88], [4, 97], [4, 98], [5, 23], [5, 55], [5, 56], [5, 76], [5, 79], [5, 91], [5, 96], [6, 15], [6, 21], [6, 45], [6, 56], [6, 65], [6, 76], [6, 89], [7, 8], [7, 20], [7, 36], [7, 43], [7, 93], [7, 96], [7, 97], [8, 26], [8, 68], [8, 70], [8, 71], [8, 74], [8, 75], [8, 77], [8, 91], [9, 36], [9, 48], [9, 50], [9, 58], [9, 93], [9, 99], [10, 12], [10, 19], [10, 25], [10, 26], [10, 50], [10, 58], [10, 62], [10, 66], [10, 79], [10, 89], [10, 96], [10, 98], [11, 18], [11, 41], [11, 43], [11, 54], [11, 69], [11, 74], [11, 94], [12, 22], [12, 24], [12, 27], [12, 32], [12, 49], [12, 65], [12, 67], [12, 70], [12, 75], [12, 82], [13, 25], [13, 45], [13, 48], [13, 49], [13, 68], [13, 69], [13, 87], [13, 98], [14, 53], [14, 70], [14, 72], [14, 81], [14, 84], [14, 90], [15, 22], [15, 40], [15, 57], [15, 71], [15, 73], [16, 39], [16, 96], [17, 22], [17, 23], [17, 32], [17, 36], [17, 42], [17, 79], [17, 86], [17, 87], [18, 24], [18, 29], [18, 54], [19, 46], [19, 69], [19, 74], [19, 87], [20, 35], [20, 38], [20, 54], [20, 68], [20, 96], [21, 48], [21, 60], [21, 69], [21, 70], [21, 78], [22, 25], [22, 37], [22, 45], [22, 67], [22, 74], [22, 88], [22, 99], [23, 32], [23, 45], [23, 66], [23, 68], [23, 77], [24, 30], [24, 38], [24, 45], [24, 48], [24, 66], [24, 71], [24, 73], [24, 78], [24, 93], [25, 31], [25, 33], [25, 37], [25, 40], [25, 65], [25, 97], [26, 36], [26, 57], [26, 67], [26, 74], [26, 85], [26, 97], [27, 30], [27, 62], [27, 99], [28, 29], [28, 58], [28, 59], [28, 65], [28, 78], [28, 79], [28, 87], [28, 96], [29, 45], [29, 56], [29, 59], [29, 66], [29, 75], [29, 76], [29, 85], [29, 93], [29, 94], [30, 42], [30, 68], [31, 40], [31, 49], [31, 53], [31, 62], [31, 63], [31, 85], [31, 91], [31, 92], [32, 43], [32, 62], [32, 63], [33, 44], [33, 48], [33, 49], [33, 54], [33, 81], [34, 47], [34, 54], [34, 58], [34, 59], [34, 74], [34, 76], [34, 88], [35, 44], [35, 60], [35, 87], [35, 99], [36, 68], [36, 83], [36, 91], [36, 94], [37, 47], [37, 48], [37, 56], [37, 62], [37, 80], [37, 89], [38, 45], [38, 50], [38, 54], [38, 63], [38, 65], [38, 96], [38, 99], [39, 47], [39, 58], [39, 76], [39, 83], [39, 84], [39, 97], [40, 50], [40, 56], [40, 60], [40, 68], [40, 69], [40, 82], [40, 92], [41, 44], [41, 45], [41, 47], [41, 89], [42, 48], [42, 49], [42, 57], [42, 61], [42, 64], [42, 69], [42, 83], [42, 87], [42, 89], [42, 91], [43, 50], [43, 62], [43, 74], [43, 85], [44, 69], [44, 73], [44, 82], [44, 93], [44, 99], [45, 46], [45, 50], [45, 54], [45, 72], [45, 77], [45, 95], [46, 56], [46, 57], [46, 71], [47, 85], [47, 89], [47, 94], [48, 53], [48, 59], [48, 65], [48, 89], [48, 98], [49, 61], [49, 67], [49, 70], [49, 87], [50, 69], [51, 55], [51, 56], [51, 78], [51, 84], [51, 93], [52, 65], [52, 68], [52, 70], [52, 90], [52, 99], [53, 64], [53, 73], [53, 84], [53, 87], [54, 65], [54, 68], [54, 70], [54, 80], [55, 56], [55, 64], [55, 70], [56, 57], [56, 60], [56, 68], [56, 79], [57, 70], [57, 81], [57, 88], [57, 92], [58, 74], [58, 83], [58, 94], [59, 82], [59, 90], [59, 91], [60, 65], [60, 68], [60, 77], [60, 82], [61, 71], [61, 76], [61, 86], [61, 94], [62, 69], [62, 78], [62, 84], [62, 88], [62, 91], [63, 80], [63, 85], [63, 89], [64, 70], [64, 81], [64, 89], [64, 90], [64, 94], [64, 95], [66, 68], [66, 86], [66, 88], [67, 73], [68, 76], [68, 84], [68, 87], [69, 71], [69, 78], [69, 90], [70, 94], [72, 79], [72, 86], [72, 93], [73, 93], [74, 89], [75, 80], [75, 81], [76, 87], [76, 98], [77, 99], [78, 80], [79, 81], [79, 85], [79, 86], [80, 92], [80, 99], [81, 87], [81, 92], [82, 89], [83, 86], [85, 87], [85, 94], [85, 97], [88, 92], [88, 99], [89, 96], [91, 99], [92, 94], [95, 96], [95, 97]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s5/tests/run.py b/tasks/construct-mc-graph-k-coloring-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l5-s5/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-hadamard-l5-s2/environment/Dockerfile b/tasks/construct-mc-hadamard-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l5-s2/environment/instance.json b/tasks/construct-mc-hadamard-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c9470ccf314338e5da9ce7beeab2068b012bccc2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 41, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s2/solution/solve.sh b/tasks/construct-mc-hadamard-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c7dfb845ffdf955717d4fb7ebb0e59a3bfdc303 --- /dev/null +++ b/tasks/construct-mc-hadamard-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' +{"x": [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, 1], "y": [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, -1]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l5-s2/tests/check.py b/tasks/construct-mc-hadamard-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s2/tests/check.py @@ -0,0 +1,18 @@ +"""Legendre pair of odd length n (MathConstraint hadamard, CC-BY-4.0): x, y in {-1,+1}^n with +sum(x) = sum(y) = 1 and PAF_x(k) + PAF_y(k) = -2 for k = 1..(n-1)/2 (periodic autocorrelation).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, -1, 1, "x") + y = int_list(ans.get("y"), n, -1, 1, "y") + if 0 in x or 0 in y: + raise Invalid("entries must be -1 or +1") + if sum(x) != 1 or sum(y) != 1: + raise Invalid("sum(x) and sum(y) must both equal 1") + for k in range(1, (n - 1) // 2 + 1): + p = sum(x[i] * x[(i + k) % n] for i in range(n)) + sum(y[i] * y[(i + k) % n] for i in range(n)) + if p != -2: + raise Invalid(f"PAF_x({k}) + PAF_y({k}) = {p}, need -2") + return None, {} diff --git a/tasks/construct-mc-hadamard-l5-s2/tests/instance.json b/tasks/construct-mc-hadamard-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c9470ccf314338e5da9ce7beeab2068b012bccc2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 41, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s2/tests/run.py b/tasks/construct-mc-hadamard-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l5-s2/tests/test.sh b/tasks/construct-mc-hadamard-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-langford-l1-s2/environment/Dockerfile b/tasks/construct-mc-langford-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l1-s2/environment/instance.json b/tasks/construct-mc-langford-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..44f293f76f0809713e5b45b1362bbe49e5e264fe --- /dev/null +++ b/tasks/construct-mc-langford-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 3, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l1-s2/solution/solve.sh b/tasks/construct-mc-langford-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5cfc2bd41d48ea1c9fd9f2f369cc69b8f56eb072 --- /dev/null +++ b/tasks/construct-mc-langford-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' +{"seq": [2, 3, 1, 2, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l1-s2/tests/check.py b/tasks/construct-mc-langford-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l1-s2/tests/check.py @@ -0,0 +1,17 @@ +"""Langford sequence L(2, n) (MathConstraint langford, CC-BY-4.0). Accepts any valid sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + seq = int_list(ans.get("seq"), 2 * n, 1, n, "seq") + for v in range(1, n + 1): + pos = [i for i, s in enumerate(seq) if s == v] + if len(pos) != 2: + raise Invalid(f"value {v} occurs {len(pos)} times (need exactly 2)") + if pos[1] - pos[0] != v + 1: + raise Invalid(f"the two copies of {v} are {pos[1] - pos[0]} positions apart (need {v + 1})") + for name, i, v in inst.get("fixed", []): + if seq[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-langford-l1-s2/tests/instance.json b/tasks/construct-mc-langford-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..44f293f76f0809713e5b45b1362bbe49e5e264fe --- /dev/null +++ b/tasks/construct-mc-langford-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 3, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l1-s2/tests/run.py b/tasks/construct-mc-langford-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l1-s2/tests/test.sh b/tasks/construct-mc-langford-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-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-low-autocorrelation-l3-s6/environment/Dockerfile b/tasks/construct-mc-low-autocorrelation-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-low-autocorrelation-l3-s6/environment/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fd4e3107586c5646d4c39bfc58245934abf73bff --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "bound": 49, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s6/solution/solve.sh b/tasks/construct-mc-low-autocorrelation-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3dabe05a96846bd87aacb389b7d086a93c0cd339 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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' +{"seq": [-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-l3-s6/tests/check.py b/tasks/construct-mc-low-autocorrelation-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8456f7b1c0ff0c9fb4bc9ae5a49074c8afa7d1aa --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s6/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-l3-s6/tests/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fd4e3107586c5646d4c39bfc58245934abf73bff --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "bound": 49, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s6/tests/run.py b/tasks/construct-mc-low-autocorrelation-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-low-autocorrelation-l3-s6/tests/test.sh b/tasks/construct-mc-low-autocorrelation-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-l3-s8/environment/Dockerfile b/tasks/construct-mc-low-autocorrelation-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-mc-low-autocorrelation-l3-s8/environment/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb0b906d7c3fcd0bf775cc35116d71786d72737b --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 23, "bound": 59, "fixed": [["seq", 5, -1], ["seq", 10, -1], ["seq", 13, 1], ["seq", 19, 1], ["c", 12, 0], ["c", 13, -3], ["c", 16, 0], ["c", 19, -1]], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s8/solution/solve.sh b/tasks/construct-mc-low-autocorrelation-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..920131f9ee0c46e9c584c2169fb159a844eb69c9 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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' +{"seq": [-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-l3-s8/tests/check.py b/tasks/construct-mc-low-autocorrelation-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8456f7b1c0ff0c9fb4bc9ae5a49074c8afa7d1aa --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s8/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-l3-s8/tests/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb0b906d7c3fcd0bf775cc35116d71786d72737b --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 23, "bound": 59, "fixed": [["seq", 5, -1], ["seq", 10, -1], ["seq", 13, 1], ["seq", 19, 1], ["c", 12, 0], ["c", 13, -3], ["c", 16, 0], ["c", 19, -1]], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s8/tests/run.py b/tasks/construct-mc-low-autocorrelation-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-mc-low-autocorrelation-l3-s8/tests/test.sh b/tasks/construct-mc-low-autocorrelation-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-mc-magic-sequence-l4-s0/environment/Dockerfile b/tasks/construct-mc-magic-sequence-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-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-magic-sequence-l4-s0/environment/instance.json b/tasks/construct-mc-magic-sequence-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4315208c253daa0a82a293467183b2dc18d8c14b --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "fixed": [], "family": "mc_magic_sequence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-magic-sequence-l4-s0/solution/solve.sh b/tasks/construct-mc-magic-sequence-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4c31b11449d55fcb1da51229ef99e88b96bfb4f3 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-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": [16, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-magic-sequence-l4-s0/tests/check.py b/tasks/construct-mc-magic-sequence-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..27f636ddd6cfe523924ae01c6b9f37ee392f0332 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s0/tests/check.py @@ -0,0 +1,18 @@ +"""Magic sequence of length n: x[i] = number of occurrences of i in x (MathConstraint magic_sequence, +CC-BY-4.0). The property itself is checked (no stored answer).""" +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n, "x") + cnt = Counter(x) + for i in range(n): + if x[i] != cnt.get(i, 0): + raise Invalid(f"x[{i}] = {x[i]} but {i} occurs {cnt.get(i, 0)} times") + for name, i, v in inst.get("fixed", []): + if x[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-magic-sequence-l4-s0/tests/instance.json b/tasks/construct-mc-magic-sequence-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4315208c253daa0a82a293467183b2dc18d8c14b --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "fixed": [], "family": "mc_magic_sequence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-magic-sequence-l4-s0/tests/run.py b/tasks/construct-mc-magic-sequence-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-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-magic-sequence-l4-s0/tests/test.sh b/tasks/construct-mc-magic-sequence-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-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-max-clique-l3-s0/environment/Dockerfile b/tasks/construct-mc-max-clique-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-clique-l3-s0/environment/instance.json b/tasks/construct-mc-max-clique-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..400161913ae6ecc38702e324df5f716e099f4398 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 48, "k": 7, "edges": [[0, 3], [0, 4], [0, 8], [0, 9], [0, 11], [0, 14], [0, 15], [0, 16], [0, 19], [0, 20], [0, 21], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 36], [0, 37], [0, 41], [0, 43], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 10], [1, 11], [1, 13], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 26], [1, 29], [1, 31], [1, 33], [1, 35], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 43], [1, 44], [1, 45], [1, 46], [2, 3], [2, 4], [2, 6], [2, 8], [2, 9], [2, 11], [2, 12], [2, 13], [2, 15], [2, 19], [2, 20], [2, 21], [2, 22], [2, 25], [2, 27], [2, 29], [2, 32], [2, 36], [2, 40], [2, 44], [2, 46], [2, 47], [3, 4], [3, 5], [3, 8], [3, 10], [3, 11], [3, 12], [3, 15], [3, 17], [3, 19], [3, 21], [3, 22], [3, 24], [3, 25], [3, 26], [3, 27], [3, 31], [3, 32], [3, 33], [3, 36], [3, 37], [3, 38], [3, 40], [3, 41], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [4, 14], [4, 15], [4, 22], [4, 24], [4, 25], [4, 28], [4, 29], [4, 30], [4, 33], [4, 34], [4, 35], [4, 37], [4, 39], [4, 40], [4, 41], [4, 45], [4, 46], [4, 47], [5, 6], [5, 7], [5, 9], [5, 13], [5, 14], [5, 15], [5, 17], [5, 19], [5, 20], [5, 23], [5, 24], [5, 25], [5, 27], [5, 29], [5, 31], [5, 32], [5, 33], [5, 35], [5, 36], [5, 37], [5, 38], [5, 39], [5, 40], [5, 42], [5, 47], [6, 7], [6, 8], [6, 10], [6, 12], [6, 17], [6, 21], [6, 22], [6, 23], [6, 24], [6, 26], [6, 27], [6, 37], [6, 38], [6, 40], [6, 43], [6, 45], [7, 9], [7, 11], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 24], [7, 27], [7, 29], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 41], [7, 42], [7, 43], [7, 45], [8, 9], [8, 14], [8, 15], [8, 16], [8, 19], [8, 20], [8, 23], [8, 25], [8, 27], [8, 28], [8, 30], [8, 31], [8, 35], [8, 37], [8, 42], [8, 43], [8, 44], [8, 45], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 17], [9, 19], [9, 20], [9, 21], [9, 23], [9, 25], [9, 26], [9, 27], [9, 28], [9, 31], [9, 34], [9, 35], [9, 36], [9, 38], [9, 40], [9, 41], [9, 44], [9, 45], [9, 47], [10, 13], [10, 14], [10, 15], [10, 17], [10, 21], [10, 22], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 40], [10, 43], [10, 45], [10, 47], [11, 12], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 32], [11, 33], [11, 37], [11, 38], [11, 42], [11, 43], [11, 44], [11, 45], [12, 14], [12, 15], [12, 16], [12, 18], [12, 21], [12, 22], [12, 25], [12, 26], [12, 28], [12, 31], [12, 32], [12, 33], [12, 35], [12, 39], [12, 46], [13, 15], [13, 17], [13, 19], [13, 20], [13, 25], [13, 28], [13, 30], [13, 31], [13, 33], [13, 34], [13, 35], [13, 41], [13, 44], [13, 47], [14, 17], [14, 18], [14, 21], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 34], [14, 35], [14, 37], [14, 38], [14, 43], [14, 44], [14, 45], [14, 46], [15, 16], [15, 19], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 33], [15, 39], [15, 40], [15, 43], [16, 19], [16, 20], [16, 21], [16, 26], [16, 29], [16, 31], [16, 35], [16, 36], [16, 37], [16, 40], [16, 43], [16, 44], [17, 19], [17, 20], [17, 21], [17, 22], [17, 25], [17, 28], [17, 30], [17, 32], [17, 35], [17, 36], [17, 38], [17, 40], [17, 43], [18, 19], [18, 24], [18, 25], [18, 26], [18, 27], [18, 34], [18, 35], [18, 36], [18, 37], [18, 40], [18, 41], [18, 46], [18, 47], [19, 21], [19, 24], [19, 26], [19, 28], [19, 31], [19, 33], [19, 36], [19, 37], [19, 39], [19, 40], [19, 41], [19, 42], [19, 43], [19, 44], [19, 46], [20, 24], [20, 26], [20, 30], [20, 35], [20, 36], [20, 38], [20, 39], [20, 40], [20, 42], [20, 43], [20, 44], [20, 45], [20, 47], [21, 23], [21, 29], [21, 30], [21, 33], [21, 34], [21, 36], [21, 38], [21, 39], [21, 44], [21, 45], [21, 46], [22, 23], [22, 24], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 33], [22, 35], [22, 36], [22, 37], [22, 39], [22, 41], [22, 45], [22, 46], [22, 47], [23, 25], [23, 31], [23, 33], [23, 34], [23, 35], [23, 36], [23, 37], [23, 41], [23, 44], [23, 46], [23, 47], [24, 25], [24, 26], [24, 28], [24, 31], [24, 32], [24, 34], [24, 35], [24, 36], [24, 41], [24, 46], [25, 27], [25, 29], [25, 31], [25, 32], [25, 33], [25, 34], [25, 36], [25, 37], [25, 39], [25, 40], [25, 42], [25, 43], [25, 45], [25, 46], [26, 28], [26, 29], [26, 33], [26, 35], [26, 36], [26, 39], [26, 43], [26, 44], [26, 45], [26, 47], [27, 28], [27, 30], [27, 32], [27, 33], [27, 35], [27, 37], [27, 39], [27, 40], [27, 44], [27, 45], [28, 29], [28, 30], [28, 32], [28, 33], [28, 36], [28, 38], [28, 39], [28, 43], [28, 44], [28, 45], [28, 46], [28, 47], [29, 31], [29, 32], [29, 36], [29, 40], [29, 41], [29, 42], [29, 43], [29, 44], [29, 46], [30, 31], [30, 33], [30, 34], [30, 36], [30, 37], [30, 38], [30, 41], [30, 45], [30, 46], [31, 32], [31, 34], [31, 35], [31, 36], [31, 38], [31, 41], [31, 42], [31, 44], [31, 46], [31, 47], [32, 33], [32, 35], [32, 37], [32, 38], [32, 39], [32, 41], [32, 43], [32, 45], [32, 46], [32, 47], [33, 34], [33, 40], [33, 41], [33, 42], [33, 43], [33, 46], [34, 38], [34, 39], [34, 40], [34, 41], [34, 46], [34, 47], [35, 36], [35, 37], [35, 40], [35, 41], [35, 45], [35, 47], [36, 38], [36, 39], [36, 41], [36, 42], [36, 43], [36, 45], [37, 38], [37, 39], [37, 41], [37, 44], [37, 45], [37, 46], [37, 47], [38, 40], [38, 44], [38, 45], [38, 47], [39, 40], [39, 41], [39, 43], [39, 44], [39, 45], [39, 47], [40, 41], [40, 42], [40, 44], [40, 45], [40, 47], [41, 42], [41, 44], [41, 45], [41, 46], [42, 44], [42, 45], [42, 47], [43, 44], [44, 45], [44, 46], [44, 47], [45, 47]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s0/solution/solve.sh b/tasks/construct-mc-max-clique-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a889dea9e8c979ccdbb7ad347a68930874472a48 --- /dev/null +++ b/tasks/construct-mc-max-clique-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' +{"clique": [1, 3, 11, 37, 38, 44, 45]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l3-s0/tests/check.py b/tasks/construct-mc-max-clique-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s0/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l3-s0/tests/instance.json b/tasks/construct-mc-max-clique-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..400161913ae6ecc38702e324df5f716e099f4398 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 48, "k": 7, "edges": [[0, 3], [0, 4], [0, 8], [0, 9], [0, 11], [0, 14], [0, 15], [0, 16], [0, 19], [0, 20], [0, 21], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 36], [0, 37], [0, 41], [0, 43], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 10], [1, 11], [1, 13], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 26], [1, 29], [1, 31], [1, 33], [1, 35], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 43], [1, 44], [1, 45], [1, 46], [2, 3], [2, 4], [2, 6], [2, 8], [2, 9], [2, 11], [2, 12], [2, 13], [2, 15], [2, 19], [2, 20], [2, 21], [2, 22], [2, 25], [2, 27], [2, 29], [2, 32], [2, 36], [2, 40], [2, 44], [2, 46], [2, 47], [3, 4], [3, 5], [3, 8], [3, 10], [3, 11], [3, 12], [3, 15], [3, 17], [3, 19], [3, 21], [3, 22], [3, 24], [3, 25], [3, 26], [3, 27], [3, 31], [3, 32], [3, 33], [3, 36], [3, 37], [3, 38], [3, 40], [3, 41], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [4, 14], [4, 15], [4, 22], [4, 24], [4, 25], [4, 28], [4, 29], [4, 30], [4, 33], [4, 34], [4, 35], [4, 37], [4, 39], [4, 40], [4, 41], [4, 45], [4, 46], [4, 47], [5, 6], [5, 7], [5, 9], [5, 13], [5, 14], [5, 15], [5, 17], [5, 19], [5, 20], [5, 23], [5, 24], [5, 25], [5, 27], [5, 29], [5, 31], [5, 32], [5, 33], [5, 35], [5, 36], [5, 37], [5, 38], [5, 39], [5, 40], [5, 42], [5, 47], [6, 7], [6, 8], [6, 10], [6, 12], [6, 17], [6, 21], [6, 22], [6, 23], [6, 24], [6, 26], [6, 27], [6, 37], [6, 38], [6, 40], [6, 43], [6, 45], [7, 9], [7, 11], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 24], [7, 27], [7, 29], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 41], [7, 42], [7, 43], [7, 45], [8, 9], [8, 14], [8, 15], [8, 16], [8, 19], [8, 20], [8, 23], [8, 25], [8, 27], [8, 28], [8, 30], [8, 31], [8, 35], [8, 37], [8, 42], [8, 43], [8, 44], [8, 45], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 17], [9, 19], [9, 20], [9, 21], [9, 23], [9, 25], [9, 26], [9, 27], [9, 28], [9, 31], [9, 34], [9, 35], [9, 36], [9, 38], [9, 40], [9, 41], [9, 44], [9, 45], [9, 47], [10, 13], [10, 14], [10, 15], [10, 17], [10, 21], [10, 22], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 40], [10, 43], [10, 45], [10, 47], [11, 12], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 32], [11, 33], [11, 37], [11, 38], [11, 42], [11, 43], [11, 44], [11, 45], [12, 14], [12, 15], [12, 16], [12, 18], [12, 21], [12, 22], [12, 25], [12, 26], [12, 28], [12, 31], [12, 32], [12, 33], [12, 35], [12, 39], [12, 46], [13, 15], [13, 17], [13, 19], [13, 20], [13, 25], [13, 28], [13, 30], [13, 31], [13, 33], [13, 34], [13, 35], [13, 41], [13, 44], [13, 47], [14, 17], [14, 18], [14, 21], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 34], [14, 35], [14, 37], [14, 38], [14, 43], [14, 44], [14, 45], [14, 46], [15, 16], [15, 19], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 33], [15, 39], [15, 40], [15, 43], [16, 19], [16, 20], [16, 21], [16, 26], [16, 29], [16, 31], [16, 35], [16, 36], [16, 37], [16, 40], [16, 43], [16, 44], [17, 19], [17, 20], [17, 21], [17, 22], [17, 25], [17, 28], [17, 30], [17, 32], [17, 35], [17, 36], [17, 38], [17, 40], [17, 43], [18, 19], [18, 24], [18, 25], [18, 26], [18, 27], [18, 34], [18, 35], [18, 36], [18, 37], [18, 40], [18, 41], [18, 46], [18, 47], [19, 21], [19, 24], [19, 26], [19, 28], [19, 31], [19, 33], [19, 36], [19, 37], [19, 39], [19, 40], [19, 41], [19, 42], [19, 43], [19, 44], [19, 46], [20, 24], [20, 26], [20, 30], [20, 35], [20, 36], [20, 38], [20, 39], [20, 40], [20, 42], [20, 43], [20, 44], [20, 45], [20, 47], [21, 23], [21, 29], [21, 30], [21, 33], [21, 34], [21, 36], [21, 38], [21, 39], [21, 44], [21, 45], [21, 46], [22, 23], [22, 24], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 33], [22, 35], [22, 36], [22, 37], [22, 39], [22, 41], [22, 45], [22, 46], [22, 47], [23, 25], [23, 31], [23, 33], [23, 34], [23, 35], [23, 36], [23, 37], [23, 41], [23, 44], [23, 46], [23, 47], [24, 25], [24, 26], [24, 28], [24, 31], [24, 32], [24, 34], [24, 35], [24, 36], [24, 41], [24, 46], [25, 27], [25, 29], [25, 31], [25, 32], [25, 33], [25, 34], [25, 36], [25, 37], [25, 39], [25, 40], [25, 42], [25, 43], [25, 45], [25, 46], [26, 28], [26, 29], [26, 33], [26, 35], [26, 36], [26, 39], [26, 43], [26, 44], [26, 45], [26, 47], [27, 28], [27, 30], [27, 32], [27, 33], [27, 35], [27, 37], [27, 39], [27, 40], [27, 44], [27, 45], [28, 29], [28, 30], [28, 32], [28, 33], [28, 36], [28, 38], [28, 39], [28, 43], [28, 44], [28, 45], [28, 46], [28, 47], [29, 31], [29, 32], [29, 36], [29, 40], [29, 41], [29, 42], [29, 43], [29, 44], [29, 46], [30, 31], [30, 33], [30, 34], [30, 36], [30, 37], [30, 38], [30, 41], [30, 45], [30, 46], [31, 32], [31, 34], [31, 35], [31, 36], [31, 38], [31, 41], [31, 42], [31, 44], [31, 46], [31, 47], [32, 33], [32, 35], [32, 37], [32, 38], [32, 39], [32, 41], [32, 43], [32, 45], [32, 46], [32, 47], [33, 34], [33, 40], [33, 41], [33, 42], [33, 43], [33, 46], [34, 38], [34, 39], [34, 40], [34, 41], [34, 46], [34, 47], [35, 36], [35, 37], [35, 40], [35, 41], [35, 45], [35, 47], [36, 38], [36, 39], [36, 41], [36, 42], [36, 43], [36, 45], [37, 38], [37, 39], [37, 41], [37, 44], [37, 45], [37, 46], [37, 47], [38, 40], [38, 44], [38, 45], [38, 47], [39, 40], [39, 41], [39, 43], [39, 44], [39, 45], [39, 47], [40, 41], [40, 42], [40, 44], [40, 45], [40, 47], [41, 42], [41, 44], [41, 45], [41, 46], [42, 44], [42, 45], [42, 47], [43, 44], [44, 45], [44, 46], [44, 47], [45, 47]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s0/tests/run.py b/tasks/construct-mc-max-clique-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-clique-l3-s0/tests/test.sh b/tasks/construct-mc-max-clique-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-independent-set-l4-s3/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-max-independent-set-l4-s3/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..98395af89372da68ceeb12a36d41a68b4b0b72e6 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 2], [0, 4], [0, 6], [0, 8], [0, 9], [0, 11], [0, 12], [0, 17], [0, 21], [0, 22], [0, 23], [0, 25], [0, 28], [0, 36], [0, 37], [0, 39], [0, 41], [0, 44], [0, 45], [0, 49], [0, 51], [0, 52], [1, 10], [1, 11], [1, 24], [1, 27], [1, 34], [1, 35], [1, 36], [1, 44], [1, 47], [1, 48], [1, 59], [2, 5], [2, 7], [2, 10], [2, 17], [2, 23], [2, 33], [2, 43], [2, 44], [2, 46], [2, 47], [2, 48], [2, 52], [2, 54], [3, 11], [3, 15], [3, 18], [3, 19], [3, 21], [3, 24], [3, 31], [3, 32], [3, 33], [3, 35], [3, 39], [3, 40], [3, 41], [3, 44], [3, 45], [3, 48], [3, 50], [3, 51], [3, 52], [3, 55], [3, 59], [4, 13], [4, 19], [4, 26], [4, 28], [4, 32], [4, 39], [4, 43], [4, 50], [4, 52], [4, 57], [4, 58], [4, 59], [5, 6], [5, 20], [5, 36], [5, 40], [5, 48], [5, 54], [5, 56], [6, 9], [6, 10], [6, 11], [6, 14], [6, 24], [6, 27], [6, 28], [6, 29], [6, 31], [6, 32], [6, 34], [6, 41], [6, 43], [6, 44], [6, 51], [6, 56], [6, 57], [6, 59], [7, 9], [7, 10], [7, 11], [7, 15], [7, 16], [7, 17], [7, 22], [7, 27], [7, 28], [7, 36], [7, 40], [7, 42], [7, 45], [7, 47], [7, 53], [7, 54], [7, 55], [7, 57], [8, 26], [8, 34], [8, 35], [8, 36], [8, 38], [8, 39], [8, 44], [8, 51], [8, 53], [8, 55], [8, 57], [8, 58], [9, 11], [9, 16], [9, 17], [9, 19], [9, 21], [9, 24], [9, 27], [9, 28], [9, 30], [9, 37], [9, 38], [9, 40], [9, 42], [9, 44], [9, 47], [9, 48], [9, 52], [9, 56], [9, 58], [9, 59], [10, 12], [10, 14], [10, 24], [10, 25], [10, 34], [10, 35], [10, 45], [10, 49], [10, 55], [10, 58], [11, 25], [11, 27], [11, 29], [11, 41], [11, 43], [11, 47], [11, 49], [11, 53], [12, 23], [12, 26], [12, 28], [12, 35], [12, 36], [12, 44], [12, 45], [12, 50], [12, 51], [12, 55], [12, 59], [13, 23], [13, 27], [13, 32], [13, 38], [13, 39], [13, 45], [13, 53], [13, 54], [13, 57], [13, 58], [13, 59], [14, 17], [14, 18], [14, 19], [14, 24], [14, 28], [14, 29], [14, 30], [14, 33], [14, 38], [14, 44], [14, 46], [14, 47], [14, 51], [15, 19], [15, 21], [15, 25], [15, 27], [15, 28], [15, 32], [15, 33], [15, 41], [15, 45], [15, 48], [15, 49], [15, 51], [15, 59], [16, 19], [16, 21], [16, 25], [16, 27], [16, 30], [16, 32], [16, 33], [16, 43], [16, 44], [16, 48], [16, 49], [16, 52], [16, 54], [17, 19], [17, 21], [17, 22], [17, 24], [17, 34], [17, 36], [17, 37], [17, 38], [17, 39], [17, 52], [17, 54], [17, 55], [17, 59], [18, 20], [18, 24], [18, 26], [18, 31], [18, 32], [18, 38], [18, 39], [18, 40], [18, 42], [18, 44], [18, 49], [18, 52], [18, 53], [18, 55], [19, 23], [19, 24], [19, 26], [19, 29], [19, 31], [19, 33], [19, 40], [19, 46], [19, 48], [19, 50], [19, 54], [19, 57], [20, 27], [20, 30], [20, 51], [20, 57], [21, 27], [21, 29], [21, 30], [21, 33], [21, 35], [21, 39], [21, 42], [21, 47], [21, 50], [21, 53], [21, 58], [22, 27], [22, 32], [22, 33], [22, 39], [22, 41], [22, 45], [22, 51], [22, 57], [22, 59], [23, 26], [23, 27], [23, 29], [23, 34], [23, 35], [23, 37], [23, 46], [23, 50], [23, 53], [24, 27], [24, 33], [24, 36], [24, 40], [24, 41], [24, 43], [24, 52], [24, 59], [25, 32], [25, 33], [25, 37], [25, 42], [25, 52], [25, 55], [26, 27], [26, 29], [26, 30], [26, 31], [26, 38], [26, 43], [26, 46], [26, 48], [26, 49], [26, 52], [26, 55], [27, 30], [27, 34], [27, 35], [27, 42], [27, 45], [27, 51], [27, 53], [27, 54], [27, 55], [27, 56], [27, 57], [28, 30], [28, 31], [28, 34], [28, 35], [28, 42], [28, 45], [28, 47], [28, 50], [28, 51], [28, 54], [28, 56], [29, 30], [29, 32], [29, 34], [29, 36], [29, 44], [29, 52], [29, 53], [29, 56], [29, 58], [30, 31], [30, 34], [30, 37], [30, 38], [30, 44], [30, 48], [30, 51], [30, 52], [30, 53], [30, 56], [30, 58], [31, 32], [31, 36], [31, 43], [31, 44], [31, 45], [31, 46], [31, 48], [31, 59], [32, 33], [32, 40], [32, 42], [32, 43], [32, 44], [32, 47], [33, 41], [33, 42], [33, 44], [33, 45], [33, 46], [33, 48], [33, 49], [33, 50], [33, 52], [33, 54], [33, 56], [33, 57], [34, 39], [34, 40], [34, 42], [34, 49], [34, 50], [34, 52], [34, 54], [35, 36], [35, 40], [35, 50], [35, 54], [35, 56], [35, 59], [36, 37], [36, 45], [36, 49], [36, 51], [36, 55], [36, 57], [37, 41], [37, 47], [37, 51], [37, 53], [37, 55], [37, 56], [37, 57], [37, 59], [38, 46], [39, 46], [39, 47], [39, 48], [39, 53], [39, 57], [39, 59], [40, 45], [40, 46], [40, 55], [41, 49], [41, 52], [41, 57], [42, 44], [42, 45], [42, 46], [42, 48], [42, 51], [42, 55], [42, 56], [43, 44], [43, 45], [43, 48], [43, 49], [43, 55], [44, 48], [44, 51], [44, 52], [44, 55], [44, 57], [45, 51], [45, 52], [45, 56], [45, 57], [45, 59], [46, 47], [46, 54], [47, 55], [47, 59], [48, 49], [49, 50], [49, 54], [49, 56], [49, 59], [50, 52], [50, 57], [50, 58], [51, 55], [51, 56], [51, 59], [52, 55], [52, 57], [56, 58], [56, 59], [57, 58]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s3/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dbdcf73c526270caeaca0f244e934cfa9bdbc673 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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' +{"independent_set": [2, 8, 11, 12, 13, 14, 15, 16, 20, 22, 31, 37, 40, 42]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s3/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s3/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l4-s3/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..98395af89372da68ceeb12a36d41a68b4b0b72e6 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 2], [0, 4], [0, 6], [0, 8], [0, 9], [0, 11], [0, 12], [0, 17], [0, 21], [0, 22], [0, 23], [0, 25], [0, 28], [0, 36], [0, 37], [0, 39], [0, 41], [0, 44], [0, 45], [0, 49], [0, 51], [0, 52], [1, 10], [1, 11], [1, 24], [1, 27], [1, 34], [1, 35], [1, 36], [1, 44], [1, 47], [1, 48], [1, 59], [2, 5], [2, 7], [2, 10], [2, 17], [2, 23], [2, 33], [2, 43], [2, 44], [2, 46], [2, 47], [2, 48], [2, 52], [2, 54], [3, 11], [3, 15], [3, 18], [3, 19], [3, 21], [3, 24], [3, 31], [3, 32], [3, 33], [3, 35], [3, 39], [3, 40], [3, 41], [3, 44], [3, 45], [3, 48], [3, 50], [3, 51], [3, 52], [3, 55], [3, 59], [4, 13], [4, 19], [4, 26], [4, 28], [4, 32], [4, 39], [4, 43], [4, 50], [4, 52], [4, 57], [4, 58], [4, 59], [5, 6], [5, 20], [5, 36], [5, 40], [5, 48], [5, 54], [5, 56], [6, 9], [6, 10], [6, 11], [6, 14], [6, 24], [6, 27], [6, 28], [6, 29], [6, 31], [6, 32], [6, 34], [6, 41], [6, 43], [6, 44], [6, 51], [6, 56], [6, 57], [6, 59], [7, 9], [7, 10], [7, 11], [7, 15], [7, 16], [7, 17], [7, 22], [7, 27], [7, 28], [7, 36], [7, 40], [7, 42], [7, 45], [7, 47], [7, 53], [7, 54], [7, 55], [7, 57], [8, 26], [8, 34], [8, 35], [8, 36], [8, 38], [8, 39], [8, 44], [8, 51], [8, 53], [8, 55], [8, 57], [8, 58], [9, 11], [9, 16], [9, 17], [9, 19], [9, 21], [9, 24], [9, 27], [9, 28], [9, 30], [9, 37], [9, 38], [9, 40], [9, 42], [9, 44], [9, 47], [9, 48], [9, 52], [9, 56], [9, 58], [9, 59], [10, 12], [10, 14], [10, 24], [10, 25], [10, 34], [10, 35], [10, 45], [10, 49], [10, 55], [10, 58], [11, 25], [11, 27], [11, 29], [11, 41], [11, 43], [11, 47], [11, 49], [11, 53], [12, 23], [12, 26], [12, 28], [12, 35], [12, 36], [12, 44], [12, 45], [12, 50], [12, 51], [12, 55], [12, 59], [13, 23], [13, 27], [13, 32], [13, 38], [13, 39], [13, 45], [13, 53], [13, 54], [13, 57], [13, 58], [13, 59], [14, 17], [14, 18], [14, 19], [14, 24], [14, 28], [14, 29], [14, 30], [14, 33], [14, 38], [14, 44], [14, 46], [14, 47], [14, 51], [15, 19], [15, 21], [15, 25], [15, 27], [15, 28], [15, 32], [15, 33], [15, 41], [15, 45], [15, 48], [15, 49], [15, 51], [15, 59], [16, 19], [16, 21], [16, 25], [16, 27], [16, 30], [16, 32], [16, 33], [16, 43], [16, 44], [16, 48], [16, 49], [16, 52], [16, 54], [17, 19], [17, 21], [17, 22], [17, 24], [17, 34], [17, 36], [17, 37], [17, 38], [17, 39], [17, 52], [17, 54], [17, 55], [17, 59], [18, 20], [18, 24], [18, 26], [18, 31], [18, 32], [18, 38], [18, 39], [18, 40], [18, 42], [18, 44], [18, 49], [18, 52], [18, 53], [18, 55], [19, 23], [19, 24], [19, 26], [19, 29], [19, 31], [19, 33], [19, 40], [19, 46], [19, 48], [19, 50], [19, 54], [19, 57], [20, 27], [20, 30], [20, 51], [20, 57], [21, 27], [21, 29], [21, 30], [21, 33], [21, 35], [21, 39], [21, 42], [21, 47], [21, 50], [21, 53], [21, 58], [22, 27], [22, 32], [22, 33], [22, 39], [22, 41], [22, 45], [22, 51], [22, 57], [22, 59], [23, 26], [23, 27], [23, 29], [23, 34], [23, 35], [23, 37], [23, 46], [23, 50], [23, 53], [24, 27], [24, 33], [24, 36], [24, 40], [24, 41], [24, 43], [24, 52], [24, 59], [25, 32], [25, 33], [25, 37], [25, 42], [25, 52], [25, 55], [26, 27], [26, 29], [26, 30], [26, 31], [26, 38], [26, 43], [26, 46], [26, 48], [26, 49], [26, 52], [26, 55], [27, 30], [27, 34], [27, 35], [27, 42], [27, 45], [27, 51], [27, 53], [27, 54], [27, 55], [27, 56], [27, 57], [28, 30], [28, 31], [28, 34], [28, 35], [28, 42], [28, 45], [28, 47], [28, 50], [28, 51], [28, 54], [28, 56], [29, 30], [29, 32], [29, 34], [29, 36], [29, 44], [29, 52], [29, 53], [29, 56], [29, 58], [30, 31], [30, 34], [30, 37], [30, 38], [30, 44], [30, 48], [30, 51], [30, 52], [30, 53], [30, 56], [30, 58], [31, 32], [31, 36], [31, 43], [31, 44], [31, 45], [31, 46], [31, 48], [31, 59], [32, 33], [32, 40], [32, 42], [32, 43], [32, 44], [32, 47], [33, 41], [33, 42], [33, 44], [33, 45], [33, 46], [33, 48], [33, 49], [33, 50], [33, 52], [33, 54], [33, 56], [33, 57], [34, 39], [34, 40], [34, 42], [34, 49], [34, 50], [34, 52], [34, 54], [35, 36], [35, 40], [35, 50], [35, 54], [35, 56], [35, 59], [36, 37], [36, 45], [36, 49], [36, 51], [36, 55], [36, 57], [37, 41], [37, 47], [37, 51], [37, 53], [37, 55], [37, 56], [37, 57], [37, 59], [38, 46], [39, 46], [39, 47], [39, 48], [39, 53], [39, 57], [39, 59], [40, 45], [40, 46], [40, 55], [41, 49], [41, 52], [41, 57], [42, 44], [42, 45], [42, 46], [42, 48], [42, 51], [42, 55], [42, 56], [43, 44], [43, 45], [43, 48], [43, 49], [43, 55], [44, 48], [44, 51], [44, 52], [44, 55], [44, 57], [45, 51], [45, 52], [45, 56], [45, 57], [45, 59], [46, 47], [46, 54], [47, 55], [47, 59], [48, 49], [49, 50], [49, 54], [49, 56], [49, 59], [50, 52], [50, 57], [50, 58], [51, 55], [51, 56], [51, 59], [52, 55], [52, 57], [56, 58], [56, 59], [57, 58]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s3/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-max-independent-set-l4-s3/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-max-independent-set-l4-s4/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-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-max-independent-set-l4-s4/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a9402995a2244466e4508c424c3ca0d30ed57fb --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 11], [0, 13], [0, 15], [0, 17], [0, 26], [0, 33], [0, 35], [0, 37], [0, 38], [0, 52], [0, 54], [0, 55], [0, 57], [1, 3], [1, 6], [1, 12], [1, 20], [1, 22], [1, 27], [1, 28], [1, 34], [1, 36], [1, 39], [1, 43], [1, 45], [1, 47], [1, 48], [1, 49], [1, 55], [1, 57], [2, 3], [2, 14], [2, 15], [2, 18], [2, 23], [2, 24], [2, 31], [2, 43], [2, 45], [2, 48], [2, 55], [2, 59], [3, 4], [3, 7], [3, 12], [3, 18], [3, 19], [3, 21], [3, 23], [3, 24], [3, 32], [3, 33], [3, 37], [3, 40], [3, 41], [3, 47], [3, 50], [3, 57], [3, 59], [4, 8], [4, 10], [4, 13], [4, 15], [4, 16], [4, 18], [4, 24], [4, 26], [4, 31], [4, 33], [4, 38], [4, 39], [4, 44], [4, 47], [4, 51], [4, 53], [4, 58], [5, 6], [5, 7], [5, 10], [5, 11], [5, 16], [5, 17], [5, 20], [5, 22], [5, 30], [5, 31], [5, 32], [5, 40], [5, 42], [5, 46], [5, 47], [5, 48], [5, 50], [5, 53], [5, 55], [5, 57], [5, 59], [6, 11], [6, 16], [6, 19], [6, 27], [6, 28], [6, 40], [6, 42], [6, 43], [6, 46], [6, 49], [6, 52], [6, 55], [7, 9], [7, 10], [7, 11], [7, 15], [7, 16], [7, 24], [7, 29], [7, 32], [7, 42], [7, 45], [7, 47], [7, 51], [7, 54], [7, 58], [7, 59], [8, 11], [8, 13], [8, 14], [8, 16], [8, 17], [8, 22], [8, 23], [8, 24], [8, 32], [8, 33], [8, 35], [8, 37], [8, 38], [8, 52], [8, 54], [8, 58], [8, 59], [9, 14], [9, 20], [9, 22], [9, 24], [9, 28], [9, 29], [9, 30], [9, 37], [9, 38], [9, 44], [9, 46], [9, 52], [9, 53], [9, 55], [10, 16], [10, 18], [10, 19], [10, 23], [10, 26], [10, 27], [10, 30], [10, 31], [10, 33], [10, 38], [10, 40], [10, 44], [10, 45], [10, 56], [10, 57], [10, 59], [11, 12], [11, 14], [11, 16], [11, 18], [11, 20], [11, 26], [11, 33], [11, 37], [11, 39], [11, 42], [11, 43], [11, 44], [11, 49], [11, 50], [11, 59], [12, 14], [12, 15], [12, 31], [12, 40], [12, 42], [12, 48], [12, 55], [12, 59], [13, 19], [13, 21], [13, 27], [13, 28], [13, 29], [13, 32], [13, 33], [13, 38], [13, 39], [13, 40], [13, 41], [13, 44], [13, 45], [13, 59], [14, 15], [14, 16], [14, 17], [14, 21], [14, 27], [14, 29], [14, 30], [14, 33], [14, 39], [14, 41], [14, 45], [14, 46], [14, 49], [14, 57], [15, 16], [15, 17], [15, 18], [15, 20], [15, 24], [15, 27], [15, 29], [15, 31], [15, 37], [15, 44], [15, 45], [15, 47], [15, 50], [15, 53], [15, 58], [16, 20], [16, 21], [16, 28], [16, 30], [16, 36], [16, 41], [16, 42], [16, 44], [16, 47], [16, 54], [16, 57], [17, 23], [17, 29], [17, 36], [17, 37], [17, 40], [17, 41], [17, 42], [17, 43], [17, 45], [17, 46], [17, 49], [17, 51], [17, 53], [17, 56], [18, 22], [18, 24], [18, 26], [18, 28], [18, 34], [18, 37], [18, 38], [18, 46], [18, 49], [18, 50], [18, 52], [18, 57], [18, 59], [19, 23], [19, 25], [19, 26], [19, 27], [19, 28], [19, 33], [19, 35], [19, 42], [19, 45], [19, 48], [19, 49], [19, 53], [19, 55], [19, 58], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 36], [20, 38], [20, 41], [20, 43], [20, 45], [20, 49], [20, 52], [20, 55], [20, 58], [21, 22], [21, 23], [21, 24], [21, 31], [21, 34], [21, 39], [21, 42], [21, 44], [21, 48], [21, 56], [22, 25], [22, 28], [22, 32], [22, 34], [22, 36], [22, 44], [22, 46], [22, 48], [22, 50], [22, 51], [22, 55], [22, 56], [22, 58], [22, 59], [23, 24], [23, 26], [23, 29], [23, 30], [23, 31], [23, 37], [23, 40], [23, 41], [23, 47], [23, 49], [23, 50], [23, 54], [23, 56], [23, 57], [23, 58], [24, 26], [24, 31], [24, 56], [25, 27], [25, 32], [25, 35], [25, 37], [25, 40], [25, 42], [25, 44], [25, 45], [25, 48], [25, 54], [25, 55], [26, 29], [26, 37], [26, 38], [26, 40], [26, 42], [26, 43], [26, 47], [26, 51], [27, 30], [27, 33], [27, 34], [27, 35], [27, 36], [27, 44], [27, 45], [27, 49], [27, 55], [27, 59], [28, 33], [28, 40], [28, 44], [28, 46], [28, 52], [28, 54], [28, 57], [28, 59], [29, 37], [29, 44], [29, 48], [29, 53], [30, 33], [30, 39], [30, 40], [30, 41], [30, 44], [30, 46], [30, 51], [30, 53], [30, 54], [31, 33], [31, 35], [31, 36], [31, 40], [31, 50], [31, 54], [31, 58], [32, 38], [32, 39], [32, 41], [32, 42], [32, 43], [32, 56], [32, 57], [32, 58], [32, 59], [33, 40], [33, 43], [33, 45], [33, 48], [33, 56], [33, 57], [33, 59], [34, 35], [34, 43], [34, 45], [34, 51], [34, 56], [35, 36], [35, 39], [35, 41], [35, 42], [35, 43], [35, 46], [35, 56], [36, 45], [36, 48], [36, 54], [36, 55], [36, 56], [36, 57], [36, 58], [37, 39], [37, 41], [37, 53], [37, 56], [37, 58], [38, 39], [38, 42], [38, 53], [38, 55], [39, 40], [39, 46], [39, 50], [39, 53], [39, 56], [40, 47], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 59], [41, 46], [42, 43], [42, 44], [42, 46], [42, 48], [42, 51], [42, 52], [42, 53], [42, 55], [43, 44], [43, 46], [43, 47], [43, 53], [43, 55], [43, 59], [44, 47], [44, 48], [44, 49], [44, 54], [44, 56], [44, 59], [45, 47], [45, 55], [45, 56], [45, 57], [45, 58], [45, 59], [46, 48], [46, 49], [46, 55], [46, 59], [47, 58], [47, 59], [48, 49], [48, 52], [48, 54], [48, 57], [49, 50], [49, 51], [49, 52], [49, 54], [50, 52], [50, 56], [50, 58], [50, 59], [51, 52], [51, 58], [52, 53], [52, 56], [52, 58], [53, 54], [53, 57], [53, 59], [54, 56], [54, 57], [55, 57], [55, 59], [56, 59], [57, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s4/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7bd9320ef95bfcb75d5998b67676e150c7eacfba --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-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' +{"independent_set": [0, 2, 6, 8, 9, 10, 12, 21, 25, 36, 41, 47, 50, 51]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s4/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s4/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l4-s4/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a9402995a2244466e4508c424c3ca0d30ed57fb --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 11], [0, 13], [0, 15], [0, 17], [0, 26], [0, 33], [0, 35], [0, 37], [0, 38], [0, 52], [0, 54], [0, 55], [0, 57], [1, 3], [1, 6], [1, 12], [1, 20], [1, 22], [1, 27], [1, 28], [1, 34], [1, 36], [1, 39], [1, 43], [1, 45], [1, 47], [1, 48], [1, 49], [1, 55], [1, 57], [2, 3], [2, 14], [2, 15], [2, 18], [2, 23], [2, 24], [2, 31], [2, 43], [2, 45], [2, 48], [2, 55], [2, 59], [3, 4], [3, 7], [3, 12], [3, 18], [3, 19], [3, 21], [3, 23], [3, 24], [3, 32], [3, 33], [3, 37], [3, 40], [3, 41], [3, 47], [3, 50], [3, 57], [3, 59], [4, 8], [4, 10], [4, 13], [4, 15], [4, 16], [4, 18], [4, 24], [4, 26], [4, 31], [4, 33], [4, 38], [4, 39], [4, 44], [4, 47], [4, 51], [4, 53], [4, 58], [5, 6], [5, 7], [5, 10], [5, 11], [5, 16], [5, 17], [5, 20], [5, 22], [5, 30], [5, 31], [5, 32], [5, 40], [5, 42], [5, 46], [5, 47], [5, 48], [5, 50], [5, 53], [5, 55], [5, 57], [5, 59], [6, 11], [6, 16], [6, 19], [6, 27], [6, 28], [6, 40], [6, 42], [6, 43], [6, 46], [6, 49], [6, 52], [6, 55], [7, 9], [7, 10], [7, 11], [7, 15], [7, 16], [7, 24], [7, 29], [7, 32], [7, 42], [7, 45], [7, 47], [7, 51], [7, 54], [7, 58], [7, 59], [8, 11], [8, 13], [8, 14], [8, 16], [8, 17], [8, 22], [8, 23], [8, 24], [8, 32], [8, 33], [8, 35], [8, 37], [8, 38], [8, 52], [8, 54], [8, 58], [8, 59], [9, 14], [9, 20], [9, 22], [9, 24], [9, 28], [9, 29], [9, 30], [9, 37], [9, 38], [9, 44], [9, 46], [9, 52], [9, 53], [9, 55], [10, 16], [10, 18], [10, 19], [10, 23], [10, 26], [10, 27], [10, 30], [10, 31], [10, 33], [10, 38], [10, 40], [10, 44], [10, 45], [10, 56], [10, 57], [10, 59], [11, 12], [11, 14], [11, 16], [11, 18], [11, 20], [11, 26], [11, 33], [11, 37], [11, 39], [11, 42], [11, 43], [11, 44], [11, 49], [11, 50], [11, 59], [12, 14], [12, 15], [12, 31], [12, 40], [12, 42], [12, 48], [12, 55], [12, 59], [13, 19], [13, 21], [13, 27], [13, 28], [13, 29], [13, 32], [13, 33], [13, 38], [13, 39], [13, 40], [13, 41], [13, 44], [13, 45], [13, 59], [14, 15], [14, 16], [14, 17], [14, 21], [14, 27], [14, 29], [14, 30], [14, 33], [14, 39], [14, 41], [14, 45], [14, 46], [14, 49], [14, 57], [15, 16], [15, 17], [15, 18], [15, 20], [15, 24], [15, 27], [15, 29], [15, 31], [15, 37], [15, 44], [15, 45], [15, 47], [15, 50], [15, 53], [15, 58], [16, 20], [16, 21], [16, 28], [16, 30], [16, 36], [16, 41], [16, 42], [16, 44], [16, 47], [16, 54], [16, 57], [17, 23], [17, 29], [17, 36], [17, 37], [17, 40], [17, 41], [17, 42], [17, 43], [17, 45], [17, 46], [17, 49], [17, 51], [17, 53], [17, 56], [18, 22], [18, 24], [18, 26], [18, 28], [18, 34], [18, 37], [18, 38], [18, 46], [18, 49], [18, 50], [18, 52], [18, 57], [18, 59], [19, 23], [19, 25], [19, 26], [19, 27], [19, 28], [19, 33], [19, 35], [19, 42], [19, 45], [19, 48], [19, 49], [19, 53], [19, 55], [19, 58], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 36], [20, 38], [20, 41], [20, 43], [20, 45], [20, 49], [20, 52], [20, 55], [20, 58], [21, 22], [21, 23], [21, 24], [21, 31], [21, 34], [21, 39], [21, 42], [21, 44], [21, 48], [21, 56], [22, 25], [22, 28], [22, 32], [22, 34], [22, 36], [22, 44], [22, 46], [22, 48], [22, 50], [22, 51], [22, 55], [22, 56], [22, 58], [22, 59], [23, 24], [23, 26], [23, 29], [23, 30], [23, 31], [23, 37], [23, 40], [23, 41], [23, 47], [23, 49], [23, 50], [23, 54], [23, 56], [23, 57], [23, 58], [24, 26], [24, 31], [24, 56], [25, 27], [25, 32], [25, 35], [25, 37], [25, 40], [25, 42], [25, 44], [25, 45], [25, 48], [25, 54], [25, 55], [26, 29], [26, 37], [26, 38], [26, 40], [26, 42], [26, 43], [26, 47], [26, 51], [27, 30], [27, 33], [27, 34], [27, 35], [27, 36], [27, 44], [27, 45], [27, 49], [27, 55], [27, 59], [28, 33], [28, 40], [28, 44], [28, 46], [28, 52], [28, 54], [28, 57], [28, 59], [29, 37], [29, 44], [29, 48], [29, 53], [30, 33], [30, 39], [30, 40], [30, 41], [30, 44], [30, 46], [30, 51], [30, 53], [30, 54], [31, 33], [31, 35], [31, 36], [31, 40], [31, 50], [31, 54], [31, 58], [32, 38], [32, 39], [32, 41], [32, 42], [32, 43], [32, 56], [32, 57], [32, 58], [32, 59], [33, 40], [33, 43], [33, 45], [33, 48], [33, 56], [33, 57], [33, 59], [34, 35], [34, 43], [34, 45], [34, 51], [34, 56], [35, 36], [35, 39], [35, 41], [35, 42], [35, 43], [35, 46], [35, 56], [36, 45], [36, 48], [36, 54], [36, 55], [36, 56], [36, 57], [36, 58], [37, 39], [37, 41], [37, 53], [37, 56], [37, 58], [38, 39], [38, 42], [38, 53], [38, 55], [39, 40], [39, 46], [39, 50], [39, 53], [39, 56], [40, 47], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 59], [41, 46], [42, 43], [42, 44], [42, 46], [42, 48], [42, 51], [42, 52], [42, 53], [42, 55], [43, 44], [43, 46], [43, 47], [43, 53], [43, 55], [43, 59], [44, 47], [44, 48], [44, 49], [44, 54], [44, 56], [44, 59], [45, 47], [45, 55], [45, 56], [45, 57], [45, 58], [45, 59], [46, 48], [46, 49], [46, 55], [46, 59], [47, 58], [47, 59], [48, 49], [48, 52], [48, 54], [48, 57], [49, 50], [49, 51], [49, 52], [49, 54], [50, 52], [50, 56], [50, 58], [50, 59], [51, 52], [51, 58], [52, 53], [52, 56], [52, 58], [53, 54], [53, 57], [53, 59], [54, 56], [54, 57], [55, 57], [55, 59], [56, 59], [57, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s4/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-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-max-independent-set-l4-s4/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-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-mc-number-partitioning-l4-s6/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-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-number-partitioning-l4-s6/environment/instance.json b/tasks/construct-mc-number-partitioning-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4af248949eea68cf386b40598378891ba745ba82 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 39, "k": 4, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s6/solution/solve.sh b/tasks/construct-mc-number-partitioning-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..53b534bbef5caf3873990ba7821a3a4429701b90 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-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' +{"x": [1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l4-s6/tests/check.py b/tasks/construct-mc-number-partitioning-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s6/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-l4-s6/tests/instance.json b/tasks/construct-mc-number-partitioning-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4af248949eea68cf386b40598378891ba745ba82 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 39, "k": 4, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s6/tests/run.py b/tasks/construct-mc-number-partitioning-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-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-number-partitioning-l4-s6/tests/test.sh b/tasks/construct-mc-number-partitioning-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-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-number-partitioning-l4-s8/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-mc-number-partitioning-l4-s8/environment/instance.json b/tasks/construct-mc-number-partitioning-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..930f612455a70fc4027ad53b8a6830cd6c02a7bb --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 29, "k": 3, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s8/solution/solve.sh b/tasks/construct-mc-number-partitioning-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..216c4cd342a4457e69e679559aaa957464776fbf --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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' +{"x": [1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l4-s8/tests/check.py b/tasks/construct-mc-number-partitioning-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s8/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-l4-s8/tests/instance.json b/tasks/construct-mc-number-partitioning-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..930f612455a70fc4027ad53b8a6830cd6c02a7bb --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 29, "k": 3, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s8/tests/run.py b/tasks/construct-mc-number-partitioning-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-mc-number-partitioning-l4-s8/tests/test.sh b/tasks/construct-mc-number-partitioning-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-mc-ortholatin-l2-s0/environment/Dockerfile b/tasks/construct-mc-ortholatin-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-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-ortholatin-l2-s0/environment/instance.json b/tasks/construct-mc-ortholatin-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..57cad9fc51de7973edca6715d043e9c8127c9385 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l2-s0/solution/solve.sh b/tasks/construct-mc-ortholatin-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0abe988c65064cd6f1112e8413fe3506d0087737 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-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": [[0, 1, 2, 3, 4, 5, 6, 7], [1, 0, 3, 2, 5, 4, 7, 6], [2, 3, 0, 1, 6, 7, 4, 5], [3, 2, 1, 0, 7, 6, 5, 4], [4, 5, 6, 7, 0, 1, 2, 3], [5, 4, 7, 6, 1, 0, 3, 2], [6, 7, 4, 5, 2, 3, 0, 1], [7, 6, 5, 4, 3, 2, 1, 0]], "Y": [[0, 1, 2, 3, 4, 5, 6, 7], [2, 3, 0, 1, 6, 7, 4, 5], [4, 7, 6, 5, 0, 1, 2, 3], [6, 5, 4, 7, 2, 3, 0, 1], [5, 2, 7, 0, 1, 6, 3, 4], [7, 0, 5, 2, 3, 4, 1, 6], [1, 6, 3, 4, 7, 2, 5, 0], [3, 4, 1, 6, 5, 0, 7, 2]]} +RLMATH_EOF diff --git a/tasks/construct-mc-ortholatin-l2-s0/tests/check.py b/tasks/construct-mc-ortholatin-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a5418a59fae1c86318eee903e90d75b36d8a3306 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s0/tests/check.py @@ -0,0 +1,25 @@ +"""Pair of orthogonal Latin squares of order n (MathConstraint ortholatin, CC-BY-4.0).""" +from run import Invalid, int_list + + +def _square(v, n, name): + if not isinstance(v, list) or len(v) != n: + raise Invalid(f"{name} must be a list of {n} rows") + S = [int_list(r, n, 0, n - 1, f"{name} row") for r in v] + full = list(range(n)) + for i in range(n): + if sorted(S[i]) != full: + raise Invalid(f"{name}: row {i} is not a permutation of 0..{n - 1}") + if sorted(S[r][i] for r in range(n)) != full: + raise Invalid(f"{name}: column {i} is not a permutation of 0..{n - 1}") + return S + + +def check(inst, ans): + n = inst["n"] + X = _square(ans.get("X"), n, "X") + Y = _square(ans.get("Y"), n, "Y") + pairs = {(X[i][j], Y[i][j]) for i in range(n) for j in range(n)} + if len(pairs) != n * n: + raise Invalid("X and Y are not orthogonal (some ordered pair repeats)") + return None, {} diff --git a/tasks/construct-mc-ortholatin-l2-s0/tests/instance.json b/tasks/construct-mc-ortholatin-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..57cad9fc51de7973edca6715d043e9c8127c9385 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l2-s0/tests/run.py b/tasks/construct-mc-ortholatin-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-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-ortholatin-l2-s0/tests/test.sh b/tasks/construct-mc-ortholatin-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-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-pysms-chromatic-girth-l6-s1/environment/Dockerfile b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-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-mc-pysms-chromatic-girth-l6-s1/environment/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f7cae1a4656d12ad680db7d96c58f17eff5da48 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 24, "required_edges": [], "max_chromatic_number": 4, "min_edges": 34, "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-l6-s1/solution/solve.sh b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f10dc938061e9bdaa1f627da4c427b3e05811f35 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-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' +{"edges": [[0, 21], [0, 22], [0, 23], [1, 19], [1, 20], [1, 23], [2, 17], [2, 18], [2, 23], [3, 15], [3, 16], [3, 22], [4, 14], [4, 16], [4, 20], [5, 13], [5, 16], [5, 18], [6, 12], [6, 15], [6, 19], [7, 11], [7, 14], [7, 17], [8, 10], [8, 12], [8, 18], [9, 10], [9, 11], [9, 22], [10, 20], [11, 13], [12, 21], [13, 19], [14, 21], [15, 17]], "coloring": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s1/tests/check.py b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/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-l6-s1/tests/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f7cae1a4656d12ad680db7d96c58f17eff5da48 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 24, "required_edges": [], "max_chromatic_number": 4, "min_edges": 34, "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-l6-s1/tests/run.py b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-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-mc-pysms-chromatic-girth-l6-s1/tests/test.sh b/tasks/construct-mc-pysms-chromatic-girth-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-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-mc-pysms-clique-coloring-l1-s2/environment/Dockerfile b/tasks/construct-mc-pysms-clique-coloring-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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-pysms-clique-coloring-l1-s2/environment/instance.json b/tasks/construct-mc-pysms-clique-coloring-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..310382d0d48fb5363038f14c86bcc8a2c8da9a04 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [[1, 10], [0, 4], [0, 8], [2, 9]], "max_chromatic_number": 2, "max_clique": 4, "min_degree": 3, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s2/solution/solve.sh b/tasks/construct-mc-pysms-clique-coloring-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c235e9920320487c4f0cbbe49106341701b947c2 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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' +{"edges": [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]], "coloring": [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s2/tests/check.py b/tasks/construct-mc-pysms-clique-coloring-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s2/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-clique-coloring-l1-s2/tests/instance.json b/tasks/construct-mc-pysms-clique-coloring-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..310382d0d48fb5363038f14c86bcc8a2c8da9a04 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [[1, 10], [0, 4], [0, 8], [2, 9]], "max_chromatic_number": 2, "max_clique": 4, "min_degree": 3, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s2/tests/run.py b/tasks/construct-mc-pysms-clique-coloring-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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-pysms-clique-coloring-l1-s2/tests/test.sh b/tasks/construct-mc-pysms-clique-coloring-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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-pysms-clique-coloring-l5-s3/environment/Dockerfile b/tasks/construct-mc-pysms-clique-coloring-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-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-clique-coloring-l5-s3/environment/instance.json b/tasks/construct-mc-pysms-clique-coloring-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a4d43f7bcfa70d5fca68d3dc49655c722464c036 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [[1, 7], [1, 10], [0, 8], [0, 3], [1, 14]], "max_chromatic_number": 4, "max_clique": 3, "min_degree": 1, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s3/solution/solve.sh b/tasks/construct-mc-pysms-clique-coloring-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c40a5bb5a43c45422b63ded410462be84d6951ea --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-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, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]], "coloring": [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s3/tests/check.py b/tasks/construct-mc-pysms-clique-coloring-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-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-clique-coloring-l5-s3/tests/instance.json b/tasks/construct-mc-pysms-clique-coloring-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a4d43f7bcfa70d5fca68d3dc49655c722464c036 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [[1, 7], [1, 10], [0, 8], [0, 3], [1, 14]], "max_chromatic_number": 4, "max_clique": 3, "min_degree": 1, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s3/tests/run.py b/tasks/construct-mc-pysms-clique-coloring-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-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-clique-coloring-l5-s3/tests/test.sh b/tasks/construct-mc-pysms-clique-coloring-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-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-degree-bounds-l2-s1/environment/Dockerfile b/tasks/construct-mc-pysms-degree-bounds-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-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-mc-pysms-degree-bounds-l2-s1/environment/instance.json b/tasks/construct-mc-pysms-degree-bounds-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..af49655239f46696210fde42bac9b2dfc3e0a496 --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 13, "required_edges": [], "max_degree": 5, "min_degree": 4, "family": "mc_pysms_degree_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s1/solution/solve.sh b/tasks/construct-mc-pysms-degree-bounds-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ac4cd887ad4fba44063f17793f0f5a096c9d655 --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-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' +{"edges": [[0, 9], [0, 10], [0, 11], [0, 12], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 7], [2, 9], [2, 10], [2, 11], [2, 12], [3, 6], [3, 9], [3, 10], [3, 11], [3, 12], [4, 5], [4, 9], [4, 10], [4, 11], [4, 12], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s1/tests/check.py b/tasks/construct-mc-pysms-degree-bounds-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s1/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-degree-bounds-l2-s1/tests/instance.json b/tasks/construct-mc-pysms-degree-bounds-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..af49655239f46696210fde42bac9b2dfc3e0a496 --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 13, "required_edges": [], "max_degree": 5, "min_degree": 4, "family": "mc_pysms_degree_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s1/tests/run.py b/tasks/construct-mc-pysms-degree-bounds-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-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-mc-pysms-degree-bounds-l2-s1/tests/test.sh b/tasks/construct-mc-pysms-degree-bounds-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-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-mc-pysms-min-degree-l5-s1/environment/Dockerfile b/tasks/construct-mc-pysms-min-degree-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-mc-pysms-min-degree-l5-s1/environment/instance.json b/tasks/construct-mc-pysms-min-degree-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4cd192b472e6c4710f41976f9661362677d581af --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [], "min_degree": 6, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l5-s1/solution/solve.sh b/tasks/construct-mc-pysms-min-degree-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..202381af71f4ba7b8da0d1a923832175f9607239 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-degree-l5-s1/tests/check.py b/tasks/construct-mc-pysms-min-degree-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s1/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-min-degree-l5-s1/tests/instance.json b/tasks/construct-mc-pysms-min-degree-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4cd192b472e6c4710f41976f9661362677d581af --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [], "min_degree": 6, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l5-s1/tests/run.py b/tasks/construct-mc-pysms-min-degree-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-mc-pysms-min-degree-l5-s1/tests/test.sh b/tasks/construct-mc-pysms-min-degree-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-mc-social-golfers-l5-s0/environment/Dockerfile b/tasks/construct-mc-social-golfers-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-mc-social-golfers-l5-s0/environment/instance.json b/tasks/construct-mc-social-golfers-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..827a3062e3015c59872ddff788b987a04b71f78d --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 10, "group_size": 5, "n_weeks": 7, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l5-s0/solution/solve.sh b/tasks/construct-mc-social-golfers-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..110f54c93784c31647b521ceb2428e4395d02149 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9], [4, 2, 8, 9, 1, 7, 1, 4, 3, 6, 3, 6, 8, 9, 7, 0, 7, 8, 3, 5, 9, 0, 8, 5, 6, 9, 5, 2, 6, 7, 5, 1, 4, 0, 2, 6, 5, 4, 7, 9, 1, 4, 3, 0, 2, 3, 2, 8, 1, 0], [9, 8, 0, 2, 4, 8, 7, 3, 6, 9, 7, 1, 2, 8, 5, 8, 6, 3, 5, 4, 9, 7, 6, 0, 2, 6, 1, 7, 5, 4, 7, 3, 6, 4, 0, 3, 5, 2, 0, 1, 2, 5, 9, 1, 3, 1, 9, 4, 8, 0], [9, 5, 7, 6, 8, 7, 9, 6, 8, 3, 4, 9, 3, 2, 5, 4, 9, 8, 0, 1, 7, 6, 0, 5, 8, 1, 3, 7, 6, 2, 2, 4, 5, 3, 1, 2, 9, 1, 4, 0, 0, 4, 2, 1, 3, 7, 0, 5, 6, 8], [6, 5, 7, 9, 8, 6, 5, 8, 9, 7, 6, 9, 5, 7, 8, 2, 3, 4, 0, 1, 8, 7, 6, 9, 1, 4, 8, 3, 6, 5, 0, 3, 1, 4, 2, 2, 7, 0, 4, 5, 2, 9, 1, 3, 0, 2, 4, 3, 1, 0], [2, 1, 3, 0, 9, 6, 4, 7, 8, 5, 3, 7, 6, 4, 5, 7, 9, 4, 6, 5, 8, 9, 5, 4, 2, 6, 3, 5, 8, 7, 2, 1, 0, 8, 9, 6, 1, 3, 0, 2, 8, 9, 1, 4, 0, 0, 7, 2, 3, 1], [0, 1, 2, 3, 4, 3, 2, 1, 0, 4, 1, 5, 0, 6, 2, 2, 6, 7, 5, 0, 5, 7, 8, 9, 1, 4, 8, 9, 6, 7, 4, 0, 7, 9, 3, 8, 3, 6, 5, 9, 7, 8, 9, 1, 2, 4, 6, 3, 5, 8]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l5-s0/tests/check.py b/tasks/construct-mc-social-golfers-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s0/tests/check.py @@ -0,0 +1,25 @@ +"""Social golfer problem (MathConstraint social_golfers, CSPLib prob010, CC-BY-4.0): each week partition +the g*s players into g groups of size s; no two players share a group in more than one week.""" +from run import Invalid, int_list + + +def check(inst, ans): + g, s, w = inst["n_groups"], inst["group_size"], inst["n_weeks"] + P = g * s + sched = ans.get("schedule") + if not isinstance(sched, list) or len(sched) != w: + raise Invalid(f"schedule must be a list of {w} weeks") + met = set() + for wk, row in enumerate(sched): + row = int_list(row, P, 0, g - 1, f"week {wk}") + groups = [[p for p in range(P) if row[p] == grp] for grp in range(g)] + for grp, mem in enumerate(groups): + if len(mem) != s: + raise Invalid(f"week {wk}: group {grp} has {len(mem)} players, need {s}") + for i in range(s): + for j in range(i + 1, s): + pr = (mem[i], mem[j]) + if pr in met: + raise Invalid(f"players {pr} play together in more than one week") + met.add(pr) + return None, {} diff --git a/tasks/construct-mc-social-golfers-l5-s0/tests/instance.json b/tasks/construct-mc-social-golfers-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..827a3062e3015c59872ddff788b987a04b71f78d --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 10, "group_size": 5, "n_weeks": 7, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l5-s0/tests/run.py b/tasks/construct-mc-social-golfers-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-mc-social-golfers-l5-s0/tests/test.sh b/tasks/construct-mc-social-golfers-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-mc-van-der-waerden-l4-s0/environment/Dockerfile b/tasks/construct-mc-van-der-waerden-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-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-van-der-waerden-l4-s0/environment/instance.json b/tasks/construct-mc-van-der-waerden-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bcf4d8839d65d74444efd6c04d6dee8e517113a7 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"k": 3, "L": 4, "n": 60, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s0/solution/solve.sh b/tasks/construct-mc-van-der-waerden-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bfcd6c9702b60dd9139509fc03daff522c31139e --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-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' +{"colors": [0, 1, 2, 2, 1, 0, 0, 0, 1, 0, 1, 2, 1, 0, 2, 0, 0, 1, 1, 1, 2, 2, 1, 0, 2, 1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 2, 1, 0, 1, 2, 0, 2, 0, 2, 2, 0, 0, 1, 2, 0, 2, 2, 1, 1, 0, 1, 0, 1, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-van-der-waerden-l4-s0/tests/check.py b/tasks/construct-mc-van-der-waerden-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9853b089b6ac1773d80eac8e9e02ceb4019ad41f --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s0/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-l4-s0/tests/instance.json b/tasks/construct-mc-van-der-waerden-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bcf4d8839d65d74444efd6c04d6dee8e517113a7 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"k": 3, "L": 4, "n": 60, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s0/tests/run.py b/tasks/construct-mc-van-der-waerden-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-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-van-der-waerden-l4-s0/tests/test.sh b/tasks/construct-mc-van-der-waerden-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-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-vertex-cover-l1-s0/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s0/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c50ae719632617da9b99b9fdb8576d749167c7e9 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 6], [0, 14], [1, 6], [1, 12], [1, 15], [1, 19], [2, 5], [2, 11], [2, 13], [2, 19], [3, 6], [3, 17], [4, 8], [4, 19], [5, 6], [5, 19], [7, 9], [8, 10], [8, 12], [8, 15], [8, 17], [8, 19], [9, 12], [9, 14], [9, 16], [9, 18], [9, 19], [11, 18], [12, 16], [13, 18], [13, 19], [14, 16], [17, 18]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s0/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..99d6332b3ad7c9dcc2e08c52152ba1dc97835f9f --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [1, 2, 3, 6, 8, 9, 13, 14, 16, 18, 19]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s0/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s0/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s0/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c50ae719632617da9b99b9fdb8576d749167c7e9 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 6], [0, 14], [1, 6], [1, 12], [1, 15], [1, 19], [2, 5], [2, 11], [2, 13], [2, 19], [3, 6], [3, 17], [4, 8], [4, 19], [5, 6], [5, 19], [7, 9], [8, 10], [8, 12], [8, 15], [8, 17], [8, 19], [9, 12], [9, 14], [9, 16], [9, 18], [9, 19], [11, 18], [12, 16], [13, 18], [13, 19], [14, 16], [17, 18]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s0/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s0/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s7/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s7/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..993298ec0404723fa307ea387dc766fdb4bda8e2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 2], [0, 5], [0, 6], [0, 10], [1, 3], [1, 5], [1, 17], [1, 18], [2, 9], [2, 15], [3, 6], [3, 11], [3, 12], [4, 11], [4, 12], [5, 15], [5, 18], [6, 8], [6, 16], [6, 17], [7, 13], [7, 14], [7, 17], [8, 12], [9, 16], [10, 12], [10, 18], [12, 13], [12, 17], [12, 18], [16, 18]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s7/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..21a28acaaa05a45b56cd886f0509e73285fe79e6 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 2, 6, 7, 10, 11, 12, 15, 16, 18]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s7/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s7/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s7/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..993298ec0404723fa307ea387dc766fdb4bda8e2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 2], [0, 5], [0, 6], [0, 10], [1, 3], [1, 5], [1, 17], [1, 18], [2, 9], [2, 15], [3, 6], [3, 11], [3, 12], [4, 11], [4, 12], [5, 15], [5, 18], [6, 8], [6, 16], [6, 17], [7, 13], [7, 14], [7, 17], [8, 12], [9, 16], [10, 12], [10, 18], [12, 13], [12, 17], [12, 18], [16, 18]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s7/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s7/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l5-s8/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l5-s8/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b4a0103df53177cc616dcfeaaf50a5be9258edf --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 1], [0, 6], [0, 16], [0, 22], [0, 24], [0, 41], [0, 49], [0, 55], [0, 63], [0, 67], [0, 71], [0, 79], [0, 83], [0, 87], [0, 88], [1, 23], [1, 28], [1, 46], [1, 62], [1, 66], [1, 70], [2, 10], [2, 16], [2, 18], [2, 20], [2, 25], [2, 27], [2, 41], [2, 55], [2, 74], [3, 8], [3, 9], [3, 11], [3, 44], [3, 51], [3, 78], [3, 82], [3, 85], [3, 88], [4, 5], [4, 9], [4, 19], [4, 47], [4, 48], [4, 56], [4, 61], [4, 73], [4, 77], [5, 9], [5, 40], [5, 58], [5, 63], [5, 65], [5, 73], [5, 78], [5, 86], [6, 12], [6, 35], [6, 40], [6, 44], [6, 47], [6, 54], [7, 8], [7, 9], [7, 14], [7, 22], [7, 33], [7, 35], [7, 40], [7, 44], [7, 52], [7, 61], [7, 72], [8, 11], [8, 14], [8, 19], [8, 35], [8, 68], [8, 72], [8, 81], [9, 17], [9, 27], [9, 41], [9, 45], [9, 46], [9, 49], [9, 55], [9, 56], [9, 58], [9, 60], [9, 61], [9, 71], [9, 77], [9, 88], [10, 19], [10, 27], [10, 37], [10, 42], [10, 45], [10, 51], [10, 54], [10, 69], [11, 18], [11, 28], [11, 30], [11, 34], [11, 40], [11, 41], [11, 46], [11, 51], [11, 55], [11, 61], [11, 68], [11, 74], [11, 87], [12, 13], [12, 39], [12, 46], [12, 50], [12, 65], [12, 81], [13, 32], [13, 34], [13, 35], [13, 53], [13, 54], [13, 57], [13, 61], [13, 71], [13, 73], [13, 74], [13, 82], [13, 88], [14, 26], [14, 29], [14, 50], [14, 62], [14, 75], [14, 83], [14, 87], [15, 33], [15, 43], [15, 46], [15, 59], [15, 78], [15, 89], [16, 22], [16, 38], [16, 43], [16, 89], [17, 19], [17, 22], [17, 23], [17, 31], [17, 37], [17, 43], [17, 44], [17, 56], [17, 57], [17, 61], [17, 66], [17, 70], [17, 77], [17, 87], [17, 88], [18, 31], [18, 33], [18, 34], [18, 38], [18, 54], [18, 58], [18, 64], [18, 68], [18, 73], [19, 33], [19, 38], [19, 39], [19, 44], [19, 52], [19, 58], [19, 66], [19, 70], [19, 76], [19, 83], [20, 28], [20, 31], [20, 35], [20, 46], [20, 62], [20, 89], [21, 38], [21, 47], [21, 54], [21, 77], [21, 78], [21, 84], [22, 24], [22, 34], [22, 44], [22, 51], [22, 52], [22, 53], [22, 65], [22, 69], [22, 71], [22, 76], [22, 85], [22, 87], [23, 30], [23, 36], [23, 38], [23, 49], [23, 54], [23, 56], [23, 62], [23, 71], [23, 75], [23, 76], [23, 82], [23, 84], [24, 35], [24, 39], [24, 43], [24, 51], [24, 69], [24, 76], [24, 81], [25, 31], [25, 43], [25, 44], [25, 69], [26, 28], [26, 35], [26, 40], [26, 46], [26, 54], [26, 65], [26, 73], [26, 80], [26, 83], [26, 84], [26, 88], [27, 44], [27, 47], [27, 51], [27, 55], [27, 59], [27, 65], [27, 77], [27, 78], [28, 45], [28, 47], [28, 49], [28, 50], [28, 51], [28, 52], [28, 72], [28, 82], [29, 35], [29, 46], [29, 56], [29, 58], [29, 65], [29, 85], [30, 50], [30, 75], [30, 76], [30, 78], [30, 80], [31, 49], [31, 55], [31, 63], [31, 65], [31, 68], [31, 70], [31, 75], [31, 89], [32, 33], [32, 69], [32, 70], [32, 76], [32, 79], [32, 87], [33, 47], [33, 55], [33, 64], [33, 72], [33, 75], [33, 76], [33, 77], [33, 81], [34, 61], [34, 67], [34, 73], [34, 75], [34, 82], [34, 85], [35, 67], [35, 78], [35, 84], [36, 43], [36, 59], [36, 61], [36, 64], [36, 69], [36, 70], [36, 71], [36, 73], [36, 74], [36, 84], [36, 86], [36, 87], [37, 43], [37, 59], [37, 79], [37, 89], [38, 39], [38, 43], [38, 48], [38, 50], [38, 56], [38, 57], [38, 60], [38, 61], [38, 69], [38, 75], [38, 77], [38, 81], [38, 83], [39, 49], [39, 71], [39, 80], [39, 83], [40, 43], [40, 45], [40, 46], [40, 63], [40, 64], [40, 68], [40, 73], [41, 57], [41, 60], [41, 65], [41, 69], [41, 75], [41, 76], [41, 77], [41, 78], [41, 80], [41, 87], [42, 59], [42, 61], [42, 62], [42, 78], [42, 80], [43, 46], [43, 59], [43, 69], [43, 75], [43, 85], [43, 86], [43, 87], [44, 48], [44, 51], [44, 75], [44, 77], [44, 88], [45, 48], [45, 61], [45, 72], [45, 78], [45, 89], [46, 51], [46, 54], [46, 56], [46, 60], [46, 66], [46, 72], [46, 77], [46, 81], [47, 55], [47, 59], [47, 75], [47, 81], [48, 51], [48, 74], [48, 80], [48, 83], [48, 88], [49, 52], [49, 65], [49, 67], [49, 68], [49, 71], [49, 76], [49, 80], [49, 81], [49, 82], [49, 84], [49, 87], [50, 51], [50, 52], [50, 58], [51, 53], [51, 76], [51, 82], [51, 88], [52, 73], [52, 79], [52, 82], [52, 85], [52, 86], [53, 57], [53, 60], [53, 78], [53, 83], [54, 62], [54, 63], [54, 82], [54, 89], [55, 58], [55, 70], [55, 85], [56, 70], [56, 73], [56, 75], [56, 77], [57, 66], [57, 70], [57, 71], [57, 73], [57, 80], [57, 84], [57, 87], [58, 60], [58, 79], [58, 82], [58, 88], [58, 89], [59, 63], [59, 64], [59, 86], [60, 67], [60, 73], [60, 83], [61, 70], [61, 71], [61, 77], [61, 86], [62, 68], [62, 81], [62, 83], [62, 85], [62, 89], [63, 65], [63, 73], [63, 76], [63, 88], [64, 71], [64, 75], [64, 77], [65, 67], [65, 69], [65, 70], [65, 73], [65, 77], [65, 86], [65, 88], [66, 67], [66, 73], [66, 79], [66, 80], [66, 82], [66, 83], [66, 88], [67, 69], [67, 72], [67, 77], [67, 84], [68, 76], [68, 80], [68, 83], [69, 77], [69, 80], [69, 89], [71, 84], [71, 85], [71, 87], [72, 74], [72, 89], [73, 79], [73, 82], [73, 83], [73, 85], [74, 76], [74, 89], [75, 87], [76, 78], [76, 79], [76, 80], [76, 88], [76, 89], [77, 85], [77, 88], [78, 89], [79, 81], [80, 87], [81, 88], [82, 84], [82, 89], [83, 86], [84, 85], [84, 86], [85, 88], [87, 89]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s8/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d9e58d9e0b559c50a39026504549e093d95424 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 2, 5, 8, 9, 10, 11, 12, 13, 14, 17, 18, 19, 22, 23, 24, 25, 28, 29, 31, 32, 33, 35, 36, 38, 39, 40, 41, 43, 44, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56, 57, 59, 60, 61, 62, 65, 67, 71, 72, 73, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 88, 89]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s8/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s8/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l5-s8/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b4a0103df53177cc616dcfeaaf50a5be9258edf --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 1], [0, 6], [0, 16], [0, 22], [0, 24], [0, 41], [0, 49], [0, 55], [0, 63], [0, 67], [0, 71], [0, 79], [0, 83], [0, 87], [0, 88], [1, 23], [1, 28], [1, 46], [1, 62], [1, 66], [1, 70], [2, 10], [2, 16], [2, 18], [2, 20], [2, 25], [2, 27], [2, 41], [2, 55], [2, 74], [3, 8], [3, 9], [3, 11], [3, 44], [3, 51], [3, 78], [3, 82], [3, 85], [3, 88], [4, 5], [4, 9], [4, 19], [4, 47], [4, 48], [4, 56], [4, 61], [4, 73], [4, 77], [5, 9], [5, 40], [5, 58], [5, 63], [5, 65], [5, 73], [5, 78], [5, 86], [6, 12], [6, 35], [6, 40], [6, 44], [6, 47], [6, 54], [7, 8], [7, 9], [7, 14], [7, 22], [7, 33], [7, 35], [7, 40], [7, 44], [7, 52], [7, 61], [7, 72], [8, 11], [8, 14], [8, 19], [8, 35], [8, 68], [8, 72], [8, 81], [9, 17], [9, 27], [9, 41], [9, 45], [9, 46], [9, 49], [9, 55], [9, 56], [9, 58], [9, 60], [9, 61], [9, 71], [9, 77], [9, 88], [10, 19], [10, 27], [10, 37], [10, 42], [10, 45], [10, 51], [10, 54], [10, 69], [11, 18], [11, 28], [11, 30], [11, 34], [11, 40], [11, 41], [11, 46], [11, 51], [11, 55], [11, 61], [11, 68], [11, 74], [11, 87], [12, 13], [12, 39], [12, 46], [12, 50], [12, 65], [12, 81], [13, 32], [13, 34], [13, 35], [13, 53], [13, 54], [13, 57], [13, 61], [13, 71], [13, 73], [13, 74], [13, 82], [13, 88], [14, 26], [14, 29], [14, 50], [14, 62], [14, 75], [14, 83], [14, 87], [15, 33], [15, 43], [15, 46], [15, 59], [15, 78], [15, 89], [16, 22], [16, 38], [16, 43], [16, 89], [17, 19], [17, 22], [17, 23], [17, 31], [17, 37], [17, 43], [17, 44], [17, 56], [17, 57], [17, 61], [17, 66], [17, 70], [17, 77], [17, 87], [17, 88], [18, 31], [18, 33], [18, 34], [18, 38], [18, 54], [18, 58], [18, 64], [18, 68], [18, 73], [19, 33], [19, 38], [19, 39], [19, 44], [19, 52], [19, 58], [19, 66], [19, 70], [19, 76], [19, 83], [20, 28], [20, 31], [20, 35], [20, 46], [20, 62], [20, 89], [21, 38], [21, 47], [21, 54], [21, 77], [21, 78], [21, 84], [22, 24], [22, 34], [22, 44], [22, 51], [22, 52], [22, 53], [22, 65], [22, 69], [22, 71], [22, 76], [22, 85], [22, 87], [23, 30], [23, 36], [23, 38], [23, 49], [23, 54], [23, 56], [23, 62], [23, 71], [23, 75], [23, 76], [23, 82], [23, 84], [24, 35], [24, 39], [24, 43], [24, 51], [24, 69], [24, 76], [24, 81], [25, 31], [25, 43], [25, 44], [25, 69], [26, 28], [26, 35], [26, 40], [26, 46], [26, 54], [26, 65], [26, 73], [26, 80], [26, 83], [26, 84], [26, 88], [27, 44], [27, 47], [27, 51], [27, 55], [27, 59], [27, 65], [27, 77], [27, 78], [28, 45], [28, 47], [28, 49], [28, 50], [28, 51], [28, 52], [28, 72], [28, 82], [29, 35], [29, 46], [29, 56], [29, 58], [29, 65], [29, 85], [30, 50], [30, 75], [30, 76], [30, 78], [30, 80], [31, 49], [31, 55], [31, 63], [31, 65], [31, 68], [31, 70], [31, 75], [31, 89], [32, 33], [32, 69], [32, 70], [32, 76], [32, 79], [32, 87], [33, 47], [33, 55], [33, 64], [33, 72], [33, 75], [33, 76], [33, 77], [33, 81], [34, 61], [34, 67], [34, 73], [34, 75], [34, 82], [34, 85], [35, 67], [35, 78], [35, 84], [36, 43], [36, 59], [36, 61], [36, 64], [36, 69], [36, 70], [36, 71], [36, 73], [36, 74], [36, 84], [36, 86], [36, 87], [37, 43], [37, 59], [37, 79], [37, 89], [38, 39], [38, 43], [38, 48], [38, 50], [38, 56], [38, 57], [38, 60], [38, 61], [38, 69], [38, 75], [38, 77], [38, 81], [38, 83], [39, 49], [39, 71], [39, 80], [39, 83], [40, 43], [40, 45], [40, 46], [40, 63], [40, 64], [40, 68], [40, 73], [41, 57], [41, 60], [41, 65], [41, 69], [41, 75], [41, 76], [41, 77], [41, 78], [41, 80], [41, 87], [42, 59], [42, 61], [42, 62], [42, 78], [42, 80], [43, 46], [43, 59], [43, 69], [43, 75], [43, 85], [43, 86], [43, 87], [44, 48], [44, 51], [44, 75], [44, 77], [44, 88], [45, 48], [45, 61], [45, 72], [45, 78], [45, 89], [46, 51], [46, 54], [46, 56], [46, 60], [46, 66], [46, 72], [46, 77], [46, 81], [47, 55], [47, 59], [47, 75], [47, 81], [48, 51], [48, 74], [48, 80], [48, 83], [48, 88], [49, 52], [49, 65], [49, 67], [49, 68], [49, 71], [49, 76], [49, 80], [49, 81], [49, 82], [49, 84], [49, 87], [50, 51], [50, 52], [50, 58], [51, 53], [51, 76], [51, 82], [51, 88], [52, 73], [52, 79], [52, 82], [52, 85], [52, 86], [53, 57], [53, 60], [53, 78], [53, 83], [54, 62], [54, 63], [54, 82], [54, 89], [55, 58], [55, 70], [55, 85], [56, 70], [56, 73], [56, 75], [56, 77], [57, 66], [57, 70], [57, 71], [57, 73], [57, 80], [57, 84], [57, 87], [58, 60], [58, 79], [58, 82], [58, 88], [58, 89], [59, 63], [59, 64], [59, 86], [60, 67], [60, 73], [60, 83], [61, 70], [61, 71], [61, 77], [61, 86], [62, 68], [62, 81], [62, 83], [62, 85], [62, 89], [63, 65], [63, 73], [63, 76], [63, 88], [64, 71], [64, 75], [64, 77], [65, 67], [65, 69], [65, 70], [65, 73], [65, 77], [65, 86], [65, 88], [66, 67], [66, 73], [66, 79], [66, 80], [66, 82], [66, 83], [66, 88], [67, 69], [67, 72], [67, 77], [67, 84], [68, 76], [68, 80], [68, 83], [69, 77], [69, 80], [69, 89], [71, 84], [71, 85], [71, 87], [72, 74], [72, 89], [73, 79], [73, 82], [73, 83], [73, 85], [74, 76], [74, 89], [75, 87], [76, 78], [76, 79], [76, 80], [76, 88], [76, 89], [77, 85], [77, 88], [78, 89], [79, 81], [80, 87], [81, 88], [82, 84], [82, 89], [83, 86], [84, 85], [84, 86], [85, 88], [87, 89]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s8/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l5-s8/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-nppc-3col-l1-s1/environment/Dockerfile b/tasks/construct-nppc-3col-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l1-s1/environment/instance.json b/tasks/construct-nppc-3col-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d5a8ab64d04f3eb88623db20b1305aab8ab3c61f --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 9], [1, 3], [1, 9], [2, 3], [2, 6], [2, 7], [3, 4], [3, 7], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [7, 9], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s1/solution/solve.sh b/tasks/construct-nppc-3col-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4cd82acba49434861c777cc39441932b92f278c4 --- /dev/null +++ b/tasks/construct-nppc-3col-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": [2, 0, 0, 1, 0, 0, 1, 2, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l1-s1/tests/check.py b/tasks/construct-nppc-3col-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s1/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-l1-s1/tests/instance.json b/tasks/construct-nppc-3col-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d5a8ab64d04f3eb88623db20b1305aab8ab3c61f --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 9], [1, 3], [1, 9], [2, 3], [2, 6], [2, 7], [3, 4], [3, 7], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [7, 9], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s1/tests/run.py b/tasks/construct-nppc-3col-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l1-s1/tests/test.sh b/tasks/construct-nppc-3col-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l1-s6/environment/Dockerfile b/tasks/construct-nppc-3col-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l1-s6/environment/instance.json b/tasks/construct-nppc-3col-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4e70a69c7f696979a1eec2eb7a6751dd4bdc4e25 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 4], [0, 5], [0, 6], [0, 8], [1, 3], [1, 6], [1, 8], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 5], [3, 8], [3, 9], [4, 9], [5, 7], [6, 7], [7, 8], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s6/solution/solve.sh b/tasks/construct-nppc-3col-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..59a4cdba8e4a3c838c31bad4c428e03602dfdd85 --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [2, 1, 2, 2, 0, 0, 0, 1, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l1-s6/tests/check.py b/tasks/construct-nppc-3col-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s6/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-l1-s6/tests/instance.json b/tasks/construct-nppc-3col-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4e70a69c7f696979a1eec2eb7a6751dd4bdc4e25 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 4], [0, 5], [0, 6], [0, 8], [1, 3], [1, 6], [1, 8], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 5], [3, 8], [3, 9], [4, 9], [5, 7], [6, 7], [7, 8], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s6/tests/run.py b/tasks/construct-nppc-3col-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l1-s6/tests/test.sh b/tasks/construct-nppc-3col-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l1-s8/environment/Dockerfile b/tasks/construct-nppc-3col-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l1-s8/environment/instance.json b/tasks/construct-nppc-3col-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..be04b72e1d9aa26151add0401d4ea1981b036712 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 4], [0, 5], [0, 6], [0, 7], [1, 2], [1, 3], [1, 7], [2, 5], [2, 6], [2, 7], [3, 5], [3, 6], [3, 7], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 9], [7, 8]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s8/solution/solve.sh b/tasks/construct-nppc-3col-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2c1cdcdb17e3c060428a43bb1a7a979a9f1fbcdf --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [0, 1, 0, 0, 1, 1, 2, 2, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l1-s8/tests/check.py b/tasks/construct-nppc-3col-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s8/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-l1-s8/tests/instance.json b/tasks/construct-nppc-3col-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..be04b72e1d9aa26151add0401d4ea1981b036712 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 4], [0, 5], [0, 6], [0, 7], [1, 2], [1, 3], [1, 7], [2, 5], [2, 6], [2, 7], [3, 5], [3, 6], [3, 7], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 9], [7, 8]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s8/tests/run.py b/tasks/construct-nppc-3col-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l1-s8/tests/test.sh b/tasks/construct-nppc-3col-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s7/environment/Dockerfile b/tasks/construct-nppc-3col-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s7/environment/instance.json b/tasks/construct-nppc-3col-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fbe848cdf16f19ac619c0cdbd547d22aa65ac906 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 1], [0, 16], [0, 24], [0, 32], [0, 41], [0, 48], [1, 2], [1, 37], [1, 45], [1, 51], [1, 52], [1, 55], [2, 8], [2, 13], [2, 30], [2, 42], [2, 59], [3, 6], [3, 10], [3, 30], [3, 32], [3, 43], [3, 59], [4, 28], [4, 30], [4, 31], [4, 52], [5, 21], [5, 32], [5, 51], [6, 12], [6, 38], [6, 39], [6, 45], [6, 51], [6, 59], [7, 10], [7, 28], [8, 17], [8, 38], [8, 40], [8, 41], [9, 12], [9, 18], [9, 28], [9, 37], [9, 41], [9, 52], [9, 55], [9, 58], [10, 17], [10, 18], [10, 20], [10, 21], [10, 26], [10, 45], [10, 54], [10, 55], [11, 21], [11, 27], [11, 38], [11, 42], [11, 44], [12, 15], [12, 42], [12, 51], [13, 14], [13, 16], [13, 20], [13, 45], [13, 59], [14, 24], [14, 28], [14, 44], [14, 53], [15, 17], [15, 22], [15, 27], [15, 38], [15, 49], [15, 57], [16, 19], [16, 30], [16, 46], [16, 57], [17, 18], [17, 29], [17, 45], [17, 53], [18, 26], [18, 30], [18, 44], [18, 51], [18, 57], [19, 24], [19, 32], [19, 42], [19, 45], [19, 56], [19, 59], [20, 28], [20, 30], [20, 34], [20, 45], [20, 56], [21, 28], [21, 35], [21, 49], [22, 24], [22, 35], [22, 50], [23, 55], [23, 57], [24, 37], [24, 39], [24, 48], [24, 49], [25, 26], [25, 28], [25, 34], [25, 36], [25, 46], [25, 47], [25, 56], [25, 57], [26, 36], [26, 52], [26, 56], [27, 32], [27, 34], [27, 36], [27, 41], [27, 46], [27, 48], [27, 49], [27, 53], [28, 49], [28, 53], [29, 35], [29, 54], [30, 50], [30, 51], [30, 53], [30, 54], [31, 51], [32, 38], [32, 40], [32, 50], [32, 57], [33, 40], [33, 51], [33, 58], [34, 57], [35, 39], [35, 40], [35, 47], [35, 48], [35, 50], [35, 52], [35, 59], [36, 54], [37, 40], [37, 42], [37, 44], [37, 54], [37, 57], [38, 46], [38, 49], [39, 44], [40, 53], [40, 55], [41, 48], [41, 50], [41, 53], [41, 55], [42, 47], [42, 50], [42, 51], [42, 55], [42, 57], [43, 49], [43, 52], [44, 50], [44, 59], [45, 51], [45, 54], [45, 56], [46, 50], [46, 51], [46, 55], [46, 59], [47, 53], [47, 55], [48, 57], [51, 53], [53, 57], [54, 55], [55, 57], [57, 59], [58, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s7/solution/solve.sh b/tasks/construct-nppc-3col-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..26738ac86b56195590ab19f49f3bf8e5fe2bc1a7 --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [2, 0, 2, 2, 2, 1, 0, 1, 1, 2, 0, 1, 1, 0, 2, 0, 1, 2, 1, 2, 2, 2, 1, 0, 0, 1, 2, 2, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 2, 2, 2, 0, 0, 0, 0, 1, 0, 2, 1, 1, 2, 2, 1, 1, 2, 1, 0, 2, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l5-s7/tests/check.py b/tasks/construct-nppc-3col-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s7/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-l5-s7/tests/instance.json b/tasks/construct-nppc-3col-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fbe848cdf16f19ac619c0cdbd547d22aa65ac906 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 1], [0, 16], [0, 24], [0, 32], [0, 41], [0, 48], [1, 2], [1, 37], [1, 45], [1, 51], [1, 52], [1, 55], [2, 8], [2, 13], [2, 30], [2, 42], [2, 59], [3, 6], [3, 10], [3, 30], [3, 32], [3, 43], [3, 59], [4, 28], [4, 30], [4, 31], [4, 52], [5, 21], [5, 32], [5, 51], [6, 12], [6, 38], [6, 39], [6, 45], [6, 51], [6, 59], [7, 10], [7, 28], [8, 17], [8, 38], [8, 40], [8, 41], [9, 12], [9, 18], [9, 28], [9, 37], [9, 41], [9, 52], [9, 55], [9, 58], [10, 17], [10, 18], [10, 20], [10, 21], [10, 26], [10, 45], [10, 54], [10, 55], [11, 21], [11, 27], [11, 38], [11, 42], [11, 44], [12, 15], [12, 42], [12, 51], [13, 14], [13, 16], [13, 20], [13, 45], [13, 59], [14, 24], [14, 28], [14, 44], [14, 53], [15, 17], [15, 22], [15, 27], [15, 38], [15, 49], [15, 57], [16, 19], [16, 30], [16, 46], [16, 57], [17, 18], [17, 29], [17, 45], [17, 53], [18, 26], [18, 30], [18, 44], [18, 51], [18, 57], [19, 24], [19, 32], [19, 42], [19, 45], [19, 56], [19, 59], [20, 28], [20, 30], [20, 34], [20, 45], [20, 56], [21, 28], [21, 35], [21, 49], [22, 24], [22, 35], [22, 50], [23, 55], [23, 57], [24, 37], [24, 39], [24, 48], [24, 49], [25, 26], [25, 28], [25, 34], [25, 36], [25, 46], [25, 47], [25, 56], [25, 57], [26, 36], [26, 52], [26, 56], [27, 32], [27, 34], [27, 36], [27, 41], [27, 46], [27, 48], [27, 49], [27, 53], [28, 49], [28, 53], [29, 35], [29, 54], [30, 50], [30, 51], [30, 53], [30, 54], [31, 51], [32, 38], [32, 40], [32, 50], [32, 57], [33, 40], [33, 51], [33, 58], [34, 57], [35, 39], [35, 40], [35, 47], [35, 48], [35, 50], [35, 52], [35, 59], [36, 54], [37, 40], [37, 42], [37, 44], [37, 54], [37, 57], [38, 46], [38, 49], [39, 44], [40, 53], [40, 55], [41, 48], [41, 50], [41, 53], [41, 55], [42, 47], [42, 50], [42, 51], [42, 55], [42, 57], [43, 49], [43, 52], [44, 50], [44, 59], [45, 51], [45, 54], [45, 56], [46, 50], [46, 51], [46, 55], [46, 59], [47, 53], [47, 55], [48, 57], [51, 53], [53, 57], [54, 55], [55, 57], [57, 59], [58, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s7/tests/run.py b/tasks/construct-nppc-3col-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s7/tests/test.sh b/tasks/construct-nppc-3col-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s9/environment/Dockerfile b/tasks/construct-nppc-3col-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s9/environment/instance.json b/tasks/construct-nppc-3col-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ae6329c55c1a48a20694b6737599652ad59cdfe --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 11], [0, 13], [0, 38], [0, 44], [0, 45], [0, 46], [0, 49], [0, 50], [0, 55], [0, 59], [1, 2], [1, 12], [1, 15], [1, 17], [1, 18], [1, 26], [1, 41], [1, 44], [2, 23], [2, 26], [2, 49], [3, 18], [3, 28], [3, 39], [3, 45], [3, 56], [4, 24], [4, 26], [4, 28], [4, 44], [5, 16], [5, 17], [5, 19], [5, 33], [5, 42], [5, 43], [5, 55], [6, 12], [6, 18], [6, 43], [6, 50], [6, 59], [7, 8], [7, 9], [7, 11], [7, 19], [7, 24], [7, 25], [7, 26], [7, 35], [7, 44], [7, 45], [7, 50], [7, 54], [8, 22], [8, 26], [8, 34], [8, 41], [8, 55], [9, 14], [9, 24], [9, 25], [9, 42], [9, 54], [10, 18], [10, 26], [10, 29], [10, 32], [10, 35], [10, 37], [10, 40], [10, 43], [10, 58], [10, 59], [11, 20], [11, 21], [11, 25], [11, 26], [11, 32], [11, 38], [11, 49], [12, 38], [13, 23], [13, 38], [13, 49], [13, 53], [13, 55], [14, 17], [14, 18], [14, 21], [14, 33], [14, 38], [14, 43], [14, 45], [14, 46], [15, 18], [15, 43], [15, 48], [15, 52], [15, 57], [16, 22], [16, 24], [16, 27], [16, 33], [16, 58], [17, 23], [17, 25], [17, 30], [17, 36], [17, 37], [17, 47], [18, 51], [19, 24], [19, 30], [19, 37], [19, 51], [19, 58], [20, 25], [20, 27], [20, 37], [21, 28], [21, 29], [21, 33], [21, 58], [22, 43], [22, 50], [22, 57], [23, 24], [23, 31], [24, 31], [24, 34], [24, 43], [24, 52], [25, 30], [25, 31], [25, 40], [25, 48], [25, 50], [26, 57], [27, 31], [27, 36], [27, 47], [28, 35], [28, 36], [28, 39], [28, 47], [28, 51], [28, 58], [29, 46], [29, 47], [29, 48], [29, 50], [29, 56], [30, 37], [30, 50], [30, 58], [31, 42], [31, 48], [31, 58], [32, 36], [32, 48], [33, 37], [33, 38], [33, 39], [33, 48], [33, 49], [33, 51], [35, 36], [35, 40], [35, 43], [35, 47], [36, 41], [36, 51], [36, 52], [36, 58], [37, 42], [37, 52], [38, 43], [39, 50], [40, 58], [41, 46], [41, 52], [41, 57], [43, 55], [44, 51], [45, 51], [46, 51], [46, 58], [47, 50], [47, 53], [48, 52], [49, 50], [50, 51], [50, 53], [50, 58], [51, 55], [52, 55], [53, 56], [54, 55], [56, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s9/solution/solve.sh b/tasks/construct-nppc-3col-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd75e20fe6b949dcf7ea7c46e2f6b92abedf2040 --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [2, 0, 1, 2, 0, 2, 0, 0, 1, 1, 0, 1, 2, 1, 2, 2, 0, 1, 1, 1, 0, 0, 2, 0, 2, 2, 2, 2, 1, 2, 0, 1, 2, 1, 0, 2, 0, 2, 0, 0, 1, 2, 0, 1, 1, 1, 1, 0, 0, 0, 1, 2, 1, 2, 2, 0, 0, 1, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l5-s9/tests/check.py b/tasks/construct-nppc-3col-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s9/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-l5-s9/tests/instance.json b/tasks/construct-nppc-3col-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ae6329c55c1a48a20694b6737599652ad59cdfe --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 11], [0, 13], [0, 38], [0, 44], [0, 45], [0, 46], [0, 49], [0, 50], [0, 55], [0, 59], [1, 2], [1, 12], [1, 15], [1, 17], [1, 18], [1, 26], [1, 41], [1, 44], [2, 23], [2, 26], [2, 49], [3, 18], [3, 28], [3, 39], [3, 45], [3, 56], [4, 24], [4, 26], [4, 28], [4, 44], [5, 16], [5, 17], [5, 19], [5, 33], [5, 42], [5, 43], [5, 55], [6, 12], [6, 18], [6, 43], [6, 50], [6, 59], [7, 8], [7, 9], [7, 11], [7, 19], [7, 24], [7, 25], [7, 26], [7, 35], [7, 44], [7, 45], [7, 50], [7, 54], [8, 22], [8, 26], [8, 34], [8, 41], [8, 55], [9, 14], [9, 24], [9, 25], [9, 42], [9, 54], [10, 18], [10, 26], [10, 29], [10, 32], [10, 35], [10, 37], [10, 40], [10, 43], [10, 58], [10, 59], [11, 20], [11, 21], [11, 25], [11, 26], [11, 32], [11, 38], [11, 49], [12, 38], [13, 23], [13, 38], [13, 49], [13, 53], [13, 55], [14, 17], [14, 18], [14, 21], [14, 33], [14, 38], [14, 43], [14, 45], [14, 46], [15, 18], [15, 43], [15, 48], [15, 52], [15, 57], [16, 22], [16, 24], [16, 27], [16, 33], [16, 58], [17, 23], [17, 25], [17, 30], [17, 36], [17, 37], [17, 47], [18, 51], [19, 24], [19, 30], [19, 37], [19, 51], [19, 58], [20, 25], [20, 27], [20, 37], [21, 28], [21, 29], [21, 33], [21, 58], [22, 43], [22, 50], [22, 57], [23, 24], [23, 31], [24, 31], [24, 34], [24, 43], [24, 52], [25, 30], [25, 31], [25, 40], [25, 48], [25, 50], [26, 57], [27, 31], [27, 36], [27, 47], [28, 35], [28, 36], [28, 39], [28, 47], [28, 51], [28, 58], [29, 46], [29, 47], [29, 48], [29, 50], [29, 56], [30, 37], [30, 50], [30, 58], [31, 42], [31, 48], [31, 58], [32, 36], [32, 48], [33, 37], [33, 38], [33, 39], [33, 48], [33, 49], [33, 51], [35, 36], [35, 40], [35, 43], [35, 47], [36, 41], [36, 51], [36, 52], [36, 58], [37, 42], [37, 52], [38, 43], [39, 50], [40, 58], [41, 46], [41, 52], [41, 57], [43, 55], [44, 51], [45, 51], [46, 51], [46, 58], [47, 50], [47, 53], [48, 52], [49, 50], [50, 51], [50, 53], [50, 58], [51, 55], [52, 55], [53, 56], [54, 55], [56, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s9/tests/run.py b/tasks/construct-nppc-3col-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s9/tests/test.sh b/tasks/construct-nppc-3col-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-bandwidth-l3-s3/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-bandwidth-l3-s3/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9ca4ad9461c49b9b3d8cfa9c8c775481ee6c0288 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [0, 4], [1, 3], [2, 4], [2, 5], [3, 7], [5, 6], [6, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s3/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e436e00490f849042755466b60758720e3aa9299 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [6, 2, 5, 0, 7, 4, 3, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s3/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s3/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l3-s3/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9ca4ad9461c49b9b3d8cfa9c8c775481ee6c0288 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [0, 4], [1, 3], [2, 4], [2, 5], [3, 7], [5, 6], [6, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s3/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-bandwidth-l3-s3/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-bandwidth-l3-s4/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l3-s4/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cc7012e9990d463f63e51f37bea56944bf17e32b --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 1], [0, 5], [1, 5], [2, 5], [3, 4], [4, 6], [5, 7], [6, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s4/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6a59161f622760a825513b5f4a886b36b34ade86 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [6, 4, 7, 0, 1, 5, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s4/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s4/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l3-s4/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cc7012e9990d463f63e51f37bea56944bf17e32b --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 1], [0, 5], [1, 5], [2, 5], [3, 4], [4, 6], [5, 7], [6, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s4/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l3-s4/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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/construct-nppc-clique-l6-s2/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s2/environment/instance.json b/tasks/construct-nppc-clique-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3863a3a6a7fdc4ace47d1b85fe096d82b7d4ebb6 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 15], [0, 16], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 36], [0, 38], [0, 40], [0, 42], [0, 44], [0, 46], [0, 47], [0, 48], [0, 49], [0, 51], [0, 52], [0, 56], [0, 58], [0, 59], [0, 62], [0, 65], [0, 66], [0, 67], [0, 74], [0, 76], [0, 79], [0, 82], [0, 85], [0, 89], [0, 93], [0, 94], [0, 95], [0, 98], [0, 99], [1, 3], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 23], [1, 24], [1, 26], [1, 27], [1, 28], [1, 29], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 38], [1, 42], [1, 43], [1, 47], [1, 48], [1, 50], [1, 51], [1, 56], [1, 59], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 68], [1, 69], [1, 70], [1, 71], [1, 77], [1, 78], [1, 79], [1, 80], [1, 81], [1, 82], [1, 84], [1, 85], [1, 86], [1, 87], [1, 91], [1, 93], [1, 94], [1, 95], [1, 96], [1, 97], [1, 98], [1, 99], [2, 3], [2, 4], [2, 5], [2, 10], [2, 11], [2, 14], [2, 16], [2, 20], [2, 22], [2, 27], [2, 30], [2, 32], [2, 33], [2, 36], [2, 41], [2, 42], [2, 43], [2, 45], [2, 48], [2, 54], [2, 55], [2, 57], [2, 59], [2, 61], [2, 62], [2, 66], [2, 67], [2, 68], [2, 69], [2, 70], [2, 71], [2, 74], [2, 77], [2, 78], [2, 79], [2, 80], [2, 83], [2, 84], [2, 85], [2, 87], [2, 89], [2, 92], [2, 94], [2, 95], [2, 97], [3, 5], [3, 6], [3, 10], [3, 12], [3, 19], [3, 20], [3, 21], [3, 23], [3, 24], [3, 26], [3, 27], [3, 32], [3, 34], [3, 36], [3, 39], [3, 41], [3, 43], [3, 46], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 58], [3, 60], [3, 62], [3, 63], [3, 64], [3, 65], [3, 68], [3, 69], [3, 72], [3, 73], [3, 75], [3, 81], [3, 82], [3, 84], [3, 87], [3, 88], [3, 90], [3, 91], [3, 97], [4, 7], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 18], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 30], [4, 31], [4, 33], [4, 34], [4, 38], [4, 40], [4, 41], [4, 43], [4, 44], [4, 45], [4, 46], [4, 48], [4, 50], [4, 51], [4, 53], [4, 57], [4, 60], [4, 65], [4, 66], [4, 68], [4, 69], [4, 70], [4, 72], [4, 73], [4, 74], [4, 76], [4, 77], [4, 79], [4, 81], [4, 82], [4, 86], [4, 87], [4, 88], [4, 90], [4, 93], [4, 97], [4, 98], [5, 7], [5, 8], [5, 10], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 21], [5, 25], [5, 26], [5, 28], [5, 29], [5, 30], [5, 35], [5, 36], [5, 38], [5, 41], [5, 42], [5, 44], [5, 45], [5, 46], [5, 47], [5, 48], [5, 49], [5, 51], [5, 52], [5, 54], [5, 55], [5, 56], [5, 59], [5, 60], [5, 62], [5, 63], [5, 64], [5, 65], [5, 67], [5, 68], [5, 69], [5, 71], [5, 72], [5, 77], [5, 79], [5, 80], [5, 81], [5, 82], [5, 83], [5, 84], [5, 86], [5, 91], [5, 95], [5, 97], [5, 98], [6, 9], [6, 10], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 22], [6, 24], [6, 25], [6, 29], [6, 35], [6, 36], [6, 39], [6, 40], [6, 41], [6, 44], [6, 45], [6, 48], [6, 49], [6, 52], [6, 53], [6, 54], [6, 55], [6, 58], [6, 59], [6, 60], [6, 61], [6, 62], [6, 63], [6, 64], [6, 66], [6, 72], [6, 77], [6, 79], [6, 80], [6, 81], [6, 83], [6, 84], [6, 90], [6, 94], [6, 99], [7, 8], [7, 10], [7, 12], [7, 13], [7, 16], [7, 17], [7, 18], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 35], [7, 36], [7, 37], [7, 38], [7, 40], [7, 41], [7, 42], [7, 45], [7, 47], [7, 48], [7, 51], [7, 56], [7, 59], [7, 61], [7, 62], [7, 63], [7, 64], [7, 65], [7, 66], [7, 67], [7, 68], [7, 69], [7, 70], [7, 71], [7, 72], [7, 73], [7, 74], [7, 76], [7, 77], [7, 78], [7, 80], [7, 81], [7, 83], [7, 84], [7, 85], [7, 86], [7, 87], [7, 91], [7, 95], [7, 97], [7, 98], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 24], [8, 26], [8, 27], [8, 28], [8, 31], [8, 32], [8, 33], [8, 34], [8, 36], [8, 37], [8, 40], [8, 41], [8, 43], [8, 44], [8, 47], [8, 49], [8, 50], [8, 52], [8, 55], [8, 57], [8, 58], [8, 63], [8, 64], [8, 65], [8, 66], [8, 67], [8, 69], [8, 71], [8, 74], [8, 75], [8, 76], [8, 79], [8, 81], [8, 82], [8, 85], [8, 89], [8, 94], [8, 95], [8, 96], [8, 99], [9, 16], [9, 18], [9, 21], [9, 22], [9, 23], [9, 27], [9, 31], [9, 33], [9, 34], [9, 35], [9, 36], [9, 45], [9, 46], [9, 47], [9, 50], [9, 52], [9, 59], [9, 62], [9, 63], [9, 64], [9, 65], [9, 67], [9, 69], [9, 74], [9, 76], [9, 77], [9, 79], [9, 80], [9, 81], [9, 82], [9, 83], [9, 85], [9, 86], [9, 87], [9, 88], [9, 89], [9, 92], [9, 94], [9, 96], [9, 97], [9, 98], [9, 99], [10, 11], [10, 14], [10, 16], [10, 17], [10, 19], [10, 23], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 32], [10, 33], [10, 35], [10, 37], [10, 40], [10, 42], [10, 43], [10, 44], [10, 49], [10, 51], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 61], [10, 66], [10, 67], [10, 68], [10, 69], [10, 70], [10, 71], [10, 73], [10, 74], [10, 75], [10, 76], [10, 79], [10, 82], [10, 84], [10, 85], [10, 87], [10, 89], [10, 90], [10, 91], [10, 96], [10, 97], [11, 14], [11, 15], [11, 17], [11, 18], [11, 19], [11, 22], [11, 24], [11, 25], [11, 28], [11, 30], [11, 32], [11, 33], [11, 34], [11, 36], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 44], [11, 45], [11, 46], [11, 48], [11, 49], [11, 50], [11, 55], [11, 58], [11, 65], [11, 66], [11, 67], [11, 68], [11, 69], [11, 70], [11, 72], [11, 76], [11, 78], [11, 82], [11, 84], [11, 85], [11, 88], [11, 92], [11, 93], [11, 95], [11, 96], [11, 98], [11, 99], [12, 13], [12, 15], [12, 18], [12, 19], [12, 23], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 31], [12, 32], [12, 35], [12, 36], [12, 38], [12, 40], [12, 41], [12, 43], [12, 44], [12, 45], [12, 47], [12, 48], [12, 49], [12, 50], [12, 53], [12, 55], [12, 56], [12, 57], [12, 58], [12, 59], [12, 60], [12, 61], [12, 62], [12, 63], [12, 65], [12, 68], [12, 70], [12, 72], [12, 73], [12, 74], [12, 76], [12, 77], [12, 78], [12, 80], [12, 81], [12, 86], [12, 87], [12, 90], [12, 91], [12, 92], [12, 95], [12, 96], [12, 97], [12, 98], [12, 99], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 33], [13, 35], [13, 36], [13, 38], [13, 39], [13, 40], [13, 41], [13, 47], [13, 51], [13, 53], [13, 54], [13, 57], [13, 59], [13, 60], [13, 62], [13, 63], [13, 64], [13, 65], [13, 70], [13, 72], [13, 74], [13, 75], [13, 80], [13, 81], [13, 82], [13, 83], [13, 84], [13, 88], [13, 90], [13, 91], [13, 95], [14, 15], [14, 18], [14, 19], [14, 21], [14, 23], [14, 25], [14, 29], [14, 30], [14, 32], [14, 34], [14, 36], [14, 37], [14, 39], [14, 41], [14, 42], [14, 43], [14, 45], [14, 46], [14, 47], [14, 48], [14, 51], [14, 53], [14, 55], [14, 58], [14, 62], [14, 65], [14, 66], [14, 78], [14, 79], [14, 84], [14, 85], [14, 87], [14, 88], [14, 89], [14, 92], [14, 93], [14, 96], [14, 97], [15, 17], [15, 18], [15, 19], [15, 20], [15, 25], [15, 26], [15, 29], [15, 30], [15, 32], [15, 34], [15, 35], [15, 37], [15, 41], [15, 42], [15, 43], [15, 44], [15, 47], [15, 49], [15, 51], [15, 52], [15, 57], [15, 63], [15, 64], [15, 68], [15, 70], [15, 72], [15, 73], [15, 74], [15, 80], [15, 81], [15, 83], [15, 85], [15, 87], [15, 88], [15, 94], [16, 17], [16, 19], [16, 20], [16, 22], [16, 29], [16, 30], [16, 31], [16, 34], [16, 36], [16, 38], [16, 40], [16, 43], [16, 44], [16, 45], [16, 47], [16, 48], [16, 50], [16, 51], [16, 54], [16, 55], [16, 60], [16, 61], [16, 62], [16, 63], [16, 64], [16, 65], [16, 67], [16, 68], [16, 71], [16, 75], [16, 76], [16, 77], [16, 78], [16, 81], [16, 83], [16, 85], [16, 86], [16, 91], [16, 93], [16, 94], [16, 95], [16, 97], [17, 19], [17, 23], [17, 28], [17, 32], [17, 34], [17, 37], [17, 44], [17, 45], [17, 46], [17, 47], [17, 48], [17, 52], [17, 56], [17, 57], [17, 60], [17, 61], [17, 63], [17, 65], [17, 67], [17, 69], [17, 71], [17, 72], [17, 74], [17, 75], [17, 76], [17, 78], [17, 79], [17, 82], [17, 85], [17, 88], [17, 89], [17, 91], [17, 92], [17, 93], [17, 94], [17, 97], [17, 98], [18, 19], [18, 21], [18, 23], [18, 29], [18, 35], [18, 38], [18, 40], [18, 41], [18, 42], [18, 44], [18, 45], [18, 47], [18, 48], [18, 49], [18, 52], [18, 53], [18, 54], [18, 55], [18, 57], [18, 58], [18, 59], [18, 61], [18, 65], [18, 68], [18, 70], [18, 71], [18, 72], [18, 76], [18, 78], [18, 79], [18, 82], [18, 84], [18, 86], [18, 90], [18, 91], [18, 92], [18, 97], [18, 98], [18, 99], [19, 22], [19, 24], [19, 26], [19, 27], [19, 28], [19, 31], [19, 38], [19, 39], [19, 45], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 52], [19, 54], [19, 56], [19, 59], [19, 61], [19, 62], [19, 63], [19, 64], [19, 66], [19, 67], [19, 68], [19, 69], [19, 72], [19, 74], [19, 75], [19, 76], [19, 77], [19, 78], [19, 81], [19, 82], [19, 84], [19, 85], [19, 86], [19, 88], [19, 89], [19, 90], [19, 91], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 36], [20, 37], [20, 38], [20, 39], [20, 41], [20, 42], [20, 44], [20, 45], [20, 46], [20, 47], [20, 50], [20, 52], [20, 57], [20, 58], [20, 59], [20, 67], [20, 72], [20, 73], [20, 75], [20, 77], [20, 81], [20, 82], [20, 83], [20, 84], [20, 87], [20, 88], [20, 89], [20, 91], [20, 92], [20, 93], [20, 97], [20, 98], [21, 27], [21, 29], [21, 31], [21, 33], [21, 36], [21, 38], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 46], [21, 47], [21, 49], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [21, 56], [21, 58], [21, 61], [21, 64], [21, 65], [21, 66], [21, 67], [21, 69], [21, 70], [21, 73], [21, 74], [21, 79], [21, 81], [21, 83], [21, 84], [21, 87], [21, 88], [21, 91], [21, 95], [22, 24], [22, 25], [22, 27], [22, 28], [22, 31], [22, 33], [22, 34], [22, 36], [22, 37], [22, 40], [22, 41], [22, 43], [22, 46], [22, 47], [22, 48], [22, 50], [22, 51], [22, 52], [22, 53], [22, 56], [22, 58], [22, 59], [22, 60], [22, 61], [22, 66], [22, 71], [22, 72], [22, 74], [22, 76], [22, 77], [22, 80], [22, 82], [22, 84], [22, 86], [22, 87], [22, 90], [22, 93], [22, 94], [22, 95], [23, 25], [23, 26], [23, 28], [23, 29], [23, 33], [23, 34], [23, 42], [23, 43], [23, 44], [23, 45], [23, 46], [23, 49], [23, 51], [23, 53], [23, 54], [23, 55], [23, 59], [23, 60], [23, 61], [23, 62], [23, 64], [23, 66], [23, 69], [23, 70], [23, 73], [23, 74], [23, 76], [23, 77], [23, 78], [23, 82], [23, 84], [23, 86], [23, 87], [23, 90], [23, 91], [23, 92], [23, 95], [23, 96], [23, 98], [23, 99], [24, 26], [24, 27], [24, 30], [24, 37], [24, 38], [24, 39], [24, 41], [24, 42], [24, 44], [24, 45], [24, 46], [24, 47], [24, 49], [24, 50], [24, 51], [24, 53], [24, 55], [24, 56], [24, 57], [24, 58], [24, 61], [24, 67], [24, 68], [24, 73], [24, 74], [24, 75], [24, 76], [24, 85], [24, 87], [24, 88], [24, 89], [24, 95], [24, 96], [24, 97], [24, 98], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 32], [25, 33], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 41], [25, 43], [25, 44], [25, 46], [25, 48], [25, 49], [25, 52], [25, 53], [25, 56], [25, 57], [25, 59], [25, 60], [25, 61], [25, 64], [25, 67], [25, 68], [25, 69], [25, 71], [25, 73], [25, 77], [25, 79], [25, 81], [25, 82], [25, 85], [25, 87], [25, 91], [25, 97], [25, 98], [26, 27], [26, 29], [26, 30], [26, 32], [26, 35], [26, 36], [26, 38], [26, 39], [26, 41], [26, 43], [26, 44], [26, 45], [26, 47], [26, 48], [26, 50], [26, 52], [26, 55], [26, 56], [26, 62], [26, 63], [26, 64], [26, 65], [26, 67], [26, 70], [26, 72], [26, 74], [26, 75], [26, 77], [26, 80], [26, 81], [26, 82], [26, 84], [26, 85], [26, 86], [26, 87], [26, 89], [26, 90], [26, 91], [26, 92], [26, 95], [26, 97], [26, 98], [27, 28], [27, 29], [27, 30], [27, 31], [27, 36], [27, 37], [27, 40], [27, 42], [27, 43], [27, 44], [27, 45], [27, 47], [27, 51], [27, 56], [27, 58], [27, 59], [27, 60], [27, 61], [27, 67], [27, 68], [27, 69], [27, 72], [27, 77], [27, 80], [27, 81], [27, 83], [27, 86], [27, 87], [27, 88], [27, 89], [27, 91], [27, 92], [27, 93], [27, 94], [27, 95], [27, 97], [27, 98], [27, 99], [28, 31], [28, 35], [28, 37], [28, 39], [28, 40], [28, 46], [28, 48], [28, 49], [28, 53], [28, 58], [28, 59], [28, 64], [28, 67], [28, 70], [28, 71], [28, 82], [28, 84], [28, 88], [28, 90], [28, 91], [28, 92], [28, 93], [28, 94], [28, 95], [28, 98], [29, 30], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 41], [29, 42], [29, 43], [29, 44], [29, 45], [29, 47], [29, 49], [29, 51], [29, 54], [29, 56], [29, 63], [29, 64], [29, 65], [29, 69], [29, 71], [29, 74], [29, 75], [29, 76], [29, 77], [29, 80], [29, 81], [29, 83], [29, 85], [29, 86], [29, 87], [29, 88], [29, 89], [29, 91], [29, 94], [29, 95], [29, 97], [29, 98], [30, 31], [30, 33], [30, 34], [30, 37], [30, 38], [30, 39], [30, 40], [30, 42], [30, 43], [30, 48], [30, 50], [30, 51], [30, 53], [30, 56], [30, 59], [30, 60], [30, 61], [30, 70], [30, 72], [30, 74], [30, 77], [30, 78], [30, 81], [30, 82], [30, 85], [30, 86], [30, 88], [30, 89], [30, 91], [30, 93], [30, 94], [30, 97], [31, 32], [31, 35], [31, 39], [31, 42], [31, 43], [31, 47], [31, 54], [31, 55], [31, 56], [31, 58], [31, 59], [31, 65], [31, 67], [31, 68], [31, 70], [31, 72], [31, 73], [31, 75], [31, 76], [31, 78], [31, 80], [31, 83], [31, 84], [31, 85], [31, 87], [31, 88], [31, 89], [31, 90], [31, 91], [31, 92], [31, 96], [32, 34], [32, 36], [32, 37], [32, 39], [32, 42], [32, 45], [32, 46], [32, 51], [32, 56], [32, 57], [32, 58], [32, 59], [32, 61], [32, 62], [32, 64], [32, 65], [32, 67], [32, 69], [32, 70], [32, 71], [32, 73], [32, 75], [32, 78], [32, 79], [32, 80], [32, 82], [32, 83], [32, 86], [32, 87], [32, 88], [32, 90], [32, 94], [32, 95], [32, 96], [32, 98], [32, 99], [33, 34], [33, 35], [33, 39], [33, 40], [33, 41], [33, 42], [33, 43], [33, 44], [33, 45], [33, 46], [33, 47], [33, 50], [33, 51], [33, 52], [33, 53], [33, 54], [33, 56], [33, 60], [33, 61], [33, 62], [33, 63], [33, 64], [33, 68], [33, 69], [33, 73], [33, 75], [33, 77], [33, 78], [33, 83], [33, 84], [33, 87], [33, 89], [33, 90], [33, 92], [33, 93], [33, 94], [33, 95], [33, 97], [34, 35], [34, 36], [34, 37], [34, 40], [34, 42], [34, 43], [34, 44], [34, 45], [34, 47], [34, 48], [34, 50], [34, 56], [34, 57], [34, 59], [34, 62], [34, 64], [34, 66], [34, 72], [34, 73], [34, 77], [34, 78], [34, 81], [34, 83], [34, 86], [34, 89], [34, 91], [34, 92], [34, 96], [34, 97], [34, 98], [35, 36], [35, 37], [35, 38], [35, 39], [35, 41], [35, 43], [35, 44], [35, 45], [35, 47], [35, 49], [35, 51], [35, 52], [35, 53], [35, 54], [35, 55], [35, 56], [35, 60], [35, 61], [35, 63], [35, 64], [35, 65], [35, 68], [35, 69], [35, 70], [35, 72], [35, 75], [35, 76], [35, 77], [35, 78], [35, 79], [35, 80], [35, 81], [35, 83], [35, 84], [35, 86], [35, 88], [35, 89], [35, 91], [35, 92], [35, 95], [35, 97], [35, 98], [36, 37], [36, 38], [36, 42], [36, 45], [36, 47], [36, 48], [36, 49], [36, 51], [36, 52], [36, 56], [36, 58], [36, 59], [36, 60], [36, 63], [36, 64], [36, 65], [36, 66], [36, 68], [36, 74], [36, 76], [36, 77], [36, 78], [36, 79], [36, 80], [36, 81], [36, 82], [36, 83], [36, 85], [36, 86], [36, 87], [36, 88], [36, 91], [36, 97], [36, 98], [36, 99], [37, 41], [37, 42], [37, 44], [37, 46], [37, 47], [37, 51], [37, 53], [37, 59], [37, 60], [37, 61], [37, 64], [37, 66], [37, 67], [37, 69], [37, 70], [37, 71], [37, 72], [37, 74], [37, 75], [37, 76], [37, 79], [37, 82], [37, 83], [37, 84], [37, 85], [37, 90], [37, 93], [37, 94], [37, 95], [37, 96], [37, 97], [37, 98], [37, 99], [38, 39], [38, 40], [38, 46], [38, 47], [38, 48], [38, 49], [38, 51], [38, 53], [38, 54], [38, 56], [38, 57], [38, 58], [38, 60], [38, 63], [38, 65], [38, 67], [38, 69], [38, 70], [38, 74], [38, 76], [38, 77], [38, 79], [38, 80], [38, 81], [38, 82], [38, 83], [38, 85], [38, 86], [38, 88], [38, 89], [38, 91], [38, 92], [38, 94], [38, 95], [38, 97], [38, 98], [39, 45], [39, 46], [39, 47], [39, 50], [39, 51], [39, 52], [39, 54], [39, 55], [39, 57], [39, 58], [39, 62], [39, 63], [39, 64], [39, 68], [39, 71], [39, 73], [39, 74], [39, 76], [39, 77], [39, 78], [39, 80], [39, 82], [39, 85], [39, 87], [39, 88], [39, 89], [39, 94], [39, 95], [39, 96], [40, 41], [40, 42], [40, 44], [40, 45], [40, 46], [40, 51], [40, 58], [40, 59], [40, 60], [40, 61], [40, 68], [40, 70], [40, 83], [40, 84], [40, 88], [40, 94], [40, 95], [40, 97], [40, 99], [41, 43], [41, 44], [41, 46], [41, 47], [41, 51], [41, 54], [41, 56], [41, 59], [41, 61], [41, 62], [41, 63], [41, 71], [41, 72], [41, 73], [41, 75], [41, 77], [41, 79], [41, 83], [41, 87], [41, 88], [41, 91], [41, 93], [41, 95], [41, 96], [41, 98], [42, 44], [42, 46], [42, 48], [42, 49], [42, 51], [42, 52], [42, 53], [42, 58], [42, 59], [42, 60], [42, 61], [42, 62], [42, 63], [42, 68], [42, 69], [42, 70], [42, 71], [42, 73], [42, 74], [42, 78], [42, 79], [42, 81], [42, 83], [42, 85], [42, 87], [42, 88], [42, 93], [42, 96], [42, 99], [43, 50], [43, 51], [43, 58], [43, 59], [43, 61], [43, 64], [43, 66], [43, 71], [43, 72], [43, 73], [43, 75], [43, 79], [43, 80], [43, 81], [43, 82], [43, 84], [43, 86], [43, 89], [43, 90], [43, 91], [43, 98], [44, 46], [44, 47], [44, 50], [44, 51], [44, 52], [44, 56], [44, 57], [44, 59], [44, 61], [44, 62], [44, 63], [44, 64], [44, 66], [44, 67], [44, 69], [44, 70], [44, 72], [44, 75], [44, 76], [44, 79], [44, 80], [44, 83], [44, 85], [44, 88], [44, 90], [44, 91], [44, 92], [44, 96], [44, 97], [44, 98], [45, 49], [45, 50], [45, 53], [45, 54], [45, 55], [45, 57], [45, 58], [45, 59], [45, 60], [45, 61], [45, 62], [45, 64], [45, 67], [45, 72], [45, 74], [45, 76], [45, 79], [45, 80], [45, 82], [45, 85], [45, 86], [45, 88], [45, 89], [45, 91], [45, 92], [46, 48], [46, 52], [46, 54], [46, 56], [46, 58], [46, 59], [46, 60], [46, 62], [46, 63], [46, 65], [46, 66], [46, 67], [46, 68], [46, 71], [46, 72], [46, 76], [46, 80], [46, 81], [46, 84], [46, 85], [46, 86], [46, 87], [46, 88], [46, 90], [46, 91], [46, 92], [46, 93], [46, 94], [46, 96], [46, 98], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 55], [47, 56], [47, 57], [47, 62], [47, 63], [47, 64], [47, 65], [47, 67], [47, 72], [47, 73], [47, 75], [47, 76], [47, 77], [47, 78], [47, 80], [47, 81], [47, 82], [47, 86], [47, 88], [47, 89], [47, 91], [47, 96], [47, 97], [47, 98], [48, 50], [48, 52], [48, 53], [48, 54], [48, 55], [48, 58], [48, 59], [48, 60], [48, 61], [48, 62], [48, 63], [48, 64], [48, 65], [48, 66], [48, 67], [48, 71], [48, 72], [48, 73], [48, 76], [48, 79], [48, 81], [48, 87], [48, 89], [48, 90], [48, 91], [48, 95], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [49, 59], [49, 61], [49, 63], [49, 64], [49, 68], [49, 70], [49, 74], [49, 75], [49, 76], [49, 77], [49, 78], [49, 79], [49, 83], [49, 87], [49, 90], [49, 94], [49, 97], [50, 52], [50, 53], [50, 57], [50, 58], [50, 60], [50, 62], [50, 65], [50, 71], [50, 72], [50, 74], [50, 75], [50, 76], [50, 77], [50, 78], [50, 81], [50, 82], [50, 87], [50, 89], [50, 90], [50, 92], [50, 93], [50, 96], [50, 97], [50, 98], [50, 99], [51, 53], [51, 54], [51, 55], [51, 57], [51, 61], [51, 62], [51, 64], [51, 65], [51, 66], [51, 67], [51, 71], [51, 73], [51, 75], [51, 76], [51, 81], [51, 82], [51, 83], [51, 85], [51, 86], [51, 87], [51, 90], [51, 91], [51, 92], [51, 93], [51, 94], [51, 96], [51, 99], [52, 53], [52, 54], [52, 58], [52, 61], [52, 62], [52, 64], [52, 66], [52, 68], [52, 70], [52, 72], [52, 73], [52, 74], [52, 75], [52, 76], [52, 78], [52, 79], [52, 83], [52, 85], [52, 90], [52, 92], [52, 93], [52, 94], [52, 95], [53, 54], [53, 55], [53, 56], [53, 57], [53, 61], [53, 62], [53, 63], [53, 67], [53, 68], [53, 69], [53, 70], [53, 74], [53, 75], [53, 76], [53, 79], [53, 80], [53, 81], [53, 82], [53, 83], [53, 84], [53, 86], [53, 87], [53, 88], [53, 89], [53, 91], [53, 92], [53, 94], [53, 96], [53, 97], [53, 99], [54, 57], [54, 58], [54, 59], [54, 60], [54, 61], [54, 63], [54, 65], [54, 68], [54, 69], [54, 72], [54, 73], [54, 74], [54, 75], [54, 76], [54, 77], [54, 81], [54, 82], [54, 83], [54, 85], [54, 86], [54, 87], [54, 88], [54, 91], [54, 93], [54, 94], [54, 95], [54, 96], [54, 98], [54, 99], [55, 57], [55, 58], [55, 64], [55, 65], [55, 66], [55, 67], [55, 68], [55, 69], [55, 73], [55, 76], [55, 78], [55, 80], [55, 84], [55, 87], [55, 88], [55, 91], [55, 98], [56, 57], [56, 58], [56, 63], [56, 65], [56, 67], [56, 68], [56, 69], [56, 71], [56, 74], [56, 76], [56, 77], [56, 78], [56, 79], [56, 80], [56, 81], [56, 82], [56, 85], [56, 86], [56, 87], [56, 88], [56, 89], [56, 91], [56, 93], [56, 95], [56, 97], [56, 98], [57, 58], [57, 64], [57, 65], [57, 66], [57, 67], [57, 74], [57, 75], [57, 76], [57, 77], [57, 79], [57, 80], [57, 81], [57, 82], [57, 83], [57, 85], [57, 88], [57, 89], [57, 90], [57, 92], [57, 94], [57, 96], [57, 97], [57, 98], [58, 59], [58, 60], [58, 63], [58, 64], [58, 67], [58, 69], [58, 71], [58, 73], [58, 74], [58, 75], [58, 78], [58, 79], [58, 80], [58, 86], [58, 87], [58, 89], [58, 92], [58, 96], [58, 97], [58, 98], [58, 99], [59, 60], [59, 61], [59, 62], [59, 65], [59, 66], [59, 68], [59, 69], [59, 70], [59, 71], [59, 73], [59, 75], [59, 78], [59, 81], [59, 85], [59, 88], [59, 98], [59, 99], [60, 65], [60, 66], [60, 69], [60, 70], [60, 71], [60, 74], [60, 75], [60, 76], [60, 78], [60, 80], [60, 81], [60, 82], [60, 83], [60, 84], [60, 85], [60, 90], [60, 93], [60, 94], [60, 96], [60, 98], [60, 99], [61, 62], [61, 66], [61, 68], [61, 69], [61, 70], [61, 71], [61, 77], [61, 78], [61, 80], [61, 88], [61, 90], [61, 91], [61, 93], [61, 97], [61, 98], [61, 99], [62, 63], [62, 66], [62, 67], [62, 70], [62, 73], [62, 74], [62, 75], [62, 76], [62, 77], [62, 78], [62, 79], [62, 80], [62, 81], [62, 82], [62, 83], [62, 84], [62, 85], [62, 89], [62, 90], [62, 92], [62, 94], [62, 97], [63, 64], [63, 65], [63, 66], [63, 67], [63, 68], [63, 69], [63, 71], [63, 74], [63, 77], [63, 78], [63, 80], [63, 81], [63, 86], [63, 88], [63, 89], [63, 91], [63, 94], [63, 96], [63, 97], [63, 98], [63, 99], [64, 68], [64, 69], [64, 70], [64, 74], [64, 75], [64, 76], [64, 79], [64, 82], [64, 84], [64, 85], [64, 86], [64, 89], [64, 90], [64, 93], [64, 94], [64, 95], [64, 96], [64, 98], [65, 68], [65, 69], [65, 70], [65, 71], [65, 77], [65, 80], [65, 81], [65, 82], [65, 83], [65, 84], [65, 85], [65, 86], [65, 87], [65, 90], [65, 91], [65, 93], [65, 94], [65, 97], [65, 98], [65, 99], [66, 67], [66, 68], [66, 72], [66, 75], [66, 76], [66, 80], [66, 81], [66, 82], [66, 85], [66, 88], [66, 89], [66, 90], [66, 91], [66, 93], [66, 94], [66, 95], [66, 96], [66, 99], [67, 69], [67, 70], [67, 71], [67, 73], [67, 75], [67, 76], [67, 80], [67, 84], [67, 88], [67, 94], [67, 96], [67, 97], [67, 98], [68, 69], [68, 70], [68, 73], [68, 79], [68, 80], [68, 82], [68, 83], [68, 84], [68, 85], [68, 87], [68, 90], [68, 91], [68, 93], [68, 94], [68, 97], [69, 71], [69, 72], [69, 73], [69, 76], [69, 77], [69, 78], [69, 83], [69, 85], [69, 87], [69, 88], [69, 90], [69, 91], [69, 92], [69, 99], [70, 72], [70, 74], [70, 75], [70, 77], [70, 78], [70, 81], [70, 82], [70, 83], [70, 84], [70, 86], [70, 87], [70, 89], [70, 93], [70, 96], [70, 97], [70, 98], [71, 72], [71, 73], [71, 74], [71, 75], [71, 76], [71, 77], [71, 78], [71, 81], [71, 83], [71, 84], [71, 86], [71, 89], [71, 91], [71, 92], [71, 93], [71, 95], [71, 96], [71, 97], [71, 98], [72, 78], [72, 80], [72, 81], [72, 82], [72, 85], [72, 87], [72, 88], [72, 92], [72, 93], [72, 94], [72, 96], [72, 98], [73, 76], [73, 77], [73, 78], [73, 80], [73, 81], [73, 86], [73, 91], [73, 92], [73, 93], [73, 94], [73, 97], [73, 98], [74, 75], [74, 76], [74, 77], [74, 79], [74, 80], [74, 82], [74, 86], [74, 88], [74, 93], [74, 95], [74, 96], [74, 97], [74, 98], [75, 78], [75, 81], [75, 82], [75, 85], [75, 86], [75, 88], [75, 90], [75, 97], [75, 99], [76, 81], [76, 82], [76, 84], [76, 86], [76, 87], [76, 89], [76, 90], [76, 91], [76, 93], [76, 94], [76, 97], [76, 99], [77, 80], [77, 81], [77, 82], [77, 86], [77, 87], [77, 89], [77, 90], [77, 91], [77, 94], [77, 95], [77, 97], [77, 98], [77, 99], [78, 79], [78, 84], [78, 90], [78, 91], [78, 93], [78, 96], [78, 97], [78, 98], [79, 80], [79, 82], [79, 83], [79, 84], [79, 86], [79, 87], [79, 88], [79, 91], [79, 92], [79, 93], [79, 95], [79, 96], [79, 97], [79, 99], [80, 81], [80, 82], [80, 83], [80, 85], [80, 86], [80, 87], [80, 89], [80, 91], [80, 92], [80, 94], [80, 95], [80, 97], [80, 98], [80, 99], [81, 84], [81, 86], [81, 88], [81, 89], [81, 90], [81, 91], [81, 92], [81, 93], [81, 95], [81, 97], [81, 98], [82, 83], [82, 85], [82, 86], [82, 87], [82, 89], [82, 92], [82, 94], [82, 95], [82, 97], [82, 98], [82, 99], [83, 84], [83, 86], [83, 87], [83, 91], [83, 93], [83, 94], [83, 96], [83, 97], [83, 99], [84, 85], [84, 88], [84, 89], [84, 91], [84, 92], [84, 93], [84, 97], [84, 98], [85, 86], [85, 87], [85, 88], [85, 89], [85, 91], [85, 92], [85, 95], [85, 96], [86, 88], [86, 89], [86, 90], [86, 91], [86, 92], [86, 93], [86, 94], [86, 97], [86, 98], [87, 88], [87, 89], [87, 90], [87, 91], [87, 92], [87, 93], [87, 94], [87, 95], [87, 96], [87, 97], [87, 98], [87, 99], [88, 91], [88, 92], [88, 95], [88, 96], [88, 98], [89, 91], [89, 96], [89, 97], [89, 98], [89, 99], [90, 92], [90, 94], [90, 95], [90, 97], [90, 99], [91, 92], [91, 93], [91, 94], [91, 95], [91, 96], [91, 97], [91, 98], [92, 94], [92, 95], [92, 97], [94, 98], [94, 99], [95, 96], [95, 99], [97, 98]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s2/solution/solve.sh b/tasks/construct-nppc-clique-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6082494fcc8820b78df63241efe0620a277d7339 --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [1, 5, 7, 12, 26, 29, 35, 36, 38, 47, 56, 63, 65, 77, 80, 81, 86, 91, 97, 98]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s2/tests/check.py b/tasks/construct-nppc-clique-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s2/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l6-s2/tests/instance.json b/tasks/construct-nppc-clique-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3863a3a6a7fdc4ace47d1b85fe096d82b7d4ebb6 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 15], [0, 16], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 36], [0, 38], [0, 40], [0, 42], [0, 44], [0, 46], [0, 47], [0, 48], [0, 49], [0, 51], [0, 52], [0, 56], [0, 58], [0, 59], [0, 62], [0, 65], [0, 66], [0, 67], [0, 74], [0, 76], [0, 79], [0, 82], [0, 85], [0, 89], [0, 93], [0, 94], [0, 95], [0, 98], [0, 99], [1, 3], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 23], [1, 24], [1, 26], [1, 27], [1, 28], [1, 29], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 38], [1, 42], [1, 43], [1, 47], [1, 48], [1, 50], [1, 51], [1, 56], [1, 59], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 68], [1, 69], [1, 70], [1, 71], [1, 77], [1, 78], [1, 79], [1, 80], [1, 81], [1, 82], [1, 84], [1, 85], [1, 86], [1, 87], [1, 91], [1, 93], [1, 94], [1, 95], [1, 96], [1, 97], [1, 98], [1, 99], [2, 3], [2, 4], [2, 5], [2, 10], [2, 11], [2, 14], [2, 16], [2, 20], [2, 22], [2, 27], [2, 30], [2, 32], [2, 33], [2, 36], [2, 41], [2, 42], [2, 43], [2, 45], [2, 48], [2, 54], [2, 55], [2, 57], [2, 59], [2, 61], [2, 62], [2, 66], [2, 67], [2, 68], [2, 69], [2, 70], [2, 71], [2, 74], [2, 77], [2, 78], [2, 79], [2, 80], [2, 83], [2, 84], [2, 85], [2, 87], [2, 89], [2, 92], [2, 94], [2, 95], [2, 97], [3, 5], [3, 6], [3, 10], [3, 12], [3, 19], [3, 20], [3, 21], [3, 23], [3, 24], [3, 26], [3, 27], [3, 32], [3, 34], [3, 36], [3, 39], [3, 41], [3, 43], [3, 46], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 58], [3, 60], [3, 62], [3, 63], [3, 64], [3, 65], [3, 68], [3, 69], [3, 72], [3, 73], [3, 75], [3, 81], [3, 82], [3, 84], [3, 87], [3, 88], [3, 90], [3, 91], [3, 97], [4, 7], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 18], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 30], [4, 31], [4, 33], [4, 34], [4, 38], [4, 40], [4, 41], [4, 43], [4, 44], [4, 45], [4, 46], [4, 48], [4, 50], [4, 51], [4, 53], [4, 57], [4, 60], [4, 65], [4, 66], [4, 68], [4, 69], [4, 70], [4, 72], [4, 73], [4, 74], [4, 76], [4, 77], [4, 79], [4, 81], [4, 82], [4, 86], [4, 87], [4, 88], [4, 90], [4, 93], [4, 97], [4, 98], [5, 7], [5, 8], [5, 10], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 21], [5, 25], [5, 26], [5, 28], [5, 29], [5, 30], [5, 35], [5, 36], [5, 38], [5, 41], [5, 42], [5, 44], [5, 45], [5, 46], [5, 47], [5, 48], [5, 49], [5, 51], [5, 52], [5, 54], [5, 55], [5, 56], [5, 59], [5, 60], [5, 62], [5, 63], [5, 64], [5, 65], [5, 67], [5, 68], [5, 69], [5, 71], [5, 72], [5, 77], [5, 79], [5, 80], [5, 81], [5, 82], [5, 83], [5, 84], [5, 86], [5, 91], [5, 95], [5, 97], [5, 98], [6, 9], [6, 10], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 22], [6, 24], [6, 25], [6, 29], [6, 35], [6, 36], [6, 39], [6, 40], [6, 41], [6, 44], [6, 45], [6, 48], [6, 49], [6, 52], [6, 53], [6, 54], [6, 55], [6, 58], [6, 59], [6, 60], [6, 61], [6, 62], [6, 63], [6, 64], [6, 66], [6, 72], [6, 77], [6, 79], [6, 80], [6, 81], [6, 83], [6, 84], [6, 90], [6, 94], [6, 99], [7, 8], [7, 10], [7, 12], [7, 13], [7, 16], [7, 17], [7, 18], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 35], [7, 36], [7, 37], [7, 38], [7, 40], [7, 41], [7, 42], [7, 45], [7, 47], [7, 48], [7, 51], [7, 56], [7, 59], [7, 61], [7, 62], [7, 63], [7, 64], [7, 65], [7, 66], [7, 67], [7, 68], [7, 69], [7, 70], [7, 71], [7, 72], [7, 73], [7, 74], [7, 76], [7, 77], [7, 78], [7, 80], [7, 81], [7, 83], [7, 84], [7, 85], [7, 86], [7, 87], [7, 91], [7, 95], [7, 97], [7, 98], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 24], [8, 26], [8, 27], [8, 28], [8, 31], [8, 32], [8, 33], [8, 34], [8, 36], [8, 37], [8, 40], [8, 41], [8, 43], [8, 44], [8, 47], [8, 49], [8, 50], [8, 52], [8, 55], [8, 57], [8, 58], [8, 63], [8, 64], [8, 65], [8, 66], [8, 67], [8, 69], [8, 71], [8, 74], [8, 75], [8, 76], [8, 79], [8, 81], [8, 82], [8, 85], [8, 89], [8, 94], [8, 95], [8, 96], [8, 99], [9, 16], [9, 18], [9, 21], [9, 22], [9, 23], [9, 27], [9, 31], [9, 33], [9, 34], [9, 35], [9, 36], [9, 45], [9, 46], [9, 47], [9, 50], [9, 52], [9, 59], [9, 62], [9, 63], [9, 64], [9, 65], [9, 67], [9, 69], [9, 74], [9, 76], [9, 77], [9, 79], [9, 80], [9, 81], [9, 82], [9, 83], [9, 85], [9, 86], [9, 87], [9, 88], [9, 89], [9, 92], [9, 94], [9, 96], [9, 97], [9, 98], [9, 99], [10, 11], [10, 14], [10, 16], [10, 17], [10, 19], [10, 23], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 32], [10, 33], [10, 35], [10, 37], [10, 40], [10, 42], [10, 43], [10, 44], [10, 49], [10, 51], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 61], [10, 66], [10, 67], [10, 68], [10, 69], [10, 70], [10, 71], [10, 73], [10, 74], [10, 75], [10, 76], [10, 79], [10, 82], [10, 84], [10, 85], [10, 87], [10, 89], [10, 90], [10, 91], [10, 96], [10, 97], [11, 14], [11, 15], [11, 17], [11, 18], [11, 19], [11, 22], [11, 24], [11, 25], [11, 28], [11, 30], [11, 32], [11, 33], [11, 34], [11, 36], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 44], [11, 45], [11, 46], [11, 48], [11, 49], [11, 50], [11, 55], [11, 58], [11, 65], [11, 66], [11, 67], [11, 68], [11, 69], [11, 70], [11, 72], [11, 76], [11, 78], [11, 82], [11, 84], [11, 85], [11, 88], [11, 92], [11, 93], [11, 95], [11, 96], [11, 98], [11, 99], [12, 13], [12, 15], [12, 18], [12, 19], [12, 23], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 31], [12, 32], [12, 35], [12, 36], [12, 38], [12, 40], [12, 41], [12, 43], [12, 44], [12, 45], [12, 47], [12, 48], [12, 49], [12, 50], [12, 53], [12, 55], [12, 56], [12, 57], [12, 58], [12, 59], [12, 60], [12, 61], [12, 62], [12, 63], [12, 65], [12, 68], [12, 70], [12, 72], [12, 73], [12, 74], [12, 76], [12, 77], [12, 78], [12, 80], [12, 81], [12, 86], [12, 87], [12, 90], [12, 91], [12, 92], [12, 95], [12, 96], [12, 97], [12, 98], [12, 99], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 33], [13, 35], [13, 36], [13, 38], [13, 39], [13, 40], [13, 41], [13, 47], [13, 51], [13, 53], [13, 54], [13, 57], [13, 59], [13, 60], [13, 62], [13, 63], [13, 64], [13, 65], [13, 70], [13, 72], [13, 74], [13, 75], [13, 80], [13, 81], [13, 82], [13, 83], [13, 84], [13, 88], [13, 90], [13, 91], [13, 95], [14, 15], [14, 18], [14, 19], [14, 21], [14, 23], [14, 25], [14, 29], [14, 30], [14, 32], [14, 34], [14, 36], [14, 37], [14, 39], [14, 41], [14, 42], [14, 43], [14, 45], [14, 46], [14, 47], [14, 48], [14, 51], [14, 53], [14, 55], [14, 58], [14, 62], [14, 65], [14, 66], [14, 78], [14, 79], [14, 84], [14, 85], [14, 87], [14, 88], [14, 89], [14, 92], [14, 93], [14, 96], [14, 97], [15, 17], [15, 18], [15, 19], [15, 20], [15, 25], [15, 26], [15, 29], [15, 30], [15, 32], [15, 34], [15, 35], [15, 37], [15, 41], [15, 42], [15, 43], [15, 44], [15, 47], [15, 49], [15, 51], [15, 52], [15, 57], [15, 63], [15, 64], [15, 68], [15, 70], [15, 72], [15, 73], [15, 74], [15, 80], [15, 81], [15, 83], [15, 85], [15, 87], [15, 88], [15, 94], [16, 17], [16, 19], [16, 20], [16, 22], [16, 29], [16, 30], [16, 31], [16, 34], [16, 36], [16, 38], [16, 40], [16, 43], [16, 44], [16, 45], [16, 47], [16, 48], [16, 50], [16, 51], [16, 54], [16, 55], [16, 60], [16, 61], [16, 62], [16, 63], [16, 64], [16, 65], [16, 67], [16, 68], [16, 71], [16, 75], [16, 76], [16, 77], [16, 78], [16, 81], [16, 83], [16, 85], [16, 86], [16, 91], [16, 93], [16, 94], [16, 95], [16, 97], [17, 19], [17, 23], [17, 28], [17, 32], [17, 34], [17, 37], [17, 44], [17, 45], [17, 46], [17, 47], [17, 48], [17, 52], [17, 56], [17, 57], [17, 60], [17, 61], [17, 63], [17, 65], [17, 67], [17, 69], [17, 71], [17, 72], [17, 74], [17, 75], [17, 76], [17, 78], [17, 79], [17, 82], [17, 85], [17, 88], [17, 89], [17, 91], [17, 92], [17, 93], [17, 94], [17, 97], [17, 98], [18, 19], [18, 21], [18, 23], [18, 29], [18, 35], [18, 38], [18, 40], [18, 41], [18, 42], [18, 44], [18, 45], [18, 47], [18, 48], [18, 49], [18, 52], [18, 53], [18, 54], [18, 55], [18, 57], [18, 58], [18, 59], [18, 61], [18, 65], [18, 68], [18, 70], [18, 71], [18, 72], [18, 76], [18, 78], [18, 79], [18, 82], [18, 84], [18, 86], [18, 90], [18, 91], [18, 92], [18, 97], [18, 98], [18, 99], [19, 22], [19, 24], [19, 26], [19, 27], [19, 28], [19, 31], [19, 38], [19, 39], [19, 45], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 52], [19, 54], [19, 56], [19, 59], [19, 61], [19, 62], [19, 63], [19, 64], [19, 66], [19, 67], [19, 68], [19, 69], [19, 72], [19, 74], [19, 75], [19, 76], [19, 77], [19, 78], [19, 81], [19, 82], [19, 84], [19, 85], [19, 86], [19, 88], [19, 89], [19, 90], [19, 91], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 36], [20, 37], [20, 38], [20, 39], [20, 41], [20, 42], [20, 44], [20, 45], [20, 46], [20, 47], [20, 50], [20, 52], [20, 57], [20, 58], [20, 59], [20, 67], [20, 72], [20, 73], [20, 75], [20, 77], [20, 81], [20, 82], [20, 83], [20, 84], [20, 87], [20, 88], [20, 89], [20, 91], [20, 92], [20, 93], [20, 97], [20, 98], [21, 27], [21, 29], [21, 31], [21, 33], [21, 36], [21, 38], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 46], [21, 47], [21, 49], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [21, 56], [21, 58], [21, 61], [21, 64], [21, 65], [21, 66], [21, 67], [21, 69], [21, 70], [21, 73], [21, 74], [21, 79], [21, 81], [21, 83], [21, 84], [21, 87], [21, 88], [21, 91], [21, 95], [22, 24], [22, 25], [22, 27], [22, 28], [22, 31], [22, 33], [22, 34], [22, 36], [22, 37], [22, 40], [22, 41], [22, 43], [22, 46], [22, 47], [22, 48], [22, 50], [22, 51], [22, 52], [22, 53], [22, 56], [22, 58], [22, 59], [22, 60], [22, 61], [22, 66], [22, 71], [22, 72], [22, 74], [22, 76], [22, 77], [22, 80], [22, 82], [22, 84], [22, 86], [22, 87], [22, 90], [22, 93], [22, 94], [22, 95], [23, 25], [23, 26], [23, 28], [23, 29], [23, 33], [23, 34], [23, 42], [23, 43], [23, 44], [23, 45], [23, 46], [23, 49], [23, 51], [23, 53], [23, 54], [23, 55], [23, 59], [23, 60], [23, 61], [23, 62], [23, 64], [23, 66], [23, 69], [23, 70], [23, 73], [23, 74], [23, 76], [23, 77], [23, 78], [23, 82], [23, 84], [23, 86], [23, 87], [23, 90], [23, 91], [23, 92], [23, 95], [23, 96], [23, 98], [23, 99], [24, 26], [24, 27], [24, 30], [24, 37], [24, 38], [24, 39], [24, 41], [24, 42], [24, 44], [24, 45], [24, 46], [24, 47], [24, 49], [24, 50], [24, 51], [24, 53], [24, 55], [24, 56], [24, 57], [24, 58], [24, 61], [24, 67], [24, 68], [24, 73], [24, 74], [24, 75], [24, 76], [24, 85], [24, 87], [24, 88], [24, 89], [24, 95], [24, 96], [24, 97], [24, 98], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 32], [25, 33], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 41], [25, 43], [25, 44], [25, 46], [25, 48], [25, 49], [25, 52], [25, 53], [25, 56], [25, 57], [25, 59], [25, 60], [25, 61], [25, 64], [25, 67], [25, 68], [25, 69], [25, 71], [25, 73], [25, 77], [25, 79], [25, 81], [25, 82], [25, 85], [25, 87], [25, 91], [25, 97], [25, 98], [26, 27], [26, 29], [26, 30], [26, 32], [26, 35], [26, 36], [26, 38], [26, 39], [26, 41], [26, 43], [26, 44], [26, 45], [26, 47], [26, 48], [26, 50], [26, 52], [26, 55], [26, 56], [26, 62], [26, 63], [26, 64], [26, 65], [26, 67], [26, 70], [26, 72], [26, 74], [26, 75], [26, 77], [26, 80], [26, 81], [26, 82], [26, 84], [26, 85], [26, 86], [26, 87], [26, 89], [26, 90], [26, 91], [26, 92], [26, 95], [26, 97], [26, 98], [27, 28], [27, 29], [27, 30], [27, 31], [27, 36], [27, 37], [27, 40], [27, 42], [27, 43], [27, 44], [27, 45], [27, 47], [27, 51], [27, 56], [27, 58], [27, 59], [27, 60], [27, 61], [27, 67], [27, 68], [27, 69], [27, 72], [27, 77], [27, 80], [27, 81], [27, 83], [27, 86], [27, 87], [27, 88], [27, 89], [27, 91], [27, 92], [27, 93], [27, 94], [27, 95], [27, 97], [27, 98], [27, 99], [28, 31], [28, 35], [28, 37], [28, 39], [28, 40], [28, 46], [28, 48], [28, 49], [28, 53], [28, 58], [28, 59], [28, 64], [28, 67], [28, 70], [28, 71], [28, 82], [28, 84], [28, 88], [28, 90], [28, 91], [28, 92], [28, 93], [28, 94], [28, 95], [28, 98], [29, 30], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 41], [29, 42], [29, 43], [29, 44], [29, 45], [29, 47], [29, 49], [29, 51], [29, 54], [29, 56], [29, 63], [29, 64], [29, 65], [29, 69], [29, 71], [29, 74], [29, 75], [29, 76], [29, 77], [29, 80], [29, 81], [29, 83], [29, 85], [29, 86], [29, 87], [29, 88], [29, 89], [29, 91], [29, 94], [29, 95], [29, 97], [29, 98], [30, 31], [30, 33], [30, 34], [30, 37], [30, 38], [30, 39], [30, 40], [30, 42], [30, 43], [30, 48], [30, 50], [30, 51], [30, 53], [30, 56], [30, 59], [30, 60], [30, 61], [30, 70], [30, 72], [30, 74], [30, 77], [30, 78], [30, 81], [30, 82], [30, 85], [30, 86], [30, 88], [30, 89], [30, 91], [30, 93], [30, 94], [30, 97], [31, 32], [31, 35], [31, 39], [31, 42], [31, 43], [31, 47], [31, 54], [31, 55], [31, 56], [31, 58], [31, 59], [31, 65], [31, 67], [31, 68], [31, 70], [31, 72], [31, 73], [31, 75], [31, 76], [31, 78], [31, 80], [31, 83], [31, 84], [31, 85], [31, 87], [31, 88], [31, 89], [31, 90], [31, 91], [31, 92], [31, 96], [32, 34], [32, 36], [32, 37], [32, 39], [32, 42], [32, 45], [32, 46], [32, 51], [32, 56], [32, 57], [32, 58], [32, 59], [32, 61], [32, 62], [32, 64], [32, 65], [32, 67], [32, 69], [32, 70], [32, 71], [32, 73], [32, 75], [32, 78], [32, 79], [32, 80], [32, 82], [32, 83], [32, 86], [32, 87], [32, 88], [32, 90], [32, 94], [32, 95], [32, 96], [32, 98], [32, 99], [33, 34], [33, 35], [33, 39], [33, 40], [33, 41], [33, 42], [33, 43], [33, 44], [33, 45], [33, 46], [33, 47], [33, 50], [33, 51], [33, 52], [33, 53], [33, 54], [33, 56], [33, 60], [33, 61], [33, 62], [33, 63], [33, 64], [33, 68], [33, 69], [33, 73], [33, 75], [33, 77], [33, 78], [33, 83], [33, 84], [33, 87], [33, 89], [33, 90], [33, 92], [33, 93], [33, 94], [33, 95], [33, 97], [34, 35], [34, 36], [34, 37], [34, 40], [34, 42], [34, 43], [34, 44], [34, 45], [34, 47], [34, 48], [34, 50], [34, 56], [34, 57], [34, 59], [34, 62], [34, 64], [34, 66], [34, 72], [34, 73], [34, 77], [34, 78], [34, 81], [34, 83], [34, 86], [34, 89], [34, 91], [34, 92], [34, 96], [34, 97], [34, 98], [35, 36], [35, 37], [35, 38], [35, 39], [35, 41], [35, 43], [35, 44], [35, 45], [35, 47], [35, 49], [35, 51], [35, 52], [35, 53], [35, 54], [35, 55], [35, 56], [35, 60], [35, 61], [35, 63], [35, 64], [35, 65], [35, 68], [35, 69], [35, 70], [35, 72], [35, 75], [35, 76], [35, 77], [35, 78], [35, 79], [35, 80], [35, 81], [35, 83], [35, 84], [35, 86], [35, 88], [35, 89], [35, 91], [35, 92], [35, 95], [35, 97], [35, 98], [36, 37], [36, 38], [36, 42], [36, 45], [36, 47], [36, 48], [36, 49], [36, 51], [36, 52], [36, 56], [36, 58], [36, 59], [36, 60], [36, 63], [36, 64], [36, 65], [36, 66], [36, 68], [36, 74], [36, 76], [36, 77], [36, 78], [36, 79], [36, 80], [36, 81], [36, 82], [36, 83], [36, 85], [36, 86], [36, 87], [36, 88], [36, 91], [36, 97], [36, 98], [36, 99], [37, 41], [37, 42], [37, 44], [37, 46], [37, 47], [37, 51], [37, 53], [37, 59], [37, 60], [37, 61], [37, 64], [37, 66], [37, 67], [37, 69], [37, 70], [37, 71], [37, 72], [37, 74], [37, 75], [37, 76], [37, 79], [37, 82], [37, 83], [37, 84], [37, 85], [37, 90], [37, 93], [37, 94], [37, 95], [37, 96], [37, 97], [37, 98], [37, 99], [38, 39], [38, 40], [38, 46], [38, 47], [38, 48], [38, 49], [38, 51], [38, 53], [38, 54], [38, 56], [38, 57], [38, 58], [38, 60], [38, 63], [38, 65], [38, 67], [38, 69], [38, 70], [38, 74], [38, 76], [38, 77], [38, 79], [38, 80], [38, 81], [38, 82], [38, 83], [38, 85], [38, 86], [38, 88], [38, 89], [38, 91], [38, 92], [38, 94], [38, 95], [38, 97], [38, 98], [39, 45], [39, 46], [39, 47], [39, 50], [39, 51], [39, 52], [39, 54], [39, 55], [39, 57], [39, 58], [39, 62], [39, 63], [39, 64], [39, 68], [39, 71], [39, 73], [39, 74], [39, 76], [39, 77], [39, 78], [39, 80], [39, 82], [39, 85], [39, 87], [39, 88], [39, 89], [39, 94], [39, 95], [39, 96], [40, 41], [40, 42], [40, 44], [40, 45], [40, 46], [40, 51], [40, 58], [40, 59], [40, 60], [40, 61], [40, 68], [40, 70], [40, 83], [40, 84], [40, 88], [40, 94], [40, 95], [40, 97], [40, 99], [41, 43], [41, 44], [41, 46], [41, 47], [41, 51], [41, 54], [41, 56], [41, 59], [41, 61], [41, 62], [41, 63], [41, 71], [41, 72], [41, 73], [41, 75], [41, 77], [41, 79], [41, 83], [41, 87], [41, 88], [41, 91], [41, 93], [41, 95], [41, 96], [41, 98], [42, 44], [42, 46], [42, 48], [42, 49], [42, 51], [42, 52], [42, 53], [42, 58], [42, 59], [42, 60], [42, 61], [42, 62], [42, 63], [42, 68], [42, 69], [42, 70], [42, 71], [42, 73], [42, 74], [42, 78], [42, 79], [42, 81], [42, 83], [42, 85], [42, 87], [42, 88], [42, 93], [42, 96], [42, 99], [43, 50], [43, 51], [43, 58], [43, 59], [43, 61], [43, 64], [43, 66], [43, 71], [43, 72], [43, 73], [43, 75], [43, 79], [43, 80], [43, 81], [43, 82], [43, 84], [43, 86], [43, 89], [43, 90], [43, 91], [43, 98], [44, 46], [44, 47], [44, 50], [44, 51], [44, 52], [44, 56], [44, 57], [44, 59], [44, 61], [44, 62], [44, 63], [44, 64], [44, 66], [44, 67], [44, 69], [44, 70], [44, 72], [44, 75], [44, 76], [44, 79], [44, 80], [44, 83], [44, 85], [44, 88], [44, 90], [44, 91], [44, 92], [44, 96], [44, 97], [44, 98], [45, 49], [45, 50], [45, 53], [45, 54], [45, 55], [45, 57], [45, 58], [45, 59], [45, 60], [45, 61], [45, 62], [45, 64], [45, 67], [45, 72], [45, 74], [45, 76], [45, 79], [45, 80], [45, 82], [45, 85], [45, 86], [45, 88], [45, 89], [45, 91], [45, 92], [46, 48], [46, 52], [46, 54], [46, 56], [46, 58], [46, 59], [46, 60], [46, 62], [46, 63], [46, 65], [46, 66], [46, 67], [46, 68], [46, 71], [46, 72], [46, 76], [46, 80], [46, 81], [46, 84], [46, 85], [46, 86], [46, 87], [46, 88], [46, 90], [46, 91], [46, 92], [46, 93], [46, 94], [46, 96], [46, 98], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 55], [47, 56], [47, 57], [47, 62], [47, 63], [47, 64], [47, 65], [47, 67], [47, 72], [47, 73], [47, 75], [47, 76], [47, 77], [47, 78], [47, 80], [47, 81], [47, 82], [47, 86], [47, 88], [47, 89], [47, 91], [47, 96], [47, 97], [47, 98], [48, 50], [48, 52], [48, 53], [48, 54], [48, 55], [48, 58], [48, 59], [48, 60], [48, 61], [48, 62], [48, 63], [48, 64], [48, 65], [48, 66], [48, 67], [48, 71], [48, 72], [48, 73], [48, 76], [48, 79], [48, 81], [48, 87], [48, 89], [48, 90], [48, 91], [48, 95], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [49, 59], [49, 61], [49, 63], [49, 64], [49, 68], [49, 70], [49, 74], [49, 75], [49, 76], [49, 77], [49, 78], [49, 79], [49, 83], [49, 87], [49, 90], [49, 94], [49, 97], [50, 52], [50, 53], [50, 57], [50, 58], [50, 60], [50, 62], [50, 65], [50, 71], [50, 72], [50, 74], [50, 75], [50, 76], [50, 77], [50, 78], [50, 81], [50, 82], [50, 87], [50, 89], [50, 90], [50, 92], [50, 93], [50, 96], [50, 97], [50, 98], [50, 99], [51, 53], [51, 54], [51, 55], [51, 57], [51, 61], [51, 62], [51, 64], [51, 65], [51, 66], [51, 67], [51, 71], [51, 73], [51, 75], [51, 76], [51, 81], [51, 82], [51, 83], [51, 85], [51, 86], [51, 87], [51, 90], [51, 91], [51, 92], [51, 93], [51, 94], [51, 96], [51, 99], [52, 53], [52, 54], [52, 58], [52, 61], [52, 62], [52, 64], [52, 66], [52, 68], [52, 70], [52, 72], [52, 73], [52, 74], [52, 75], [52, 76], [52, 78], [52, 79], [52, 83], [52, 85], [52, 90], [52, 92], [52, 93], [52, 94], [52, 95], [53, 54], [53, 55], [53, 56], [53, 57], [53, 61], [53, 62], [53, 63], [53, 67], [53, 68], [53, 69], [53, 70], [53, 74], [53, 75], [53, 76], [53, 79], [53, 80], [53, 81], [53, 82], [53, 83], [53, 84], [53, 86], [53, 87], [53, 88], [53, 89], [53, 91], [53, 92], [53, 94], [53, 96], [53, 97], [53, 99], [54, 57], [54, 58], [54, 59], [54, 60], [54, 61], [54, 63], [54, 65], [54, 68], [54, 69], [54, 72], [54, 73], [54, 74], [54, 75], [54, 76], [54, 77], [54, 81], [54, 82], [54, 83], [54, 85], [54, 86], [54, 87], [54, 88], [54, 91], [54, 93], [54, 94], [54, 95], [54, 96], [54, 98], [54, 99], [55, 57], [55, 58], [55, 64], [55, 65], [55, 66], [55, 67], [55, 68], [55, 69], [55, 73], [55, 76], [55, 78], [55, 80], [55, 84], [55, 87], [55, 88], [55, 91], [55, 98], [56, 57], [56, 58], [56, 63], [56, 65], [56, 67], [56, 68], [56, 69], [56, 71], [56, 74], [56, 76], [56, 77], [56, 78], [56, 79], [56, 80], [56, 81], [56, 82], [56, 85], [56, 86], [56, 87], [56, 88], [56, 89], [56, 91], [56, 93], [56, 95], [56, 97], [56, 98], [57, 58], [57, 64], [57, 65], [57, 66], [57, 67], [57, 74], [57, 75], [57, 76], [57, 77], [57, 79], [57, 80], [57, 81], [57, 82], [57, 83], [57, 85], [57, 88], [57, 89], [57, 90], [57, 92], [57, 94], [57, 96], [57, 97], [57, 98], [58, 59], [58, 60], [58, 63], [58, 64], [58, 67], [58, 69], [58, 71], [58, 73], [58, 74], [58, 75], [58, 78], [58, 79], [58, 80], [58, 86], [58, 87], [58, 89], [58, 92], [58, 96], [58, 97], [58, 98], [58, 99], [59, 60], [59, 61], [59, 62], [59, 65], [59, 66], [59, 68], [59, 69], [59, 70], [59, 71], [59, 73], [59, 75], [59, 78], [59, 81], [59, 85], [59, 88], [59, 98], [59, 99], [60, 65], [60, 66], [60, 69], [60, 70], [60, 71], [60, 74], [60, 75], [60, 76], [60, 78], [60, 80], [60, 81], [60, 82], [60, 83], [60, 84], [60, 85], [60, 90], [60, 93], [60, 94], [60, 96], [60, 98], [60, 99], [61, 62], [61, 66], [61, 68], [61, 69], [61, 70], [61, 71], [61, 77], [61, 78], [61, 80], [61, 88], [61, 90], [61, 91], [61, 93], [61, 97], [61, 98], [61, 99], [62, 63], [62, 66], [62, 67], [62, 70], [62, 73], [62, 74], [62, 75], [62, 76], [62, 77], [62, 78], [62, 79], [62, 80], [62, 81], [62, 82], [62, 83], [62, 84], [62, 85], [62, 89], [62, 90], [62, 92], [62, 94], [62, 97], [63, 64], [63, 65], [63, 66], [63, 67], [63, 68], [63, 69], [63, 71], [63, 74], [63, 77], [63, 78], [63, 80], [63, 81], [63, 86], [63, 88], [63, 89], [63, 91], [63, 94], [63, 96], [63, 97], [63, 98], [63, 99], [64, 68], [64, 69], [64, 70], [64, 74], [64, 75], [64, 76], [64, 79], [64, 82], [64, 84], [64, 85], [64, 86], [64, 89], [64, 90], [64, 93], [64, 94], [64, 95], [64, 96], [64, 98], [65, 68], [65, 69], [65, 70], [65, 71], [65, 77], [65, 80], [65, 81], [65, 82], [65, 83], [65, 84], [65, 85], [65, 86], [65, 87], [65, 90], [65, 91], [65, 93], [65, 94], [65, 97], [65, 98], [65, 99], [66, 67], [66, 68], [66, 72], [66, 75], [66, 76], [66, 80], [66, 81], [66, 82], [66, 85], [66, 88], [66, 89], [66, 90], [66, 91], [66, 93], [66, 94], [66, 95], [66, 96], [66, 99], [67, 69], [67, 70], [67, 71], [67, 73], [67, 75], [67, 76], [67, 80], [67, 84], [67, 88], [67, 94], [67, 96], [67, 97], [67, 98], [68, 69], [68, 70], [68, 73], [68, 79], [68, 80], [68, 82], [68, 83], [68, 84], [68, 85], [68, 87], [68, 90], [68, 91], [68, 93], [68, 94], [68, 97], [69, 71], [69, 72], [69, 73], [69, 76], [69, 77], [69, 78], [69, 83], [69, 85], [69, 87], [69, 88], [69, 90], [69, 91], [69, 92], [69, 99], [70, 72], [70, 74], [70, 75], [70, 77], [70, 78], [70, 81], [70, 82], [70, 83], [70, 84], [70, 86], [70, 87], [70, 89], [70, 93], [70, 96], [70, 97], [70, 98], [71, 72], [71, 73], [71, 74], [71, 75], [71, 76], [71, 77], [71, 78], [71, 81], [71, 83], [71, 84], [71, 86], [71, 89], [71, 91], [71, 92], [71, 93], [71, 95], [71, 96], [71, 97], [71, 98], [72, 78], [72, 80], [72, 81], [72, 82], [72, 85], [72, 87], [72, 88], [72, 92], [72, 93], [72, 94], [72, 96], [72, 98], [73, 76], [73, 77], [73, 78], [73, 80], [73, 81], [73, 86], [73, 91], [73, 92], [73, 93], [73, 94], [73, 97], [73, 98], [74, 75], [74, 76], [74, 77], [74, 79], [74, 80], [74, 82], [74, 86], [74, 88], [74, 93], [74, 95], [74, 96], [74, 97], [74, 98], [75, 78], [75, 81], [75, 82], [75, 85], [75, 86], [75, 88], [75, 90], [75, 97], [75, 99], [76, 81], [76, 82], [76, 84], [76, 86], [76, 87], [76, 89], [76, 90], [76, 91], [76, 93], [76, 94], [76, 97], [76, 99], [77, 80], [77, 81], [77, 82], [77, 86], [77, 87], [77, 89], [77, 90], [77, 91], [77, 94], [77, 95], [77, 97], [77, 98], [77, 99], [78, 79], [78, 84], [78, 90], [78, 91], [78, 93], [78, 96], [78, 97], [78, 98], [79, 80], [79, 82], [79, 83], [79, 84], [79, 86], [79, 87], [79, 88], [79, 91], [79, 92], [79, 93], [79, 95], [79, 96], [79, 97], [79, 99], [80, 81], [80, 82], [80, 83], [80, 85], [80, 86], [80, 87], [80, 89], [80, 91], [80, 92], [80, 94], [80, 95], [80, 97], [80, 98], [80, 99], [81, 84], [81, 86], [81, 88], [81, 89], [81, 90], [81, 91], [81, 92], [81, 93], [81, 95], [81, 97], [81, 98], [82, 83], [82, 85], [82, 86], [82, 87], [82, 89], [82, 92], [82, 94], [82, 95], [82, 97], [82, 98], [82, 99], [83, 84], [83, 86], [83, 87], [83, 91], [83, 93], [83, 94], [83, 96], [83, 97], [83, 99], [84, 85], [84, 88], [84, 89], [84, 91], [84, 92], [84, 93], [84, 97], [84, 98], [85, 86], [85, 87], [85, 88], [85, 89], [85, 91], [85, 92], [85, 95], [85, 96], [86, 88], [86, 89], [86, 90], [86, 91], [86, 92], [86, 93], [86, 94], [86, 97], [86, 98], [87, 88], [87, 89], [87, 90], [87, 91], [87, 92], [87, 93], [87, 94], [87, 95], [87, 96], [87, 97], [87, 98], [87, 99], [88, 91], [88, 92], [88, 95], [88, 96], [88, 98], [89, 91], [89, 96], [89, 97], [89, 98], [89, 99], [90, 92], [90, 94], [90, 95], [90, 97], [90, 99], [91, 92], [91, 93], [91, 94], [91, 95], [91, 96], [91, 97], [91, 98], [92, 94], [92, 95], [92, 97], [94, 98], [94, 99], [95, 96], [95, 99], [97, 98]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s2/tests/run.py b/tasks/construct-nppc-clique-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s2/tests/test.sh b/tasks/construct-nppc-clique-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s5/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-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-nppc-clique-l6-s5/environment/instance.json b/tasks/construct-nppc-clique-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..62862e8c6a5e2341fadceeab810d223455b48152 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 5], [0, 6], [0, 7], [0, 11], [0, 15], [0, 16], [0, 17], [0, 18], [0, 25], [0, 29], [0, 30], [0, 33], [0, 37], [0, 38], [0, 39], [0, 42], [0, 44], [0, 46], [0, 47], [0, 53], [0, 54], [0, 56], [0, 58], [0, 59], [0, 62], [0, 63], [0, 64], [0, 65], [0, 68], [0, 69], [0, 75], [0, 76], [0, 77], [0, 78], [0, 81], [0, 82], [0, 83], [0, 84], [0, 86], [0, 88], [0, 89], [0, 90], [0, 91], [0, 93], [0, 95], [0, 96], [0, 98], [0, 99], [1, 3], [1, 6], [1, 9], [1, 13], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [1, 22], [1, 27], [1, 31], [1, 32], [1, 35], [1, 36], [1, 37], [1, 38], [1, 40], [1, 41], [1, 42], [1, 46], [1, 48], [1, 51], [1, 53], [1, 55], [1, 56], [1, 58], [1, 59], [1, 60], [1, 64], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 79], [1, 81], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 91], [1, 92], [1, 95], [1, 98], [2, 4], [2, 9], [2, 11], [2, 14], [2, 15], [2, 16], [2, 18], [2, 19], [2, 20], [2, 21], [2, 25], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 35], [2, 36], [2, 38], [2, 40], [2, 41], [2, 42], [2, 43], [2, 46], [2, 47], [2, 48], [2, 49], [2, 53], [2, 55], [2, 56], [2, 57], [2, 61], [2, 62], [2, 63], [2, 64], [2, 65], [2, 67], [2, 68], [2, 69], [2, 70], [2, 74], [2, 78], [2, 79], [2, 80], [2, 81], [2, 83], [2, 84], [2, 85], [2, 86], [2, 87], [2, 88], [2, 91], [2, 93], [2, 98], [3, 5], [3, 7], [3, 9], [3, 10], [3, 11], [3, 13], [3, 14], [3, 19], [3, 20], [3, 22], [3, 23], [3, 25], [3, 26], [3, 28], [3, 29], [3, 31], [3, 32], [3, 34], [3, 35], [3, 36], [3, 38], [3, 40], [3, 41], [3, 44], [3, 45], [3, 48], [3, 50], [3, 52], [3, 53], [3, 56], [3, 57], [3, 58], [3, 59], [3, 62], [3, 64], [3, 65], [3, 66], [3, 68], [3, 69], [3, 70], [3, 71], [3, 73], [3, 75], [3, 76], [3, 77], [3, 79], [3, 80], [3, 83], [3, 84], [3, 85], [3, 86], [3, 87], [3, 88], [3, 91], [3, 93], [3, 96], [3, 97], [4, 5], [4, 8], [4, 11], [4, 12], [4, 13], [4, 14], [4, 16], [4, 17], [4, 19], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 34], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 43], [4, 46], [4, 48], [4, 49], [4, 50], [4, 52], [4, 56], [4, 58], [4, 61], [4, 62], [4, 64], [4, 66], [4, 68], [4, 69], [4, 70], [4, 73], [4, 74], [4, 75], [4, 76], [4, 79], [4, 80], [4, 81], [4, 84], [4, 87], [4, 89], [4, 92], [4, 94], [4, 96], [4, 97], [4, 99], [5, 7], [5, 8], [5, 11], [5, 12], [5, 14], [5, 16], [5, 17], [5, 21], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 32], [5, 33], [5, 35], [5, 42], [5, 43], [5, 46], [5, 48], [5, 51], [5, 52], [5, 54], [5, 55], [5, 58], [5, 59], [5, 65], [5, 66], [5, 67], [5, 73], [5, 74], [5, 77], [5, 78], [5, 85], [5, 89], [5, 91], [5, 93], [5, 98], [6, 7], [6, 8], [6, 9], [6, 11], [6, 14], [6, 15], [6, 16], [6, 17], [6, 19], [6, 20], [6, 22], [6, 26], [6, 27], [6, 28], [6, 31], [6, 32], [6, 34], [6, 37], [6, 38], [6, 41], [6, 43], [6, 47], [6, 50], [6, 53], [6, 55], [6, 57], [6, 58], [6, 68], [6, 69], [6, 72], [6, 74], [6, 75], [6, 76], [6, 77], [6, 78], [6, 83], [6, 85], [6, 87], [6, 88], [6, 89], [6, 90], [6, 91], [6, 93], [6, 95], [6, 96], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [7, 15], [7, 17], [7, 19], [7, 20], [7, 21], [7, 22], [7, 25], [7, 26], [7, 27], [7, 28], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 39], [7, 40], [7, 41], [7, 42], [7, 43], [7, 44], [7, 45], [7, 47], [7, 48], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 57], [7, 59], [7, 61], [7, 62], [7, 65], [7, 67], [7, 68], [7, 70], [7, 73], [7, 75], [7, 77], [7, 78], [7, 79], [7, 84], [7, 86], [7, 87], [7, 88], [7, 90], [7, 91], [7, 96], [7, 99], [8, 10], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 25], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 36], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 48], [8, 50], [8, 51], [8, 52], [8, 54], [8, 56], [8, 60], [8, 61], [8, 62], [8, 63], [8, 66], [8, 67], [8, 68], [8, 69], [8, 70], [8, 72], [8, 73], [8, 76], [8, 78], [8, 80], [8, 82], [8, 83], [8, 85], [8, 86], [8, 87], [8, 88], [8, 89], [8, 95], [9, 14], [9, 17], [9, 18], [9, 19], [9, 21], [9, 23], [9, 26], [9, 27], [9, 29], [9, 31], [9, 32], [9, 34], [9, 35], [9, 37], [9, 39], [9, 41], [9, 46], [9, 47], [9, 48], [9, 55], [9, 58], [9, 59], [9, 60], [9, 61], [9, 62], [9, 65], [9, 66], [9, 67], [9, 72], [9, 73], [9, 75], [9, 77], [9, 81], [9, 83], [9, 87], [9, 89], [9, 91], [9, 92], [9, 95], [9, 97], [9, 99], [10, 11], [10, 12], [10, 14], [10, 19], [10, 20], [10, 21], [10, 22], [10, 27], [10, 28], [10, 33], [10, 35], [10, 36], [10, 38], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 50], [10, 52], [10, 54], [10, 55], [10, 58], [10, 59], [10, 60], [10, 61], [10, 62], [10, 64], [10, 66], [10, 68], [10, 70], [10, 71], [10, 72], [10, 73], [10, 81], [10, 82], [10, 85], [10, 86], [10, 87], [10, 88], [10, 89], [10, 90], [10, 91], [10, 94], [10, 96], [10, 97], [10, 98], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 26], [11, 30], [11, 34], [11, 39], [11, 40], [11, 41], [11, 48], [11, 50], [11, 51], [11, 52], [11, 56], [11, 58], [11, 59], [11, 61], [11, 63], [11, 64], [11, 66], [11, 67], [11, 69], [11, 70], [11, 71], [11, 72], [11, 74], [11, 75], [11, 76], [11, 77], [11, 78], [11, 79], [11, 81], [11, 84], [11, 85], [11, 86], [11, 92], [11, 93], [11, 94], [11, 98], [12, 15], [12, 16], [12, 17], [12, 19], [12, 20], [12, 22], [12, 23], [12, 25], [12, 26], [12, 31], [12, 34], [12, 35], [12, 36], [12, 37], [12, 41], [12, 43], [12, 44], [12, 45], [12, 49], [12, 50], [12, 53], [12, 54], [12, 55], [12, 58], [12, 60], [12, 61], [12, 63], [12, 65], [12, 66], [12, 68], [12, 69], [12, 70], [12, 71], [12, 72], [12, 73], [12, 74], [12, 76], [12, 80], [12, 85], [12, 87], [12, 89], [12, 92], [12, 93], [12, 96], [12, 98], [13, 14], [13, 21], [13, 22], [13, 23], [13, 24], [13, 27], [13, 32], [13, 39], [13, 40], [13, 44], [13, 45], [13, 46], [13, 52], [13, 53], [13, 54], [13, 57], [13, 65], [13, 68], [13, 71], [13, 72], [13, 73], [13, 74], [13, 75], [13, 81], [13, 84], [13, 85], [13, 86], [13, 87], [13, 88], [13, 89], [13, 90], [13, 92], [13, 93], [13, 94], [13, 97], [13, 98], [14, 15], [14, 16], [14, 18], [14, 20], [14, 21], [14, 23], [14, 26], [14, 27], [14, 29], [14, 30], [14, 31], [14, 32], [14, 35], [14, 36], [14, 37], [14, 38], [14, 40], [14, 41], [14, 42], [14, 44], [14, 45], [14, 46], [14, 48], [14, 51], [14, 52], [14, 54], [14, 55], [14, 57], [14, 59], [14, 61], [14, 64], [14, 72], [14, 73], [14, 74], [14, 76], [14, 80], [14, 81], [14, 84], [14, 85], [14, 86], [14, 94], [14, 95], [14, 98], [14, 99], [15, 16], [15, 17], [15, 19], [15, 21], [15, 27], [15, 28], [15, 29], [15, 37], [15, 42], [15, 44], [15, 48], [15, 49], [15, 51], [15, 54], [15, 55], [15, 57], [15, 61], [15, 62], [15, 63], [15, 65], [15, 66], [15, 71], [15, 75], [15, 77], [15, 79], [15, 81], [15, 82], [15, 85], [15, 86], [15, 87], [15, 90], [15, 94], [15, 98], [15, 99], [16, 19], [16, 21], [16, 22], [16, 23], [16, 27], [16, 28], [16, 31], [16, 35], [16, 38], [16, 39], [16, 43], [16, 49], [16, 51], [16, 54], [16, 55], [16, 56], [16, 57], [16, 59], [16, 60], [16, 63], [16, 64], [16, 65], [16, 66], [16, 68], [16, 69], [16, 70], [16, 73], [16, 77], [16, 78], [16, 79], [16, 80], [16, 82], [16, 85], [16, 86], [16, 87], [16, 89], [16, 92], [16, 93], [16, 94], [16, 97], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 27], [17, 28], [17, 29], [17, 31], [17, 32], [17, 36], [17, 39], [17, 45], [17, 46], [17, 49], [17, 51], [17, 52], [17, 53], [17, 54], [17, 55], [17, 58], [17, 61], [17, 62], [17, 63], [17, 67], [17, 68], [17, 69], [17, 71], [17, 72], [17, 74], [17, 78], [17, 80], [17, 82], [17, 83], [17, 84], [17, 85], [17, 86], [17, 89], [17, 90], [17, 93], [17, 95], [17, 96], [17, 98], [17, 99], [18, 22], [18, 23], [18, 24], [18, 27], [18, 29], [18, 31], [18, 33], [18, 35], [18, 38], [18, 40], [18, 41], [18, 43], [18, 44], [18, 46], [18, 49], [18, 51], [18, 53], [18, 55], [18, 58], [18, 59], [18, 60], [18, 61], [18, 62], [18, 63], [18, 64], [18, 68], [18, 69], [18, 70], [18, 71], [18, 73], [18, 75], [18, 76], [18, 78], [18, 81], [18, 82], [18, 83], [18, 84], [18, 90], [18, 91], [18, 93], [18, 94], [18, 95], [18, 98], [18, 99], [19, 20], [19, 21], [19, 22], [19, 25], [19, 27], [19, 28], [19, 33], [19, 34], [19, 35], [19, 36], [19, 38], [19, 42], [19, 43], [19, 44], [19, 45], [19, 49], [19, 50], [19, 52], [19, 54], [19, 57], [19, 59], [19, 60], [19, 61], [19, 62], [19, 63], [19, 67], [19, 68], [19, 69], [19, 70], [19, 71], [19, 72], [19, 73], [19, 74], [19, 75], [19, 76], [19, 77], [19, 81], [19, 85], [19, 86], [19, 87], [19, 88], [19, 90], [19, 91], [19, 92], [19, 94], [19, 95], [19, 97], [20, 21], [20, 23], [20, 24], [20, 25], [20, 27], [20, 29], [20, 33], [20, 37], [20, 41], [20, 43], [20, 45], [20, 49], [20, 50], [20, 51], [20, 52], [20, 54], [20, 57], [20, 65], [20, 66], [20, 68], [20, 69], [20, 70], [20, 72], [20, 73], [20, 79], [20, 83], [20, 85], [20, 87], [20, 89], [20, 90], [20, 91], [20, 93], [20, 95], [20, 96], [20, 98], [21, 23], [21, 25], [21, 28], [21, 29], [21, 31], [21, 40], [21, 43], [21, 45], [21, 47], [21, 48], [21, 50], [21, 52], [21, 55], [21, 59], [21, 60], [21, 61], [21, 62], [21, 63], [21, 64], [21, 68], [21, 70], [21, 72], [21, 76], [21, 77], [21, 78], [21, 79], [21, 80], [21, 82], [21, 84], [21, 85], [21, 86], [21, 87], [21, 89], [21, 91], [21, 92], [21, 93], [21, 96], [21, 99], [22, 24], [22, 25], [22, 29], [22, 31], [22, 33], [22, 35], [22, 39], [22, 43], [22, 44], [22, 49], [22, 52], [22, 53], [22, 54], [22, 60], [22, 63], [22, 64], [22, 65], [22, 68], [22, 70], [22, 71], [22, 73], [22, 74], [22, 75], [22, 76], [22, 81], [22, 82], [22, 85], [22, 88], [22, 90], [22, 91], [22, 92], [22, 95], [22, 97], [22, 98], [23, 26], [23, 28], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 46], [23, 47], [23, 49], [23, 50], [23, 51], [23, 54], [23, 55], [23, 56], [23, 59], [23, 60], [23, 63], [23, 64], [23, 65], [23, 68], [23, 70], [23, 72], [23, 73], [23, 76], [23, 77], [23, 78], [23, 80], [23, 86], [23, 88], [23, 90], [23, 92], [23, 93], [23, 98], [23, 99], [24, 25], [24, 29], [24, 31], [24, 33], [24, 34], [24, 35], [24, 36], [24, 38], [24, 39], [24, 41], [24, 42], [24, 43], [24, 44], [24, 46], [24, 47], [24, 51], [24, 52], [24, 53], [24, 55], [24, 58], [24, 62], [24, 63], [24, 64], [24, 66], [24, 67], [24, 69], [24, 72], [24, 75], [24, 76], [24, 78], [24, 79], [24, 80], [24, 83], [24, 84], [24, 85], [24, 86], [24, 90], [24, 92], [24, 94], [24, 96], [24, 97], [24, 99], [25, 29], [25, 32], [25, 36], [25, 39], [25, 41], [25, 42], [25, 43], [25, 44], [25, 48], [25, 49], [25, 50], [25, 51], [25, 53], [25, 55], [25, 57], [25, 58], [25, 60], [25, 61], [25, 64], [25, 66], [25, 69], [25, 71], [25, 72], [25, 74], [25, 76], [25, 77], [25, 79], [25, 80], [25, 82], [25, 85], [25, 89], [25, 90], [25, 91], [25, 92], [25, 93], [26, 27], [26, 28], [26, 29], [26, 31], [26, 32], [26, 33], [26, 35], [26, 36], [26, 37], [26, 44], [26, 45], [26, 46], [26, 49], [26, 50], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [26, 57], [26, 59], [26, 61], [26, 62], [26, 63], [26, 65], [26, 66], [26, 68], [26, 71], [26, 72], [26, 73], [26, 75], [26, 76], [26, 79], [26, 82], [26, 86], [26, 89], [26, 92], [26, 93], [26, 94], [26, 95], [26, 98], [26, 99], [27, 28], [27, 29], [27, 31], [27, 32], [27, 35], [27, 36], [27, 38], [27, 40], [27, 41], [27, 42], [27, 43], [27, 45], [27, 47], [27, 48], [27, 49], [27, 50], [27, 52], [27, 54], [27, 55], [27, 56], [27, 58], [27, 59], [27, 61], [27, 62], [27, 64], [27, 66], [27, 68], [27, 70], [27, 73], [27, 74], [27, 75], [27, 76], [27, 77], [27, 82], [27, 83], [27, 86], [27, 87], [27, 88], [27, 89], [27, 93], [27, 95], [27, 96], [27, 99], [28, 29], [28, 30], [28, 31], [28, 32], [28, 35], [28, 36], [28, 37], [28, 38], [28, 41], [28, 42], [28, 43], [28, 45], [28, 46], [28, 47], [28, 49], [28, 50], [28, 52], [28, 53], [28, 54], [28, 55], [28, 60], [28, 61], [28, 62], [28, 64], [28, 65], [28, 66], [28, 67], [28, 68], [28, 70], [28, 71], [28, 73], [28, 74], [28, 75], [28, 76], [28, 81], [28, 86], [28, 87], [28, 89], [28, 90], [28, 92], [28, 94], [28, 95], [28, 96], [28, 97], [29, 34], [29, 36], [29, 37], [29, 41], [29, 46], [29, 48], [29, 50], [29, 52], [29, 53], [29, 55], [29, 57], [29, 59], [29, 61], [29, 62], [29, 63], [29, 64], [29, 65], [29, 67], [29, 68], [29, 70], [29, 71], [29, 72], [29, 73], [29, 74], [29, 75], [29, 76], [29, 77], [29, 79], [29, 82], [29, 84], [29, 87], [29, 90], [29, 91], [29, 92], [29, 94], [29, 98], [29, 99], [30, 31], [30, 34], [30, 35], [30, 36], [30, 37], [30, 41], [30, 43], [30, 45], [30, 47], [30, 50], [30, 51], [30, 54], [30, 56], [30, 59], [30, 60], [30, 63], [30, 64], [30, 66], [30, 68], [30, 72], [30, 74], [30, 75], [30, 76], [30, 79], [30, 80], [30, 81], [30, 83], [30, 84], [30, 86], [30, 90], [30, 91], [30, 92], [30, 96], [30, 97], [30, 98], [31, 33], [31, 34], [31, 39], [31, 41], [31, 42], [31, 43], [31, 45], [31, 46], [31, 47], [31, 48], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [31, 59], [31, 60], [31, 61], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 70], [31, 74], [31, 79], [31, 84], [31, 85], [31, 86], [31, 87], [31, 89], [31, 91], [31, 92], [31, 94], [31, 96], [31, 97], [31, 98], [32, 35], [32, 36], [32, 39], [32, 40], [32, 42], [32, 43], [32, 46], [32, 47], [32, 48], [32, 50], [32, 52], [32, 54], [32, 58], [32, 59], [32, 60], [32, 70], [32, 71], [32, 72], [32, 73], [32, 74], [32, 77], [32, 78], [32, 79], [32, 80], [32, 81], [32, 83], [32, 85], [32, 86], [32, 89], [32, 91], [32, 93], [32, 94], [32, 95], [32, 96], [33, 35], [33, 44], [33, 47], [33, 48], [33, 49], [33, 50], [33, 53], [33, 54], [33, 55], [33, 56], [33, 58], [33, 60], [33, 61], [33, 63], [33, 64], [33, 65], [33, 67], [33, 70], [33, 71], [33, 72], [33, 73], [33, 74], [33, 75], [33, 79], [33, 80], [33, 81], [33, 82], [33, 85], [33, 86], [33, 90], [33, 91], [33, 92], [33, 94], [33, 95], [33, 97], [33, 98], [33, 99], [34, 36], [34, 37], [34, 39], [34, 43], [34, 44], [34, 45], [34, 49], [34, 51], [34, 54], [34, 57], [34, 59], [34, 61], [34, 63], [34, 64], [34, 66], [34, 70], [34, 71], [34, 72], [34, 74], [34, 76], [34, 77], [34, 81], [34, 83], [34, 87], [34, 88], [34, 89], [34, 91], [34, 94], [34, 98], [35, 36], [35, 38], [35, 44], [35, 45], [35, 46], [35, 48], [35, 49], [35, 53], [35, 54], [35, 55], [35, 56], [35, 57], [35, 59], [35, 61], [35, 65], [35, 66], [35, 67], [35, 70], [35, 72], [35, 73], [35, 75], [35, 76], [35, 78], [35, 80], [35, 82], [35, 83], [35, 87], [35, 90], [35, 93], [35, 96], [35, 97], [35, 98], [35, 99], [36, 39], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 49], [36, 50], [36, 51], [36, 52], [36, 53], [36, 54], [36, 55], [36, 59], [36, 60], [36, 61], [36, 62], [36, 63], [36, 64], [36, 68], [36, 69], [36, 70], [36, 71], [36, 72], [36, 73], [36, 74], [36, 75], [36, 76], [36, 77], [36, 78], [36, 79], [36, 83], [36, 84], [36, 86], [36, 87], [36, 88], [36, 89], [36, 94], [36, 95], [36, 99], [37, 39], [37, 41], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 49], [37, 50], [37, 51], [37, 53], [37, 58], [37, 60], [37, 61], [37, 65], [37, 66], [37, 68], [37, 69], [37, 70], [37, 72], [37, 73], [37, 74], [37, 75], [37, 76], [37, 78], [37, 79], [37, 82], [37, 84], [37, 87], [37, 89], [37, 93], [37, 95], [37, 96], [37, 97], [37, 98], [38, 40], [38, 44], [38, 45], [38, 46], [38, 47], [38, 50], [38, 51], [38, 55], [38, 57], [38, 59], [38, 61], [38, 63], [38, 64], [38, 66], [38, 71], [38, 72], [38, 74], [38, 75], [38, 76], [38, 77], [38, 81], [38, 82], [38, 84], [38, 87], [38, 89], [38, 90], [38, 91], [38, 92], [38, 96], [38, 97], [39, 40], [39, 42], [39, 43], [39, 44], [39, 46], [39, 47], [39, 50], [39, 55], [39, 58], [39, 59], [39, 64], [39, 66], [39, 67], [39, 68], [39, 69], [39, 71], [39, 73], [39, 75], [39, 76], [39, 77], [39, 79], [39, 81], [39, 91], [39, 92], [39, 93], [39, 94], [39, 97], [39, 98], [40, 41], [40, 42], [40, 46], [40, 50], [40, 51], [40, 53], [40, 54], [40, 56], [40, 57], [40, 59], [40, 60], [40, 61], [40, 63], [40, 65], [40, 68], [40, 70], [40, 76], [40, 78], [40, 80], [40, 81], [40, 83], [40, 85], [40, 86], [40, 89], [40, 90], [40, 98], [40, 99], [41, 43], [41, 44], [41, 45], [41, 46], [41, 48], [41, 52], [41, 53], [41, 54], [41, 55], [41, 56], [41, 57], [41, 62], [41, 63], [41, 64], [41, 65], [41, 66], [41, 67], [41, 70], [41, 71], [41, 74], [41, 75], [41, 77], [41, 84], [41, 86], [41, 87], [41, 89], [41, 91], [41, 95], [41, 98], [42, 43], [42, 45], [42, 48], [42, 49], [42, 50], [42, 52], [42, 53], [42, 54], [42, 57], [42, 61], [42, 62], [42, 63], [42, 64], [42, 66], [42, 68], [42, 69], [42, 70], [42, 73], [42, 74], [42, 76], [42, 77], [42, 78], [42, 82], [42, 84], [42, 85], [42, 86], [42, 87], [42, 88], [42, 89], [42, 92], [42, 93], [42, 95], [42, 98], [43, 44], [43, 45], [43, 46], [43, 50], [43, 52], [43, 54], [43, 57], [43, 58], [43, 59], [43, 60], [43, 61], [43, 62], [43, 63], [43, 64], [43, 67], [43, 68], [43, 70], [43, 71], [43, 73], [43, 78], [43, 79], [43, 80], [43, 81], [43, 82], [43, 83], [43, 85], [43, 86], [43, 87], [43, 88], [43, 92], [43, 98], [43, 99], [44, 47], [44, 49], [44, 50], [44, 54], [44, 57], [44, 58], [44, 59], [44, 60], [44, 62], [44, 64], [44, 65], [44, 68], [44, 70], [44, 72], [44, 74], [44, 75], [44, 76], [44, 77], [44, 78], [44, 81], [44, 82], [44, 84], [44, 86], [44, 87], [44, 88], [44, 89], [44, 94], [44, 98], [45, 46], [45, 50], [45, 52], [45, 54], [45, 55], [45, 57], [45, 60], [45, 61], [45, 62], [45, 67], [45, 68], [45, 69], [45, 70], [45, 72], [45, 73], [45, 75], [45, 76], [45, 80], [45, 81], [45, 86], [45, 87], [45, 89], [45, 91], [45, 93], [45, 95], [45, 96], [45, 98], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 53], [46, 54], [46, 56], [46, 58], [46, 59], [46, 60], [46, 68], [46, 69], [46, 72], [46, 75], [46, 76], [46, 78], [46, 79], [46, 81], [46, 83], [46, 86], [46, 90], [46, 92], [46, 93], [46, 94], [46, 95], [46, 97], [46, 98], [46, 99], [47, 50], [47, 51], [47, 52], [47, 56], [47, 57], [47, 61], [47, 62], [47, 63], [47, 67], [47, 68], [47, 69], [47, 70], [47, 72], [47, 73], [47, 74], [47, 78], [47, 82], [47, 83], [47, 88], [47, 89], [47, 91], [48, 49], [48, 51], [48, 58], [48, 60], [48, 66], [48, 67], [48, 68], [48, 69], [48, 70], [48, 71], [48, 72], [48, 73], [48, 74], [48, 78], [48, 79], [48, 81], [48, 82], [48, 86], [48, 87], [48, 88], [48, 89], [48, 95], [48, 97], [49, 52], [49, 54], [49, 56], [49, 57], [49, 59], [49, 61], [49, 62], [49, 63], [49, 64], [49, 65], [49, 67], [49, 73], [49, 74], [49, 75], [49, 76], [49, 77], [49, 80], [49, 81], [49, 83], [49, 86], [49, 88], [49, 89], [49, 92], [49, 94], [49, 96], [50, 51], [50, 52], [50, 54], [50, 55], [50, 56], [50, 57], [50, 60], [50, 61], [50, 62], [50, 65], [50, 67], [50, 68], [50, 70], [50, 72], [50, 73], [50, 74], [50, 75], [50, 77], [50, 78], [50, 81], [50, 84], [50, 86], [50, 87], [50, 88], [50, 91], [50, 93], [50, 94], [50, 95], [50, 96], [51, 52], [51, 56], [51, 59], [51, 61], [51, 62], [51, 63], [51, 65], [51, 66], [51, 67], [51, 68], [51, 69], [51, 72], [51, 75], [51, 76], [51, 77], [51, 78], [51, 80], [51, 81], [51, 82], [51, 83], [51, 85], [51, 89], [51, 93], [51, 94], [51, 95], [51, 97], [51, 98], [51, 99], [52, 53], [52, 54], [52, 55], [52, 58], [52, 59], [52, 60], [52, 61], [52, 62], [52, 63], [52, 64], [52, 66], [52, 67], [52, 68], [52, 70], [52, 71], [52, 73], [52, 75], [52, 76], [52, 77], [52, 78], [52, 79], [52, 80], [52, 81], [52, 82], [52, 84], [52, 85], [52, 86], [52, 87], [52, 89], [52, 90], [52, 92], [52, 93], [52, 94], [52, 96], [52, 97], [52, 98], [52, 99], [53, 54], [53, 56], [53, 57], [53, 59], [53, 60], [53, 65], [53, 68], [53, 70], [53, 71], [53, 72], [53, 73], [53, 74], [53, 75], [53, 76], [53, 78], [53, 79], [53, 82], [53, 86], [53, 89], [53, 90], [53, 91], [53, 92], [53, 94], [53, 98], [54, 58], [54, 59], [54, 61], [54, 62], [54, 64], [54, 67], [54, 68], [54, 70], [54, 71], [54, 73], [54, 74], [54, 77], [54, 78], [54, 81], [54, 83], [54, 84], [54, 86], [54, 87], [54, 90], [54, 91], [54, 98], [55, 57], [55, 60], [55, 63], [55, 68], [55, 69], [55, 71], [55, 77], [55, 78], [55, 79], [55, 81], [55, 82], [55, 83], [55, 86], [55, 87], [55, 89], [55, 90], [55, 93], [55, 94], [55, 97], [55, 98], [55, 99], [56, 58], [56, 60], [56, 63], [56, 64], [56, 66], [56, 67], [56, 68], [56, 69], [56, 70], [56, 73], [56, 75], [56, 76], [56, 78], [56, 79], [56, 81], [56, 82], [56, 84], [56, 86], [56, 87], [56, 88], [56, 90], [56, 91], [56, 93], [56, 94], [56, 97], [56, 98], [57, 59], [57, 60], [57, 65], [57, 66], [57, 67], [57, 68], [57, 69], [57, 72], [57, 74], [57, 76], [57, 77], [57, 80], [57, 81], [57, 82], [57, 83], [57, 88], [57, 89], [57, 90], [57, 94], [57, 96], [57, 97], [57, 99], [58, 59], [58, 62], [58, 63], [58, 69], [58, 70], [58, 71], [58, 74], [58, 75], [58, 77], [58, 80], [58, 82], [58, 86], [58, 89], [58, 91], [58, 93], [58, 94], [58, 95], [58, 96], [59, 62], [59, 66], [59, 68], [59, 69], [59, 70], [59, 72], [59, 75], [59, 76], [59, 79], [59, 81], [59, 82], [59, 87], [59, 91], [59, 92], [59, 93], [59, 94], [60, 63], [60, 64], [60, 66], [60, 67], [60, 70], [60, 73], [60, 74], [60, 75], [60, 78], [60, 79], [60, 80], [60, 81], [60, 84], [60, 89], [60, 92], [60, 95], [60, 96], [60, 97], [60, 98], [61, 62], [61, 63], [61, 64], [61, 65], [61, 66], [61, 67], [61, 68], [61, 69], [61, 70], [61, 71], [61, 73], [61, 74], [61, 75], [61, 77], [61, 80], [61, 81], [61, 83], [61, 85], [61, 86], [61, 87], [61, 89], [61, 90], [61, 93], [61, 94], [61, 96], [61, 98], [61, 99], [62, 63], [62, 67], [62, 68], [62, 70], [62, 71], [62, 72], [62, 73], [62, 74], [62, 75], [62, 76], [62, 78], [62, 79], [62, 84], [62, 85], [62, 86], [62, 87], [62, 88], [62, 90], [62, 95], [62, 96], [62, 98], [62, 99], [63, 64], [63, 66], [63, 67], [63, 68], [63, 70], [63, 71], [63, 73], [63, 74], [63, 76], [63, 80], [63, 81], [63, 82], [63, 84], [63, 86], [63, 89], [63, 92], [63, 96], [64, 65], [64, 68], [64, 69], [64, 71], [64, 72], [64, 73], [64, 76], [64, 78], [64, 81], [64, 82], [64, 85], [64, 86], [64, 91], [64, 94], [64, 97], [64, 98], [64, 99], [65, 66], [65, 67], [65, 69], [65, 80], [65, 82], [65, 83], [65, 84], [65, 85], [65, 86], [65, 88], [65, 89], [65, 90], [65, 91], [65, 93], [65, 95], [65, 97], [66, 67], [66, 69], [66, 73], [66, 76], [66, 78], [66, 79], [66, 81], [66, 82], [66, 87], [66, 91], [66, 92], [66, 93], [66, 95], [66, 96], [66, 97], [66, 98], [67, 71], [67, 73], [67, 75], [67, 80], [67, 82], [67, 84], [67, 85], [67, 88], [67, 89], [67, 93], [67, 96], [67, 97], [67, 98], [67, 99], [68, 70], [68, 71], [68, 73], [68, 74], [68, 75], [68, 76], [68, 81], [68, 82], [68, 84], [68, 86], [68, 87], [68, 88], [68, 89], [68, 91], [68, 92], [68, 95], [68, 99], [69, 71], [69, 73], [69, 75], [69, 78], [69, 80], [69, 83], [69, 90], [69, 93], [69, 98], [69, 99], [70, 72], [70, 73], [70, 74], [70, 79], [70, 80], [70, 82], [70, 83], [70, 84], [70, 85], [70, 86], [70, 87], [70, 88], [70, 89], [70, 90], [70, 92], [70, 98], [71, 73], [71, 76], [71, 80], [71, 81], [71, 84], [71, 85], [71, 87], [71, 89], [71, 94], [71, 96], [71, 97], [72, 74], [72, 75], [72, 88], [72, 89], [72, 92], [72, 95], [72, 98], [73, 75], [73, 77], [73, 79], [73, 80], [73, 81], [73, 82], [73, 86], [73, 87], [73, 88], [73, 90], [73, 93], [73, 94], [73, 98], [74, 76], [74, 77], [74, 80], [74, 81], [74, 84], [74, 85], [74, 87], [74, 94], [74, 96], [74, 97], [75, 77], [75, 78], [75, 81], [75, 84], [75, 86], [75, 87], [75, 88], [75, 89], [75, 93], [75, 94], [75, 95], [75, 96], [75, 99], [76, 77], [76, 78], [76, 79], [76, 81], [76, 82], [76, 88], [76, 90], [76, 93], [76, 95], [76, 96], [76, 99], [77, 78], [77, 80], [77, 82], [77, 89], [77, 91], [77, 92], [77, 94], [77, 97], [77, 98], [78, 79], [78, 80], [78, 81], [78, 83], [78, 84], [78, 85], [78, 88], [78, 89], [78, 91], [78, 94], [78, 95], [78, 96], [78, 97], [78, 98], [78, 99], [79, 80], [79, 81], [79, 82], [79, 83], [79, 86], [79, 87], [79, 90], [79, 91], [79, 92], [79, 93], [79, 94], [79, 96], [79, 98], [80, 81], [80, 82], [80, 85], [80, 90], [80, 92], [80, 95], [80, 96], [80, 97], [80, 99], [81, 88], [81, 91], [81, 92], [81, 96], [81, 99], [82, 84], [82, 85], [82, 86], [82, 87], [82, 89], [82, 91], [82, 95], [82, 97], [82, 98], [82, 99], [83, 84], [83, 85], [83, 86], [83, 87], [83, 89], [83, 90], [83, 91], [83, 92], [83, 99], [84, 87], [84, 89], [84, 91], [84, 92], [84, 93], [84, 95], [84, 98], [85, 87], [85, 88], [85, 91], [85, 97], [85, 98], [85, 99], [86, 87], [86, 88], [86, 89], [86, 90], [86, 91], [86, 92], [86, 94], [86, 96], [86, 97], [86, 99], [87, 90], [87, 93], [87, 95], [87, 99], [88, 91], [88, 93], [88, 94], [88, 97], [88, 98], [89, 94], [89, 95], [89, 97], [89, 98], [90, 91], [90, 92], [90, 93], [90, 96], [90, 97], [90, 98], [90, 99], [91, 92], [91, 93], [91, 94], [91, 96], [91, 97], [91, 99], [92, 95], [92, 96], [92, 98], [92, 99], [93, 94], [93, 95], [93, 97], [94, 96], [94, 98], [94, 99], [95, 96], [95, 98], [96, 97], [96, 98], [97, 98], [98, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s5/solution/solve.sh b/tasks/construct-nppc-clique-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7adf6117a27c153314d2c78d73afd8cc69539e45 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-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' +{"clique": [7, 8, 10, 19, 27, 28, 36, 42, 43, 45, 50, 52, 54, 61, 62, 68, 70, 73, 86, 87]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s5/tests/check.py b/tasks/construct-nppc-clique-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s5/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l6-s5/tests/instance.json b/tasks/construct-nppc-clique-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..62862e8c6a5e2341fadceeab810d223455b48152 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 5], [0, 6], [0, 7], [0, 11], [0, 15], [0, 16], [0, 17], [0, 18], [0, 25], [0, 29], [0, 30], [0, 33], [0, 37], [0, 38], [0, 39], [0, 42], [0, 44], [0, 46], [0, 47], [0, 53], [0, 54], [0, 56], [0, 58], [0, 59], [0, 62], [0, 63], [0, 64], [0, 65], [0, 68], [0, 69], [0, 75], [0, 76], [0, 77], [0, 78], [0, 81], [0, 82], [0, 83], [0, 84], [0, 86], [0, 88], [0, 89], [0, 90], [0, 91], [0, 93], [0, 95], [0, 96], [0, 98], [0, 99], [1, 3], [1, 6], [1, 9], [1, 13], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [1, 22], [1, 27], [1, 31], [1, 32], [1, 35], [1, 36], [1, 37], [1, 38], [1, 40], [1, 41], [1, 42], [1, 46], [1, 48], [1, 51], [1, 53], [1, 55], [1, 56], [1, 58], [1, 59], [1, 60], [1, 64], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 79], [1, 81], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 91], [1, 92], [1, 95], [1, 98], [2, 4], [2, 9], [2, 11], [2, 14], [2, 15], [2, 16], [2, 18], [2, 19], [2, 20], [2, 21], [2, 25], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 35], [2, 36], [2, 38], [2, 40], [2, 41], [2, 42], [2, 43], [2, 46], [2, 47], [2, 48], [2, 49], [2, 53], [2, 55], [2, 56], [2, 57], [2, 61], [2, 62], [2, 63], [2, 64], [2, 65], [2, 67], [2, 68], [2, 69], [2, 70], [2, 74], [2, 78], [2, 79], [2, 80], [2, 81], [2, 83], [2, 84], [2, 85], [2, 86], [2, 87], [2, 88], [2, 91], [2, 93], [2, 98], [3, 5], [3, 7], [3, 9], [3, 10], [3, 11], [3, 13], [3, 14], [3, 19], [3, 20], [3, 22], [3, 23], [3, 25], [3, 26], [3, 28], [3, 29], [3, 31], [3, 32], [3, 34], [3, 35], [3, 36], [3, 38], [3, 40], [3, 41], [3, 44], [3, 45], [3, 48], [3, 50], [3, 52], [3, 53], [3, 56], [3, 57], [3, 58], [3, 59], [3, 62], [3, 64], [3, 65], [3, 66], [3, 68], [3, 69], [3, 70], [3, 71], [3, 73], [3, 75], [3, 76], [3, 77], [3, 79], [3, 80], [3, 83], [3, 84], [3, 85], [3, 86], [3, 87], [3, 88], [3, 91], [3, 93], [3, 96], [3, 97], [4, 5], [4, 8], [4, 11], [4, 12], [4, 13], [4, 14], [4, 16], [4, 17], [4, 19], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 34], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 43], [4, 46], [4, 48], [4, 49], [4, 50], [4, 52], [4, 56], [4, 58], [4, 61], [4, 62], [4, 64], [4, 66], [4, 68], [4, 69], [4, 70], [4, 73], [4, 74], [4, 75], [4, 76], [4, 79], [4, 80], [4, 81], [4, 84], [4, 87], [4, 89], [4, 92], [4, 94], [4, 96], [4, 97], [4, 99], [5, 7], [5, 8], [5, 11], [5, 12], [5, 14], [5, 16], [5, 17], [5, 21], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 32], [5, 33], [5, 35], [5, 42], [5, 43], [5, 46], [5, 48], [5, 51], [5, 52], [5, 54], [5, 55], [5, 58], [5, 59], [5, 65], [5, 66], [5, 67], [5, 73], [5, 74], [5, 77], [5, 78], [5, 85], [5, 89], [5, 91], [5, 93], [5, 98], [6, 7], [6, 8], [6, 9], [6, 11], [6, 14], [6, 15], [6, 16], [6, 17], [6, 19], [6, 20], [6, 22], [6, 26], [6, 27], [6, 28], [6, 31], [6, 32], [6, 34], [6, 37], [6, 38], [6, 41], [6, 43], [6, 47], [6, 50], [6, 53], [6, 55], [6, 57], [6, 58], [6, 68], [6, 69], [6, 72], [6, 74], [6, 75], [6, 76], [6, 77], [6, 78], [6, 83], [6, 85], [6, 87], [6, 88], [6, 89], [6, 90], [6, 91], [6, 93], [6, 95], [6, 96], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [7, 15], [7, 17], [7, 19], [7, 20], [7, 21], [7, 22], [7, 25], [7, 26], [7, 27], [7, 28], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 39], [7, 40], [7, 41], [7, 42], [7, 43], [7, 44], [7, 45], [7, 47], [7, 48], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 57], [7, 59], [7, 61], [7, 62], [7, 65], [7, 67], [7, 68], [7, 70], [7, 73], [7, 75], [7, 77], [7, 78], [7, 79], [7, 84], [7, 86], [7, 87], [7, 88], [7, 90], [7, 91], [7, 96], [7, 99], [8, 10], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 25], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 36], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 48], [8, 50], [8, 51], [8, 52], [8, 54], [8, 56], [8, 60], [8, 61], [8, 62], [8, 63], [8, 66], [8, 67], [8, 68], [8, 69], [8, 70], [8, 72], [8, 73], [8, 76], [8, 78], [8, 80], [8, 82], [8, 83], [8, 85], [8, 86], [8, 87], [8, 88], [8, 89], [8, 95], [9, 14], [9, 17], [9, 18], [9, 19], [9, 21], [9, 23], [9, 26], [9, 27], [9, 29], [9, 31], [9, 32], [9, 34], [9, 35], [9, 37], [9, 39], [9, 41], [9, 46], [9, 47], [9, 48], [9, 55], [9, 58], [9, 59], [9, 60], [9, 61], [9, 62], [9, 65], [9, 66], [9, 67], [9, 72], [9, 73], [9, 75], [9, 77], [9, 81], [9, 83], [9, 87], [9, 89], [9, 91], [9, 92], [9, 95], [9, 97], [9, 99], [10, 11], [10, 12], [10, 14], [10, 19], [10, 20], [10, 21], [10, 22], [10, 27], [10, 28], [10, 33], [10, 35], [10, 36], [10, 38], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 50], [10, 52], [10, 54], [10, 55], [10, 58], [10, 59], [10, 60], [10, 61], [10, 62], [10, 64], [10, 66], [10, 68], [10, 70], [10, 71], [10, 72], [10, 73], [10, 81], [10, 82], [10, 85], [10, 86], [10, 87], [10, 88], [10, 89], [10, 90], [10, 91], [10, 94], [10, 96], [10, 97], [10, 98], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 26], [11, 30], [11, 34], [11, 39], [11, 40], [11, 41], [11, 48], [11, 50], [11, 51], [11, 52], [11, 56], [11, 58], [11, 59], [11, 61], [11, 63], [11, 64], [11, 66], [11, 67], [11, 69], [11, 70], [11, 71], [11, 72], [11, 74], [11, 75], [11, 76], [11, 77], [11, 78], [11, 79], [11, 81], [11, 84], [11, 85], [11, 86], [11, 92], [11, 93], [11, 94], [11, 98], [12, 15], [12, 16], [12, 17], [12, 19], [12, 20], [12, 22], [12, 23], [12, 25], [12, 26], [12, 31], [12, 34], [12, 35], [12, 36], [12, 37], [12, 41], [12, 43], [12, 44], [12, 45], [12, 49], [12, 50], [12, 53], [12, 54], [12, 55], [12, 58], [12, 60], [12, 61], [12, 63], [12, 65], [12, 66], [12, 68], [12, 69], [12, 70], [12, 71], [12, 72], [12, 73], [12, 74], [12, 76], [12, 80], [12, 85], [12, 87], [12, 89], [12, 92], [12, 93], [12, 96], [12, 98], [13, 14], [13, 21], [13, 22], [13, 23], [13, 24], [13, 27], [13, 32], [13, 39], [13, 40], [13, 44], [13, 45], [13, 46], [13, 52], [13, 53], [13, 54], [13, 57], [13, 65], [13, 68], [13, 71], [13, 72], [13, 73], [13, 74], [13, 75], [13, 81], [13, 84], [13, 85], [13, 86], [13, 87], [13, 88], [13, 89], [13, 90], [13, 92], [13, 93], [13, 94], [13, 97], [13, 98], [14, 15], [14, 16], [14, 18], [14, 20], [14, 21], [14, 23], [14, 26], [14, 27], [14, 29], [14, 30], [14, 31], [14, 32], [14, 35], [14, 36], [14, 37], [14, 38], [14, 40], [14, 41], [14, 42], [14, 44], [14, 45], [14, 46], [14, 48], [14, 51], [14, 52], [14, 54], [14, 55], [14, 57], [14, 59], [14, 61], [14, 64], [14, 72], [14, 73], [14, 74], [14, 76], [14, 80], [14, 81], [14, 84], [14, 85], [14, 86], [14, 94], [14, 95], [14, 98], [14, 99], [15, 16], [15, 17], [15, 19], [15, 21], [15, 27], [15, 28], [15, 29], [15, 37], [15, 42], [15, 44], [15, 48], [15, 49], [15, 51], [15, 54], [15, 55], [15, 57], [15, 61], [15, 62], [15, 63], [15, 65], [15, 66], [15, 71], [15, 75], [15, 77], [15, 79], [15, 81], [15, 82], [15, 85], [15, 86], [15, 87], [15, 90], [15, 94], [15, 98], [15, 99], [16, 19], [16, 21], [16, 22], [16, 23], [16, 27], [16, 28], [16, 31], [16, 35], [16, 38], [16, 39], [16, 43], [16, 49], [16, 51], [16, 54], [16, 55], [16, 56], [16, 57], [16, 59], [16, 60], [16, 63], [16, 64], [16, 65], [16, 66], [16, 68], [16, 69], [16, 70], [16, 73], [16, 77], [16, 78], [16, 79], [16, 80], [16, 82], [16, 85], [16, 86], [16, 87], [16, 89], [16, 92], [16, 93], [16, 94], [16, 97], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 27], [17, 28], [17, 29], [17, 31], [17, 32], [17, 36], [17, 39], [17, 45], [17, 46], [17, 49], [17, 51], [17, 52], [17, 53], [17, 54], [17, 55], [17, 58], [17, 61], [17, 62], [17, 63], [17, 67], [17, 68], [17, 69], [17, 71], [17, 72], [17, 74], [17, 78], [17, 80], [17, 82], [17, 83], [17, 84], [17, 85], [17, 86], [17, 89], [17, 90], [17, 93], [17, 95], [17, 96], [17, 98], [17, 99], [18, 22], [18, 23], [18, 24], [18, 27], [18, 29], [18, 31], [18, 33], [18, 35], [18, 38], [18, 40], [18, 41], [18, 43], [18, 44], [18, 46], [18, 49], [18, 51], [18, 53], [18, 55], [18, 58], [18, 59], [18, 60], [18, 61], [18, 62], [18, 63], [18, 64], [18, 68], [18, 69], [18, 70], [18, 71], [18, 73], [18, 75], [18, 76], [18, 78], [18, 81], [18, 82], [18, 83], [18, 84], [18, 90], [18, 91], [18, 93], [18, 94], [18, 95], [18, 98], [18, 99], [19, 20], [19, 21], [19, 22], [19, 25], [19, 27], [19, 28], [19, 33], [19, 34], [19, 35], [19, 36], [19, 38], [19, 42], [19, 43], [19, 44], [19, 45], [19, 49], [19, 50], [19, 52], [19, 54], [19, 57], [19, 59], [19, 60], [19, 61], [19, 62], [19, 63], [19, 67], [19, 68], [19, 69], [19, 70], [19, 71], [19, 72], [19, 73], [19, 74], [19, 75], [19, 76], [19, 77], [19, 81], [19, 85], [19, 86], [19, 87], [19, 88], [19, 90], [19, 91], [19, 92], [19, 94], [19, 95], [19, 97], [20, 21], [20, 23], [20, 24], [20, 25], [20, 27], [20, 29], [20, 33], [20, 37], [20, 41], [20, 43], [20, 45], [20, 49], [20, 50], [20, 51], [20, 52], [20, 54], [20, 57], [20, 65], [20, 66], [20, 68], [20, 69], [20, 70], [20, 72], [20, 73], [20, 79], [20, 83], [20, 85], [20, 87], [20, 89], [20, 90], [20, 91], [20, 93], [20, 95], [20, 96], [20, 98], [21, 23], [21, 25], [21, 28], [21, 29], [21, 31], [21, 40], [21, 43], [21, 45], [21, 47], [21, 48], [21, 50], [21, 52], [21, 55], [21, 59], [21, 60], [21, 61], [21, 62], [21, 63], [21, 64], [21, 68], [21, 70], [21, 72], [21, 76], [21, 77], [21, 78], [21, 79], [21, 80], [21, 82], [21, 84], [21, 85], [21, 86], [21, 87], [21, 89], [21, 91], [21, 92], [21, 93], [21, 96], [21, 99], [22, 24], [22, 25], [22, 29], [22, 31], [22, 33], [22, 35], [22, 39], [22, 43], [22, 44], [22, 49], [22, 52], [22, 53], [22, 54], [22, 60], [22, 63], [22, 64], [22, 65], [22, 68], [22, 70], [22, 71], [22, 73], [22, 74], [22, 75], [22, 76], [22, 81], [22, 82], [22, 85], [22, 88], [22, 90], [22, 91], [22, 92], [22, 95], [22, 97], [22, 98], [23, 26], [23, 28], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 46], [23, 47], [23, 49], [23, 50], [23, 51], [23, 54], [23, 55], [23, 56], [23, 59], [23, 60], [23, 63], [23, 64], [23, 65], [23, 68], [23, 70], [23, 72], [23, 73], [23, 76], [23, 77], [23, 78], [23, 80], [23, 86], [23, 88], [23, 90], [23, 92], [23, 93], [23, 98], [23, 99], [24, 25], [24, 29], [24, 31], [24, 33], [24, 34], [24, 35], [24, 36], [24, 38], [24, 39], [24, 41], [24, 42], [24, 43], [24, 44], [24, 46], [24, 47], [24, 51], [24, 52], [24, 53], [24, 55], [24, 58], [24, 62], [24, 63], [24, 64], [24, 66], [24, 67], [24, 69], [24, 72], [24, 75], [24, 76], [24, 78], [24, 79], [24, 80], [24, 83], [24, 84], [24, 85], [24, 86], [24, 90], [24, 92], [24, 94], [24, 96], [24, 97], [24, 99], [25, 29], [25, 32], [25, 36], [25, 39], [25, 41], [25, 42], [25, 43], [25, 44], [25, 48], [25, 49], [25, 50], [25, 51], [25, 53], [25, 55], [25, 57], [25, 58], [25, 60], [25, 61], [25, 64], [25, 66], [25, 69], [25, 71], [25, 72], [25, 74], [25, 76], [25, 77], [25, 79], [25, 80], [25, 82], [25, 85], [25, 89], [25, 90], [25, 91], [25, 92], [25, 93], [26, 27], [26, 28], [26, 29], [26, 31], [26, 32], [26, 33], [26, 35], [26, 36], [26, 37], [26, 44], [26, 45], [26, 46], [26, 49], [26, 50], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [26, 57], [26, 59], [26, 61], [26, 62], [26, 63], [26, 65], [26, 66], [26, 68], [26, 71], [26, 72], [26, 73], [26, 75], [26, 76], [26, 79], [26, 82], [26, 86], [26, 89], [26, 92], [26, 93], [26, 94], [26, 95], [26, 98], [26, 99], [27, 28], [27, 29], [27, 31], [27, 32], [27, 35], [27, 36], [27, 38], [27, 40], [27, 41], [27, 42], [27, 43], [27, 45], [27, 47], [27, 48], [27, 49], [27, 50], [27, 52], [27, 54], [27, 55], [27, 56], [27, 58], [27, 59], [27, 61], [27, 62], [27, 64], [27, 66], [27, 68], [27, 70], [27, 73], [27, 74], [27, 75], [27, 76], [27, 77], [27, 82], [27, 83], [27, 86], [27, 87], [27, 88], [27, 89], [27, 93], [27, 95], [27, 96], [27, 99], [28, 29], [28, 30], [28, 31], [28, 32], [28, 35], [28, 36], [28, 37], [28, 38], [28, 41], [28, 42], [28, 43], [28, 45], [28, 46], [28, 47], [28, 49], [28, 50], [28, 52], [28, 53], [28, 54], [28, 55], [28, 60], [28, 61], [28, 62], [28, 64], [28, 65], [28, 66], [28, 67], [28, 68], [28, 70], [28, 71], [28, 73], [28, 74], [28, 75], [28, 76], [28, 81], [28, 86], [28, 87], [28, 89], [28, 90], [28, 92], [28, 94], [28, 95], [28, 96], [28, 97], [29, 34], [29, 36], [29, 37], [29, 41], [29, 46], [29, 48], [29, 50], [29, 52], [29, 53], [29, 55], [29, 57], [29, 59], [29, 61], [29, 62], [29, 63], [29, 64], [29, 65], [29, 67], [29, 68], [29, 70], [29, 71], [29, 72], [29, 73], [29, 74], [29, 75], [29, 76], [29, 77], [29, 79], [29, 82], [29, 84], [29, 87], [29, 90], [29, 91], [29, 92], [29, 94], [29, 98], [29, 99], [30, 31], [30, 34], [30, 35], [30, 36], [30, 37], [30, 41], [30, 43], [30, 45], [30, 47], [30, 50], [30, 51], [30, 54], [30, 56], [30, 59], [30, 60], [30, 63], [30, 64], [30, 66], [30, 68], [30, 72], [30, 74], [30, 75], [30, 76], [30, 79], [30, 80], [30, 81], [30, 83], [30, 84], [30, 86], [30, 90], [30, 91], [30, 92], [30, 96], [30, 97], [30, 98], [31, 33], [31, 34], [31, 39], [31, 41], [31, 42], [31, 43], [31, 45], [31, 46], [31, 47], [31, 48], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [31, 59], [31, 60], [31, 61], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 70], [31, 74], [31, 79], [31, 84], [31, 85], [31, 86], [31, 87], [31, 89], [31, 91], [31, 92], [31, 94], [31, 96], [31, 97], [31, 98], [32, 35], [32, 36], [32, 39], [32, 40], [32, 42], [32, 43], [32, 46], [32, 47], [32, 48], [32, 50], [32, 52], [32, 54], [32, 58], [32, 59], [32, 60], [32, 70], [32, 71], [32, 72], [32, 73], [32, 74], [32, 77], [32, 78], [32, 79], [32, 80], [32, 81], [32, 83], [32, 85], [32, 86], [32, 89], [32, 91], [32, 93], [32, 94], [32, 95], [32, 96], [33, 35], [33, 44], [33, 47], [33, 48], [33, 49], [33, 50], [33, 53], [33, 54], [33, 55], [33, 56], [33, 58], [33, 60], [33, 61], [33, 63], [33, 64], [33, 65], [33, 67], [33, 70], [33, 71], [33, 72], [33, 73], [33, 74], [33, 75], [33, 79], [33, 80], [33, 81], [33, 82], [33, 85], [33, 86], [33, 90], [33, 91], [33, 92], [33, 94], [33, 95], [33, 97], [33, 98], [33, 99], [34, 36], [34, 37], [34, 39], [34, 43], [34, 44], [34, 45], [34, 49], [34, 51], [34, 54], [34, 57], [34, 59], [34, 61], [34, 63], [34, 64], [34, 66], [34, 70], [34, 71], [34, 72], [34, 74], [34, 76], [34, 77], [34, 81], [34, 83], [34, 87], [34, 88], [34, 89], [34, 91], [34, 94], [34, 98], [35, 36], [35, 38], [35, 44], [35, 45], [35, 46], [35, 48], [35, 49], [35, 53], [35, 54], [35, 55], [35, 56], [35, 57], [35, 59], [35, 61], [35, 65], [35, 66], [35, 67], [35, 70], [35, 72], [35, 73], [35, 75], [35, 76], [35, 78], [35, 80], [35, 82], [35, 83], [35, 87], [35, 90], [35, 93], [35, 96], [35, 97], [35, 98], [35, 99], [36, 39], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 49], [36, 50], [36, 51], [36, 52], [36, 53], [36, 54], [36, 55], [36, 59], [36, 60], [36, 61], [36, 62], [36, 63], [36, 64], [36, 68], [36, 69], [36, 70], [36, 71], [36, 72], [36, 73], [36, 74], [36, 75], [36, 76], [36, 77], [36, 78], [36, 79], [36, 83], [36, 84], [36, 86], [36, 87], [36, 88], [36, 89], [36, 94], [36, 95], [36, 99], [37, 39], [37, 41], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 49], [37, 50], [37, 51], [37, 53], [37, 58], [37, 60], [37, 61], [37, 65], [37, 66], [37, 68], [37, 69], [37, 70], [37, 72], [37, 73], [37, 74], [37, 75], [37, 76], [37, 78], [37, 79], [37, 82], [37, 84], [37, 87], [37, 89], [37, 93], [37, 95], [37, 96], [37, 97], [37, 98], [38, 40], [38, 44], [38, 45], [38, 46], [38, 47], [38, 50], [38, 51], [38, 55], [38, 57], [38, 59], [38, 61], [38, 63], [38, 64], [38, 66], [38, 71], [38, 72], [38, 74], [38, 75], [38, 76], [38, 77], [38, 81], [38, 82], [38, 84], [38, 87], [38, 89], [38, 90], [38, 91], [38, 92], [38, 96], [38, 97], [39, 40], [39, 42], [39, 43], [39, 44], [39, 46], [39, 47], [39, 50], [39, 55], [39, 58], [39, 59], [39, 64], [39, 66], [39, 67], [39, 68], [39, 69], [39, 71], [39, 73], [39, 75], [39, 76], [39, 77], [39, 79], [39, 81], [39, 91], [39, 92], [39, 93], [39, 94], [39, 97], [39, 98], [40, 41], [40, 42], [40, 46], [40, 50], [40, 51], [40, 53], [40, 54], [40, 56], [40, 57], [40, 59], [40, 60], [40, 61], [40, 63], [40, 65], [40, 68], [40, 70], [40, 76], [40, 78], [40, 80], [40, 81], [40, 83], [40, 85], [40, 86], [40, 89], [40, 90], [40, 98], [40, 99], [41, 43], [41, 44], [41, 45], [41, 46], [41, 48], [41, 52], [41, 53], [41, 54], [41, 55], [41, 56], [41, 57], [41, 62], [41, 63], [41, 64], [41, 65], [41, 66], [41, 67], [41, 70], [41, 71], [41, 74], [41, 75], [41, 77], [41, 84], [41, 86], [41, 87], [41, 89], [41, 91], [41, 95], [41, 98], [42, 43], [42, 45], [42, 48], [42, 49], [42, 50], [42, 52], [42, 53], [42, 54], [42, 57], [42, 61], [42, 62], [42, 63], [42, 64], [42, 66], [42, 68], [42, 69], [42, 70], [42, 73], [42, 74], [42, 76], [42, 77], [42, 78], [42, 82], [42, 84], [42, 85], [42, 86], [42, 87], [42, 88], [42, 89], [42, 92], [42, 93], [42, 95], [42, 98], [43, 44], [43, 45], [43, 46], [43, 50], [43, 52], [43, 54], [43, 57], [43, 58], [43, 59], [43, 60], [43, 61], [43, 62], [43, 63], [43, 64], [43, 67], [43, 68], [43, 70], [43, 71], [43, 73], [43, 78], [43, 79], [43, 80], [43, 81], [43, 82], [43, 83], [43, 85], [43, 86], [43, 87], [43, 88], [43, 92], [43, 98], [43, 99], [44, 47], [44, 49], [44, 50], [44, 54], [44, 57], [44, 58], [44, 59], [44, 60], [44, 62], [44, 64], [44, 65], [44, 68], [44, 70], [44, 72], [44, 74], [44, 75], [44, 76], [44, 77], [44, 78], [44, 81], [44, 82], [44, 84], [44, 86], [44, 87], [44, 88], [44, 89], [44, 94], [44, 98], [45, 46], [45, 50], [45, 52], [45, 54], [45, 55], [45, 57], [45, 60], [45, 61], [45, 62], [45, 67], [45, 68], [45, 69], [45, 70], [45, 72], [45, 73], [45, 75], [45, 76], [45, 80], [45, 81], [45, 86], [45, 87], [45, 89], [45, 91], [45, 93], [45, 95], [45, 96], [45, 98], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 53], [46, 54], [46, 56], [46, 58], [46, 59], [46, 60], [46, 68], [46, 69], [46, 72], [46, 75], [46, 76], [46, 78], [46, 79], [46, 81], [46, 83], [46, 86], [46, 90], [46, 92], [46, 93], [46, 94], [46, 95], [46, 97], [46, 98], [46, 99], [47, 50], [47, 51], [47, 52], [47, 56], [47, 57], [47, 61], [47, 62], [47, 63], [47, 67], [47, 68], [47, 69], [47, 70], [47, 72], [47, 73], [47, 74], [47, 78], [47, 82], [47, 83], [47, 88], [47, 89], [47, 91], [48, 49], [48, 51], [48, 58], [48, 60], [48, 66], [48, 67], [48, 68], [48, 69], [48, 70], [48, 71], [48, 72], [48, 73], [48, 74], [48, 78], [48, 79], [48, 81], [48, 82], [48, 86], [48, 87], [48, 88], [48, 89], [48, 95], [48, 97], [49, 52], [49, 54], [49, 56], [49, 57], [49, 59], [49, 61], [49, 62], [49, 63], [49, 64], [49, 65], [49, 67], [49, 73], [49, 74], [49, 75], [49, 76], [49, 77], [49, 80], [49, 81], [49, 83], [49, 86], [49, 88], [49, 89], [49, 92], [49, 94], [49, 96], [50, 51], [50, 52], [50, 54], [50, 55], [50, 56], [50, 57], [50, 60], [50, 61], [50, 62], [50, 65], [50, 67], [50, 68], [50, 70], [50, 72], [50, 73], [50, 74], [50, 75], [50, 77], [50, 78], [50, 81], [50, 84], [50, 86], [50, 87], [50, 88], [50, 91], [50, 93], [50, 94], [50, 95], [50, 96], [51, 52], [51, 56], [51, 59], [51, 61], [51, 62], [51, 63], [51, 65], [51, 66], [51, 67], [51, 68], [51, 69], [51, 72], [51, 75], [51, 76], [51, 77], [51, 78], [51, 80], [51, 81], [51, 82], [51, 83], [51, 85], [51, 89], [51, 93], [51, 94], [51, 95], [51, 97], [51, 98], [51, 99], [52, 53], [52, 54], [52, 55], [52, 58], [52, 59], [52, 60], [52, 61], [52, 62], [52, 63], [52, 64], [52, 66], [52, 67], [52, 68], [52, 70], [52, 71], [52, 73], [52, 75], [52, 76], [52, 77], [52, 78], [52, 79], [52, 80], [52, 81], [52, 82], [52, 84], [52, 85], [52, 86], [52, 87], [52, 89], [52, 90], [52, 92], [52, 93], [52, 94], [52, 96], [52, 97], [52, 98], [52, 99], [53, 54], [53, 56], [53, 57], [53, 59], [53, 60], [53, 65], [53, 68], [53, 70], [53, 71], [53, 72], [53, 73], [53, 74], [53, 75], [53, 76], [53, 78], [53, 79], [53, 82], [53, 86], [53, 89], [53, 90], [53, 91], [53, 92], [53, 94], [53, 98], [54, 58], [54, 59], [54, 61], [54, 62], [54, 64], [54, 67], [54, 68], [54, 70], [54, 71], [54, 73], [54, 74], [54, 77], [54, 78], [54, 81], [54, 83], [54, 84], [54, 86], [54, 87], [54, 90], [54, 91], [54, 98], [55, 57], [55, 60], [55, 63], [55, 68], [55, 69], [55, 71], [55, 77], [55, 78], [55, 79], [55, 81], [55, 82], [55, 83], [55, 86], [55, 87], [55, 89], [55, 90], [55, 93], [55, 94], [55, 97], [55, 98], [55, 99], [56, 58], [56, 60], [56, 63], [56, 64], [56, 66], [56, 67], [56, 68], [56, 69], [56, 70], [56, 73], [56, 75], [56, 76], [56, 78], [56, 79], [56, 81], [56, 82], [56, 84], [56, 86], [56, 87], [56, 88], [56, 90], [56, 91], [56, 93], [56, 94], [56, 97], [56, 98], [57, 59], [57, 60], [57, 65], [57, 66], [57, 67], [57, 68], [57, 69], [57, 72], [57, 74], [57, 76], [57, 77], [57, 80], [57, 81], [57, 82], [57, 83], [57, 88], [57, 89], [57, 90], [57, 94], [57, 96], [57, 97], [57, 99], [58, 59], [58, 62], [58, 63], [58, 69], [58, 70], [58, 71], [58, 74], [58, 75], [58, 77], [58, 80], [58, 82], [58, 86], [58, 89], [58, 91], [58, 93], [58, 94], [58, 95], [58, 96], [59, 62], [59, 66], [59, 68], [59, 69], [59, 70], [59, 72], [59, 75], [59, 76], [59, 79], [59, 81], [59, 82], [59, 87], [59, 91], [59, 92], [59, 93], [59, 94], [60, 63], [60, 64], [60, 66], [60, 67], [60, 70], [60, 73], [60, 74], [60, 75], [60, 78], [60, 79], [60, 80], [60, 81], [60, 84], [60, 89], [60, 92], [60, 95], [60, 96], [60, 97], [60, 98], [61, 62], [61, 63], [61, 64], [61, 65], [61, 66], [61, 67], [61, 68], [61, 69], [61, 70], [61, 71], [61, 73], [61, 74], [61, 75], [61, 77], [61, 80], [61, 81], [61, 83], [61, 85], [61, 86], [61, 87], [61, 89], [61, 90], [61, 93], [61, 94], [61, 96], [61, 98], [61, 99], [62, 63], [62, 67], [62, 68], [62, 70], [62, 71], [62, 72], [62, 73], [62, 74], [62, 75], [62, 76], [62, 78], [62, 79], [62, 84], [62, 85], [62, 86], [62, 87], [62, 88], [62, 90], [62, 95], [62, 96], [62, 98], [62, 99], [63, 64], [63, 66], [63, 67], [63, 68], [63, 70], [63, 71], [63, 73], [63, 74], [63, 76], [63, 80], [63, 81], [63, 82], [63, 84], [63, 86], [63, 89], [63, 92], [63, 96], [64, 65], [64, 68], [64, 69], [64, 71], [64, 72], [64, 73], [64, 76], [64, 78], [64, 81], [64, 82], [64, 85], [64, 86], [64, 91], [64, 94], [64, 97], [64, 98], [64, 99], [65, 66], [65, 67], [65, 69], [65, 80], [65, 82], [65, 83], [65, 84], [65, 85], [65, 86], [65, 88], [65, 89], [65, 90], [65, 91], [65, 93], [65, 95], [65, 97], [66, 67], [66, 69], [66, 73], [66, 76], [66, 78], [66, 79], [66, 81], [66, 82], [66, 87], [66, 91], [66, 92], [66, 93], [66, 95], [66, 96], [66, 97], [66, 98], [67, 71], [67, 73], [67, 75], [67, 80], [67, 82], [67, 84], [67, 85], [67, 88], [67, 89], [67, 93], [67, 96], [67, 97], [67, 98], [67, 99], [68, 70], [68, 71], [68, 73], [68, 74], [68, 75], [68, 76], [68, 81], [68, 82], [68, 84], [68, 86], [68, 87], [68, 88], [68, 89], [68, 91], [68, 92], [68, 95], [68, 99], [69, 71], [69, 73], [69, 75], [69, 78], [69, 80], [69, 83], [69, 90], [69, 93], [69, 98], [69, 99], [70, 72], [70, 73], [70, 74], [70, 79], [70, 80], [70, 82], [70, 83], [70, 84], [70, 85], [70, 86], [70, 87], [70, 88], [70, 89], [70, 90], [70, 92], [70, 98], [71, 73], [71, 76], [71, 80], [71, 81], [71, 84], [71, 85], [71, 87], [71, 89], [71, 94], [71, 96], [71, 97], [72, 74], [72, 75], [72, 88], [72, 89], [72, 92], [72, 95], [72, 98], [73, 75], [73, 77], [73, 79], [73, 80], [73, 81], [73, 82], [73, 86], [73, 87], [73, 88], [73, 90], [73, 93], [73, 94], [73, 98], [74, 76], [74, 77], [74, 80], [74, 81], [74, 84], [74, 85], [74, 87], [74, 94], [74, 96], [74, 97], [75, 77], [75, 78], [75, 81], [75, 84], [75, 86], [75, 87], [75, 88], [75, 89], [75, 93], [75, 94], [75, 95], [75, 96], [75, 99], [76, 77], [76, 78], [76, 79], [76, 81], [76, 82], [76, 88], [76, 90], [76, 93], [76, 95], [76, 96], [76, 99], [77, 78], [77, 80], [77, 82], [77, 89], [77, 91], [77, 92], [77, 94], [77, 97], [77, 98], [78, 79], [78, 80], [78, 81], [78, 83], [78, 84], [78, 85], [78, 88], [78, 89], [78, 91], [78, 94], [78, 95], [78, 96], [78, 97], [78, 98], [78, 99], [79, 80], [79, 81], [79, 82], [79, 83], [79, 86], [79, 87], [79, 90], [79, 91], [79, 92], [79, 93], [79, 94], [79, 96], [79, 98], [80, 81], [80, 82], [80, 85], [80, 90], [80, 92], [80, 95], [80, 96], [80, 97], [80, 99], [81, 88], [81, 91], [81, 92], [81, 96], [81, 99], [82, 84], [82, 85], [82, 86], [82, 87], [82, 89], [82, 91], [82, 95], [82, 97], [82, 98], [82, 99], [83, 84], [83, 85], [83, 86], [83, 87], [83, 89], [83, 90], [83, 91], [83, 92], [83, 99], [84, 87], [84, 89], [84, 91], [84, 92], [84, 93], [84, 95], [84, 98], [85, 87], [85, 88], [85, 91], [85, 97], [85, 98], [85, 99], [86, 87], [86, 88], [86, 89], [86, 90], [86, 91], [86, 92], [86, 94], [86, 96], [86, 97], [86, 99], [87, 90], [87, 93], [87, 95], [87, 99], [88, 91], [88, 93], [88, 94], [88, 97], [88, 98], [89, 94], [89, 95], [89, 97], [89, 98], [90, 91], [90, 92], [90, 93], [90, 96], [90, 97], [90, 98], [90, 99], [91, 92], [91, 93], [91, 94], [91, 96], [91, 97], [91, 99], [92, 95], [92, 96], [92, 98], [92, 99], [93, 94], [93, 95], [93, 97], [94, 96], [94, 98], [94, 99], [95, 96], [95, 98], [96, 97], [96, 98], [97, 98], [98, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s5/tests/run.py b/tasks/construct-nppc-clique-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l6-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-nppc-clique-l6-s5/tests/test.sh b/tasks/construct-nppc-clique-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-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-nppc-dominating-set-l2-s2/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l2-s2/environment/instance.json b/tasks/construct-nppc-dominating-set-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ab9daf81f176b63623764f3d083ca87e52b4a7ea --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 6], [0, 7], [0, 8], [0, 13], [0, 14], [0, 15], [0, 16], [0, 18], [0, 20], [0, 24], [0, 25], [0, 27], [0, 29], [1, 5], [1, 6], [1, 9], [1, 19], [1, 24], [1, 27], [1, 29], [2, 3], [2, 4], [2, 8], [2, 9], [2, 10], [2, 16], [2, 17], [2, 18], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [3, 4], [3, 13], [3, 17], [3, 18], [3, 22], [3, 25], [4, 5], [4, 7], [4, 16], [4, 21], [4, 22], [4, 26], [5, 8], [5, 11], [5, 12], [5, 13], [5, 15], [5, 19], [5, 20], [5, 24], [5, 25], [5, 27], [6, 9], [6, 10], [6, 11], [6, 14], [6, 15], [6, 17], [6, 19], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [7, 8], [7, 10], [7, 11], [7, 12], [7, 13], [7, 20], [7, 22], [7, 23], [7, 27], [7, 28], [7, 29], [8, 12], [8, 17], [8, 18], [8, 20], [8, 21], [9, 13], [9, 15], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 28], [10, 12], [10, 14], [10, 15], [10, 24], [10, 28], [10, 29], [11, 12], [11, 15], [11, 17], [11, 18], [11, 20], [11, 24], [11, 27], [11, 28], [11, 29], [12, 13], [12, 14], [12, 21], [12, 22], [12, 23], [12, 24], [12, 26], [13, 24], [14, 16], [14, 21], [14, 28], [15, 19], [15, 21], [15, 23], [15, 24], [15, 25], [15, 26], [16, 17], [16, 18], [16, 20], [16, 21], [17, 25], [17, 28], [18, 20], [18, 22], [18, 23], [18, 24], [18, 26], [19, 21], [19, 22], [19, 26], [20, 29], [21, 23], [21, 25], [21, 27], [22, 24], [22, 27], [23, 24], [23, 27], [24, 25]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s2/solution/solve.sh b/tasks/construct-nppc-dominating-set-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..95c7fc01d622e3a1a2626904e85ca7be609ffa67 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [3, 6, 7, 10, 13, 14, 15, 19, 21, 22, 23, 24, 26, 28, 29]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l2-s2/tests/check.py b/tasks/construct-nppc-dominating-set-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s2/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-l2-s2/tests/instance.json b/tasks/construct-nppc-dominating-set-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ab9daf81f176b63623764f3d083ca87e52b4a7ea --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 6], [0, 7], [0, 8], [0, 13], [0, 14], [0, 15], [0, 16], [0, 18], [0, 20], [0, 24], [0, 25], [0, 27], [0, 29], [1, 5], [1, 6], [1, 9], [1, 19], [1, 24], [1, 27], [1, 29], [2, 3], [2, 4], [2, 8], [2, 9], [2, 10], [2, 16], [2, 17], [2, 18], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [3, 4], [3, 13], [3, 17], [3, 18], [3, 22], [3, 25], [4, 5], [4, 7], [4, 16], [4, 21], [4, 22], [4, 26], [5, 8], [5, 11], [5, 12], [5, 13], [5, 15], [5, 19], [5, 20], [5, 24], [5, 25], [5, 27], [6, 9], [6, 10], [6, 11], [6, 14], [6, 15], [6, 17], [6, 19], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [7, 8], [7, 10], [7, 11], [7, 12], [7, 13], [7, 20], [7, 22], [7, 23], [7, 27], [7, 28], [7, 29], [8, 12], [8, 17], [8, 18], [8, 20], [8, 21], [9, 13], [9, 15], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 28], [10, 12], [10, 14], [10, 15], [10, 24], [10, 28], [10, 29], [11, 12], [11, 15], [11, 17], [11, 18], [11, 20], [11, 24], [11, 27], [11, 28], [11, 29], [12, 13], [12, 14], [12, 21], [12, 22], [12, 23], [12, 24], [12, 26], [13, 24], [14, 16], [14, 21], [14, 28], [15, 19], [15, 21], [15, 23], [15, 24], [15, 25], [15, 26], [16, 17], [16, 18], [16, 20], [16, 21], [17, 25], [17, 28], [18, 20], [18, 22], [18, 23], [18, 24], [18, 26], [19, 21], [19, 22], [19, 26], [20, 29], [21, 23], [21, 25], [21, 27], [22, 24], [22, 27], [23, 24], [23, 27], [24, 25]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s2/tests/run.py b/tasks/construct-nppc-dominating-set-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l2-s2/tests/test.sh b/tasks/construct-nppc-dominating-set-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l2-s5/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l2-s5/environment/instance.json b/tasks/construct-nppc-dominating-set-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1dd2cee0f704765980be25b85f199236300c9ae5 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 1], [0, 5], [0, 9], [0, 12], [0, 14], [0, 16], [0, 18], [0, 20], [1, 6], [1, 9], [1, 10], [1, 14], [1, 15], [1, 17], [1, 20], [1, 25], [1, 26], [1, 28], [1, 29], [2, 3], [2, 5], [2, 7], [2, 9], [2, 12], [2, 23], [2, 26], [2, 27], [3, 6], [3, 11], [3, 15], [3, 18], [3, 21], [3, 25], [3, 26], [3, 28], [4, 5], [4, 8], [4, 15], [4, 17], [4, 21], [4, 24], [4, 26], [4, 27], [4, 29], [5, 14], [5, 16], [5, 24], [5, 25], [6, 8], [6, 9], [6, 15], [6, 18], [6, 22], [6, 27], [7, 8], [7, 11], [7, 14], [7, 21], [7, 23], [7, 24], [7, 25], [7, 27], [8, 10], [8, 11], [8, 12], [8, 14], [8, 17], [8, 18], [8, 20], [8, 23], [8, 27], [9, 12], [9, 16], [9, 19], [9, 22], [9, 24], [9, 26], [10, 11], [10, 13], [10, 19], [10, 21], [10, 22], [10, 25], [10, 28], [11, 15], [11, 18], [11, 20], [11, 23], [11, 25], [11, 26], [11, 28], [12, 14], [12, 16], [12, 19], [12, 28], [12, 29], [13, 16], [13, 24], [13, 25], [13, 29], [14, 15], [14, 19], [14, 25], [14, 29], [15, 20], [15, 22], [15, 25], [16, 18], [16, 21], [16, 24], [16, 26], [16, 28], [16, 29], [17, 20], [17, 24], [17, 25], [18, 22], [18, 26], [18, 27], [18, 28], [19, 22], [19, 27], [19, 29], [20, 21], [20, 25], [20, 29], [21, 22], [21, 23], [21, 25], [22, 24], [22, 29], [23, 24], [24, 26], [25, 26], [25, 28], [25, 29], [26, 27], [26, 28]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s5/solution/solve.sh b/tasks/construct-nppc-dominating-set-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..44863be37d2da64b21b77bea3a179d5e051826b6 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [1, 2, 4, 5, 6, 7, 8, 9, 11, 14, 21, 22, 25, 26, 28]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l2-s5/tests/check.py b/tasks/construct-nppc-dominating-set-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s5/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-l2-s5/tests/instance.json b/tasks/construct-nppc-dominating-set-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1dd2cee0f704765980be25b85f199236300c9ae5 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 1], [0, 5], [0, 9], [0, 12], [0, 14], [0, 16], [0, 18], [0, 20], [1, 6], [1, 9], [1, 10], [1, 14], [1, 15], [1, 17], [1, 20], [1, 25], [1, 26], [1, 28], [1, 29], [2, 3], [2, 5], [2, 7], [2, 9], [2, 12], [2, 23], [2, 26], [2, 27], [3, 6], [3, 11], [3, 15], [3, 18], [3, 21], [3, 25], [3, 26], [3, 28], [4, 5], [4, 8], [4, 15], [4, 17], [4, 21], [4, 24], [4, 26], [4, 27], [4, 29], [5, 14], [5, 16], [5, 24], [5, 25], [6, 8], [6, 9], [6, 15], [6, 18], [6, 22], [6, 27], [7, 8], [7, 11], [7, 14], [7, 21], [7, 23], [7, 24], [7, 25], [7, 27], [8, 10], [8, 11], [8, 12], [8, 14], [8, 17], [8, 18], [8, 20], [8, 23], [8, 27], [9, 12], [9, 16], [9, 19], [9, 22], [9, 24], [9, 26], [10, 11], [10, 13], [10, 19], [10, 21], [10, 22], [10, 25], [10, 28], [11, 15], [11, 18], [11, 20], [11, 23], [11, 25], [11, 26], [11, 28], [12, 14], [12, 16], [12, 19], [12, 28], [12, 29], [13, 16], [13, 24], [13, 25], [13, 29], [14, 15], [14, 19], [14, 25], [14, 29], [15, 20], [15, 22], [15, 25], [16, 18], [16, 21], [16, 24], [16, 26], [16, 28], [16, 29], [17, 20], [17, 24], [17, 25], [18, 22], [18, 26], [18, 27], [18, 28], [19, 22], [19, 27], [19, 29], [20, 21], [20, 25], [20, 29], [21, 22], [21, 23], [21, 25], [22, 24], [22, 29], [23, 24], [24, 26], [25, 26], [25, 28], [25, 29], [26, 27], [26, 28]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s5/tests/run.py b/tasks/construct-nppc-dominating-set-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l2-s5/tests/test.sh b/tasks/construct-nppc-dominating-set-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l6-s3/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l6-s3/environment/instance.json b/tasks/construct-nppc-dominating-set-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aec2c547f354f89618c4d61a82f72fedb08dc9f1 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 20], [0, 43], [0, 51], [0, 59], [0, 67], [0, 85], [0, 100], [0, 113], [0, 115], [0, 116], [0, 122], [0, 160], [0, 180], [0, 184], [0, 195], [0, 210], [0, 243], [0, 245], [0, 247], [1, 4], [1, 17], [1, 23], [1, 31], [1, 33], [1, 44], [1, 49], [1, 85], [1, 125], [1, 127], [1, 183], [1, 200], [1, 205], [1, 216], [1, 226], [1, 233], [1, 235], [1, 269], [1, 286], [2, 6], [2, 19], [2, 51], [2, 79], [2, 101], [2, 103], [2, 106], [2, 144], [2, 145], [2, 148], [2, 159], [2, 162], [2, 169], [2, 183], [2, 197], [2, 199], [2, 205], [2, 224], [2, 251], [2, 253], [2, 255], [2, 258], [2, 268], [3, 48], [3, 54], [3, 55], [3, 74], [3, 92], [3, 103], [3, 104], [3, 144], [3, 163], [3, 178], [3, 208], [3, 225], [3, 252], [3, 269], [3, 277], [4, 25], [4, 42], [4, 68], [4, 81], [4, 136], [4, 152], [4, 153], [4, 169], [4, 178], [4, 204], [4, 222], [4, 237], [4, 248], [4, 249], [4, 251], [4, 260], [4, 268], [5, 24], [5, 29], [5, 56], [5, 58], [5, 67], [5, 70], [5, 89], [5, 94], [5, 137], [5, 157], [5, 163], [5, 187], [5, 200], [5, 215], [5, 219], [5, 240], [5, 250], [5, 275], [5, 278], [6, 13], [6, 17], [6, 18], [6, 21], [6, 38], [6, 40], [6, 55], [6, 58], [6, 70], [6, 73], [6, 101], [6, 108], [6, 128], [6, 139], [6, 142], [6, 146], [6, 164], [6, 190], [6, 192], [6, 193], [6, 223], [6, 235], [6, 260], [6, 263], [6, 280], [6, 286], [6, 287], [6, 288], [6, 299], [7, 11], [7, 18], [7, 54], [7, 73], [7, 76], [7, 83], [7, 93], [7, 139], [7, 146], [7, 159], [7, 177], [7, 196], [7, 208], [7, 212], [7, 231], [7, 241], [7, 275], [7, 278], [7, 282], [7, 292], [7, 293], [8, 15], [8, 30], [8, 53], [8, 82], [8, 93], [8, 98], [8, 112], [8, 116], [8, 119], [8, 124], [8, 189], [8, 195], [8, 208], [8, 213], [8, 216], [8, 248], [8, 263], [9, 11], [9, 14], [9, 19], [9, 27], [9, 41], [9, 57], [9, 87], [9, 97], [9, 112], [9, 116], [9, 139], [9, 151], [9, 152], [9, 153], [9, 154], [9, 156], [9, 168], [9, 184], [9, 201], [9, 207], [9, 244], [9, 247], [9, 252], [9, 266], [9, 271], [9, 279], [9, 280], [9, 289], [9, 290], [10, 12], [10, 41], [10, 62], [10, 64], [10, 89], [10, 101], [10, 140], [10, 148], [10, 160], [10, 185], [10, 193], [10, 215], [10, 238], [10, 246], [10, 256], [10, 257], [10, 261], [11, 48], [11, 71], [11, 85], [11, 88], [11, 106], [11, 136], [11, 151], [11, 153], [11, 156], [11, 161], [11, 195], [11, 203], [11, 240], [11, 247], [11, 267], [11, 287], [12, 26], [12, 60], [12, 66], [12, 68], [12, 71], [12, 73], [12, 115], [12, 116], [12, 132], [12, 133], [12, 161], [12, 170], [12, 180], [12, 199], [12, 216], [12, 230], [12, 239], [12, 253], [12, 265], [12, 291], [12, 293], [13, 16], [13, 26], [13, 34], [13, 37], [13, 44], [13, 46], [13, 54], [13, 67], [13, 125], [13, 146], [13, 156], [13, 200], [13, 215], [13, 222], [13, 224], [13, 243], [13, 264], [13, 266], [13, 282], [13, 284], [14, 17], [14, 33], [14, 45], [14, 47], [14, 51], [14, 53], [14, 54], [14, 82], [14, 96], [14, 146], [14, 158], [14, 188], [14, 189], [14, 208], [14, 214], [14, 228], [14, 243], [14, 248], [14, 259], [14, 266], [14, 271], [14, 275], [14, 298], [15, 28], [15, 38], [15, 45], [15, 72], [15, 76], [15, 86], [15, 121], [15, 131], [15, 164], [15, 176], [15, 178], [15, 251], [15, 252], [15, 292], [15, 297], [16, 18], [16, 39], [16, 44], [16, 47], [16, 64], [16, 91], [16, 131], [16, 159], [16, 165], [16, 185], [16, 200], [16, 280], [16, 281], [16, 292], [16, 295], [17, 44], [17, 72], [17, 73], [17, 93], [17, 109], [17, 140], [17, 154], [17, 172], [17, 208], [17, 218], [17, 292], [18, 44], [18, 85], [18, 95], [18, 108], [18, 136], [18, 165], [18, 173], [18, 178], [18, 190], [18, 209], [18, 253], [18, 255], [18, 260], [18, 293], [19, 37], [19, 49], [19, 58], [19, 67], [19, 69], [19, 75], [19, 83], [19, 86], [19, 93], [19, 106], [19, 112], [19, 156], [19, 166], [19, 175], [19, 184], [19, 191], [19, 202], [19, 205], [19, 237], [19, 256], [19, 272], [19, 273], [19, 275], [20, 22], [20, 42], [20, 80], [20, 88], [20, 92], [20, 100], [20, 107], [20, 112], [20, 123], [20, 147], [20, 156], [20, 190], [20, 201], [20, 216], [20, 223], [20, 227], [20, 279], [20, 299], [21, 27], [21, 65], [21, 66], [21, 72], [21, 79], [21, 81], [21, 89], [21, 121], [21, 129], [21, 136], [21, 175], [21, 184], [21, 190], [21, 194], [21, 223], [21, 240], [21, 276], [21, 281], [21, 291], [22, 26], [22, 76], [22, 85], [22, 104], [22, 108], [22, 123], [22, 143], [22, 157], [22, 229], [22, 251], [22, 277], [22, 278], [22, 279], [23, 51], [23, 63], [23, 68], [23, 92], [23, 97], [23, 124], [23, 146], [23, 149], [23, 171], [23, 221], [23, 259], [23, 263], [23, 267], [23, 271], [23, 279], [24, 34], [24, 37], [24, 44], [24, 50], [24, 93], [24, 99], [24, 101], [24, 109], [24, 124], [24, 131], [24, 149], [24, 155], [24, 156], [24, 182], [24, 187], [24, 200], [24, 223], [24, 226], [24, 233], [24, 250], [24, 256], [25, 31], [25, 52], [25, 56], [25, 157], [25, 161], [25, 178], [25, 185], [25, 208], [25, 215], [25, 254], [25, 278], [25, 294], [25, 297], [26, 40], [26, 60], [26, 87], [26, 105], [26, 108], [26, 128], [26, 152], [26, 155], [26, 193], [26, 200], [26, 208], [26, 238], [26, 255], [26, 257], [26, 278], [26, 279], [27, 34], [27, 43], [27, 51], [27, 61], [27, 65], [27, 91], [27, 93], [27, 96], [27, 131], [27, 132], [27, 135], [27, 136], [27, 139], [27, 153], [27, 175], [27, 190], [27, 214], [27, 284], [27, 297], [28, 38], [28, 87], [28, 90], [28, 102], [28, 119], [28, 123], [28, 169], [28, 175], [28, 179], [28, 215], [28, 218], [28, 237], [28, 252], [28, 271], [29, 34], [29, 40], [29, 64], [29, 68], [29, 83], [29, 88], [29, 91], [29, 105], [29, 125], [29, 141], [29, 144], [29, 157], [29, 172], [29, 200], [29, 201], [29, 223], [29, 238], [29, 250], [29, 286], [30, 46], [30, 65], [30, 66], [30, 70], [30, 78], [30, 101], [30, 113], [30, 129], [30, 139], [30, 193], [30, 196], [30, 201], [30, 217], [30, 239], [30, 266], [30, 272], [30, 286], [30, 290], [31, 40], [31, 58], [31, 60], [31, 147], [31, 148], [31, 168], [31, 179], [31, 199], [31, 202], [31, 224], [31, 230], [31, 239], [31, 258], [31, 293], [32, 35], [32, 42], [32, 46], [32, 81], [32, 82], [32, 90], [32, 92], [32, 95], [32, 101], [32, 114], [32, 123], [32, 135], [32, 136], [32, 139], [32, 169], [32, 194], [32, 205], [32, 210], [32, 211], [32, 218], [32, 228], [32, 236], [32, 258], [32, 274], [32, 284], [33, 43], [33, 66], [33, 75], [33, 98], [33, 111], [33, 141], [33, 147], [33, 160], [33, 182], [33, 186], [33, 189], [33, 199], [33, 216], [33, 226], [33, 260], [33, 270], [33, 277], [33, 288], [34, 38], [34, 43], [34, 64], [34, 71], [34, 73], [34, 108], [34, 120], [34, 128], [34, 132], [34, 133], [34, 135], [34, 137], [34, 146], [34, 147], [34, 184], [34, 188], [34, 197], [34, 215], [34, 216], [34, 235], [35, 95], [35, 116], [35, 141], [35, 148], [35, 152], [35, 160], [35, 176], [35, 185], [35, 215], [35, 222], [35, 240], [35, 247], [35, 251], [35, 267], [35, 279], [36, 43], [36, 48], [36, 89], [36, 93], [36, 120], [36, 142], [36, 165], [36, 207], [36, 208], [36, 210], [36, 222], [36, 225], [36, 230], [36, 260], [36, 269], [36, 272], [36, 296], [37, 45], [37, 53], [37, 87], [37, 99], [37, 141], [37, 150], [37, 188], [37, 197], [37, 201], [37, 204], [37, 206], [37, 227], [37, 229], [37, 232], [37, 248], [38, 56], [38, 65], [38, 70], [38, 111], [38, 112], [38, 119], [38, 147], [38, 154], [38, 161], [38, 165], [38, 177], [38, 179], [38, 189], [38, 190], [38, 208], [38, 226], [38, 246], [39, 46], [39, 58], [39, 63], [39, 71], [39, 72], [39, 97], [39, 105], [39, 106], [39, 116], [39, 127], [39, 133], [39, 158], [39, 170], [39, 172], [39, 176], [39, 189], [39, 206], [39, 210], [39, 244], [39, 255], [39, 258], [39, 261], [39, 287], [40, 49], [40, 57], [40, 61], [40, 69], [40, 80], [40, 96], [40, 103], [40, 107], [40, 114], [40, 121], [40, 147], [40, 150], [40, 172], [40, 186], [40, 194], [40, 197], [40, 208], [40, 217], [40, 218], [40, 240], [40, 252], [40, 254], [40, 281], [40, 286], [40, 291], [40, 292], [41, 52], [41, 56], [41, 65], [41, 79], [41, 115], [41, 158], [41, 173], [41, 182], [41, 198], [41, 264], [41, 291], [42, 67], [42, 76], [42, 77], [42, 83], [42, 91], [42, 96], [42, 101], [42, 126], [42, 158], [42, 171], [42, 231], [42, 258], [42, 266], [42, 275], [42, 277], [42, 291], [43, 65], [43, 95], [43, 102], [43, 129], [43, 138], [43, 179], [43, 184], [43, 190], [43, 231], [43, 244], [43, 263], [43, 264], [43, 294], [44, 49], [44, 71], [44, 92], [44, 145], [44, 151], [44, 162], [44, 171], [44, 175], [44, 179], [44, 188], [44, 229], [44, 235], [44, 238], [44, 243], [44, 244], [44, 261], [44, 271], [44, 277], [44, 292], [45, 46], [45, 50], [45, 51], [45, 115], [45, 116], [45, 146], [45, 151], [45, 157], [45, 175], [45, 184], [45, 241], [45, 250], [45, 253], [45, 258], [45, 259], [45, 272], [45, 295], [46, 67], [46, 69], [46, 79], [46, 95], [46, 103], [46, 120], [46, 169], [46, 182], [46, 209], [46, 210], [46, 213], [46, 216], [47, 59], [47, 62], [47, 79], [47, 87], [47, 107], [47, 109], [47, 124], [47, 127], [47, 129], [47, 146], [47, 154], [47, 198], [47, 201], [47, 214], [47, 219], [47, 228], [47, 240], [47, 242], [47, 271], [47, 278], [48, 60], [48, 62], [48, 77], [48, 82], [48, 105], [48, 106], [48, 130], [48, 139], [48, 145], [48, 146], [48, 169], [48, 276], [48, 294], [49, 64], [49, 78], [49, 79], [49, 84], [49, 96], [49, 116], [49, 126], [49, 129], [49, 130], [49, 134], [49, 135], [49, 143], [49, 147], [49, 194], [49, 204], [49, 230], [49, 257], [49, 264], [49, 279], [50, 64], [50, 74], [50, 94], [50, 95], [50, 105], [50, 114], [50, 115], [50, 127], [50, 135], [50, 182], [50, 190], [50, 200], [51, 70], [51, 82], [51, 83], [51, 92], [51, 102], [51, 130], [51, 155], [51, 170], [51, 175], [51, 177], [51, 183], [51, 184], [51, 186], [51, 198], [51, 200], [51, 206], [51, 220], [51, 229], [51, 235], [51, 253], [51, 258], [51, 259], [51, 272], [51, 275], [51, 280], [51, 285], [51, 286], [52, 69], [52, 79], [52, 97], [52, 102], [52, 139], [52, 146], [52, 150], [52, 169], [52, 179], [52, 180], [52, 208], [52, 256], [52, 267], [52, 279], [52, 294], [53, 94], [53, 98], [53, 119], [53, 144], [53, 184], [53, 234], [53, 242], [53, 265], [53, 273], [54, 73], [54, 82], [54, 88], [54, 130], [54, 161], [54, 169], [54, 183], [54, 191], [54, 192], [54, 208], [54, 244], [54, 285], [55, 80], [55, 104], [55, 123], [55, 143], [55, 164], [55, 187], [55, 193], [55, 224], [55, 230], [55, 266], [55, 278], [56, 67], [56, 94], [56, 103], [56, 115], [56, 129], [56, 138], [56, 208], [56, 243], [56, 255], [56, 259], [56, 263], [56, 291], [57, 95], [57, 116], [57, 124], [57, 126], [57, 176], [57, 195], [57, 199], [57, 200], [57, 210], [57, 240], [57, 255], [57, 298], [58, 65], [58, 78], [58, 103], [58, 108], [58, 115], [58, 132], [58, 143], [58, 161], [58, 169], [58, 178], [58, 192], [58, 196], [58, 204], [58, 233], [58, 235], [58, 239], [58, 289], [58, 297], [59, 72], [59, 77], [59, 98], [59, 104], [59, 121], [59, 143], [59, 150], [59, 152], [59, 163], [59, 184], [59, 228], [59, 236], [59, 259], [59, 263], [59, 291], [60, 64], [60, 94], [60, 119], [60, 122], [60, 142], [60, 148], [60, 169], [60, 177], [60, 193], [60, 196], [60, 197], [60, 228], [60, 265], [60, 282], [60, 292], [61, 86], [61, 103], [61, 116], [61, 147], [61, 170], [61, 218], [61, 290], [62, 113], [62, 114], [62, 129], [62, 141], [62, 193], [62, 209], [62, 210], [62, 213], [62, 219], [62, 220], [62, 240], [62, 262], [62, 285], [62, 299], [63, 77], [63, 87], [63, 90], [63, 95], [63, 100], [63, 129], [63, 164], [63, 176], [63, 193], [63, 282], [63, 290], [63, 291], [64, 67], [64, 101], [64, 122], [64, 130], [64, 156], [64, 185], [64, 209], [64, 212], [64, 250], [64, 253], [64, 264], [65, 92], [65, 103], [65, 124], [65, 132], [65, 154], [65, 189], [65, 206], [65, 276], [65, 298], [66, 72], [66, 73], [66, 76], [66, 82], [66, 121], [66, 167], [66, 180], [66, 196], [66, 200], [66, 209], [66, 214], [66, 225], [66, 241], [66, 242], [66, 272], [66, 289], [66, 297], [66, 298], [67, 82], [67, 94], [67, 112], [67, 124], [67, 155], [67, 157], [67, 180], [67, 183], [67, 193], [67, 202], [67, 220], [67, 237], [67, 258], [67, 268], [67, 275], [67, 279], [68, 115], [68, 121], [68, 122], [68, 136], [68, 148], [68, 161], [68, 169], [68, 174], [68, 176], [68, 190], [68, 211], [68, 263], [68, 276], [68, 297], [68, 298], [69, 83], [69, 89], [69, 107], [69, 125], [69, 128], [69, 137], [69, 146], [69, 148], [69, 158], [69, 166], [69, 168], [69, 204], [69, 236], [69, 238], [69, 241], [69, 251], [69, 256], [69, 277], [69, 278], [69, 287], [70, 80], [70, 81], [70, 106], [70, 107], [70, 128], [70, 143], [70, 150], [70, 154], [70, 165], [70, 167], [70, 187], [70, 245], [70, 258], [70, 293], [70, 296], [71, 91], [71, 114], [71, 126], [71, 141], [71, 171], [71, 179], [71, 180], [71, 182], [71, 205], [71, 207], [71, 230], [71, 245], [71, 253], [71, 277], [72, 76], [72, 77], [72, 80], [72, 96], [72, 115], [72, 129], [72, 158], [72, 163], [72, 181], [72, 185], [72, 248], [72, 254], [73, 112], [73, 115], [73, 123], [73, 131], [73, 136], [73, 146], [73, 171], [73, 172], [73, 179], [73, 191], [73, 200], [73, 221], [73, 228], [73, 231], [73, 249], [73, 268], [73, 283], [73, 284], [73, 291], [74, 96], [74, 109], [74, 119], [74, 125], [74, 140], [74, 142], [74, 151], [74, 156], [74, 186], [74, 187], [74, 200], [74, 229], [74, 249], [74, 294], [74, 296], [75, 79], [75, 97], [75, 101], [75, 121], [75, 128], [75, 134], [75, 135], [75, 138], [75, 184], [75, 193], [75, 210], [75, 211], [75, 213], [75, 217], [75, 220], [75, 271], [75, 275], [76, 81], [76, 103], [76, 117], [76, 136], [76, 139], [76, 142], [76, 150], [76, 179], [76, 205], [76, 212], [76, 217], [76, 218], [76, 242], [76, 244], [76, 250], [76, 262], [76, 265], [76, 291], [77, 91], [77, 110], [77, 142], [77, 147], [77, 149], [77, 150], [77, 159], [77, 208], [77, 264], [77, 273], [77, 279], [77, 286], [78, 86], [78, 98], [78, 118], [78, 121], [78, 136], [78, 177], [78, 183], [78, 202], [78, 204], [78, 210], [78, 231], [78, 245], [78, 261], [78, 281], [78, 286], [79, 81], [79, 83], [79, 85], [79, 89], [79, 103], [79, 104], [79, 105], [79, 106], [79, 112], [79, 133], [79, 141], [79, 151], [79, 160], [79, 165], [79, 170], [79, 208], [79, 233], [79, 241], [79, 262], [79, 265], [79, 276], [79, 282], [79, 296], [80, 91], [80, 96], [80, 117], [80, 141], [80, 143], [80, 194], [80, 217], [80, 233], [80, 267], [81, 88], [81, 126], [81, 136], [81, 142], [81, 167], [81, 168], [81, 173], [81, 236], [81, 239], [81, 243], [81, 277], [81, 283], [82, 103], [82, 137], [82, 156], [82, 158], [82, 179], [82, 183], [82, 190], [82, 191], [82, 210], [82, 213], [82, 240], [82, 241], [82, 252], [82, 258], [82, 267], [82, 299], [83, 97], [83, 113], [83, 124], [83, 128], [83, 130], [83, 153], [83, 159], [83, 201], [83, 223], [83, 225], [83, 240], [83, 275], [83, 276], [83, 287], [83, 297], [84, 89], [84, 98], [84, 115], [84, 161], [84, 178], [84, 189], [84, 209], [84, 223], [84, 252], [84, 290], [84, 295], [85, 177], [85, 218], [85, 267], [85, 273], [85, 275], [85, 283], [85, 287], [86, 90], [86, 115], [86, 168], [86, 185], [86, 200], [86, 215], [86, 221], [86, 231], [86, 236], [86, 257], [86, 258], [86, 263], [86, 298], [87, 88], [87, 100], [87, 117], [87, 124], [87, 138], [87, 145], [87, 159], [87, 187], [87, 265], [87, 277], [88, 110], [88, 124], [88, 179], [88, 192], [88, 205], [88, 218], [88, 227], [88, 229], [88, 268], [88, 281], [88, 293], [89, 106], [89, 152], [89, 169], [89, 180], [89, 183], [89, 188], [89, 201], [89, 206], [89, 216], [89, 230], [89, 238], [89, 271], [89, 279], [89, 285], [89, 287], [90, 113], [90, 121], [90, 127], [90, 135], [90, 141], [90, 158], [90, 172], [90, 189], [90, 205], [90, 211], [90, 214], [90, 219], [90, 231], [90, 232], [90, 233], [90, 235], [90, 236], [90, 239], [90, 281], [91, 98], [91, 99], [91, 107], [91, 116], [91, 126], [91, 133], [91, 144], [91, 179], [91, 191], [91, 209], [91, 212], [91, 217], [91, 221], [91, 232], [91, 247], [91, 270], [91, 274], [91, 295], [92, 110], [92, 125], [92, 127], [92, 142], [92, 144], [92, 168], [92, 187], [92, 190], [92, 222], [92, 229], [92, 231], [92, 244], [92, 247], [92, 249], [92, 285], [93, 99], [93, 102], [93, 106], [93, 149], [93, 207], [93, 209], [93, 213], [93, 233], [93, 277], [93, 285], [93, 286], [94, 120], [94, 129], [94, 159], [94, 179], [94, 190], [94, 200], [94, 213], [94, 224], [94, 225], [94, 294], [95, 102], [95, 110], [95, 116], [95, 118], [95, 137], [95, 139], [95, 148], [95, 152], [95, 181], [95, 188], [95, 218], [95, 223], [95, 230], [95, 246], [95, 255], [95, 256], [95, 258], [95, 264], [95, 267], [95, 268], [95, 274], [95, 278], [95, 281], [95, 290], [95, 294], [96, 97], [96, 100], [96, 102], [96, 139], [96, 144], [96, 147], [96, 154], [96, 173], [96, 192], [96, 195], [96, 214], [96, 215], [96, 216], [96, 220], [96, 223], [96, 261], [96, 297], [97, 110], [97, 118], [97, 132], [97, 158], [97, 187], [97, 215], [97, 237], [97, 254], [97, 267], [97, 272], [98, 124], [98, 135], [98, 136], [98, 138], [98, 141], [98, 150], [98, 206], [98, 211], [98, 217], [98, 221], [98, 234], [98, 250], [98, 265], [98, 278], [98, 289], [98, 299], [99, 119], [99, 146], [99, 174], [99, 220], [99, 227], [99, 234], [99, 235], [99, 242], [99, 251], [99, 263], [100, 143], [100, 165], [100, 173], [100, 190], [100, 198], [100, 228], [100, 233], [100, 244], [100, 253], [100, 254], [100, 258], [100, 275], [100, 279], [100, 295], [101, 112], [101, 116], [101, 160], [101, 181], [101, 207], [101, 208], [101, 210], [101, 223], [101, 229], [101, 232], [101, 243], [101, 266], [101, 291], [101, 299], [102, 110], [102, 122], [102, 139], [102, 141], [102, 153], [102, 172], [102, 173], [102, 196], [102, 205], [102, 236], [102, 237], [102, 253], [102, 291], [102, 299], [103, 124], [103, 139], [103, 140], [103, 187], [103, 194], [103, 205], [103, 207], [103, 213], [103, 248], [103, 254], [104, 121], [104, 125], [104, 134], [104, 158], [104, 167], [104, 171], [104, 179], [104, 189], [104, 201], [104, 208], [104, 218], [104, 221], [104, 247], [104, 267], [105, 128], [105, 129], [105, 142], [105, 151], [105, 155], [105, 160], [105, 168], [105, 176], [105, 199], [105, 205], [105, 206], [105, 214], [105, 217], [105, 227], [105, 258], [105, 278], [105, 280], [105, 282], [105, 283], [105, 294], [105, 298], [106, 113], [106, 119], [106, 125], [106, 133], [106, 138], [106, 145], [106, 155], [106, 157], [106, 173], [106, 175], [106, 185], [106, 197], [106, 204], [106, 212], [106, 214], [106, 217], [106, 230], [106, 239], [106, 246], [106, 251], [106, 252], [106, 261], [106, 268], [106, 277], [106, 283], [106, 285], [106, 297], [107, 114], [107, 136], [107, 147], [107, 153], [107, 166], [107, 200], [107, 208], [107, 219], [107, 257], [107, 261], [107, 267], [107, 268], [107, 291], [108, 120], [108, 126], [108, 127], [108, 138], [108, 150], [108, 181], [108, 208], [108, 224], [108, 233], [108, 245], [108, 258], [109, 119], [109, 159], [109, 183], [109, 232], [109, 245], [109, 247], [109, 250], [109, 267], [110, 115], [110, 138], [110, 195], [110, 200], [110, 206], [110, 207], [110, 215], [110, 239], [110, 278], [111, 141], [111, 158], [111, 182], [111, 245], [111, 264], [111, 272], [111, 280], [111, 297], [112, 150], [112, 185], [112, 188], [112, 219], [112, 222], [112, 228], [112, 240], [112, 252], [112, 275], [113, 128], [113, 130], [113, 143], [113, 151], [113, 172], [113, 194], [113, 204], [113, 254], [113, 259], [113, 270], [113, 283], [113, 299], [114, 126], [114, 149], [114, 159], [114, 178], [114, 207], [114, 213], [114, 229], [114, 240], [114, 248], [114, 252], [114, 275], [114, 280], [115, 116], [115, 124], [115, 137], [115, 157], [115, 160], [115, 163], [115, 197], [115, 217], [115, 219], [115, 233], [115, 235], [115, 246], [115, 265], [115, 267], [115, 289], [116, 129], [116, 149], [116, 151], [116, 156], [116, 159], [116, 182], [116, 218], [116, 219], [116, 226], [116, 235], [116, 237], [116, 238], [116, 273], [116, 296], [117, 120], [117, 133], [117, 158], [117, 162], [117, 182], [117, 217], [117, 239], [117, 280], [117, 281], [117, 295], [118, 135], [118, 138], [118, 141], [118, 147], [118, 194], [118, 226], [118, 244], [118, 286], [119, 134], [119, 136], [119, 162], [119, 163], [119, 168], [119, 170], [119, 171], [119, 188], [119, 194], [119, 195], [119, 196], [119, 205], [119, 210], [119, 224], [119, 250], [119, 254], [119, 259], [119, 261], [119, 265], [119, 270], [119, 271], [119, 281], [120, 133], [120, 153], [120, 166], [120, 172], [120, 198], [120, 203], [120, 246], [120, 254], [120, 273], [120, 285], [120, 286], [120, 295], [121, 141], [121, 142], [121, 166], [121, 169], [121, 187], [121, 229], [121, 257], [122, 125], [122, 130], [122, 153], [122, 179], [122, 191], [122, 224], [122, 233], [122, 241], [122, 248], [122, 253], [122, 257], [122, 276], [122, 296], [123, 130], [123, 131], [123, 170], [123, 212], [123, 229], [123, 239], [123, 283], [123, 294], [123, 296], [124, 147], [124, 151], [124, 161], [124, 171], [124, 191], [124, 193], [124, 225], [124, 226], [124, 231], [124, 235], [124, 243], [124, 244], [124, 245], [124, 255], [124, 256], [124, 277], [125, 152], [125, 157], [125, 165], [125, 173], [125, 180], [125, 207], [125, 230], [125, 256], [125, 271], [125, 276], [125, 280], [126, 134], [126, 139], [126, 141], [126, 146], [126, 156], [126, 179], [126, 204], [126, 221], [126, 261], [126, 265], [126, 276], [126, 285], [126, 291], [126, 298], [127, 131], [127, 154], [127, 172], [127, 231], [127, 277], [128, 147], [128, 176], [128, 179], [128, 195], [128, 196], [128, 220], [128, 225], [128, 234], [128, 254], [128, 292], [128, 295], [129, 141], [129, 147], [129, 165], [129, 182], [129, 199], [129, 211], [129, 239], [129, 248], [129, 258], [129, 272], [129, 278], [130, 136], [130, 149], [130, 150], [130, 164], [130, 167], [130, 168], [130, 183], [130, 196], [130, 202], [130, 203], [130, 215], [130, 229], [130, 230], [130, 242], [130, 265], [130, 280], [130, 284], [130, 292], [130, 298], [131, 142], [131, 159], [131, 160], [131, 184], [131, 238], [131, 240], [131, 244], [131, 266], [131, 268], [131, 286], [131, 294], [132, 137], [132, 156], [132, 158], [132, 159], [132, 173], [132, 183], [132, 184], [132, 185], [132, 195], [132, 200], [132, 204], [132, 223], [132, 235], [132, 251], [132, 256], [132, 263], [132, 282], [132, 291], [133, 134], [133, 136], [133, 146], [133, 150], [133, 182], [133, 211], [133, 245], [133, 277], [133, 279], [134, 149], [134, 162], [134, 168], [134, 170], [134, 207], [134, 220], [134, 239], [134, 253], [134, 277], [134, 287], [135, 141], [135, 149], [135, 169], [135, 232], [135, 276], [136, 148], [136, 196], [136, 209], [136, 221], [136, 242], [136, 280], [137, 164], [137, 180], [137, 200], [137, 239], [137, 241], [137, 257], [137, 276], [137, 282], [138, 198], [138, 206], [138, 207], [138, 220], [138, 250], [138, 253], [138, 263], [138, 277], [138, 280], [138, 283], [138, 292], [138, 296], [139, 177], [139, 204], [139, 206], [139, 213], [139, 216], [139, 232], [139, 243], [139, 258], [139, 260], [139, 262], [139, 267], [139, 277], [140, 146], [140, 148], [140, 175], [140, 178], [140, 210], [140, 228], [140, 251], [140, 259], [140, 277], [141, 157], [141, 160], [141, 167], [141, 176], [141, 185], [141, 207], [141, 213], [141, 224], [141, 232], [141, 235], [141, 240], [141, 265], [141, 277], [141, 287], [142, 153], [142, 156], [142, 180], [142, 188], [142, 194], [142, 197], [142, 216], [142, 261], [143, 146], [143, 181], [143, 182], [143, 183], [143, 192], [143, 193], [143, 200], [143, 215], [143, 216], [143, 225], [143, 232], [143, 236], [143, 239], [143, 248], [143, 251], [143, 266], [143, 269], [143, 271], [143, 276], [143, 288], [144, 159], [144, 188], [144, 195], [144, 208], [144, 239], [144, 270], [144, 276], [144, 294], [145, 162], [145, 176], [145, 190], [145, 231], [145, 241], [145, 248], [145, 256], [145, 266], [145, 284], [145, 294], [146, 188], [146, 197], [146, 207], [146, 214], [146, 223], [146, 231], [146, 241], [146, 244], [146, 264], [146, 290], [147, 195], [147, 215], [147, 281], [147, 290], [148, 170], [148, 188], [148, 209], [148, 299], [149, 158], [149, 196], [149, 205], [149, 216], [149, 240], [149, 272], [149, 286], [150, 154], [150, 169], [150, 198], [150, 214], [150, 243], [150, 244], [150, 248], [150, 285], [150, 298], [151, 152], [151, 178], [151, 194], [151, 217], [151, 231], [151, 244], [151, 249], [151, 272], [151, 277], [151, 279], [151, 288], [151, 299], [152, 166], [152, 179], [152, 214], [152, 216], [152, 221], [152, 238], [152, 241], [152, 255], [152, 256], [153, 178], [153, 189], [153, 248], [153, 262], [153, 264], [153, 294], [154, 158], [154, 189], [154, 204], [154, 225], [154, 240], [154, 248], [154, 262], [154, 266], [154, 275], [154, 292], [154, 293], [155, 194], [156, 162], [156, 205], [156, 213], [156, 222], [156, 233], [156, 270], [156, 272], [156, 273], [156, 274], [156, 292], [157, 165], [157, 176], [157, 178], [157, 180], [157, 183], [157, 185], [157, 206], [157, 280], [158, 169], [158, 189], [158, 199], [158, 229], [158, 234], [158, 249], [158, 259], [158, 271], [158, 274], [158, 291], [158, 295], [158, 296], [159, 169], [159, 270], [159, 275], [159, 283], [160, 194], [160, 197], [160, 211], [160, 284], [160, 286], [161, 198], [161, 199], [161, 251], [161, 279], [161, 283], [162, 206], [162, 218], [162, 279], [163, 171], [163, 194], [163, 228], [163, 232], [163, 270], [163, 286], [164, 178], [164, 203], [164, 224], [164, 227], [164, 230], [164, 243], [164, 251], [164, 279], [164, 280], [164, 295], [165, 186], [165, 203], [165, 219], [166, 176], [166, 198], [166, 202], [166, 215], [166, 245], [166, 284], [167, 171], [167, 184], [167, 204], [167, 206], [167, 208], [167, 234], [167, 235], [167, 258], [167, 263], [167, 286], [167, 298], [168, 190], [168, 212], [168, 215], [168, 226], [168, 249], [168, 255], [168, 275], [168, 289], [169, 170], [169, 177], [169, 199], [169, 202], [169, 207], [169, 209], [169, 225], [169, 233], [169, 247], [169, 258], [169, 259], [169, 264], [169, 293], [169, 299], [170, 180], [170, 225], [170, 232], [170, 239], [170, 255], [170, 266], [170, 277], [170, 278], [170, 279], [170, 288], [170, 289], [171, 190], [171, 196], [171, 206], [171, 239], [171, 243], [171, 257], [171, 263], [171, 267], [171, 287], [172, 175], [172, 212], [172, 218], [172, 225], [172, 229], [172, 257], [172, 262], [172, 273], [172, 277], [172, 286], [172, 294], [173, 174], [173, 181], [173, 194], [173, 208], [173, 211], [173, 220], [173, 227], [173, 238], [173, 261], [173, 263], [173, 281], [174, 181], [174, 200], [174, 202], [174, 248], [174, 252], [174, 259], [174, 261], [174, 267], [174, 268], [174, 273], [175, 193], [175, 198], [175, 222], [175, 223], [175, 235], [175, 241], [175, 242], [175, 243], [175, 247], [175, 257], [175, 274], [176, 179], [176, 194], [176, 201], [176, 213], [176, 215], [176, 235], [176, 243], [176, 274], [176, 290], [177, 197], [177, 202], [177, 234], [177, 245], [178, 195], [178, 197], [178, 203], [178, 210], [178, 228], [178, 248], [178, 252], [178, 257], [178, 269], [178, 270], [178, 273], [178, 277], [178, 281], [178, 282], [179, 186], [179, 191], [179, 196], [179, 198], [179, 199], [179, 225], [179, 245], [179, 253], [179, 275], [179, 280], [179, 289], [180, 182], [180, 200], [180, 236], [180, 237], [180, 264], [180, 265], [180, 272], [180, 288], [180, 295], [181, 182], [181, 218], [181, 223], [181, 241], [181, 250], [181, 254], [181, 268], [181, 281], [181, 290], [181, 294], [181, 299], [182, 247], [182, 256], [182, 266], [182, 272], [182, 295], [183, 290], [184, 197], [184, 202], [184, 235], [184, 251], [184, 276], [184, 281], [184, 284], [184, 294], [185, 198], [185, 224], [185, 226], [185, 234], [185, 246], [185, 263], [185, 280], [185, 287], [185, 288], [185, 293], [186, 199], [186, 205], [186, 214], [186, 218], [186, 271], [186, 273], [186, 286], [186, 287], [186, 293], [186, 294], [187, 200], [187, 202], [187, 229], [187, 231], [187, 250], [187, 257], [187, 260], [187, 276], [187, 290], [188, 202], [188, 226], [188, 229], [188, 232], [188, 237], [188, 271], [188, 278], [189, 190], [189, 194], [189, 196], [189, 213], [189, 246], [189, 257], [189, 269], [189, 273], [189, 280], [190, 207], [190, 218], [190, 221], [190, 233], [190, 297], [190, 298], [191, 231], [191, 268], [191, 270], [191, 287], [191, 290], [192, 202], [192, 207], [192, 214], [192, 240], [192, 258], [192, 267], [192, 268], [192, 292], [192, 298], [193, 206], [193, 209], [193, 217], [193, 218], [193, 228], [193, 241], [193, 257], [193, 273], [193, 275], [193, 278], [194, 199], [194, 221], [194, 238], [194, 248], [194, 274], [194, 275], [194, 287], [194, 297], [195, 201], [195, 205], [195, 207], [195, 214], [195, 230], [195, 236], [195, 240], [195, 270], [196, 198], [196, 205], [196, 211], [196, 231], [196, 236], [196, 268], [196, 293], [196, 296], [197, 203], [197, 223], [197, 234], [197, 267], [197, 277], [197, 282], [197, 293], [197, 294], [198, 200], [198, 215], [198, 241], [198, 244], [198, 290], [198, 293], [199, 201], [199, 204], [199, 214], [199, 233], [199, 249], [199, 256], [199, 277], [200, 219], [200, 221], [200, 226], [200, 233], [200, 241], [200, 251], [200, 260], [200, 272], [200, 275], [200, 278], [200, 281], [200, 286], [200, 296], [201, 238], [201, 269], [201, 287], [201, 289], [202, 203], [202, 242], [202, 251], [202, 279], [202, 280], [202, 289], [203, 253], [204, 216], [204, 235], [204, 246], [205, 210], [205, 270], [205, 287], [205, 294], [206, 215], [206, 233], [206, 255], [206, 273], [206, 283], [207, 247], [207, 252], [207, 257], [207, 261], [207, 272], [207, 293], [208, 232], [208, 237], [208, 239], [208, 244], [208, 253], [208, 263], [208, 273], [208, 295], [209, 231], [209, 286], [210, 236], [210, 253], [211, 224], [211, 230], [211, 240], [211, 248], [211, 255], [211, 276], [211, 277], [211, 287], [212, 219], [212, 225], [212, 229], [212, 243], [212, 250], [212, 286], [212, 295], [213, 218], [213, 243], [213, 260], [213, 272], [213, 286], [214, 218], [214, 249], [214, 265], [214, 289], [214, 296], [215, 220], [215, 234], [215, 253], [215, 264], [215, 271], [215, 282], [215, 290], [216, 251], [216, 263], [216, 275], [216, 276], [216, 286], [216, 297], [217, 221], [217, 251], [217, 254], [217, 257], [217, 262], [217, 278], [217, 299], [218, 224], [218, 244], [218, 247], [218, 252], [218, 288], [219, 220], [219, 228], [219, 275], [219, 277], [219, 283], [219, 296], [220, 221], [220, 226], [220, 248], [220, 284], [221, 264], [221, 267], [221, 269], [221, 277], [222, 231], [222, 248], [222, 261], [222, 264], [222, 270], [222, 288], [223, 239], [223, 261], [223, 263], [223, 279], [224, 227], [224, 245], [224, 249], [224, 252], [224, 266], [224, 270], [224, 286], [225, 237], [225, 241], [226, 235], [226, 241], [226, 258], [226, 274], [226, 275], [226, 277], [226, 287], [226, 295], [226, 297], [227, 249], [227, 252], [227, 275], [227, 276], [227, 277], [228, 249], [228, 253], [228, 261], [228, 278], [228, 291], [228, 293], [228, 298], [229, 241], [229, 257], [229, 276], [229, 279], [229, 289], [230, 281], [231, 259], [231, 265], [232, 244], [232, 254], [232, 256], [232, 258], [233, 235], [233, 254], [233, 255], [233, 256], [233, 262], [233, 292], [233, 295], [234, 250], [234, 260], [234, 270], [234, 284], [235, 250], [235, 252], [235, 257], [235, 258], [235, 273], [235, 279], [235, 296], [236, 258], [236, 266], [237, 246], [237, 247], [237, 251], [237, 285], [238, 248], [238, 250], [238, 279], [239, 262], [239, 270], [239, 281], [239, 285], [239, 290], [239, 299], [240, 260], [240, 283], [240, 294], [241, 253], [241, 256], [241, 260], [241, 262], [242, 250], [242, 259], [242, 282], [243, 259], [243, 284], [243, 286], [243, 287], [244, 246], [244, 266], [244, 268], [244, 276], [244, 279], [244, 297], [245, 258], [245, 262], [245, 276], [245, 281], [246, 284], [246, 293], [247, 250], [247, 255], [247, 279], [248, 258], [248, 270], [248, 278], [249, 264], [249, 281], [249, 297], [249, 298], [250, 290], [251, 296], [252, 255], [252, 279], [253, 269], [253, 290], [254, 295], [255, 261], [256, 260], [256, 282], [256, 289], [256, 290], [257, 268], [257, 269], [257, 299], [258, 261], [258, 272], [259, 277], [259, 298], [260, 273], [260, 274], [260, 276], [260, 288], [261, 268], [261, 291], [261, 299], [262, 273], [262, 289], [262, 294], [265, 268], [266, 273], [267, 280], [267, 296], [268, 290], [269, 289], [269, 293], [270, 272], [273, 276], [273, 282], [273, 291], [274, 277], [274, 285], [275, 279], [275, 295], [276, 297], [278, 281], [278, 288], [279, 299], [280, 289], [282, 292], [283, 285], [283, 292], [286, 288], [286, 291], [286, 293], [287, 288], [287, 290], [289, 290], [290, 297], [292, 293], [293, 299]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s3/solution/solve.sh b/tasks/construct-nppc-dominating-set-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..712bbafc5cab1d57f34057326a4a588b469f873a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [9, 79, 92, 95, 106, 116, 119, 124, 130, 141, 143, 158, 169, 178, 179, 200, 208, 215, 277, 286]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l6-s3/tests/check.py b/tasks/construct-nppc-dominating-set-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s3/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-l6-s3/tests/instance.json b/tasks/construct-nppc-dominating-set-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aec2c547f354f89618c4d61a82f72fedb08dc9f1 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 20], [0, 43], [0, 51], [0, 59], [0, 67], [0, 85], [0, 100], [0, 113], [0, 115], [0, 116], [0, 122], [0, 160], [0, 180], [0, 184], [0, 195], [0, 210], [0, 243], [0, 245], [0, 247], [1, 4], [1, 17], [1, 23], [1, 31], [1, 33], [1, 44], [1, 49], [1, 85], [1, 125], [1, 127], [1, 183], [1, 200], [1, 205], [1, 216], [1, 226], [1, 233], [1, 235], [1, 269], [1, 286], [2, 6], [2, 19], [2, 51], [2, 79], [2, 101], [2, 103], [2, 106], [2, 144], [2, 145], [2, 148], [2, 159], [2, 162], [2, 169], [2, 183], [2, 197], [2, 199], [2, 205], [2, 224], [2, 251], [2, 253], [2, 255], [2, 258], [2, 268], [3, 48], [3, 54], [3, 55], [3, 74], [3, 92], [3, 103], [3, 104], [3, 144], [3, 163], [3, 178], [3, 208], [3, 225], [3, 252], [3, 269], [3, 277], [4, 25], [4, 42], [4, 68], [4, 81], [4, 136], [4, 152], [4, 153], [4, 169], [4, 178], [4, 204], [4, 222], [4, 237], [4, 248], [4, 249], [4, 251], [4, 260], [4, 268], [5, 24], [5, 29], [5, 56], [5, 58], [5, 67], [5, 70], [5, 89], [5, 94], [5, 137], [5, 157], [5, 163], [5, 187], [5, 200], [5, 215], [5, 219], [5, 240], [5, 250], [5, 275], [5, 278], [6, 13], [6, 17], [6, 18], [6, 21], [6, 38], [6, 40], [6, 55], [6, 58], [6, 70], [6, 73], [6, 101], [6, 108], [6, 128], [6, 139], [6, 142], [6, 146], [6, 164], [6, 190], [6, 192], [6, 193], [6, 223], [6, 235], [6, 260], [6, 263], [6, 280], [6, 286], [6, 287], [6, 288], [6, 299], [7, 11], [7, 18], [7, 54], [7, 73], [7, 76], [7, 83], [7, 93], [7, 139], [7, 146], [7, 159], [7, 177], [7, 196], [7, 208], [7, 212], [7, 231], [7, 241], [7, 275], [7, 278], [7, 282], [7, 292], [7, 293], [8, 15], [8, 30], [8, 53], [8, 82], [8, 93], [8, 98], [8, 112], [8, 116], [8, 119], [8, 124], [8, 189], [8, 195], [8, 208], [8, 213], [8, 216], [8, 248], [8, 263], [9, 11], [9, 14], [9, 19], [9, 27], [9, 41], [9, 57], [9, 87], [9, 97], [9, 112], [9, 116], [9, 139], [9, 151], [9, 152], [9, 153], [9, 154], [9, 156], [9, 168], [9, 184], [9, 201], [9, 207], [9, 244], [9, 247], [9, 252], [9, 266], [9, 271], [9, 279], [9, 280], [9, 289], [9, 290], [10, 12], [10, 41], [10, 62], [10, 64], [10, 89], [10, 101], [10, 140], [10, 148], [10, 160], [10, 185], [10, 193], [10, 215], [10, 238], [10, 246], [10, 256], [10, 257], [10, 261], [11, 48], [11, 71], [11, 85], [11, 88], [11, 106], [11, 136], [11, 151], [11, 153], [11, 156], [11, 161], [11, 195], [11, 203], [11, 240], [11, 247], [11, 267], [11, 287], [12, 26], [12, 60], [12, 66], [12, 68], [12, 71], [12, 73], [12, 115], [12, 116], [12, 132], [12, 133], [12, 161], [12, 170], [12, 180], [12, 199], [12, 216], [12, 230], [12, 239], [12, 253], [12, 265], [12, 291], [12, 293], [13, 16], [13, 26], [13, 34], [13, 37], [13, 44], [13, 46], [13, 54], [13, 67], [13, 125], [13, 146], [13, 156], [13, 200], [13, 215], [13, 222], [13, 224], [13, 243], [13, 264], [13, 266], [13, 282], [13, 284], [14, 17], [14, 33], [14, 45], [14, 47], [14, 51], [14, 53], [14, 54], [14, 82], [14, 96], [14, 146], [14, 158], [14, 188], [14, 189], [14, 208], [14, 214], [14, 228], [14, 243], [14, 248], [14, 259], [14, 266], [14, 271], [14, 275], [14, 298], [15, 28], [15, 38], [15, 45], [15, 72], [15, 76], [15, 86], [15, 121], [15, 131], [15, 164], [15, 176], [15, 178], [15, 251], [15, 252], [15, 292], [15, 297], [16, 18], [16, 39], [16, 44], [16, 47], [16, 64], [16, 91], [16, 131], [16, 159], [16, 165], [16, 185], [16, 200], [16, 280], [16, 281], [16, 292], [16, 295], [17, 44], [17, 72], [17, 73], [17, 93], [17, 109], [17, 140], [17, 154], [17, 172], [17, 208], [17, 218], [17, 292], [18, 44], [18, 85], [18, 95], [18, 108], [18, 136], [18, 165], [18, 173], [18, 178], [18, 190], [18, 209], [18, 253], [18, 255], [18, 260], [18, 293], [19, 37], [19, 49], [19, 58], [19, 67], [19, 69], [19, 75], [19, 83], [19, 86], [19, 93], [19, 106], [19, 112], [19, 156], [19, 166], [19, 175], [19, 184], [19, 191], [19, 202], [19, 205], [19, 237], [19, 256], [19, 272], [19, 273], [19, 275], [20, 22], [20, 42], [20, 80], [20, 88], [20, 92], [20, 100], [20, 107], [20, 112], [20, 123], [20, 147], [20, 156], [20, 190], [20, 201], [20, 216], [20, 223], [20, 227], [20, 279], [20, 299], [21, 27], [21, 65], [21, 66], [21, 72], [21, 79], [21, 81], [21, 89], [21, 121], [21, 129], [21, 136], [21, 175], [21, 184], [21, 190], [21, 194], [21, 223], [21, 240], [21, 276], [21, 281], [21, 291], [22, 26], [22, 76], [22, 85], [22, 104], [22, 108], [22, 123], [22, 143], [22, 157], [22, 229], [22, 251], [22, 277], [22, 278], [22, 279], [23, 51], [23, 63], [23, 68], [23, 92], [23, 97], [23, 124], [23, 146], [23, 149], [23, 171], [23, 221], [23, 259], [23, 263], [23, 267], [23, 271], [23, 279], [24, 34], [24, 37], [24, 44], [24, 50], [24, 93], [24, 99], [24, 101], [24, 109], [24, 124], [24, 131], [24, 149], [24, 155], [24, 156], [24, 182], [24, 187], [24, 200], [24, 223], [24, 226], [24, 233], [24, 250], [24, 256], [25, 31], [25, 52], [25, 56], [25, 157], [25, 161], [25, 178], [25, 185], [25, 208], [25, 215], [25, 254], [25, 278], [25, 294], [25, 297], [26, 40], [26, 60], [26, 87], [26, 105], [26, 108], [26, 128], [26, 152], [26, 155], [26, 193], [26, 200], [26, 208], [26, 238], [26, 255], [26, 257], [26, 278], [26, 279], [27, 34], [27, 43], [27, 51], [27, 61], [27, 65], [27, 91], [27, 93], [27, 96], [27, 131], [27, 132], [27, 135], [27, 136], [27, 139], [27, 153], [27, 175], [27, 190], [27, 214], [27, 284], [27, 297], [28, 38], [28, 87], [28, 90], [28, 102], [28, 119], [28, 123], [28, 169], [28, 175], [28, 179], [28, 215], [28, 218], [28, 237], [28, 252], [28, 271], [29, 34], [29, 40], [29, 64], [29, 68], [29, 83], [29, 88], [29, 91], [29, 105], [29, 125], [29, 141], [29, 144], [29, 157], [29, 172], [29, 200], [29, 201], [29, 223], [29, 238], [29, 250], [29, 286], [30, 46], [30, 65], [30, 66], [30, 70], [30, 78], [30, 101], [30, 113], [30, 129], [30, 139], [30, 193], [30, 196], [30, 201], [30, 217], [30, 239], [30, 266], [30, 272], [30, 286], [30, 290], [31, 40], [31, 58], [31, 60], [31, 147], [31, 148], [31, 168], [31, 179], [31, 199], [31, 202], [31, 224], [31, 230], [31, 239], [31, 258], [31, 293], [32, 35], [32, 42], [32, 46], [32, 81], [32, 82], [32, 90], [32, 92], [32, 95], [32, 101], [32, 114], [32, 123], [32, 135], [32, 136], [32, 139], [32, 169], [32, 194], [32, 205], [32, 210], [32, 211], [32, 218], [32, 228], [32, 236], [32, 258], [32, 274], [32, 284], [33, 43], [33, 66], [33, 75], [33, 98], [33, 111], [33, 141], [33, 147], [33, 160], [33, 182], [33, 186], [33, 189], [33, 199], [33, 216], [33, 226], [33, 260], [33, 270], [33, 277], [33, 288], [34, 38], [34, 43], [34, 64], [34, 71], [34, 73], [34, 108], [34, 120], [34, 128], [34, 132], [34, 133], [34, 135], [34, 137], [34, 146], [34, 147], [34, 184], [34, 188], [34, 197], [34, 215], [34, 216], [34, 235], [35, 95], [35, 116], [35, 141], [35, 148], [35, 152], [35, 160], [35, 176], [35, 185], [35, 215], [35, 222], [35, 240], [35, 247], [35, 251], [35, 267], [35, 279], [36, 43], [36, 48], [36, 89], [36, 93], [36, 120], [36, 142], [36, 165], [36, 207], [36, 208], [36, 210], [36, 222], [36, 225], [36, 230], [36, 260], [36, 269], [36, 272], [36, 296], [37, 45], [37, 53], [37, 87], [37, 99], [37, 141], [37, 150], [37, 188], [37, 197], [37, 201], [37, 204], [37, 206], [37, 227], [37, 229], [37, 232], [37, 248], [38, 56], [38, 65], [38, 70], [38, 111], [38, 112], [38, 119], [38, 147], [38, 154], [38, 161], [38, 165], [38, 177], [38, 179], [38, 189], [38, 190], [38, 208], [38, 226], [38, 246], [39, 46], [39, 58], [39, 63], [39, 71], [39, 72], [39, 97], [39, 105], [39, 106], [39, 116], [39, 127], [39, 133], [39, 158], [39, 170], [39, 172], [39, 176], [39, 189], [39, 206], [39, 210], [39, 244], [39, 255], [39, 258], [39, 261], [39, 287], [40, 49], [40, 57], [40, 61], [40, 69], [40, 80], [40, 96], [40, 103], [40, 107], [40, 114], [40, 121], [40, 147], [40, 150], [40, 172], [40, 186], [40, 194], [40, 197], [40, 208], [40, 217], [40, 218], [40, 240], [40, 252], [40, 254], [40, 281], [40, 286], [40, 291], [40, 292], [41, 52], [41, 56], [41, 65], [41, 79], [41, 115], [41, 158], [41, 173], [41, 182], [41, 198], [41, 264], [41, 291], [42, 67], [42, 76], [42, 77], [42, 83], [42, 91], [42, 96], [42, 101], [42, 126], [42, 158], [42, 171], [42, 231], [42, 258], [42, 266], [42, 275], [42, 277], [42, 291], [43, 65], [43, 95], [43, 102], [43, 129], [43, 138], [43, 179], [43, 184], [43, 190], [43, 231], [43, 244], [43, 263], [43, 264], [43, 294], [44, 49], [44, 71], [44, 92], [44, 145], [44, 151], [44, 162], [44, 171], [44, 175], [44, 179], [44, 188], [44, 229], [44, 235], [44, 238], [44, 243], [44, 244], [44, 261], [44, 271], [44, 277], [44, 292], [45, 46], [45, 50], [45, 51], [45, 115], [45, 116], [45, 146], [45, 151], [45, 157], [45, 175], [45, 184], [45, 241], [45, 250], [45, 253], [45, 258], [45, 259], [45, 272], [45, 295], [46, 67], [46, 69], [46, 79], [46, 95], [46, 103], [46, 120], [46, 169], [46, 182], [46, 209], [46, 210], [46, 213], [46, 216], [47, 59], [47, 62], [47, 79], [47, 87], [47, 107], [47, 109], [47, 124], [47, 127], [47, 129], [47, 146], [47, 154], [47, 198], [47, 201], [47, 214], [47, 219], [47, 228], [47, 240], [47, 242], [47, 271], [47, 278], [48, 60], [48, 62], [48, 77], [48, 82], [48, 105], [48, 106], [48, 130], [48, 139], [48, 145], [48, 146], [48, 169], [48, 276], [48, 294], [49, 64], [49, 78], [49, 79], [49, 84], [49, 96], [49, 116], [49, 126], [49, 129], [49, 130], [49, 134], [49, 135], [49, 143], [49, 147], [49, 194], [49, 204], [49, 230], [49, 257], [49, 264], [49, 279], [50, 64], [50, 74], [50, 94], [50, 95], [50, 105], [50, 114], [50, 115], [50, 127], [50, 135], [50, 182], [50, 190], [50, 200], [51, 70], [51, 82], [51, 83], [51, 92], [51, 102], [51, 130], [51, 155], [51, 170], [51, 175], [51, 177], [51, 183], [51, 184], [51, 186], [51, 198], [51, 200], [51, 206], [51, 220], [51, 229], [51, 235], [51, 253], [51, 258], [51, 259], [51, 272], [51, 275], [51, 280], [51, 285], [51, 286], [52, 69], [52, 79], [52, 97], [52, 102], [52, 139], [52, 146], [52, 150], [52, 169], [52, 179], [52, 180], [52, 208], [52, 256], [52, 267], [52, 279], [52, 294], [53, 94], [53, 98], [53, 119], [53, 144], [53, 184], [53, 234], [53, 242], [53, 265], [53, 273], [54, 73], [54, 82], [54, 88], [54, 130], [54, 161], [54, 169], [54, 183], [54, 191], [54, 192], [54, 208], [54, 244], [54, 285], [55, 80], [55, 104], [55, 123], [55, 143], [55, 164], [55, 187], [55, 193], [55, 224], [55, 230], [55, 266], [55, 278], [56, 67], [56, 94], [56, 103], [56, 115], [56, 129], [56, 138], [56, 208], [56, 243], [56, 255], [56, 259], [56, 263], [56, 291], [57, 95], [57, 116], [57, 124], [57, 126], [57, 176], [57, 195], [57, 199], [57, 200], [57, 210], [57, 240], [57, 255], [57, 298], [58, 65], [58, 78], [58, 103], [58, 108], [58, 115], [58, 132], [58, 143], [58, 161], [58, 169], [58, 178], [58, 192], [58, 196], [58, 204], [58, 233], [58, 235], [58, 239], [58, 289], [58, 297], [59, 72], [59, 77], [59, 98], [59, 104], [59, 121], [59, 143], [59, 150], [59, 152], [59, 163], [59, 184], [59, 228], [59, 236], [59, 259], [59, 263], [59, 291], [60, 64], [60, 94], [60, 119], [60, 122], [60, 142], [60, 148], [60, 169], [60, 177], [60, 193], [60, 196], [60, 197], [60, 228], [60, 265], [60, 282], [60, 292], [61, 86], [61, 103], [61, 116], [61, 147], [61, 170], [61, 218], [61, 290], [62, 113], [62, 114], [62, 129], [62, 141], [62, 193], [62, 209], [62, 210], [62, 213], [62, 219], [62, 220], [62, 240], [62, 262], [62, 285], [62, 299], [63, 77], [63, 87], [63, 90], [63, 95], [63, 100], [63, 129], [63, 164], [63, 176], [63, 193], [63, 282], [63, 290], [63, 291], [64, 67], [64, 101], [64, 122], [64, 130], [64, 156], [64, 185], [64, 209], [64, 212], [64, 250], [64, 253], [64, 264], [65, 92], [65, 103], [65, 124], [65, 132], [65, 154], [65, 189], [65, 206], [65, 276], [65, 298], [66, 72], [66, 73], [66, 76], [66, 82], [66, 121], [66, 167], [66, 180], [66, 196], [66, 200], [66, 209], [66, 214], [66, 225], [66, 241], [66, 242], [66, 272], [66, 289], [66, 297], [66, 298], [67, 82], [67, 94], [67, 112], [67, 124], [67, 155], [67, 157], [67, 180], [67, 183], [67, 193], [67, 202], [67, 220], [67, 237], [67, 258], [67, 268], [67, 275], [67, 279], [68, 115], [68, 121], [68, 122], [68, 136], [68, 148], [68, 161], [68, 169], [68, 174], [68, 176], [68, 190], [68, 211], [68, 263], [68, 276], [68, 297], [68, 298], [69, 83], [69, 89], [69, 107], [69, 125], [69, 128], [69, 137], [69, 146], [69, 148], [69, 158], [69, 166], [69, 168], [69, 204], [69, 236], [69, 238], [69, 241], [69, 251], [69, 256], [69, 277], [69, 278], [69, 287], [70, 80], [70, 81], [70, 106], [70, 107], [70, 128], [70, 143], [70, 150], [70, 154], [70, 165], [70, 167], [70, 187], [70, 245], [70, 258], [70, 293], [70, 296], [71, 91], [71, 114], [71, 126], [71, 141], [71, 171], [71, 179], [71, 180], [71, 182], [71, 205], [71, 207], [71, 230], [71, 245], [71, 253], [71, 277], [72, 76], [72, 77], [72, 80], [72, 96], [72, 115], [72, 129], [72, 158], [72, 163], [72, 181], [72, 185], [72, 248], [72, 254], [73, 112], [73, 115], [73, 123], [73, 131], [73, 136], [73, 146], [73, 171], [73, 172], [73, 179], [73, 191], [73, 200], [73, 221], [73, 228], [73, 231], [73, 249], [73, 268], [73, 283], [73, 284], [73, 291], [74, 96], [74, 109], [74, 119], [74, 125], [74, 140], [74, 142], [74, 151], [74, 156], [74, 186], [74, 187], [74, 200], [74, 229], [74, 249], [74, 294], [74, 296], [75, 79], [75, 97], [75, 101], [75, 121], [75, 128], [75, 134], [75, 135], [75, 138], [75, 184], [75, 193], [75, 210], [75, 211], [75, 213], [75, 217], [75, 220], [75, 271], [75, 275], [76, 81], [76, 103], [76, 117], [76, 136], [76, 139], [76, 142], [76, 150], [76, 179], [76, 205], [76, 212], [76, 217], [76, 218], [76, 242], [76, 244], [76, 250], [76, 262], [76, 265], [76, 291], [77, 91], [77, 110], [77, 142], [77, 147], [77, 149], [77, 150], [77, 159], [77, 208], [77, 264], [77, 273], [77, 279], [77, 286], [78, 86], [78, 98], [78, 118], [78, 121], [78, 136], [78, 177], [78, 183], [78, 202], [78, 204], [78, 210], [78, 231], [78, 245], [78, 261], [78, 281], [78, 286], [79, 81], [79, 83], [79, 85], [79, 89], [79, 103], [79, 104], [79, 105], [79, 106], [79, 112], [79, 133], [79, 141], [79, 151], [79, 160], [79, 165], [79, 170], [79, 208], [79, 233], [79, 241], [79, 262], [79, 265], [79, 276], [79, 282], [79, 296], [80, 91], [80, 96], [80, 117], [80, 141], [80, 143], [80, 194], [80, 217], [80, 233], [80, 267], [81, 88], [81, 126], [81, 136], [81, 142], [81, 167], [81, 168], [81, 173], [81, 236], [81, 239], [81, 243], [81, 277], [81, 283], [82, 103], [82, 137], [82, 156], [82, 158], [82, 179], [82, 183], [82, 190], [82, 191], [82, 210], [82, 213], [82, 240], [82, 241], [82, 252], [82, 258], [82, 267], [82, 299], [83, 97], [83, 113], [83, 124], [83, 128], [83, 130], [83, 153], [83, 159], [83, 201], [83, 223], [83, 225], [83, 240], [83, 275], [83, 276], [83, 287], [83, 297], [84, 89], [84, 98], [84, 115], [84, 161], [84, 178], [84, 189], [84, 209], [84, 223], [84, 252], [84, 290], [84, 295], [85, 177], [85, 218], [85, 267], [85, 273], [85, 275], [85, 283], [85, 287], [86, 90], [86, 115], [86, 168], [86, 185], [86, 200], [86, 215], [86, 221], [86, 231], [86, 236], [86, 257], [86, 258], [86, 263], [86, 298], [87, 88], [87, 100], [87, 117], [87, 124], [87, 138], [87, 145], [87, 159], [87, 187], [87, 265], [87, 277], [88, 110], [88, 124], [88, 179], [88, 192], [88, 205], [88, 218], [88, 227], [88, 229], [88, 268], [88, 281], [88, 293], [89, 106], [89, 152], [89, 169], [89, 180], [89, 183], [89, 188], [89, 201], [89, 206], [89, 216], [89, 230], [89, 238], [89, 271], [89, 279], [89, 285], [89, 287], [90, 113], [90, 121], [90, 127], [90, 135], [90, 141], [90, 158], [90, 172], [90, 189], [90, 205], [90, 211], [90, 214], [90, 219], [90, 231], [90, 232], [90, 233], [90, 235], [90, 236], [90, 239], [90, 281], [91, 98], [91, 99], [91, 107], [91, 116], [91, 126], [91, 133], [91, 144], [91, 179], [91, 191], [91, 209], [91, 212], [91, 217], [91, 221], [91, 232], [91, 247], [91, 270], [91, 274], [91, 295], [92, 110], [92, 125], [92, 127], [92, 142], [92, 144], [92, 168], [92, 187], [92, 190], [92, 222], [92, 229], [92, 231], [92, 244], [92, 247], [92, 249], [92, 285], [93, 99], [93, 102], [93, 106], [93, 149], [93, 207], [93, 209], [93, 213], [93, 233], [93, 277], [93, 285], [93, 286], [94, 120], [94, 129], [94, 159], [94, 179], [94, 190], [94, 200], [94, 213], [94, 224], [94, 225], [94, 294], [95, 102], [95, 110], [95, 116], [95, 118], [95, 137], [95, 139], [95, 148], [95, 152], [95, 181], [95, 188], [95, 218], [95, 223], [95, 230], [95, 246], [95, 255], [95, 256], [95, 258], [95, 264], [95, 267], [95, 268], [95, 274], [95, 278], [95, 281], [95, 290], [95, 294], [96, 97], [96, 100], [96, 102], [96, 139], [96, 144], [96, 147], [96, 154], [96, 173], [96, 192], [96, 195], [96, 214], [96, 215], [96, 216], [96, 220], [96, 223], [96, 261], [96, 297], [97, 110], [97, 118], [97, 132], [97, 158], [97, 187], [97, 215], [97, 237], [97, 254], [97, 267], [97, 272], [98, 124], [98, 135], [98, 136], [98, 138], [98, 141], [98, 150], [98, 206], [98, 211], [98, 217], [98, 221], [98, 234], [98, 250], [98, 265], [98, 278], [98, 289], [98, 299], [99, 119], [99, 146], [99, 174], [99, 220], [99, 227], [99, 234], [99, 235], [99, 242], [99, 251], [99, 263], [100, 143], [100, 165], [100, 173], [100, 190], [100, 198], [100, 228], [100, 233], [100, 244], [100, 253], [100, 254], [100, 258], [100, 275], [100, 279], [100, 295], [101, 112], [101, 116], [101, 160], [101, 181], [101, 207], [101, 208], [101, 210], [101, 223], [101, 229], [101, 232], [101, 243], [101, 266], [101, 291], [101, 299], [102, 110], [102, 122], [102, 139], [102, 141], [102, 153], [102, 172], [102, 173], [102, 196], [102, 205], [102, 236], [102, 237], [102, 253], [102, 291], [102, 299], [103, 124], [103, 139], [103, 140], [103, 187], [103, 194], [103, 205], [103, 207], [103, 213], [103, 248], [103, 254], [104, 121], [104, 125], [104, 134], [104, 158], [104, 167], [104, 171], [104, 179], [104, 189], [104, 201], [104, 208], [104, 218], [104, 221], [104, 247], [104, 267], [105, 128], [105, 129], [105, 142], [105, 151], [105, 155], [105, 160], [105, 168], [105, 176], [105, 199], [105, 205], [105, 206], [105, 214], [105, 217], [105, 227], [105, 258], [105, 278], [105, 280], [105, 282], [105, 283], [105, 294], [105, 298], [106, 113], [106, 119], [106, 125], [106, 133], [106, 138], [106, 145], [106, 155], [106, 157], [106, 173], [106, 175], [106, 185], [106, 197], [106, 204], [106, 212], [106, 214], [106, 217], [106, 230], [106, 239], [106, 246], [106, 251], [106, 252], [106, 261], [106, 268], [106, 277], [106, 283], [106, 285], [106, 297], [107, 114], [107, 136], [107, 147], [107, 153], [107, 166], [107, 200], [107, 208], [107, 219], [107, 257], [107, 261], [107, 267], [107, 268], [107, 291], [108, 120], [108, 126], [108, 127], [108, 138], [108, 150], [108, 181], [108, 208], [108, 224], [108, 233], [108, 245], [108, 258], [109, 119], [109, 159], [109, 183], [109, 232], [109, 245], [109, 247], [109, 250], [109, 267], [110, 115], [110, 138], [110, 195], [110, 200], [110, 206], [110, 207], [110, 215], [110, 239], [110, 278], [111, 141], [111, 158], [111, 182], [111, 245], [111, 264], [111, 272], [111, 280], [111, 297], [112, 150], [112, 185], [112, 188], [112, 219], [112, 222], [112, 228], [112, 240], [112, 252], [112, 275], [113, 128], [113, 130], [113, 143], [113, 151], [113, 172], [113, 194], [113, 204], [113, 254], [113, 259], [113, 270], [113, 283], [113, 299], [114, 126], [114, 149], [114, 159], [114, 178], [114, 207], [114, 213], [114, 229], [114, 240], [114, 248], [114, 252], [114, 275], [114, 280], [115, 116], [115, 124], [115, 137], [115, 157], [115, 160], [115, 163], [115, 197], [115, 217], [115, 219], [115, 233], [115, 235], [115, 246], [115, 265], [115, 267], [115, 289], [116, 129], [116, 149], [116, 151], [116, 156], [116, 159], [116, 182], [116, 218], [116, 219], [116, 226], [116, 235], [116, 237], [116, 238], [116, 273], [116, 296], [117, 120], [117, 133], [117, 158], [117, 162], [117, 182], [117, 217], [117, 239], [117, 280], [117, 281], [117, 295], [118, 135], [118, 138], [118, 141], [118, 147], [118, 194], [118, 226], [118, 244], [118, 286], [119, 134], [119, 136], [119, 162], [119, 163], [119, 168], [119, 170], [119, 171], [119, 188], [119, 194], [119, 195], [119, 196], [119, 205], [119, 210], [119, 224], [119, 250], [119, 254], [119, 259], [119, 261], [119, 265], [119, 270], [119, 271], [119, 281], [120, 133], [120, 153], [120, 166], [120, 172], [120, 198], [120, 203], [120, 246], [120, 254], [120, 273], [120, 285], [120, 286], [120, 295], [121, 141], [121, 142], [121, 166], [121, 169], [121, 187], [121, 229], [121, 257], [122, 125], [122, 130], [122, 153], [122, 179], [122, 191], [122, 224], [122, 233], [122, 241], [122, 248], [122, 253], [122, 257], [122, 276], [122, 296], [123, 130], [123, 131], [123, 170], [123, 212], [123, 229], [123, 239], [123, 283], [123, 294], [123, 296], [124, 147], [124, 151], [124, 161], [124, 171], [124, 191], [124, 193], [124, 225], [124, 226], [124, 231], [124, 235], [124, 243], [124, 244], [124, 245], [124, 255], [124, 256], [124, 277], [125, 152], [125, 157], [125, 165], [125, 173], [125, 180], [125, 207], [125, 230], [125, 256], [125, 271], [125, 276], [125, 280], [126, 134], [126, 139], [126, 141], [126, 146], [126, 156], [126, 179], [126, 204], [126, 221], [126, 261], [126, 265], [126, 276], [126, 285], [126, 291], [126, 298], [127, 131], [127, 154], [127, 172], [127, 231], [127, 277], [128, 147], [128, 176], [128, 179], [128, 195], [128, 196], [128, 220], [128, 225], [128, 234], [128, 254], [128, 292], [128, 295], [129, 141], [129, 147], [129, 165], [129, 182], [129, 199], [129, 211], [129, 239], [129, 248], [129, 258], [129, 272], [129, 278], [130, 136], [130, 149], [130, 150], [130, 164], [130, 167], [130, 168], [130, 183], [130, 196], [130, 202], [130, 203], [130, 215], [130, 229], [130, 230], [130, 242], [130, 265], [130, 280], [130, 284], [130, 292], [130, 298], [131, 142], [131, 159], [131, 160], [131, 184], [131, 238], [131, 240], [131, 244], [131, 266], [131, 268], [131, 286], [131, 294], [132, 137], [132, 156], [132, 158], [132, 159], [132, 173], [132, 183], [132, 184], [132, 185], [132, 195], [132, 200], [132, 204], [132, 223], [132, 235], [132, 251], [132, 256], [132, 263], [132, 282], [132, 291], [133, 134], [133, 136], [133, 146], [133, 150], [133, 182], [133, 211], [133, 245], [133, 277], [133, 279], [134, 149], [134, 162], [134, 168], [134, 170], [134, 207], [134, 220], [134, 239], [134, 253], [134, 277], [134, 287], [135, 141], [135, 149], [135, 169], [135, 232], [135, 276], [136, 148], [136, 196], [136, 209], [136, 221], [136, 242], [136, 280], [137, 164], [137, 180], [137, 200], [137, 239], [137, 241], [137, 257], [137, 276], [137, 282], [138, 198], [138, 206], [138, 207], [138, 220], [138, 250], [138, 253], [138, 263], [138, 277], [138, 280], [138, 283], [138, 292], [138, 296], [139, 177], [139, 204], [139, 206], [139, 213], [139, 216], [139, 232], [139, 243], [139, 258], [139, 260], [139, 262], [139, 267], [139, 277], [140, 146], [140, 148], [140, 175], [140, 178], [140, 210], [140, 228], [140, 251], [140, 259], [140, 277], [141, 157], [141, 160], [141, 167], [141, 176], [141, 185], [141, 207], [141, 213], [141, 224], [141, 232], [141, 235], [141, 240], [141, 265], [141, 277], [141, 287], [142, 153], [142, 156], [142, 180], [142, 188], [142, 194], [142, 197], [142, 216], [142, 261], [143, 146], [143, 181], [143, 182], [143, 183], [143, 192], [143, 193], [143, 200], [143, 215], [143, 216], [143, 225], [143, 232], [143, 236], [143, 239], [143, 248], [143, 251], [143, 266], [143, 269], [143, 271], [143, 276], [143, 288], [144, 159], [144, 188], [144, 195], [144, 208], [144, 239], [144, 270], [144, 276], [144, 294], [145, 162], [145, 176], [145, 190], [145, 231], [145, 241], [145, 248], [145, 256], [145, 266], [145, 284], [145, 294], [146, 188], [146, 197], [146, 207], [146, 214], [146, 223], [146, 231], [146, 241], [146, 244], [146, 264], [146, 290], [147, 195], [147, 215], [147, 281], [147, 290], [148, 170], [148, 188], [148, 209], [148, 299], [149, 158], [149, 196], [149, 205], [149, 216], [149, 240], [149, 272], [149, 286], [150, 154], [150, 169], [150, 198], [150, 214], [150, 243], [150, 244], [150, 248], [150, 285], [150, 298], [151, 152], [151, 178], [151, 194], [151, 217], [151, 231], [151, 244], [151, 249], [151, 272], [151, 277], [151, 279], [151, 288], [151, 299], [152, 166], [152, 179], [152, 214], [152, 216], [152, 221], [152, 238], [152, 241], [152, 255], [152, 256], [153, 178], [153, 189], [153, 248], [153, 262], [153, 264], [153, 294], [154, 158], [154, 189], [154, 204], [154, 225], [154, 240], [154, 248], [154, 262], [154, 266], [154, 275], [154, 292], [154, 293], [155, 194], [156, 162], [156, 205], [156, 213], [156, 222], [156, 233], [156, 270], [156, 272], [156, 273], [156, 274], [156, 292], [157, 165], [157, 176], [157, 178], [157, 180], [157, 183], [157, 185], [157, 206], [157, 280], [158, 169], [158, 189], [158, 199], [158, 229], [158, 234], [158, 249], [158, 259], [158, 271], [158, 274], [158, 291], [158, 295], [158, 296], [159, 169], [159, 270], [159, 275], [159, 283], [160, 194], [160, 197], [160, 211], [160, 284], [160, 286], [161, 198], [161, 199], [161, 251], [161, 279], [161, 283], [162, 206], [162, 218], [162, 279], [163, 171], [163, 194], [163, 228], [163, 232], [163, 270], [163, 286], [164, 178], [164, 203], [164, 224], [164, 227], [164, 230], [164, 243], [164, 251], [164, 279], [164, 280], [164, 295], [165, 186], [165, 203], [165, 219], [166, 176], [166, 198], [166, 202], [166, 215], [166, 245], [166, 284], [167, 171], [167, 184], [167, 204], [167, 206], [167, 208], [167, 234], [167, 235], [167, 258], [167, 263], [167, 286], [167, 298], [168, 190], [168, 212], [168, 215], [168, 226], [168, 249], [168, 255], [168, 275], [168, 289], [169, 170], [169, 177], [169, 199], [169, 202], [169, 207], [169, 209], [169, 225], [169, 233], [169, 247], [169, 258], [169, 259], [169, 264], [169, 293], [169, 299], [170, 180], [170, 225], [170, 232], [170, 239], [170, 255], [170, 266], [170, 277], [170, 278], [170, 279], [170, 288], [170, 289], [171, 190], [171, 196], [171, 206], [171, 239], [171, 243], [171, 257], [171, 263], [171, 267], [171, 287], [172, 175], [172, 212], [172, 218], [172, 225], [172, 229], [172, 257], [172, 262], [172, 273], [172, 277], [172, 286], [172, 294], [173, 174], [173, 181], [173, 194], [173, 208], [173, 211], [173, 220], [173, 227], [173, 238], [173, 261], [173, 263], [173, 281], [174, 181], [174, 200], [174, 202], [174, 248], [174, 252], [174, 259], [174, 261], [174, 267], [174, 268], [174, 273], [175, 193], [175, 198], [175, 222], [175, 223], [175, 235], [175, 241], [175, 242], [175, 243], [175, 247], [175, 257], [175, 274], [176, 179], [176, 194], [176, 201], [176, 213], [176, 215], [176, 235], [176, 243], [176, 274], [176, 290], [177, 197], [177, 202], [177, 234], [177, 245], [178, 195], [178, 197], [178, 203], [178, 210], [178, 228], [178, 248], [178, 252], [178, 257], [178, 269], [178, 270], [178, 273], [178, 277], [178, 281], [178, 282], [179, 186], [179, 191], [179, 196], [179, 198], [179, 199], [179, 225], [179, 245], [179, 253], [179, 275], [179, 280], [179, 289], [180, 182], [180, 200], [180, 236], [180, 237], [180, 264], [180, 265], [180, 272], [180, 288], [180, 295], [181, 182], [181, 218], [181, 223], [181, 241], [181, 250], [181, 254], [181, 268], [181, 281], [181, 290], [181, 294], [181, 299], [182, 247], [182, 256], [182, 266], [182, 272], [182, 295], [183, 290], [184, 197], [184, 202], [184, 235], [184, 251], [184, 276], [184, 281], [184, 284], [184, 294], [185, 198], [185, 224], [185, 226], [185, 234], [185, 246], [185, 263], [185, 280], [185, 287], [185, 288], [185, 293], [186, 199], [186, 205], [186, 214], [186, 218], [186, 271], [186, 273], [186, 286], [186, 287], [186, 293], [186, 294], [187, 200], [187, 202], [187, 229], [187, 231], [187, 250], [187, 257], [187, 260], [187, 276], [187, 290], [188, 202], [188, 226], [188, 229], [188, 232], [188, 237], [188, 271], [188, 278], [189, 190], [189, 194], [189, 196], [189, 213], [189, 246], [189, 257], [189, 269], [189, 273], [189, 280], [190, 207], [190, 218], [190, 221], [190, 233], [190, 297], [190, 298], [191, 231], [191, 268], [191, 270], [191, 287], [191, 290], [192, 202], [192, 207], [192, 214], [192, 240], [192, 258], [192, 267], [192, 268], [192, 292], [192, 298], [193, 206], [193, 209], [193, 217], [193, 218], [193, 228], [193, 241], [193, 257], [193, 273], [193, 275], [193, 278], [194, 199], [194, 221], [194, 238], [194, 248], [194, 274], [194, 275], [194, 287], [194, 297], [195, 201], [195, 205], [195, 207], [195, 214], [195, 230], [195, 236], [195, 240], [195, 270], [196, 198], [196, 205], [196, 211], [196, 231], [196, 236], [196, 268], [196, 293], [196, 296], [197, 203], [197, 223], [197, 234], [197, 267], [197, 277], [197, 282], [197, 293], [197, 294], [198, 200], [198, 215], [198, 241], [198, 244], [198, 290], [198, 293], [199, 201], [199, 204], [199, 214], [199, 233], [199, 249], [199, 256], [199, 277], [200, 219], [200, 221], [200, 226], [200, 233], [200, 241], [200, 251], [200, 260], [200, 272], [200, 275], [200, 278], [200, 281], [200, 286], [200, 296], [201, 238], [201, 269], [201, 287], [201, 289], [202, 203], [202, 242], [202, 251], [202, 279], [202, 280], [202, 289], [203, 253], [204, 216], [204, 235], [204, 246], [205, 210], [205, 270], [205, 287], [205, 294], [206, 215], [206, 233], [206, 255], [206, 273], [206, 283], [207, 247], [207, 252], [207, 257], [207, 261], [207, 272], [207, 293], [208, 232], [208, 237], [208, 239], [208, 244], [208, 253], [208, 263], [208, 273], [208, 295], [209, 231], [209, 286], [210, 236], [210, 253], [211, 224], [211, 230], [211, 240], [211, 248], [211, 255], [211, 276], [211, 277], [211, 287], [212, 219], [212, 225], [212, 229], [212, 243], [212, 250], [212, 286], [212, 295], [213, 218], [213, 243], [213, 260], [213, 272], [213, 286], [214, 218], [214, 249], [214, 265], [214, 289], [214, 296], [215, 220], [215, 234], [215, 253], [215, 264], [215, 271], [215, 282], [215, 290], [216, 251], [216, 263], [216, 275], [216, 276], [216, 286], [216, 297], [217, 221], [217, 251], [217, 254], [217, 257], [217, 262], [217, 278], [217, 299], [218, 224], [218, 244], [218, 247], [218, 252], [218, 288], [219, 220], [219, 228], [219, 275], [219, 277], [219, 283], [219, 296], [220, 221], [220, 226], [220, 248], [220, 284], [221, 264], [221, 267], [221, 269], [221, 277], [222, 231], [222, 248], [222, 261], [222, 264], [222, 270], [222, 288], [223, 239], [223, 261], [223, 263], [223, 279], [224, 227], [224, 245], [224, 249], [224, 252], [224, 266], [224, 270], [224, 286], [225, 237], [225, 241], [226, 235], [226, 241], [226, 258], [226, 274], [226, 275], [226, 277], [226, 287], [226, 295], [226, 297], [227, 249], [227, 252], [227, 275], [227, 276], [227, 277], [228, 249], [228, 253], [228, 261], [228, 278], [228, 291], [228, 293], [228, 298], [229, 241], [229, 257], [229, 276], [229, 279], [229, 289], [230, 281], [231, 259], [231, 265], [232, 244], [232, 254], [232, 256], [232, 258], [233, 235], [233, 254], [233, 255], [233, 256], [233, 262], [233, 292], [233, 295], [234, 250], [234, 260], [234, 270], [234, 284], [235, 250], [235, 252], [235, 257], [235, 258], [235, 273], [235, 279], [235, 296], [236, 258], [236, 266], [237, 246], [237, 247], [237, 251], [237, 285], [238, 248], [238, 250], [238, 279], [239, 262], [239, 270], [239, 281], [239, 285], [239, 290], [239, 299], [240, 260], [240, 283], [240, 294], [241, 253], [241, 256], [241, 260], [241, 262], [242, 250], [242, 259], [242, 282], [243, 259], [243, 284], [243, 286], [243, 287], [244, 246], [244, 266], [244, 268], [244, 276], [244, 279], [244, 297], [245, 258], [245, 262], [245, 276], [245, 281], [246, 284], [246, 293], [247, 250], [247, 255], [247, 279], [248, 258], [248, 270], [248, 278], [249, 264], [249, 281], [249, 297], [249, 298], [250, 290], [251, 296], [252, 255], [252, 279], [253, 269], [253, 290], [254, 295], [255, 261], [256, 260], [256, 282], [256, 289], [256, 290], [257, 268], [257, 269], [257, 299], [258, 261], [258, 272], [259, 277], [259, 298], [260, 273], [260, 274], [260, 276], [260, 288], [261, 268], [261, 291], [261, 299], [262, 273], [262, 289], [262, 294], [265, 268], [266, 273], [267, 280], [267, 296], [268, 290], [269, 289], [269, 293], [270, 272], [273, 276], [273, 282], [273, 291], [274, 277], [274, 285], [275, 279], [275, 295], [276, 297], [278, 281], [278, 288], [279, 299], [280, 289], [282, 292], [283, 285], [283, 292], [286, 288], [286, 291], [286, 293], [287, 288], [287, 290], [289, 290], [290, 297], [292, 293], [293, 299]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s3/tests/run.py b/tasks/construct-nppc-dominating-set-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-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-dominating-set-l6-s3/tests/test.sh b/tasks/construct-nppc-dominating-set-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-quad-diophantine-l6-s3/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l6-s3/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..70a88826d253d9c1e36183cace5da6cf8452171e --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"a": 4787828032, "b": 8984156428, "c": 162393729631277195717677124568, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s3/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2a470689930550a746cf9457abb89c54f587f6aa --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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": 5823919407, "y": 5688842850} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s3/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s3/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s3/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..70a88826d253d9c1e36183cace5da6cf8452171e --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"a": 4787828032, "b": 8984156428, "c": 162393729631277195717677124568, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s3/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-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-quad-diophantine-l6-s3/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l6-s4/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-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-nppc-quad-diophantine-l6-s4/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fdc8fce3e3b821350cb271abbd9cdfe022e25ce3 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"a": 6204434225, "b": 5722084952, "c": 1251572483655086075961002985, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s4/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cce97d6b072f7039c932312d8f4e140eb82f42ef --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-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": 449135011, "y": 265309130} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s4/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s4/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s4/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fdc8fce3e3b821350cb271abbd9cdfe022e25ce3 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"a": 6204434225, "b": 5722084952, "c": 1251572483655086075961002985, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s4/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-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-nppc-quad-diophantine-l6-s4/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-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-quadratic-congruence-l2-s2/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l6-s3/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l6-s3/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..866e006d69982eb221bc4a2301bf437f1ff00b31 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"a": 34322292804173329451794444471347083768414991817, "b": 212683753137781606690885709001486990856642175161, "c": 178425056429802095852851124768623520344473035959, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s3/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b5b013b665a746c1abb49f6822a8941e41daed83 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 178424593453532532216727916676481843180781634196} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..866e006d69982eb221bc4a2301bf437f1ff00b31 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"a": 34322292804173329451794444471347083768414991817, "b": 212683753137781606690885709001486990856642175161, "c": 178425056429802095852851124768623520344473035959, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-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-quadratic-congruence-l6-s3/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l6-s4/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-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-nppc-quadratic-congruence-l6-s4/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0616ddb607f235330d21b6fd6cf86ac3504d9deb --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"a": 185862978271109057504131336370876095676608028147, "b": 263603019027103054600622249816138468514069009007, "c": 155466150104900151690761786422066641366886926332, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s4/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1be08d5e0b2cc6b35f29ab8cab550f19a18355e6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-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": 155459998128155802521992706122542182718191430912} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0616ddb607f235330d21b6fd6cf86ac3504d9deb --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"a": 185862978271109057504131336370876095676608028147, "b": 263603019027103054600622249816138468514069009007, "c": 155466150104900151690761786422066641366886926332, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-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-nppc-quadratic-congruence-l6-s4/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-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-vertex-cover-l4-s8/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-vertex-cover-l4-s8/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..393365528f8a43c3ec6792a6420e3c4b0417299f --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 5], [0, 9], [0, 10], [0, 14], [0, 17], [0, 19], [0, 22], [0, 27], [0, 36], [0, 37], [1, 2], [1, 5], [1, 9], [1, 10], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 21], [1, 25], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 35], [1, 36], [1, 38], [1, 39], [2, 7], [2, 14], [2, 15], [2, 17], [2, 18], [2, 19], [2, 28], [2, 35], [2, 37], [3, 5], [3, 14], [3, 17], [3, 18], [3, 26], [3, 27], [3, 33], [3, 36], [3, 38], [4, 10], [4, 14], [4, 15], [4, 17], [4, 26], [4, 27], [4, 28], [4, 33], [4, 35], [4, 36], [4, 38], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 18], [5, 19], [5, 20], [5, 22], [5, 24], [5, 26], [5, 27], [5, 28], [5, 30], [5, 31], [5, 33], [5, 35], [5, 37], [5, 38], [6, 10], [6, 14], [6, 18], [6, 19], [6, 24], [6, 27], [6, 33], [6, 36], [6, 38], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 24], [7, 26], [7, 28], [7, 29], [7, 32], [7, 33], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [8, 10], [8, 15], [8, 18], [8, 19], [8, 22], [8, 24], [8, 27], [8, 28], [8, 36], [9, 14], [9, 17], [9, 21], [9, 23], [9, 24], [9, 26], [9, 27], [9, 33], [9, 35], [9, 36], [9, 38], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 19], [10, 20], [10, 22], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 33], [10, 35], [10, 37], [10, 38], [10, 39], [11, 17], [11, 18], [11, 22], [11, 38], [12, 14], [12, 17], [12, 18], [12, 19], [12, 22], [12, 26], [12, 28], [12, 33], [12, 35], [12, 36], [12, 37], [12, 38], [13, 15], [13, 19], [13, 24], [13, 33], [13, 38], [14, 15], [14, 17], [14, 22], [14, 23], [14, 25], [14, 27], [14, 28], [14, 30], [14, 34], [14, 35], [14, 36], [14, 38], [15, 17], [15, 20], [15, 21], [15, 26], [15, 27], [15, 29], [15, 30], [15, 31], [15, 33], [15, 34], [15, 35], [15, 36], [15, 37], [15, 38], [15, 39], [16, 17], [16, 19], [16, 22], [16, 24], [16, 37], [16, 38], [17, 18], [17, 20], [17, 24], [17, 25], [17, 26], [17, 27], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 37], [17, 38], [18, 19], [18, 22], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 33], [18, 36], [18, 37], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 28], [19, 29], [19, 31], [19, 32], [19, 33], [19, 34], [19, 37], [19, 38], [19, 39], [20, 27], [20, 28], [20, 35], [20, 36], [20, 37], [21, 24], [21, 27], [21, 28], [21, 35], [21, 36], [22, 24], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 34], [22, 35], [22, 36], [22, 37], [23, 24], [23, 26], [23, 27], [23, 35], [23, 36], [23, 38], [24, 25], [24, 26], [24, 27], [24, 28], [24, 30], [24, 31], [24, 32], [24, 34], [24, 35], [24, 36], [24, 38], [24, 39], [25, 28], [25, 36], [25, 38], [26, 27], [26, 31], [26, 32], [26, 37], [26, 39], [27, 28], [27, 29], [27, 36], [27, 38], [27, 39], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 37], [28, 38], [28, 39], [29, 35], [30, 35], [31, 35], [31, 36], [31, 37], [31, 38], [32, 33], [32, 35], [32, 37], [33, 34], [33, 36], [33, 38], [33, 39], [34, 35], [34, 37], [35, 36], [35, 37], [35, 39], [36, 38], [36, 39], [37, 38], [37, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s8/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..40e3142fc8acb6142de30382bc091524cb0116b8 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [1, 5, 7, 9, 10, 14, 15, 17, 18, 19, 22, 24, 26, 27, 28, 33, 35, 36, 37, 38]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s8/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s8/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l4-s8/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..393365528f8a43c3ec6792a6420e3c4b0417299f --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 5], [0, 9], [0, 10], [0, 14], [0, 17], [0, 19], [0, 22], [0, 27], [0, 36], [0, 37], [1, 2], [1, 5], [1, 9], [1, 10], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 21], [1, 25], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 35], [1, 36], [1, 38], [1, 39], [2, 7], [2, 14], [2, 15], [2, 17], [2, 18], [2, 19], [2, 28], [2, 35], [2, 37], [3, 5], [3, 14], [3, 17], [3, 18], [3, 26], [3, 27], [3, 33], [3, 36], [3, 38], [4, 10], [4, 14], [4, 15], [4, 17], [4, 26], [4, 27], [4, 28], [4, 33], [4, 35], [4, 36], [4, 38], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 18], [5, 19], [5, 20], [5, 22], [5, 24], [5, 26], [5, 27], [5, 28], [5, 30], [5, 31], [5, 33], [5, 35], [5, 37], [5, 38], [6, 10], [6, 14], [6, 18], [6, 19], [6, 24], [6, 27], [6, 33], [6, 36], [6, 38], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 24], [7, 26], [7, 28], [7, 29], [7, 32], [7, 33], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [8, 10], [8, 15], [8, 18], [8, 19], [8, 22], [8, 24], [8, 27], [8, 28], [8, 36], [9, 14], [9, 17], [9, 21], [9, 23], [9, 24], [9, 26], [9, 27], [9, 33], [9, 35], [9, 36], [9, 38], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 19], [10, 20], [10, 22], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 33], [10, 35], [10, 37], [10, 38], [10, 39], [11, 17], [11, 18], [11, 22], [11, 38], [12, 14], [12, 17], [12, 18], [12, 19], [12, 22], [12, 26], [12, 28], [12, 33], [12, 35], [12, 36], [12, 37], [12, 38], [13, 15], [13, 19], [13, 24], [13, 33], [13, 38], [14, 15], [14, 17], [14, 22], [14, 23], [14, 25], [14, 27], [14, 28], [14, 30], [14, 34], [14, 35], [14, 36], [14, 38], [15, 17], [15, 20], [15, 21], [15, 26], [15, 27], [15, 29], [15, 30], [15, 31], [15, 33], [15, 34], [15, 35], [15, 36], [15, 37], [15, 38], [15, 39], [16, 17], [16, 19], [16, 22], [16, 24], [16, 37], [16, 38], [17, 18], [17, 20], [17, 24], [17, 25], [17, 26], [17, 27], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 37], [17, 38], [18, 19], [18, 22], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 33], [18, 36], [18, 37], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 28], [19, 29], [19, 31], [19, 32], [19, 33], [19, 34], [19, 37], [19, 38], [19, 39], [20, 27], [20, 28], [20, 35], [20, 36], [20, 37], [21, 24], [21, 27], [21, 28], [21, 35], [21, 36], [22, 24], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 34], [22, 35], [22, 36], [22, 37], [23, 24], [23, 26], [23, 27], [23, 35], [23, 36], [23, 38], [24, 25], [24, 26], [24, 27], [24, 28], [24, 30], [24, 31], [24, 32], [24, 34], [24, 35], [24, 36], [24, 38], [24, 39], [25, 28], [25, 36], [25, 38], [26, 27], [26, 31], [26, 32], [26, 37], [26, 39], [27, 28], [27, 29], [27, 36], [27, 38], [27, 39], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 37], [28, 38], [28, 39], [29, 35], [30, 35], [31, 35], [31, 36], [31, 37], [31, 38], [32, 33], [32, 35], [32, 37], [33, 34], [33, 36], [33, 38], [33, 39], [34, 35], [34, 37], [35, 36], [35, 37], [35, 39], [36, 38], [36, 39], [37, 38], [37, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s8/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-vertex-cover-l4-s8/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-l3-s3/environment/Dockerfile b/tasks/construct-rg-graph-color-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s3/environment/instance.json b/tasks/construct-rg-graph-color-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dcecef0e132e8ce1e1e8c4833c70e130b031ebc9 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 1], [0, 6], [0, 8], [1, 2], [1, 5], [2, 3], [2, 4], [3, 6], [3, 9], [4, 6], [4, 7], [5, 6], [7, 8], [7, 9], [8, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s3/solution/solve.sh b/tasks/construct-rg-graph-color-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d45a56f1f045425e4800440add7f1f4b7451f11b --- /dev/null +++ b/tasks/construct-rg-graph-color-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, 2, 1, 2, 2, 1, 3, 1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l3-s3/tests/check.py b/tasks/construct-rg-graph-color-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s3/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-l3-s3/tests/instance.json b/tasks/construct-rg-graph-color-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dcecef0e132e8ce1e1e8c4833c70e130b031ebc9 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 1], [0, 6], [0, 8], [1, 2], [1, 5], [2, 3], [2, 4], [3, 6], [3, 9], [4, 6], [4, 7], [5, 6], [7, 8], [7, 9], [8, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s3/tests/run.py b/tasks/construct-rg-graph-color-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s3/tests/test.sh b/tasks/construct-rg-graph-color-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s4/environment/Dockerfile b/tasks/construct-rg-graph-color-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s4/environment/instance.json b/tasks/construct-rg-graph-color-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5def130a76f19bad8612bb08bf21ce60214dd9e --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 1], [0, 5], [0, 8], [1, 2], [1, 5], [1, 6], [1, 7], [1, 9], [2, 5], [5, 6], [5, 7], [5, 9], [7, 8]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s4/solution/solve.sh b/tasks/construct-rg-graph-color-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ee2af6d7e032ff13992456893b10c2ecf43bc110 --- /dev/null +++ b/tasks/construct-rg-graph-color-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' +{"coloring": [1, 2, 1, 1, 1, 3, 1, 1, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l3-s4/tests/check.py b/tasks/construct-rg-graph-color-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s4/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-l3-s4/tests/instance.json b/tasks/construct-rg-graph-color-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5def130a76f19bad8612bb08bf21ce60214dd9e --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 1], [0, 5], [0, 8], [1, 2], [1, 5], [1, 6], [1, 7], [1, 9], [2, 5], [5, 6], [5, 7], [5, 9], [7, 8]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s4/tests/run.py b/tasks/construct-rg-graph-color-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s4/tests/test.sh b/tasks/construct-rg-graph-color-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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/construct-rg-intermediate-integration-l1-s0/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s0/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2418d57bbccefe22c032414ecfaddbc1cbd3f814 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(5*x - 5)**2", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s0/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..413b8316d1aba395c02f7623fed52a06e838ed2d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "25*x**3/3 - 25*x**2 + 25*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s0/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s0/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-intermediate-integration-l1-s0/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2418d57bbccefe22c032414ecfaddbc1cbd3f814 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(5*x - 5)**2", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s0/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s0/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s7/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-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-intermediate-integration-l1-s7/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d6f4e383f3e697373d841b3b1438ed699abc67ac --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-2*(5*x - 4)**4", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s7/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..027097a545c3d847245fa8ae4740ee32d12059bf --- /dev/null +++ b/tasks/construct-rg-intermediate-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": "-250*x**5 + 1000*x**4 - 1600*x**3 + 1280*x**2 - 512*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s7/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-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-intermediate-integration-l1-s7/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d6f4e383f3e697373d841b3b1438ed699abc67ac --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-2*(5*x - 4)**4", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s7/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-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-intermediate-integration-l1-s7/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-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-intermediate-integration-l5-s8/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-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-intermediate-integration-l5-s8/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0850adde93013504bb7bb2db31da207a2afc2c20 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*exp(x)*cos(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s8/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4240aa379843b88187d7a6ec2e7782e609ff5433 --- /dev/null +++ b/tasks/construct-rg-intermediate-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": "-3*exp(x)*sin(x)/2 - 3*exp(x)*cos(x)/2 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s8/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-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-intermediate-integration-l5-s8/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0850adde93013504bb7bb2db31da207a2afc2c20 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*exp(x)*cos(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s8/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-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-intermediate-integration-l5-s8/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-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-rg-simple-integration-l3-s2/environment/Dockerfile b/tasks/construct-rg-simple-integration-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s2/environment/instance.json b/tasks/construct-rg-simple-integration-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c14cf80bd039f21d51569a004fd5905769c78d48 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-30*X**9 + 28*X**6 + 56*X**3", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s2/solution/solve.sh b/tasks/construct-rg-simple-integration-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c76c16392d3e46bbca457ab17ee3e7b8e2aa3ac --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "-3*X**10 + 4*X**7 + 14*X**4 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l3-s2/tests/check.py b/tasks/construct-rg-simple-integration-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s2/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-l3-s2/tests/instance.json b/tasks/construct-rg-simple-integration-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c14cf80bd039f21d51569a004fd5905769c78d48 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-30*X**9 + 28*X**6 + 56*X**3", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s2/tests/run.py b/tasks/construct-rg-simple-integration-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s2/tests/test.sh b/tasks/construct-rg-simple-integration-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s5/environment/Dockerfile b/tasks/construct-rg-simple-integration-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-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-rg-simple-integration-l3-s5/environment/instance.json b/tasks/construct-rg-simple-integration-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8ff4307b519d996d031c8d4e64c672b0c80c3f1a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-45*X**8/8 + 12*X**5 + 35*X**4/8", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s5/solution/solve.sh b/tasks/construct-rg-simple-integration-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..02b44b4e71dda3a8399e9de00f6b17365c6829a6 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-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' +{"antiderivative": "-5*X**9/8 + 2*X**6 + 7*X**5/8 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l3-s5/tests/check.py b/tasks/construct-rg-simple-integration-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s5/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-l3-s5/tests/instance.json b/tasks/construct-rg-simple-integration-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8ff4307b519d996d031c8d4e64c672b0c80c3f1a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-45*X**8/8 + 12*X**5 + 35*X**4/8", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s5/tests/run.py b/tasks/construct-rg-simple-integration-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-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-rg-simple-integration-l3-s5/tests/test.sh b/tasks/construct-rg-simple-integration-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-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-antiderivative-l2-s2/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l2-s2/environment/instance.json b/tasks/construct-rlve-antiderivative-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0f9473c55275d4b083dc141b1ab7fa98930d96c --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "x*cos(x)/sin(x) + log(sin(x))", "max_ops": 32, "max_len": 680, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s2/solution/solve.sh b/tasks/construct-rlve-antiderivative-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..53e794af2574e2ae37c9f9734b92b38ef392bab2 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "log(sin(x)**x)"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l2-s2/tests/check.py b/tasks/construct-rlve-antiderivative-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s2/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-l2-s2/tests/instance.json b/tasks/construct-rlve-antiderivative-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0f9473c55275d4b083dc141b1ab7fa98930d96c --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "x*cos(x)/sin(x) + log(sin(x))", "max_ops": 32, "max_len": 680, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s2/tests/run.py b/tasks/construct-rlve-antiderivative-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l2-s2/tests/test.sh b/tasks/construct-rlve-antiderivative-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l2-s5/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-rlve-antiderivative-l2-s5/environment/instance.json b/tasks/construct-rlve-antiderivative-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2ca70309de1b91cb58fd3cf9c2df0cb6b3cbaa1b --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "(2*x)**x*(log(2*x) + 1)", "max_ops": 28, "max_len": 560, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s5/solution/solve.sh b/tasks/construct-rlve-antiderivative-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0292a0a0e5b13d540f9f7c074c9531b63fec252b --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "(2*x)**x"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l2-s5/tests/check.py b/tasks/construct-rlve-antiderivative-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s5/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-l2-s5/tests/instance.json b/tasks/construct-rlve-antiderivative-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2ca70309de1b91cb58fd3cf9c2df0cb6b3cbaa1b --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "(2*x)**x*(log(2*x) + 1)", "max_ops": 28, "max_len": 560, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s5/tests/run.py b/tasks/construct-rlve-antiderivative-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-rlve-antiderivative-l2-s5/tests/test.sh b/tasks/construct-rlve-antiderivative-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-rlve-antiderivative-l6-s3/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-rlve-antiderivative-l6-s3/environment/instance.json b/tasks/construct-rlve-antiderivative-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae680638bee3526cf06e0bef68b9cebb1390427f --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "2*(sqrt(2)*sqrt(x)/8)**x*(log(sqrt(2)*sqrt(x)/8) + 1/2)/3", "max_ops": 64, "max_len": 1040, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s3/solution/solve.sh b/tasks/construct-rlve-antiderivative-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d62ca7925ae99c73bddf9063c1be0f5f1d2d0aa0 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "2*(sqrt(2)*sqrt(x)/8)**x/3 + 8/3"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l6-s3/tests/check.py b/tasks/construct-rlve-antiderivative-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s3/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-l6-s3/tests/instance.json b/tasks/construct-rlve-antiderivative-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae680638bee3526cf06e0bef68b9cebb1390427f --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "2*(sqrt(2)*sqrt(x)/8)**x*(log(sqrt(2)*sqrt(x)/8) + 1/2)/3", "max_ops": 64, "max_len": 1040, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s3/tests/run.py b/tasks/construct-rlve-antiderivative-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-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-antiderivative-l6-s3/tests/test.sh b/tasks/construct-rlve-antiderivative-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-rlve-antiderivative-l6-s4/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-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-antiderivative-l6-s4/environment/instance.json b/tasks/construct-rlve-antiderivative-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..95f27075a3fcad4167c39f30c4f2c183b0f8e491 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "-4*(x**2/2 + x*(x + 1))*sin(x**2*(x + 1)/2)", "max_ops": 44, "max_len": 820, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s4/solution/solve.sh b/tasks/construct-rlve-antiderivative-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..393e21f3e2b6848cd30d9bdff55b5f487e59c3b0 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-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' +{"F": "4*cos(x**2*(x + 1)/2)"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l6-s4/tests/check.py b/tasks/construct-rlve-antiderivative-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s4/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-l6-s4/tests/instance.json b/tasks/construct-rlve-antiderivative-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..95f27075a3fcad4167c39f30c4f2c183b0f8e491 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "-4*(x**2/2 + x*(x + 1))*sin(x**2*(x + 1)/2)", "max_ops": 44, "max_len": 820, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s4/tests/run.py b/tasks/construct-rlve-antiderivative-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-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-antiderivative-l6-s4/tests/test.sh b/tasks/construct-rlve-antiderivative-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-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-l3-s1/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l3-s1/environment/instance.json b/tasks/construct-rlve-bezout-identity-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f576fb149f1caf51b705ef3c6d02ec3d6ab6128 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": [138, 128, 220, -422, 184, 370], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s1/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a2ded933bb5643cb3d624ccfb90f2eb09acfaba9 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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' +{"X": [13, -14, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l3-s1/tests/check.py b/tasks/construct-rlve-bezout-identity-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s1/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-l3-s1/tests/instance.json b/tasks/construct-rlve-bezout-identity-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f576fb149f1caf51b705ef3c6d02ec3d6ab6128 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": [138, 128, 220, -422, 184, 370], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s1/tests/run.py b/tasks/construct-rlve-bezout-identity-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l3-s1/tests/test.sh b/tasks/construct-rlve-bezout-identity-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l3-s6/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-rlve-bezout-identity-l3-s6/environment/instance.json b/tasks/construct-rlve-bezout-identity-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f6f5d78d276b7a41d87b0769d87c5b56076b4eb1 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"A": [411, -150, -222, 267, 468, 312], "target": 3, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s6/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dd893b1c25a6073a3860fdbe8d5671156e76d46f --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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' +{"X": [23, 63, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l3-s6/tests/check.py b/tasks/construct-rlve-bezout-identity-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s6/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-l3-s6/tests/instance.json b/tasks/construct-rlve-bezout-identity-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f6f5d78d276b7a41d87b0769d87c5b56076b4eb1 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"A": [411, -150, -222, 267, 468, 312], "target": 3, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s6/tests/run.py b/tasks/construct-rlve-bezout-identity-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-rlve-bezout-identity-l3-s6/tests/test.sh b/tasks/construct-rlve-bezout-identity-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-rlve-construct-hack-interval-l1-s3/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l1-s3/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bded6ae35f4b72b500e5c2bf02b6eaa268adca73 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"mod": 27, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s2/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-rlve-construct-hack-interval-l5-s2/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e09cdfe4a1841eb6557566cbf938e8d932e1e239 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"mod": 557778703246615, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s2/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e864660d617533300affb0bb70579c789b2735c7 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 393344438959380, "R": 493344438959379} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e09cdfe4a1841eb6557566cbf938e8d932e1e239 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"mod": 557778703246615, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-rlve-construct-hack-interval-l5-s2/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-rlve-construct-hack-interval-l5-s5/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s5/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d8b9cd07037db771037ceac8e17dc3626fd43747 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"mod": 297626190643643, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s5/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5b3f9fd3aee9b0f2fb7084dccba480dbc7e79b5c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 10252381287286, "R": 20252381287285} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d8b9cd07037db771037ceac8e17dc3626fd43747 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"mod": 297626190643643, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s5/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-l4-s2/environment/Dockerfile b/tasks/construct-rlve-crt-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s2/environment/instance.json b/tasks/construct-rlve-crt-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..42e7d23552bf1796f5dfee6a5998ec8ba62e2ecf --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [434467, 584485, 139970, 371055, 60042], "residues": [209947, 59929, 84534, 273359, 43994], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s2/solution/solve.sh b/tasks/construct-rlve-crt-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c455cf03ecbd6de9b5538016ff9153d697b4e433 --- /dev/null +++ b/tasks/construct-rlve-crt-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' +{"x": 644414} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l4-s2/tests/check.py b/tasks/construct-rlve-crt-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s2/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-l4-s2/tests/instance.json b/tasks/construct-rlve-crt-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..42e7d23552bf1796f5dfee6a5998ec8ba62e2ecf --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [434467, 584485, 139970, 371055, 60042], "residues": [209947, 59929, 84534, 273359, 43994], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s2/tests/run.py b/tasks/construct-rlve-crt-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s2/tests/test.sh b/tasks/construct-rlve-crt-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s5/environment/Dockerfile b/tasks/construct-rlve-crt-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s5/environment/instance.json b/tasks/construct-rlve-crt-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a005d6f5a78e74e6df8c2e1c70aa73694c20145f --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [93959, 70316, 78546, 7108, 72860], "residues": [38003, 61646, 53416, 4018, 59102], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s5/solution/solve.sh b/tasks/construct-rlve-crt-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d5bb2a53db1bfe2bcec44ab4dbde53f2661eacad --- /dev/null +++ b/tasks/construct-rlve-crt-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' +{"x": 131962} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l4-s5/tests/check.py b/tasks/construct-rlve-crt-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s5/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-l4-s5/tests/instance.json b/tasks/construct-rlve-crt-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a005d6f5a78e74e6df8c2e1c70aa73694c20145f --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [93959, 70316, 78546, 7108, 72860], "residues": [38003, 61646, 53416, 4018, 59102], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s5/tests/run.py b/tasks/construct-rlve-crt-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s5/tests/test.sh b/tasks/construct-rlve-crt-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-distinct-subset-sum-permutation-l1-s3/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s3/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f3008046f65711851aaf042073bfdc2d26d9f1fb --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": [0, 1, 7, 4], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0a874c5944ca22cf443b04e24901d71fe4b20646 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [1, 4, 0, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/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-l1-s3/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f3008046f65711851aaf042073bfdc2d26d9f1fb --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": [0, 1, 7, 4], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s3/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s2/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-rlve-distinct-subset-sum-permutation-l5-s2/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4675bd1bd96a1ab8ab29a273946e03d7cb551566 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"A": [20, 35, 11, 14, 7, 13, 12, 23, 9, 8, 21, 1, 0, 28, 29, 32, 27, 24], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..22b794529531cfd7d040169afe934558fccf684b --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [21, 0, 12, 20, 8, 14, 13, 24, 11, 9, 23, 7, 1, 29, 32, 35, 28, 27]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/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-l5-s2/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4675bd1bd96a1ab8ab29a273946e03d7cb551566 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"A": [20, 35, 11, 14, 7, 13, 12, 23, 9, 8, 21, 1, 0, 28, 29, 32, 27, 24], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-rlve-distinct-subset-sum-permutation-l5-s2/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-rlve-distinct-subset-sum-permutation-l5-s5/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s5/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..113cd4276ae0142f949beabcd933e2b1c25760a7 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": [35, 30, 29, 6, 26, 1, 5, 8, 2, 7, 3, 34, 0, 4, 28, 31, 17, 21], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d6215e9d4977f3cd384f3e0eeb2fa06cb592dadf --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [0, 31, 30, 7, 28, 2, 6, 17, 3, 8, 4, 35, 1, 5, 29, 34, 21, 26]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/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-l5-s5/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..113cd4276ae0142f949beabcd933e2b1c25760a7 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": [35, 30, 29, 6, 26, 1, 5, 8, 2, 7, 3, 34, 0, 4, 28, 31, 17, 21], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s5/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-even-degree-partition-l4-s2/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s2/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0b2f21100540b23c94c537e95cd3368ba0ce8113 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 4], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 14], [0, 15], [0, 16], [0, 17], [1, 2], [1, 4], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 17], [2, 3], [2, 4], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 14], [2, 16], [2, 17], [3, 4], [3, 8], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [4, 7], [4, 10], [4, 12], [4, 14], [4, 15], [4, 17], [5, 6], [5, 8], [5, 11], [5, 12], [5, 13], [5, 16], [5, 17], [6, 8], [6, 9], [6, 11], [6, 14], [6, 16], [6, 17], [7, 8], [7, 11], [7, 12], [7, 14], [7, 16], [7, 17], [8, 9], [8, 10], [8, 13], [8, 14], [8, 15], [9, 12], [9, 16], [9, 17], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [11, 13], [11, 14], [11, 15], [12, 14], [12, 15], [12, 16], [12, 17], [13, 15], [13, 16], [13, 17], [14, 16], [15, 16], [15, 17], [16, 17]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s2/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..010410a4a85e6f3b25824372e13122412c42088e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l4-s2/tests/check.py b/tasks/construct-rlve-even-degree-partition-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s2/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-l4-s2/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0b2f21100540b23c94c537e95cd3368ba0ce8113 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 4], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 14], [0, 15], [0, 16], [0, 17], [1, 2], [1, 4], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 17], [2, 3], [2, 4], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 14], [2, 16], [2, 17], [3, 4], [3, 8], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [4, 7], [4, 10], [4, 12], [4, 14], [4, 15], [4, 17], [5, 6], [5, 8], [5, 11], [5, 12], [5, 13], [5, 16], [5, 17], [6, 8], [6, 9], [6, 11], [6, 14], [6, 16], [6, 17], [7, 8], [7, 11], [7, 12], [7, 14], [7, 16], [7, 17], [8, 9], [8, 10], [8, 13], [8, 14], [8, 15], [9, 12], [9, 16], [9, 17], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [11, 13], [11, 14], [11, 15], [12, 14], [12, 15], [12, 16], [12, 17], [13, 15], [13, 16], [13, 17], [14, 16], [15, 16], [15, 17], [16, 17]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s2/tests/run.py b/tasks/construct-rlve-even-degree-partition-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s2/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-graph-isomorphism-l2-s1/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s1/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9dc1062a4939ad0baa0ffe7e46dba4d9117a04c3 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[1, 3], [5, 7], [3, 4], [1, 5], [1, 2], [6, 7], [0, 2]], "edges2": [[4, 5], [2, 5], [1, 2], [0, 7], [5, 7], [4, 6], [3, 6]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s1/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc43fa6c8e70e2bba440f90825efcc217f64fccb --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [0, 5, 7, 2, 1, 4, 3, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s1/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s1/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-l2-s1/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9dc1062a4939ad0baa0ffe7e46dba4d9117a04c3 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[1, 3], [5, 7], [3, 4], [1, 5], [1, 2], [6, 7], [0, 2]], "edges2": [[4, 5], [2, 5], [1, 2], [0, 7], [5, 7], [4, 6], [3, 6]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s1/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s1/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s6/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s6/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dc6b14c1dcccf13244b8bd8118c5b19e80e716de --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[0, 1], [1, 6], [0, 4], [3, 6], [3, 7], [0, 6], [0, 2], [4, 7], [3, 5], [1, 4], [0, 3], [2, 3], [1, 2], [5, 7], [1, 5]], "edges2": [[4, 5], [2, 3], [3, 7], [0, 7], [5, 6], [0, 5], [1, 5], [2, 4], [1, 2], [5, 7], [0, 2], [2, 6], [3, 6], [0, 4], [0, 1]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s6/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..87a554b644cbbf5d2a7c82d63707d35393071b6e --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [0, 5, 1, 2, 7, 6, 4, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s6/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s6/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-l2-s6/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dc6b14c1dcccf13244b8bd8118c5b19e80e716de --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[0, 1], [1, 6], [0, 4], [3, 6], [3, 7], [0, 6], [0, 2], [4, 7], [3, 5], [1, 4], [0, 3], [2, 3], [1, 2], [5, 7], [1, 5]], "edges2": [[4, 5], [2, 3], [3, 7], [0, 7], [5, 6], [0, 5], [1, 5], [2, 4], [1, 2], [5, 7], [0, 2], [2, 6], [3, 6], [0, 4], [0, 1]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s6/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s6/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s0/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s0/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1e2fc1199ee8c37b874b7cf915f922fe68f649c6 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[15, 32], [17, 36], [13, 18], [22, 28], [15, 23], [25, 33], [24, 25], [18, 33], [1, 29], [5, 8], [27, 30], [3, 24], [5, 32], [12, 33], [16, 29], [3, 25], [0, 26], [1, 6], [5, 17], [22, 27], [8, 14], [6, 33], [14, 30], [6, 29], [4, 31], [2, 7], [10, 30], [8, 31], [2, 3], [2, 11], [17, 26], [5, 38], [21, 34], [24, 37], [19, 30], [23, 29], [9, 27], [12, 27], [5, 24], [30, 37], [0, 3], [5, 9], [0, 17], [0, 8], [11, 14], [13, 35], [0, 7], [7, 10], [16, 31], [5, 36], [30, 32], [20, 27], [5, 35], [19, 38], [24, 32], [13, 19], [31, 33], [6, 34], [20, 23], [25, 28], [7, 17], [10, 14], [4, 26], [6, 18], [28, 30], [18, 29], [13, 20], [31, 36], [20, 33], [5, 23], [5, 22], [7, 11], [22, 36], [12, 22], [11, 25], [17, 38], [3, 13], [32, 37], [26, 31], [6, 10], [25, 39], [12, 30], [11, 33], [25, 38], [8, 37], [17, 19], [23, 39], [5, 11], [1, 33], [8, 10], [0, 16], [9, 21], [6, 7], [13, 28], [3, 37], [7, 30], [27, 33], [22, 30], [14, 32], [24, 36], [26, 38], [8, 38], [1, 25], [10, 23], [26, 29], [10, 13], [11, 36], [1, 31], [15, 38], [16, 39], [34, 36], [8, 39], [0, 27], [21, 27], [26, 33], [13, 17], [10, 15], [12, 39], [17, 27], [0, 35], [15, 30], [19, 22], [13, 33], [1, 28], [8, 29], [9, 14], [15, 25], [0, 24], [12, 35], [9, 26], [18, 30], [19, 28], [6, 39], [10, 36], [7, 36], [7, 27], [28, 29], [11, 26], [6, 24], [1, 13], [9, 38], [22, 29], [20, 22], [5, 30], [31, 35], [19, 33], [13, 21], [34, 39], [22, 26], [7, 9], [16, 36], [9, 29], [10, 35], [0, 32], [9, 11], [4, 35], [25, 26], [6, 13], [23, 26], [30, 38], [2, 31], [10, 28], [4, 14], [32, 36], [9, 10], [10, 31], [9, 15], [4, 20], [28, 37], [14, 25], [7, 39], [13, 30], [10, 34], [1, 26], [14, 38], [8, 12], [4, 21], [25, 35], [14, 18], [26, 34], [9, 19], [0, 23], [18, 34], [13, 25], [0, 10], [3, 11], [10, 17], [31, 37], [9, 17], [19, 31], [22, 31], [2, 23], [20, 34], [22, 32], [11, 28], [4, 38], [4, 11], [19, 39], [10, 24], [21, 28], [4, 33], [13, 34], [0, 28], [1, 23], [9, 36], [29, 30], [20, 21], [13, 15], [11, 27], [15, 18], [9, 37], [15, 36], [12, 29], [8, 32], [0, 25], [0, 29], [8, 24], [7, 19], [4, 22], [11, 13], [0, 9], [29, 33], [4, 39], [1, 22], [33, 35], [24, 38], [3, 7], [20, 30], [22, 39], [5, 27], [22, 35], [11, 23], [11, 15], [30, 35], [19, 37], [2, 39], [9, 16], [12, 20], [14, 15], [19, 21], [17, 29], [17, 30], [13, 36], [0, 5], [25, 34], [28, 38], [12, 18], [3, 15], [6, 17], [14, 24], [5, 16], [0, 4], [1, 7], [20, 24], [10, 33], [11, 19], [0, 11], [3, 14], [26, 28], [14, 36], [10, 27], [10, 19], [20, 36], [3, 22], [5, 13], [9, 12], [30, 36], [15, 20], [10, 22], [6, 31], [1, 24], [30, 39], [2, 22]], "edges2": [[34, 38], [15, 23], [1, 17], [2, 5], [28, 31], [17, 32], [3, 37], [15, 34], [28, 35], [1, 13], [28, 38], [3, 9], [3, 21], [17, 22], [7, 8], [0, 6], [15, 18], [22, 38], [7, 27], [0, 28], [20, 36], [12, 20], [19, 33], [35, 39], [1, 8], [5, 17], [8, 25], [27, 33], [7, 22], [1, 35], [21, 36], [6, 19], [21, 31], [13, 28], [14, 33], [16, 37], [16, 24], [5, 32], [1, 38], [12, 27], [14, 28], [13, 16], [11, 18], [4, 37], [7, 12], [33, 34], [17, 19], [34, 35], [12, 39], [17, 27], [10, 27], [0, 21], [18, 39], [31, 39], [27, 36], [10, 24], [2, 11], [16, 34], [28, 39], [25, 32], [11, 30], [13, 32], [4, 26], [3, 22], [9, 15], [2, 29], [5, 9], [2, 26], [32, 39], [31, 32], [10, 12], [2, 18], [7, 24], [0, 22], [6, 10], [1, 6], [15, 17], [11, 35], [2, 14], [16, 32], [10, 31], [14, 32], [5, 26], [21, 35], [12, 17], [4, 23], [5, 10], [1, 25], [23, 27], [29, 38], [6, 12], [16, 31], [26, 29], [0, 27], [7, 10], [12, 22], [17, 24], [13, 36], [18, 36], [22, 31], [2, 33], [3, 8], [10, 23], [17, 21], [11, 21], [2, 16], [32, 36], [9, 30], [23, 34], [2, 19], [17, 33], [17, 30], [0, 25], [13, 34], [13, 20], [9, 32], [27, 34], [4, 28], [14, 18], [3, 6], [24, 38], [3, 16], [3, 15], [9, 36], [5, 18], [25, 33], [19, 26], [12, 36], [9, 10], [4, 22], [2, 23], [21, 27], [3, 29], [9, 14], [21, 38], [28, 30], [9, 33], [10, 37], [16, 38], [34, 36], [23, 26], [3, 17], [13, 14], [8, 26], [11, 13], [0, 18], [27, 30], [2, 25], [27, 29], [5, 34], [3, 14], [19, 35], [16, 26], [12, 16], [7, 13], [23, 32], [16, 23], [16, 19], [30, 31], [22, 25], [32, 38], [14, 16], [21, 32], [22, 32], [9, 16], [13, 29], [22, 29], [18, 21], [21, 30], [7, 17], [1, 36], [4, 5], [18, 27], [20, 27], [2, 32], [8, 17], [8, 15], [17, 34], [5, 38], [18, 38], [1, 5], [4, 7], [0, 37], [19, 23], [6, 28], [8, 21], [7, 23], [0, 12], [2, 10], [2, 28], [33, 38], [8, 38], [15, 37], [7, 33], [5, 30], [6, 21], [9, 38], [33, 37], [6, 7], [6, 30], [34, 39], [0, 38], [17, 23], [5, 36], [16, 20], [32, 34], [0, 32], [18, 22], [3, 33], [17, 38], [24, 30], [8, 13], [17, 25], [24, 33], [10, 11], [35, 38], [35, 37], [4, 30], [27, 37], [18, 30], [4, 32], [24, 32], [20, 29], [4, 18], [6, 31], [10, 30], [10, 28], [24, 35], [10, 29], [33, 35], [5, 21], [4, 6], [14, 24], [16, 35], [18, 34], [36, 38], [22, 27], [9, 18], [29, 30], [23, 38], [10, 38], [26, 37], [30, 32], [14, 25], [10, 18], [0, 31], [24, 37], [23, 39], [26, 27], [21, 22], [7, 26], [10, 36], [19, 29], [18, 26], [26, 35], [6, 38], [0, 7], [9, 27], [1, 33], [20, 35], [6, 39], [13, 37], [1, 2], [19, 36], [26, 33], [1, 19], [16, 30], [16, 21], [3, 32], [10, 26], [0, 4], [7, 19], [4, 34]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s0/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f75a0aa7e0b7ad190c2fc2326b927b0eae90d53c --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [10, 19, 20, 12, 37, 30, 1, 36, 28, 18, 38, 27, 14, 17, 0, 22, 11, 5, 25, 34, 3, 15, 16, 29, 6, 7, 26, 9, 23, 2, 32, 35, 31, 33, 8, 24, 21, 39, 4, 13]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s0/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s0/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-l6-s0/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1e2fc1199ee8c37b874b7cf915f922fe68f649c6 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[15, 32], [17, 36], [13, 18], [22, 28], [15, 23], [25, 33], [24, 25], [18, 33], [1, 29], [5, 8], [27, 30], [3, 24], [5, 32], [12, 33], [16, 29], [3, 25], [0, 26], [1, 6], [5, 17], [22, 27], [8, 14], [6, 33], [14, 30], [6, 29], [4, 31], [2, 7], [10, 30], [8, 31], [2, 3], [2, 11], [17, 26], [5, 38], [21, 34], [24, 37], [19, 30], [23, 29], [9, 27], [12, 27], [5, 24], [30, 37], [0, 3], [5, 9], [0, 17], [0, 8], [11, 14], [13, 35], [0, 7], [7, 10], [16, 31], [5, 36], [30, 32], [20, 27], [5, 35], [19, 38], [24, 32], [13, 19], [31, 33], [6, 34], [20, 23], [25, 28], [7, 17], [10, 14], [4, 26], [6, 18], [28, 30], [18, 29], [13, 20], [31, 36], [20, 33], [5, 23], [5, 22], [7, 11], [22, 36], [12, 22], [11, 25], [17, 38], [3, 13], [32, 37], [26, 31], [6, 10], [25, 39], [12, 30], [11, 33], [25, 38], [8, 37], [17, 19], [23, 39], [5, 11], [1, 33], [8, 10], [0, 16], [9, 21], [6, 7], [13, 28], [3, 37], [7, 30], [27, 33], [22, 30], [14, 32], [24, 36], [26, 38], [8, 38], [1, 25], [10, 23], [26, 29], [10, 13], [11, 36], [1, 31], [15, 38], [16, 39], [34, 36], [8, 39], [0, 27], [21, 27], [26, 33], [13, 17], [10, 15], [12, 39], [17, 27], [0, 35], [15, 30], [19, 22], [13, 33], [1, 28], [8, 29], [9, 14], [15, 25], [0, 24], [12, 35], [9, 26], [18, 30], [19, 28], [6, 39], [10, 36], [7, 36], [7, 27], [28, 29], [11, 26], [6, 24], [1, 13], [9, 38], [22, 29], [20, 22], [5, 30], [31, 35], [19, 33], [13, 21], [34, 39], [22, 26], [7, 9], [16, 36], [9, 29], [10, 35], [0, 32], [9, 11], [4, 35], [25, 26], [6, 13], [23, 26], [30, 38], [2, 31], [10, 28], [4, 14], [32, 36], [9, 10], [10, 31], [9, 15], [4, 20], [28, 37], [14, 25], [7, 39], [13, 30], [10, 34], [1, 26], [14, 38], [8, 12], [4, 21], [25, 35], [14, 18], [26, 34], [9, 19], [0, 23], [18, 34], [13, 25], [0, 10], [3, 11], [10, 17], [31, 37], [9, 17], [19, 31], [22, 31], [2, 23], [20, 34], [22, 32], [11, 28], [4, 38], [4, 11], [19, 39], [10, 24], [21, 28], [4, 33], [13, 34], [0, 28], [1, 23], [9, 36], [29, 30], [20, 21], [13, 15], [11, 27], [15, 18], [9, 37], [15, 36], [12, 29], [8, 32], [0, 25], [0, 29], [8, 24], [7, 19], [4, 22], [11, 13], [0, 9], [29, 33], [4, 39], [1, 22], [33, 35], [24, 38], [3, 7], [20, 30], [22, 39], [5, 27], [22, 35], [11, 23], [11, 15], [30, 35], [19, 37], [2, 39], [9, 16], [12, 20], [14, 15], [19, 21], [17, 29], [17, 30], [13, 36], [0, 5], [25, 34], [28, 38], [12, 18], [3, 15], [6, 17], [14, 24], [5, 16], [0, 4], [1, 7], [20, 24], [10, 33], [11, 19], [0, 11], [3, 14], [26, 28], [14, 36], [10, 27], [10, 19], [20, 36], [3, 22], [5, 13], [9, 12], [30, 36], [15, 20], [10, 22], [6, 31], [1, 24], [30, 39], [2, 22]], "edges2": [[34, 38], [15, 23], [1, 17], [2, 5], [28, 31], [17, 32], [3, 37], [15, 34], [28, 35], [1, 13], [28, 38], [3, 9], [3, 21], [17, 22], [7, 8], [0, 6], [15, 18], [22, 38], [7, 27], [0, 28], [20, 36], [12, 20], [19, 33], [35, 39], [1, 8], [5, 17], [8, 25], [27, 33], [7, 22], [1, 35], [21, 36], [6, 19], [21, 31], [13, 28], [14, 33], [16, 37], [16, 24], [5, 32], [1, 38], [12, 27], [14, 28], [13, 16], [11, 18], [4, 37], [7, 12], [33, 34], [17, 19], [34, 35], [12, 39], [17, 27], [10, 27], [0, 21], [18, 39], [31, 39], [27, 36], [10, 24], [2, 11], [16, 34], [28, 39], [25, 32], [11, 30], [13, 32], [4, 26], [3, 22], [9, 15], [2, 29], [5, 9], [2, 26], [32, 39], [31, 32], [10, 12], [2, 18], [7, 24], [0, 22], [6, 10], [1, 6], [15, 17], [11, 35], [2, 14], [16, 32], [10, 31], [14, 32], [5, 26], [21, 35], [12, 17], [4, 23], [5, 10], [1, 25], [23, 27], [29, 38], [6, 12], [16, 31], [26, 29], [0, 27], [7, 10], [12, 22], [17, 24], [13, 36], [18, 36], [22, 31], [2, 33], [3, 8], [10, 23], [17, 21], [11, 21], [2, 16], [32, 36], [9, 30], [23, 34], [2, 19], [17, 33], [17, 30], [0, 25], [13, 34], [13, 20], [9, 32], [27, 34], [4, 28], [14, 18], [3, 6], [24, 38], [3, 16], [3, 15], [9, 36], [5, 18], [25, 33], [19, 26], [12, 36], [9, 10], [4, 22], [2, 23], [21, 27], [3, 29], [9, 14], [21, 38], [28, 30], [9, 33], [10, 37], [16, 38], [34, 36], [23, 26], [3, 17], [13, 14], [8, 26], [11, 13], [0, 18], [27, 30], [2, 25], [27, 29], [5, 34], [3, 14], [19, 35], [16, 26], [12, 16], [7, 13], [23, 32], [16, 23], [16, 19], [30, 31], [22, 25], [32, 38], [14, 16], [21, 32], [22, 32], [9, 16], [13, 29], [22, 29], [18, 21], [21, 30], [7, 17], [1, 36], [4, 5], [18, 27], [20, 27], [2, 32], [8, 17], [8, 15], [17, 34], [5, 38], [18, 38], [1, 5], [4, 7], [0, 37], [19, 23], [6, 28], [8, 21], [7, 23], [0, 12], [2, 10], [2, 28], [33, 38], [8, 38], [15, 37], [7, 33], [5, 30], [6, 21], [9, 38], [33, 37], [6, 7], [6, 30], [34, 39], [0, 38], [17, 23], [5, 36], [16, 20], [32, 34], [0, 32], [18, 22], [3, 33], [17, 38], [24, 30], [8, 13], [17, 25], [24, 33], [10, 11], [35, 38], [35, 37], [4, 30], [27, 37], [18, 30], [4, 32], [24, 32], [20, 29], [4, 18], [6, 31], [10, 30], [10, 28], [24, 35], [10, 29], [33, 35], [5, 21], [4, 6], [14, 24], [16, 35], [18, 34], [36, 38], [22, 27], [9, 18], [29, 30], [23, 38], [10, 38], [26, 37], [30, 32], [14, 25], [10, 18], [0, 31], [24, 37], [23, 39], [26, 27], [21, 22], [7, 26], [10, 36], [19, 29], [18, 26], [26, 35], [6, 38], [0, 7], [9, 27], [1, 33], [20, 35], [6, 39], [13, 37], [1, 2], [19, 36], [26, 33], [1, 19], [16, 30], [16, 21], [3, 32], [10, 26], [0, 4], [7, 19], [4, 34]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s0/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s0/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s7/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-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-graph-isomorphism-l6-s7/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4c36f70a2908c164241eea8924cea558ed7c69d5 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[15, 17], [13, 22], [4, 23], [34, 36], [15, 23], [17, 22], [3, 7], [11, 23], [13, 26], [0, 21], [8, 35], [4, 31], [20, 25], [9, 23], [13, 27], [7, 12], [19, 28], [21, 32], [4, 15], [22, 24], [28, 29], [21, 30], [23, 39], [21, 34], [7, 17], [31, 38], [22, 37], [0, 6], [8, 12], [8, 25], [3, 12], [2, 35], [7, 24], [9, 15], [1, 4], [11, 30], [10, 36], [17, 31], [1, 10], [14, 29], [4, 7], [24, 37], [9, 31], [13, 38], [22, 27], [3, 15], [0, 23], [3, 21], [2, 20], [22, 30], [6, 10], [4, 5], [14, 35], [2, 4], [5, 29], [2, 37], [14, 22], [20, 21], [5, 26], [9, 22], [13, 34], [5, 25], [24, 33], [4, 12], [5, 32], [5, 20], [12, 26], [13, 24], [24, 27], [17, 36], [18, 32], [19, 31], [21, 29], [12, 17], [22, 34], [14, 34], [12, 18], [23, 24], [23, 37], [9, 16], [5, 27], [7, 34], [22, 28], [22, 23], [0, 28], [0, 22], [1, 23], [7, 37], [7, 38], [6, 9], [0, 39], [7, 33], [10, 29], [8, 31], [0, 14], [21, 38], [3, 37], [12, 39], [4, 36], [32, 33], [3, 26], [8, 9], [0, 5], [28, 33], [7, 31], [25, 27], [15, 22], [16, 17], [0, 8], [14, 39], [27, 35], [14, 27], [24, 32], [9, 30], [8, 24], [20, 22], [23, 29], [14, 32], [15, 32], [6, 21], [1, 27], [2, 34], [9, 32], [32, 34], [3, 4], [20, 31], [5, 15], [14, 18], [16, 22], [5, 10], [3, 6], [11, 21], [0, 16], [19, 32], [3, 18], [7, 18], [6, 27], [16, 24], [5, 7], [1, 33], [6, 28], [8, 16], [4, 27], [26, 28], [2, 23], [17, 38], [6, 39], [7, 28], [13, 36], [38, 39], [4, 6], [2, 9], [11, 27], [0, 13], [36, 37], [7, 27], [16, 23], [22, 31], [1, 31], [12, 19], [20, 30], [5, 8], [7, 11], [5, 39], [18, 20], [8, 32], [21, 27], [5, 16], [15, 16], [31, 37], [14, 17], [6, 31], [2, 36], [10, 26], [17, 23], [2, 29], [10, 23], [16, 32], [23, 28], [37, 39], [25, 32], [17, 20], [15, 28], [9, 13], [16, 20], [12, 13], [26, 37], [23, 32], [19, 26], [33, 36], [21, 24], [14, 24], [6, 12], [28, 35], [27, 37], [17, 39], [18, 23], [2, 16], [17, 35], [1, 36], [16, 28], [21, 35], [0, 37], [4, 39], [5, 12], [14, 25], [6, 38], [22, 25], [4, 16], [14, 16], [25, 29], [11, 19], [15, 29], [20, 35], [10, 37], [17, 21], [17, 37], [23, 35], [4, 34], [3, 5], [11, 28], [23, 26], [0, 32], [12, 27], [19, 35], [7, 10], [34, 39], [7, 30], [14, 28], [1, 19], [0, 11], [32, 39], [5, 34], [7, 8], [0, 17], [18, 26], [10, 22], [6, 17], [37, 38], [24, 29], [27, 30], [25, 28], [14, 38], [2, 8], [13, 30], [9, 37], [5, 14], [18, 21], [11, 35], [1, 24], [25, 33], [1, 26], [30, 32], [2, 12], [12, 22], [2, 32], [17, 34], [6, 13], [26, 39], [9, 39], [19, 23], [8, 37], [16, 19], [2, 28], [28, 32], [25, 34], [2, 19], [13, 16], [11, 24], [18, 33], [5, 13], [15, 27], [7, 39], [25, 38], [33, 35], [10, 34], [6, 15], [11, 15], [1, 34], [20, 26], [21, 25], [35, 39], [4, 21], [32, 37], [1, 16], [20, 27], [30, 35], [17, 33], [2, 22], [22, 29], [1, 9], [33, 39], [7, 14], [19, 30], [25, 26], [32, 36], [21, 22], [18, 28], [30, 31], [1, 39], [11, 38], [0, 36], [29, 33], [19, 39], [7, 9], [12, 25], [4, 24], [7, 32], [0, 7], [18, 24], [20, 29], [3, 27], [21, 31], [9, 17], [3, 22], [6, 29], [21, 39], [30, 37], [28, 39], [10, 27], [26, 30], [1, 12], [4, 19], [9, 11], [9, 35], [21, 26], [8, 15], [10, 24], [5, 18], [1, 29], [1, 22], [12, 36], [3, 35], [1, 30], [22, 26], [7, 36], [25, 30], [12, 23], [8, 39], [25, 35], [11, 22], [11, 32], [26, 29], [8, 36], [23, 34], [30, 39], [16, 39], [3, 11], [24, 39], [10, 33], [32, 38], [22, 35], [12, 21], [29, 37], [18, 38], [20, 23], [4, 20], [4, 8], [24, 38], [31, 39], [20, 36], [11, 16], [2, 15], [4, 33], [10, 32], [4, 32], [11, 14], [6, 34], [1, 35], [28, 36], [26, 38], [19, 20], [5, 11], [9, 33], [23, 27], [21, 36], [3, 8], [23, 30], [22, 39], [22, 33], [19, 37], [0, 31], [28, 30], [21, 23], [4, 18], [0, 35], [1, 6], [1, 28], [8, 22], [34, 35], [18, 19], [23, 38], [0, 24], [3, 9], [14, 20], [23, 33], [16, 18], [12, 16], [29, 39], [4, 14], [30, 36], [1, 11], [1, 3], [20, 37], [13, 39], [8, 28], [22, 36], [12, 15], [15, 25], [3, 19], [5, 22], [17, 29], [11, 20], [6, 22], [8, 33], [4, 29], [3, 10], [2, 39], [10, 18], [0, 15], [1, 14], [10, 13], [29, 32], [17, 27], [10, 20], [7, 19], [13, 15], [10, 11], [8, 18], [3, 20], [10, 31], [25, 37], [8, 26], [18, 29], [13, 37], [21, 37], [2, 26], [8, 11], [35, 38], [5, 19], [19, 36], [3, 38], [12, 37], [3, 24], [20, 24], [0, 1], [3, 23], [27, 33], [1, 7], [10, 19], [27, 28], [13, 21], [6, 25], [19, 34], [10, 21], [10, 28], [6, 26], [12, 32], [10, 35], [12, 30], [2, 10], [26, 32], [19, 33], [8, 17], [21, 33], [20, 32], [12, 38], [1, 25], [3, 39], [14, 15], [2, 7], [24, 26], [15, 37], [16, 29], [15, 19], [15, 26], [33, 37], [28, 34], [0, 30], [16, 36], [1, 20], [3, 29], [2, 13], [10, 38], [2, 24], [2, 31], [16, 38], [20, 39], [7, 22], [9, 36], [4, 37], [0, 34], [0, 25], [5, 30], [24, 31], [24, 30], [16, 21], [7, 35], [34, 37], [18, 30], [8, 19], [13, 25], [15, 20], [11, 12], [20, 34], [7, 23], [4, 10]], "edges2": [[34, 36], [11, 25], [23, 30], [3, 16], [6, 8], [3, 25], [2, 5], [5, 23], [9, 13], [2, 24], [10, 31], [12, 24], [11, 36], [10, 34], [13, 27], [15, 19], [1, 13], [3, 11], [6, 28], [13, 24], [30, 32], [19, 33], [4, 35], [11, 21], [32, 36], [5, 33], [14, 30], [15, 33], [4, 11], [12, 39], [0, 29], [7, 8], [9, 34], [3, 5], [1, 32], [34, 38], [17, 32], [20, 24], [21, 29], [17, 26], [28, 29], [4, 22], [20, 32], [10, 37], [5, 19], [4, 28], [26, 32], [6, 18], [9, 23], [22, 23], [10, 23], [2, 7], [0, 5], [6, 10], [30, 35], [16, 35], [13, 29], [1, 21], [0, 39], [8, 17], [3, 18], [8, 16], [7, 9], [30, 33], [9, 24], [5, 18], [3, 28], [22, 37], [26, 39], [20, 27], [23, 38], [2, 36], [26, 33], [6, 36], [13, 18], [12, 28], [12, 33], [7, 28], [15, 25], [21, 31], [33, 35], [0, 30], [5, 15], [11, 39], [25, 38], [7, 35], [5, 27], [13, 39], [24, 32], [8, 14], [29, 31], [7, 25], [24, 31], [0, 12], [24, 27], [0, 36], [10, 15], [3, 6], [10, 11], [5, 32], [14, 35], [17, 36], [24, 37], [26, 28], [15, 29], [12, 18], [22, 25], [9, 11], [13, 14], [4, 23], [4, 16], [4, 5], [7, 19], [22, 30], [3, 9], [24, 25], [26, 35], [2, 12], [3, 33], [2, 33], [9, 33], [9, 36], [2, 6], [12, 17], [10, 30], [22, 27], [0, 16], [22, 29], [4, 25], [11, 20], [10, 12], [19, 27], [17, 24], [25, 37], [4, 18], [12, 30], [2, 8], [24, 34], [9, 25], [18, 23], [1, 36], [14, 26], [5, 22], [27, 33], [11, 28], [32, 39], [19, 35], [23, 29], [4, 30], [16, 38], [3, 7], [23, 24], [11, 22], [3, 12], [17, 21], [4, 39], [16, 33], [4, 38], [16, 22], [3, 10], [10, 14], [1, 39], [14, 29], [17, 37], [21, 33], [12, 16], [2, 31], [0, 2], [0, 13], [12, 20], [34, 37], [11, 27], [38, 39], [9, 15], [20, 29], [22, 26], [2, 23], [31, 33], [31, 34], [35, 39], [32, 33], [2, 26], [12, 22], [1, 17], [19, 29], [25, 39], [29, 30], [3, 34], [4, 37], [1, 11], [4, 6], [5, 29], [29, 37], [19, 26], [20, 22], [17, 25], [3, 14], [26, 27], [14, 15], [6, 13], [5, 30], [5, 6], [19, 34], [8, 9], [15, 23], [18, 30], [1, 3], [13, 23], [4, 8], [9, 18], [24, 33], [11, 15], [0, 25], [26, 29], [12, 14], [7, 32], [1, 23], [4, 21], [15, 35], [15, 28], [6, 32], [14, 22], [11, 29], [25, 35], [10, 22], [24, 26], [0, 15], [8, 29], [35, 36], [3, 19], [7, 33], [11, 12], [21, 23], [18, 28], [15, 24], [8, 32], [10, 28], [12, 21], [6, 17], [29, 35], [2, 11], [7, 27], [12, 34], [25, 36], [5, 34], [29, 39], [20, 26], [17, 38], [36, 37], [2, 39], [9, 19], [33, 34], [8, 12], [16, 24], [0, 8], [1, 2], [24, 29], [31, 39], [2, 15], [16, 27], [2, 4], [26, 30], [18, 34], [6, 15], [33, 39], [5, 20], [2, 22], [7, 36], [12, 27], [28, 33], [5, 31], [0, 4], [7, 12], [3, 38], [11, 35], [3, 36], [37, 39], [9, 31], [35, 37], [1, 19], [9, 28], [25, 33], [28, 31], [9, 26], [32, 35], [14, 16], [14, 34], [14, 33], [4, 33], [16, 26], [6, 11], [16, 32], [9, 12], [1, 5], [9, 30], [11, 19], [6, 16], [2, 35], [2, 10], [26, 31], [1, 4], [1, 37], [16, 29], [5, 13], [13, 26], [17, 33], [4, 36], [15, 20], [7, 24], [6, 35], [14, 20], [20, 35], [10, 26], [13, 30], [1, 33], [8, 25], [20, 23], [17, 34], [2, 13], [10, 32], [0, 38], [5, 9], [7, 38], [7, 31], [22, 32], [30, 34], [4, 13], [30, 36], [17, 31], [27, 35], [7, 34], [19, 28], [28, 32], [0, 22], [14, 24], [19, 39], [20, 28], [15, 32], [8, 37], [12, 32], [1, 38], [18, 35], [6, 31], [1, 20], [13, 33], [33, 38], [16, 28], [4, 10], [2, 38], [15, 17], [2, 14], [8, 19], [3, 22], [0, 31], [17, 18], [11, 24], [2, 28], [11, 26], [16, 18], [28, 36], [8, 11], [16, 36], [1, 28], [8, 34], [2, 37], [0, 24], [18, 27], [1, 10], [10, 24], [27, 38], [18, 29], [19, 30], [27, 37], [10, 29], [3, 26], [15, 26], [15, 30], [1, 14], [25, 29], [0, 23], [25, 27], [8, 24], [2, 17], [29, 34], [21, 27], [4, 12], [14, 38], [19, 22], [24, 36], [27, 36], [21, 24], [2, 25], [1, 16], [2, 30], [6, 33], [6, 30], [3, 32], [23, 35], [12, 25], [3, 15], [1, 22], [21, 25], [29, 33], [3, 39], [13, 31], [1, 9], [4, 20], [17, 23], [2, 34], [22, 39], [18, 24], [0, 10], [12, 19], [4, 29], [15, 34], [7, 21], [10, 20], [22, 28], [23, 25], [1, 12], [24, 35], [0, 17], [4, 31], [0, 32], [0, 11], [22, 31], [5, 36], [14, 19], [5, 16], [21, 39], [14, 28], [13, 16], [18, 33], [0, 20], [5, 21], [16, 30], [4, 14], [21, 22], [3, 17], [7, 39], [21, 36], [10, 35], [18, 26], [19, 20], [15, 39], [7, 29], [13, 22], [30, 38], [21, 30], [14, 25], [26, 37], [11, 38], [11, 23], [2, 19], [30, 37], [13, 38], [0, 3], [1, 35], [33, 36], [0, 27], [33, 37], [0, 19], [7, 18], [27, 28], [25, 26], [1, 25], [25, 31], [10, 18], [19, 25], [0, 35], [6, 26], [4, 27], [5, 11], [9, 27], [23, 33], [10, 21], [2, 27], [37, 38], [4, 17], [2, 32], [8, 13], [13, 17], [6, 9], [14, 18], [30, 31], [21, 26], [27, 30], [5, 39], [21, 38], [21, 32], [10, 39], [0, 33], [8, 20], [6, 20], [32, 38], [13, 36], [0, 14], [11, 32], [11, 16], [0, 26], [31, 36], [11, 31], [0, 18], [8, 35], [19, 24], [18, 25], [10, 25]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s7/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a1d85722fa62156e33d4d286876d44e7aeba049 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-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' +{"p": [36, 30, 39, 14, 10, 28, 34, 4, 1, 38, 29, 16, 12, 7, 6, 3, 32, 17, 20, 22, 26, 24, 33, 0, 35, 9, 19, 18, 5, 15, 27, 37, 11, 23, 31, 13, 21, 25, 8, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s7/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s7/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-l6-s7/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4c36f70a2908c164241eea8924cea558ed7c69d5 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[15, 17], [13, 22], [4, 23], [34, 36], [15, 23], [17, 22], [3, 7], [11, 23], [13, 26], [0, 21], [8, 35], [4, 31], [20, 25], [9, 23], [13, 27], [7, 12], [19, 28], [21, 32], [4, 15], [22, 24], [28, 29], [21, 30], [23, 39], [21, 34], [7, 17], [31, 38], [22, 37], [0, 6], [8, 12], [8, 25], [3, 12], [2, 35], [7, 24], [9, 15], [1, 4], [11, 30], [10, 36], [17, 31], [1, 10], [14, 29], [4, 7], [24, 37], [9, 31], [13, 38], [22, 27], [3, 15], [0, 23], [3, 21], [2, 20], [22, 30], [6, 10], [4, 5], [14, 35], [2, 4], [5, 29], [2, 37], [14, 22], [20, 21], [5, 26], [9, 22], [13, 34], [5, 25], [24, 33], [4, 12], [5, 32], [5, 20], [12, 26], [13, 24], [24, 27], [17, 36], [18, 32], [19, 31], [21, 29], [12, 17], [22, 34], [14, 34], [12, 18], [23, 24], [23, 37], [9, 16], [5, 27], [7, 34], [22, 28], [22, 23], [0, 28], [0, 22], [1, 23], [7, 37], [7, 38], [6, 9], [0, 39], [7, 33], [10, 29], [8, 31], [0, 14], [21, 38], [3, 37], [12, 39], [4, 36], [32, 33], [3, 26], [8, 9], [0, 5], [28, 33], [7, 31], [25, 27], [15, 22], [16, 17], [0, 8], [14, 39], [27, 35], [14, 27], [24, 32], [9, 30], [8, 24], [20, 22], [23, 29], [14, 32], [15, 32], [6, 21], [1, 27], [2, 34], [9, 32], [32, 34], [3, 4], [20, 31], [5, 15], [14, 18], [16, 22], [5, 10], [3, 6], [11, 21], [0, 16], [19, 32], [3, 18], [7, 18], [6, 27], [16, 24], [5, 7], [1, 33], [6, 28], [8, 16], [4, 27], [26, 28], [2, 23], [17, 38], [6, 39], [7, 28], [13, 36], [38, 39], [4, 6], [2, 9], [11, 27], [0, 13], [36, 37], [7, 27], [16, 23], [22, 31], [1, 31], [12, 19], [20, 30], [5, 8], [7, 11], [5, 39], [18, 20], [8, 32], [21, 27], [5, 16], [15, 16], [31, 37], [14, 17], [6, 31], [2, 36], [10, 26], [17, 23], [2, 29], [10, 23], [16, 32], [23, 28], [37, 39], [25, 32], [17, 20], [15, 28], [9, 13], [16, 20], [12, 13], [26, 37], [23, 32], [19, 26], [33, 36], [21, 24], [14, 24], [6, 12], [28, 35], [27, 37], [17, 39], [18, 23], [2, 16], [17, 35], [1, 36], [16, 28], [21, 35], [0, 37], [4, 39], [5, 12], [14, 25], [6, 38], [22, 25], [4, 16], [14, 16], [25, 29], [11, 19], [15, 29], [20, 35], [10, 37], [17, 21], [17, 37], [23, 35], [4, 34], [3, 5], [11, 28], [23, 26], [0, 32], [12, 27], [19, 35], [7, 10], [34, 39], [7, 30], [14, 28], [1, 19], [0, 11], [32, 39], [5, 34], [7, 8], [0, 17], [18, 26], [10, 22], [6, 17], [37, 38], [24, 29], [27, 30], [25, 28], [14, 38], [2, 8], [13, 30], [9, 37], [5, 14], [18, 21], [11, 35], [1, 24], [25, 33], [1, 26], [30, 32], [2, 12], [12, 22], [2, 32], [17, 34], [6, 13], [26, 39], [9, 39], [19, 23], [8, 37], [16, 19], [2, 28], [28, 32], [25, 34], [2, 19], [13, 16], [11, 24], [18, 33], [5, 13], [15, 27], [7, 39], [25, 38], [33, 35], [10, 34], [6, 15], [11, 15], [1, 34], [20, 26], [21, 25], [35, 39], [4, 21], [32, 37], [1, 16], [20, 27], [30, 35], [17, 33], [2, 22], [22, 29], [1, 9], [33, 39], [7, 14], [19, 30], [25, 26], [32, 36], [21, 22], [18, 28], [30, 31], [1, 39], [11, 38], [0, 36], [29, 33], [19, 39], [7, 9], [12, 25], [4, 24], [7, 32], [0, 7], [18, 24], [20, 29], [3, 27], [21, 31], [9, 17], [3, 22], [6, 29], [21, 39], [30, 37], [28, 39], [10, 27], [26, 30], [1, 12], [4, 19], [9, 11], [9, 35], [21, 26], [8, 15], [10, 24], [5, 18], [1, 29], [1, 22], [12, 36], [3, 35], [1, 30], [22, 26], [7, 36], [25, 30], [12, 23], [8, 39], [25, 35], [11, 22], [11, 32], [26, 29], [8, 36], [23, 34], [30, 39], [16, 39], [3, 11], [24, 39], [10, 33], [32, 38], [22, 35], [12, 21], [29, 37], [18, 38], [20, 23], [4, 20], [4, 8], [24, 38], [31, 39], [20, 36], [11, 16], [2, 15], [4, 33], [10, 32], [4, 32], [11, 14], [6, 34], [1, 35], [28, 36], [26, 38], [19, 20], [5, 11], [9, 33], [23, 27], [21, 36], [3, 8], [23, 30], [22, 39], [22, 33], [19, 37], [0, 31], [28, 30], [21, 23], [4, 18], [0, 35], [1, 6], [1, 28], [8, 22], [34, 35], [18, 19], [23, 38], [0, 24], [3, 9], [14, 20], [23, 33], [16, 18], [12, 16], [29, 39], [4, 14], [30, 36], [1, 11], [1, 3], [20, 37], [13, 39], [8, 28], [22, 36], [12, 15], [15, 25], [3, 19], [5, 22], [17, 29], [11, 20], [6, 22], [8, 33], [4, 29], [3, 10], [2, 39], [10, 18], [0, 15], [1, 14], [10, 13], [29, 32], [17, 27], [10, 20], [7, 19], [13, 15], [10, 11], [8, 18], [3, 20], [10, 31], [25, 37], [8, 26], [18, 29], [13, 37], [21, 37], [2, 26], [8, 11], [35, 38], [5, 19], [19, 36], [3, 38], [12, 37], [3, 24], [20, 24], [0, 1], [3, 23], [27, 33], [1, 7], [10, 19], [27, 28], [13, 21], [6, 25], [19, 34], [10, 21], [10, 28], [6, 26], [12, 32], [10, 35], [12, 30], [2, 10], [26, 32], [19, 33], [8, 17], [21, 33], [20, 32], [12, 38], [1, 25], [3, 39], [14, 15], [2, 7], [24, 26], [15, 37], [16, 29], [15, 19], [15, 26], [33, 37], [28, 34], [0, 30], [16, 36], [1, 20], [3, 29], [2, 13], [10, 38], [2, 24], [2, 31], [16, 38], [20, 39], [7, 22], [9, 36], [4, 37], [0, 34], [0, 25], [5, 30], [24, 31], [24, 30], [16, 21], [7, 35], [34, 37], [18, 30], [8, 19], [13, 25], [15, 20], [11, 12], [20, 34], [7, 23], [4, 10]], "edges2": [[34, 36], [11, 25], [23, 30], [3, 16], [6, 8], [3, 25], [2, 5], [5, 23], [9, 13], [2, 24], [10, 31], [12, 24], [11, 36], [10, 34], [13, 27], [15, 19], [1, 13], [3, 11], [6, 28], [13, 24], [30, 32], [19, 33], [4, 35], [11, 21], [32, 36], [5, 33], [14, 30], [15, 33], [4, 11], [12, 39], [0, 29], [7, 8], [9, 34], [3, 5], [1, 32], [34, 38], [17, 32], [20, 24], [21, 29], [17, 26], [28, 29], [4, 22], [20, 32], [10, 37], [5, 19], [4, 28], [26, 32], [6, 18], [9, 23], [22, 23], [10, 23], [2, 7], [0, 5], [6, 10], [30, 35], [16, 35], [13, 29], [1, 21], [0, 39], [8, 17], [3, 18], [8, 16], [7, 9], [30, 33], [9, 24], [5, 18], [3, 28], [22, 37], [26, 39], [20, 27], [23, 38], [2, 36], [26, 33], [6, 36], [13, 18], [12, 28], [12, 33], [7, 28], [15, 25], [21, 31], [33, 35], [0, 30], [5, 15], [11, 39], [25, 38], [7, 35], [5, 27], [13, 39], [24, 32], [8, 14], [29, 31], [7, 25], [24, 31], [0, 12], [24, 27], [0, 36], [10, 15], [3, 6], [10, 11], [5, 32], [14, 35], [17, 36], [24, 37], [26, 28], [15, 29], [12, 18], [22, 25], [9, 11], [13, 14], [4, 23], [4, 16], [4, 5], [7, 19], [22, 30], [3, 9], [24, 25], [26, 35], [2, 12], [3, 33], [2, 33], [9, 33], [9, 36], [2, 6], [12, 17], [10, 30], [22, 27], [0, 16], [22, 29], [4, 25], [11, 20], [10, 12], [19, 27], [17, 24], [25, 37], [4, 18], [12, 30], [2, 8], [24, 34], [9, 25], [18, 23], [1, 36], [14, 26], [5, 22], [27, 33], [11, 28], [32, 39], [19, 35], [23, 29], [4, 30], [16, 38], [3, 7], [23, 24], [11, 22], [3, 12], [17, 21], [4, 39], [16, 33], [4, 38], [16, 22], [3, 10], [10, 14], [1, 39], [14, 29], [17, 37], [21, 33], [12, 16], [2, 31], [0, 2], [0, 13], [12, 20], [34, 37], [11, 27], [38, 39], [9, 15], [20, 29], [22, 26], [2, 23], [31, 33], [31, 34], [35, 39], [32, 33], [2, 26], [12, 22], [1, 17], [19, 29], [25, 39], [29, 30], [3, 34], [4, 37], [1, 11], [4, 6], [5, 29], [29, 37], [19, 26], [20, 22], [17, 25], [3, 14], [26, 27], [14, 15], [6, 13], [5, 30], [5, 6], [19, 34], [8, 9], [15, 23], [18, 30], [1, 3], [13, 23], [4, 8], [9, 18], [24, 33], [11, 15], [0, 25], [26, 29], [12, 14], [7, 32], [1, 23], [4, 21], [15, 35], [15, 28], [6, 32], [14, 22], [11, 29], [25, 35], [10, 22], [24, 26], [0, 15], [8, 29], [35, 36], [3, 19], [7, 33], [11, 12], [21, 23], [18, 28], [15, 24], [8, 32], [10, 28], [12, 21], [6, 17], [29, 35], [2, 11], [7, 27], [12, 34], [25, 36], [5, 34], [29, 39], [20, 26], [17, 38], [36, 37], [2, 39], [9, 19], [33, 34], [8, 12], [16, 24], [0, 8], [1, 2], [24, 29], [31, 39], [2, 15], [16, 27], [2, 4], [26, 30], [18, 34], [6, 15], [33, 39], [5, 20], [2, 22], [7, 36], [12, 27], [28, 33], [5, 31], [0, 4], [7, 12], [3, 38], [11, 35], [3, 36], [37, 39], [9, 31], [35, 37], [1, 19], [9, 28], [25, 33], [28, 31], [9, 26], [32, 35], [14, 16], [14, 34], [14, 33], [4, 33], [16, 26], [6, 11], [16, 32], [9, 12], [1, 5], [9, 30], [11, 19], [6, 16], [2, 35], [2, 10], [26, 31], [1, 4], [1, 37], [16, 29], [5, 13], [13, 26], [17, 33], [4, 36], [15, 20], [7, 24], [6, 35], [14, 20], [20, 35], [10, 26], [13, 30], [1, 33], [8, 25], [20, 23], [17, 34], [2, 13], [10, 32], [0, 38], [5, 9], [7, 38], [7, 31], [22, 32], [30, 34], [4, 13], [30, 36], [17, 31], [27, 35], [7, 34], [19, 28], [28, 32], [0, 22], [14, 24], [19, 39], [20, 28], [15, 32], [8, 37], [12, 32], [1, 38], [18, 35], [6, 31], [1, 20], [13, 33], [33, 38], [16, 28], [4, 10], [2, 38], [15, 17], [2, 14], [8, 19], [3, 22], [0, 31], [17, 18], [11, 24], [2, 28], [11, 26], [16, 18], [28, 36], [8, 11], [16, 36], [1, 28], [8, 34], [2, 37], [0, 24], [18, 27], [1, 10], [10, 24], [27, 38], [18, 29], [19, 30], [27, 37], [10, 29], [3, 26], [15, 26], [15, 30], [1, 14], [25, 29], [0, 23], [25, 27], [8, 24], [2, 17], [29, 34], [21, 27], [4, 12], [14, 38], [19, 22], [24, 36], [27, 36], [21, 24], [2, 25], [1, 16], [2, 30], [6, 33], [6, 30], [3, 32], [23, 35], [12, 25], [3, 15], [1, 22], [21, 25], [29, 33], [3, 39], [13, 31], [1, 9], [4, 20], [17, 23], [2, 34], [22, 39], [18, 24], [0, 10], [12, 19], [4, 29], [15, 34], [7, 21], [10, 20], [22, 28], [23, 25], [1, 12], [24, 35], [0, 17], [4, 31], [0, 32], [0, 11], [22, 31], [5, 36], [14, 19], [5, 16], [21, 39], [14, 28], [13, 16], [18, 33], [0, 20], [5, 21], [16, 30], [4, 14], [21, 22], [3, 17], [7, 39], [21, 36], [10, 35], [18, 26], [19, 20], [15, 39], [7, 29], [13, 22], [30, 38], [21, 30], [14, 25], [26, 37], [11, 38], [11, 23], [2, 19], [30, 37], [13, 38], [0, 3], [1, 35], [33, 36], [0, 27], [33, 37], [0, 19], [7, 18], [27, 28], [25, 26], [1, 25], [25, 31], [10, 18], [19, 25], [0, 35], [6, 26], [4, 27], [5, 11], [9, 27], [23, 33], [10, 21], [2, 27], [37, 38], [4, 17], [2, 32], [8, 13], [13, 17], [6, 9], [14, 18], [30, 31], [21, 26], [27, 30], [5, 39], [21, 38], [21, 32], [10, 39], [0, 33], [8, 20], [6, 20], [32, 38], [13, 36], [0, 14], [11, 32], [11, 16], [0, 26], [31, 36], [11, 31], [0, 18], [8, 35], [19, 24], [18, 25], [10, 25]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s7/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-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-graph-isomorphism-l6-s7/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-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-graph-isomorphism-l6-s9/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s9/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1cf12544a4e04e650172d126fc6104121f53019b --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[12, 36], [18, 24], [5, 7], [1, 19], [13, 35], [13, 25], [22, 29], [8, 9], [7, 12], [3, 26], [2, 25], [8, 17], [9, 15], [0, 12], [6, 28], [7, 27], [13, 18], [17, 39], [24, 36], [9, 11], [22, 31], [10, 21], [22, 25], [2, 21], [2, 17], [18, 27], [19, 30], [30, 37], [12, 28], [14, 23], [5, 20], [10, 28], [12, 24], [24, 37], [22, 23], [11, 32], [16, 19], [5, 17], [4, 33], [5, 32], [26, 33], [13, 27], [16, 36], [18, 22], [4, 16], [9, 10], [7, 23], [13, 22], [6, 26], [4, 6], [16, 37], [7, 36], [1, 27], [8, 14], [11, 13], [2, 29], [9, 39], [4, 12], [9, 21], [4, 19], [14, 39], [21, 24], [23, 33], [0, 35], [3, 9], [11, 21], [0, 23], [17, 30], [16, 26], [9, 29], [24, 30], [8, 11], [0, 31], [2, 24], [14, 20], [17, 32], [29, 39], [5, 19], [10, 38], [23, 31], [14, 33], [3, 5], [1, 36], [22, 32], [3, 33], [7, 13], [1, 5], [5, 31], [0, 36], [0, 8], [25, 39], [15, 24], [10, 31], [1, 14], [3, 29], [8, 12], [8, 30], [2, 11], [9, 26], [19, 24], [7, 10], [9, 31], [17, 36], [6, 7], [11, 34], [5, 34], [20, 39], [16, 31], [9, 32], [7, 32], [18, 30], [8, 29], [29, 31], [26, 32], [15, 26], [2, 30], [29, 37], [4, 17], [26, 31], [2, 37], [34, 39], [26, 34], [4, 22], [8, 33], [1, 39], [26, 27], [35, 36], [3, 19], [5, 37], [28, 37], [10, 16], [0, 28], [1, 15], [21, 27], [19, 35], [9, 20], [6, 16], [9, 16], [18, 33], [15, 38], [11, 30], [15, 33], [26, 39], [3, 25], [8, 38], [6, 32], [25, 32], [18, 38], [36, 38], [31, 38], [6, 23], [20, 25], [27, 33], [6, 12], [10, 37], [10, 13], [4, 15], [17, 37], [19, 26], [4, 8], [18, 29], [12, 34], [12, 39], [14, 37], [8, 26], [36, 39], [11, 24], [7, 19], [3, 36], [1, 28], [5, 27], [7, 38], [17, 38], [10, 32], [1, 8], [0, 37], [7, 24], [2, 19], [20, 31], [25, 34], [15, 17], [11, 36], [11, 20], [3, 22], [13, 16], [21, 39], [2, 31], [11, 25], [20, 36], [3, 7], [22, 28], [15, 20], [12, 38], [27, 39], [26, 30], [7, 29], [3, 20], [21, 37], [2, 35], [11, 33], [12, 14], [32, 39], [5, 18], [8, 20], [18, 34], [11, 18], [24, 26], [1, 10], [5, 6], [18, 39], [4, 5], [2, 9], [8, 10], [2, 23], [2, 3], [2, 15], [8, 31], [11, 27], [3, 8], [26, 36], [27, 35], [15, 21], [6, 33], [17, 22], [2, 26], [1, 23], [27, 36], [21, 32], [16, 22], [27, 32], [3, 30], [18, 25], [5, 21], [24, 33], [17, 31], [7, 33], [20, 28], [30, 31], [15, 30], [3, 28], [34, 37], [21, 28], [23, 28], [4, 34], [18, 21], [31, 34], [11, 14], [13, 30], [6, 21], [9, 18], [17, 19], [0, 20], [2, 5], [12, 17], [1, 16], [15, 19], [32, 35], [4, 30], [8, 15], [5, 25], [7, 16], [8, 25], [8, 28], [3, 23], [11, 38], [16, 18], [16, 21], [9, 25], [6, 18], [12, 31], [28, 36], [0, 26], [12, 21]], "edges2": [[21, 27], [3, 11], [7, 8], [14, 21], [7, 23], [7, 25], [19, 33], [0, 7], [14, 32], [25, 34], [1, 31], [1, 26], [13, 39], [0, 38], [30, 33], [14, 38], [3, 18], [12, 29], [18, 19], [0, 23], [14, 31], [14, 15], [16, 32], [4, 36], [21, 36], [26, 39], [1, 4], [26, 27], [0, 18], [6, 12], [7, 15], [4, 13], [15, 26], [18, 20], [17, 33], [15, 35], [10, 32], [4, 11], [7, 27], [3, 19], [37, 38], [23, 38], [1, 23], [11, 37], [28, 33], [12, 19], [21, 31], [25, 28], [16, 19], [24, 30], [19, 28], [6, 39], [1, 6], [20, 38], [4, 35], [2, 32], [2, 8], [1, 3], [6, 14], [13, 16], [29, 36], [3, 9], [3, 21], [2, 33], [14, 37], [23, 30], [31, 38], [29, 38], [25, 39], [12, 37], [16, 38], [11, 22], [3, 12], [10, 18], [5, 16], [6, 22], [9, 39], [1, 8], [4, 25], [17, 37], [4, 39], [18, 33], [8, 35], [7, 26], [22, 38], [10, 38], [9, 29], [25, 27], [1, 39], [5, 23], [8, 28], [2, 34], [21, 34], [24, 36], [32, 39], [11, 20], [6, 32], [33, 38], [12, 25], [23, 35], [16, 26], [8, 12], [3, 29], [19, 38], [21, 38], [14, 16], [4, 26], [0, 16], [4, 33], [18, 23], [20, 21], [3, 33], [0, 15], [29, 35], [12, 27], [17, 18], [32, 38], [2, 18], [18, 38], [28, 29], [15, 31], [1, 10], [22, 34], [12, 26], [1, 9], [15, 37], [2, 30], [11, 33], [4, 21], [12, 30], [18, 37], [5, 19], [6, 10], [17, 38], [15, 16], [12, 38], [17, 28], [14, 22], [10, 14], [31, 37], [10, 29], [29, 33], [9, 27], [0, 17], [7, 34], [10, 21], [27, 28], [4, 28], [8, 23], [11, 13], [6, 26], [30, 32], [34, 35], [16, 22], [8, 11], [25, 31], [12, 36], [10, 39], [5, 8], [13, 17], [10, 30], [22, 35], [14, 29], [6, 13], [3, 10], [8, 39], [13, 32], [7, 9], [33, 36], [1, 30], [0, 39], [11, 31], [2, 21], [3, 4], [11, 23], [7, 17], [27, 34], [4, 30], [19, 36], [1, 25], [6, 35], [5, 24], [27, 38], [35, 36], [9, 16], [27, 39], [2, 28], [19, 21], [4, 14], [26, 30], [13, 18], [20, 39], [9, 11], [15, 24], [8, 18], [1, 11], [2, 20], [17, 22], [16, 30], [8, 36], [16, 39], [10, 16], [14, 18], [10, 23], [4, 18], [8, 15], [22, 27], [5, 26], [10, 20], [11, 19], [9, 36], [13, 28], [5, 7], [0, 29], [10, 12], [16, 27], [15, 33], [9, 15], [2, 39], [24, 37], [15, 17], [25, 30], [8, 10], [2, 5], [21, 32], [31, 34], [3, 20], [19, 39], [3, 36], [26, 35], [9, 12], [35, 38], [12, 18], [6, 15], [6, 17], [7, 36], [24, 26], [7, 30], [1, 16], [27, 29], [2, 31], [5, 32], [34, 37], [23, 31], [17, 31], [7, 20], [7, 21], [28, 36], [15, 21], [17, 25], [12, 15], [4, 32], [28, 38], [6, 20], [19, 29], [1, 17], [3, 32], [3, 24], [4, 7], [3, 34], [0, 33], [5, 39], [6, 30], [6, 33], [12, 13], [12, 21], [1, 29], [9, 19], [31, 35], [9, 17], [3, 16], [18, 34], [8, 25]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s9/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c47e987442dc18b2c442bc1899a5a2b5f3dd3795 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [37, 35, 3, 21, 28, 4, 25, 7, 38, 10, 23, 16, 17, 5, 22, 29, 8, 33, 39, 36, 14, 1, 2, 34, 9, 32, 12, 26, 31, 20, 19, 18, 30, 27, 13, 24, 15, 11, 0, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s9/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s9/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-l6-s9/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1cf12544a4e04e650172d126fc6104121f53019b --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[12, 36], [18, 24], [5, 7], [1, 19], [13, 35], [13, 25], [22, 29], [8, 9], [7, 12], [3, 26], [2, 25], [8, 17], [9, 15], [0, 12], [6, 28], [7, 27], [13, 18], [17, 39], [24, 36], [9, 11], [22, 31], [10, 21], [22, 25], [2, 21], [2, 17], [18, 27], [19, 30], [30, 37], [12, 28], [14, 23], [5, 20], [10, 28], [12, 24], [24, 37], [22, 23], [11, 32], [16, 19], [5, 17], [4, 33], [5, 32], [26, 33], [13, 27], [16, 36], [18, 22], [4, 16], [9, 10], [7, 23], [13, 22], [6, 26], [4, 6], [16, 37], [7, 36], [1, 27], [8, 14], [11, 13], [2, 29], [9, 39], [4, 12], [9, 21], [4, 19], [14, 39], [21, 24], [23, 33], [0, 35], [3, 9], [11, 21], [0, 23], [17, 30], [16, 26], [9, 29], [24, 30], [8, 11], [0, 31], [2, 24], [14, 20], [17, 32], [29, 39], [5, 19], [10, 38], [23, 31], [14, 33], [3, 5], [1, 36], [22, 32], [3, 33], [7, 13], [1, 5], [5, 31], [0, 36], [0, 8], [25, 39], [15, 24], [10, 31], [1, 14], [3, 29], [8, 12], [8, 30], [2, 11], [9, 26], [19, 24], [7, 10], [9, 31], [17, 36], [6, 7], [11, 34], [5, 34], [20, 39], [16, 31], [9, 32], [7, 32], [18, 30], [8, 29], [29, 31], [26, 32], [15, 26], [2, 30], [29, 37], [4, 17], [26, 31], [2, 37], [34, 39], [26, 34], [4, 22], [8, 33], [1, 39], [26, 27], [35, 36], [3, 19], [5, 37], [28, 37], [10, 16], [0, 28], [1, 15], [21, 27], [19, 35], [9, 20], [6, 16], [9, 16], [18, 33], [15, 38], [11, 30], [15, 33], [26, 39], [3, 25], [8, 38], [6, 32], [25, 32], [18, 38], [36, 38], [31, 38], [6, 23], [20, 25], [27, 33], [6, 12], [10, 37], [10, 13], [4, 15], [17, 37], [19, 26], [4, 8], [18, 29], [12, 34], [12, 39], [14, 37], [8, 26], [36, 39], [11, 24], [7, 19], [3, 36], [1, 28], [5, 27], [7, 38], [17, 38], [10, 32], [1, 8], [0, 37], [7, 24], [2, 19], [20, 31], [25, 34], [15, 17], [11, 36], [11, 20], [3, 22], [13, 16], [21, 39], [2, 31], [11, 25], [20, 36], [3, 7], [22, 28], [15, 20], [12, 38], [27, 39], [26, 30], [7, 29], [3, 20], [21, 37], [2, 35], [11, 33], [12, 14], [32, 39], [5, 18], [8, 20], [18, 34], [11, 18], [24, 26], [1, 10], [5, 6], [18, 39], [4, 5], [2, 9], [8, 10], [2, 23], [2, 3], [2, 15], [8, 31], [11, 27], [3, 8], [26, 36], [27, 35], [15, 21], [6, 33], [17, 22], [2, 26], [1, 23], [27, 36], [21, 32], [16, 22], [27, 32], [3, 30], [18, 25], [5, 21], [24, 33], [17, 31], [7, 33], [20, 28], [30, 31], [15, 30], [3, 28], [34, 37], [21, 28], [23, 28], [4, 34], [18, 21], [31, 34], [11, 14], [13, 30], [6, 21], [9, 18], [17, 19], [0, 20], [2, 5], [12, 17], [1, 16], [15, 19], [32, 35], [4, 30], [8, 15], [5, 25], [7, 16], [8, 25], [8, 28], [3, 23], [11, 38], [16, 18], [16, 21], [9, 25], [6, 18], [12, 31], [28, 36], [0, 26], [12, 21]], "edges2": [[21, 27], [3, 11], [7, 8], [14, 21], [7, 23], [7, 25], [19, 33], [0, 7], [14, 32], [25, 34], [1, 31], [1, 26], [13, 39], [0, 38], [30, 33], [14, 38], [3, 18], [12, 29], [18, 19], [0, 23], [14, 31], [14, 15], [16, 32], [4, 36], [21, 36], [26, 39], [1, 4], [26, 27], [0, 18], [6, 12], [7, 15], [4, 13], [15, 26], [18, 20], [17, 33], [15, 35], [10, 32], [4, 11], [7, 27], [3, 19], [37, 38], [23, 38], [1, 23], [11, 37], [28, 33], [12, 19], [21, 31], [25, 28], [16, 19], [24, 30], [19, 28], [6, 39], [1, 6], [20, 38], [4, 35], [2, 32], [2, 8], [1, 3], [6, 14], [13, 16], [29, 36], [3, 9], [3, 21], [2, 33], [14, 37], [23, 30], [31, 38], [29, 38], [25, 39], [12, 37], [16, 38], [11, 22], [3, 12], [10, 18], [5, 16], [6, 22], [9, 39], [1, 8], [4, 25], [17, 37], [4, 39], [18, 33], [8, 35], [7, 26], [22, 38], [10, 38], [9, 29], [25, 27], [1, 39], [5, 23], [8, 28], [2, 34], [21, 34], [24, 36], [32, 39], [11, 20], [6, 32], [33, 38], [12, 25], [23, 35], [16, 26], [8, 12], [3, 29], [19, 38], [21, 38], [14, 16], [4, 26], [0, 16], [4, 33], [18, 23], [20, 21], [3, 33], [0, 15], [29, 35], [12, 27], [17, 18], [32, 38], [2, 18], [18, 38], [28, 29], [15, 31], [1, 10], [22, 34], [12, 26], [1, 9], [15, 37], [2, 30], [11, 33], [4, 21], [12, 30], [18, 37], [5, 19], [6, 10], [17, 38], [15, 16], [12, 38], [17, 28], [14, 22], [10, 14], [31, 37], [10, 29], [29, 33], [9, 27], [0, 17], [7, 34], [10, 21], [27, 28], [4, 28], [8, 23], [11, 13], [6, 26], [30, 32], [34, 35], [16, 22], [8, 11], [25, 31], [12, 36], [10, 39], [5, 8], [13, 17], [10, 30], [22, 35], [14, 29], [6, 13], [3, 10], [8, 39], [13, 32], [7, 9], [33, 36], [1, 30], [0, 39], [11, 31], [2, 21], [3, 4], [11, 23], [7, 17], [27, 34], [4, 30], [19, 36], [1, 25], [6, 35], [5, 24], [27, 38], [35, 36], [9, 16], [27, 39], [2, 28], [19, 21], [4, 14], [26, 30], [13, 18], [20, 39], [9, 11], [15, 24], [8, 18], [1, 11], [2, 20], [17, 22], [16, 30], [8, 36], [16, 39], [10, 16], [14, 18], [10, 23], [4, 18], [8, 15], [22, 27], [5, 26], [10, 20], [11, 19], [9, 36], [13, 28], [5, 7], [0, 29], [10, 12], [16, 27], [15, 33], [9, 15], [2, 39], [24, 37], [15, 17], [25, 30], [8, 10], [2, 5], [21, 32], [31, 34], [3, 20], [19, 39], [3, 36], [26, 35], [9, 12], [35, 38], [12, 18], [6, 15], [6, 17], [7, 36], [24, 26], [7, 30], [1, 16], [27, 29], [2, 31], [5, 32], [34, 37], [23, 31], [17, 31], [7, 20], [7, 21], [28, 36], [15, 21], [17, 25], [12, 15], [4, 32], [28, 38], [6, 20], [19, 29], [1, 17], [3, 32], [3, 24], [4, 7], [3, 34], [0, 33], [5, 39], [6, 30], [6, 33], [12, 13], [12, 21], [1, 29], [9, 19], [31, 35], [9, 17], [3, 16], [18, 34], [8, 25]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s9/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s9/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-grid-parity-construction-l2-s1/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s1/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..720c14a25fb343a9a8ab958c9a0010d88087ac28 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["01001", "10111"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s1/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a7969eebda03b816bfb91dfa546612e536c7ba9 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["10111", "11011"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s1/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s1/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-l2-s1/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..720c14a25fb343a9a8ab958c9a0010d88087ac28 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["01001", "10111"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s1/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s1/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s6/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s6/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..422fa467f312d5e1d9bf18a22ec54b73070b0cea --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["00", "10", "01", "01"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s6/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d038ee0eee885c5dc8dad9787c7720e3c6d98530 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["00", "00", "10", "10"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s6/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s6/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-l2-s6/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..422fa467f312d5e1d9bf18a22ec54b73070b0cea --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["00", "10", "01", "01"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s6/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s6/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s8/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s8/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eed4c14fe01d3c4fad6ea9baccaabdb0503af73d --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["00", "00", "11", "10", "11"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s8/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..098d4369a77ca5477a7790f2ce334299cc2dc30b --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["01", "11", "01", "11", "11"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s8/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s8/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-l2-s8/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eed4c14fe01d3c4fad6ea9baccaabdb0503af73d --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["00", "00", "11", "10", "11"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s8/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s8/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s7/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-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-grid-parity-construction-l6-s7/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a30ac54d85eb08e2cf7c1df3fb327224f0975e4a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["01001101000110", "01101000110001", "01101100011011", "10110110010101", "11110000000110", "01100110011100", "10101101000000", "01101110101110", "10100001011000", "00100010100110", "00001100101111", "00000101100100", "10101100000000", "01110111011110", "00011001101010", "01000101110110", "00011001001010", "01000110110100", "00010000111101", "01000000110111"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s7/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..767f10cbf3cb0fc29d2fe2bca837a9107ba60860 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-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' +{"grid": ["11011011101011", "01001100001110", "01000001001111", "11000011100011", "11010010001110", "00101100110000", "11010111011010", "10010011110011", "01000100011000", "11011100001111", "01101100101000", "01010011001100", "10110101111110", "01111011110001", "01110011001011", "11001110100011", "00000010001001", "11010000110110", "01011101111100", "00001000110001"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s7/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s7/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-l6-s7/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a30ac54d85eb08e2cf7c1df3fb327224f0975e4a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["01001101000110", "01101000110001", "01101100011011", "10110110010101", "11110000000110", "01100110011100", "10101101000000", "01101110101110", "10100001011000", "00100010100110", "00001100101111", "00000101100100", "10101100000000", "01110111011110", "00011001101010", "01000101110110", "00011001001010", "01000110110100", "00010000111101", "01000000110111"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s7/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-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-grid-parity-construction-l6-s7/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-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-grid-parity-construction-l6-s9/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s9/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..775127e6906d12ecc10ea9d152ecb5d38df913aa --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["10011010110001001", "10101100000100111", "00111111001111110", "11001010000101010", "00001111000001101", "11011111101100011", "11001010000111000", "10100001011010110", "11101011010101010", "10111000101110000"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s9/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a420c3c0cdcb1861ea183c8db86ba38bb4db95d --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["00010000100000110", "10100011000000000", "00001000000100001", "10000000000001101", "00000010000011010", "10001000000100011", "00000001100001101", "01000000010001010", "01000000000000000", "01001011000100000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s9/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s9/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-l6-s9/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..775127e6906d12ecc10ea9d152ecb5d38df913aa --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["10011010110001001", "10101100000100111", "00111111001111110", "11001010000101010", "00001111000001101", "11011111101100011", "11001010000111000", "10100001011010110", "11101011010101010", "10111000101110000"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s9/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s9/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-imp-party-l4-s0/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-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-imp-party-l4-s0/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d6820ea10a448496ef4fdb075ede08b4ba6c6fbf --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 3], [0, 8], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 20], [0, 21], [0, 22], [0, 23], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 33], [0, 35], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [2, 8], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 19], [2, 20], [2, 21], [2, 23], [2, 25], [2, 26], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 35], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [4, 8], [4, 10], [4, 11], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 21], [4, 23], [4, 25], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 33], [4, 35], [5, 8], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 19], [5, 21], [5, 22], [5, 23], [5, 26], [5, 28], [5, 30], [5, 31], [5, 33], [5, 35], [6, 8], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 19], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 30], [6, 31], [6, 33], [6, 35], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 19], [7, 20], [7, 21], [7, 23], [7, 25], [7, 26], [7, 28], [7, 29], [7, 30], [7, 31], [7, 33], [7, 35], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 19], [9, 21], [9, 22], [9, 23], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 33], [9, 35], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 33], [13, 34], [13, 35], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 25], [18, 26], [18, 28], [18, 29], [18, 30], [18, 31], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [19, 35], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 33], [20, 34], [20, 35], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [24, 28], [24, 29], [24, 30], [24, 31], [24, 33], [24, 35], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [27, 28], [27, 29], [27, 30], [27, 31], [27, 33], [27, 35], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [30, 31], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 35], [33, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s0/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a71e640a98bb095153bbb731dc4c7f899418286d --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-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' +{"clique": [1, 3, 8, 10, 14, 15, 16, 19, 23, 25, 28, 35]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s0/tests/check.py b/tasks/construct-rlve-imp-party-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s0/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l4-s0/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d6820ea10a448496ef4fdb075ede08b4ba6c6fbf --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 3], [0, 8], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 20], [0, 21], [0, 22], [0, 23], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 33], [0, 35], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [2, 8], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 19], [2, 20], [2, 21], [2, 23], [2, 25], [2, 26], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 35], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [4, 8], [4, 10], [4, 11], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 21], [4, 23], [4, 25], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 33], [4, 35], [5, 8], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 19], [5, 21], [5, 22], [5, 23], [5, 26], [5, 28], [5, 30], [5, 31], [5, 33], [5, 35], [6, 8], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 19], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 30], [6, 31], [6, 33], [6, 35], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 19], [7, 20], [7, 21], [7, 23], [7, 25], [7, 26], [7, 28], [7, 29], [7, 30], [7, 31], [7, 33], [7, 35], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 19], [9, 21], [9, 22], [9, 23], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 33], [9, 35], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 33], [13, 34], [13, 35], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 25], [18, 26], [18, 28], [18, 29], [18, 30], [18, 31], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [19, 35], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 33], [20, 34], [20, 35], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [24, 28], [24, 29], [24, 30], [24, 31], [24, 33], [24, 35], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [27, 28], [27, 29], [27, 30], [27, 31], [27, 33], [27, 35], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [30, 31], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 35], [33, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s0/tests/run.py b/tasks/construct-rlve-imp-party-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-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-imp-party-l4-s0/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-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-imp-party-l4-s7/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-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-imp-party-l4-s7/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6b833285f988d38069d46e5c92b0533d8d14f7a0 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 3], [0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 20], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 31], [0, 33], [0, 34], [0, 35], [1, 14], [1, 16], [1, 20], [1, 25], [2, 17], [2, 18], [3, 5], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 20], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 31], [3, 33], [3, 34], [3, 35], [4, 23], [4, 31], [4, 35], [5, 6], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 20], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 30], [6, 31], [6, 33], [6, 34], [6, 35], [7, 11], [7, 23], [7, 25], [7, 35], [8, 9], [8, 10], [8, 11], [8, 12], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 20], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 31], [8, 33], [8, 34], [8, 35], [9, 10], [9, 11], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 20], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 31], [9, 33], [9, 34], [9, 35], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 20], [10, 22], [10, 23], [10, 24], [10, 25], [10, 26], [10, 27], [10, 30], [10, 31], [10, 33], [10, 34], [10, 35], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 31], [11, 33], [11, 34], [11, 35], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 20], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 31], [14, 33], [14, 34], [14, 35], [15, 16], [15, 17], [15, 18], [15, 20], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 31], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 20], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 31], [16, 33], [16, 34], [16, 35], [17, 18], [17, 20], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 31], [17, 33], [17, 34], [17, 35], [18, 20], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 30], [18, 31], [18, 33], [18, 34], [18, 35], [19, 27], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 31], [20, 33], [20, 34], [20, 35], [21, 23], [22, 23], [22, 26], [23, 24], [23, 25], [23, 26], [23, 27], [23, 31], [23, 33], [23, 34], [23, 35], [24, 25], [24, 26], [24, 27], [24, 30], [24, 31], [24, 33], [24, 34], [24, 35], [25, 26], [25, 27], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [26, 27], [26, 31], [26, 33], [26, 34], [26, 35], [27, 28], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [31, 33], [31, 34], [31, 35], [33, 34], [33, 35], [34, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s7/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..405fa9988ee0828a6d9d789dd1d82d2efde40a7f --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-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' +{"clique": [0, 6, 8, 9, 11, 14, 25, 26, 27, 31, 33, 35]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s7/tests/check.py b/tasks/construct-rlve-imp-party-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s7/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l4-s7/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6b833285f988d38069d46e5c92b0533d8d14f7a0 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 3], [0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 20], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 31], [0, 33], [0, 34], [0, 35], [1, 14], [1, 16], [1, 20], [1, 25], [2, 17], [2, 18], [3, 5], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 20], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 31], [3, 33], [3, 34], [3, 35], [4, 23], [4, 31], [4, 35], [5, 6], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 20], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 30], [6, 31], [6, 33], [6, 34], [6, 35], [7, 11], [7, 23], [7, 25], [7, 35], [8, 9], [8, 10], [8, 11], [8, 12], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 20], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 31], [8, 33], [8, 34], [8, 35], [9, 10], [9, 11], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 20], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 31], [9, 33], [9, 34], [9, 35], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 20], [10, 22], [10, 23], [10, 24], [10, 25], [10, 26], [10, 27], [10, 30], [10, 31], [10, 33], [10, 34], [10, 35], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 31], [11, 33], [11, 34], [11, 35], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 20], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 31], [14, 33], [14, 34], [14, 35], [15, 16], [15, 17], [15, 18], [15, 20], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 31], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 20], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 31], [16, 33], [16, 34], [16, 35], [17, 18], [17, 20], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 31], [17, 33], [17, 34], [17, 35], [18, 20], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 30], [18, 31], [18, 33], [18, 34], [18, 35], [19, 27], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 31], [20, 33], [20, 34], [20, 35], [21, 23], [22, 23], [22, 26], [23, 24], [23, 25], [23, 26], [23, 27], [23, 31], [23, 33], [23, 34], [23, 35], [24, 25], [24, 26], [24, 27], [24, 30], [24, 31], [24, 33], [24, 34], [24, 35], [25, 26], [25, 27], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [26, 27], [26, 31], [26, 33], [26, 34], [26, 35], [27, 28], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [31, 33], [31, 34], [31, 35], [33, 34], [33, 35], [34, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s7/tests/run.py b/tasks/construct-rlve-imp-party-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-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-imp-party-l4-s7/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-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-integer-linear-system-l3-s0/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-rlve-integer-linear-system-l3-s0/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8add2ec85e1594909d015d46a8c0c78b5d55cd85 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 0, 1, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 1, 1, 0], [1, 0, 0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 0, 1, 0, 1], [0, 1, 0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 1], [1, 0, 0, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 0, 0]], "rhs": [10, 19, 30, 25, 30, 20, 24, 23, 14, 15, 18, 25, 23, 18, 19, 24, 25, 15, 15, 12, 15, 10], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s0/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5050f6c8fe742195d42659130d9920d444fdd6a7 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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' +{"x": [4, 3, 2, 7, 4, 4, 5, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s0/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s0/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l3-s0/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8add2ec85e1594909d015d46a8c0c78b5d55cd85 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 0, 1, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 1, 1, 0], [1, 0, 0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 0, 1, 0, 1], [0, 1, 0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 1], [1, 0, 0, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 0, 0]], "rhs": [10, 19, 30, 25, 30, 20, 24, 23, 14, 15, 18, 25, 23, 18, 19, 24, 25, 15, 15, 12, 15, 10], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s0/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-rlve-integer-linear-system-l3-s0/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-rlve-integer-linear-system-l3-s7/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-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-integer-linear-system-l3-s7/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..99fc97e88be3f12f0f0d1fc9b101121a506d266b --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 1, 1, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 1, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 1, 1, 1]], "rhs": [25, 25, 28, 23, 10, 3, 7, 17, 11, 22, 22, 18, 27, 24, 21, 33], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s7/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ad5382cd176c57a10c56d5f7082970b6b48dee2f --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-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' +{"x": [7, 3, 3, 7, 3, 5, 7, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s7/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s7/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l3-s7/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..99fc97e88be3f12f0f0d1fc9b101121a506d266b --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 1, 1, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 1, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 1, 1, 1]], "rhs": [25, 25, 28, 23, 10, 3, 7, 17, 11, 22, 22, 18, 27, 24, 21, 33], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s7/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-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-integer-linear-system-l3-s7/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-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-largest-convex-polygon-l4-s7/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-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-largest-convex-polygon-l4-s7/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7ba6fb1c98a89568615e8e71fa1a01e178ab08bd --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 1], [1, 15], [13, 1], [1, 8], [8, 10], [6, 4], [13, 13], [7, 9], [5, 13], [8, 3], [18, 6], [15, 9], [15, 15], [18, 14], [7, 5], [2, 11], [17, 14], [2, 8]], "k": 9, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s7/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d9eb4b2e4a70ddf3dc75cfbf3299d370a0f14849 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-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' +{"indices": [3, 15, 8, 12, 16, 10, 2, 9, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s7/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s7/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-l4-s7/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7ba6fb1c98a89568615e8e71fa1a01e178ab08bd --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 1], [1, 15], [13, 1], [1, 8], [8, 10], [6, 4], [13, 13], [7, 9], [5, 13], [8, 3], [18, 6], [15, 9], [15, 15], [18, 14], [7, 5], [2, 11], [17, 14], [2, 8]], "k": 9, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s7/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-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-largest-convex-polygon-l4-s7/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-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-largest-convex-polygon-l4-s9/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-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-largest-convex-polygon-l4-s9/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb03560ec5382dc9ebcbcf320a7269ab84086def --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"points": [[11, 1], [4, 4], [16, 11], [14, 5], [15, 14], [0, 16], [4, 9], [16, 0], [8, 1], [0, 3], [13, 9], [5, 16], [2, 18], [3, 6], [9, 17], [15, 2], [3, 5], [11, 8]], "k": 10, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s9/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..87fbd85ed80429b08eddd510afb3e539c0e8f450 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-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' +{"indices": [5, 12, 14, 4, 2, 3, 0, 8, 1, 13]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s9/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s9/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-l4-s9/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb03560ec5382dc9ebcbcf320a7269ab84086def --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"points": [[11, 1], [4, 4], [16, 11], [14, 5], [15, 14], [0, 16], [4, 9], [16, 0], [8, 1], [0, 3], [13, 9], [5, 16], [2, 18], [3, 6], [9, 17], [15, 2], [3, 5], [11, 8]], "k": 10, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s9/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-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-largest-convex-polygon-l4-s9/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-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-largest-rectangle-l2-s1/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s1/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aee69db07260853cff84728d311b514332ff268c --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-3, -8], [4, 3], [3, 12], [4, 1], [1, -4], [-9, -2], [6, 5], [7, -8], [-1, 7], [8, 8]], "area": 41, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s1/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..95f8aa15fbd015b535681a30f9a2a912cfe60cd5 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [1, 8, 2, 9]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l2-s1/tests/check.py b/tasks/construct-rlve-largest-rectangle-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s1/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-l2-s1/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aee69db07260853cff84728d311b514332ff268c --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-3, -8], [4, 3], [3, 12], [4, 1], [1, -4], [-9, -2], [6, 5], [7, -8], [-1, 7], [8, 8]], "area": 41, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s1/tests/run.py b/tasks/construct-rlve-largest-rectangle-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s1/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s6/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s6/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fd5a1b142963205ef7614f93f85c3070062f825c --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"points": [[2, 1], [-6, 3], [-2, 5], [2, 9], [6, 5], [5, 3], [-8, 10], [-4, 3], [9, 7], [6, -7]], "area": 32, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s6/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8706f401c6d23a1e86a5c8321cdfd09fb11cd92d --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [0, 2, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l2-s6/tests/check.py b/tasks/construct-rlve-largest-rectangle-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s6/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-l2-s6/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fd5a1b142963205ef7614f93f85c3070062f825c --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"points": [[2, 1], [-6, 3], [-2, 5], [2, 9], [6, 5], [5, 3], [-8, 10], [-4, 3], [9, 7], [6, -7]], "area": 32, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s6/tests/run.py b/tasks/construct-rlve-largest-rectangle-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s6/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s8/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s8/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fbadec72e721875bbdd553dacb3b46d2da5b5c89 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-3, -7], [-1, -7], [10, 5], [0, -4], [-7, 6], [3, 0], [6, 1], [-4, -6], [1, 10], [-3, -3]], "area": 10, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s8/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..790f4f918825ea408edc4de73b89bcc714598749 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [1, 3, 9, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l2-s8/tests/check.py b/tasks/construct-rlve-largest-rectangle-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s8/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-l2-s8/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fbadec72e721875bbdd553dacb3b46d2da5b5c89 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-3, -7], [-1, -7], [10, 5], [0, -4], [-7, 6], [3, 0], [6, 1], [-4, -6], [1, 10], [-3, -3]], "area": 10, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s8/tests/run.py b/tasks/construct-rlve-largest-rectangle-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s8/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s7/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-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-largest-rectangle-l6-s7/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8c23d790b54a0000a7ccf55cfe5f91943f1f99b2 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"points": [[35, 7], [7, 58], [-30, -35], [-43, 9], [31, -21], [40, 39], [10, -57], [30, 45], [52, -53], [-2, 43], [60, -45], [6, 24], [-59, 3], [-44, 43], [44, 51], [-16, 60], [17, -46], [-41, -34], [8, 38], [19, -58], [-17, -46], [19, 31], [-42, -7], [2, -12], [-19, -42], [18, -11], [-57, -8], [-30, -36], [-26, 21], [-33, 43], [-11, 28], [-8, 57], [-30, 36], [-47, 44], [4, -25], [-12, 40], [56, -6], [-24, 24], [-27, 14], [6, 46], [-41, -17], [17, -23], [-26, -43], [16, 55], [-48, 26], [45, -22], [31, 14], [-18, 60], [9, -7], [15, -10], [-15, 24], [-37, 23], [47, 55], [-16, -34], [-57, -31], [-9, 36], [36, 22], [-48, 51], [-45, 17], [-7, 42]], "area": 173, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s7/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7cf950ad19751131a464efe27c6ed195f90cce8 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-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' +{"indices": [23, 34, 41, 49]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l6-s7/tests/check.py b/tasks/construct-rlve-largest-rectangle-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s7/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-l6-s7/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8c23d790b54a0000a7ccf55cfe5f91943f1f99b2 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"points": [[35, 7], [7, 58], [-30, -35], [-43, 9], [31, -21], [40, 39], [10, -57], [30, 45], [52, -53], [-2, 43], [60, -45], [6, 24], [-59, 3], [-44, 43], [44, 51], [-16, 60], [17, -46], [-41, -34], [8, 38], [19, -58], [-17, -46], [19, 31], [-42, -7], [2, -12], [-19, -42], [18, -11], [-57, -8], [-30, -36], [-26, 21], [-33, 43], [-11, 28], [-8, 57], [-30, 36], [-47, 44], [4, -25], [-12, 40], [56, -6], [-24, 24], [-27, 14], [6, 46], [-41, -17], [17, -23], [-26, -43], [16, 55], [-48, 26], [45, -22], [31, 14], [-18, 60], [9, -7], [15, -10], [-15, 24], [-37, 23], [47, 55], [-16, -34], [-57, -31], [-9, 36], [36, 22], [-48, 51], [-45, 17], [-7, 42]], "area": 173, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s7/tests/run.py b/tasks/construct-rlve-largest-rectangle-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-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-largest-rectangle-l6-s7/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-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-largest-rectangle-l6-s9/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s9/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0af5580346ba9717714a3a7f101046477090be8e --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-31, 0], [26, -31], [-10, -15], [-46, -27], [-30, 42], [-14, -56], [29, -17], [-39, 27], [-13, -28], [40, 30], [30, 19], [18, 26], [-45, -50], [16, 52], [-56, 31], [35, -47], [-31, -30], [44, -4], [34, -21], [3, -25], [48, -47], [52, -47], [16, 5], [55, -24], [13, -4], [55, 2], [52, 9], [-7, -27], [22, -31], [10, -11], [-3, 56], [39, 5], [-2, -53], [-15, -53], [29, -41], [-60, -46], [-16, 42], [16, -56], [33, 26], [-17, 37], [-59, 5], [58, 46], [50, -32], [43, 51], [19, 19], [-54, 6], [30, 53], [8, -6], [12, -40], [-53, 15], [8, -3], [26, -52], [40, 40], [48, -33], [35, 53], [15, -9], [47, -22], [-2, -45], [34, 17], [-2, 24]], "area": 29, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s9/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8bae2a57fcc157c47606fcc3c55d92bd914b8e74 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [24, 47, 29, 55]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l6-s9/tests/check.py b/tasks/construct-rlve-largest-rectangle-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s9/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-l6-s9/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0af5580346ba9717714a3a7f101046477090be8e --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-31, 0], [26, -31], [-10, -15], [-46, -27], [-30, 42], [-14, -56], [29, -17], [-39, 27], [-13, -28], [40, 30], [30, 19], [18, 26], [-45, -50], [16, 52], [-56, 31], [35, -47], [-31, -30], [44, -4], [34, -21], [3, -25], [48, -47], [52, -47], [16, 5], [55, -24], [13, -4], [55, 2], [52, 9], [-7, -27], [22, -31], [10, -11], [-3, 56], [39, 5], [-2, -53], [-15, -53], [29, -41], [-60, -46], [-16, 42], [16, -56], [33, 26], [-17, 37], [-59, 5], [58, 46], [50, -32], [43, 51], [19, 19], [-54, 6], [30, 53], [8, -6], [12, -40], [-53, 15], [8, -3], [26, -52], [40, 40], [48, -33], [35, 53], [15, -9], [47, -22], [-2, -45], [34, 17], [-2, 24]], "area": 29, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s9/tests/run.py b/tasks/construct-rlve-largest-rectangle-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s9/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-matrix-permutation-equivalence-l5-s2/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-rlve-matrix-permutation-equivalence-l5-s2/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dfe3610e2c161e35dd225add916ada32e99f5822 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"A": ["00", "00", "01", "10", "00", "10", "00", "01", "00", "10", "10", "01", "00", "10", "01", "00"], "B": ["01", "01", "00", "00", "00", "01", "00", "01", "10", "01", "00", "00", "10", "10", "10", "00"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5edc972112f323925f12f35c65a4341a7995f39d --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [9, 5, 1, 15, 8, 13, 4, 3, 14, 10, 0, 12, 7, 2, 11, 6], "b": [1, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dfe3610e2c161e35dd225add916ada32e99f5822 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"A": ["00", "00", "01", "10", "00", "10", "00", "01", "00", "10", "10", "01", "00", "10", "01", "00"], "B": ["01", "01", "00", "00", "00", "01", "00", "01", "10", "01", "00", "00", "10", "10", "10", "00"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-rlve-matrix-permutation-equivalence-l5-s2/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-rlve-matrix-permutation-equivalence-l5-s5/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s5/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5a12966d453dc6cf533b83bac7792963f077fdd1 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": ["101110", "011110", "111111", "001110", "011111", "100101", "001101", "001110", "101110", "111010", "011111", "111111", "111011", "101111", "111100", "110111"], "B": ["110100", "111111", "011100", "111110", "111010", "110111", "101011", "110111", "110010", "011111", "111001", "111111", "101111", "110011", "110010", "111010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6a5216634246e8f523a01281501ba818c1c538a1 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [6, 2, 5, 13, 8, 10, 9, 4, 3, 15, 14, 11, 12, 1, 7, 0], "b": [2, 3, 0, 5, 4, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5a12966d453dc6cf533b83bac7792963f077fdd1 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": ["101110", "011110", "111111", "001110", "011111", "100101", "001101", "001110", "101110", "111010", "011111", "111111", "111011", "101111", "111100", "110111"], "B": ["110100", "111111", "011100", "111110", "111010", "110111", "101011", "110111", "110010", "011111", "111001", "111111", "101111", "110011", "110010", "111010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s5/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-max-achromatic-coloring-l4-s6/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-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-max-achromatic-coloring-l4-s6/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0c94f5169a7e9c73389f835c7d7e20403fc48f2 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 7, "edges": [[0, 1], [0, 3], [0, 5], [0, 9], [0, 10], [1, 2], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [2, 3], [2, 6], [2, 9], [2, 11], [3, 4], [3, 6], [3, 8], [3, 11], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [5, 8], [5, 9], [5, 11], [7, 8], [7, 10], [10, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s6/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0b137a9d2bf99eeb23b4d08f92448997164824c7 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-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' +{"colors": [0, 1, 2, 3, 4, 2, 0, 3, 5, 6, 5, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s6/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/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-l4-s6/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0c94f5169a7e9c73389f835c7d7e20403fc48f2 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 7, "edges": [[0, 1], [0, 3], [0, 5], [0, 9], [0, 10], [1, 2], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [2, 3], [2, 6], [2, 9], [2, 11], [3, 4], [3, 6], [3, 8], [3, 11], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [5, 8], [5, 9], [5, 11], [7, 8], [7, 10], [10, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s6/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-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-max-achromatic-coloring-l4-s6/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-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-max-achromatic-coloring-l4-s8/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l4-s8/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6d01d34ae41678a22dacc0123d9da8ca092bbb19 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 7, "edges": [[0, 2], [0, 3], [0, 4], [0, 6], [0, 7], [0, 9], [0, 10], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 9], [2, 5], [2, 8], [2, 9], [2, 10], [2, 11], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [4, 11], [5, 6], [5, 9], [6, 7], [6, 8], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [8, 9], [9, 10], [10, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s8/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5912635fb7ac54823d431cb472e0a78386040c15 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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' +{"colors": [0, 0, 1, 1, 2, 3, 1, 3, 4, 5, 6, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s8/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/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-l4-s8/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6d01d34ae41678a22dacc0123d9da8ca092bbb19 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 7, "edges": [[0, 2], [0, 3], [0, 4], [0, 6], [0, 7], [0, 9], [0, 10], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 9], [2, 5], [2, 8], [2, 9], [2, 10], [2, 11], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [4, 11], [5, 6], [5, 9], [6, 7], [6, 8], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [8, 9], [9, 10], [10, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s8/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l4-s8/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-maximum-clique-l6-s3/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-rlve-maximum-clique-l6-s3/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3278cdb1b41e90ec4ca8710df3f0944bd91dc506 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 12, "edges": [[0, 1], [0, 2], [0, 4], [0, 8], [0, 9], [0, 13], [0, 14], [0, 15], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 36], [0, 40], [0, 41], [0, 42], [0, 45], [0, 46], [0, 48], [0, 49], [0, 50], [0, 51], [0, 53], [0, 55], [1, 2], [1, 4], [1, 6], [1, 7], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 27], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 53], [1, 54], [1, 55], [2, 3], [2, 4], [2, 6], [2, 7], [2, 9], [2, 10], [2, 11], [2, 13], [2, 15], [2, 16], [2, 18], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 47], [2, 48], [2, 49], [2, 50], [2, 53], [2, 54], [3, 4], [3, 5], [3, 9], [3, 10], [3, 11], [3, 12], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 24], [3, 26], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 37], [3, 39], [3, 41], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 52], [3, 53], [4, 6], [4, 7], [4, 9], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 18], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 44], [4, 47], [4, 49], [4, 50], [4, 51], [4, 52], [4, 53], [4, 54], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 24], [5, 25], [5, 26], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 37], [5, 38], [5, 39], [5, 40], [5, 42], [5, 43], [5, 45], [5, 46], [5, 48], [5, 49], [5, 50], [5, 52], [5, 53], [6, 7], [6, 8], [6, 9], [6, 11], [6, 12], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 27], [6, 28], [6, 33], [6, 34], [6, 35], [6, 36], [6, 40], [6, 43], [6, 45], [6, 46], [6, 48], [6, 49], [6, 50], [6, 52], [6, 53], [6, 54], [6, 55], [7, 8], [7, 10], [7, 11], [7, 12], [7, 13], [7, 15], [7, 17], [7, 18], [7, 19], [7, 20], [7, 23], [7, 24], [7, 26], [7, 27], [7, 28], [7, 29], [7, 31], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [7, 39], [7, 40], [7, 42], [7, 43], [7, 45], [7, 47], [7, 49], [7, 51], [7, 54], [8, 9], [8, 10], [8, 12], [8, 15], [8, 16], [8, 22], [8, 23], [8, 24], [8, 27], [8, 29], [8, 30], [8, 32], [8, 33], [8, 34], [8, 36], [8, 38], [8, 39], [8, 41], [8, 43], [8, 44], [8, 46], [8, 47], [8, 48], [8, 50], [8, 51], [8, 52], [8, 55], [9, 10], [9, 11], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 20], [9, 21], [9, 22], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 34], [9, 35], [9, 36], [9, 37], [9, 38], [9, 40], [9, 42], [9, 43], [9, 44], [9, 45], [9, 47], [9, 49], [9, 50], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [10, 11], [10, 13], [10, 14], [10, 15], [10, 16], [10, 18], [10, 20], [10, 22], [10, 23], [10, 27], [10, 28], [10, 30], [10, 32], [10, 33], [10, 34], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 50], [10, 51], [10, 52], [10, 53], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 24], [11, 26], [11, 27], [11, 28], [11, 30], [11, 31], [11, 35], [11, 36], [11, 38], [11, 39], [11, 40], [11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 47], [11, 49], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 26], [12, 28], [12, 30], [12, 31], [12, 32], [12, 33], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [12, 41], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 52], [12, 53], [12, 54], [12, 55], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 23], [13, 24], [13, 25], [13, 29], [13, 30], [13, 31], [13, 32], [13, 34], [13, 36], [13, 38], [13, 39], [13, 40], [13, 41], [13, 43], [13, 44], [13, 46], [13, 47], [13, 48], [13, 49], [13, 51], [13, 53], [13, 54], [13, 55], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 26], [14, 27], [14, 28], [14, 29], [14, 32], [14, 33], [14, 34], [14, 35], [14, 37], [14, 38], [14, 39], [14, 40], [14, 42], [14, 43], [14, 44], [14, 45], [14, 46], [14, 47], [14, 48], [14, 50], [14, 51], [14, 52], [14, 53], [14, 55], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 35], [15, 36], [15, 37], [15, 38], [15, 39], [15, 40], [15, 41], [15, 42], [15, 44], [15, 46], [15, 47], [15, 48], [15, 49], [15, 52], [15, 53], [15, 54], [15, 55], [16, 19], [16, 20], [16, 21], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 29], [16, 33], [16, 34], [16, 35], [16, 36], [16, 37], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 55], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 44], [17, 45], [17, 47], [17, 49], [17, 51], [17, 52], [17, 53], [17, 54], [17, 55], [18, 19], [18, 20], [18, 24], [18, 25], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 42], [18, 43], [18, 45], [18, 47], [18, 48], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [19, 20], [19, 22], [19, 23], [19, 26], [19, 27], [19, 28], [19, 31], [19, 32], [19, 35], [19, 37], [19, 38], [19, 39], [19, 40], [19, 41], [19, 42], [19, 44], [19, 45], [19, 46], [19, 47], [19, 48], [19, 49], [19, 53], [19, 54], [19, 55], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 31], [20, 32], [20, 33], [20, 34], [20, 36], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [20, 44], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 51], [20, 52], [20, 53], [21, 22], [21, 23], [21, 24], [21, 27], [21, 28], [21, 29], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [21, 36], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 44], [21, 46], [21, 47], [21, 49], [21, 50], [21, 51], [21, 52], [21, 53], [21, 54], [22, 23], [22, 25], [22, 26], [22, 27], [22, 29], [22, 30], [22, 31], [22, 32], [22, 35], [22, 36], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 47], [22, 48], [22, 50], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [23, 25], [23, 26], [23, 27], [23, 30], [23, 33], [23, 35], [23, 36], [23, 37], [23, 39], [23, 40], [23, 42], [23, 47], [23, 48], [23, 51], [23, 52], [23, 53], [23, 54], [24, 26], [24, 27], [24, 28], [24, 29], [24, 31], [24, 32], [24, 33], [24, 35], [24, 37], [24, 38], [24, 40], [24, 43], [24, 44], [24, 45], [24, 46], [24, 47], [24, 48], [24, 49], [24, 51], [24, 52], [24, 53], [24, 54], [25, 28], [25, 29], [25, 30], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 43], [25, 44], [25, 45], [25, 47], [25, 48], [25, 51], [25, 52], [25, 54], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 35], [26, 36], [26, 37], [26, 39], [26, 42], [26, 45], [26, 52], [26, 53], [26, 54], [26, 55], [27, 28], [27, 31], [27, 32], [27, 33], [27, 34], [27, 36], [27, 38], [27, 40], [27, 41], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 47], [27, 48], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [28, 29], [28, 30], [28, 33], [28, 34], [28, 35], [28, 36], [28, 37], [28, 38], [28, 39], [28, 42], [28, 43], [28, 45], [28, 47], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 54], [28, 55], [29, 31], [29, 32], [29, 33], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 44], [29, 45], [29, 46], [29, 48], [29, 49], [29, 51], [29, 55], [30, 31], [30, 33], [30, 35], [30, 36], [30, 37], [30, 38], [30, 39], [30, 40], [30, 41], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 47], [30, 48], [30, 49], [30, 50], [30, 51], [30, 52], [30, 53], [30, 54], [31, 32], [31, 33], [31, 34], [31, 36], [31, 37], [31, 39], [31, 43], [31, 44], [31, 45], [31, 46], [31, 47], [31, 48], [31, 49], [31, 51], [31, 54], [31, 55], [32, 33], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 40], [32, 41], [32, 42], [32, 45], [32, 46], [32, 48], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [33, 34], [33, 35], [33, 36], [33, 37], [33, 40], [33, 43], [33, 44], [33, 46], [33, 49], [33, 52], [33, 54], [33, 55], [34, 35], [34, 36], [34, 40], [34, 42], [34, 43], [34, 44], [34, 45], [34, 47], [34, 50], [34, 51], [34, 52], [34, 54], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 50], [35, 51], [35, 53], [35, 54], [36, 37], [36, 40], [36, 41], [36, 43], [36, 46], [36, 47], [36, 48], [36, 49], [36, 53], [36, 54], [37, 40], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 51], [37, 52], [37, 53], [37, 54], [37, 55], [38, 39], [38, 41], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [38, 48], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 55], [39, 41], [39, 43], [39, 44], [39, 45], [39, 47], [39, 48], [39, 49], [39, 50], [39, 52], [39, 53], [39, 54], [40, 41], [40, 46], [40, 47], [40, 48], [40, 49], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [41, 43], [41, 44], [41, 46], [41, 47], [41, 48], [41, 49], [41, 50], [41, 52], [41, 53], [41, 54], [41, 55], [42, 43], [42, 44], [42, 46], [42, 47], [42, 49], [42, 50], [42, 51], [42, 53], [42, 55], [43, 44], [43, 45], [43, 46], [43, 47], [43, 49], [43, 50], [43, 54], [43, 55], [44, 45], [44, 46], [44, 48], [44, 49], [44, 51], [44, 52], [44, 53], [44, 54], [44, 55], [45, 46], [45, 48], [45, 49], [45, 50], [45, 52], [45, 53], [45, 54], [45, 55], [46, 47], [46, 49], [46, 50], [46, 51], [46, 53], [46, 55], [47, 48], [47, 53], [47, 54], [48, 49], [48, 50], [48, 54], [48, 55], [49, 50], [49, 51], [49, 54], [49, 55], [50, 52], [51, 52], [51, 53], [51, 54], [51, 55], [52, 53], [52, 55], [53, 54]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s3/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..66e10bdff7d80f061664499ddc3230e72c251008 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [0, 1, 2, 4, 13, 15, 20, 21, 24, 32, 40, 53]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s3/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s3/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("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l6-s3/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3278cdb1b41e90ec4ca8710df3f0944bd91dc506 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 12, "edges": [[0, 1], [0, 2], [0, 4], [0, 8], [0, 9], [0, 13], [0, 14], [0, 15], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 36], [0, 40], [0, 41], [0, 42], [0, 45], [0, 46], [0, 48], [0, 49], [0, 50], [0, 51], [0, 53], [0, 55], [1, 2], [1, 4], [1, 6], [1, 7], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 27], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 53], [1, 54], [1, 55], [2, 3], [2, 4], [2, 6], [2, 7], [2, 9], [2, 10], [2, 11], [2, 13], [2, 15], [2, 16], [2, 18], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 47], [2, 48], [2, 49], [2, 50], [2, 53], [2, 54], [3, 4], [3, 5], [3, 9], [3, 10], [3, 11], [3, 12], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 24], [3, 26], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 37], [3, 39], [3, 41], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 52], [3, 53], [4, 6], [4, 7], [4, 9], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 18], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 44], [4, 47], [4, 49], [4, 50], [4, 51], [4, 52], [4, 53], [4, 54], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 24], [5, 25], [5, 26], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 37], [5, 38], [5, 39], [5, 40], [5, 42], [5, 43], [5, 45], [5, 46], [5, 48], [5, 49], [5, 50], [5, 52], [5, 53], [6, 7], [6, 8], [6, 9], [6, 11], [6, 12], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 27], [6, 28], [6, 33], [6, 34], [6, 35], [6, 36], [6, 40], [6, 43], [6, 45], [6, 46], [6, 48], [6, 49], [6, 50], [6, 52], [6, 53], [6, 54], [6, 55], [7, 8], [7, 10], [7, 11], [7, 12], [7, 13], [7, 15], [7, 17], [7, 18], [7, 19], [7, 20], [7, 23], [7, 24], [7, 26], [7, 27], [7, 28], [7, 29], [7, 31], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [7, 39], [7, 40], [7, 42], [7, 43], [7, 45], [7, 47], [7, 49], [7, 51], [7, 54], [8, 9], [8, 10], [8, 12], [8, 15], [8, 16], [8, 22], [8, 23], [8, 24], [8, 27], [8, 29], [8, 30], [8, 32], [8, 33], [8, 34], [8, 36], [8, 38], [8, 39], [8, 41], [8, 43], [8, 44], [8, 46], [8, 47], [8, 48], [8, 50], [8, 51], [8, 52], [8, 55], [9, 10], [9, 11], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 20], [9, 21], [9, 22], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 34], [9, 35], [9, 36], [9, 37], [9, 38], [9, 40], [9, 42], [9, 43], [9, 44], [9, 45], [9, 47], [9, 49], [9, 50], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [10, 11], [10, 13], [10, 14], [10, 15], [10, 16], [10, 18], [10, 20], [10, 22], [10, 23], [10, 27], [10, 28], [10, 30], [10, 32], [10, 33], [10, 34], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 50], [10, 51], [10, 52], [10, 53], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 24], [11, 26], [11, 27], [11, 28], [11, 30], [11, 31], [11, 35], [11, 36], [11, 38], [11, 39], [11, 40], [11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 47], [11, 49], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 26], [12, 28], [12, 30], [12, 31], [12, 32], [12, 33], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [12, 41], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 52], [12, 53], [12, 54], [12, 55], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 23], [13, 24], [13, 25], [13, 29], [13, 30], [13, 31], [13, 32], [13, 34], [13, 36], [13, 38], [13, 39], [13, 40], [13, 41], [13, 43], [13, 44], [13, 46], [13, 47], [13, 48], [13, 49], [13, 51], [13, 53], [13, 54], [13, 55], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 26], [14, 27], [14, 28], [14, 29], [14, 32], [14, 33], [14, 34], [14, 35], [14, 37], [14, 38], [14, 39], [14, 40], [14, 42], [14, 43], [14, 44], [14, 45], [14, 46], [14, 47], [14, 48], [14, 50], [14, 51], [14, 52], [14, 53], [14, 55], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 35], [15, 36], [15, 37], [15, 38], [15, 39], [15, 40], [15, 41], [15, 42], [15, 44], [15, 46], [15, 47], [15, 48], [15, 49], [15, 52], [15, 53], [15, 54], [15, 55], [16, 19], [16, 20], [16, 21], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 29], [16, 33], [16, 34], [16, 35], [16, 36], [16, 37], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 55], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 44], [17, 45], [17, 47], [17, 49], [17, 51], [17, 52], [17, 53], [17, 54], [17, 55], [18, 19], [18, 20], [18, 24], [18, 25], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 42], [18, 43], [18, 45], [18, 47], [18, 48], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [19, 20], [19, 22], [19, 23], [19, 26], [19, 27], [19, 28], [19, 31], [19, 32], [19, 35], [19, 37], [19, 38], [19, 39], [19, 40], [19, 41], [19, 42], [19, 44], [19, 45], [19, 46], [19, 47], [19, 48], [19, 49], [19, 53], [19, 54], [19, 55], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 31], [20, 32], [20, 33], [20, 34], [20, 36], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [20, 44], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 51], [20, 52], [20, 53], [21, 22], [21, 23], [21, 24], [21, 27], [21, 28], [21, 29], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [21, 36], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 44], [21, 46], [21, 47], [21, 49], [21, 50], [21, 51], [21, 52], [21, 53], [21, 54], [22, 23], [22, 25], [22, 26], [22, 27], [22, 29], [22, 30], [22, 31], [22, 32], [22, 35], [22, 36], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 47], [22, 48], [22, 50], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [23, 25], [23, 26], [23, 27], [23, 30], [23, 33], [23, 35], [23, 36], [23, 37], [23, 39], [23, 40], [23, 42], [23, 47], [23, 48], [23, 51], [23, 52], [23, 53], [23, 54], [24, 26], [24, 27], [24, 28], [24, 29], [24, 31], [24, 32], [24, 33], [24, 35], [24, 37], [24, 38], [24, 40], [24, 43], [24, 44], [24, 45], [24, 46], [24, 47], [24, 48], [24, 49], [24, 51], [24, 52], [24, 53], [24, 54], [25, 28], [25, 29], [25, 30], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 43], [25, 44], [25, 45], [25, 47], [25, 48], [25, 51], [25, 52], [25, 54], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 35], [26, 36], [26, 37], [26, 39], [26, 42], [26, 45], [26, 52], [26, 53], [26, 54], [26, 55], [27, 28], [27, 31], [27, 32], [27, 33], [27, 34], [27, 36], [27, 38], [27, 40], [27, 41], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 47], [27, 48], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [28, 29], [28, 30], [28, 33], [28, 34], [28, 35], [28, 36], [28, 37], [28, 38], [28, 39], [28, 42], [28, 43], [28, 45], [28, 47], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 54], [28, 55], [29, 31], [29, 32], [29, 33], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 44], [29, 45], [29, 46], [29, 48], [29, 49], [29, 51], [29, 55], [30, 31], [30, 33], [30, 35], [30, 36], [30, 37], [30, 38], [30, 39], [30, 40], [30, 41], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 47], [30, 48], [30, 49], [30, 50], [30, 51], [30, 52], [30, 53], [30, 54], [31, 32], [31, 33], [31, 34], [31, 36], [31, 37], [31, 39], [31, 43], [31, 44], [31, 45], [31, 46], [31, 47], [31, 48], [31, 49], [31, 51], [31, 54], [31, 55], [32, 33], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 40], [32, 41], [32, 42], [32, 45], [32, 46], [32, 48], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [33, 34], [33, 35], [33, 36], [33, 37], [33, 40], [33, 43], [33, 44], [33, 46], [33, 49], [33, 52], [33, 54], [33, 55], [34, 35], [34, 36], [34, 40], [34, 42], [34, 43], [34, 44], [34, 45], [34, 47], [34, 50], [34, 51], [34, 52], [34, 54], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 50], [35, 51], [35, 53], [35, 54], [36, 37], [36, 40], [36, 41], [36, 43], [36, 46], [36, 47], [36, 48], [36, 49], [36, 53], [36, 54], [37, 40], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 51], [37, 52], [37, 53], [37, 54], [37, 55], [38, 39], [38, 41], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [38, 48], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 55], [39, 41], [39, 43], [39, 44], [39, 45], [39, 47], [39, 48], [39, 49], [39, 50], [39, 52], [39, 53], [39, 54], [40, 41], [40, 46], [40, 47], [40, 48], [40, 49], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [41, 43], [41, 44], [41, 46], [41, 47], [41, 48], [41, 49], [41, 50], [41, 52], [41, 53], [41, 54], [41, 55], [42, 43], [42, 44], [42, 46], [42, 47], [42, 49], [42, 50], [42, 51], [42, 53], [42, 55], [43, 44], [43, 45], [43, 46], [43, 47], [43, 49], [43, 50], [43, 54], [43, 55], [44, 45], [44, 46], [44, 48], [44, 49], [44, 51], [44, 52], [44, 53], [44, 54], [44, 55], [45, 46], [45, 48], [45, 49], [45, 50], [45, 52], [45, 53], [45, 54], [45, 55], [46, 47], [46, 49], [46, 50], [46, 51], [46, 53], [46, 55], [47, 48], [47, 53], [47, 54], [48, 49], [48, 50], [48, 54], [48, 55], [49, 50], [49, 51], [49, 54], [49, 55], [50, 52], [51, 52], [51, 53], [51, 54], [51, 55], [52, 53], [52, 55], [53, 54]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s3/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-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-maximum-clique-l6-s3/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-rlve-maximum-clique-l6-s4/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-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-maximum-clique-l6-s4/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5c4cca52e19d183ec63aa404f575ba3b8f4609ae --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 13, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 10], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 38], [0, 39], [0, 40], [0, 41], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 49], [0, 52], [0, 53], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 10], [1, 13], [1, 14], [1, 17], [1, 18], [1, 19], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 28], [1, 31], [1, 32], [1, 34], [1, 35], [1, 37], [1, 41], [1, 42], [1, 43], [1, 44], [1, 46], [1, 47], [1, 48], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [2, 4], [2, 5], [2, 7], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 32], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 42], [2, 44], [2, 46], [2, 47], [2, 48], [2, 50], [2, 51], [2, 54], [2, 55], [3, 4], [3, 5], [3, 6], [3, 10], [3, 11], [3, 13], [3, 16], [3, 18], [3, 19], [3, 20], [3, 21], [3, 28], [3, 29], [3, 30], [3, 31], [3, 34], [3, 35], [3, 36], [3, 39], [3, 40], [3, 41], [3, 43], [3, 44], [3, 46], [3, 47], [3, 49], [3, 50], [3, 51], [3, 52], [3, 54], [3, 55], [4, 5], [4, 6], [4, 7], [4, 8], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 17], [4, 19], [4, 20], [4, 22], [4, 24], [4, 25], [4, 27], [4, 28], [4, 30], [4, 31], [4, 32], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 41], [4, 42], [4, 44], [4, 46], [4, 49], [4, 50], [4, 51], [4, 52], [4, 55], [5, 6], [5, 7], [5, 8], [5, 9], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 19], [5, 22], [5, 24], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 32], [5, 34], [5, 35], [5, 36], [5, 37], [5, 38], [5, 40], [5, 41], [5, 43], [5, 44], [5, 47], [5, 48], [5, 49], [5, 50], [5, 52], [5, 54], [6, 8], [6, 9], [6, 10], [6, 12], [6, 15], [6, 16], [6, 17], [6, 18], [6, 24], [6, 25], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 33], [6, 34], [6, 35], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 46], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [7, 9], [7, 10], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 19], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 29], [7, 31], [7, 32], [7, 34], [7, 36], [7, 38], [7, 40], [7, 41], [7, 42], [7, 44], [7, 46], [7, 47], [7, 48], [7, 49], [7, 50], [7, 52], [7, 53], [7, 54], [7, 55], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 22], [8, 23], [8, 25], [8, 27], [8, 29], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 50], [8, 52], [8, 53], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 16], [9, 18], [9, 19], [9, 20], [9, 24], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 33], [9, 34], [9, 37], [9, 38], [9, 40], [9, 42], [9, 45], [9, 48], [9, 50], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [10, 11], [10, 12], [10, 13], [10, 15], [10, 16], [10, 17], [10, 20], [10, 21], [10, 22], [10, 23], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 38], [10, 39], [10, 40], [10, 41], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 48], [10, 49], [10, 51], [10, 53], [10, 54], [10, 55], [11, 12], [11, 13], [11, 14], [11, 15], [11, 18], [11, 21], [11, 22], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 32], [11, 35], [11, 36], [11, 37], [11, 38], [11, 40], [11, 41], [11, 43], [11, 44], [11, 45], [11, 47], [11, 48], [11, 49], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [12, 13], [12, 14], [12, 16], [12, 17], [12, 19], [12, 20], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 49], [12, 50], [12, 52], [12, 53], [12, 54], [12, 55], [13, 14], [13, 15], [13, 17], [13, 18], [13, 19], [13, 21], [13, 22], [13, 23], [13, 24], [13, 26], [13, 28], [13, 31], [13, 34], [13, 35], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 41], [13, 46], [13, 47], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [14, 16], [14, 18], [14, 19], [14, 21], [14, 22], [14, 24], [14, 25], [14, 27], [14, 28], [14, 29], [14, 30], [14, 33], [14, 35], [14, 37], [14, 38], [14, 39], [14, 41], [14, 42], [14, 44], [14, 46], [14, 47], [14, 48], [14, 49], [14, 50], [14, 51], [14, 55], [15, 16], [15, 17], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 26], [15, 28], [15, 29], [15, 31], [15, 33], [15, 36], [15, 38], [15, 40], [15, 41], [15, 43], [15, 44], [15, 45], [15, 46], [15, 47], [15, 48], [15, 49], [15, 50], [15, 54], [15, 55], [16, 17], [16, 19], [16, 21], [16, 22], [16, 23], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 33], [16, 34], [16, 35], [16, 36], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 47], [16, 48], [16, 49], [16, 50], [16, 52], [16, 53], [16, 55], [17, 18], [17, 19], [17, 20], [17, 22], [17, 24], [17, 25], [17, 28], [17, 29], [17, 30], [17, 31], [17, 35], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 42], [17, 43], [17, 44], [17, 45], [17, 46], [17, 47], [17, 48], [17, 49], [17, 50], [17, 51], [17, 52], [18, 19], [18, 20], [18, 21], [18, 25], [18, 26], [18, 27], [18, 30], [18, 31], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 42], [18, 44], [18, 46], [18, 47], [18, 49], [18, 53], [19, 20], [19, 22], [19, 26], [19, 27], [19, 28], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [19, 38], [19, 39], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 27], [20, 29], [20, 32], [20, 33], [20, 34], [20, 38], [20, 39], [20, 40], [20, 42], [20, 43], [20, 44], [20, 47], [20, 48], [20, 49], [20, 51], [20, 52], [20, 54], [20, 55], [21, 22], [21, 24], [21, 25], [21, 27], [21, 28], [21, 31], [21, 32], [21, 34], [21, 35], [21, 37], [21, 38], [21, 41], [21, 42], [21, 43], [21, 49], [21, 50], [21, 52], [21, 55], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [22, 40], [22, 41], [22, 43], [22, 44], [22, 45], [22, 47], [22, 50], [22, 51], [22, 52], [22, 53], [22, 55], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 45], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 54], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 34], [24, 35], [24, 36], [24, 37], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 45], [24, 46], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 54], [24, 55], [25, 26], [25, 27], [25, 30], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 45], [25, 47], [25, 48], [25, 50], [25, 51], [25, 53], [25, 54], [26, 27], [26, 28], [26, 32], [26, 33], [26, 34], [26, 36], [26, 42], [26, 45], [26, 46], [26, 47], [26, 48], [26, 50], [26, 52], [26, 53], [26, 54], [26, 55], [27, 28], [27, 29], [27, 32], [27, 33], [27, 34], [27, 35], [27, 39], [27, 41], [27, 42], [27, 43], [27, 44], [27, 46], [27, 47], [27, 49], [27, 50], [27, 51], [27, 54], [27, 55], [28, 31], [28, 32], [28, 35], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 43], [28, 45], [28, 46], [28, 47], [28, 49], [28, 50], [28, 51], [28, 52], [28, 54], [29, 30], [29, 31], [29, 32], [29, 34], [29, 35], [29, 38], [29, 39], [29, 40], [29, 42], [29, 43], [29, 46], [29, 47], [29, 48], [29, 49], [29, 50], [29, 51], [29, 52], [29, 53], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 38], [30, 39], [30, 41], [30, 42], [30, 43], [30, 44], [30, 47], [30, 48], [30, 50], [30, 51], [30, 52], [30, 53], [30, 54], [30, 55], [31, 33], [31, 34], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 44], [31, 45], [31, 46], [31, 48], [31, 50], [31, 53], [31, 54], [31, 55], [32, 34], [32, 35], [32, 36], [32, 38], [32, 39], [32, 40], [32, 42], [32, 43], [32, 45], [32, 46], [32, 47], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [32, 54], [33, 34], [33, 35], [33, 36], [33, 37], [33, 39], [33, 41], [33, 42], [33, 44], [33, 46], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 53], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 40], [34, 42], [34, 43], [34, 44], [34, 47], [34, 48], [34, 49], [34, 50], [34, 52], [34, 53], [34, 54], [34, 55], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 44], [35, 45], [35, 46], [35, 48], [35, 49], [35, 50], [35, 51], [35, 54], [35, 55], [36, 37], [36, 38], [36, 39], [36, 40], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 51], [36, 52], [36, 54], [36, 55], [37, 41], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 48], [37, 50], [37, 51], [37, 52], [37, 53], [37, 54], [37, 55], [38, 41], [38, 43], [38, 44], [38, 45], [38, 47], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [39, 43], [39, 44], [39, 45], [39, 46], [39, 48], [39, 49], [39, 50], [39, 51], [39, 52], [39, 54], [39, 55], [40, 41], [40, 42], [40, 44], [40, 46], [40, 47], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [41, 42], [41, 45], [41, 47], [41, 49], [41, 51], [41, 54], [41, 55], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [43, 44], [43, 45], [43, 46], [43, 47], [43, 48], [43, 49], [43, 50], [43, 51], [43, 52], [43, 55], [44, 45], [44, 46], [44, 47], [44, 48], [44, 50], [44, 51], [44, 52], [44, 53], [44, 54], [44, 55], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 54], [45, 55], [46, 47], [46, 52], [46, 53], [46, 54], [46, 55], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [48, 50], [48, 51], [48, 52], [48, 53], [48, 55], [49, 50], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [50, 51], [50, 52], [50, 53], [50, 55], [51, 52], [51, 54], [51, 55], [52, 54], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s4/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d1b4c425678d277ed7b7c0f3720ffc584a6c7e9 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-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' +{"clique": [0, 5, 12, 16, 22, 30, 34, 36, 38, 43, 44, 47, 52]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s4/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s4/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("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l6-s4/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5c4cca52e19d183ec63aa404f575ba3b8f4609ae --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 13, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 10], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 38], [0, 39], [0, 40], [0, 41], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 49], [0, 52], [0, 53], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 10], [1, 13], [1, 14], [1, 17], [1, 18], [1, 19], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 28], [1, 31], [1, 32], [1, 34], [1, 35], [1, 37], [1, 41], [1, 42], [1, 43], [1, 44], [1, 46], [1, 47], [1, 48], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [2, 4], [2, 5], [2, 7], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 32], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 42], [2, 44], [2, 46], [2, 47], [2, 48], [2, 50], [2, 51], [2, 54], [2, 55], [3, 4], [3, 5], [3, 6], [3, 10], [3, 11], [3, 13], [3, 16], [3, 18], [3, 19], [3, 20], [3, 21], [3, 28], [3, 29], [3, 30], [3, 31], [3, 34], [3, 35], [3, 36], [3, 39], [3, 40], [3, 41], [3, 43], [3, 44], [3, 46], [3, 47], [3, 49], [3, 50], [3, 51], [3, 52], [3, 54], [3, 55], [4, 5], [4, 6], [4, 7], [4, 8], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 17], [4, 19], [4, 20], [4, 22], [4, 24], [4, 25], [4, 27], [4, 28], [4, 30], [4, 31], [4, 32], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 41], [4, 42], [4, 44], [4, 46], [4, 49], [4, 50], [4, 51], [4, 52], [4, 55], [5, 6], [5, 7], [5, 8], [5, 9], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 19], [5, 22], [5, 24], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 32], [5, 34], [5, 35], [5, 36], [5, 37], [5, 38], [5, 40], [5, 41], [5, 43], [5, 44], [5, 47], [5, 48], [5, 49], [5, 50], [5, 52], [5, 54], [6, 8], [6, 9], [6, 10], [6, 12], [6, 15], [6, 16], [6, 17], [6, 18], [6, 24], [6, 25], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 33], [6, 34], [6, 35], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 46], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [7, 9], [7, 10], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 19], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 29], [7, 31], [7, 32], [7, 34], [7, 36], [7, 38], [7, 40], [7, 41], [7, 42], [7, 44], [7, 46], [7, 47], [7, 48], [7, 49], [7, 50], [7, 52], [7, 53], [7, 54], [7, 55], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 22], [8, 23], [8, 25], [8, 27], [8, 29], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 50], [8, 52], [8, 53], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 16], [9, 18], [9, 19], [9, 20], [9, 24], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 33], [9, 34], [9, 37], [9, 38], [9, 40], [9, 42], [9, 45], [9, 48], [9, 50], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [10, 11], [10, 12], [10, 13], [10, 15], [10, 16], [10, 17], [10, 20], [10, 21], [10, 22], [10, 23], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 38], [10, 39], [10, 40], [10, 41], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 48], [10, 49], [10, 51], [10, 53], [10, 54], [10, 55], [11, 12], [11, 13], [11, 14], [11, 15], [11, 18], [11, 21], [11, 22], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 32], [11, 35], [11, 36], [11, 37], [11, 38], [11, 40], [11, 41], [11, 43], [11, 44], [11, 45], [11, 47], [11, 48], [11, 49], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [12, 13], [12, 14], [12, 16], [12, 17], [12, 19], [12, 20], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 49], [12, 50], [12, 52], [12, 53], [12, 54], [12, 55], [13, 14], [13, 15], [13, 17], [13, 18], [13, 19], [13, 21], [13, 22], [13, 23], [13, 24], [13, 26], [13, 28], [13, 31], [13, 34], [13, 35], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 41], [13, 46], [13, 47], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [14, 16], [14, 18], [14, 19], [14, 21], [14, 22], [14, 24], [14, 25], [14, 27], [14, 28], [14, 29], [14, 30], [14, 33], [14, 35], [14, 37], [14, 38], [14, 39], [14, 41], [14, 42], [14, 44], [14, 46], [14, 47], [14, 48], [14, 49], [14, 50], [14, 51], [14, 55], [15, 16], [15, 17], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 26], [15, 28], [15, 29], [15, 31], [15, 33], [15, 36], [15, 38], [15, 40], [15, 41], [15, 43], [15, 44], [15, 45], [15, 46], [15, 47], [15, 48], [15, 49], [15, 50], [15, 54], [15, 55], [16, 17], [16, 19], [16, 21], [16, 22], [16, 23], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 33], [16, 34], [16, 35], [16, 36], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 47], [16, 48], [16, 49], [16, 50], [16, 52], [16, 53], [16, 55], [17, 18], [17, 19], [17, 20], [17, 22], [17, 24], [17, 25], [17, 28], [17, 29], [17, 30], [17, 31], [17, 35], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 42], [17, 43], [17, 44], [17, 45], [17, 46], [17, 47], [17, 48], [17, 49], [17, 50], [17, 51], [17, 52], [18, 19], [18, 20], [18, 21], [18, 25], [18, 26], [18, 27], [18, 30], [18, 31], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 42], [18, 44], [18, 46], [18, 47], [18, 49], [18, 53], [19, 20], [19, 22], [19, 26], [19, 27], [19, 28], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [19, 38], [19, 39], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 27], [20, 29], [20, 32], [20, 33], [20, 34], [20, 38], [20, 39], [20, 40], [20, 42], [20, 43], [20, 44], [20, 47], [20, 48], [20, 49], [20, 51], [20, 52], [20, 54], [20, 55], [21, 22], [21, 24], [21, 25], [21, 27], [21, 28], [21, 31], [21, 32], [21, 34], [21, 35], [21, 37], [21, 38], [21, 41], [21, 42], [21, 43], [21, 49], [21, 50], [21, 52], [21, 55], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [22, 40], [22, 41], [22, 43], [22, 44], [22, 45], [22, 47], [22, 50], [22, 51], [22, 52], [22, 53], [22, 55], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 45], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 54], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 34], [24, 35], [24, 36], [24, 37], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 45], [24, 46], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 54], [24, 55], [25, 26], [25, 27], [25, 30], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 45], [25, 47], [25, 48], [25, 50], [25, 51], [25, 53], [25, 54], [26, 27], [26, 28], [26, 32], [26, 33], [26, 34], [26, 36], [26, 42], [26, 45], [26, 46], [26, 47], [26, 48], [26, 50], [26, 52], [26, 53], [26, 54], [26, 55], [27, 28], [27, 29], [27, 32], [27, 33], [27, 34], [27, 35], [27, 39], [27, 41], [27, 42], [27, 43], [27, 44], [27, 46], [27, 47], [27, 49], [27, 50], [27, 51], [27, 54], [27, 55], [28, 31], [28, 32], [28, 35], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 43], [28, 45], [28, 46], [28, 47], [28, 49], [28, 50], [28, 51], [28, 52], [28, 54], [29, 30], [29, 31], [29, 32], [29, 34], [29, 35], [29, 38], [29, 39], [29, 40], [29, 42], [29, 43], [29, 46], [29, 47], [29, 48], [29, 49], [29, 50], [29, 51], [29, 52], [29, 53], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 38], [30, 39], [30, 41], [30, 42], [30, 43], [30, 44], [30, 47], [30, 48], [30, 50], [30, 51], [30, 52], [30, 53], [30, 54], [30, 55], [31, 33], [31, 34], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 44], [31, 45], [31, 46], [31, 48], [31, 50], [31, 53], [31, 54], [31, 55], [32, 34], [32, 35], [32, 36], [32, 38], [32, 39], [32, 40], [32, 42], [32, 43], [32, 45], [32, 46], [32, 47], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [32, 54], [33, 34], [33, 35], [33, 36], [33, 37], [33, 39], [33, 41], [33, 42], [33, 44], [33, 46], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 53], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 40], [34, 42], [34, 43], [34, 44], [34, 47], [34, 48], [34, 49], [34, 50], [34, 52], [34, 53], [34, 54], [34, 55], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 44], [35, 45], [35, 46], [35, 48], [35, 49], [35, 50], [35, 51], [35, 54], [35, 55], [36, 37], [36, 38], [36, 39], [36, 40], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 51], [36, 52], [36, 54], [36, 55], [37, 41], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 48], [37, 50], [37, 51], [37, 52], [37, 53], [37, 54], [37, 55], [38, 41], [38, 43], [38, 44], [38, 45], [38, 47], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [39, 43], [39, 44], [39, 45], [39, 46], [39, 48], [39, 49], [39, 50], [39, 51], [39, 52], [39, 54], [39, 55], [40, 41], [40, 42], [40, 44], [40, 46], [40, 47], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [41, 42], [41, 45], [41, 47], [41, 49], [41, 51], [41, 54], [41, 55], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [43, 44], [43, 45], [43, 46], [43, 47], [43, 48], [43, 49], [43, 50], [43, 51], [43, 52], [43, 55], [44, 45], [44, 46], [44, 47], [44, 48], [44, 50], [44, 51], [44, 52], [44, 53], [44, 54], [44, 55], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 54], [45, 55], [46, 47], [46, 52], [46, 53], [46, 54], [46, 55], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [48, 50], [48, 51], [48, 52], [48, 53], [48, 55], [49, 50], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [50, 51], [50, 52], [50, 53], [50, 55], [51, 52], [51, 54], [51, 55], [52, 54], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s4/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-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-maximum-clique-l6-s4/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-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-min-chromatic-number-l1-s0/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s0/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..afe4509fca368ca0446737f0cd31018fe1216bbe --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [1, 4], [2, 3], [2, 5], [3, 4], [3, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s0/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..66aabeae2a2047618c608e448da59b39f1d68738 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 0, 0, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s0/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s0/tests/check.py @@ -0,0 +1,10 @@ +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") + 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-rlve-min-chromatic-number-l1-s0/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..afe4509fca368ca0446737f0cd31018fe1216bbe --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [1, 4], [2, 3], [2, 5], [3, 4], [3, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s0/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s0/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s9/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s9/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0ebddd88ddf8e9a010b94c6f479da7efa5fe7c6 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 2], [0, 3], [0, 4], [0, 5], [1, 4], [1, 5], [2, 3], [2, 5], [3, 4], [3, 5], [4, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s9/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f1d93aefd851e6a887b963eabb4861e3ba0ef966 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 0, 1, 2, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s9/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s9/tests/check.py @@ -0,0 +1,10 @@ +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") + 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-rlve-min-chromatic-number-l1-s9/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0ebddd88ddf8e9a010b94c6f479da7efa5fe7c6 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 2], [0, 3], [0, 4], [0, 5], [1, 4], [1, 5], [2, 3], [2, 5], [3, 4], [3, 5], [4, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s9/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s9/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s1/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s1/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..face5a2803bac389ab7a77fb2530e63fe26e6f73 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 6, "edges": [[0, 4], [0, 7], [0, 9], [0, 10], [0, 11], [0, 14], [0, 18], [0, 19], [0, 21], [1, 5], [1, 6], [1, 9], [1, 11], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 22], [2, 3], [2, 4], [2, 9], [2, 12], [2, 13], [2, 15], [2, 16], [2, 18], [2, 19], [2, 21], [3, 4], [3, 10], [3, 11], [3, 12], [3, 15], [3, 16], [3, 18], [3, 20], [3, 21], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 16], [4, 17], [4, 18], [4, 20], [4, 23], [5, 8], [5, 9], [5, 13], [5, 14], [5, 15], [5, 17], [5, 18], [5, 20], [5, 21], [5, 23], [6, 10], [6, 12], [6, 17], [6, 18], [6, 20], [6, 22], [6, 23], [7, 12], [7, 13], [7, 15], [7, 17], [7, 20], [8, 10], [8, 11], [8, 13], [8, 18], [8, 19], [9, 14], [9, 16], [9, 18], [9, 21], [10, 11], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 19], [10, 21], [11, 12], [11, 14], [11, 18], [11, 19], [11, 20], [12, 13], [12, 15], [12, 17], [12, 23], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 21], [13, 23], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [15, 21], [16, 21], [16, 22], [16, 23], [17, 19], [17, 20], [17, 23], [18, 19], [19, 20], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s1/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6173cbf81667d7a7034ea46720256095123b2276 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 0, 0, 1, 2, 3, 1, 3, 0, 1, 3, 4, 2, 1, 2, 5, 5, 4, 5, 1, 5, 4, 2, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s1/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s1/tests/check.py @@ -0,0 +1,10 @@ +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") + 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-rlve-min-chromatic-number-l5-s1/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..face5a2803bac389ab7a77fb2530e63fe26e6f73 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 6, "edges": [[0, 4], [0, 7], [0, 9], [0, 10], [0, 11], [0, 14], [0, 18], [0, 19], [0, 21], [1, 5], [1, 6], [1, 9], [1, 11], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 22], [2, 3], [2, 4], [2, 9], [2, 12], [2, 13], [2, 15], [2, 16], [2, 18], [2, 19], [2, 21], [3, 4], [3, 10], [3, 11], [3, 12], [3, 15], [3, 16], [3, 18], [3, 20], [3, 21], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 16], [4, 17], [4, 18], [4, 20], [4, 23], [5, 8], [5, 9], [5, 13], [5, 14], [5, 15], [5, 17], [5, 18], [5, 20], [5, 21], [5, 23], [6, 10], [6, 12], [6, 17], [6, 18], [6, 20], [6, 22], [6, 23], [7, 12], [7, 13], [7, 15], [7, 17], [7, 20], [8, 10], [8, 11], [8, 13], [8, 18], [8, 19], [9, 14], [9, 16], [9, 18], [9, 21], [10, 11], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 19], [10, 21], [11, 12], [11, 14], [11, 18], [11, 19], [11, 20], [12, 13], [12, 15], [12, 17], [12, 23], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 21], [13, 23], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [15, 21], [16, 21], [16, 22], [16, 23], [17, 19], [17, 20], [17, 23], [18, 19], [19, 20], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s1/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s1/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s6/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-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-min-chromatic-number-l5-s6/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b7633a53f9c58d697328b347584304e2c9174ec --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 5, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 7], [0, 11], [0, 12], [0, 14], [0, 18], [0, 19], [0, 20], [0, 22], [1, 2], [1, 5], [1, 9], [1, 15], [1, 22], [1, 23], [2, 5], [2, 7], [2, 14], [2, 17], [2, 20], [2, 21], [2, 22], [2, 23], [3, 4], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 17], [3, 21], [4, 14], [4, 16], [4, 17], [4, 21], [5, 8], [5, 11], [5, 18], [5, 19], [5, 21], [5, 22], [6, 12], [6, 14], [6, 15], [6, 18], [6, 20], [6, 23], [7, 11], [7, 15], [7, 18], [8, 9], [8, 13], [8, 15], [8, 18], [8, 21], [8, 22], [9, 11], [9, 17], [9, 18], [9, 19], [9, 20], [10, 12], [10, 14], [10, 17], [10, 20], [10, 23], [11, 14], [11, 16], [11, 17], [11, 20], [11, 21], [12, 13], [12, 14], [12, 18], [12, 20], [13, 15], [13, 16], [13, 18], [14, 16], [15, 19], [16, 19], [16, 22], [16, 23], [17, 21], [17, 22], [17, 23], [18, 21], [18, 22], [18, 23], [19, 21], [19, 22], [20, 21], [22, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s6/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..026f4d25e50ef8aae307342c0d24aecb6ae5c92d --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-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' +{"colors": [0, 1, 0, 0, 1, 2, 1, 2, 1, 0, 1, 1, 2, 0, 3, 3, 4, 4, 4, 1, 4, 3, 3, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s6/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s6/tests/check.py @@ -0,0 +1,10 @@ +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") + 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-rlve-min-chromatic-number-l5-s6/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b7633a53f9c58d697328b347584304e2c9174ec --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 5, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 7], [0, 11], [0, 12], [0, 14], [0, 18], [0, 19], [0, 20], [0, 22], [1, 2], [1, 5], [1, 9], [1, 15], [1, 22], [1, 23], [2, 5], [2, 7], [2, 14], [2, 17], [2, 20], [2, 21], [2, 22], [2, 23], [3, 4], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 17], [3, 21], [4, 14], [4, 16], [4, 17], [4, 21], [5, 8], [5, 11], [5, 18], [5, 19], [5, 21], [5, 22], [6, 12], [6, 14], [6, 15], [6, 18], [6, 20], [6, 23], [7, 11], [7, 15], [7, 18], [8, 9], [8, 13], [8, 15], [8, 18], [8, 21], [8, 22], [9, 11], [9, 17], [9, 18], [9, 19], [9, 20], [10, 12], [10, 14], [10, 17], [10, 20], [10, 23], [11, 14], [11, 16], [11, 17], [11, 20], [11, 21], [12, 13], [12, 14], [12, 18], [12, 20], [13, 15], [13, 16], [13, 18], [14, 16], [15, 19], [16, 19], [16, 22], [16, 23], [17, 21], [17, 22], [17, 23], [18, 21], [18, 22], [18, 23], [19, 21], [19, 22], [20, 21], [22, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s6/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-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-min-chromatic-number-l5-s6/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-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-min-harmonious-coloring-l1-s3/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l1-s3/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7eb6db62d815e3a0e1752a0250ef48f37c8ae826 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 1], [0, 3], [0, 5], [2, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s3/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8612e04ad527532870f4eaf402dce12339d93740 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 1, 1, 2, 0, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s3/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/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-l1-s3/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7eb6db62d815e3a0e1752a0250ef48f37c8ae826 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 1], [0, 3], [0, 5], [2, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s3/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l1-s3/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l1-s4/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l1-s4/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b60c09ce6f6ec30f4339ce08197910464bc15212 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [2, 4], [3, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s4/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..66aabeae2a2047618c608e448da59b39f1d68738 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 0, 0, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s4/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/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-l1-s4/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b60c09ce6f6ec30f4339ce08197910464bc15212 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [2, 4], [3, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s4/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l1-s4/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l5-s2/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/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-l5-s2/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..06a0b83a005235d6799c6d58c7ba586d8138ffdb --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 9, "edges": [[0, 2], [0, 7], [0, 12], [1, 5], [1, 9], [2, 4], [2, 5], [2, 7], [2, 9], [3, 4], [3, 6], [3, 12], [4, 9], [4, 11], [5, 7], [5, 8], [5, 13], [6, 9], [6, 10], [6, 14], [7, 11], [7, 13], [10, 11], [10, 13], [12, 13], [12, 14]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s2/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-rlve-min-harmonious-coloring-l5-s5/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l5-s5/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..81d49347754addc06dddee0a1730dcaf789158dd --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 5, "edges": [[1, 12], [2, 9], [2, 13], [3, 8], [3, 13], [4, 13], [5, 10], [7, 9], [7, 13], [8, 10]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s5/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc01e21642f9085a3137864e0f55310ec91a136a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 0, 0, 1, 2, 0, 0, 3, 2, 1, 3, 0, 2, 4, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s5/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/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-l5-s5/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..81d49347754addc06dddee0a1730dcaf789158dd --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 5, "edges": [[1, 12], [2, 9], [2, 13], [3, 8], [3, 13], [4, 13], [5, 10], [7, 9], [7, 13], [8, 10]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s5/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l5-s5/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-pairwise-sums-recovery-l3-s3/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s3/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b7587b32fce504fe25b41788b0ecf2daf0edf321 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [18, 24, 20, 27, 31, 25, 30, 23, 27, 20, 24, 18, 22, 12, 21, 16, 14, 28, 29, 17, 26, 19, 10, 29, 25, 23, 22, 16], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6e9db467437ceb4dee7759327b9a8ed569700f59 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [3, 7, 9, 11, 13, 14, 15, 16]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/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-l3-s3/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b7587b32fce504fe25b41788b0ecf2daf0edf321 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [18, 24, 20, 27, 31, 25, 30, 23, 27, 20, 24, 18, 22, 12, 21, 16, 14, 28, 29, 17, 26, 19, 10, 29, 25, 23, 22, 16], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s3/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s4/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s4/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f873afd6facd37410d0cc2f10e751ec9d6f43bee --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [16, 11, 15, 27, 12, 16, 21, 7, 12, 4, 16, 10, 10, 13, 11, 24, 19, 17, 18, 20, 13, 15, 22, 9, 23, 19, 5, 8], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bcea5ddfe87e37e28257cc68f6d3101f949f5314 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [1, 3, 4, 7, 8, 9, 12, 15]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/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-l3-s4/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f873afd6facd37410d0cc2f10e751ec9d6f43bee --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [16, 11, 15, 27, 12, 16, 21, 7, 12, 4, 16, 10, 10, 13, 11, 24, 19, 17, 18, 20, 13, 15, 22, 9, 23, 19, 5, 8], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s4/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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/construct-rlve-pan-solar-panels-l2-s1/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s1/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b850ff155188ed0173ffdc1ec69536866501cf5c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": 39, "B": 106, "C": 604, "D": 944, "target": 106, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s1/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..900c2f42927ca74476cd3e70946ea9377342f04b --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 106, "Y": 848} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b850ff155188ed0173ffdc1ec69536866501cf5c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": 39, "B": 106, "C": 604, "D": 944, "target": 106, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s1/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s6/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s6/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..808d4983bfa755dad22c7b2d77320c40c18fda9b --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"A": 199, "B": 204, "C": 565, "D": 788, "target": 204, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s6/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..73a880df4ebc4f526b08367512e1eaaf7a8bde87 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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' +{"X": 204, "Y": 612} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..808d4983bfa755dad22c7b2d77320c40c18fda9b --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"A": 199, "B": 204, "C": 565, "D": 788, "target": 204, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s6/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s0/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s0/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..942a425ede66ea9a7c25becee6f569ae8495f550 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": 28143709615, "B": 44258818276, "C": 63660013589, "D": 72309747170, "target": 36154873585, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s0/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cb95e1f5e3bb4eed0f97b130143913e8e82baf61 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 36154873585, "Y": 72309747170} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..942a425ede66ea9a7c25becee6f569ae8495f550 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": 28143709615, "B": 44258818276, "C": 63660013589, "D": 72309747170, "target": 36154873585, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s0/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s9/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s9/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4d41d47f85196b23055371d7d45c72d9a4714063 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"A": 26958113992, "B": 30778571821, "C": 34764604900, "D": 96352711891, "target": 30778571821, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s9/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1844efa297b86873063a01c4488eb1a2fc766363 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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' +{"X": 30778571821, "Y": 92335715463} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4d41d47f85196b23055371d7d45c72d9a4714063 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"A": 26958113992, "B": 30778571821, "C": 34764604900, "D": 96352711891, "target": 30778571821, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s9/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-polynomial-global-minimum-l3-s5/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-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-global-minimum-l3-s5/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb6a870cccc4d52f0b8de46033e119ded4e7706c --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [133, 376, 487, 316, 121, 24, 2], "fmin": "24.3069302671124772112525806487936335179249847", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s5/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..797aa2cdeab3c30c39ca1b4d1651dcc96ed6ef32 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-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' +{"x0": -0.8056733792055042} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s5/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/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-l3-s5/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb6a870cccc4d52f0b8de46033e119ded4e7706c --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [133, 376, 487, 316, 121, 24, 2], "fmin": "24.3069302671124772112525806487936335179249847", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s5/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-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-global-minimum-l3-s5/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-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-integer-roots-l4-s0/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-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-integer-roots-l4-s0/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7beaba555e06573299117a3986e457e194d63eff --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [-2365440000, -753664000, 731731200, 257007040, -33282368, -18656304, -561184, 389716, 28332, -3181, -301, 9, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s0/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3166a33be0859ffa4bcb753bdd36fdd7e14220b0 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-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' +{"roots": [-10, -8, -8, -7, -6, -5, -2, 2, 4, 10, 10, 11]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s0/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/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-l4-s0/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7beaba555e06573299117a3986e457e194d63eff --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [-2365440000, -753664000, 731731200, 257007040, -33282368, -18656304, -561184, 389716, 28332, -3181, -301, 9, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s0/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-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-integer-roots-l4-s0/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-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-integer-roots-l4-s9/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-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-integer-roots-l4-s9/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..12859d0e4c11dabbdae2056f5740e16817a9a24f --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [0, 0, -1152000, 2697600, -2134880, 564624, 76064, -56016, 3354, 1401, -139, -9, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s9/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3dc26124a51da5be38184c79874dc3483f6bef5e --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-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' +{"roots": [-10, -6, -5, 0, 0, 1, 2, 2, 3, 4, 8, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s9/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/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-l4-s9/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..12859d0e4c11dabbdae2056f5740e16817a9a24f --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [0, 0, -1152000, 2697600, -2134880, 564624, 76064, -56016, 3354, 1401, -139, -9, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s9/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-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-integer-roots-l4-s9/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-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-interpolation-l3-s0/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-rlve-polynomial-interpolation-l3-s0/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c668db75b301fcf5c63e042d135588637dafb542 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"X": [3, -2, 1, 0, 2, 5, -3], "Y": [658, 273, -6, 1, 1, 21826, 2386], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s0/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c152b422033dbe024f6cfe48b2fce48856f1397 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [1, 0, -2, -5, 1, -3, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s0/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s0/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-l3-s0/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c668db75b301fcf5c63e042d135588637dafb542 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"X": [3, -2, 1, 0, 2, 5, -3], "Y": [658, 273, -6, 1, 1, 21826, 2386], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s0/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-rlve-polynomial-interpolation-l3-s0/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-rlve-polynomial-interpolation-l3-s7/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-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-polynomial-interpolation-l3-s7/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8b7e8ec0a9b0d4fb41af9ec492e8d99d013a49dd --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"X": [-2, -1, -6, 1, -3, -5, 4], "Y": [249, -1, 132249, -9, 2583, 46767, 3549], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s7/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6cab1069da0ae1fe5fd67717df598c22b1ce436f --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-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' +{"coeffs": [-3, -4, -5, 5, 1, -5, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s7/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s7/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-l3-s7/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8b7e8ec0a9b0d4fb41af9ec492e8d99d013a49dd --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"X": [-2, -1, -6, 1, -3, -5, 4], "Y": [249, -1, 132249, -9, 2583, 46767, 3549], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s7/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-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-polynomial-interpolation-l3-s7/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-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-prefix-product-permutation-l3-s2/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-rlve-prefix-product-permutation-l3-s2/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f95e722ecd3500e90a45939daf05c555a6a01e2 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 109, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s2/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f85f96ee7dd67eedb1eac8fd5efe0d84ba760340 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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' +{"perm": [1, 2, 56, 74, 83, 23, 92, 79, 42, 98, 12, 11, 101, 43, 40, 81, 76, 78, 104, 24, 61, 27, 6, 20, 51, 49, 22, 106, 75, 95, 41, 103, 93, 77, 94, 82, 107, 57, 67, 15, 31, 9, 14, 72, 58, 64, 65, 59, 26, 90, 25, 63, 66, 73, 108, 3, 38, 45, 48, 86, 21, 85, 52, 46, 47, 53, 39, 97, 102, 80, 96, 44, 54, 4, 29, 17, 34, 18, 8, 70, 16, 36, 5, 89, 62, 60, 91, 105, 84, 50, 87, 7, 33, 35, 30, 71, 68, 10, 100, 99, 13, 69, 32, 19, 88, 28, 37, 55, 109]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s2/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s2/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-l3-s2/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f95e722ecd3500e90a45939daf05c555a6a01e2 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 109, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s2/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-rlve-prefix-product-permutation-l3-s2/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-rlve-prefix-product-permutation-l3-s5/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-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-prefix-product-permutation-l3-s5/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b489de297e468ce076ed8ce56981b7f3535485e0 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 241, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s5/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7c890877bb289676ff8dcae31a37a9e4e3dc044f --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-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' +{"perm": [1, 2, 122, 162, 182, 194, 202, 70, 212, 135, 218, 23, 222, 205, 156, 226, 227, 157, 68, 204, 230, 24, 12, 22, 232, 136, 103, 126, 199, 134, 234, 71, 114, 169, 79, 63, 155, 229, 223, 69, 236, 195, 133, 214, 127, 76, 132, 201, 237, 183, 189, 53, 52, 192, 184, 150, 100, 149, 188, 193, 238, 163, 36, 89, 178, 90, 85, 19, 40, 8, 32, 130, 78, 209, 115, 46, 112, 73, 35, 181, 239, 123, 98, 152, 67, 225, 228, 206, 64, 66, 159, 99, 187, 185, 101, 138, 119, 83, 92, 57, 95, 106, 27, 118, 147, 102, 217, 233, 213, 200, 196, 77, 171, 33, 75, 198, 215, 104, 97, 161, 240, 3, 82, 146, 139, 28, 45, 168, 210, 72, 166, 47, 43, 30, 10, 26, 141, 96, 125, 216, 137, 148, 186, 151, 160, 124, 105, 142, 58, 56, 144, 84, 177, 179, 37, 15, 18, 176, 91, 145, 120, 4, 62, 208, 170, 131, 197, 128, 34, 165, 113, 211, 235, 203, 224, 158, 153, 65, 154, 207, 80, 5, 50, 55, 94, 143, 93, 59, 51, 191, 190, 54, 60, 6, 42, 111, 167, 116, 29, 110, 48, 7, 174, 20, 14, 88, 180, 164, 74, 129, 172, 9, 109, 44, 117, 140, 107, 11, 221, 231, 219, 13, 39, 175, 86, 16, 17, 87, 38, 21, 220, 25, 108, 31, 173, 41, 49, 61, 81, 121, 241]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s5/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s5/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-l3-s5/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b489de297e468ce076ed8ce56981b7f3535485e0 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 241, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s5/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-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-prefix-product-permutation-l3-s5/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-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-prefix-sum-permutation-l2-s2/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l2-s2/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f262de0bab593626bde9e0c4d5f23999743aac1a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 70, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s2/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..74fe29e95860d1530ff7faab771e2207a982c712 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [70, 1, 68, 3, 66, 5, 64, 7, 62, 9, 60, 11, 58, 13, 56, 15, 54, 17, 52, 19, 50, 21, 48, 23, 46, 25, 44, 27, 42, 29, 40, 31, 38, 33, 36, 35, 34, 37, 32, 39, 30, 41, 28, 43, 26, 45, 24, 47, 22, 49, 20, 51, 18, 53, 16, 55, 14, 57, 12, 59, 10, 61, 8, 63, 6, 65, 4, 67, 2, 69]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s2/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/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(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s2/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f262de0bab593626bde9e0c4d5f23999743aac1a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 70, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s2/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l2-s2/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l2-s5/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l2-s5/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..43fbeaff11051c87d41b0afc1f98493f4acb1f28 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 36, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s5/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c5d6ad9b71a64480526604711add0d0398146f92 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [36, 1, 34, 3, 32, 5, 30, 7, 28, 9, 26, 11, 24, 13, 22, 15, 20, 17, 18, 19, 16, 21, 14, 23, 12, 25, 10, 27, 8, 29, 6, 31, 4, 33, 2, 35]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s5/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/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(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s5/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..43fbeaff11051c87d41b0afc1f98493f4acb1f28 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 36, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s5/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l2-s5/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prime-graph-coloring-l3-s3/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s3/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..80d5c257ac026190dd9b23e2c4b56f7fe2d29def --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 63, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s3/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..573cb2b439132cbb01d9caab544f7c07571a567c --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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' +{"colors": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/check.py @@ -0,0 +1,20 @@ +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") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..80d5c257ac026190dd9b23e2c4b56f7fe2d29def --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 63, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s3/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s4/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s4/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e877e56f2ae813f2f12509b74e2475384b7c9424 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 68, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s4/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..378eef8887ceb0ea80e23bbecf311d65d5b346b3 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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' +{"colors": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/check.py @@ -0,0 +1,20 @@ +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") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e877e56f2ae813f2f12509b74e2475384b7c9424 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 68, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s4/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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/construct-rlve-recursive-sequence-sum-l1-s1/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s1/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2b4b650e96b0ea89eed2b56b26acb23593e603e7 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"F0": 69, "A": 1, "B": 12991, "S": 130186, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s1/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d442d77cdb9612131b01acbcbc1413e038c3b798 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [1, 2, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2b4b650e96b0ea89eed2b56b26acb23593e603e7 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"F0": 69, "A": 1, "B": 12991, "S": 130186, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s1/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s8/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s8/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..079387908d0967d7dafc1807d7321669714769b5 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"F0": 75, "A": 16, "B": 367, "S": 434397, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s8/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c621b4e4f01eab810b4e898c046839c8aa6ca435 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..079387908d0967d7dafc1807d7321669714769b5 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"F0": 75, "A": 16, "B": 367, "S": 434397, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s8/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s0/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-rlve-recursive-sequence-sum-l5-s0/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..afcfeee62c696402cdd9ae0d02c4ace4c5ead529 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"F0": 89, "A": 16, "B": 7430, "S": 212094218386632933849346945292941662992420, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s0/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8b83dcdd7517411e8abea9a0b833546d9b3dea6d --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..afcfeee62c696402cdd9ae0d02c4ace4c5ead529 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"F0": 89, "A": 16, "B": 7430, "S": 212094218386632933849346945292941662992420, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-rlve-recursive-sequence-sum-l5-s0/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-rlve-recursive-sequence-sum-l5-s7/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s7/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..746c2bb7adb78d364005dfc583a103a348b24178 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"F0": 124, "A": 2, "B": 4904, "S": 43187534256648, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s7/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..66be2d7f6de174a4beb166688f30ef09ddd569c8 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..746c2bb7adb78d364005dfc583a103a348b24178 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"F0": 124, "A": 2, "B": 4904, "S": 43187534256648, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s7/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-round-robin-scores-l1-s3/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s3/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..47dfc58ad80df06b603c5c6d9ba7bde5de036de7 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"W": [5, 5, 4, 1], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s3/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c6b240f4f37bcb96320335987648442c80c3c1ba --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["0112", "1021", "1002", "0100"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s3/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s3/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l1-s3/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..47dfc58ad80df06b603c5c6d9ba7bde5de036de7 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"W": [5, 5, 4, 1], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s3/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s3/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s4/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s4/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8bb1cbedcc9ac3f8b491a27b8958eea806698b7 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"W": [3, 9, 3, 3], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s4/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..58e7f56fcda5266c54f2d57828d53705e3ca8585 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["0020", "2022", "0002", "2000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s4/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s4/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l1-s4/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8bb1cbedcc9ac3f8b491a27b8958eea806698b7 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"W": [3, 9, 3, 3], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s4/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s4/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-shortest-path-count-l2-s9/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-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-shortest-path-count-l2-s9/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9906fecd24b297f49a672b5e45966fb0aeebcdf9 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"K": 380, "n_max": 57, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s9/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c54bd8728a57931c53dfb01fa14bca74450e44f --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-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' +{"n": 27, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNYNNNNNN", "NNYYNNYYNNNNNNNNNNNNYNNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNNNYYNNYYNNNNNNNNNNYNNNN", "NNNNNNYYNNYYNNNNNNNNNNYNNNN", "NNNNNNNNYYNNYYNNNNNNNNNYNNN", "NNNNNNNNYYNNYYNNNNNNNNNYNNN", "NNNNNNNNNNYYNNYYNNNNNNNNYNN", "NNNNNNNNNNYYNNYYNNNNNNNNYNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNN", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNYYNNNNNNNNNNNNNYNYNNNNN", "NNNNNNYYNNNNNNNNNNNNYNYNNNN", "NNNNNNNNYYNNNNNNNNNNNYNYNNN", "NNNNNNNNNNYYNNNNNNNNNNYNYNN", "NNNNNNNNNNNNYYNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNYYNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s9/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s9/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l2-s9/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9906fecd24b297f49a672b5e45966fb0aeebcdf9 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"K": 380, "n_max": 57, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s9/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-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-shortest-path-count-l2-s9/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-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-shortest-path-count-l6-s1/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-shortest-path-count-l6-s1/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a342f524fe545fdc2e05b8023e9914a758c48394 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"K": 586828300174062601, "n_max": 363, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s1/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3190074784f082b9d2f3906d4aab18c876eb9615 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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' +{"n": 180, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s1/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s1/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l6-s1/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a342f524fe545fdc2e05b8023e9914a758c48394 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"K": 586828300174062601, "n_max": 363, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s1/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-shortest-path-count-l6-s1/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-shortest-path-count-l6-s6/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-shortest-path-count-l6-s6/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0fe92307c92a29d2ce8861f625a06e6546961e07 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"K": 20843904301087559, "n_max": 333, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s6/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..409cf80d6810d589a82c9fb6b1565db204ea79bb --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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' +{"n": 165, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s6/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s6/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l6-s6/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0fe92307c92a29d2ce8861f625a06e6546961e07 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"K": 20843904301087559, "n_max": 333, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s6/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-shortest-path-count-l6-s6/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-smallest-enclosing-circle-l1-s2/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-rlve-smallest-enclosing-circle-l1-s2/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e229a165d723bad12206e2ac0d35cec27ac153e --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"points": [[3, 1], [3, 3], [6, 6], [7, 0]], "r_opt": 3.1791202073853184, "r2_num": 10693, "r2_den": 1058, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8e4cb41b962dcd9e69b4c0043886d7a882ff56a0 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 5.586956521739131, "y": 2.847826086956522, "r": 3.1791202083853185} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e229a165d723bad12206e2ac0d35cec27ac153e --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"points": [[3, 1], [3, 3], [6, 6], [7, 0]], "r_opt": 3.1791202073853184, "r2_num": 10693, "r2_den": 1058, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-rlve-smallest-enclosing-circle-l1-s2/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-rlve-smallest-enclosing-circle-l1-s5/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l1-s5/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ba3163c841243dbb690e801b92ab9384f2ed521d --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"points": [[2, 3], [5, 5], [7, 1], [8, 3]], "r_opt": 3.0, "r2_num": 9, "r2_den": 1, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7399f6c0c842182d181306d4c0896614f24ea6a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 5.0, "y": 3.0, "r": 3.000000001} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ba3163c841243dbb690e801b92ab9384f2ed521d --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"points": [[2, 3], [5, 5], [7, 1], [8, 3]], "r_opt": 3.0, "r2_num": 9, "r2_den": 1, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l1-s5/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-subgraph-isomorphism-l1-s1/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s1/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d17f710da42114db8dfed30ab842ad6dcf186a6b --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[0, 1]], "edges2": [[0, 2], [2, 3], [1, 3]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s1/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f27fdbe0cc27fa9128a7aec9ea90494dd14f1d79 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [2, 0, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s1/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/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-l1-s1/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d17f710da42114db8dfed30ab842ad6dcf186a6b --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[0, 1]], "edges2": [[0, 2], [2, 3], [1, 3]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s1/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s1/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s6/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s6/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8523d8577d647f4ab8b573ceb5b0babc197af473 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n1": 4, "n2": 5, "edges1": [[0, 3], [0, 1], [1, 3], [0, 2]], "edges2": [[0, 2], [0, 1], [1, 2], [0, 3], [2, 4]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s6/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..67c78eb86109f5e9428123d4b656d290d901cbf2 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [0, 2, 3, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s6/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/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-l1-s6/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8523d8577d647f4ab8b573ceb5b0babc197af473 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n1": 4, "n2": 5, "edges1": [[0, 3], [0, 1], [1, 3], [0, 2]], "edges2": [[0, 2], [0, 1], [1, 2], [0, 3], [2, 4]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s6/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s6/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s8/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s8/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a9ce6bc9f64b3b38f229b020f87c963dfa2c0a09 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[0, 2], [1, 2]], "edges2": [[0, 1], [2, 4], [0, 3], [1, 4]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s8/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f0ac08ecb8a25f1cf655b92453f657635cb8e091 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [0, 4, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s8/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/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-l1-s8/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a9ce6bc9f64b3b38f229b020f87c963dfa2c0a09 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[0, 2], [1, 2]], "edges2": [[0, 1], [2, 4], [0, 3], [1, 4]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s8/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s8/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s7/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s7/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9d8808ecadd047a191ceeee25a5003a35bc9cd1a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n1": 19, "n2": 26, "edges1": [[0, 17], [6, 12], [1, 2], [4, 6], [5, 8], [0, 10], [6, 16], [0, 16], [12, 17], [11, 13], [0, 9], [5, 7], [10, 17], [1, 16], [11, 16], [7, 16], [5, 16], [4, 10], [15, 16], [13, 15], [7, 18], [8, 11], [7, 8]], "edges2": [[20, 22], [9, 17], [7, 18], [13, 23], [0, 14], [1, 4], [23, 24], [7, 11], [5, 9], [7, 13], [13, 20], [13, 24], [6, 21], [20, 23], [4, 7], [16, 21], [21, 25], [13, 25], [16, 24], [8, 23], [4, 16], [7, 17], [1, 25], [8, 13], [5, 20], [5, 14], [17, 18], [4, 5], [22, 23], [5, 18], [8, 9], [2, 7], [3, 13], [12, 13], [13, 14], [12, 22], [2, 12], [12, 18], [17, 20], [3, 15], [17, 22], [13, 17], [9, 20], [7, 16], [17, 21], [12, 15], [1, 6], [8, 22]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s7/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..079ed696d6e423ab7e86f307a9bcdc2cb85e14f6 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [7, 14, 0, 10, 21, 23, 25, 8, 22, 11, 16, 12, 1, 15, 19, 3, 13, 4, 9]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s7/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/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-l5-s7/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9d8808ecadd047a191ceeee25a5003a35bc9cd1a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n1": 19, "n2": 26, "edges1": [[0, 17], [6, 12], [1, 2], [4, 6], [5, 8], [0, 10], [6, 16], [0, 16], [12, 17], [11, 13], [0, 9], [5, 7], [10, 17], [1, 16], [11, 16], [7, 16], [5, 16], [4, 10], [15, 16], [13, 15], [7, 18], [8, 11], [7, 8]], "edges2": [[20, 22], [9, 17], [7, 18], [13, 23], [0, 14], [1, 4], [23, 24], [7, 11], [5, 9], [7, 13], [13, 20], [13, 24], [6, 21], [20, 23], [4, 7], [16, 21], [21, 25], [13, 25], [16, 24], [8, 23], [4, 16], [7, 17], [1, 25], [8, 13], [5, 20], [5, 14], [17, 18], [4, 5], [22, 23], [5, 18], [8, 9], [2, 7], [3, 13], [12, 13], [13, 14], [12, 22], [2, 12], [12, 18], [17, 20], [3, 15], [17, 22], [13, 17], [9, 20], [7, 16], [17, 21], [12, 15], [1, 6], [8, 22]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s7/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s7/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s9/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s9/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..810bc4b624010de3f36fe118b88b108889cf9ef4 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n1": 25, "n2": 26, "edges1": [[12, 13], [19, 23], [4, 23], [2, 13], [3, 21], [8, 24], [20, 22], [0, 11], [20, 24], [15, 20], [2, 11], [0, 22], [1, 13], [17, 22], [12, 24], [8, 17], [11, 24], [14, 15], [4, 17], [1, 5], [12, 22], [10, 17], [11, 19], [4, 20], [6, 15], [14, 19], [7, 10], [3, 23], [4, 18], [0, 4], [12, 16], [6, 12], [17, 20], [0, 8], [2, 18], [5, 9], [4, 7], [5, 8], [18, 24], [4, 5], [14, 20], [13, 23], [10, 19], [8, 19], [12, 15], [18, 20], [7, 20], [1, 7], [4, 19], [1, 16], [13, 14], [0, 19], [9, 15], [4, 10], [7, 22], [9, 18], [15, 21], [3, 10], [18, 23], [5, 11], [3, 13], [5, 7], [1, 22], [0, 10], [11, 23], [9, 24], [1, 12], [2, 4], [9, 14], [4, 15], [1, 8], [11, 15], [4, 16], [11, 14], [20, 21], [12, 18], [22, 23], [12, 21], [17, 21], [5, 21], [1, 6], [13, 18], [2, 7], [2, 17], [13, 17], [1, 14], [5, 10], [6, 11], [3, 7], [0, 12], [5, 24], [7, 19], [7, 21], [18, 21], [17, 23], [2, 21], [8, 12], [11, 16], [2, 5], [23, 24], [8, 23], [8, 10], [9, 12], [22, 24], [16, 19], [1, 11], [16, 20], [7, 23], [4, 6], [9, 10], [5, 17], [20, 23], [3, 16], [9, 20], [14, 17], [16, 18], [9, 17], [6, 7], [21, 22], [10, 12], [3, 9], [7, 24], [1, 18], [3, 5], [7, 14], [16, 21], [2, 23], [0, 17], [11, 18], [0, 16], [6, 22], [2, 6], [4, 9], [14, 23], [21, 23], [3, 14], [11, 21], [1, 17], [6, 19], [10, 20], [3, 12], [2, 3], [11, 13], [12, 20], [0, 24], [8, 16], [7, 16], [7, 18], [5, 14], [4, 22], [7, 9], [10, 22], [2, 24], [7, 13], [5, 23], [16, 23], [15, 18], [11, 12], [5, 22], [7, 17], [1, 21], [1, 15], [0, 20], [9, 23], [5, 12]], "edges2": [[8, 15], [9, 23], [2, 23], [3, 11], [18, 21], [5, 16], [0, 22], [15, 22], [9, 12], [6, 24], [2, 16], [11, 25], [14, 19], [4, 23], [17, 18], [24, 25], [0, 9], [1, 4], [9, 10], [7, 20], [13, 22], [0, 4], [2, 5], [20, 22], [7, 8], [16, 17], [7, 10], [0, 12], [10, 19], [1, 24], [5, 22], [8, 19], [10, 13], [2, 11], [19, 21], [3, 14], [5, 6], [0, 2], [18, 20], [4, 5], [6, 16], [11, 21], [10, 12], [14, 15], [0, 23], [5, 18], [8, 9], [1, 6], [12, 17], [14, 25], [4, 15], [5, 8], [11, 22], [1, 23], [18, 24], [0, 10], [5, 21], [8, 22], [19, 24], [1, 5], [5, 15], [2, 10], [6, 18], [1, 8], [2, 22], [16, 20], [0, 18], [9, 20], [1, 10], [6, 9], [1, 17], [0, 17], [5, 13], [6, 10], [7, 11], [4, 19], [0, 25], [3, 24], [13, 15], [7, 19], [8, 13], [5, 17], [1, 12], [14, 17], [0, 13], [4, 17], [22, 24], [12, 18], [8, 18], [0, 24], [15, 23], [9, 13], [10, 16], [19, 23], [8, 16], [8, 17], [4, 7], [0, 19], [17, 21], [0, 14], [3, 7], [2, 8], [3, 13], [5, 14], [3, 5], [19, 22], [12, 23], [11, 17], [1, 19], [0, 21], [9, 14], [9, 18], [9, 25], [8, 21], [10, 14], [22, 25], [15, 19], [3, 19], [2, 18], [19, 25], [1, 25], [3, 25], [11, 12], [6, 20], [6, 14], [13, 18], [17, 20], [2, 15], [19, 20], [3, 18], [3, 21], [5, 11], [1, 2], [5, 24], [1, 14], [13, 20], [3, 9], [13, 16], [8, 20], [1, 21], [4, 25], [9, 19], [15, 21], [18, 19], [5, 12], [0, 8], [2, 13], [7, 22], [23, 25], [0, 15], [16, 24], [3, 6], [3, 20], [14, 16], [1, 7], [2, 19], [7, 17], [6, 13], [16, 19], [17, 25], [0, 7], [20, 21], [8, 23], [14, 21], [23, 24], [0, 20], [9, 22], [3, 22], [0, 3], [21, 25], [1, 11], [8, 24], [4, 20], [5, 25], [21, 23], [7, 15], [20, 23], [9, 11]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s9/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bf617b8f39af2f098add2c9fe946f7c8953bb841 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [6, 17, 23, 15, 9, 8, 12, 0, 16, 22, 13, 1, 5, 4, 7, 11, 14, 20, 25, 10, 3, 21, 18, 19, 24]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s9/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/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-l5-s9/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..810bc4b624010de3f36fe118b88b108889cf9ef4 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n1": 25, "n2": 26, "edges1": [[12, 13], [19, 23], [4, 23], [2, 13], [3, 21], [8, 24], [20, 22], [0, 11], [20, 24], [15, 20], [2, 11], [0, 22], [1, 13], [17, 22], [12, 24], [8, 17], [11, 24], [14, 15], [4, 17], [1, 5], [12, 22], [10, 17], [11, 19], [4, 20], [6, 15], [14, 19], [7, 10], [3, 23], [4, 18], [0, 4], [12, 16], [6, 12], [17, 20], [0, 8], [2, 18], [5, 9], [4, 7], [5, 8], [18, 24], [4, 5], [14, 20], [13, 23], [10, 19], [8, 19], [12, 15], [18, 20], [7, 20], [1, 7], [4, 19], [1, 16], [13, 14], [0, 19], [9, 15], [4, 10], [7, 22], [9, 18], [15, 21], [3, 10], [18, 23], [5, 11], [3, 13], [5, 7], [1, 22], [0, 10], [11, 23], [9, 24], [1, 12], [2, 4], [9, 14], [4, 15], [1, 8], [11, 15], [4, 16], [11, 14], [20, 21], [12, 18], [22, 23], [12, 21], [17, 21], [5, 21], [1, 6], [13, 18], [2, 7], [2, 17], [13, 17], [1, 14], [5, 10], [6, 11], [3, 7], [0, 12], [5, 24], [7, 19], [7, 21], [18, 21], [17, 23], [2, 21], [8, 12], [11, 16], [2, 5], [23, 24], [8, 23], [8, 10], [9, 12], [22, 24], [16, 19], [1, 11], [16, 20], [7, 23], [4, 6], [9, 10], [5, 17], [20, 23], [3, 16], [9, 20], [14, 17], [16, 18], [9, 17], [6, 7], [21, 22], [10, 12], [3, 9], [7, 24], [1, 18], [3, 5], [7, 14], [16, 21], [2, 23], [0, 17], [11, 18], [0, 16], [6, 22], [2, 6], [4, 9], [14, 23], [21, 23], [3, 14], [11, 21], [1, 17], [6, 19], [10, 20], [3, 12], [2, 3], [11, 13], [12, 20], [0, 24], [8, 16], [7, 16], [7, 18], [5, 14], [4, 22], [7, 9], [10, 22], [2, 24], [7, 13], [5, 23], [16, 23], [15, 18], [11, 12], [5, 22], [7, 17], [1, 21], [1, 15], [0, 20], [9, 23], [5, 12]], "edges2": [[8, 15], [9, 23], [2, 23], [3, 11], [18, 21], [5, 16], [0, 22], [15, 22], [9, 12], [6, 24], [2, 16], [11, 25], [14, 19], [4, 23], [17, 18], [24, 25], [0, 9], [1, 4], [9, 10], [7, 20], [13, 22], [0, 4], [2, 5], [20, 22], [7, 8], [16, 17], [7, 10], [0, 12], [10, 19], [1, 24], [5, 22], [8, 19], [10, 13], [2, 11], [19, 21], [3, 14], [5, 6], [0, 2], [18, 20], [4, 5], [6, 16], [11, 21], [10, 12], [14, 15], [0, 23], [5, 18], [8, 9], [1, 6], [12, 17], [14, 25], [4, 15], [5, 8], [11, 22], [1, 23], [18, 24], [0, 10], [5, 21], [8, 22], [19, 24], [1, 5], [5, 15], [2, 10], [6, 18], [1, 8], [2, 22], [16, 20], [0, 18], [9, 20], [1, 10], [6, 9], [1, 17], [0, 17], [5, 13], [6, 10], [7, 11], [4, 19], [0, 25], [3, 24], [13, 15], [7, 19], [8, 13], [5, 17], [1, 12], [14, 17], [0, 13], [4, 17], [22, 24], [12, 18], [8, 18], [0, 24], [15, 23], [9, 13], [10, 16], [19, 23], [8, 16], [8, 17], [4, 7], [0, 19], [17, 21], [0, 14], [3, 7], [2, 8], [3, 13], [5, 14], [3, 5], [19, 22], [12, 23], [11, 17], [1, 19], [0, 21], [9, 14], [9, 18], [9, 25], [8, 21], [10, 14], [22, 25], [15, 19], [3, 19], [2, 18], [19, 25], [1, 25], [3, 25], [11, 12], [6, 20], [6, 14], [13, 18], [17, 20], [2, 15], [19, 20], [3, 18], [3, 21], [5, 11], [1, 2], [5, 24], [1, 14], [13, 20], [3, 9], [13, 16], [8, 20], [1, 21], [4, 25], [9, 19], [15, 21], [18, 19], [5, 12], [0, 8], [2, 13], [7, 22], [23, 25], [0, 15], [16, 24], [3, 6], [3, 20], [14, 16], [1, 7], [2, 19], [7, 17], [6, 13], [16, 19], [17, 25], [0, 7], [20, 21], [8, 23], [14, 21], [23, 24], [0, 20], [9, 22], [3, 22], [0, 3], [21, 25], [1, 11], [8, 24], [4, 20], [5, 25], [21, 23], [7, 15], [20, 23], [9, 11]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s9/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s9/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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/optimize-ae-p1-ff-nikodym-d3-p41/environment/Dockerfile b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/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-nikodym-d3-p41/environment/instance.json b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..89eb0d4388e9e32c051efa52c8a970201793f4e8 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/environment/instance.json @@ -0,0 +1 @@ +{"p": 41, "direction": "minimize", "family": "ae_p1_ff_nikodym", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p41/solution/solve.sh b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8b1f7e6de290b91b965687314168393469f01e4c --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/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' +{"removed": [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [0, 9, 9], [0, 10, 10], [0, 11, 11], [0, 12, 12], [0, 13, 13], [0, 14, 14], [0, 15, 15], [0, 16, 16], [0, 17, 17], [0, 18, 18], [0, 19, 19], [0, 20, 20], [0, 21, 21], [0, 22, 22], [0, 23, 23], [0, 24, 24], [0, 25, 25], [0, 26, 26], [0, 27, 27], [0, 28, 28], [0, 29, 29], [0, 30, 30], [0, 31, 31], [0, 32, 32], [0, 33, 33], [0, 34, 34], [0, 35, 35], [0, 36, 36], [0, 37, 37], [0, 38, 38], [0, 39, 39], [0, 40, 40], [1, 0, 1], [1, 1, 0], [1, 1, 1], [2, 0, 2], [2, 1, 2], [2, 1, 4], [2, 1, 8], [2, 1, 16], [2, 1, 18], [2, 1, 21], [2, 1, 31], [2, 1, 36], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2, 2, 4], [2, 2, 8], [2, 2, 16], [2, 2, 21], [2, 2, 31], [2, 2, 32], [2, 2, 36], [2, 4, 1], [2, 4, 2], [2, 4, 8], [2, 4, 16], [2, 4, 21], [2, 4, 23], [2, 4, 31], [2, 4, 32], [2, 5, 8], [2, 5, 10], [2, 5, 16], [2, 5, 20], [2, 5, 23], [2, 5, 32], [2, 5, 39], [2, 5, 40], [2, 8, 1], [2, 8, 2], [2, 8, 4], [2, 8, 5], [2, 8, 16], [2, 8, 21], [2, 8, 23], [2, 8, 32], [2, 9, 18], [2, 9, 21], [2, 9, 25], [2, 9, 31], [2, 9, 33], [2, 9, 36], [2, 9, 37], [2, 9, 39], [2, 10, 5], [2, 10, 16], [2, 10, 20], [2, 10, 23], [2, 10, 32], [2, 10, 37], [2, 10, 39], [2, 10, 40], [2, 16, 1], [2, 16, 2], [2, 16, 4], [2, 16, 5], [2, 16, 8], [2, 16, 10], [2, 16, 23], [2, 16, 32], [2, 18, 1], [2, 18, 9], [2, 18, 21], [2, 18, 25], [2, 18, 31], [2, 18, 33], [2, 18, 36], [2, 18, 37], [2, 20, 5], [2, 20, 10], [2, 20, 23], [2, 20, 32], [2, 20, 33], [2, 20, 37], [2, 20, 39], [2, 20, 40], [2, 21, 1], [2, 21, 2], [2, 21, 4], [2, 21, 8], [2, 21, 9], [2, 21, 18], [2, 21, 31], [2, 21, 36], [2, 23, 4], [2, 23, 5], [2, 23, 8], [2, 23, 10], [2, 23, 16], [2, 23, 20], [2, 23, 32], [2, 23, 40], [2, 25, 9], [2, 25, 18], [2, 25, 31], [2, 25, 33], [2, 25, 36], [2, 25, 37], [2, 25, 39], [2, 25, 40], [2, 31, 1], [2, 31, 2], [2, 31, 4], [2, 31, 9], [2, 31, 18], [2, 31, 21], [2, 31, 25], [2, 31, 36], [2, 32, 2], [2, 32, 4], [2, 32, 5], [2, 32, 8], [2, 32, 10], [2, 32, 16], [2, 32, 20], [2, 32, 23], [2, 33, 9], [2, 33, 18], [2, 33, 20], [2, 33, 25], [2, 33, 36], [2, 33, 37], [2, 33, 39], [2, 33, 40], [2, 36, 1], [2, 36, 2], [2, 36, 9], [2, 36, 18], [2, 36, 21], [2, 36, 25], [2, 36, 31], [2, 36, 33], [2, 37, 9], [2, 37, 10], [2, 37, 18], [2, 37, 20], [2, 37, 25], [2, 37, 33], [2, 37, 39], [2, 37, 40], [2, 39, 5], [2, 39, 9], [2, 39, 10], [2, 39, 20], [2, 39, 25], [2, 39, 33], [2, 39, 37], [2, 39, 40], [2, 40, 5], [2, 40, 10], [2, 40, 20], [2, 40, 23], [2, 40, 25], [2, 40, 33], [2, 40, 37], [2, 40, 39], [3, 0, 3], [3, 1, 3], [3, 1, 9], [3, 1, 14], [3, 1, 27], [3, 1, 32], [3, 1, 38], [3, 1, 40], [3, 3, 0], [3, 3, 1], [3, 3, 3], [3, 3, 9], [3, 3, 14], [3, 3, 27], [3, 3, 32], [3, 3, 38], [3, 3, 40], [3, 9, 1], [3, 9, 3], [3, 9, 14], [3, 9, 27], [3, 9, 32], [3, 9, 38], [3, 9, 40], [3, 14, 1], [3, 14, 3], [3, 14, 9], [3, 14, 27], [3, 14, 32], [3, 14, 38], [3, 14, 40], [3, 27, 1], [3, 27, 3], [3, 27, 9], [3, 27, 14], [3, 27, 32], [3, 27, 38], [3, 27, 40], [3, 32, 1], [3, 32, 3], [3, 32, 9], [3, 32, 14], [3, 32, 27], [3, 32, 38], [3, 32, 40], [3, 38, 1], [3, 38, 3], [3, 38, 9], [3, 38, 14], [3, 38, 27], [3, 38, 32], [3, 38, 40], [3, 40, 1], [3, 40, 3], [3, 40, 9], [3, 40, 14], [3, 40, 27], [3, 40, 32], [3, 40, 38], [4, 0, 4], [4, 1, 4], [4, 1, 10], [4, 1, 16], [4, 1, 18], [4, 1, 23], [4, 1, 25], [4, 1, 31], [4, 1, 37], [4, 4, 0], [4, 4, 1], [4, 4, 4], [4, 4, 10], [4, 4, 16], [4, 4, 18], [4, 4, 23], [4, 4, 25], [4, 4, 31], [4, 4, 40], [4, 10, 1], [4, 10, 4], [4, 10, 16], [4, 10, 18], [4, 10, 23], [4, 10, 25], [4, 10, 37], [4, 10, 40], [4, 16, 1], [4, 16, 4], [4, 16, 10], [4, 16, 18], [4, 16, 23], [4, 16, 31], [4, 16, 37], [4, 16, 40], [4, 18, 1], [4, 18, 4], [4, 18, 10], [4, 18, 16], [4, 18, 25], [4, 18, 31], [4, 18, 37], [4, 18, 40], [4, 23, 1], [4, 23, 4], [4, 23, 10], [4, 23, 16], [4, 23, 25], [4, 23, 31], [4, 23, 37], [4, 23, 40], [4, 25, 1], [4, 25, 4], [4, 25, 10], [4, 25, 18], [4, 25, 23], [4, 25, 31], [4, 25, 37], [4, 25, 40], [4, 31, 1], [4, 31, 4], [4, 31, 16], [4, 31, 18], [4, 31, 23], [4, 31, 25], [4, 31, 37], [4, 31, 40], [4, 37, 1], [4, 37, 10], [4, 37, 16], [4, 37, 18], [4, 37, 23], [4, 37, 25], [4, 37, 31], [4, 37, 40], [4, 40, 4], [4, 40, 10], [4, 40, 16], [4, 40, 18], [4, 40, 23], [4, 40, 25], [4, 40, 31], [4, 40, 37], [5, 0, 5], [5, 1, 2], [5, 1, 5], [5, 1, 10], [5, 1, 21], [5, 1, 23], [5, 1, 25], [5, 1, 33], [5, 1, 37], [5, 2, 1], [5, 2, 4], [5, 2, 5], [5, 2, 9], [5, 2, 10], [5, 2, 20], [5, 2, 25], [5, 2, 33], [5, 4, 2], [5, 4, 8], [5, 4, 9], [5, 4, 10], [5, 4, 18], [5, 4, 20], [5, 4, 25], [5, 4, 40], [5, 5, 0], [5, 5, 1], [5, 5, 2], [5, 5, 5], [5, 5, 9], [5, 5, 10], [5, 5, 21], [5, 5, 23], [5, 5, 25], [5, 5, 33], [5, 8, 4], [5, 8, 9], [5, 8, 16], [5, 8, 18], [5, 8, 20], [5, 8, 36], [5, 8, 39], [5, 8, 40], [5, 9, 2], [5, 9, 4], [5, 9, 5], [5, 9, 8], [5, 9, 10], [5, 9, 18], [5, 9, 20], [5, 9, 25], [5, 10, 1], [5, 10, 2], [5, 10, 4], [5, 10, 5], [5, 10, 9], [5, 10, 18], [5, 10, 20], [5, 10, 25], [5, 16, 8], [5, 16, 18], [5, 16, 31], [5, 16, 32], [5, 16, 36], [5, 16, 37], [5, 16, 39], [5, 16, 40], [5, 18, 4], [5, 18, 8], [5, 18, 9], [5, 18, 10], [5, 18, 16], [5, 18, 20], [5, 18, 36], [5, 18, 40], [5, 20, 2], [5, 20, 4], [5, 20, 8], [5, 20, 9], [5, 20, 10], [5, 20, 18], [5, 20, 36], [5, 20, 40], [5, 21, 1], [5, 21, 5], [5, 21, 23], [5, 21, 31], [5, 21, 32], [5, 21, 33], [5, 21, 37], [5, 21, 39], [5, 23, 1], [5, 23, 5], [5, 23, 21], [5, 23, 25], [5, 23, 31], [5, 23, 32], [5, 23, 33], [5, 23, 37], [5, 25, 1], [5, 25, 2], [5, 25, 4], [5, 25, 5], [5, 25, 9], [5, 25, 10], [5, 25, 23], [5, 25, 33], [5, 31, 16], [5, 31, 21], [5, 31, 23], [5, 31, 32], [5, 31, 36], [5, 31, 37], [5, 31, 39], [5, 31, 40], [5, 32, 16], [5, 32, 21], [5, 32, 23], [5, 32, 31], [5, 32, 33], [5, 32, 36], [5, 32, 37], [5, 32, 39], [5, 33, 1], [5, 33, 2], [5, 33, 5], [5, 33, 21], [5, 33, 23], [5, 33, 25], [5, 33, 32], [5, 33, 37], [5, 36, 8], [5, 36, 16], [5, 36, 18], [5, 36, 20], [5, 36, 31], [5, 36, 32], [5, 36, 39], [5, 36, 40], [5, 37, 1], [5, 37, 16], [5, 37, 21], [5, 37, 23], [5, 37, 31], [5, 37, 32], [5, 37, 33], [5, 37, 39], [5, 39, 8], [5, 39, 16], [5, 39, 21], [5, 39, 31], [5, 39, 32], [5, 39, 36], [5, 39, 37], [5, 39, 40], [5, 40, 4], [5, 40, 8], [5, 40, 16], [5, 40, 18], [5, 40, 20], [5, 40, 31], [5, 40, 36], [5, 40, 39], [6, 0, 6], [6, 1, 6], [6, 1, 7], [6, 1, 8], [6, 1, 11], [6, 1, 15], [6, 1, 23], [6, 1, 25], [6, 1, 36], [6, 2, 5], [6, 2, 9], [6, 2, 12], [6, 2, 14], [6, 2, 16], [6, 2, 22], [6, 2, 30], [6, 2, 31], [6, 3, 4], [6, 3, 18], [6, 3, 21], [6, 3, 24], [6, 3, 26], [6, 3, 28], [6, 3, 33], [6, 3, 34], [6, 4, 3], [6, 4, 10], [6, 4, 18], [6, 4, 19], [6, 4, 21], [6, 4, 24], [6, 4, 28], [6, 4, 32], [6, 5, 2], [6, 5, 14], [6, 5, 16], [6, 5, 30], [6, 5, 33], [6, 5, 34], [6, 5, 35], [6, 5, 40], [6, 6, 0], [6, 6, 1], [6, 6, 6], [6, 6, 7], [6, 6, 8], [6, 6, 11], [6, 6, 15], [6, 6, 25], [6, 6, 27], [6, 6, 36], [6, 7, 1], [6, 7, 6], [6, 7, 8], [6, 7, 11], [6, 7, 15], [6, 7, 23], [6, 7, 36], [6, 7, 38], [6, 8, 1], [6, 8, 6], [6, 8, 7], [6, 8, 15], [6, 8, 20], [6, 8, 23], [6, 8, 36], [6, 8, 38], [6, 9, 2], [6, 9, 12], [6, 9, 13], [6, 9, 17], [6, 9, 20], [6, 9, 22], [6, 9, 31], [6, 9, 37], [6, 10, 4], [6, 10, 19], [6, 10, 25], [6, 10, 27], [6, 10, 28], [6, 10, 29], [6, 10, 32], [6, 10, 39], [6, 11, 1], [6, 11, 6], [6, 11, 7], [6, 11, 25], [6, 11, 27], [6, 11, 29], [6, 11, 36], [6, 11, 39], [6, 12, 2], [6, 12, 9], [6, 12, 13], [6, 12, 14], [6, 12, 16], [6, 12, 22], [6, 12, 30], [6, 12, 31], [6, 13, 9], [6, 13, 12], [6, 13, 17], [6, 13, 20], [6, 13, 22], [6, 13, 31], [6, 13, 37], [6, 13, 38], [6, 14, 2], [6, 14, 5], [6, 14, 12], [6, 14, 16], [6, 14, 22], [6, 14, 30], [6, 14, 31], [6, 14, 35], [6, 15, 1], [6, 15, 6], [6, 15, 7], [6, 15, 8], [6, 15, 17], [6, 15, 20], [6, 15, 23], [6, 15, 38], [6, 16, 2], [6, 16, 5], [6, 16, 12], [6, 16, 14], [6, 16, 30], [6, 16, 31], [6, 16, 35], [6, 16, 40], [6, 17, 9], [6, 17, 13], [6, 17, 15], [6, 17, 20], [6, 17, 22], [6, 17, 23], [6, 17, 37], [6, 17, 38], [6, 18, 3], [6, 18, 4], [6, 18, 21], [6, 18, 24], [6, 18, 26], [6, 18, 33], [6, 18, 34], [6, 18, 40], [6, 19, 4], [6, 19, 10], [6, 19, 24], [6, 19, 27], [6, 19, 28], [6, 19, 29], [6, 19, 32], [6, 19, 39], [6, 20, 8], [6, 20, 9], [6, 20, 13], [6, 20, 15], [6, 20, 17], [6, 20, 23], [6, 20, 37], [6, 20, 38], [6, 21, 3], [6, 21, 4], [6, 21, 18], [6, 21, 24], [6, 21, 26], [6, 21, 28], [6, 21, 32], [6, 21, 33], [6, 22, 2], [6, 22, 9], [6, 22, 12], [6, 22, 13], [6, 22, 14], [6, 22, 17], [6, 22, 31], [6, 22, 37], [6, 23, 1], [6, 23, 7], [6, 23, 8], [6, 23, 15], [6, 23, 17], [6, 23, 20], [6, 23, 37], [6, 23, 38], [6, 24, 3], [6, 24, 4], [6, 24, 18], [6, 24, 19], [6, 24, 21], [6, 24, 26], [6, 24, 28], [6, 24, 32], [6, 25, 1], [6, 25, 6], [6, 25, 10], [6, 25, 11], [6, 25, 27], [6, 25, 29], [6, 25, 36], [6, 25, 39], [6, 26, 3], [6, 26, 18], [6, 26, 21], [6, 26, 24], [6, 26, 33], [6, 26, 34], [6, 26, 35], [6, 26, 40], [6, 27, 6], [6, 27, 10], [6, 27, 11], [6, 27, 19], [6, 27, 25], [6, 27, 29], [6, 27, 36], [6, 27, 39], [6, 28, 3], [6, 28, 4], [6, 28, 10], [6, 28, 19], [6, 28, 21], [6, 28, 24], [6, 28, 29], [6, 28, 32], [6, 29, 10], [6, 29, 11], [6, 29, 19], [6, 29, 25], [6, 29, 27], [6, 29, 28], [6, 29, 32], [6, 29, 39], [6, 30, 2], [6, 30, 5], [6, 30, 12], [6, 30, 14], [6, 30, 16], [6, 30, 34], [6, 30, 35], [6, 30, 40], [6, 31, 2], [6, 31, 9], [6, 31, 12], [6, 31, 13], [6, 31, 14], [6, 31, 16], [6, 31, 22], [6, 31, 37], [6, 32, 4], [6, 32, 10], [6, 32, 19], [6, 32, 21], [6, 32, 24], [6, 32, 28], [6, 32, 29], [6, 32, 39], [6, 33, 3], [6, 33, 5], [6, 33, 18], [6, 33, 21], [6, 33, 26], [6, 33, 34], [6, 33, 35], [6, 33, 40], [6, 34, 3], [6, 34, 5], [6, 34, 18], [6, 34, 26], [6, 34, 30], [6, 34, 33], [6, 34, 35], [6, 34, 40], [6, 35, 5], [6, 35, 14], [6, 35, 16], [6, 35, 26], [6, 35, 30], [6, 35, 33], [6, 35, 34], [6, 35, 40], [6, 36, 1], [6, 36, 6], [6, 36, 7], [6, 36, 8], [6, 36, 11], [6, 36, 25], [6, 36, 27], [6, 36, 39], [6, 37, 9], [6, 37, 13], [6, 37, 17], [6, 37, 20], [6, 37, 22], [6, 37, 23], [6, 37, 31], [6, 37, 38], [6, 38, 7], [6, 38, 8], [6, 38, 13], [6, 38, 15], [6, 38, 17], [6, 38, 20], [6, 38, 23], [6, 38, 37], [6, 39, 10], [6, 39, 11], [6, 39, 19], [6, 39, 25], [6, 39, 27], [6, 39, 29], [6, 39, 32], [6, 39, 36], [6, 40, 5], [6, 40, 16], [6, 40, 18], [6, 40, 26], [6, 40, 30], [6, 40, 33], [6, 40, 34], [6, 40, 35], [7, 0, 7], [7, 1, 6], [7, 1, 7], [7, 1, 8], [7, 1, 11], [7, 1, 15], [7, 1, 23], [7, 1, 25], [7, 1, 36], [7, 2, 5], [7, 2, 9], [7, 2, 12], [7, 2, 14], [7, 2, 16], [7, 2, 22], [7, 2, 30], [7, 2, 31], [7, 3, 4], [7, 3, 18], [7, 3, 21], [7, 3, 24], [7, 3, 26], [7, 3, 28], [7, 3, 33], [7, 3, 34], [7, 4, 3], [7, 4, 10], [7, 4, 18], [7, 4, 19], [7, 4, 21], [7, 4, 24], [7, 4, 28], [7, 4, 32], [7, 5, 2], [7, 5, 14], [7, 5, 16], [7, 5, 30], [7, 5, 33], [7, 5, 34], [7, 5, 35], [7, 5, 40], [7, 6, 1], [7, 6, 7], [7, 6, 8], [7, 6, 11], [7, 6, 15], [7, 6, 25], [7, 6, 27], [7, 6, 36], [7, 7, 0], [7, 7, 1], [7, 7, 6], [7, 7, 7], [7, 7, 8], [7, 7, 11], [7, 7, 15], [7, 7, 23], [7, 7, 36], [7, 7, 38], [7, 8, 1], [7, 8, 6], [7, 8, 7], [7, 8, 15], [7, 8, 20], [7, 8, 23], [7, 8, 36], [7, 8, 38], [7, 9, 2], [7, 9, 12], [7, 9, 13], [7, 9, 17], [7, 9, 20], [7, 9, 22], [7, 9, 31], [7, 9, 37], [7, 10, 4], [7, 10, 19], [7, 10, 25], [7, 10, 27], [7, 10, 28], [7, 10, 29], [7, 10, 32], [7, 10, 39], [7, 11, 1], [7, 11, 6], [7, 11, 7], [7, 11, 25], [7, 11, 27], [7, 11, 29], [7, 11, 36], [7, 11, 39], [7, 12, 2], [7, 12, 9], [7, 12, 13], [7, 12, 14], [7, 12, 16], [7, 12, 22], [7, 12, 30], [7, 12, 31], [7, 13, 9], [7, 13, 12], [7, 13, 17], [7, 13, 20], [7, 13, 22], [7, 13, 31], [7, 13, 37], [7, 13, 38], [7, 14, 2], [7, 14, 5], [7, 14, 12], [7, 14, 16], [7, 14, 22], [7, 14, 30], [7, 14, 31], [7, 14, 35], [7, 15, 1], [7, 15, 6], [7, 15, 7], [7, 15, 8], [7, 15, 17], [7, 15, 20], [7, 15, 23], [7, 15, 38], [7, 16, 2], [7, 16, 5], [7, 16, 12], [7, 16, 14], [7, 16, 30], [7, 16, 31], [7, 16, 35], [7, 16, 40], [7, 17, 9], [7, 17, 13], [7, 17, 15], [7, 17, 20], [7, 17, 22], [7, 17, 23], [7, 17, 37], [7, 17, 38], [7, 18, 3], [7, 18, 4], [7, 18, 21], [7, 18, 24], [7, 18, 26], [7, 18, 33], [7, 18, 34], [7, 18, 40], [7, 19, 4], [7, 19, 10], [7, 19, 24], [7, 19, 27], [7, 19, 28], [7, 19, 29], [7, 19, 32], [7, 19, 39], [7, 20, 8], [7, 20, 9], [7, 20, 13], [7, 20, 15], [7, 20, 17], [7, 20, 23], [7, 20, 37], [7, 20, 38], [7, 21, 3], [7, 21, 4], [7, 21, 18], [7, 21, 24], [7, 21, 26], [7, 21, 28], [7, 21, 32], [7, 21, 33], [7, 22, 2], [7, 22, 9], [7, 22, 12], [7, 22, 13], [7, 22, 14], [7, 22, 17], [7, 22, 31], [7, 22, 37], [7, 23, 1], [7, 23, 7], [7, 23, 8], [7, 23, 15], [7, 23, 17], [7, 23, 20], [7, 23, 37], [7, 23, 38], [7, 24, 3], [7, 24, 4], [7, 24, 18], [7, 24, 19], [7, 24, 21], [7, 24, 26], [7, 24, 28], [7, 24, 32], [7, 25, 1], [7, 25, 6], [7, 25, 10], [7, 25, 11], [7, 25, 27], [7, 25, 29], [7, 25, 36], [7, 25, 39], [7, 26, 3], [7, 26, 18], [7, 26, 21], [7, 26, 24], [7, 26, 33], [7, 26, 34], [7, 26, 35], [7, 26, 40], [7, 27, 6], [7, 27, 10], [7, 27, 11], [7, 27, 19], [7, 27, 25], [7, 27, 29], [7, 27, 36], [7, 27, 39], [7, 28, 3], [7, 28, 4], [7, 28, 10], [7, 28, 19], [7, 28, 21], [7, 28, 24], [7, 28, 29], [7, 28, 32], [7, 29, 10], [7, 29, 11], [7, 29, 19], [7, 29, 25], [7, 29, 27], [7, 29, 28], [7, 29, 32], [7, 29, 39], [7, 30, 2], [7, 30, 5], [7, 30, 12], [7, 30, 14], [7, 30, 16], [7, 30, 34], [7, 30, 35], [7, 30, 40], [7, 31, 2], [7, 31, 9], [7, 31, 12], [7, 31, 13], [7, 31, 14], [7, 31, 16], [7, 31, 22], [7, 31, 37], [7, 32, 4], [7, 32, 10], [7, 32, 19], [7, 32, 21], [7, 32, 24], [7, 32, 28], [7, 32, 29], [7, 32, 39], [7, 33, 3], [7, 33, 5], [7, 33, 18], [7, 33, 21], [7, 33, 26], [7, 33, 34], [7, 33, 35], [7, 33, 40], [7, 34, 3], [7, 34, 5], [7, 34, 18], [7, 34, 26], [7, 34, 30], [7, 34, 33], [7, 34, 35], [7, 34, 40], [7, 35, 5], [7, 35, 14], [7, 35, 16], [7, 35, 26], [7, 35, 30], [7, 35, 33], [7, 35, 34], [7, 35, 40], [7, 36, 1], [7, 36, 6], [7, 36, 7], [7, 36, 8], [7, 36, 11], [7, 36, 25], [7, 36, 27], [7, 36, 39], [7, 37, 9], [7, 37, 13], [7, 37, 17], [7, 37, 20], [7, 37, 22], [7, 37, 23], [7, 37, 31], [7, 37, 38], [7, 38, 7], [7, 38, 8], [7, 38, 13], [7, 38, 15], [7, 38, 17], [7, 38, 20], [7, 38, 23], [7, 38, 37], [7, 39, 10], [7, 39, 11], [7, 39, 19], [7, 39, 25], [7, 39, 27], [7, 39, 29], [7, 39, 32], [7, 39, 36], [7, 40, 5], [7, 40, 16], [7, 40, 18], [7, 40, 26], [7, 40, 30], [7, 40, 33], [7, 40, 34], [7, 40, 35], [8, 0, 8], [8, 1, 8], [8, 1, 10], [8, 1, 20], [8, 1, 23], [8, 1, 25], [8, 1, 36], [8, 1, 37], [8, 1, 39], [8, 2, 5], [8, 2, 9], [8, 2, 16], [8, 2, 20], [8, 2, 31], [8, 2, 33], [8, 2, 37], [8, 2, 40], [8, 4, 10], [8, 4, 18], [8, 4, 21], [8, 4, 25], [8, 4, 32], [8, 4, 33], [8, 4, 39], [8, 4, 40], [8, 5, 2], [8, 5, 9], [8, 5, 16], [8, 5, 18], [8, 5, 21], [8, 5, 31], [8, 5, 33], [8, 5, 40], [8, 8, 0], [8, 8, 1], [8, 8, 8], [8, 8, 9], [8, 8, 20], [8, 8, 23], [8, 8, 25], [8, 8, 36], [8, 8, 37], [8, 8, 39], [8, 9, 2], [8, 9, 5], [8, 9, 8], [8, 9, 16], [8, 9, 20], [8, 9, 23], [8, 9, 31], [8, 9, 37], [8, 10, 1], [8, 10, 4], [8, 10, 18], [8, 10, 21], [8, 10, 25], [8, 10, 32], [8, 10, 36], [8, 10, 39], [8, 16, 2], [8, 16, 5], [8, 16, 9], [8, 16, 18], [8, 16, 31], [8, 16, 33], [8, 16, 37], [8, 16, 40], [8, 18, 4], [8, 18, 5], [8, 18, 10], [8, 18, 16], [8, 18, 21], [8, 18, 32], [8, 18, 33], [8, 18, 40], [8, 20, 1], [8, 20, 2], [8, 20, 8], [8, 20, 9], [8, 20, 23], [8, 20, 31], [8, 20, 36], [8, 20, 37], [8, 21, 4], [8, 21, 5], [8, 21, 10], [8, 21, 18], [8, 21, 32], [8, 21, 33], [8, 21, 39], [8, 21, 40], [8, 23, 1], [8, 23, 8], [8, 23, 9], [8, 23, 20], [8, 23, 25], [8, 23, 31], [8, 23, 36], [8, 23, 37], [8, 25, 1], [8, 25, 4], [8, 25, 8], [8, 25, 10], [8, 25, 23], [8, 25, 32], [8, 25, 36], [8, 25, 39], [8, 31, 2], [8, 31, 5], [8, 31, 9], [8, 31, 16], [8, 31, 20], [8, 31, 23], [8, 31, 37], [8, 31, 40], [8, 32, 4], [8, 32, 10], [8, 32, 18], [8, 32, 21], [8, 32, 25], [8, 32, 33], [8, 32, 36], [8, 32, 39], [8, 33, 2], [8, 33, 4], [8, 33, 5], [8, 33, 16], [8, 33, 18], [8, 33, 21], [8, 33, 32], [8, 33, 40], [8, 36, 1], [8, 36, 8], [8, 36, 10], [8, 36, 20], [8, 36, 23], [8, 36, 25], [8, 36, 32], [8, 36, 39], [8, 37, 1], [8, 37, 2], [8, 37, 8], [8, 37, 9], [8, 37, 16], [8, 37, 20], [8, 37, 23], [8, 37, 31], [8, 39, 1], [8, 39, 4], [8, 39, 8], [8, 39, 10], [8, 39, 21], [8, 39, 25], [8, 39, 32], [8, 39, 36], [8, 40, 2], [8, 40, 4], [8, 40, 5], [8, 40, 16], [8, 40, 18], [8, 40, 21], [8, 40, 31], [8, 40, 33], [9, 0, 9], [9, 1, 1], [9, 1, 9], [9, 1, 32], [9, 1, 40], [9, 9, 0], [9, 9, 1], [9, 9, 9], [9, 9, 32], [9, 9, 40], [9, 32, 1], [9, 32, 9], [9, 32, 32], [9, 32, 40], [9, 40, 1], [9, 40, 9], [9, 40, 32], [9, 40, 40], [10, 0, 10], [10, 1, 10], [10, 1, 16], [10, 1, 18], [10, 1, 37], [10, 10, 0], [10, 10, 1], [10, 10, 10], [10, 10, 16], [10, 10, 18], [10, 10, 37], [10, 16, 1], [10, 16, 10], [10, 16, 18], [10, 16, 37], [10, 18, 1], [10, 18, 10], [10, 18, 16], [10, 18, 37], [10, 37, 1], [10, 37, 10], [10, 37, 16], [10, 37, 18], [11, 0, 11], [11, 1, 4], [11, 1, 11], [11, 1, 13], [11, 1, 15], [11, 1, 19], [11, 1, 20], [11, 1, 31], [11, 1, 39], [11, 2, 8], [11, 2, 21], [11, 2, 22], [11, 2, 26], [11, 2, 30], [11, 2, 37], [11, 2, 38], [11, 2, 40], [11, 3, 4], [11, 3, 11], [11, 3, 12], [11, 3, 16], [11, 3, 19], [11, 3, 33], [11, 3, 35], [11, 3, 39], [11, 4, 1], [11, 4, 3], [11, 4, 11], [11, 4, 16], [11, 4, 19], [11, 4, 33], [11, 4, 35], [11, 4, 39], [11, 5, 13], [11, 5, 14], [11, 5, 18], [11, 5, 20], [11, 5, 24], [11, 5, 31], [11, 5, 32], [11, 5, 34], [11, 6, 8], [11, 6, 22], [11, 6, 24], [11, 6, 25], [11, 6, 29], [11, 6, 32], [11, 6, 37], [11, 6, 38], [11, 7, 9], [11, 7, 10], [11, 7, 12], [11, 7, 17], [11, 7, 23], [11, 7, 27], [11, 7, 28], [11, 7, 36], [11, 8, 2], [11, 8, 6], [11, 8, 22], [11, 8, 25], [11, 8, 29], [11, 8, 32], [11, 8, 37], [11, 8, 38], [11, 9, 7], [11, 9, 12], [11, 9, 16], [11, 9, 17], [11, 9, 23], [11, 9, 33], [11, 9, 35], [11, 9, 36], [11, 10, 7], [11, 10, 21], [11, 10, 23], [11, 10, 26], [11, 10, 27], [11, 10, 28], [11, 10, 36], [11, 10, 40], [11, 11, 0], [11, 11, 1], [11, 11, 3], [11, 11, 4], [11, 11, 11], [11, 11, 13], [11, 11, 15], [11, 11, 19], [11, 11, 20], [11, 11, 39], [11, 12, 3], [11, 12, 7], [11, 12, 9], [11, 12, 16], [11, 12, 17], [11, 12, 23], [11, 12, 33], [11, 12, 35], [11, 13, 1], [11, 13, 5], [11, 13, 11], [11, 13, 14], [11, 13, 15], [11, 13, 20], [11, 13, 31], [11, 13, 34], [11, 14, 5], [11, 14, 13], [11, 14, 15], [11, 14, 18], [11, 14, 20], [11, 14, 24], [11, 14, 31], [11, 14, 34], [11, 15, 1], [11, 15, 11], [11, 15, 13], [11, 15, 14], [11, 15, 19], [11, 15, 20], [11, 15, 31], [11, 15, 39], [11, 16, 3], [11, 16, 4], [11, 16, 9], [11, 16, 12], [11, 16, 17], [11, 16, 23], [11, 16, 33], [11, 16, 35], [11, 17, 7], [11, 17, 9], [11, 17, 12], [11, 17, 16], [11, 17, 23], [11, 17, 27], [11, 17, 35], [11, 17, 36], [11, 18, 5], [11, 18, 14], [11, 18, 24], [11, 18, 25], [11, 18, 29], [11, 18, 31], [11, 18, 32], [11, 18, 34], [11, 19, 1], [11, 19, 3], [11, 19, 4], [11, 19, 11], [11, 19, 15], [11, 19, 33], [11, 19, 35], [11, 19, 39], [11, 20, 1], [11, 20, 5], [11, 20, 11], [11, 20, 13], [11, 20, 14], [11, 20, 15], [11, 20, 31], [11, 20, 39], [11, 21, 2], [11, 21, 10], [11, 21, 26], [11, 21, 27], [11, 21, 28], [11, 21, 30], [11, 21, 36], [11, 21, 40], [11, 22, 2], [11, 22, 6], [11, 22, 8], [11, 22, 26], [11, 22, 30], [11, 22, 37], [11, 22, 38], [11, 22, 40], [11, 23, 7], [11, 23, 9], [11, 23, 10], [11, 23, 12], [11, 23, 16], [11, 23, 17], [11, 23, 27], [11, 23, 36], [11, 24, 5], [11, 24, 6], [11, 24, 14], [11, 24, 18], [11, 24, 25], [11, 24, 29], [11, 24, 32], [11, 24, 34], [11, 25, 6], [11, 25, 8], [11, 25, 18], [11, 25, 24], [11, 25, 29], [11, 25, 32], [11, 25, 37], [11, 25, 38], [11, 26, 2], [11, 26, 10], [11, 26, 21], [11, 26, 22], [11, 26, 27], [11, 26, 28], [11, 26, 30], [11, 26, 40], [11, 27, 7], [11, 27, 10], [11, 27, 17], [11, 27, 21], [11, 27, 23], [11, 27, 26], [11, 27, 28], [11, 27, 36], [11, 28, 7], [11, 28, 10], [11, 28, 21], [11, 28, 26], [11, 28, 27], [11, 28, 30], [11, 28, 36], [11, 28, 40], [11, 29, 6], [11, 29, 8], [11, 29, 18], [11, 29, 24], [11, 29, 25], [11, 29, 32], [11, 29, 34], [11, 29, 38], [11, 30, 2], [11, 30, 21], [11, 30, 22], [11, 30, 26], [11, 30, 28], [11, 30, 37], [11, 30, 38], [11, 30, 40], [11, 31, 1], [11, 31, 5], [11, 31, 13], [11, 31, 14], [11, 31, 15], [11, 31, 18], [11, 31, 20], [11, 31, 34], [11, 32, 5], [11, 32, 6], [11, 32, 8], [11, 32, 18], [11, 32, 24], [11, 32, 25], [11, 32, 29], [11, 32, 34], [11, 33, 3], [11, 33, 4], [11, 33, 9], [11, 33, 12], [11, 33, 16], [11, 33, 19], [11, 33, 35], [11, 33, 39], [11, 34, 5], [11, 34, 13], [11, 34, 14], [11, 34, 18], [11, 34, 24], [11, 34, 29], [11, 34, 31], [11, 34, 32], [11, 35, 3], [11, 35, 4], [11, 35, 9], [11, 35, 12], [11, 35, 16], [11, 35, 17], [11, 35, 19], [11, 35, 33], [11, 36, 7], [11, 36, 9], [11, 36, 10], [11, 36, 17], [11, 36, 21], [11, 36, 23], [11, 36, 27], [11, 36, 28], [11, 37, 2], [11, 37, 6], [11, 37, 8], [11, 37, 22], [11, 37, 25], [11, 37, 30], [11, 37, 38], [11, 37, 40], [11, 38, 2], [11, 38, 6], [11, 38, 8], [11, 38, 22], [11, 38, 25], [11, 38, 29], [11, 38, 30], [11, 38, 37], [11, 39, 1], [11, 39, 3], [11, 39, 4], [11, 39, 11], [11, 39, 15], [11, 39, 19], [11, 39, 20], [11, 39, 33], [11, 40, 2], [11, 40, 10], [11, 40, 21], [11, 40, 22], [11, 40, 26], [11, 40, 28], [11, 40, 30], [11, 40, 37], [12, 0, 12], [12, 1, 2], [12, 1, 4], [12, 1, 6], [12, 1, 7], [12, 1, 12], [12, 1, 21], [12, 1, 24], [12, 1, 31], [12, 2, 1], [12, 2, 4], [12, 2, 7], [12, 2, 8], [12, 2, 12], [12, 2, 14], [12, 2, 21], [12, 2, 24], [12, 3, 6], [12, 3, 11], [12, 3, 12], [12, 3, 18], [12, 3, 21], [12, 3, 22], [12, 3, 31], [12, 3, 36], [12, 4, 1], [12, 4, 2], [12, 4, 7], [12, 4, 8], [12, 4, 14], [12, 4, 16], [12, 4, 24], [12, 4, 28], [12, 5, 10], [12, 5, 19], [12, 5, 20], [12, 5, 23], [12, 5, 30], [12, 5, 32], [12, 5, 35], [12, 5, 38], [12, 6, 1], [12, 6, 3], [12, 6, 12], [12, 6, 21], [12, 6, 22], [12, 6, 24], [12, 6, 31], [12, 6, 36], [12, 7, 1], [12, 7, 2], [12, 7, 4], [12, 7, 8], [12, 7, 12], [12, 7, 14], [12, 7, 24], [12, 7, 28], [12, 8, 2], [12, 8, 4], [12, 8, 7], [12, 8, 14], [12, 8, 15], [12, 8, 16], [12, 8, 28], [12, 8, 32], [12, 9, 11], [12, 9, 13], [12, 9, 18], [12, 9, 22], [12, 9, 25], [12, 9, 26], [12, 9, 33], [12, 9, 36], [12, 10, 5], [12, 10, 19], [12, 10, 20], [12, 10, 23], [12, 10, 29], [12, 10, 35], [12, 10, 38], [12, 10, 40], [12, 11, 3], [12, 11, 9], [12, 11, 13], [12, 11, 18], [12, 11, 22], [12, 11, 25], [12, 11, 26], [12, 11, 36], [12, 12, 0], [12, 12, 1], [12, 12, 2], [12, 12, 3], [12, 12, 6], [12, 12, 7], [12, 12, 12], [12, 12, 21], [12, 12, 24], [12, 12, 31], [12, 13, 9], [12, 13, 11], [12, 13, 25], [12, 13, 26], [12, 13, 27], [12, 13, 33], [12, 13, 34], [12, 13, 37], [12, 14, 2], [12, 14, 4], [12, 14, 7], [12, 14, 8], [12, 14, 15], [12, 14, 16], [12, 14, 24], [12, 14, 28], [12, 15, 8], [12, 15, 14], [12, 15, 16], [12, 15, 19], [12, 15, 23], [12, 15, 28], [12, 15, 30], [12, 15, 32], [12, 16, 4], [12, 16, 8], [12, 16, 14], [12, 16, 15], [12, 16, 23], [12, 16, 28], [12, 16, 30], [12, 16, 32], [12, 17, 20], [12, 17, 27], [12, 17, 29], [12, 17, 34], [12, 17, 35], [12, 17, 37], [12, 17, 39], [12, 17, 40], [12, 18, 3], [12, 18, 9], [12, 18, 11], [12, 18, 22], [12, 18, 25], [12, 18, 26], [12, 18, 31], [12, 18, 36], [12, 19, 5], [12, 19, 10], [12, 19, 15], [12, 19, 23], [12, 19, 30], [12, 19, 32], [12, 19, 35], [12, 19, 38], [12, 20, 5], [12, 20, 10], [12, 20, 17], [12, 20, 29], [12, 20, 35], [12, 20, 38], [12, 20, 39], [12, 20, 40], [12, 21, 1], [12, 21, 2], [12, 21, 3], [12, 21, 6], [12, 21, 12], [12, 21, 24], [12, 21, 31], [12, 21, 36], [12, 22, 3], [12, 22, 6], [12, 22, 9], [12, 22, 11], [12, 22, 18], [12, 22, 26], [12, 22, 31], [12, 22, 36], [12, 23, 5], [12, 23, 10], [12, 23, 15], [12, 23, 16], [12, 23, 19], [12, 23, 30], [12, 23, 32], [12, 23, 38], [12, 24, 1], [12, 24, 2], [12, 24, 4], [12, 24, 6], [12, 24, 7], [12, 24, 12], [12, 24, 14], [12, 24, 21], [12, 25, 9], [12, 25, 11], [12, 25, 13], [12, 25, 18], [12, 25, 26], [12, 25, 27], [12, 25, 33], [12, 25, 37], [12, 26, 9], [12, 26, 11], [12, 26, 13], [12, 26, 18], [12, 26, 22], [12, 26, 25], [12, 26, 27], [12, 26, 33], [12, 27, 13], [12, 27, 17], [12, 27, 25], [12, 27, 26], [12, 27, 33], [12, 27, 34], [12, 27, 37], [12, 27, 39], [12, 28, 4], [12, 28, 7], [12, 28, 8], [12, 28, 14], [12, 28, 15], [12, 28, 16], [12, 28, 30], [12, 28, 32], [12, 29, 10], [12, 29, 17], [12, 29, 20], [12, 29, 34], [12, 29, 35], [12, 29, 38], [12, 29, 39], [12, 29, 40], [12, 30, 5], [12, 30, 15], [12, 30, 16], [12, 30, 19], [12, 30, 23], [12, 30, 28], [12, 30, 32], [12, 30, 38], [12, 31, 1], [12, 31, 3], [12, 31, 6], [12, 31, 12], [12, 31, 18], [12, 31, 21], [12, 31, 22], [12, 31, 36], [12, 32, 5], [12, 32, 8], [12, 32, 15], [12, 32, 16], [12, 32, 19], [12, 32, 23], [12, 32, 28], [12, 32, 30], [12, 33, 9], [12, 33, 13], [12, 33, 25], [12, 33, 26], [12, 33, 27], [12, 33, 34], [12, 33, 37], [12, 33, 39], [12, 34, 13], [12, 34, 17], [12, 34, 27], [12, 34, 29], [12, 34, 33], [12, 34, 37], [12, 34, 39], [12, 34, 40], [12, 35, 5], [12, 35, 10], [12, 35, 17], [12, 35, 19], [12, 35, 20], [12, 35, 29], [12, 35, 38], [12, 35, 40], [12, 36, 3], [12, 36, 6], [12, 36, 9], [12, 36, 11], [12, 36, 18], [12, 36, 21], [12, 36, 22], [12, 36, 31], [12, 37, 13], [12, 37, 17], [12, 37, 25], [12, 37, 27], [12, 37, 33], [12, 37, 34], [12, 37, 39], [12, 37, 40], [12, 38, 5], [12, 38, 10], [12, 38, 19], [12, 38, 20], [12, 38, 23], [12, 38, 29], [12, 38, 30], [12, 38, 35], [12, 39, 17], [12, 39, 20], [12, 39, 27], [12, 39, 29], [12, 39, 33], [12, 39, 34], [12, 39, 37], [12, 39, 40], [12, 40, 10], [12, 40, 17], [12, 40, 20], [12, 40, 29], [12, 40, 34], [12, 40, 35], [12, 40, 37], [12, 40, 39], [13, 0, 13], [13, 1, 5], [13, 1, 12], [13, 1, 13], [13, 1, 19], [13, 1, 23], [13, 1, 24], [13, 1, 25], [13, 1, 33], [13, 2, 5], [13, 2, 7], [13, 2, 9], [13, 2, 10], [13, 2, 24], [13, 2, 25], [13, 2, 26], [13, 2, 38], [13, 3, 15], [13, 3, 16], [13, 3, 17], [13, 3, 28], [13, 3, 31], [13, 3, 34], [13, 3, 36], [13, 3, 39], [13, 4, 7], [13, 4, 9], [13, 4, 10], [13, 4, 11], [13, 4, 14], [13, 4, 18], [13, 4, 20], [13, 4, 35], [13, 5, 1], [13, 5, 2], [13, 5, 13], [13, 5, 19], [13, 5, 24], [13, 5, 25], [13, 5, 33], [13, 5, 38], [13, 6, 15], [13, 6, 21], [13, 6, 27], [13, 6, 30], [13, 6, 31], [13, 6, 32], [13, 6, 34], [13, 6, 37], [13, 7, 2], [13, 7, 4], [13, 7, 9], [13, 7, 10], [13, 7, 11], [13, 7, 26], [13, 7, 35], [13, 7, 38], [13, 8, 14], [13, 8, 18], [13, 8, 20], [13, 8, 22], [13, 8, 28], [13, 8, 29], [13, 8, 36], [13, 8, 40], [13, 9, 2], [13, 9, 4], [13, 9, 7], [13, 9, 10], [13, 9, 11], [13, 9, 20], [13, 9, 26], [13, 9, 35], [13, 10, 2], [13, 10, 4], [13, 10, 7], [13, 10, 9], [13, 10, 25], [13, 10, 26], [13, 10, 35], [13, 10, 38], [13, 11, 4], [13, 11, 7], [13, 11, 9], [13, 11, 14], [13, 11, 18], [13, 11, 20], [13, 11, 29], [13, 11, 35], [13, 12, 1], [13, 12, 13], [13, 12, 19], [13, 12, 21], [13, 12, 23], [13, 12, 27], [13, 12, 30], [13, 12, 33], [13, 13, 0], [13, 13, 1], [13, 13, 5], [13, 13, 12], [13, 13, 13], [13, 13, 19], [13, 13, 24], [13, 13, 25], [13, 13, 33], [13, 13, 38], [13, 14, 4], [13, 14, 8], [13, 14, 11], [13, 14, 18], [13, 14, 20], [13, 14, 22], [13, 14, 29], [13, 14, 35], [13, 15, 3], [13, 15, 6], [13, 15, 16], [13, 15, 17], [13, 15, 31], [13, 15, 32], [13, 15, 34], [13, 15, 39], [13, 16, 3], [13, 16, 15], [13, 16, 17], [13, 16, 28], [13, 16, 31], [13, 16, 36], [13, 16, 39], [13, 16, 40], [13, 17, 3], [13, 17, 15], [13, 17, 16], [13, 17, 22], [13, 17, 28], [13, 17, 36], [13, 17, 39], [13, 17, 40], [13, 18, 4], [13, 18, 8], [13, 18, 11], [13, 18, 14], [13, 18, 20], [13, 18, 22], [13, 18, 29], [13, 18, 40], [13, 19, 1], [13, 19, 5], [13, 19, 12], [13, 19, 13], [13, 19, 23], [13, 19, 24], [13, 19, 27], [13, 19, 33], [13, 20, 4], [13, 20, 8], [13, 20, 9], [13, 20, 11], [13, 20, 14], [13, 20, 18], [13, 20, 29], [13, 20, 35], [13, 21, 6], [13, 21, 12], [13, 21, 23], [13, 21, 27], [13, 21, 30], [13, 21, 32], [13, 21, 33], [13, 21, 37], [13, 22, 8], [13, 22, 14], [13, 22, 17], [13, 22, 18], [13, 22, 28], [13, 22, 29], [13, 22, 36], [13, 22, 40], [13, 23, 1], [13, 23, 12], [13, 23, 19], [13, 23, 21], [13, 23, 27], [13, 23, 30], [13, 23, 33], [13, 23, 37], [13, 24, 1], [13, 24, 2], [13, 24, 5], [13, 24, 13], [13, 24, 19], [13, 24, 25], [13, 24, 26], [13, 24, 38], [13, 25, 1], [13, 25, 2], [13, 25, 5], [13, 25, 10], [13, 25, 13], [13, 25, 24], [13, 25, 26], [13, 25, 38], [13, 26, 2], [13, 26, 7], [13, 26, 9], [13, 26, 10], [13, 26, 24], [13, 26, 25], [13, 26, 35], [13, 26, 38], [13, 27, 6], [13, 27, 12], [13, 27, 19], [13, 27, 21], [13, 27, 23], [13, 27, 30], [13, 27, 33], [13, 27, 37], [13, 28, 3], [13, 28, 8], [13, 28, 16], [13, 28, 17], [13, 28, 22], [13, 28, 29], [13, 28, 36], [13, 28, 40], [13, 29, 8], [13, 29, 11], [13, 29, 14], [13, 29, 18], [13, 29, 20], [13, 29, 22], [13, 29, 28], [13, 29, 40], [13, 30, 6], [13, 30, 12], [13, 30, 21], [13, 30, 23], [13, 30, 27], [13, 30, 32], [13, 30, 34], [13, 30, 37], [13, 31, 3], [13, 31, 6], [13, 31, 15], [13, 31, 16], [13, 31, 32], [13, 31, 34], [13, 31, 37], [13, 31, 39], [13, 32, 6], [13, 32, 15], [13, 32, 21], [13, 32, 30], [13, 32, 31], [13, 32, 34], [13, 32, 37], [13, 32, 39], [13, 33, 1], [13, 33, 5], [13, 33, 12], [13, 33, 13], [13, 33, 19], [13, 33, 21], [13, 33, 23], [13, 33, 27], [13, 34, 3], [13, 34, 6], [13, 34, 15], [13, 34, 30], [13, 34, 31], [13, 34, 32], [13, 34, 37], [13, 34, 39], [13, 35, 4], [13, 35, 7], [13, 35, 9], [13, 35, 10], [13, 35, 11], [13, 35, 14], [13, 35, 20], [13, 35, 26], [13, 36, 3], [13, 36, 8], [13, 36, 16], [13, 36, 17], [13, 36, 22], [13, 36, 28], [13, 36, 39], [13, 36, 40], [13, 37, 6], [13, 37, 21], [13, 37, 23], [13, 37, 27], [13, 37, 30], [13, 37, 31], [13, 37, 32], [13, 37, 34], [13, 38, 2], [13, 38, 5], [13, 38, 7], [13, 38, 10], [13, 38, 13], [13, 38, 24], [13, 38, 25], [13, 38, 26], [13, 39, 3], [13, 39, 15], [13, 39, 16], [13, 39, 17], [13, 39, 31], [13, 39, 32], [13, 39, 34], [13, 39, 36], [13, 40, 8], [13, 40, 16], [13, 40, 17], [13, 40, 18], [13, 40, 22], [13, 40, 28], [13, 40, 29], [13, 40, 36], [14, 0, 14], [14, 1, 3], [14, 1, 9], [14, 1, 14], [14, 1, 27], [14, 1, 32], [14, 1, 38], [14, 1, 40], [14, 3, 1], [14, 3, 9], [14, 3, 14], [14, 3, 27], [14, 3, 32], [14, 3, 38], [14, 3, 40], [14, 9, 1], [14, 9, 3], [14, 9, 14], [14, 9, 27], [14, 9, 32], [14, 9, 38], [14, 9, 40], [14, 14, 0], [14, 14, 1], [14, 14, 3], [14, 14, 9], [14, 14, 14], [14, 14, 27], [14, 14, 32], [14, 14, 38], [14, 14, 40], [14, 27, 1], [14, 27, 3], [14, 27, 9], [14, 27, 14], [14, 27, 32], [14, 27, 38], [14, 27, 40], [14, 32, 1], [14, 32, 3], [14, 32, 9], [14, 32, 14], [14, 32, 27], [14, 32, 38], [14, 32, 40], [14, 38, 1], [14, 38, 3], [14, 38, 9], [14, 38, 14], [14, 38, 27], [14, 38, 32], [14, 38, 40], [14, 40, 1], [14, 40, 3], [14, 40, 9], [14, 40, 14], [14, 40, 27], [14, 40, 32], [14, 40, 38], [15, 0, 15], [15, 1, 4], [15, 1, 11], [15, 1, 13], [15, 1, 15], [15, 1, 19], [15, 1, 20], [15, 1, 31], [15, 1, 39], [15, 2, 8], [15, 2, 21], [15, 2, 22], [15, 2, 26], [15, 2, 30], [15, 2, 37], [15, 2, 38], [15, 2, 40], [15, 3, 4], [15, 3, 11], [15, 3, 12], [15, 3, 16], [15, 3, 19], [15, 3, 33], [15, 3, 35], [15, 3, 39], [15, 4, 1], [15, 4, 3], [15, 4, 11], [15, 4, 16], [15, 4, 19], [15, 4, 33], [15, 4, 35], [15, 4, 39], [15, 5, 13], [15, 5, 14], [15, 5, 18], [15, 5, 20], [15, 5, 24], [15, 5, 31], [15, 5, 32], [15, 5, 34], [15, 6, 8], [15, 6, 22], [15, 6, 24], [15, 6, 25], [15, 6, 29], [15, 6, 32], [15, 6, 37], [15, 6, 38], [15, 7, 9], [15, 7, 10], [15, 7, 12], [15, 7, 17], [15, 7, 23], [15, 7, 27], [15, 7, 28], [15, 7, 36], [15, 8, 2], [15, 8, 6], [15, 8, 22], [15, 8, 25], [15, 8, 29], [15, 8, 32], [15, 8, 37], [15, 8, 38], [15, 9, 7], [15, 9, 12], [15, 9, 16], [15, 9, 17], [15, 9, 23], [15, 9, 33], [15, 9, 35], [15, 9, 36], [15, 10, 7], [15, 10, 21], [15, 10, 23], [15, 10, 26], [15, 10, 27], [15, 10, 28], [15, 10, 36], [15, 10, 40], [15, 11, 1], [15, 11, 3], [15, 11, 4], [15, 11, 13], [15, 11, 15], [15, 11, 19], [15, 11, 20], [15, 11, 39], [15, 12, 3], [15, 12, 7], [15, 12, 9], [15, 12, 16], [15, 12, 17], [15, 12, 23], [15, 12, 33], [15, 12, 35], [15, 13, 1], [15, 13, 5], [15, 13, 11], [15, 13, 14], [15, 13, 15], [15, 13, 20], [15, 13, 31], [15, 13, 34], [15, 14, 5], [15, 14, 13], [15, 14, 15], [15, 14, 18], [15, 14, 20], [15, 14, 24], [15, 14, 31], [15, 14, 34], [15, 15, 0], [15, 15, 1], [15, 15, 11], [15, 15, 13], [15, 15, 14], [15, 15, 15], [15, 15, 19], [15, 15, 20], [15, 15, 31], [15, 15, 39], [15, 16, 3], [15, 16, 4], [15, 16, 9], [15, 16, 12], [15, 16, 17], [15, 16, 23], [15, 16, 33], [15, 16, 35], [15, 17, 7], [15, 17, 9], [15, 17, 12], [15, 17, 16], [15, 17, 23], [15, 17, 27], [15, 17, 35], [15, 17, 36], [15, 18, 5], [15, 18, 14], [15, 18, 24], [15, 18, 25], [15, 18, 29], [15, 18, 31], [15, 18, 32], [15, 18, 34], [15, 19, 1], [15, 19, 3], [15, 19, 4], [15, 19, 11], [15, 19, 15], [15, 19, 33], [15, 19, 35], [15, 19, 39], [15, 20, 1], [15, 20, 5], [15, 20, 11], [15, 20, 13], [15, 20, 14], [15, 20, 15], [15, 20, 31], [15, 20, 39], [15, 21, 2], [15, 21, 10], [15, 21, 26], [15, 21, 27], [15, 21, 28], [15, 21, 30], [15, 21, 36], [15, 21, 40], [15, 22, 2], [15, 22, 6], [15, 22, 8], [15, 22, 26], [15, 22, 30], [15, 22, 37], [15, 22, 38], [15, 22, 40], [15, 23, 7], [15, 23, 9], [15, 23, 10], [15, 23, 12], [15, 23, 16], [15, 23, 17], [15, 23, 27], [15, 23, 36], [15, 24, 5], [15, 24, 6], [15, 24, 14], [15, 24, 18], [15, 24, 25], [15, 24, 29], [15, 24, 32], [15, 24, 34], [15, 25, 6], [15, 25, 8], [15, 25, 18], [15, 25, 24], [15, 25, 29], [15, 25, 32], [15, 25, 37], [15, 25, 38], [15, 26, 2], [15, 26, 10], [15, 26, 21], [15, 26, 22], [15, 26, 27], [15, 26, 28], [15, 26, 30], [15, 26, 40], [15, 27, 7], [15, 27, 10], [15, 27, 17], [15, 27, 21], [15, 27, 23], [15, 27, 26], [15, 27, 28], [15, 27, 36], [15, 28, 7], [15, 28, 10], [15, 28, 21], [15, 28, 26], [15, 28, 27], [15, 28, 30], [15, 28, 36], [15, 28, 40], [15, 29, 6], [15, 29, 8], [15, 29, 18], [15, 29, 24], [15, 29, 25], [15, 29, 32], [15, 29, 34], [15, 29, 38], [15, 30, 2], [15, 30, 21], [15, 30, 22], [15, 30, 26], [15, 30, 28], [15, 30, 37], [15, 30, 38], [15, 30, 40], [15, 31, 1], [15, 31, 5], [15, 31, 13], [15, 31, 14], [15, 31, 15], [15, 31, 18], [15, 31, 20], [15, 31, 34], [15, 32, 5], [15, 32, 6], [15, 32, 8], [15, 32, 18], [15, 32, 24], [15, 32, 25], [15, 32, 29], [15, 32, 34], [15, 33, 3], [15, 33, 4], [15, 33, 9], [15, 33, 12], [15, 33, 16], [15, 33, 19], [15, 33, 35], [15, 33, 39], [15, 34, 5], [15, 34, 13], [15, 34, 14], [15, 34, 18], [15, 34, 24], [15, 34, 29], [15, 34, 31], [15, 34, 32], [15, 35, 3], [15, 35, 4], [15, 35, 9], [15, 35, 12], [15, 35, 16], [15, 35, 17], [15, 35, 19], [15, 35, 33], [15, 36, 7], [15, 36, 9], [15, 36, 10], [15, 36, 17], [15, 36, 21], [15, 36, 23], [15, 36, 27], [15, 36, 28], [15, 37, 2], [15, 37, 6], [15, 37, 8], [15, 37, 22], [15, 37, 25], [15, 37, 30], [15, 37, 38], [15, 37, 40], [15, 38, 2], [15, 38, 6], [15, 38, 8], [15, 38, 22], [15, 38, 25], [15, 38, 29], [15, 38, 30], [15, 38, 37], [15, 39, 1], [15, 39, 3], [15, 39, 4], [15, 39, 11], [15, 39, 15], [15, 39, 19], [15, 39, 20], [15, 39, 33], [15, 40, 2], [15, 40, 10], [15, 40, 21], [15, 40, 22], [15, 40, 26], [15, 40, 28], [15, 40, 30], [15, 40, 37], [16, 0, 16], [16, 1, 10], [16, 1, 16], [16, 1, 18], [16, 1, 37], [16, 10, 1], [16, 10, 16], [16, 10, 18], [16, 10, 37], [16, 16, 0], [16, 16, 1], [16, 16, 10], [16, 16, 16], [16, 16, 18], [16, 16, 37], [16, 18, 1], [16, 18, 10], [16, 18, 16], [16, 18, 37], [16, 37, 1], [16, 37, 10], [16, 37, 16], [16, 37, 18], [17, 0, 17], [17, 1, 2], [17, 1, 4], [17, 1, 17], [17, 1, 21], [17, 1, 29], [17, 1, 31], [17, 1, 34], [17, 1, 35], [17, 2, 1], [17, 2, 4], [17, 2, 8], [17, 2, 17], [17, 2, 21], [17, 2, 27], [17, 2, 29], [17, 2, 34], [17, 3, 5], [17, 3, 6], [17, 3, 10], [17, 3, 11], [17, 3, 12], [17, 3, 20], [17, 3, 22], [17, 3, 23], [17, 4, 1], [17, 4, 2], [17, 4, 8], [17, 4, 13], [17, 4, 16], [17, 4, 17], [17, 4, 27], [17, 4, 34], [17, 5, 3], [17, 5, 6], [17, 5, 10], [17, 5, 11], [17, 5, 20], [17, 5, 22], [17, 5, 23], [17, 5, 32], [17, 6, 3], [17, 6, 5], [17, 6, 10], [17, 6, 12], [17, 6, 20], [17, 6, 22], [17, 6, 24], [17, 6, 40], [17, 7, 12], [17, 7, 14], [17, 7, 24], [17, 7, 28], [17, 7, 33], [17, 7, 37], [17, 7, 39], [17, 7, 40], [17, 8, 2], [17, 8, 4], [17, 8, 13], [17, 8, 16], [17, 8, 26], [17, 8, 27], [17, 8, 32], [17, 8, 34], [17, 9, 15], [17, 9, 18], [17, 9, 19], [17, 9, 25], [17, 9, 28], [17, 9, 30], [17, 9, 33], [17, 9, 36], [17, 10, 3], [17, 10, 5], [17, 10, 6], [17, 10, 12], [17, 10, 20], [17, 10, 22], [17, 10, 23], [17, 10, 40], [17, 11, 3], [17, 11, 5], [17, 11, 13], [17, 11, 16], [17, 11, 22], [17, 11, 23], [17, 11, 26], [17, 11, 32], [17, 12, 3], [17, 12, 6], [17, 12, 7], [17, 12, 10], [17, 12, 20], [17, 12, 24], [17, 12, 39], [17, 12, 40], [17, 13, 4], [17, 13, 8], [17, 13, 11], [17, 13, 16], [17, 13, 26], [17, 13, 27], [17, 13, 32], [17, 13, 34], [17, 14, 7], [17, 14, 15], [17, 14, 24], [17, 14, 25], [17, 14, 28], [17, 14, 33], [17, 14, 37], [17, 14, 39], [17, 15, 9], [17, 15, 14], [17, 15, 18], [17, 15, 19], [17, 15, 25], [17, 15, 28], [17, 15, 30], [17, 15, 33], [17, 16, 4], [17, 16, 8], [17, 16, 11], [17, 16, 13], [17, 16, 23], [17, 16, 26], [17, 16, 27], [17, 16, 32], [17, 17, 0], [17, 17, 1], [17, 17, 2], [17, 17, 4], [17, 17, 17], [17, 17, 21], [17, 17, 27], [17, 17, 29], [17, 17, 34], [17, 17, 35], [17, 18, 9], [17, 18, 15], [17, 18, 19], [17, 18, 25], [17, 18, 30], [17, 18, 31], [17, 18, 36], [17, 18, 38], [17, 19, 9], [17, 19, 15], [17, 19, 18], [17, 19, 30], [17, 19, 31], [17, 19, 35], [17, 19, 36], [17, 19, 38], [17, 20, 3], [17, 20, 5], [17, 20, 6], [17, 20, 10], [17, 20, 12], [17, 20, 24], [17, 20, 39], [17, 20, 40], [17, 21, 1], [17, 21, 2], [17, 21, 17], [17, 21, 29], [17, 21, 31], [17, 21, 35], [17, 21, 36], [17, 21, 38], [17, 22, 3], [17, 22, 5], [17, 22, 6], [17, 22, 10], [17, 22, 11], [17, 22, 23], [17, 22, 26], [17, 22, 32], [17, 23, 3], [17, 23, 5], [17, 23, 10], [17, 23, 11], [17, 23, 16], [17, 23, 22], [17, 23, 26], [17, 23, 32], [17, 24, 6], [17, 24, 7], [17, 24, 12], [17, 24, 14], [17, 24, 20], [17, 24, 37], [17, 24, 39], [17, 24, 40], [17, 25, 9], [17, 25, 14], [17, 25, 15], [17, 25, 18], [17, 25, 28], [17, 25, 30], [17, 25, 33], [17, 25, 37], [17, 26, 8], [17, 26, 11], [17, 26, 13], [17, 26, 16], [17, 26, 22], [17, 26, 23], [17, 26, 27], [17, 26, 32], [17, 27, 2], [17, 27, 4], [17, 27, 8], [17, 27, 13], [17, 27, 16], [17, 27, 17], [17, 27, 26], [17, 27, 34], [17, 28, 7], [17, 28, 9], [17, 28, 14], [17, 28, 15], [17, 28, 25], [17, 28, 30], [17, 28, 33], [17, 28, 37], [17, 29, 1], [17, 29, 2], [17, 29, 17], [17, 29, 21], [17, 29, 31], [17, 29, 34], [17, 29, 35], [17, 29, 38], [17, 30, 9], [17, 30, 15], [17, 30, 18], [17, 30, 19], [17, 30, 25], [17, 30, 28], [17, 30, 36], [17, 30, 38], [17, 31, 1], [17, 31, 18], [17, 31, 19], [17, 31, 21], [17, 31, 29], [17, 31, 35], [17, 31, 36], [17, 31, 38], [17, 32, 5], [17, 32, 8], [17, 32, 11], [17, 32, 13], [17, 32, 16], [17, 32, 22], [17, 32, 23], [17, 32, 26], [17, 33, 7], [17, 33, 9], [17, 33, 14], [17, 33, 15], [17, 33, 25], [17, 33, 28], [17, 33, 37], [17, 33, 39], [17, 34, 1], [17, 34, 2], [17, 34, 4], [17, 34, 8], [17, 34, 13], [17, 34, 17], [17, 34, 27], [17, 34, 29], [17, 35, 1], [17, 35, 17], [17, 35, 19], [17, 35, 21], [17, 35, 29], [17, 35, 31], [17, 35, 36], [17, 35, 38], [17, 36, 9], [17, 36, 18], [17, 36, 19], [17, 36, 21], [17, 36, 30], [17, 36, 31], [17, 36, 35], [17, 36, 38], [17, 37, 7], [17, 37, 14], [17, 37, 24], [17, 37, 25], [17, 37, 28], [17, 37, 33], [17, 37, 39], [17, 37, 40], [17, 38, 18], [17, 38, 19], [17, 38, 21], [17, 38, 29], [17, 38, 30], [17, 38, 31], [17, 38, 35], [17, 38, 36], [17, 39, 7], [17, 39, 12], [17, 39, 14], [17, 39, 20], [17, 39, 24], [17, 39, 33], [17, 39, 37], [17, 39, 40], [17, 40, 6], [17, 40, 7], [17, 40, 10], [17, 40, 12], [17, 40, 20], [17, 40, 24], [17, 40, 37], [17, 40, 39], [18, 0, 18], [18, 1, 10], [18, 1, 16], [18, 1, 18], [18, 1, 37], [18, 10, 1], [18, 10, 16], [18, 10, 18], [18, 10, 37], [18, 16, 1], [18, 16, 10], [18, 16, 18], [18, 16, 37], [18, 18, 0], [18, 18, 1], [18, 18, 10], [18, 18, 16], [18, 18, 18], [18, 18, 37], [18, 37, 1], [18, 37, 10], [18, 37, 16], [18, 37, 18], [19, 0, 19], [19, 1, 5], [19, 1, 12], [19, 1, 13], [19, 1, 19], [19, 1, 23], [19, 1, 24], [19, 1, 25], [19, 1, 33], [19, 2, 5], [19, 2, 7], [19, 2, 9], [19, 2, 10], [19, 2, 24], [19, 2, 25], [19, 2, 26], [19, 2, 38], [19, 3, 15], [19, 3, 16], [19, 3, 17], [19, 3, 28], [19, 3, 31], [19, 3, 34], [19, 3, 36], [19, 3, 39], [19, 4, 7], [19, 4, 9], [19, 4, 10], [19, 4, 11], [19, 4, 14], [19, 4, 18], [19, 4, 20], [19, 4, 35], [19, 5, 1], [19, 5, 2], [19, 5, 13], [19, 5, 19], [19, 5, 24], [19, 5, 25], [19, 5, 33], [19, 5, 38], [19, 6, 15], [19, 6, 21], [19, 6, 27], [19, 6, 30], [19, 6, 31], [19, 6, 32], [19, 6, 34], [19, 6, 37], [19, 7, 2], [19, 7, 4], [19, 7, 9], [19, 7, 10], [19, 7, 11], [19, 7, 26], [19, 7, 35], [19, 7, 38], [19, 8, 14], [19, 8, 18], [19, 8, 20], [19, 8, 22], [19, 8, 28], [19, 8, 29], [19, 8, 36], [19, 8, 40], [19, 9, 2], [19, 9, 4], [19, 9, 7], [19, 9, 10], [19, 9, 11], [19, 9, 20], [19, 9, 26], [19, 9, 35], [19, 10, 2], [19, 10, 4], [19, 10, 7], [19, 10, 9], [19, 10, 25], [19, 10, 26], [19, 10, 35], [19, 10, 38], [19, 11, 4], [19, 11, 7], [19, 11, 9], [19, 11, 14], [19, 11, 18], [19, 11, 20], [19, 11, 29], [19, 11, 35], [19, 12, 1], [19, 12, 13], [19, 12, 19], [19, 12, 21], [19, 12, 23], [19, 12, 27], [19, 12, 30], [19, 12, 33], [19, 13, 1], [19, 13, 5], [19, 13, 12], [19, 13, 19], [19, 13, 24], [19, 13, 25], [19, 13, 33], [19, 13, 38], [19, 14, 4], [19, 14, 8], [19, 14, 11], [19, 14, 18], [19, 14, 20], [19, 14, 22], [19, 14, 29], [19, 14, 35], [19, 15, 3], [19, 15, 6], [19, 15, 16], [19, 15, 17], [19, 15, 31], [19, 15, 32], [19, 15, 34], [19, 15, 39], [19, 16, 3], [19, 16, 15], [19, 16, 17], [19, 16, 28], [19, 16, 31], [19, 16, 36], [19, 16, 39], [19, 16, 40], [19, 17, 3], [19, 17, 15], [19, 17, 16], [19, 17, 22], [19, 17, 28], [19, 17, 36], [19, 17, 39], [19, 17, 40], [19, 18, 4], [19, 18, 8], [19, 18, 11], [19, 18, 14], [19, 18, 20], [19, 18, 22], [19, 18, 29], [19, 18, 40], [19, 19, 0], [19, 19, 1], [19, 19, 5], [19, 19, 12], [19, 19, 13], [19, 19, 19], [19, 19, 23], [19, 19, 24], [19, 19, 27], [19, 19, 33], [19, 20, 4], [19, 20, 8], [19, 20, 9], [19, 20, 11], [19, 20, 14], [19, 20, 18], [19, 20, 29], [19, 20, 35], [19, 21, 6], [19, 21, 12], [19, 21, 23], [19, 21, 27], [19, 21, 30], [19, 21, 32], [19, 21, 33], [19, 21, 37], [19, 22, 8], [19, 22, 14], [19, 22, 17], [19, 22, 18], [19, 22, 28], [19, 22, 29], [19, 22, 36], [19, 22, 40], [19, 23, 1], [19, 23, 12], [19, 23, 19], [19, 23, 21], [19, 23, 27], [19, 23, 30], [19, 23, 33], [19, 23, 37], [19, 24, 1], [19, 24, 2], [19, 24, 5], [19, 24, 13], [19, 24, 19], [19, 24, 25], [19, 24, 26], [19, 24, 38], [19, 25, 1], [19, 25, 2], [19, 25, 5], [19, 25, 10], [19, 25, 13], [19, 25, 24], [19, 25, 26], [19, 25, 38], [19, 26, 2], [19, 26, 7], [19, 26, 9], [19, 26, 10], [19, 26, 24], [19, 26, 25], [19, 26, 35], [19, 26, 38], [19, 27, 6], [19, 27, 12], [19, 27, 19], [19, 27, 21], [19, 27, 23], [19, 27, 30], [19, 27, 33], [19, 27, 37], [19, 28, 3], [19, 28, 8], [19, 28, 16], [19, 28, 17], [19, 28, 22], [19, 28, 29], [19, 28, 36], [19, 28, 40], [19, 29, 8], [19, 29, 11], [19, 29, 14], [19, 29, 18], [19, 29, 20], [19, 29, 22], [19, 29, 28], [19, 29, 40], [19, 30, 6], [19, 30, 12], [19, 30, 21], [19, 30, 23], [19, 30, 27], [19, 30, 32], [19, 30, 34], [19, 30, 37], [19, 31, 3], [19, 31, 6], [19, 31, 15], [19, 31, 16], [19, 31, 32], [19, 31, 34], [19, 31, 37], [19, 31, 39], [19, 32, 6], [19, 32, 15], [19, 32, 21], [19, 32, 30], [19, 32, 31], [19, 32, 34], [19, 32, 37], [19, 32, 39], [19, 33, 1], [19, 33, 5], [19, 33, 12], [19, 33, 13], [19, 33, 19], [19, 33, 21], [19, 33, 23], [19, 33, 27], [19, 34, 3], [19, 34, 6], [19, 34, 15], [19, 34, 30], [19, 34, 31], [19, 34, 32], [19, 34, 37], [19, 34, 39], [19, 35, 4], [19, 35, 7], [19, 35, 9], [19, 35, 10], [19, 35, 11], [19, 35, 14], [19, 35, 20], [19, 35, 26], [19, 36, 3], [19, 36, 8], [19, 36, 16], [19, 36, 17], [19, 36, 22], [19, 36, 28], [19, 36, 39], [19, 36, 40], [19, 37, 6], [19, 37, 21], [19, 37, 23], [19, 37, 27], [19, 37, 30], [19, 37, 31], [19, 37, 32], [19, 37, 34], [19, 38, 2], [19, 38, 5], [19, 38, 7], [19, 38, 10], [19, 38, 13], [19, 38, 24], [19, 38, 25], [19, 38, 26], [19, 39, 3], [19, 39, 15], [19, 39, 16], [19, 39, 17], [19, 39, 31], [19, 39, 32], [19, 39, 34], [19, 39, 36], [19, 40, 8], [19, 40, 16], [19, 40, 17], [19, 40, 18], [19, 40, 22], [19, 40, 28], [19, 40, 29], [19, 40, 36], [20, 0, 20], [20, 1, 4], [20, 1, 5], [20, 1, 16], [20, 1, 18], [20, 1, 20], [20, 1, 31], [20, 1, 33], [20, 1, 39], [20, 2, 8], [20, 2, 10], [20, 2, 21], [20, 2, 25], [20, 2, 32], [20, 2, 36], [20, 2, 37], [20, 2, 40], [20, 4, 1], [20, 4, 9], [20, 4, 16], [20, 4, 20], [20, 4, 23], [20, 4, 31], [20, 4, 33], [20, 4, 39], [20, 5, 1], [20, 5, 8], [20, 5, 18], [20, 5, 20], [20, 5, 25], [20, 5, 31], [20, 5, 32], [20, 5, 39], [20, 8, 2], [20, 8, 5], [20, 8, 18], [20, 8, 21], [20, 8, 25], [20, 8, 32], [20, 8, 37], [20, 8, 40], [20, 9, 4], [20, 9, 10], [20, 9, 16], [20, 9, 21], [20, 9, 23], [20, 9, 33], [20, 9, 36], [20, 9, 39], [20, 10, 2], [20, 10, 9], [20, 10, 16], [20, 10, 21], [20, 10, 23], [20, 10, 36], [20, 10, 37], [20, 10, 40], [20, 16, 1], [20, 16, 4], [20, 16, 9], [20, 16, 10], [20, 16, 23], [20, 16, 33], [20, 16, 36], [20, 16, 39], [20, 18, 1], [20, 18, 5], [20, 18, 8], [20, 18, 20], [20, 18, 25], [20, 18, 31], [20, 18, 32], [20, 18, 37], [20, 20, 0], [20, 20, 1], [20, 20, 4], [20, 20, 5], [20, 20, 18], [20, 20, 20], [20, 20, 31], [20, 20, 32], [20, 20, 33], [20, 20, 39], [20, 21, 2], [20, 21, 8], [20, 21, 9], [20, 21, 10], [20, 21, 23], [20, 21, 36], [20, 21, 37], [20, 21, 40], [20, 23, 4], [20, 23, 9], [20, 23, 10], [20, 23, 16], [20, 23, 21], [20, 23, 33], [20, 23, 36], [20, 23, 40], [20, 25, 2], [20, 25, 5], [20, 25, 8], [20, 25, 18], [20, 25, 31], [20, 25, 32], [20, 25, 37], [20, 25, 40], [20, 31, 1], [20, 31, 4], [20, 31, 5], [20, 31, 18], [20, 31, 20], [20, 31, 25], [20, 31, 32], [20, 31, 39], [20, 32, 2], [20, 32, 5], [20, 32, 8], [20, 32, 18], [20, 32, 20], [20, 32, 25], [20, 32, 31], [20, 32, 37], [20, 33, 1], [20, 33, 4], [20, 33, 9], [20, 33, 16], [20, 33, 20], [20, 33, 23], [20, 33, 36], [20, 33, 39], [20, 36, 2], [20, 36, 9], [20, 36, 10], [20, 36, 16], [20, 36, 21], [20, 36, 23], [20, 36, 33], [20, 36, 40], [20, 37, 2], [20, 37, 8], [20, 37, 10], [20, 37, 18], [20, 37, 21], [20, 37, 25], [20, 37, 32], [20, 37, 40], [20, 39, 1], [20, 39, 4], [20, 39, 5], [20, 39, 9], [20, 39, 16], [20, 39, 20], [20, 39, 31], [20, 39, 33], [20, 40, 2], [20, 40, 8], [20, 40, 10], [20, 40, 21], [20, 40, 23], [20, 40, 25], [20, 40, 36], [20, 40, 37], [21, 0, 21], [21, 1, 2], [21, 1, 4], [21, 1, 8], [21, 1, 16], [21, 1, 18], [21, 1, 21], [21, 1, 31], [21, 1, 36], [21, 2, 1], [21, 2, 4], [21, 2, 8], [21, 2, 16], [21, 2, 21], [21, 2, 31], [21, 2, 32], [21, 2, 36], [21, 4, 1], [21, 4, 2], [21, 4, 8], [21, 4, 16], [21, 4, 21], [21, 4, 23], [21, 4, 31], [21, 4, 32], [21, 5, 8], [21, 5, 10], [21, 5, 16], [21, 5, 20], [21, 5, 23], [21, 5, 32], [21, 5, 39], [21, 5, 40], [21, 8, 1], [21, 8, 2], [21, 8, 4], [21, 8, 5], [21, 8, 16], [21, 8, 21], [21, 8, 23], [21, 8, 32], [21, 9, 18], [21, 9, 21], [21, 9, 25], [21, 9, 31], [21, 9, 33], [21, 9, 36], [21, 9, 37], [21, 9, 39], [21, 10, 5], [21, 10, 16], [21, 10, 20], [21, 10, 23], [21, 10, 32], [21, 10, 37], [21, 10, 39], [21, 10, 40], [21, 16, 1], [21, 16, 2], [21, 16, 4], [21, 16, 5], [21, 16, 8], [21, 16, 10], [21, 16, 23], [21, 16, 32], [21, 18, 1], [21, 18, 9], [21, 18, 21], [21, 18, 25], [21, 18, 31], [21, 18, 33], [21, 18, 36], [21, 18, 37], [21, 20, 5], [21, 20, 10], [21, 20, 23], [21, 20, 32], [21, 20, 33], [21, 20, 37], [21, 20, 39], [21, 20, 40], [21, 21, 0], [21, 21, 1], [21, 21, 2], [21, 21, 4], [21, 21, 8], [21, 21, 9], [21, 21, 18], [21, 21, 21], [21, 21, 31], [21, 21, 36], [21, 23, 4], [21, 23, 5], [21, 23, 8], [21, 23, 10], [21, 23, 16], [21, 23, 20], [21, 23, 32], [21, 23, 40], [21, 25, 9], [21, 25, 18], [21, 25, 31], [21, 25, 33], [21, 25, 36], [21, 25, 37], [21, 25, 39], [21, 25, 40], [21, 31, 1], [21, 31, 2], [21, 31, 4], [21, 31, 9], [21, 31, 18], [21, 31, 21], [21, 31, 25], [21, 31, 36], [21, 32, 2], [21, 32, 4], [21, 32, 5], [21, 32, 8], [21, 32, 10], [21, 32, 16], [21, 32, 20], [21, 32, 23], [21, 33, 9], [21, 33, 18], [21, 33, 20], [21, 33, 25], [21, 33, 36], [21, 33, 37], [21, 33, 39], [21, 33, 40], [21, 36, 1], [21, 36, 2], [21, 36, 9], [21, 36, 18], [21, 36, 21], [21, 36, 25], [21, 36, 31], [21, 36, 33], [21, 37, 9], [21, 37, 10], [21, 37, 18], [21, 37, 20], [21, 37, 25], [21, 37, 33], [21, 37, 39], [21, 37, 40], [21, 39, 5], [21, 39, 9], [21, 39, 10], [21, 39, 20], [21, 39, 25], [21, 39, 33], [21, 39, 37], [21, 39, 40], [21, 40, 5], [21, 40, 10], [21, 40, 20], [21, 40, 23], [21, 40, 25], [21, 40, 33], [21, 40, 37], [21, 40, 39], [22, 0, 22], [22, 1, 5], [22, 1, 17], [22, 1, 22], [22, 1, 23], [22, 1, 25], [22, 1, 28], [22, 1, 29], [22, 1, 33], [22, 2, 3], [22, 2, 5], [22, 2, 9], [22, 2, 10], [22, 2, 15], [22, 2, 17], [22, 2, 25], [22, 2, 34], [22, 3, 2], [22, 3, 5], [22, 3, 10], [22, 3, 15], [22, 3, 17], [22, 3, 25], [22, 3, 28], [22, 3, 34], [22, 4, 6], [22, 4, 9], [22, 4, 10], [22, 4, 18], [22, 4, 20], [22, 4, 27], [22, 4, 30], [22, 4, 34], [22, 5, 1], [22, 5, 2], [22, 5, 3], [22, 5, 17], [22, 5, 22], [22, 5, 25], [22, 5, 28], [22, 5, 33], [22, 6, 4], [22, 6, 9], [22, 6, 10], [22, 6, 15], [22, 6, 20], [22, 6, 27], [22, 6, 30], [22, 6, 34], [22, 7, 11], [22, 7, 26], [22, 7, 31], [22, 7, 32], [22, 7, 35], [22, 7, 37], [22, 7, 38], [22, 7, 39], [22, 8, 12], [22, 8, 13], [22, 8, 18], [22, 8, 19], [22, 8, 20], [22, 8, 27], [22, 8, 36], [22, 8, 40], [22, 9, 2], [22, 9, 4], [22, 9, 6], [22, 9, 10], [22, 9, 15], [22, 9, 20], [22, 9, 30], [22, 9, 34], [22, 10, 2], [22, 10, 3], [22, 10, 4], [22, 10, 6], [22, 10, 9], [22, 10, 15], [22, 10, 25], [22, 10, 34], [22, 11, 7], [22, 11, 14], [22, 11, 21], [22, 11, 23], [22, 11, 29], [22, 11, 32], [22, 11, 35], [22, 11, 37], [22, 12, 8], [22, 12, 13], [22, 12, 18], [22, 12, 19], [22, 12, 20], [22, 12, 27], [22, 12, 30], [22, 12, 40], [22, 13, 8], [22, 13, 12], [22, 13, 16], [22, 13, 19], [22, 13, 24], [22, 13, 36], [22, 13, 38], [22, 13, 40], [22, 14, 11], [22, 14, 21], [22, 14, 22], [22, 14, 23], [22, 14, 29], [22, 14, 33], [22, 14, 35], [22, 14, 37], [22, 15, 2], [22, 15, 3], [22, 15, 6], [22, 15, 9], [22, 15, 10], [22, 15, 17], [22, 15, 25], [22, 15, 34], [22, 16, 13], [22, 16, 24], [22, 16, 26], [22, 16, 31], [22, 16, 36], [22, 16, 38], [22, 16, 39], [22, 16, 40], [22, 17, 1], [22, 17, 2], [22, 17, 3], [22, 17, 5], [22, 17, 15], [22, 17, 22], [22, 17, 25], [22, 17, 28], [22, 18, 4], [22, 18, 8], [22, 18, 12], [22, 18, 19], [22, 18, 20], [22, 18, 27], [22, 18, 30], [22, 18, 40], [22, 19, 8], [22, 19, 12], [22, 19, 13], [22, 19, 18], [22, 19, 24], [22, 19, 27], [22, 19, 36], [22, 19, 40], [22, 20, 4], [22, 20, 6], [22, 20, 8], [22, 20, 9], [22, 20, 12], [22, 20, 18], [22, 20, 27], [22, 20, 30], [22, 21, 11], [22, 21, 14], [22, 21, 23], [22, 21, 29], [22, 21, 32], [22, 21, 33], [22, 21, 35], [22, 21, 37], [22, 22, 0], [22, 22, 1], [22, 22, 5], [22, 22, 14], [22, 22, 17], [22, 22, 22], [22, 22, 23], [22, 22, 28], [22, 22, 29], [22, 22, 33], [22, 23, 1], [22, 23, 11], [22, 23, 14], [22, 23, 21], [22, 23, 22], [22, 23, 29], [22, 23, 33], [22, 23, 37], [22, 24, 13], [22, 24, 16], [22, 24, 19], [22, 24, 26], [22, 24, 36], [22, 24, 38], [22, 24, 39], [22, 24, 40], [22, 25, 1], [22, 25, 2], [22, 25, 3], [22, 25, 5], [22, 25, 10], [22, 25, 15], [22, 25, 17], [22, 25, 28], [22, 26, 7], [22, 26, 16], [22, 26, 24], [22, 26, 31], [22, 26, 32], [22, 26, 35], [22, 26, 38], [22, 26, 39], [22, 27, 4], [22, 27, 6], [22, 27, 8], [22, 27, 12], [22, 27, 18], [22, 27, 19], [22, 27, 20], [22, 27, 30], [22, 28, 1], [22, 28, 3], [22, 28, 5], [22, 28, 17], [22, 28, 22], [22, 28, 25], [22, 28, 29], [22, 28, 33], [22, 29, 1], [22, 29, 11], [22, 29, 14], [22, 29, 21], [22, 29, 22], [22, 29, 23], [22, 29, 28], [22, 29, 33], [22, 30, 4], [22, 30, 6], [22, 30, 9], [22, 30, 12], [22, 30, 18], [22, 30, 20], [22, 30, 27], [22, 30, 34], [22, 31, 7], [22, 31, 16], [22, 31, 26], [22, 31, 32], [22, 31, 35], [22, 31, 37], [22, 31, 38], [22, 31, 39], [22, 32, 7], [22, 32, 11], [22, 32, 21], [22, 32, 26], [22, 32, 31], [22, 32, 35], [22, 32, 37], [22, 32, 39], [22, 33, 1], [22, 33, 5], [22, 33, 14], [22, 33, 21], [22, 33, 22], [22, 33, 23], [22, 33, 28], [22, 33, 29], [22, 34, 2], [22, 34, 3], [22, 34, 4], [22, 34, 6], [22, 34, 9], [22, 34, 10], [22, 34, 15], [22, 34, 30], [22, 35, 7], [22, 35, 11], [22, 35, 14], [22, 35, 21], [22, 35, 26], [22, 35, 31], [22, 35, 32], [22, 35, 37], [22, 36, 8], [22, 36, 13], [22, 36, 16], [22, 36, 19], [22, 36, 24], [22, 36, 38], [22, 36, 39], [22, 36, 40], [22, 37, 7], [22, 37, 11], [22, 37, 14], [22, 37, 21], [22, 37, 23], [22, 37, 31], [22, 37, 32], [22, 37, 35], [22, 38, 7], [22, 38, 13], [22, 38, 16], [22, 38, 24], [22, 38, 26], [22, 38, 31], [22, 38, 36], [22, 38, 39], [22, 39, 7], [22, 39, 16], [22, 39, 24], [22, 39, 26], [22, 39, 31], [22, 39, 32], [22, 39, 36], [22, 39, 38], [22, 40, 8], [22, 40, 12], [22, 40, 13], [22, 40, 16], [22, 40, 18], [22, 40, 19], [22, 40, 24], [22, 40, 36], [23, 0, 23], [23, 1, 4], [23, 1, 10], [23, 1, 16], [23, 1, 18], [23, 1, 23], [23, 1, 25], [23, 1, 31], [23, 1, 37], [23, 4, 1], [23, 4, 10], [23, 4, 16], [23, 4, 18], [23, 4, 23], [23, 4, 25], [23, 4, 31], [23, 4, 40], [23, 10, 1], [23, 10, 4], [23, 10, 16], [23, 10, 18], [23, 10, 23], [23, 10, 25], [23, 10, 37], [23, 10, 40], [23, 16, 1], [23, 16, 4], [23, 16, 10], [23, 16, 18], [23, 16, 23], [23, 16, 31], [23, 16, 37], [23, 16, 40], [23, 18, 1], [23, 18, 4], [23, 18, 10], [23, 18, 16], [23, 18, 25], [23, 18, 31], [23, 18, 37], [23, 18, 40], [23, 23, 0], [23, 23, 1], [23, 23, 4], [23, 23, 10], [23, 23, 16], [23, 23, 23], [23, 23, 25], [23, 23, 31], [23, 23, 37], [23, 23, 40], [23, 25, 1], [23, 25, 4], [23, 25, 10], [23, 25, 18], [23, 25, 23], [23, 25, 31], [23, 25, 37], [23, 25, 40], [23, 31, 1], [23, 31, 4], [23, 31, 16], [23, 31, 18], [23, 31, 23], [23, 31, 25], [23, 31, 37], [23, 31, 40], [23, 37, 1], [23, 37, 10], [23, 37, 16], [23, 37, 18], [23, 37, 23], [23, 37, 25], [23, 37, 31], [23, 37, 40], [23, 40, 4], [23, 40, 10], [23, 40, 16], [23, 40, 18], [23, 40, 23], [23, 40, 25], [23, 40, 31], [23, 40, 37], [24, 0, 24], [24, 1, 2], [24, 1, 4], [24, 1, 6], [24, 1, 7], [24, 1, 12], [24, 1, 21], [24, 1, 24], [24, 1, 31], [24, 2, 1], [24, 2, 4], [24, 2, 7], [24, 2, 8], [24, 2, 12], [24, 2, 14], [24, 2, 21], [24, 2, 24], [24, 3, 6], [24, 3, 11], [24, 3, 12], [24, 3, 18], [24, 3, 21], [24, 3, 22], [24, 3, 31], [24, 3, 36], [24, 4, 1], [24, 4, 2], [24, 4, 7], [24, 4, 8], [24, 4, 14], [24, 4, 16], [24, 4, 24], [24, 4, 28], [24, 5, 10], [24, 5, 19], [24, 5, 20], [24, 5, 23], [24, 5, 30], [24, 5, 32], [24, 5, 35], [24, 5, 38], [24, 6, 1], [24, 6, 3], [24, 6, 12], [24, 6, 21], [24, 6, 22], [24, 6, 24], [24, 6, 31], [24, 6, 36], [24, 7, 1], [24, 7, 2], [24, 7, 4], [24, 7, 8], [24, 7, 12], [24, 7, 14], [24, 7, 24], [24, 7, 28], [24, 8, 2], [24, 8, 4], [24, 8, 7], [24, 8, 14], [24, 8, 15], [24, 8, 16], [24, 8, 28], [24, 8, 32], [24, 9, 11], [24, 9, 13], [24, 9, 18], [24, 9, 22], [24, 9, 25], [24, 9, 26], [24, 9, 33], [24, 9, 36], [24, 10, 5], [24, 10, 19], [24, 10, 20], [24, 10, 23], [24, 10, 29], [24, 10, 35], [24, 10, 38], [24, 10, 40], [24, 11, 3], [24, 11, 9], [24, 11, 13], [24, 11, 18], [24, 11, 22], [24, 11, 25], [24, 11, 26], [24, 11, 36], [24, 12, 1], [24, 12, 2], [24, 12, 3], [24, 12, 6], [24, 12, 7], [24, 12, 21], [24, 12, 24], [24, 12, 31], [24, 13, 9], [24, 13, 11], [24, 13, 25], [24, 13, 26], [24, 13, 27], [24, 13, 33], [24, 13, 34], [24, 13, 37], [24, 14, 2], [24, 14, 4], [24, 14, 7], [24, 14, 8], [24, 14, 15], [24, 14, 16], [24, 14, 24], [24, 14, 28], [24, 15, 8], [24, 15, 14], [24, 15, 16], [24, 15, 19], [24, 15, 23], [24, 15, 28], [24, 15, 30], [24, 15, 32], [24, 16, 4], [24, 16, 8], [24, 16, 14], [24, 16, 15], [24, 16, 23], [24, 16, 28], [24, 16, 30], [24, 16, 32], [24, 17, 20], [24, 17, 27], [24, 17, 29], [24, 17, 34], [24, 17, 35], [24, 17, 37], [24, 17, 39], [24, 17, 40], [24, 18, 3], [24, 18, 9], [24, 18, 11], [24, 18, 22], [24, 18, 25], [24, 18, 26], [24, 18, 31], [24, 18, 36], [24, 19, 5], [24, 19, 10], [24, 19, 15], [24, 19, 23], [24, 19, 30], [24, 19, 32], [24, 19, 35], [24, 19, 38], [24, 20, 5], [24, 20, 10], [24, 20, 17], [24, 20, 29], [24, 20, 35], [24, 20, 38], [24, 20, 39], [24, 20, 40], [24, 21, 1], [24, 21, 2], [24, 21, 3], [24, 21, 6], [24, 21, 12], [24, 21, 24], [24, 21, 31], [24, 21, 36], [24, 22, 3], [24, 22, 6], [24, 22, 9], [24, 22, 11], [24, 22, 18], [24, 22, 26], [24, 22, 31], [24, 22, 36], [24, 23, 5], [24, 23, 10], [24, 23, 15], [24, 23, 16], [24, 23, 19], [24, 23, 30], [24, 23, 32], [24, 23, 38], [24, 24, 0], [24, 24, 1], [24, 24, 2], [24, 24, 4], [24, 24, 6], [24, 24, 7], [24, 24, 12], [24, 24, 14], [24, 24, 21], [24, 24, 24], [24, 25, 9], [24, 25, 11], [24, 25, 13], [24, 25, 18], [24, 25, 26], [24, 25, 27], [24, 25, 33], [24, 25, 37], [24, 26, 9], [24, 26, 11], [24, 26, 13], [24, 26, 18], [24, 26, 22], [24, 26, 25], [24, 26, 27], [24, 26, 33], [24, 27, 13], [24, 27, 17], [24, 27, 25], [24, 27, 26], [24, 27, 33], [24, 27, 34], [24, 27, 37], [24, 27, 39], [24, 28, 4], [24, 28, 7], [24, 28, 8], [24, 28, 14], [24, 28, 15], [24, 28, 16], [24, 28, 30], [24, 28, 32], [24, 29, 10], [24, 29, 17], [24, 29, 20], [24, 29, 34], [24, 29, 35], [24, 29, 38], [24, 29, 39], [24, 29, 40], [24, 30, 5], [24, 30, 15], [24, 30, 16], [24, 30, 19], [24, 30, 23], [24, 30, 28], [24, 30, 32], [24, 30, 38], [24, 31, 1], [24, 31, 3], [24, 31, 6], [24, 31, 12], [24, 31, 18], [24, 31, 21], [24, 31, 22], [24, 31, 36], [24, 32, 5], [24, 32, 8], [24, 32, 15], [24, 32, 16], [24, 32, 19], [24, 32, 23], [24, 32, 28], [24, 32, 30], [24, 33, 9], [24, 33, 13], [24, 33, 25], [24, 33, 26], [24, 33, 27], [24, 33, 34], [24, 33, 37], [24, 33, 39], [24, 34, 13], [24, 34, 17], [24, 34, 27], [24, 34, 29], [24, 34, 33], [24, 34, 37], [24, 34, 39], [24, 34, 40], [24, 35, 5], [24, 35, 10], [24, 35, 17], [24, 35, 19], [24, 35, 20], [24, 35, 29], [24, 35, 38], [24, 35, 40], [24, 36, 3], [24, 36, 6], [24, 36, 9], [24, 36, 11], [24, 36, 18], [24, 36, 21], [24, 36, 22], [24, 36, 31], [24, 37, 13], [24, 37, 17], [24, 37, 25], [24, 37, 27], [24, 37, 33], [24, 37, 34], [24, 37, 39], [24, 37, 40], [24, 38, 5], [24, 38, 10], [24, 38, 19], [24, 38, 20], [24, 38, 23], [24, 38, 29], [24, 38, 30], [24, 38, 35], [24, 39, 17], [24, 39, 20], [24, 39, 27], [24, 39, 29], [24, 39, 33], [24, 39, 34], [24, 39, 37], [24, 39, 40], [24, 40, 10], [24, 40, 17], [24, 40, 20], [24, 40, 29], [24, 40, 34], [24, 40, 35], [24, 40, 37], [24, 40, 39], [25, 0, 25], [25, 1, 4], [25, 1, 10], [25, 1, 16], [25, 1, 18], [25, 1, 23], [25, 1, 25], [25, 1, 31], [25, 1, 37], [25, 4, 1], [25, 4, 10], [25, 4, 16], [25, 4, 18], [25, 4, 23], [25, 4, 25], [25, 4, 31], [25, 4, 40], [25, 10, 1], [25, 10, 4], [25, 10, 16], [25, 10, 18], [25, 10, 23], [25, 10, 25], [25, 10, 37], [25, 10, 40], [25, 16, 1], [25, 16, 4], [25, 16, 10], [25, 16, 18], [25, 16, 23], [25, 16, 31], [25, 16, 37], [25, 16, 40], [25, 18, 1], [25, 18, 4], [25, 18, 10], [25, 18, 16], [25, 18, 25], [25, 18, 31], [25, 18, 37], [25, 18, 40], [25, 23, 1], [25, 23, 4], [25, 23, 10], [25, 23, 16], [25, 23, 25], [25, 23, 31], [25, 23, 37], [25, 23, 40], [25, 25, 0], [25, 25, 1], [25, 25, 4], [25, 25, 10], [25, 25, 18], [25, 25, 23], [25, 25, 25], [25, 25, 31], [25, 25, 37], [25, 25, 40], [25, 31, 1], [25, 31, 4], [25, 31, 16], [25, 31, 18], [25, 31, 23], [25, 31, 25], [25, 31, 37], [25, 31, 40], [25, 37, 1], [25, 37, 10], [25, 37, 16], [25, 37, 18], [25, 37, 23], [25, 37, 25], [25, 37, 31], [25, 37, 40], [25, 40, 4], [25, 40, 10], [25, 40, 16], [25, 40, 18], [25, 40, 23], [25, 40, 25], [25, 40, 31], [25, 40, 37], [26, 0, 26], [26, 1, 4], [26, 1, 20], [26, 1, 22], [26, 1, 26], [26, 1, 28], [26, 1, 30], [26, 1, 31], [26, 1, 39], [26, 2, 3], [26, 2, 8], [26, 2, 11], [26, 2, 15], [26, 2, 19], [26, 2, 21], [26, 2, 37], [26, 2, 40], [26, 3, 2], [26, 3, 8], [26, 3, 11], [26, 3, 12], [26, 3, 19], [26, 3, 25], [26, 3, 35], [26, 3, 37], [26, 4, 1], [26, 4, 6], [26, 4, 16], [26, 4, 22], [26, 4, 30], [26, 4, 33], [26, 4, 38], [26, 4, 39], [26, 5, 7], [26, 5, 17], [26, 5, 18], [26, 5, 20], [26, 5, 27], [26, 5, 28], [26, 5, 31], [26, 5, 32], [26, 6, 4], [26, 6, 9], [26, 6, 16], [26, 6, 22], [26, 6, 24], [26, 6, 29], [26, 6, 33], [26, 6, 38], [26, 7, 5], [26, 7, 12], [26, 7, 17], [26, 7, 18], [26, 7, 27], [26, 7, 28], [26, 7, 31], [26, 7, 32], [26, 8, 2], [26, 8, 3], [26, 8, 12], [26, 8, 19], [26, 8, 25], [26, 8, 32], [26, 8, 35], [26, 8, 37], [26, 9, 6], [26, 9, 16], [26, 9, 23], [26, 9, 24], [26, 9, 29], [26, 9, 33], [26, 9, 34], [26, 9, 36], [26, 10, 13], [26, 10, 14], [26, 10, 15], [26, 10, 21], [26, 10, 23], [26, 10, 34], [26, 10, 36], [26, 10, 40], [26, 11, 2], [26, 11, 3], [26, 11, 13], [26, 11, 15], [26, 11, 19], [26, 11, 21], [26, 11, 37], [26, 11, 40], [26, 12, 3], [26, 12, 7], [26, 12, 8], [26, 12, 17], [26, 12, 18], [26, 12, 25], [26, 12, 32], [26, 12, 35], [26, 13, 10], [26, 13, 11], [26, 13, 14], [26, 13, 15], [26, 13, 21], [26, 13, 34], [26, 13, 36], [26, 13, 40], [26, 14, 10], [26, 14, 13], [26, 14, 15], [26, 14, 21], [26, 14, 23], [26, 14, 24], [26, 14, 34], [26, 14, 36], [26, 15, 2], [26, 15, 10], [26, 15, 11], [26, 15, 13], [26, 15, 14], [26, 15, 19], [26, 15, 21], [26, 15, 40], [26, 16, 4], [26, 16, 6], [26, 16, 9], [26, 16, 23], [26, 16, 24], [26, 16, 29], [26, 16, 33], [26, 16, 38], [26, 17, 5], [26, 17, 7], [26, 17, 12], [26, 17, 18], [26, 17, 25], [26, 17, 27], [26, 17, 32], [26, 17, 35], [26, 18, 5], [26, 18, 7], [26, 18, 12], [26, 18, 17], [26, 18, 25], [26, 18, 27], [26, 18, 31], [26, 18, 32], [26, 19, 2], [26, 19, 3], [26, 19, 8], [26, 19, 11], [26, 19, 15], [26, 19, 35], [26, 19, 37], [26, 19, 40], [26, 20, 1], [26, 20, 5], [26, 20, 26], [26, 20, 27], [26, 20, 28], [26, 20, 30], [26, 20, 31], [26, 20, 39], [26, 21, 2], [26, 21, 10], [26, 21, 11], [26, 21, 13], [26, 21, 14], [26, 21, 15], [26, 21, 36], [26, 21, 40], [26, 22, 1], [26, 22, 4], [26, 22, 6], [26, 22, 26], [26, 22, 30], [26, 22, 33], [26, 22, 38], [26, 22, 39], [26, 23, 9], [26, 23, 10], [26, 23, 14], [26, 23, 16], [26, 23, 24], [26, 23, 29], [26, 23, 34], [26, 23, 36], [26, 24, 6], [26, 24, 9], [26, 24, 14], [26, 24, 16], [26, 24, 23], [26, 24, 29], [26, 24, 34], [26, 24, 36], [26, 25, 3], [26, 25, 8], [26, 25, 12], [26, 25, 17], [26, 25, 18], [26, 25, 32], [26, 25, 35], [26, 25, 37], [26, 26, 0], [26, 26, 1], [26, 26, 20], [26, 26, 22], [26, 26, 26], [26, 26, 27], [26, 26, 28], [26, 26, 30], [26, 26, 31], [26, 26, 39], [26, 27, 5], [26, 27, 7], [26, 27, 17], [26, 27, 18], [26, 27, 20], [26, 27, 26], [26, 27, 28], [26, 27, 31], [26, 28, 1], [26, 28, 5], [26, 28, 7], [26, 28, 20], [26, 28, 26], [26, 28, 27], [26, 28, 30], [26, 28, 31], [26, 29, 6], [26, 29, 9], [26, 29, 16], [26, 29, 23], [26, 29, 24], [26, 29, 33], [26, 29, 34], [26, 29, 38], [26, 30, 1], [26, 30, 4], [26, 30, 20], [26, 30, 22], [26, 30, 26], [26, 30, 28], [26, 30, 38], [26, 30, 39], [26, 31, 1], [26, 31, 5], [26, 31, 7], [26, 31, 18], [26, 31, 20], [26, 31, 26], [26, 31, 27], [26, 31, 28], [26, 32, 5], [26, 32, 7], [26, 32, 8], [26, 32, 12], [26, 32, 17], [26, 32, 18], [26, 32, 25], [26, 32, 35], [26, 33, 4], [26, 33, 6], [26, 33, 9], [26, 33, 16], [26, 33, 22], [26, 33, 29], [26, 33, 38], [26, 33, 39], [26, 34, 9], [26, 34, 10], [26, 34, 13], [26, 34, 14], [26, 34, 23], [26, 34, 24], [26, 34, 29], [26, 34, 36], [26, 35, 3], [26, 35, 8], [26, 35, 12], [26, 35, 17], [26, 35, 19], [26, 35, 25], [26, 35, 32], [26, 35, 37], [26, 36, 9], [26, 36, 10], [26, 36, 13], [26, 36, 14], [26, 36, 21], [26, 36, 23], [26, 36, 24], [26, 36, 34], [26, 37, 2], [26, 37, 3], [26, 37, 8], [26, 37, 11], [26, 37, 19], [26, 37, 25], [26, 37, 35], [26, 37, 40], [26, 38, 4], [26, 38, 6], [26, 38, 16], [26, 38, 22], [26, 38, 29], [26, 38, 30], [26, 38, 33], [26, 38, 39], [26, 39, 1], [26, 39, 4], [26, 39, 20], [26, 39, 22], [26, 39, 26], [26, 39, 30], [26, 39, 33], [26, 39, 38], [26, 40, 2], [26, 40, 10], [26, 40, 11], [26, 40, 13], [26, 40, 15], [26, 40, 19], [26, 40, 21], [26, 40, 37], [27, 0, 27], [27, 1, 3], [27, 1, 9], [27, 1, 14], [27, 1, 27], [27, 1, 32], [27, 1, 38], [27, 1, 40], [27, 3, 1], [27, 3, 9], [27, 3, 14], [27, 3, 27], [27, 3, 32], [27, 3, 38], [27, 3, 40], [27, 9, 1], [27, 9, 3], [27, 9, 14], [27, 9, 27], [27, 9, 32], [27, 9, 38], [27, 9, 40], [27, 14, 1], [27, 14, 3], [27, 14, 9], [27, 14, 27], [27, 14, 32], [27, 14, 38], [27, 14, 40], [27, 27, 0], [27, 27, 1], [27, 27, 3], [27, 27, 9], [27, 27, 14], [27, 27, 27], [27, 27, 32], [27, 27, 38], [27, 27, 40], [27, 32, 1], [27, 32, 3], [27, 32, 9], [27, 32, 14], [27, 32, 27], [27, 32, 38], [27, 32, 40], [27, 38, 1], [27, 38, 3], [27, 38, 9], [27, 38, 14], [27, 38, 27], [27, 38, 32], [27, 38, 40], [27, 40, 1], [27, 40, 3], [27, 40, 9], [27, 40, 14], [27, 40, 27], [27, 40, 32], [27, 40, 38], [28, 0, 28], [28, 1, 5], [28, 1, 17], [28, 1, 22], [28, 1, 23], [28, 1, 25], [28, 1, 28], [28, 1, 29], [28, 1, 33], [28, 2, 3], [28, 2, 5], [28, 2, 9], [28, 2, 10], [28, 2, 15], [28, 2, 17], [28, 2, 25], [28, 2, 34], [28, 3, 2], [28, 3, 5], [28, 3, 10], [28, 3, 15], [28, 3, 17], [28, 3, 25], [28, 3, 28], [28, 3, 34], [28, 4, 6], [28, 4, 9], [28, 4, 10], [28, 4, 18], [28, 4, 20], [28, 4, 27], [28, 4, 30], [28, 4, 34], [28, 5, 1], [28, 5, 2], [28, 5, 3], [28, 5, 17], [28, 5, 22], [28, 5, 25], [28, 5, 28], [28, 5, 33], [28, 6, 4], [28, 6, 9], [28, 6, 10], [28, 6, 15], [28, 6, 20], [28, 6, 27], [28, 6, 30], [28, 6, 34], [28, 7, 11], [28, 7, 26], [28, 7, 31], [28, 7, 32], [28, 7, 35], [28, 7, 37], [28, 7, 38], [28, 7, 39], [28, 8, 12], [28, 8, 13], [28, 8, 18], [28, 8, 19], [28, 8, 20], [28, 8, 27], [28, 8, 36], [28, 8, 40], [28, 9, 2], [28, 9, 4], [28, 9, 6], [28, 9, 10], [28, 9, 15], [28, 9, 20], [28, 9, 30], [28, 9, 34], [28, 10, 2], [28, 10, 3], [28, 10, 4], [28, 10, 6], [28, 10, 9], [28, 10, 15], [28, 10, 25], [28, 10, 34], [28, 11, 7], [28, 11, 14], [28, 11, 21], [28, 11, 23], [28, 11, 29], [28, 11, 32], [28, 11, 35], [28, 11, 37], [28, 12, 8], [28, 12, 13], [28, 12, 18], [28, 12, 19], [28, 12, 20], [28, 12, 27], [28, 12, 30], [28, 12, 40], [28, 13, 8], [28, 13, 12], [28, 13, 16], [28, 13, 19], [28, 13, 24], [28, 13, 36], [28, 13, 38], [28, 13, 40], [28, 14, 11], [28, 14, 21], [28, 14, 22], [28, 14, 23], [28, 14, 29], [28, 14, 33], [28, 14, 35], [28, 14, 37], [28, 15, 2], [28, 15, 3], [28, 15, 6], [28, 15, 9], [28, 15, 10], [28, 15, 17], [28, 15, 25], [28, 15, 34], [28, 16, 13], [28, 16, 24], [28, 16, 26], [28, 16, 31], [28, 16, 36], [28, 16, 38], [28, 16, 39], [28, 16, 40], [28, 17, 1], [28, 17, 2], [28, 17, 3], [28, 17, 5], [28, 17, 15], [28, 17, 22], [28, 17, 25], [28, 17, 28], [28, 18, 4], [28, 18, 8], [28, 18, 12], [28, 18, 19], [28, 18, 20], [28, 18, 27], [28, 18, 30], [28, 18, 40], [28, 19, 8], [28, 19, 12], [28, 19, 13], [28, 19, 18], [28, 19, 24], [28, 19, 27], [28, 19, 36], [28, 19, 40], [28, 20, 4], [28, 20, 6], [28, 20, 8], [28, 20, 9], [28, 20, 12], [28, 20, 18], [28, 20, 27], [28, 20, 30], [28, 21, 11], [28, 21, 14], [28, 21, 23], [28, 21, 29], [28, 21, 32], [28, 21, 33], [28, 21, 35], [28, 21, 37], [28, 22, 1], [28, 22, 5], [28, 22, 14], [28, 22, 17], [28, 22, 23], [28, 22, 28], [28, 22, 29], [28, 22, 33], [28, 23, 1], [28, 23, 11], [28, 23, 14], [28, 23, 21], [28, 23, 22], [28, 23, 29], [28, 23, 33], [28, 23, 37], [28, 24, 13], [28, 24, 16], [28, 24, 19], [28, 24, 26], [28, 24, 36], [28, 24, 38], [28, 24, 39], [28, 24, 40], [28, 25, 1], [28, 25, 2], [28, 25, 3], [28, 25, 5], [28, 25, 10], [28, 25, 15], [28, 25, 17], [28, 25, 28], [28, 26, 7], [28, 26, 16], [28, 26, 24], [28, 26, 31], [28, 26, 32], [28, 26, 35], [28, 26, 38], [28, 26, 39], [28, 27, 4], [28, 27, 6], [28, 27, 8], [28, 27, 12], [28, 27, 18], [28, 27, 19], [28, 27, 20], [28, 27, 30], [28, 28, 0], [28, 28, 1], [28, 28, 3], [28, 28, 5], [28, 28, 17], [28, 28, 22], [28, 28, 25], [28, 28, 28], [28, 28, 29], [28, 28, 33], [28, 29, 1], [28, 29, 11], [28, 29, 14], [28, 29, 21], [28, 29, 22], [28, 29, 23], [28, 29, 28], [28, 29, 33], [28, 30, 4], [28, 30, 6], [28, 30, 9], [28, 30, 12], [28, 30, 18], [28, 30, 20], [28, 30, 27], [28, 30, 34], [28, 31, 7], [28, 31, 16], [28, 31, 26], [28, 31, 32], [28, 31, 35], [28, 31, 37], [28, 31, 38], [28, 31, 39], [28, 32, 7], [28, 32, 11], [28, 32, 21], [28, 32, 26], [28, 32, 31], [28, 32, 35], [28, 32, 37], [28, 32, 39], [28, 33, 1], [28, 33, 5], [28, 33, 14], [28, 33, 21], [28, 33, 22], [28, 33, 23], [28, 33, 28], [28, 33, 29], [28, 34, 2], [28, 34, 3], [28, 34, 4], [28, 34, 6], [28, 34, 9], [28, 34, 10], [28, 34, 15], [28, 34, 30], [28, 35, 7], [28, 35, 11], [28, 35, 14], [28, 35, 21], [28, 35, 26], [28, 35, 31], [28, 35, 32], [28, 35, 37], [28, 36, 8], [28, 36, 13], [28, 36, 16], [28, 36, 19], [28, 36, 24], [28, 36, 38], [28, 36, 39], [28, 36, 40], [28, 37, 7], [28, 37, 11], [28, 37, 14], [28, 37, 21], [28, 37, 23], [28, 37, 31], [28, 37, 32], [28, 37, 35], [28, 38, 7], [28, 38, 13], [28, 38, 16], [28, 38, 24], [28, 38, 26], [28, 38, 31], [28, 38, 36], [28, 38, 39], [28, 39, 7], [28, 39, 16], [28, 39, 24], [28, 39, 26], [28, 39, 31], [28, 39, 32], [28, 39, 36], [28, 39, 38], [28, 40, 8], [28, 40, 12], [28, 40, 13], [28, 40, 16], [28, 40, 18], [28, 40, 19], [28, 40, 24], [28, 40, 36], [29, 0, 29], [29, 1, 2], [29, 1, 4], [29, 1, 17], [29, 1, 21], [29, 1, 29], [29, 1, 31], [29, 1, 34], [29, 1, 35], [29, 2, 1], [29, 2, 4], [29, 2, 8], [29, 2, 17], [29, 2, 21], [29, 2, 27], [29, 2, 29], [29, 2, 34], [29, 3, 5], [29, 3, 6], [29, 3, 10], [29, 3, 11], [29, 3, 12], [29, 3, 20], [29, 3, 22], [29, 3, 23], [29, 4, 1], [29, 4, 2], [29, 4, 8], [29, 4, 13], [29, 4, 16], [29, 4, 17], [29, 4, 27], [29, 4, 34], [29, 5, 3], [29, 5, 6], [29, 5, 10], [29, 5, 11], [29, 5, 20], [29, 5, 22], [29, 5, 23], [29, 5, 32], [29, 6, 3], [29, 6, 5], [29, 6, 10], [29, 6, 12], [29, 6, 20], [29, 6, 22], [29, 6, 24], [29, 6, 40], [29, 7, 12], [29, 7, 14], [29, 7, 24], [29, 7, 28], [29, 7, 33], [29, 7, 37], [29, 7, 39], [29, 7, 40], [29, 8, 2], [29, 8, 4], [29, 8, 13], [29, 8, 16], [29, 8, 26], [29, 8, 27], [29, 8, 32], [29, 8, 34], [29, 9, 15], [29, 9, 18], [29, 9, 19], [29, 9, 25], [29, 9, 28], [29, 9, 30], [29, 9, 33], [29, 9, 36], [29, 10, 3], [29, 10, 5], [29, 10, 6], [29, 10, 12], [29, 10, 20], [29, 10, 22], [29, 10, 23], [29, 10, 40], [29, 11, 3], [29, 11, 5], [29, 11, 13], [29, 11, 16], [29, 11, 22], [29, 11, 23], [29, 11, 26], [29, 11, 32], [29, 12, 3], [29, 12, 6], [29, 12, 7], [29, 12, 10], [29, 12, 20], [29, 12, 24], [29, 12, 39], [29, 12, 40], [29, 13, 4], [29, 13, 8], [29, 13, 11], [29, 13, 16], [29, 13, 26], [29, 13, 27], [29, 13, 32], [29, 13, 34], [29, 14, 7], [29, 14, 15], [29, 14, 24], [29, 14, 25], [29, 14, 28], [29, 14, 33], [29, 14, 37], [29, 14, 39], [29, 15, 9], [29, 15, 14], [29, 15, 18], [29, 15, 19], [29, 15, 25], [29, 15, 28], [29, 15, 30], [29, 15, 33], [29, 16, 4], [29, 16, 8], [29, 16, 11], [29, 16, 13], [29, 16, 23], [29, 16, 26], [29, 16, 27], [29, 16, 32], [29, 17, 1], [29, 17, 2], [29, 17, 4], [29, 17, 21], [29, 17, 27], [29, 17, 29], [29, 17, 34], [29, 17, 35], [29, 18, 9], [29, 18, 15], [29, 18, 19], [29, 18, 25], [29, 18, 30], [29, 18, 31], [29, 18, 36], [29, 18, 38], [29, 19, 9], [29, 19, 15], [29, 19, 18], [29, 19, 30], [29, 19, 31], [29, 19, 35], [29, 19, 36], [29, 19, 38], [29, 20, 3], [29, 20, 5], [29, 20, 6], [29, 20, 10], [29, 20, 12], [29, 20, 24], [29, 20, 39], [29, 20, 40], [29, 21, 1], [29, 21, 2], [29, 21, 17], [29, 21, 29], [29, 21, 31], [29, 21, 35], [29, 21, 36], [29, 21, 38], [29, 22, 3], [29, 22, 5], [29, 22, 6], [29, 22, 10], [29, 22, 11], [29, 22, 23], [29, 22, 26], [29, 22, 32], [29, 23, 3], [29, 23, 5], [29, 23, 10], [29, 23, 11], [29, 23, 16], [29, 23, 22], [29, 23, 26], [29, 23, 32], [29, 24, 6], [29, 24, 7], [29, 24, 12], [29, 24, 14], [29, 24, 20], [29, 24, 37], [29, 24, 39], [29, 24, 40], [29, 25, 9], [29, 25, 14], [29, 25, 15], [29, 25, 18], [29, 25, 28], [29, 25, 30], [29, 25, 33], [29, 25, 37], [29, 26, 8], [29, 26, 11], [29, 26, 13], [29, 26, 16], [29, 26, 22], [29, 26, 23], [29, 26, 27], [29, 26, 32], [29, 27, 2], [29, 27, 4], [29, 27, 8], [29, 27, 13], [29, 27, 16], [29, 27, 17], [29, 27, 26], [29, 27, 34], [29, 28, 7], [29, 28, 9], [29, 28, 14], [29, 28, 15], [29, 28, 25], [29, 28, 30], [29, 28, 33], [29, 28, 37], [29, 29, 0], [29, 29, 1], [29, 29, 2], [29, 29, 17], [29, 29, 21], [29, 29, 29], [29, 29, 31], [29, 29, 34], [29, 29, 35], [29, 29, 38], [29, 30, 9], [29, 30, 15], [29, 30, 18], [29, 30, 19], [29, 30, 25], [29, 30, 28], [29, 30, 36], [29, 30, 38], [29, 31, 1], [29, 31, 18], [29, 31, 19], [29, 31, 21], [29, 31, 29], [29, 31, 35], [29, 31, 36], [29, 31, 38], [29, 32, 5], [29, 32, 8], [29, 32, 11], [29, 32, 13], [29, 32, 16], [29, 32, 22], [29, 32, 23], [29, 32, 26], [29, 33, 7], [29, 33, 9], [29, 33, 14], [29, 33, 15], [29, 33, 25], [29, 33, 28], [29, 33, 37], [29, 33, 39], [29, 34, 1], [29, 34, 2], [29, 34, 4], [29, 34, 8], [29, 34, 13], [29, 34, 17], [29, 34, 27], [29, 34, 29], [29, 35, 1], [29, 35, 17], [29, 35, 19], [29, 35, 21], [29, 35, 29], [29, 35, 31], [29, 35, 36], [29, 35, 38], [29, 36, 9], [29, 36, 18], [29, 36, 19], [29, 36, 21], [29, 36, 30], [29, 36, 31], [29, 36, 35], [29, 36, 38], [29, 37, 7], [29, 37, 14], [29, 37, 24], [29, 37, 25], [29, 37, 28], [29, 37, 33], [29, 37, 39], [29, 37, 40], [29, 38, 18], [29, 38, 19], [29, 38, 21], [29, 38, 29], [29, 38, 30], [29, 38, 31], [29, 38, 35], [29, 38, 36], [29, 39, 7], [29, 39, 12], [29, 39, 14], [29, 39, 20], [29, 39, 24], [29, 39, 33], [29, 39, 37], [29, 39, 40], [29, 40, 6], [29, 40, 7], [29, 40, 10], [29, 40, 12], [29, 40, 20], [29, 40, 24], [29, 40, 37], [29, 40, 39], [30, 0, 30], [30, 1, 4], [30, 1, 20], [30, 1, 22], [30, 1, 26], [30, 1, 28], [30, 1, 30], [30, 1, 31], [30, 1, 39], [30, 2, 3], [30, 2, 8], [30, 2, 11], [30, 2, 15], [30, 2, 19], [30, 2, 21], [30, 2, 37], [30, 2, 40], [30, 3, 2], [30, 3, 8], [30, 3, 11], [30, 3, 12], [30, 3, 19], [30, 3, 25], [30, 3, 35], [30, 3, 37], [30, 4, 1], [30, 4, 6], [30, 4, 16], [30, 4, 22], [30, 4, 30], [30, 4, 33], [30, 4, 38], [30, 4, 39], [30, 5, 7], [30, 5, 17], [30, 5, 18], [30, 5, 20], [30, 5, 27], [30, 5, 28], [30, 5, 31], [30, 5, 32], [30, 6, 4], [30, 6, 9], [30, 6, 16], [30, 6, 22], [30, 6, 24], [30, 6, 29], [30, 6, 33], [30, 6, 38], [30, 7, 5], [30, 7, 12], [30, 7, 17], [30, 7, 18], [30, 7, 27], [30, 7, 28], [30, 7, 31], [30, 7, 32], [30, 8, 2], [30, 8, 3], [30, 8, 12], [30, 8, 19], [30, 8, 25], [30, 8, 32], [30, 8, 35], [30, 8, 37], [30, 9, 6], [30, 9, 16], [30, 9, 23], [30, 9, 24], [30, 9, 29], [30, 9, 33], [30, 9, 34], [30, 9, 36], [30, 10, 13], [30, 10, 14], [30, 10, 15], [30, 10, 21], [30, 10, 23], [30, 10, 34], [30, 10, 36], [30, 10, 40], [30, 11, 2], [30, 11, 3], [30, 11, 13], [30, 11, 15], [30, 11, 19], [30, 11, 21], [30, 11, 37], [30, 11, 40], [30, 12, 3], [30, 12, 7], [30, 12, 8], [30, 12, 17], [30, 12, 18], [30, 12, 25], [30, 12, 32], [30, 12, 35], [30, 13, 10], [30, 13, 11], [30, 13, 14], [30, 13, 15], [30, 13, 21], [30, 13, 34], [30, 13, 36], [30, 13, 40], [30, 14, 10], [30, 14, 13], [30, 14, 15], [30, 14, 21], [30, 14, 23], [30, 14, 24], [30, 14, 34], [30, 14, 36], [30, 15, 2], [30, 15, 10], [30, 15, 11], [30, 15, 13], [30, 15, 14], [30, 15, 19], [30, 15, 21], [30, 15, 40], [30, 16, 4], [30, 16, 6], [30, 16, 9], [30, 16, 23], [30, 16, 24], [30, 16, 29], [30, 16, 33], [30, 16, 38], [30, 17, 5], [30, 17, 7], [30, 17, 12], [30, 17, 18], [30, 17, 25], [30, 17, 27], [30, 17, 32], [30, 17, 35], [30, 18, 5], [30, 18, 7], [30, 18, 12], [30, 18, 17], [30, 18, 25], [30, 18, 27], [30, 18, 31], [30, 18, 32], [30, 19, 2], [30, 19, 3], [30, 19, 8], [30, 19, 11], [30, 19, 15], [30, 19, 35], [30, 19, 37], [30, 19, 40], [30, 20, 1], [30, 20, 5], [30, 20, 26], [30, 20, 27], [30, 20, 28], [30, 20, 30], [30, 20, 31], [30, 20, 39], [30, 21, 2], [30, 21, 10], [30, 21, 11], [30, 21, 13], [30, 21, 14], [30, 21, 15], [30, 21, 36], [30, 21, 40], [30, 22, 1], [30, 22, 4], [30, 22, 6], [30, 22, 26], [30, 22, 30], [30, 22, 33], [30, 22, 38], [30, 22, 39], [30, 23, 9], [30, 23, 10], [30, 23, 14], [30, 23, 16], [30, 23, 24], [30, 23, 29], [30, 23, 34], [30, 23, 36], [30, 24, 6], [30, 24, 9], [30, 24, 14], [30, 24, 16], [30, 24, 23], [30, 24, 29], [30, 24, 34], [30, 24, 36], [30, 25, 3], [30, 25, 8], [30, 25, 12], [30, 25, 17], [30, 25, 18], [30, 25, 32], [30, 25, 35], [30, 25, 37], [30, 26, 1], [30, 26, 20], [30, 26, 22], [30, 26, 27], [30, 26, 28], [30, 26, 30], [30, 26, 31], [30, 26, 39], [30, 27, 5], [30, 27, 7], [30, 27, 17], [30, 27, 18], [30, 27, 20], [30, 27, 26], [30, 27, 28], [30, 27, 31], [30, 28, 1], [30, 28, 5], [30, 28, 7], [30, 28, 20], [30, 28, 26], [30, 28, 27], [30, 28, 30], [30, 28, 31], [30, 29, 6], [30, 29, 9], [30, 29, 16], [30, 29, 23], [30, 29, 24], [30, 29, 33], [30, 29, 34], [30, 29, 38], [30, 30, 0], [30, 30, 1], [30, 30, 4], [30, 30, 20], [30, 30, 22], [30, 30, 26], [30, 30, 28], [30, 30, 30], [30, 30, 38], [30, 30, 39], [30, 31, 1], [30, 31, 5], [30, 31, 7], [30, 31, 18], [30, 31, 20], [30, 31, 26], [30, 31, 27], [30, 31, 28], [30, 32, 5], [30, 32, 7], [30, 32, 8], [30, 32, 12], [30, 32, 17], [30, 32, 18], [30, 32, 25], [30, 32, 35], [30, 33, 4], [30, 33, 6], [30, 33, 9], [30, 33, 16], [30, 33, 22], [30, 33, 29], [30, 33, 38], [30, 33, 39], [30, 34, 9], [30, 34, 10], [30, 34, 13], [30, 34, 14], [30, 34, 23], [30, 34, 24], [30, 34, 29], [30, 34, 36], [30, 35, 3], [30, 35, 8], [30, 35, 12], [30, 35, 17], [30, 35, 19], [30, 35, 25], [30, 35, 32], [30, 35, 37], [30, 36, 9], [30, 36, 10], [30, 36, 13], [30, 36, 14], [30, 36, 21], [30, 36, 23], [30, 36, 24], [30, 36, 34], [30, 37, 2], [30, 37, 3], [30, 37, 8], [30, 37, 11], [30, 37, 19], [30, 37, 25], [30, 37, 35], [30, 37, 40], [30, 38, 4], [30, 38, 6], [30, 38, 16], [30, 38, 22], [30, 38, 29], [30, 38, 30], [30, 38, 33], [30, 38, 39], [30, 39, 1], [30, 39, 4], [30, 39, 20], [30, 39, 22], [30, 39, 26], [30, 39, 30], [30, 39, 33], [30, 39, 38], [30, 40, 2], [30, 40, 10], [30, 40, 11], [30, 40, 13], [30, 40, 15], [30, 40, 19], [30, 40, 21], [30, 40, 37], [31, 0, 31], [31, 1, 4], [31, 1, 10], [31, 1, 16], [31, 1, 18], [31, 1, 23], [31, 1, 25], [31, 1, 31], [31, 1, 37], [31, 4, 1], [31, 4, 10], [31, 4, 16], [31, 4, 18], [31, 4, 23], [31, 4, 25], [31, 4, 31], [31, 4, 40], [31, 10, 1], [31, 10, 4], [31, 10, 16], [31, 10, 18], [31, 10, 23], [31, 10, 25], [31, 10, 37], [31, 10, 40], [31, 16, 1], [31, 16, 4], [31, 16, 10], [31, 16, 18], [31, 16, 23], [31, 16, 31], [31, 16, 37], [31, 16, 40], [31, 18, 1], [31, 18, 4], [31, 18, 10], [31, 18, 16], [31, 18, 25], [31, 18, 31], [31, 18, 37], [31, 18, 40], [31, 23, 1], [31, 23, 4], [31, 23, 10], [31, 23, 16], [31, 23, 25], [31, 23, 31], [31, 23, 37], [31, 23, 40], [31, 25, 1], [31, 25, 4], [31, 25, 10], [31, 25, 18], [31, 25, 23], [31, 25, 31], [31, 25, 37], [31, 25, 40], [31, 31, 0], [31, 31, 1], [31, 31, 4], [31, 31, 16], [31, 31, 18], [31, 31, 23], [31, 31, 25], [31, 31, 31], [31, 31, 37], [31, 31, 40], [31, 37, 1], [31, 37, 10], [31, 37, 16], [31, 37, 18], [31, 37, 23], [31, 37, 25], [31, 37, 31], [31, 37, 40], [31, 40, 4], [31, 40, 10], [31, 40, 16], [31, 40, 18], [31, 40, 23], [31, 40, 25], [31, 40, 31], [31, 40, 37], [32, 0, 32], [32, 1, 1], [32, 1, 9], [32, 1, 32], [32, 1, 40], [32, 9, 1], [32, 9, 9], [32, 9, 32], [32, 9, 40], [32, 32, 0], [32, 32, 1], [32, 32, 9], [32, 32, 32], [32, 32, 40], [32, 40, 1], [32, 40, 9], [32, 40, 32], [32, 40, 40], [33, 0, 33], [33, 1, 2], [33, 1, 5], [33, 1, 10], [33, 1, 21], [33, 1, 23], [33, 1, 25], [33, 1, 33], [33, 1, 37], [33, 2, 1], [33, 2, 4], [33, 2, 5], [33, 2, 9], [33, 2, 10], [33, 2, 20], [33, 2, 25], [33, 2, 33], [33, 4, 2], [33, 4, 8], [33, 4, 9], [33, 4, 10], [33, 4, 18], [33, 4, 20], [33, 4, 25], [33, 4, 40], [33, 5, 1], [33, 5, 2], [33, 5, 9], [33, 5, 10], [33, 5, 21], [33, 5, 23], [33, 5, 25], [33, 5, 33], [33, 8, 4], [33, 8, 9], [33, 8, 16], [33, 8, 18], [33, 8, 20], [33, 8, 36], [33, 8, 39], [33, 8, 40], [33, 9, 2], [33, 9, 4], [33, 9, 5], [33, 9, 8], [33, 9, 10], [33, 9, 18], [33, 9, 20], [33, 9, 25], [33, 10, 1], [33, 10, 2], [33, 10, 4], [33, 10, 5], [33, 10, 9], [33, 10, 18], [33, 10, 20], [33, 10, 25], [33, 16, 8], [33, 16, 18], [33, 16, 31], [33, 16, 32], [33, 16, 36], [33, 16, 37], [33, 16, 39], [33, 16, 40], [33, 18, 4], [33, 18, 8], [33, 18, 9], [33, 18, 10], [33, 18, 16], [33, 18, 20], [33, 18, 36], [33, 18, 40], [33, 20, 2], [33, 20, 4], [33, 20, 8], [33, 20, 9], [33, 20, 10], [33, 20, 18], [33, 20, 36], [33, 20, 40], [33, 21, 1], [33, 21, 5], [33, 21, 23], [33, 21, 31], [33, 21, 32], [33, 21, 33], [33, 21, 37], [33, 21, 39], [33, 23, 1], [33, 23, 5], [33, 23, 21], [33, 23, 25], [33, 23, 31], [33, 23, 32], [33, 23, 33], [33, 23, 37], [33, 25, 1], [33, 25, 2], [33, 25, 4], [33, 25, 5], [33, 25, 9], [33, 25, 10], [33, 25, 23], [33, 25, 33], [33, 31, 16], [33, 31, 21], [33, 31, 23], [33, 31, 32], [33, 31, 36], [33, 31, 37], [33, 31, 39], [33, 31, 40], [33, 32, 16], [33, 32, 21], [33, 32, 23], [33, 32, 31], [33, 32, 33], [33, 32, 36], [33, 32, 37], [33, 32, 39], [33, 33, 0], [33, 33, 1], [33, 33, 2], [33, 33, 5], [33, 33, 21], [33, 33, 23], [33, 33, 25], [33, 33, 32], [33, 33, 33], [33, 33, 37], [33, 36, 8], [33, 36, 16], [33, 36, 18], [33, 36, 20], [33, 36, 31], [33, 36, 32], [33, 36, 39], [33, 36, 40], [33, 37, 1], [33, 37, 16], [33, 37, 21], [33, 37, 23], [33, 37, 31], [33, 37, 32], [33, 37, 33], [33, 37, 39], [33, 39, 8], [33, 39, 16], [33, 39, 21], [33, 39, 31], [33, 39, 32], [33, 39, 36], [33, 39, 37], [33, 39, 40], [33, 40, 4], [33, 40, 8], [33, 40, 16], [33, 40, 18], [33, 40, 20], [33, 40, 31], [33, 40, 36], [33, 40, 39], [34, 0, 34], [34, 1, 8], [34, 1, 23], [34, 1, 25], [34, 1, 26], [34, 1, 30], [34, 1, 34], [34, 1, 35], [34, 1, 36], [34, 2, 5], [34, 2, 9], [34, 2, 11], [34, 2, 16], [34, 2, 19], [34, 2, 27], [34, 2, 29], [34, 2, 31], [34, 3, 8], [34, 3, 20], [34, 3, 23], [34, 3, 24], [34, 3, 26], [34, 3, 28], [34, 3, 34], [34, 3, 37], [34, 4, 10], [34, 4, 13], [34, 4, 17], [34, 4, 18], [34, 4, 21], [34, 4, 22], [34, 4, 32], [34, 4, 38], [34, 5, 2], [34, 5, 6], [34, 5, 7], [34, 5, 11], [34, 5, 16], [34, 5, 27], [34, 5, 33], [34, 5, 40], [34, 6, 5], [34, 6, 7], [34, 6, 11], [34, 6, 15], [34, 6, 16], [34, 6, 27], [34, 6, 33], [34, 6, 40], [34, 7, 5], [34, 7, 6], [34, 7, 11], [34, 7, 15], [34, 7, 18], [34, 7, 33], [34, 7, 38], [34, 7, 40], [34, 8, 1], [34, 8, 3], [34, 8, 20], [34, 8, 23], [34, 8, 26], [34, 8, 34], [34, 8, 35], [34, 8, 36], [34, 9, 2], [34, 9, 19], [34, 9, 20], [34, 9, 24], [34, 9, 28], [34, 9, 29], [34, 9, 31], [34, 9, 37], [34, 10, 4], [34, 10, 12], [34, 10, 13], [34, 10, 14], [34, 10, 22], [34, 10, 25], [34, 10, 32], [34, 10, 39], [34, 11, 2], [34, 11, 5], [34, 11, 6], [34, 11, 7], [34, 11, 16], [34, 11, 27], [34, 11, 29], [34, 11, 40], [34, 12, 10], [34, 12, 13], [34, 12, 14], [34, 12, 22], [34, 12, 25], [34, 12, 30], [34, 12, 32], [34, 12, 39], [34, 13, 4], [34, 13, 10], [34, 13, 12], [34, 13, 17], [34, 13, 21], [34, 13, 22], [34, 13, 32], [34, 13, 38], [34, 14, 10], [34, 14, 12], [34, 14, 22], [34, 14, 25], [34, 14, 30], [34, 14, 35], [34, 14, 36], [34, 14, 39], [34, 15, 6], [34, 15, 7], [34, 15, 17], [34, 15, 18], [34, 15, 21], [34, 15, 33], [34, 15, 38], [34, 15, 40], [34, 16, 2], [34, 16, 5], [34, 16, 6], [34, 16, 11], [34, 16, 27], [34, 16, 29], [34, 16, 31], [34, 16, 40], [34, 17, 4], [34, 17, 13], [34, 17, 15], [34, 17, 18], [34, 17, 21], [34, 17, 22], [34, 17, 32], [34, 17, 38], [34, 18, 4], [34, 18, 7], [34, 18, 15], [34, 18, 17], [34, 18, 21], [34, 18, 33], [34, 18, 38], [34, 18, 40], [34, 19, 2], [34, 19, 9], [34, 19, 24], [34, 19, 27], [34, 19, 28], [34, 19, 29], [34, 19, 31], [34, 19, 37], [34, 20, 3], [34, 20, 8], [34, 20, 9], [34, 20, 23], [34, 20, 24], [34, 20, 26], [34, 20, 28], [34, 20, 37], [34, 21, 4], [34, 21, 13], [34, 21, 15], [34, 21, 17], [34, 21, 18], [34, 21, 32], [34, 21, 33], [34, 21, 38], [34, 22, 4], [34, 22, 10], [34, 22, 12], [34, 22, 13], [34, 22, 14], [34, 22, 17], [34, 22, 32], [34, 22, 39], [34, 23, 1], [34, 23, 3], [34, 23, 8], [34, 23, 20], [34, 23, 24], [34, 23, 26], [34, 23, 34], [34, 23, 37], [34, 24, 3], [34, 24, 9], [34, 24, 19], [34, 24, 20], [34, 24, 23], [34, 24, 26], [34, 24, 28], [34, 24, 37], [34, 25, 1], [34, 25, 10], [34, 25, 12], [34, 25, 14], [34, 25, 30], [34, 25, 35], [34, 25, 36], [34, 25, 39], [34, 26, 1], [34, 26, 3], [34, 26, 8], [34, 26, 20], [34, 26, 23], [34, 26, 24], [34, 26, 34], [34, 26, 35], [34, 27, 2], [34, 27, 5], [34, 27, 6], [34, 27, 11], [34, 27, 16], [34, 27, 19], [34, 27, 29], [34, 27, 31], [34, 28, 3], [34, 28, 9], [34, 28, 19], [34, 28, 20], [34, 28, 24], [34, 28, 29], [34, 28, 31], [34, 28, 37], [34, 29, 2], [34, 29, 9], [34, 29, 11], [34, 29, 16], [34, 29, 19], [34, 29, 27], [34, 29, 28], [34, 29, 31], [34, 30, 1], [34, 30, 12], [34, 30, 14], [34, 30, 25], [34, 30, 34], [34, 30, 35], [34, 30, 36], [34, 30, 39], [34, 31, 2], [34, 31, 9], [34, 31, 16], [34, 31, 19], [34, 31, 27], [34, 31, 28], [34, 31, 29], [34, 31, 37], [34, 32, 4], [34, 32, 10], [34, 32, 12], [34, 32, 13], [34, 32, 17], [34, 32, 21], [34, 32, 22], [34, 32, 39], [34, 33, 5], [34, 33, 6], [34, 33, 7], [34, 33, 15], [34, 33, 18], [34, 33, 21], [34, 33, 38], [34, 33, 40], [34, 34, 0], [34, 34, 1], [34, 34, 3], [34, 34, 8], [34, 34, 23], [34, 34, 26], [34, 34, 30], [34, 34, 34], [34, 34, 35], [34, 34, 36], [34, 35, 1], [34, 35, 8], [34, 35, 14], [34, 35, 25], [34, 35, 26], [34, 35, 30], [34, 35, 34], [34, 35, 36], [34, 36, 1], [34, 36, 8], [34, 36, 14], [34, 36, 25], [34, 36, 30], [34, 36, 34], [34, 36, 35], [34, 36, 39], [34, 37, 3], [34, 37, 9], [34, 37, 19], [34, 37, 20], [34, 37, 23], [34, 37, 24], [34, 37, 28], [34, 37, 31], [34, 38, 4], [34, 38, 7], [34, 38, 13], [34, 38, 15], [34, 38, 17], [34, 38, 18], [34, 38, 21], [34, 38, 33], [34, 39, 10], [34, 39, 12], [34, 39, 14], [34, 39, 22], [34, 39, 25], [34, 39, 30], [34, 39, 32], [34, 39, 36], [34, 40, 5], [34, 40, 6], [34, 40, 7], [34, 40, 11], [34, 40, 15], [34, 40, 16], [34, 40, 18], [34, 40, 33], [35, 0, 35], [35, 1, 8], [35, 1, 23], [35, 1, 25], [35, 1, 26], [35, 1, 30], [35, 1, 34], [35, 1, 35], [35, 1, 36], [35, 2, 5], [35, 2, 9], [35, 2, 11], [35, 2, 16], [35, 2, 19], [35, 2, 27], [35, 2, 29], [35, 2, 31], [35, 3, 8], [35, 3, 20], [35, 3, 23], [35, 3, 24], [35, 3, 26], [35, 3, 28], [35, 3, 34], [35, 3, 37], [35, 4, 10], [35, 4, 13], [35, 4, 17], [35, 4, 18], [35, 4, 21], [35, 4, 22], [35, 4, 32], [35, 4, 38], [35, 5, 2], [35, 5, 6], [35, 5, 7], [35, 5, 11], [35, 5, 16], [35, 5, 27], [35, 5, 33], [35, 5, 40], [35, 6, 5], [35, 6, 7], [35, 6, 11], [35, 6, 15], [35, 6, 16], [35, 6, 27], [35, 6, 33], [35, 6, 40], [35, 7, 5], [35, 7, 6], [35, 7, 11], [35, 7, 15], [35, 7, 18], [35, 7, 33], [35, 7, 38], [35, 7, 40], [35, 8, 1], [35, 8, 3], [35, 8, 20], [35, 8, 23], [35, 8, 26], [35, 8, 34], [35, 8, 35], [35, 8, 36], [35, 9, 2], [35, 9, 19], [35, 9, 20], [35, 9, 24], [35, 9, 28], [35, 9, 29], [35, 9, 31], [35, 9, 37], [35, 10, 4], [35, 10, 12], [35, 10, 13], [35, 10, 14], [35, 10, 22], [35, 10, 25], [35, 10, 32], [35, 10, 39], [35, 11, 2], [35, 11, 5], [35, 11, 6], [35, 11, 7], [35, 11, 16], [35, 11, 27], [35, 11, 29], [35, 11, 40], [35, 12, 10], [35, 12, 13], [35, 12, 14], [35, 12, 22], [35, 12, 25], [35, 12, 30], [35, 12, 32], [35, 12, 39], [35, 13, 4], [35, 13, 10], [35, 13, 12], [35, 13, 17], [35, 13, 21], [35, 13, 22], [35, 13, 32], [35, 13, 38], [35, 14, 10], [35, 14, 12], [35, 14, 22], [35, 14, 25], [35, 14, 30], [35, 14, 35], [35, 14, 36], [35, 14, 39], [35, 15, 6], [35, 15, 7], [35, 15, 17], [35, 15, 18], [35, 15, 21], [35, 15, 33], [35, 15, 38], [35, 15, 40], [35, 16, 2], [35, 16, 5], [35, 16, 6], [35, 16, 11], [35, 16, 27], [35, 16, 29], [35, 16, 31], [35, 16, 40], [35, 17, 4], [35, 17, 13], [35, 17, 15], [35, 17, 18], [35, 17, 21], [35, 17, 22], [35, 17, 32], [35, 17, 38], [35, 18, 4], [35, 18, 7], [35, 18, 15], [35, 18, 17], [35, 18, 21], [35, 18, 33], [35, 18, 38], [35, 18, 40], [35, 19, 2], [35, 19, 9], [35, 19, 24], [35, 19, 27], [35, 19, 28], [35, 19, 29], [35, 19, 31], [35, 19, 37], [35, 20, 3], [35, 20, 8], [35, 20, 9], [35, 20, 23], [35, 20, 24], [35, 20, 26], [35, 20, 28], [35, 20, 37], [35, 21, 4], [35, 21, 13], [35, 21, 15], [35, 21, 17], [35, 21, 18], [35, 21, 32], [35, 21, 33], [35, 21, 38], [35, 22, 4], [35, 22, 10], [35, 22, 12], [35, 22, 13], [35, 22, 14], [35, 22, 17], [35, 22, 32], [35, 22, 39], [35, 23, 1], [35, 23, 3], [35, 23, 8], [35, 23, 20], [35, 23, 24], [35, 23, 26], [35, 23, 34], [35, 23, 37], [35, 24, 3], [35, 24, 9], [35, 24, 19], [35, 24, 20], [35, 24, 23], [35, 24, 26], [35, 24, 28], [35, 24, 37], [35, 25, 1], [35, 25, 10], [35, 25, 12], [35, 25, 14], [35, 25, 30], [35, 25, 35], [35, 25, 36], [35, 25, 39], [35, 26, 1], [35, 26, 3], [35, 26, 8], [35, 26, 20], [35, 26, 23], [35, 26, 24], [35, 26, 34], [35, 26, 35], [35, 27, 2], [35, 27, 5], [35, 27, 6], [35, 27, 11], [35, 27, 16], [35, 27, 19], [35, 27, 29], [35, 27, 31], [35, 28, 3], [35, 28, 9], [35, 28, 19], [35, 28, 20], [35, 28, 24], [35, 28, 29], [35, 28, 31], [35, 28, 37], [35, 29, 2], [35, 29, 9], [35, 29, 11], [35, 29, 16], [35, 29, 19], [35, 29, 27], [35, 29, 28], [35, 29, 31], [35, 30, 1], [35, 30, 12], [35, 30, 14], [35, 30, 25], [35, 30, 34], [35, 30, 35], [35, 30, 36], [35, 30, 39], [35, 31, 2], [35, 31, 9], [35, 31, 16], [35, 31, 19], [35, 31, 27], [35, 31, 28], [35, 31, 29], [35, 31, 37], [35, 32, 4], [35, 32, 10], [35, 32, 12], [35, 32, 13], [35, 32, 17], [35, 32, 21], [35, 32, 22], [35, 32, 39], [35, 33, 5], [35, 33, 6], [35, 33, 7], [35, 33, 15], [35, 33, 18], [35, 33, 21], [35, 33, 38], [35, 33, 40], [35, 34, 1], [35, 34, 3], [35, 34, 8], [35, 34, 23], [35, 34, 26], [35, 34, 30], [35, 34, 35], [35, 34, 36], [35, 35, 0], [35, 35, 1], [35, 35, 8], [35, 35, 14], [35, 35, 25], [35, 35, 26], [35, 35, 30], [35, 35, 34], [35, 35, 35], [35, 35, 36], [35, 36, 1], [35, 36, 8], [35, 36, 14], [35, 36, 25], [35, 36, 30], [35, 36, 34], [35, 36, 35], [35, 36, 39], [35, 37, 3], [35, 37, 9], [35, 37, 19], [35, 37, 20], [35, 37, 23], [35, 37, 24], [35, 37, 28], [35, 37, 31], [35, 38, 4], [35, 38, 7], [35, 38, 13], [35, 38, 15], [35, 38, 17], [35, 38, 18], [35, 38, 21], [35, 38, 33], [35, 39, 10], [35, 39, 12], [35, 39, 14], [35, 39, 22], [35, 39, 25], [35, 39, 30], [35, 39, 32], [35, 39, 36], [35, 40, 5], [35, 40, 6], [35, 40, 7], [35, 40, 11], [35, 40, 15], [35, 40, 16], [35, 40, 18], [35, 40, 33], [36, 0, 36], [36, 1, 8], [36, 1, 10], [36, 1, 20], [36, 1, 23], [36, 1, 25], [36, 1, 36], [36, 1, 37], [36, 1, 39], [36, 2, 5], [36, 2, 9], [36, 2, 16], [36, 2, 20], [36, 2, 31], [36, 2, 33], [36, 2, 37], [36, 2, 40], [36, 4, 10], [36, 4, 18], [36, 4, 21], [36, 4, 25], [36, 4, 32], [36, 4, 33], [36, 4, 39], [36, 4, 40], [36, 5, 2], [36, 5, 9], [36, 5, 16], [36, 5, 18], [36, 5, 21], [36, 5, 31], [36, 5, 33], [36, 5, 40], [36, 8, 1], [36, 8, 9], [36, 8, 20], [36, 8, 23], [36, 8, 25], [36, 8, 36], [36, 8, 37], [36, 8, 39], [36, 9, 2], [36, 9, 5], [36, 9, 8], [36, 9, 16], [36, 9, 20], [36, 9, 23], [36, 9, 31], [36, 9, 37], [36, 10, 1], [36, 10, 4], [36, 10, 18], [36, 10, 21], [36, 10, 25], [36, 10, 32], [36, 10, 36], [36, 10, 39], [36, 16, 2], [36, 16, 5], [36, 16, 9], [36, 16, 18], [36, 16, 31], [36, 16, 33], [36, 16, 37], [36, 16, 40], [36, 18, 4], [36, 18, 5], [36, 18, 10], [36, 18, 16], [36, 18, 21], [36, 18, 32], [36, 18, 33], [36, 18, 40], [36, 20, 1], [36, 20, 2], [36, 20, 8], [36, 20, 9], [36, 20, 23], [36, 20, 31], [36, 20, 36], [36, 20, 37], [36, 21, 4], [36, 21, 5], [36, 21, 10], [36, 21, 18], [36, 21, 32], [36, 21, 33], [36, 21, 39], [36, 21, 40], [36, 23, 1], [36, 23, 8], [36, 23, 9], [36, 23, 20], [36, 23, 25], [36, 23, 31], [36, 23, 36], [36, 23, 37], [36, 25, 1], [36, 25, 4], [36, 25, 8], [36, 25, 10], [36, 25, 23], [36, 25, 32], [36, 25, 36], [36, 25, 39], [36, 31, 2], [36, 31, 5], [36, 31, 9], [36, 31, 16], [36, 31, 20], [36, 31, 23], [36, 31, 37], [36, 31, 40], [36, 32, 4], [36, 32, 10], [36, 32, 18], [36, 32, 21], [36, 32, 25], [36, 32, 33], [36, 32, 36], [36, 32, 39], [36, 33, 2], [36, 33, 4], [36, 33, 5], [36, 33, 16], [36, 33, 18], [36, 33, 21], [36, 33, 32], [36, 33, 40], [36, 36, 0], [36, 36, 1], [36, 36, 8], [36, 36, 10], [36, 36, 20], [36, 36, 23], [36, 36, 25], [36, 36, 32], [36, 36, 36], [36, 36, 39], [36, 37, 1], [36, 37, 2], [36, 37, 8], [36, 37, 9], [36, 37, 16], [36, 37, 20], [36, 37, 23], [36, 37, 31], [36, 39, 1], [36, 39, 4], [36, 39, 8], [36, 39, 10], [36, 39, 21], [36, 39, 25], [36, 39, 32], [36, 39, 36], [36, 40, 2], [36, 40, 4], [36, 40, 5], [36, 40, 16], [36, 40, 18], [36, 40, 21], [36, 40, 31], [36, 40, 33], [37, 0, 37], [37, 1, 10], [37, 1, 16], [37, 1, 18], [37, 1, 37], [37, 10, 1], [37, 10, 16], [37, 10, 18], [37, 10, 37], [37, 16, 1], [37, 16, 10], [37, 16, 18], [37, 16, 37], [37, 18, 1], [37, 18, 10], [37, 18, 16], [37, 18, 37], [37, 37, 0], [37, 37, 1], [37, 37, 10], [37, 37, 16], [37, 37, 18], [37, 37, 37], [38, 0, 38], [38, 1, 3], [38, 1, 9], [38, 1, 14], [38, 1, 27], [38, 1, 32], [38, 1, 38], [38, 1, 40], [38, 3, 1], [38, 3, 9], [38, 3, 14], [38, 3, 27], [38, 3, 32], [38, 3, 38], [38, 3, 40], [38, 9, 1], [38, 9, 3], [38, 9, 14], [38, 9, 27], [38, 9, 32], [38, 9, 38], [38, 9, 40], [38, 14, 1], [38, 14, 3], [38, 14, 9], [38, 14, 27], [38, 14, 32], [38, 14, 38], [38, 14, 40], [38, 27, 1], [38, 27, 3], [38, 27, 9], [38, 27, 14], [38, 27, 32], [38, 27, 38], [38, 27, 40], [38, 32, 1], [38, 32, 3], [38, 32, 9], [38, 32, 14], [38, 32, 27], [38, 32, 38], [38, 32, 40], [38, 38, 0], [38, 38, 1], [38, 38, 3], [38, 38, 9], [38, 38, 14], [38, 38, 27], [38, 38, 32], [38, 38, 38], [38, 38, 40], [38, 40, 1], [38, 40, 3], [38, 40, 9], [38, 40, 14], [38, 40, 27], [38, 40, 32], [38, 40, 38], [39, 0, 39], [39, 1, 4], [39, 1, 5], [39, 1, 16], [39, 1, 18], [39, 1, 20], [39, 1, 31], [39, 1, 33], [39, 1, 39], [39, 2, 8], [39, 2, 10], [39, 2, 21], [39, 2, 25], [39, 2, 32], [39, 2, 36], [39, 2, 37], [39, 2, 40], [39, 4, 1], [39, 4, 9], [39, 4, 16], [39, 4, 20], [39, 4, 23], [39, 4, 31], [39, 4, 33], [39, 4, 39], [39, 5, 1], [39, 5, 8], [39, 5, 18], [39, 5, 20], [39, 5, 25], [39, 5, 31], [39, 5, 32], [39, 5, 39], [39, 8, 2], [39, 8, 5], [39, 8, 18], [39, 8, 21], [39, 8, 25], [39, 8, 32], [39, 8, 37], [39, 8, 40], [39, 9, 4], [39, 9, 10], [39, 9, 16], [39, 9, 21], [39, 9, 23], [39, 9, 33], [39, 9, 36], [39, 9, 39], [39, 10, 2], [39, 10, 9], [39, 10, 16], [39, 10, 21], [39, 10, 23], [39, 10, 36], [39, 10, 37], [39, 10, 40], [39, 16, 1], [39, 16, 4], [39, 16, 9], [39, 16, 10], [39, 16, 23], [39, 16, 33], [39, 16, 36], [39, 16, 39], [39, 18, 1], [39, 18, 5], [39, 18, 8], [39, 18, 20], [39, 18, 25], [39, 18, 31], [39, 18, 32], [39, 18, 37], [39, 20, 1], [39, 20, 4], [39, 20, 5], [39, 20, 18], [39, 20, 31], [39, 20, 32], [39, 20, 33], [39, 20, 39], [39, 21, 2], [39, 21, 8], [39, 21, 9], [39, 21, 10], [39, 21, 23], [39, 21, 36], [39, 21, 37], [39, 21, 40], [39, 23, 4], [39, 23, 9], [39, 23, 10], [39, 23, 16], [39, 23, 21], [39, 23, 33], [39, 23, 36], [39, 23, 40], [39, 25, 2], [39, 25, 5], [39, 25, 8], [39, 25, 18], [39, 25, 31], [39, 25, 32], [39, 25, 37], [39, 25, 40], [39, 31, 1], [39, 31, 4], [39, 31, 5], [39, 31, 18], [39, 31, 20], [39, 31, 25], [39, 31, 32], [39, 31, 39], [39, 32, 2], [39, 32, 5], [39, 32, 8], [39, 32, 18], [39, 32, 20], [39, 32, 25], [39, 32, 31], [39, 32, 37], [39, 33, 1], [39, 33, 4], [39, 33, 9], [39, 33, 16], [39, 33, 20], [39, 33, 23], [39, 33, 36], [39, 33, 39], [39, 36, 2], [39, 36, 9], [39, 36, 10], [39, 36, 16], [39, 36, 21], [39, 36, 23], [39, 36, 33], [39, 36, 40], [39, 37, 2], [39, 37, 8], [39, 37, 10], [39, 37, 18], [39, 37, 21], [39, 37, 25], [39, 37, 32], [39, 37, 40], [39, 39, 0], [39, 39, 1], [39, 39, 4], [39, 39, 5], [39, 39, 9], [39, 39, 16], [39, 39, 20], [39, 39, 31], [39, 39, 33], [39, 39, 39], [39, 40, 2], [39, 40, 8], [39, 40, 10], [39, 40, 21], [39, 40, 23], [39, 40, 25], [39, 40, 36], [39, 40, 37], [40, 0, 40], [40, 1, 1], [40, 1, 40], [40, 40, 0], [40, 40, 1], [40, 40, 40]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/check.py b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..6345846c9b9114bf209db5350d6863485823b433 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/check.py @@ -0,0 +1,47 @@ +"""Finite-field Nikodym set N in F_p^3, submitted as its complement. Score = |N| (minimize). + +Every point x of F_p^3 needs a direction v != 0 with x + t v in N for all t != 0 (x itself may lie outside N). +Upstream (AlphaEvolve `finite_field_nikodym.ipynb`) deduplicated silently; here the complement list must be +duplicate-free and in range. All p^2 + p + 1 projective directions are checked, vectorised over all points. +""" +import itertools + +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + p, d = inst["p"], 3 + rem = ans.get("removed") + if not isinstance(rem, list): + raise Invalid("removed must be a list") + if len(rem) >= p ** d: + raise Invalid("cannot remove every point") + w = np.array([p * p, p, 1], dtype=np.int64) + R = np.array([int_list(x, d, 0, p - 1, "point") for x in rem], dtype=np.int64).reshape(-1, d) + codes_r = R @ w + if len(np.unique(codes_r)) != len(codes_r): + raise Invalid("duplicate removed points") + in_n = np.ones(p ** d, dtype=bool) + in_n[codes_r] = False + X = np.stack(np.unravel_index(np.arange(p ** d), (p,) * d), axis=1).astype(np.int64) + good = np.zeros(p ** d, dtype=bool) + need = p - 1 + in_n.astype(np.int64) # points of N on the line through x, other than x, must number p-1 + done = False + for i in range(d): + for tail in itertools.product(range(p), repeat=d - 1 - i): + v = np.array([0] * i + [1] + list(tail), dtype=np.int64) + lid = ((X - X[:, i:i + 1] * v) % p) @ w + cnt = np.bincount(lid[in_n], minlength=p ** d) + good |= cnt[lid] == need + if good.all(): + done = True + break + if done: + break + if not done: + x = np.flatnonzero(~good)[0] + raise Invalid(f"point {X[x].tolist()} lies on no punctured line inside N") + size = p ** d - len(rem) + return size, {"size": size} diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/instance.json b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..78063ede7fc19504e636b12820ca0bd38968aeab --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/instance.json @@ -0,0 +1 @@ +{"p": 41, "direction": "minimize", "baseline": 68921, "best_known": 61704, "family": "ae_p1_ff_nikodym", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/run.py b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/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-nikodym-d3-p41/tests/test.sh b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p41/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-p59-isosceles-free-grid-n64/environment/Dockerfile b/tasks/optimize-ae-p59-isosceles-free-grid-n64/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p59-isosceles-free-grid-n64/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-p59-isosceles-free-grid-n64/environment/instance.json b/tasks/optimize-ae-p59-isosceles-free-grid-n64/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..baa2f70b4c2d21774ef112e4b1e9afb41d6c6e22 --- /dev/null +++ b/tasks/optimize-ae-p59-isosceles-free-grid-n64/environment/instance.json @@ -0,0 +1 @@ +{"n": 64, "direction": "maximize", "family": "ae_p59_isosceles_free_grid", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p59-isosceles-free-grid-n64/solution/solve.sh b/tasks/optimize-ae-p59-isosceles-free-grid-n64/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6366409afa1e72f240ff185135c8b34c428b78d2 --- /dev/null +++ b/tasks/optimize-ae-p59-isosceles-free-grid-n64/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": [[58, 56], [55, 2], [58, 1], [61, 52], [1, 40], [14, 7], [58, 62], [63, 25], [5, 1], [58, 7], [58, 25], [38, 56], [25, 56], [49, 56], [25, 1], [2, 11], [24, 11], [38, 62], [61, 27], [38, 7], [49, 7], [61, 36], [57, 17], [39, 11], [56, 61], [45, 61], [0, 38], [1, 33], [47, 0], [6, 17], [8, 2], [10, 63], [0, 62], [59, 26], [1, 2], [16, 0], [18, 61], [7, 61], [52, 26], [11, 22], [62, 3], [53, 0], [55, 61], [52, 41], [11, 37], [62, 30], [57, 46], [2, 52], [63, 38], [24, 52], [58, 17], [6, 46], [24, 58], [39, 52], [59, 37], [16, 63], [63, 62], [62, 60], [5, 38], [52, 37], [2, 27], [5, 56], [62, 23], [2, 36], [17, 0], [5, 62], [8, 61], [5, 7], [10, 0], [1, 61], [5, 25], [46, 63], [25, 62], [25, 7], [24, 5], [1, 3], [38, 1], [58, 46], [11, 26], [58, 38], [39, 5], [1, 30], [5, 46], [11, 41], [14, 58], [17, 63], [61, 11], [62, 40], [57, 1], [0, 1], [1, 60], [57, 62], [6, 1], [49, 58], [6, 62], [1, 23], [0, 25], [56, 2], [45, 2], [47, 63], [14, 5], [62, 33], [5, 17], [46, 0], [39, 58], [7, 2], [18, 2], [52, 22], [49, 5], [63, 1], [53, 63], [14, 56]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/check.py b/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..cfcfd7aba30ca03b3dccafd9ecd2dedab8e57a41 --- /dev/null +++ b/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/check.py @@ -0,0 +1,25 @@ +"""Largest subset of the n x n grid with no (possibly flat) isosceles triangle (AlphaEvolve problem 59). +Exact: for every point b, the squared distances from b to all other chosen points must be pairwise distinct.""" +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + pts = ans.get("points") + if not isinstance(pts, list) or not (1 <= len(pts) <= 4 * n): + raise Invalid(f"points must be a list of 1..{4 * n} [x, y] pairs") + p = [tuple(int_list(q, 2, 0, n - 1, "point")) for q in pts] + if len(set(p)) != len(p): + raise Invalid("points must be distinct") + a = np.array(p, dtype=np.int64) + d = ((a[:, None, :] - a[None, :, :]) ** 2).sum(-1) + for i in range(len(p)): + row = np.delete(d[i], i) + vals, cnt = np.unique(row, return_counts=True) + if (cnt > 1).any(): + dup = vals[np.argmax(cnt > 1)] + a2 = [p[k] for k in range(len(p)) if k != i and d[i, k] == dup][:2] + raise Invalid(f"isosceles: {a2[0]} and {a2[1]} are equidistant from {p[i]}") + return float(len(p)), {"size": len(p)} diff --git a/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/instance.json b/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..635b6a9a478784a38d2847f19c4d5d8f067aabd4 --- /dev/null +++ b/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/instance.json @@ -0,0 +1 @@ +{"n": 64, "direction": "maximize", "best_known": 112.0, "baseline": 74.0, "family": "ae_p59_isosceles_free_grid", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/run.py b/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p59-isosceles-free-grid-n64/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-p59-isosceles-free-grid-n64/tests/test.sh b/tasks/optimize-ae-p59-isosceles-free-grid-n64/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p59-isosceles-free-grid-n64/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-p60-no5-on-sphere-n11/environment/Dockerfile b/tasks/optimize-ae-p60-no5-on-sphere-n11/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n11/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-p60-no5-on-sphere-n11/environment/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n11/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a14b8aad2a048a65ae780e7eaab62a010452ffbb --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n11/environment/instance.json @@ -0,0 +1 @@ +{"n": 11, "max_points": 44, "direction": "maximize", "family": "ae_p60_no5_on_sphere", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n11/solution/solve.sh b/tasks/optimize-ae-p60-no5-on-sphere-n11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d1e6692908f654ada6e170e57706d964d70f23e9 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n11/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": [[5, 2, 2], [1, 2, 9], [5, 7, 3], [9, 7, 10], [3, 8, 0], [0, 3, 2], [2, 7, 9], [7, 5, 1], [8, 2, 6], [5, 9, 7], [7, 1, 0], [2, 9, 9], [1, 0, 2], [10, 5, 8], [8, 9, 8], [10, 10, 6], [10, 0, 9], [6, 1, 8], [10, 4, 1], [1, 10, 4], [9, 0, 1], [9, 8, 5], [0, 1, 3], [9, 9, 0], [0, 8, 1], [4, 3, 7], [7, 5, 7], [8, 2, 10], [0, 10, 0], [2, 10, 10], [1, 6, 6]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/check.py b/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..535715270fb95983b4b3896cda93a8746da1a961 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/check.py @@ -0,0 +1,53 @@ +"""No 5 points of an n x n x n grid subset on a common sphere or plane (AlphaEvolve problem 60). + +Exact int64 test: five points are co-spherical/co-planar iff det[x, y, z, x^2+y^2+z^2, 1] = 0, evaluated as the +4x4 determinant of differences (entries <= 3(n-1)^2, so |det| < 2^40). Upstream used float det + np.isclose.""" +import itertools + +import numpy as np + +from run import Invalid, int_list + + +def det4(m): + a, b, c, d = m[:, 0], m[:, 1], m[:, 2], m[:, 3] + + def det3(r0, r1, r2, i, j, k): + return (r0[:, i] * (r1[:, j] * r2[:, k] - r1[:, k] * r2[:, j]) + - r0[:, j] * (r1[:, i] * r2[:, k] - r1[:, k] * r2[:, i]) + + r0[:, k] * (r1[:, i] * r2[:, j] - r1[:, j] * r2[:, i])) + return (a[:, 0] * det3(b, c, d, 1, 2, 3) - a[:, 1] * det3(b, c, d, 0, 2, 3) + + a[:, 2] * det3(b, c, d, 0, 1, 3) - a[:, 3] * det3(b, c, d, 0, 1, 2)) + + +def lifted(p): + a = np.array(p, dtype=np.int64) + return np.concatenate([a, (a * a).sum(1, keepdims=True)], axis=1) + + +def bad_five(rows, combos): + """rows: (m, 4) lifted points; combos: (N, 5) index array. Returns mask of degenerate 5-sets.""" + base = rows[combos[:, 0]] + m = np.stack([rows[combos[:, i]] - base for i in range(1, 5)], axis=1) + return det4(m) == 0 + + +def check(inst, ans): + n = inst["n"] + pts = ans.get("points") + if not isinstance(pts, list) or not (1 <= len(pts) <= inst["max_points"]): + raise Invalid(f"points must be a list of 1..{inst['max_points']} [x, y, z] triples") + p = [tuple(int_list(q, 3, 0, n - 1, "point")) for q in pts] + if len(set(p)) != len(p): + raise Invalid("points must be distinct") + rows = lifted(p) + it = itertools.combinations(range(len(p)), 5) + while True: + chunk = np.array(list(itertools.islice(it, 200000)), dtype=np.int64) + if len(chunk) == 0: + break + bad = bad_five(rows, chunk) + if bad.any(): + q = [p[i] for i in chunk[np.argmax(bad)]] + raise Invalid(f"points {q} lie on a common sphere or plane") + return float(len(p)), {"size": len(p)} diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..112bcd95244ee7e927215ce1625fb2fb904ea5f1 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/instance.json @@ -0,0 +1 @@ +{"n": 11, "max_points": 44, "direction": "maximize", "best_known": 31.0, "baseline": 24.0, "family": "ae_p60_no5_on_sphere", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/run.py b/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n11/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-p60-no5-on-sphere-n11/tests/test.sh b/tasks/optimize-ae-p60-no5-on-sphere-n11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n11/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-d12-n841/environment/Dockerfile b/tasks/optimize-ea-kissing-d12-n841/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ea-kissing-d12-n841/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-d12-n841/environment/instance.json b/tasks/optimize-ea-kissing-d12-n841/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58c62207cb732ee603e82b3198b4aa2f2f1f61f5 --- /dev/null +++ b/tasks/optimize-ea-kissing-d12-n841/environment/instance.json @@ -0,0 +1 @@ +{"dim": 12, "n": 841, "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-d12-n841/solution/solve.sh b/tasks/optimize-ea-kissing-d12-n841/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0e04ec04713274704a502e09a9fff3c40ae5400b --- /dev/null +++ b/tasks/optimize-ea-kissing-d12-n841/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.22302373310752313, 0.6090589409547944, -0.6441281111669875, 2.1818906760860215, 0.40531334264266516, -0.21829197052256583, -0.07398476420820972, 0.12732085638205887, -1.4132862545992337, -0.2516190326530338, -0.8994184545120851, -0.11476843022966886], [-0.5221876064177098, -0.3924073935352479, 0.594848954536214, -1.4572838240713941, -1.5083921776454479, 0.9734304342929335, 1.4860388112677316, 1.3544101695514617, -0.418450524109105, -0.7857134684258373, 1.5425111762751287, -1.3896936422113784], [-1.52569644491241, -1.9027211293176154, -0.05990236505381943, 0.44414866667491326, -1.542243394310458, -1.3814090240072754, 0.802337209194738, 0.18845920253881687, -0.21035910913390124, -0.4645081951767893, -0.15103051265682702, -1.0619645034092535], [1.076739895652889, -1.2030621515405262, 0.15475338208381903, 0.9114921022392969, 1.33090132940633, 0.3138358644153611, -0.6711548911149889, 1.9149589746497646, -0.7886138079960587, -0.5736292189069525, -0.7804224876061604, 0.9484840021789874], [-0.26765254256012483, 0.07618021073933158, -0.1689056717943088, -0.9945294959931013, -0.593742580336772, -0.30949307474319315, -0.20113040752899383, 0.32121027414838416, -0.2020391603226009, 1.03224903570563, 0.06963892484518247, 0.12578231789216415], [-1.5932242429253274, 0.4957640871534371, 0.36070781099834875, 1.3264611633255765, -0.7485800338574221, 2.1252289647107867, -0.36688989230759905, 0.2769231994834843, -0.18182284795239767, -0.7807546479533627, 1.8311130903232054, 0.5990580146824069], [0.37981821260571635, -0.5233178669898121, 0.4508642296574557, -1.0337751997863864, -0.21984408178187137, 0.3803876465693916, 0.18308461136499762, -0.7862473337278151, -0.8843701614059954, -0.5127070733170167, -0.5345240818560931, -0.919505582064579], [0.20721763054840034, 0.18621895894739557, 2.401424731225888, -0.9775573627875302, -0.5122429898518037, -0.6048696223423242, 0.6347988442878468, 0.10589635695712737, -1.2370077446110466, -0.3900885305525113, -0.23819948305901756, 0.11769007675328347], [1.3481267228237837, -0.4571105595965796, -0.20910301861756253, -0.1710663977280985, -0.06465362059171703, -1.1897904267757102, 0.751340119049277, 0.11529062539850216, -0.1806719548803652, -2.4977468600260937, -0.13334384601435945, -0.6952178324396561], [0.23503106073523117, 0.8191634607093491, -0.17402872688309975, 1.137212184485683, 0.07566842786822665, 1.7490462393696806, 0.7410271971103163, 2.7117901069997012, 2.1439577360752375, 0.6241486649098387, 1.3287573940227086, -1.0437122979806783], [0.6130654873516153, -1.2012491750910983, -1.2107157148819052, 0.8087875625775861, 0.43318587561450816, 0.005211548585954207, -0.7345727104554426, 0.6191433826559808, -0.09895810577673557, -0.6507185463452264, -1.320162374434866, 0.0792224926204942], [0.36574605575219094, -0.31623873083852333, 0.8467071064827842, 0.6138906944326791, 0.19352968822949237, 0.054610005919616844, 0.11087119693203985, 1.1450650680879162, 1.3584147410688254, 1.9945937505464713, 0.14711777596225126, 1.4903545426002789], [-1.32020123835593, -0.52272509612959, 1.0997179260557761, -0.6241214149920526, 0.283618437242767, 0.8236692093727167, 1.3576395604141556, 1.2832157893342588, 0.8574943342836809, 1.489795783022274, -0.9109817487373378, 0.9530863923481941], [0.27998275025086194, 0.42897994391220173, -2.2862884783612745, -0.05085778403603915, 0.3739264737344403, 0.7362074043612595, -0.18981780763134892, 1.3697305120015864, -0.8697662965282306, -0.6122894033289918, 1.4235579293717278, -0.5849831877319778], [-0.8560597468770788, -0.597212434931096, -1.5084596412913422, -1.0376704402956733, 0.134105569261838, 0.33589521745744527, -0.4641648763583013, -0.5961773229682542, 0.5959506968751187, 1.680041653182771, -1.1139154024099394, -2.355163092314675], [0.46836208890114955, 0.36702063317574063, -0.6154410398429226, 1.2186190701998174, 1.2159819677715946, -0.5833281601318792, 0.617307651827373, -0.9736494135335929, 1.4039023433199846, 0.7784084178777696, 0.29718512055600976, 0.6861070703563227], [-0.2292898624996615, -1.0974453694372082, 0.278225930162673, 0.03059575110460518, -0.839419259825282, 0.579800201548236, 0.7791297789016169, 0.19691008147552197, 1.7633859342327023, -0.5694157970442953, 0.8344054419748271, 1.1000234375741638], [0.6767882951239993, -0.7745344201079087, 0.09380843730889103, 1.9710648917368607, 1.4960002421421978, 0.038713643687153694, 0.21113702205808363, 1.2269482164495447, 0.7480237160066882, 0.4351474372131549, 0.03076678431174548, 0.8549003217712711], [1.5495419839934816, -1.3771636123908741, 2.8269907977891435, -0.763173644100103, -0.3657703825532724, 0.4818856690655315, -0.3092241995610545, 0.24685077697149532, -0.3417668238974513, 1.2218867157014657, 0.2177570020106135, -0.48541477259226223], [0.613033399554094, -1.4810517047152734, 0.671816694647118, 1.2817423655460347, 1.5047689745794441, -1.7049967404885606, 1.9565458647408265, 0.11649684899071053, -0.02292289836514996, 1.1216328609594077, -0.4964459780363665, 0.6818731985431902], [1.0162366273610217, 0.05308236524021641, 0.8309055290967883, 1.3729312652896097, 0.6584866200738849, 1.5113152328064718, 4.175295580775037, 0.6648058547965219, 0.11326523109416849, -1.6416791204649754, 1.006722373320929, 0.007135158888813271], [-0.3369566832951232, -0.05224388774390734, 0.2608480132340426, -0.2856362802433601, 0.4206031634941886, 0.4675491067978939, 1.1235180203028061, 0.5057479414790416, 1.1429269581101231, 0.12082797947828501, -0.8776473622366417, -0.024499042105523457], [0.8814310149188023, -0.2599309549970665, -0.3690787492546234, 1.1383862408748049, 0.6019931891293203, 0.571240677781647, 1.3810978835736876, 1.099260670828157, 0.9169829016662836, -0.8478116827262215, -0.49395460286771786, -1.0520662834002072], [0.4027266181478944, 1.1312718519889373, 1.4551140265586433, -1.516470690408871, 0.52550594115486, -0.329089935141722, 0.919947103111723, -0.30060887739478315, -0.28610997318252, 0.762130300706122, -0.6955241683976471, -1.166760550211386], [0.27463340968431027, 0.5004295372484865, 0.7612932869186609, -0.15163627348391304, -0.4319342726962059, 1.5685026450527826, -0.03287661355610324, 0.2181270493799977, -0.4081975631126169, -1.0753290574791001, -0.03838773885199351, 1.0235108462674987], [1.0561513231562931, -1.0637371840047802, 1.1850718742804058, 0.5945279227580026, 1.2078543511765878, -2.8513713785171597, 0.42018957920232064, 2.6440223123218836, -0.7206411675957372, -0.17083032423585642, 0.45855268619217376, -0.2310440707440537], [1.1968536846962574, -1.6645095242733057, 0.26251410490720006, 0.45113125681361593, -2.755585650625305, 0.3018150658895082, -0.9581353200591854, -0.17648483456939262, 1.0900189403879637, 0.31434183683550326, -0.48735249700919636, -1.1906168398806352], [-0.7468238704101124, 0.6369641224075033, 1.3350158580177967, 0.7509232134120671, 0.20426452021114305, -0.42407228886434545, 0.8977301698619916, 0.6421029569914518, -1.1565471138572525, -0.20655980616043024, 0.4881005106019497, 0.6107170863962682], [-1.3141693572253366, -0.786543911206194, 0.5755640343687102, -0.10946092647086016, 0.6465013941987807, 0.3473340169305628, -0.2268127974042677, -0.42727914967324754, 1.2912372273252075, 0.6154389997127999, 0.08271189622917963, -1.3734742188433242], [0.9307106318942314, -0.6431320251061694, 0.8549872747456213, -0.32292055606484704, -0.6373512051514004, 1.2555606821357357, 2.4853395854561207, -1.2920351756137418, -0.08987419296663765, 1.092106381326616, -1.1611792405342345, 0.5577028273512167], [-0.3768760908476012, -0.2421880813892704, 0.2647450472925837, 0.1536514794310597, -0.27070683870427076, -0.09002085791416305, 0.8272745824084818, 1.1936396856570888, 1.2688692262258445, -0.061947419984098584, -1.8379964909084179, -0.39594649510911956], [0.7981293996786147, 0.0840429585565921, 0.6378131048379605, -0.25020277123099466, -0.5091191999541242, 0.052676125698274213, 0.6128977784413772, 0.5021950032806042, -1.0704464478491, 0.18366333659162543, 0.761299480219714, -0.7831762206483414], [1.1407130303497668, -0.9801229828684832, 0.965244528748475, -0.45561643190454526, 0.18926980712392322, 0.3305750042712936, -0.3025422636610257, -1.7036980177670347, -0.0544135698104016, 0.13898079590563037, -0.9092499654262667, 0.5355142477800747], [0.9090163078071232, -0.9089339148779464, -0.6357890919081371, 0.2239887799074518, -0.059719126807958746, 1.649733987644668, -0.29967252434518543, -0.47671144973264834, -0.688573219896076, 0.8881628422067906, 1.3766063319004467, 0.30105688945838077], [-0.9658855816585435, -0.2080367158387087, 0.5044845654701203, -0.9674091040694838, 0.31670047732582557, 0.3090169704130479, 1.1195824929850797, 1.3356973778303545, -1.6808909736585378, 1.1463681166116355, 0.02376164924786507, -0.1791460300687344], [0.7316095250849649, -0.9462782664173844, 0.9741580666527536, 0.3690967095015603, 0.3683446039434429, -0.26446473221524086, 0.9094837487218256, 2.056574842783507, -0.1415517988784517, 1.4930517453447611, -0.7247813515607069, -0.4333932675391783], [0.028065679579948693, -0.8117786143648804, 1.616767103564779, 0.2592328042064696, -1.6232463946742195, 1.8361950907895932, 0.8216721289727833, -1.9033001142778394, 1.461919744787424, -0.07408912800816239, -0.7393710537935282, 1.0565226608769351], [-0.2966651014802045, -1.5645088763115425, 0.007549255728162552, -0.09279774495436155, 0.38599853595875744, 0.5236691890459635, 0.025447188909314706, 0.13392350989301227, 0.32488457520867625, 0.8236730852780739, 0.12493634878147906, 1.018774421411586], [-0.7829825757584299, 0.5604634179880909, -1.1117622677904562, -2.093691089125926, 0.9862640162573365, -0.5129775337473399, 0.766257674887092, 1.7142918110457348, -1.1499836419863936, 0.6442882770856715, -0.29744818257370204, -0.6947721902093571], [-0.761230330913673, -1.7600279606695972, -0.8061849960596038, -0.9294186278076633, 0.4819505994481384, -1.324976233322199, -1.378512088615034, 1.3467305756807797, -1.080436694688718, 0.12450438555026613, -0.8649725333098084, 0.16586212054853136], [-0.1574756776439811, -0.12217257628948465, 0.14385432500666542, 0.34055577518664887, -1.0764212959995696, 0.2690559108269729, -0.30705700634152944, -1.593144065748968, 0.3830733914504855, 0.3700307982464187, -0.3010532155078661, 0.5440360692872459], [0.36823285307069464, -0.0036511557407960965, -0.11615151162687472, 1.3049278435897846, 0.23546156155734024, -1.7757771317963276, -0.6468898199354018, -0.8751231651200359, 1.3454601149033802, 0.8201202979185206, 2.2070087405776087, -0.41757343207354186], [-0.4481283247943572, 0.19894880199668377, 0.5954221819766925, 1.2193918819199572, 0.0858283640847238, -0.7400087361210204, 0.7155902555107199, 0.6129448422250036, 2.6804749567611523, 1.3779278076372414, -0.0815694270763528, -0.5175297950909048], [-0.1624372154658625, -0.2837682759911462, -0.9241356761123989, -0.7645253593248966, 0.20552335866204363, 0.29426685058625074, 0.1193886128614371, -1.268038525739001, -0.9605039594217593, -1.374910962701623, -1.054814966301299, -0.11076153088287169], [0.15061286025925832, -1.5904464806932344, -0.5291662177644766, 0.42303863319149887, -0.5900636148131109, 0.5673303044844668, -1.1224150986854753, -0.11567692670919977, -0.40189879821463015, 0.20346802172674125, 0.6536426387254001, 1.0453864577021053], [0.052119274187118717, 0.8131301739849328, 0.303944353808941, 0.0511984456912965, -2.2218967648650123, -0.1503295482286157, -0.309577457930835, -0.3493568572681456, -1.980001853440305, -1.704443370213834, -0.29094444704141104, 1.4647325982430714], [-1.3742309991308506, 0.08461167700747417, 1.209195909378266, 0.4925259051229931, -1.570713752024195, -0.02356113263500201, -0.9395583058342037, 0.19760690649090104, 0.5111491435448776, -0.2148272867332389, -0.6101384180304598, -0.030470832638095753], [-0.006240270933672979, -1.1132146580735722, 0.26762894836799755, -1.4399879317613897, 0.5483416237349918, -0.16803992164915807, -0.7698345443940277, 0.7520628019227181, -0.4321418552690437, -0.26021257471963966, 0.4047969938450091, -1.5218676284700252], [-0.4960171358800564, -1.65639935704768, -1.462102752168211, -0.6284332687645032, -0.8441562192276699, -0.5273134434535622, 1.3347306257327285, 1.853147965498757, 0.2654096693854172, 0.4071226656805908, -0.676165722523588, -0.3529347173108404], [-0.132857816533258, -1.6620152443388712, 0.7718591869541312, -2.5487468132499758, 0.4893686485867046, 1.2395740876133832, -0.1037282079715462, 0.3742364921754454, -0.05522239928437999, -1.0503974284702509, -0.005086221550186437, 0.46022177765384886], [-0.24891499255867316, 0.9785706101665066, -1.0275409631344918, 1.401949233661363, 0.29460717150575894, -0.2194696019352634, -0.8738407107173982, 1.1716519918290156, -1.5458285894930381, 0.14180262888883186, 1.1291090054356285, 0.4341624666447459], [0.12456762743515647, 0.7766699347457714, 0.09313583832045598, 0.6612149678088886, 0.679268242087391, 0.6189998617457555, 0.23326081273471425, -0.8741803487811484, 0.4670006549972482, 1.5734264541541485, -0.40537340524624726, 0.532050037706416], [-1.290601911190183, 1.8431674149339408, -0.9191130053942967, -0.2697323265706807, 0.9253596648139074, -0.27929987844027176, -1.0424265863746143, 0.3215887389943584, 0.13932295340528847, -0.7326190876584455, 1.9623790648634418, -1.517442720273267], [-0.06719491947638702, 1.0905540189537606, -0.3608655063024916, -0.7543870983206267, 0.9889055833825149, -1.483563423496649, -0.5440969635244827, -0.8674300841847424, -0.06269521952045974, -0.3531306844765559, -0.9048256401233598, 0.16506090161019563], [0.9444582908696408, -0.9341651376516423, -1.9180250529252327, 0.7668659326996624, 1.9054381733616097, 0.11818350092287275, -0.9932614985545901, 2.080938238816864, 1.2551429200671576, -0.23044044773398953, 0.7442875657752005, -0.14576321599804995], [0.46329303221218604, -0.4365948808492327, -0.09017608434594751, 0.6129183168841046, 0.30868996596612713, 0.13963429316688217, -0.32950771632058257, -2.7206988123127944, -0.8509387270188152, -1.3901014749253489, 0.6341385140800587, 1.3254345946264543], [-0.42042924848288854, -1.3962088110780224, 0.8348205866632771, 0.9461445188880572, -0.5297104580018832, 1.0730803545224328, -0.6319805716346137, 1.306873854376529, 0.7900121878435723, -0.16046064956770356, -0.5760666628496233, 0.7594911149720613], [1.794075694439506, -1.9370160591091055, 0.8162367619915185, 1.3106557706810702, -0.1781636537707154, 0.12421657815243489, 0.2288230863418688, -0.7586746604747122, -0.8387349470476372, -0.17597229306030912, -1.171072883905406, -0.5646051462384419], [-0.8015584996302794, 1.620634243379289, 0.7881222515061466, 0.3450662142262621, -0.5725564616478857, 0.8061800350099888, 1.0335842055717976, -0.6803825391003696, -1.0273199098602868, 0.6917643191026391, -0.5811814992929435, -0.5682966684473019], [0.3712593912822961, -2.291114146953443, -1.1035258841108126, 0.778272163309191, 0.7667340471360077, 0.16419766776708317, -0.37209669620636304, -1.9997371250338507, -0.23978042573559738, -0.13753158672809734, 2.169060243336983, 1.075789359992455], [-1.3679980414338444, -3.0155122973714206, -0.1309878359757315, -0.6143240255329007, -0.4554401678124257, 1.0140615756412559, 2.3586008532852762, -0.5957224287654271, 0.6486598802313643, -1.3766797563474205, 1.3639779885207899, -0.1254719581233004], [0.3632457873682343, -0.4805622201226766, 0.901677047801987, 0.4621815541539361, -0.5659984844467083, 0.46243433997284156, 0.09470762005972351, -0.6742336001751233, -2.6928067275886574, 2.389318892795645, -0.4320794252173358, -0.651356411379402], [0.8060524683273395, -0.7241573842138209, 1.393066933070633, -1.5056338907570046, -2.1968149708460953, -1.254248988057774, 1.2089276900338355, -0.16140836256206856, -1.7476688165482825, 0.029856346018545015, 1.556081929867912, -0.984901502333194], [-0.01198778655130212, 1.099490854139648, -0.9599121049476992, -0.08622628942869857, 2.311092591625544, 0.5274629147951169, -1.5438409991889948, -0.6045859376293119, -0.5563722657210878, -0.33718919271469366, -1.249786345272484, 1.0897101886701648], [0.3420781155202112, -0.005203076754260242, 0.1502113966809098, 0.41897623240104886, -0.7106811182872068, -1.9861466755201376, 0.4731309606384831, 0.022952823077689234, -0.5997630001081381, -0.9483855551940292, -1.5577674371691157, 0.4477403295696631], [-0.3246191116766525, -0.490565961378904, -1.561046505860838, -0.09755692709336, -1.6981049780968653, 0.28138980015147225, -0.5045166412781045, -0.5133081312794724, -2.0183538855542715, 0.2553604055941337, -0.4067832646464339, -1.5028526397425552], [1.1155772797463572, 0.34559889253869674, -2.7576607032370575, 1.0274132643389229, -0.09373454784742549, -0.5510978049631446, 1.0358367233669934, 0.840938611752638, -0.6359759596870076, 0.9751325886941228, -1.234460481476936, -0.4351419726874056], [1.3662576631484573, -1.0461098902960169, -0.5753138205399282, -0.745665462898497, -1.081267307085834, 1.0800603821398445, 0.5645556627064625, 0.728570666542351, 0.6973170091092123, -1.0695231835321082, 1.0104114669117243, -0.39896169550073657], [0.04758415337550035, 0.010959750670994913, -1.4098753318983404, -0.882489136864278, -0.9990993992794469, -0.8255660855191079, -0.14016902699048828, 0.23073545533900908, -1.000190143834687, 0.7632968926758001, -1.5959131536671656, 1.0612574370430836], [-0.42820839472017086, 0.6973904014871314, -0.3551841256814504, -1.061162652197517, -1.7169040689574828, -0.0015572427619264231, 0.7975085085428716, -1.9559220087524187, 0.33636976759739695, -0.7711225309938778, -0.23302090419370006, 1.0054363702180455], [1.1049549312048117, -0.4166803112308668, -0.603451109102987, -0.44808198573938457, -0.6317887556055286, -0.8530150574388279, -0.005013407654962592, -0.4399107375346096, 2.5220759066271734, -0.34242446488332123, -0.20688056559037235, -0.7499600812166844], [-1.0462654989485072, 1.5934184991193172, 0.573745673239826, 0.7926651428639776, 0.6953888259729822, 1.338678954837781, -1.3288157470912678, -0.20729333772579472, 1.2066970381887714, -0.5953184046736607, 1.8877164268957498, -0.15535060063448797], [0.12951571838717277, -0.4992776200116198, 0.7337283381392005, 1.2757573744814397, -0.1102813014151074, 1.0524365993149707, 0.6758673598786916, -0.18262346454323633, -0.803782805841206, 0.26677496702112097, -2.283317907729788, 1.3257210277305613], [-0.1940202559447346, 1.0434015588343966, -0.9991843133582153, 0.040126021633241644, -0.267340633585617, -1.0850913751527294, 0.8701023816230491, -0.8121550588335221, 1.2322270793866132, 0.05626734651972464, 0.16613470571156622, 0.3621571168387757], [-0.1256798402890819, -0.10757486936673857, 0.12139000548451673, -1.3465127811910422, -0.8632837971119416, -0.1081602734475887, 0.29091134842885963, 0.6307342283462285, -0.8045431519961376, -0.2335495403436735, 0.29093084660736085, 0.9221160365254664], [0.48763199041796884, -0.44002893183106845, -2.000338917160579, -1.0315070374380508, 0.25995569638539173, -1.3347832163062554, -1.030146870326206, -2.0014545524960656, 0.6083980639237575, 1.889344856289141, -0.03018025621734148, -1.8074942569449757], [1.485682530281225, 0.9487422647259498, 0.3310246961308096, -0.7215550961480915, -0.06847182434806333, 2.180508069997189, -2.0147169041158888, -0.38731887516665364, -3.168160278456451, 1.8917082541922454, -0.09093259360815249, -0.21844402430269727], [-1.2144052223109554, 1.8149631952662237, 0.6027438647154642, -0.3847132630735727, -1.1669390934052548, -1.1689488201776284, 0.15855043244593078, 0.18117704991097824, -1.006400076617669, 0.18600056279862734, -1.1363887437626794, -0.7489320242683855], [-0.21401018205643488, -1.4933106305121675, -0.3622944364567592, -0.4098434255325398, -1.731018717314719, 0.15844441360861267, 0.6154816212540763, 1.4089385232688358, -0.35635842445311616, 1.3006799114173249, 0.6265057732363238, -0.5378675336632306], [1.495695442885983, -1.652912369082648, 0.4195232456691084, 0.41780463635850784, -0.526669421837116, 0.8801502730486077, -0.23681462658779642, 0.06362374178780056, -0.6229699802291593, -0.6128691506105013, -0.8555433587128434, -1.363826822525379], [1.2112865389078127, 0.46818506067767646, -0.7772165767297028, 0.05210499091258248, 0.24079476401594216, -1.7629151755939696, -0.7551328825125976, -0.09054330851359933, -0.5205355982527797, -0.28637439475230053, 0.24436229266165077, -0.6900007019169145], [0.047456814038801136, 0.41896180657573817, -1.455671242352174, -0.6908039260390005, 0.3695475075106883, 0.6578427780756552, -0.553952176998604, -1.1335778086034365, -0.5631965745782955, 0.5617662097433422, -0.9011758281250393, 2.8778512273927945], [0.2608982891068578, -0.6777817347557596, -2.2770458716928053, 0.49596137920262817, 0.20793148431404207, 0.17172473444102332, 2.1454425809199997, -2.17911676503991, 0.8014705670677063, -0.5099473257126783, 0.5439679878538093, -1.1434064423810384], [-0.2770289237310906, -0.30735208917254153, -0.4142945721467751, 1.6577366682099308, -0.8536390764919671, 0.9109329207493869, 1.5891954445825016, -0.0417146895441888, 1.6227847165573899, 0.5446039272867367, -1.234072838692598, -0.4787873790907705], [-0.49380128415015523, -1.9817948088961086, -0.9509462592075676, 1.1426427902427605, 0.38046500502577385, 1.4518482844971972, 0.052847865159003776, -0.5729598608072229, 0.048476905655297955, 0.4261992176333915, 1.115873416213791, 0.3948115195064848], [-0.6863868709649961, 0.1434448116816341, -1.4082915568961736, -2.5697388898774425, -0.8992979369811441, -0.2228885065400297, -0.8500238348225236, -1.3922894160795831, -0.40565376250387153, 0.004300451494197196, 0.14293514803336657, -0.8549373355754869], [0.8721783508314487, -0.4145937182077534, 0.36320110710133585, 0.10066162719282594, 0.33458185799762025, 0.6616483579548229, 0.196208309531091, 0.19611885089666312, 0.3059664610749451, 1.4723563103176935, -1.5992549983892244, 1.306165664084432], [-0.5140533354524642, 1.1190185081751076, 0.30979990537276114, -0.4081643004615916, 0.35031967005308356, 0.4458245582643987, 0.22260486119371964, 2.656390910217663, -1.1813936702474257, 0.4323054774779637, -1.2210641173203034, 0.6851210719173502], [0.3925237573660802, -0.7391573716349977, 1.17086107762702, 1.2339542881562042, 1.5114402912771943, 0.07605115138783596, 1.3632214664818243, -0.305777210637277, -0.9568439100049673, -0.5460435916624917, -0.029766792637447654, -0.13302404535169735], [0.0625791449517952, 0.5558516147897623, -1.8783273666808917, -0.49878541819587136, 1.2821733619381874, 0.8067123932662029, 0.5547209671550446, -1.504337746594377, 1.2234339782358712, -1.7239233183085763, 1.4249555665175853, 0.4652118528914576], [-0.46211064254322787, -0.23098034670177053, 0.03377938229506591, -1.5837012241725152, 0.5478080617541006, 0.837659489253865, -0.2915067828076285, -1.3184839447136183, 0.5881267353991608, -0.15437521555936895, 0.7300083119318489, 2.4819856533084264], [-0.14707379661873393, -0.5917760830711153, 0.00032324725027260844, 0.6167165561860725, -0.30138957123654264, 0.61090999335197, -1.0613865761210088, -0.8793217379868444, 0.7602100915737455, -0.2842255468838106, -1.3270415539800573, 0.10534407725685188], [-0.1965732503365013, 0.9165031612118574, -0.3411861762053801, -0.9588809717064263, 0.02061517605393456, -0.3768782812592147, 0.13873860846501263, 0.07289789186122454, -0.15793925165199138, -1.1423698305618484, 0.4147345608375397, 1.8613421057369866], [0.25536023722790185, -0.2956602996081308, -0.15655998069417518, 1.4798779525540486, 1.4991215434459981, -1.3970384083820273, 1.7920107280573414, 0.14371521982297394, -0.9291809894846742, -0.5862264491885826, 0.5624723353926537, 0.27586161525680547], [-0.06508581134458688, 0.2755468956539494, 0.3376128111928697, 0.8736601738669101, -0.047099763127462606, 1.804170308702907, 0.7277666099651809, 0.0061402167162054305, 1.4448676853024036, -1.0353784557720196, 1.1517830463075895, 2.8810256577548676], [-0.5397583429782523, -0.8384630528233915, 2.745033319387964, 0.2664906897323823, -0.20585995604796298, 1.1493230677558548, 0.0018002935641869416, 1.2379790255669816, 0.8846142942413371, 0.1809812520986632, 0.5688285082868123, 1.126516111851583], [-0.30263825161599395, 0.9293106694964224, -0.29207512802456315, -0.059915656377714566, 0.9627626403754201, 1.5898708199240656, -0.5885283426739161, 0.7456603473066429, 0.11903962925946872, -0.5753105752549467, 0.05345607172677549, 1.1260902866290023], [-0.37073139849451947, 0.5131809240771212, -1.0818085920604594, 1.2932365635490788, 0.5819163571201544, -2.056999418435859, -0.3622041857527092, -1.2911305168595366, 0.9079064764519346, -1.8714641842640534, -0.37506128770658653, 1.0057596458871847], [0.23831134277390442, 1.0899376672242251, 1.6413659608342734, 1.1437495406238232, 0.24085439160561697, 0.4222434765694345, 0.8446896072313768, 0.004174002652626735, 1.0202663205078961, 1.3215191973790517, 1.7540540930326038, 0.5752380748401217], [2.9115242129948173, -1.1228489403731505, -0.6224149649297873, -1.794537683815356, 1.5810856550020402, 0.14177584974952745, -0.055534205042677094, -0.02142230920672653, -1.1120395119050377, 0.005709117445250031, -0.4210078402870139, 0.8938983232001693], [1.1076385159619013, 0.21748742647811023, 0.20909622418796012, 1.506780050718162, -1.503350297870351, -0.09260377730268789, 1.0143384970799547, 2.070215333422508, -1.3506726320255649, -0.9690484698358693, -0.9609754465722269, -0.07889863911120915], [0.03526337105167272, 1.5613432797318885, 0.0844668652131168, 0.5444853179317172, 0.33953288415029825, 0.38147182310380406, -1.3360707588680614, 0.6986562125152198, -0.7534103406796051, 0.11850708595748209, -0.5880585209631858, -1.1718442674891267], [0.16504433933286874, 1.3869054570303287, -1.574521534434446, -0.4596609654285506, 0.13571532245776816, 1.0086469605399058, -0.5397683317926764, -0.18570204135846635, -0.30323222034856695, 0.44854420494257563, -0.09720731941456613, 1.1230352473079752], [-0.26839960299780047, -1.937781857825242, -0.377314372508671, -0.5642505693754646, 0.5813281740576973, -0.22606780151506647, 0.5112356637661808, 0.15844025786293056, -0.10425776827899927, -1.9332446607078737, -0.23782294570634946, 0.09572521954057932], [-0.08514238290413159, -1.3430523773157326, -1.028811815493503, -0.37911736861300926, -0.870792658576516, 0.783440299165254, -0.08503293904373942, 0.7710695516914803, 0.045440073008042266, 0.009319951204279305, 0.34913035741538434, -0.001745280616324466], [1.7379343283662314, -1.271493201870373, -0.9655459916178509, 0.3380461614855446, -0.436376706250217, -1.2800876866190327, 0.5254182111081281, 1.4277298227530795, 0.9259249957474273, -0.8184529087425317, 1.460994823977332, -0.547809451377205], [0.8753083057612184, 0.40771106667765306, 1.1153706483971746, 1.848047203691246, -1.1717748211201113, 1.0214012278301448, -1.3212629702627334, -0.13454583620873842, -1.2743240698105502, 0.37367515436204257, 0.3975685907402532, -1.0465432774354884], [-0.11771473905127901, 0.42761264459152454, 0.49480272741492265, 0.3189908894806359, -0.8252021305336878, 1.063452675024361, 1.3269480918620047, -0.46981353106451185, 0.6531237890333973, 1.3270209502841592, -0.3927163648786469, -0.08632550104125819], [0.5141707647681178, 2.009686693067831, 0.5333758299323657, 1.2380941882319303, -0.04205996576234072, -1.7100206187238043, 0.141702322965581, -1.6590933497628046, -0.1578928383240702, 0.5381539546471719, 0.606127596487692, 1.0416515268476692], [0.024628075144651547, -0.7457690736646378, -3.5063006726275745, 0.36746728595993466, 1.5987676407826596, -0.10690339582115162, 0.6230729335605449, 1.2775589065988455, 0.03953681859704656, 0.007170228626723488, -1.0300402916138767, -1.0657680464727761], [-1.2691488945427358, -0.0449316339151529, -0.0681419907102661, 0.18192209085722136, -0.8218362448506091, -1.1872283399974646, -0.6258238699544181, -0.6061694819474228, 0.840756980971672, 0.12145590194168059, -0.04830145279880617, 1.8074319046032266], [0.6501691598841504, -1.0385102821745, 0.808313574193835, -0.4406476979060025, 0.20663130879324149, -1.1556203175090158, 0.04031777888224869, 0.8253042736081396, 1.5539619512660785, 0.0813302954414618, 0.7200488730811752, -0.9432778126560508], [-0.15468799688143992, -0.3563170152289881, -0.5698658646475074, -0.22541354574397657, 0.8181101611202828, 1.4490162870436776, -0.4302285509169235, 1.5216403517083699, -1.0880328961883827, -1.2933638582126834, 0.48508519555963664, -1.2939925990267835], [0.37942047171317944, 0.46325238050348333, -0.7457982428257733, -0.21368683823214954, -0.41748281146321536, 0.19460176077787092, 1.0633354621167324, 1.04508770296028, 1.3561441819144462, 0.9342826374083256, -0.9828510519557583, -0.7122484247410958], [0.5681196656187291, -0.736352409887857, 0.07016411645223217, -0.6468493244191956, 0.3028458791358558, -1.6129653169714129, -0.8446820781578239, -1.0291484866644651, -1.5669732889891461, 0.816464218958146, 0.2269276515425875, -1.118136841313263], [0.767582555803486, -1.7843873839187874, 0.17386012908161314, 0.02232737342407049, -2.0672100593863756, 0.2752774574327343, -0.011776194423360656, 1.0395255850365976, 1.3341791723502745, 0.16308301157023736, -0.5549020275003371, 0.17124100620834345], [-0.10605474947802256, -0.1855460476802355, -0.545125955755354, 0.9762287168228685, 2.2293364244574483, -1.5069962363557035, -0.1087651421852889, 0.6174968061695855, 1.8142305690483496, 0.5741847663236485, -0.4791001776368136, 0.13071283687203455], [2.0436836468195834, -0.7168126596979488, -1.5204855451763575, -0.4803431789777446, 1.4033635250418888, 1.782715511571607, -0.055466103427939464, 0.18631798560710844, -0.9716191974478325, -0.4045563677105035, -0.0018733223898973897, -0.15784252285050918], [-1.037571188927442, -0.29327254732883407, -0.061079095091875125, -1.5220787591210325, 0.08382530713735478, -2.497230164856027, -0.6999120181545121, -0.6677483917128398, 0.1310335831821194, 0.45551627784009113, -0.6277207281655137, -1.1711598738554985], [-1.7203574994563682, 1.4443911491193353, 1.2268437516486976, -0.5790597203952714, -0.7352272614578348, 0.052447838445471524, 1.6209585719152402, 0.8198082670819425, 0.4463996980341445, 0.6887520756237323, -0.1646387158764339, -1.2370093680807897], [-1.1973539413986822, 0.1638460859976383, 0.4513703353140227, 1.530932069995352, -0.3844422430254492, 0.1727323275360193, 0.09104868703534587, 0.6698576966010559, 0.07348234858108986, 0.04009156980768669, 1.3473581653783344, -0.45455271504129663], [-1.2345439769151958, -0.5385002225195722, 0.7916637049387649, -2.894201060110561, 0.26482480205198144, 0.22074304478954154, 0.5478221435209725, 0.6442908895894477, 0.26633891595430115, 0.11173327209834878, 0.887173323447481, 0.38811427074690763], [-1.2590338152596738, 1.645784182970185, 1.5375239585765363, 0.07054365594201029, 0.3687404759415904, -0.2678098332865974, 1.3493934261979457, -0.8058341170984589, 0.09225030995159916, 0.1664024278107115, 0.9958910954046656, 1.123168176707892], [1.1879094245789226, -0.679256709581302, 0.8406125758869363, -1.1857484490529455, -1.3951916115201044, -1.3721337005085488, -0.7849863920482733, 0.0996953657932086, 0.6903069961524501, -0.528129486285097, 1.2986594680212589, -1.891424948374582], [-0.900226592086006, -0.8242804971108322, 0.7083694608908118, 0.36207299952391647, 0.5651470452475492, -0.8140663395110588, -1.586947424284241, 1.173806554201269, -1.12889258415233, -1.448933258342002, -0.368231036688291, -1.3858596574286157], [-0.545690233457975, 0.6187486690407915, 0.599257758982741, 0.7220276522001524, 0.7725507684805796, 1.8925465057272728, -0.7961185883254567, 1.2131466879568085, -0.3706030630848632, 1.281930029396893, 0.7908081256330529, 0.7640398972659884], [0.7726194224563603, -0.6349446033345797, -1.350204162741566, -0.8801457539612545, 0.3981202077374948, 0.8847380302829988, 2.821844962784382, -1.8051098772043943, -0.3261851989765255, 1.6435457847683759, 0.7028702150034695, -1.02098768799005], [0.11636035551694329, 0.14299306592088473, 0.5533025869325605, -0.5412950260555315, 0.771031490265032, -2.0496467251158323, 2.1375057842525846, -1.0913096245443965, 0.9291511474930737, 0.8215610332784254, 0.7239942700377667, 1.5016901067494797], [-0.24915490478655372, 0.6361520505548479, -0.8955456075810169, -0.5041886415964919, 0.2537569550393941, 0.6694974516029435, 0.7432161038686309, 1.370851598742132, 0.6055876525951732, -0.2962941943065646, -1.896581567325499, -0.7538408630565877], [-1.102434969795915, 0.62449214266175, 1.5210882000246688, -1.1001897899661384, -0.10153399941683304, 0.014228716358024172, 0.9557492254545011, -1.009354286457404, -0.6337599718033708, 2.4363426290306127, -1.947630914700846, 1.4780347549563397], [-0.8079126443094958, 0.7997675401090409, 0.5989270493612466, -0.5192466870522727, -0.06386928644891994, -0.4676039907386514, -0.5727034496158759, -0.33415841840889937, -0.3513663856030676, 0.3973286110071144, 1.6730804428195292, -1.7186644904583117], [0.15194321714740888, -0.21442858602461706, 0.524164767342931, -0.3095456367731812, 2.8328123576184185, 1.205837637755603, -0.7284213721559993, -0.7147700775783293, -0.30466502678344914, 0.31509757894498347, 0.1977437624048607, 0.4471383972671783], [-0.659527266286203, -0.08869890943435343, -0.5876413740545992, -2.490359547411537, -0.22378677742413647, -0.19221832593088106, -0.34712500777525185, -0.0016773519286506636, 0.9842125662225466, 1.6262750386069438, -1.9079486180463772, -0.46982803890437386], [0.5908974886440804, -0.5272323732442716, -0.3026007363318719, 1.3188250053882666, -1.1916606927276294, 1.2156339373474656, 0.20511893850127072, -0.4351052325778714, -1.0489444822872633, 1.0611076008219646, -1.0457572398332307, -0.18047615254354482], [-1.6395866532994463, 0.15905050582624217, 1.5071213626050648, 1.262952004743884, -0.30624427859572256, -0.04101174515297083, 0.05047598880600008, 0.4887294890605922, -0.8557232072426196, 0.8415297189390264, -0.4131216134081887, -1.9980475690792103], [0.17584117948103478, -1.8836271736658554, 0.3422354896740236, -0.2240179260013843, 0.5724696209442353, 1.6779185570346633, -1.1780736406013737, -0.6444988119341375, -1.212982701671154, 1.4986576770730158, 0.22902565775382508, -0.9947264693835502], [-0.18785113729645442, -0.09037018313476715, -0.4563170809085186, 0.26885680747895363, -1.0374442337532186, 0.23682752562761925, -0.0284457765104351, -0.5002647156973965, -0.37805325103385695, 1.1573175614233553, -0.5779085325967257, -1.887625012263327], [0.10087375828239215, 2.6636214239537863, -0.3009934043184007, -0.5839623075579059, -1.2911060008358608, -0.4821259988342785, 0.41653841057944363, -1.3164788213341452, -0.46756722434149744, -0.8425042937740176, -0.8818045648812606, -0.13281283482516745], [0.5609813638131786, -1.1839090997431094, 1.0537611305152061, 0.39669499681763054, -2.5113533373309855, -0.6433185591409126, -0.21060593081701484, 0.4058453802897937, -0.5245304930898099, -0.327266498212432, 0.23053066141906162, -1.1174193709770472], [0.10428558403232542, 0.5681543739208458, -0.6608740054018447, 1.4573075354344012, -0.28657201246991865, -0.333352777098373, 0.07127356030354612, -0.010777233603807192, 1.3825621790887783, 0.818423484994508, -0.6195689035880915, -0.5657050086875676], [1.2591596858590848, 1.1589194562793594, -1.3029795608110313, 1.1896158904104588, 0.9772575519928897, 1.1490352422169765, 0.48342223526417594, 0.40097103054320105, -0.2898323828802187, 0.19798256433939349, 1.0031616374206709, -0.4143955094854209], [0.20001292758220032, 0.9074060786804405, -0.07524737712802224, 0.41249873655608377, -1.147490846770978, -0.43394309793607516, 0.9514713238873692, 0.7591090338973177, -0.7914141793215169, -0.9414557522056816, -0.5326495725539591, 0.059877358880488105], [2.0559115078228074, -0.18983854397348646, 0.27166782085953783, 0.20883288791374094, 0.26583237055799763, 1.1056471498543379, -1.3249671698359795, -0.6618333170319951, -0.11861812946874198, -1.5042357815309142, -0.6254682865337233, -1.3025393343781948], [0.10998951623347963, 0.8904773431848239, -1.5867676453415742, 0.0055346675040087775, -2.4732617834523114, -0.7058019022047397, -1.1226615085632838, -0.18653606980098283, -0.6813978715399773, 0.5775158863932286, 0.07156312262994934, -0.537931345753259], [0.9990805154384833, 0.04081400354488382, -0.02484774004207991, 0.26657709888862935, -1.2491304423432537, -0.03695714865019644, 0.5524919470995013, -1.6135622916407648, 0.02558250114318309, -0.6064421616812378, -1.8906649109240978, 1.4084050375220523], [0.47544949587941265, 0.3112312794639339, 0.5986757254780288, -1.1161689310100067, 0.846896743814034, -0.6733440794464327, -0.6312410889200426, -0.28483586431542407, -0.5375944565270436, -1.2105922190341107, -1.289826439046508, 2.046050732331591], [-0.615568177674173, -0.05458860779383096, -0.09639312279805995, 0.9776335217648403, -0.4646623704845426, 0.3853702486000512, -1.0300227608972683, 1.6656845098416864, -0.42080979313388567, -0.06832291168970768, 0.7669203522002703, -1.1700223349529377], [-0.7567377024488958, 0.21306388618959554, -0.12912875657657727, 1.3341630855764155, -2.8653289569676113, 2.5944673979398796, -1.873605575568973, -0.9761214544243279, 2.0158304844494057, 0.9112812004242067, 0.3916162494529121, -0.8445786508543562], [0.8683769267898547, 0.6988811897896412, 0.20995666043637523, -1.1211983279530444, -0.1983828549994155, -0.1417586826219766, 0.4263401952347981, 1.7335189840111966, 0.9533977230496345, -1.61981114068648, 1.3714247113597737, -0.06842108333529046], [0.45929164885667434, -0.3564036557972684, -0.6844457792729559, 1.1084178914552285, 1.0250306700153264, 1.4430511404849085, -1.8643395891189463, 0.3001780858212103, 0.014195696212428327, 0.8976172003808223, 1.151382417248629, -0.11377517659400449], [1.0838211834462756, -0.019308783874242286, -0.8618791186220927, 0.4658739918319139, 0.8178596563579988, 0.7289008738824481, 0.5195776026414718, -0.16747962703640268, -0.11959289223314627, -2.6639566683585714, -0.238845341650014, 0.6682572542580567], [0.5598519417329985, -0.6971113438838061, -1.0200314465151177, -0.7558427955191596, -1.2038756440428098, 0.908608332393681, -0.6735888788441954, -1.1439655110131113, 0.4253587548520937, 0.5219824901028907, 0.692496985357474, -0.0075729253610787115], [0.42738727265976484, 0.4597798915058797, -0.7219116883359777, -1.4988911855732645, 0.25663624895165965, 0.5491263776136649, -0.5080039595376229, -2.081424280481725, 0.7732060124270167, -0.5828102402155863, 1.0362513051593123, -1.138801218053453], [1.605775410858681, -0.1556921702147386, 0.05531366642809275, -2.2548559151387884, -0.645819843071429, -1.304900424889385, 0.9410834632987793, 0.12975465322951352, -1.7895437280972046, -0.06236346126541052, 0.08489972267274709, 0.1640365910651215], [0.9572736757745688, -0.48516079038029786, -0.8173589255267718, -0.6716471815975347, 0.5822390748018225, 0.20066332518595048, -0.6840920174083263, 0.1850347760630429, -0.48371438293049945, -0.390111692162414, 0.715324088298991, 0.1384296137705655], [-0.21022952187401572, 0.4106199611995717, -1.0169741807952808, 0.958415719566652, 0.9812916712438035, -0.1653473115694497, 1.6048669554609452, -0.8194878682838946, -0.37073271398064417, -1.0760364805580103, -0.3153317389878802, -0.10983630195460256], [-0.6815623456379628, 0.6534307688248764, 2.285243951799013, -0.13470579305760325, 0.7947371454444694, -0.34557866892989597, -1.3020224109524112, -1.0406130862787673, -0.4516669848550566, -0.7671692849544065, -0.3226714621225626, 0.20098972691796688], [-0.28259995046618097, 0.2993463790324145, -1.6431324314441444, -0.02761176070160499, -0.46573857111855466, 1.6829398603805588, -0.2852176153300091, 0.13630982346308207, 0.24379933702853676, 0.32176761426914857, -0.7958301946643235, -2.4762419204432073], [1.8008940650186867, 0.33512270504392466, 0.3601865079519783, 0.9420517063208047, 0.7743765948420125, 0.10339898588894195, 1.578186519873266, 0.373299045819377, 0.2637345583287288, -0.4479715753216586, -0.6657447467170282, -1.2285011255783858], [-1.3853552829692641, 1.207692910704809, 0.8115935173321246, -1.2025988854869223, -0.5350454529874313, -0.6511912769259374, -0.6161148819644076, 0.45750331146768897, -0.3163585509950518, 0.6681677718492031, 0.26061068136452303, -1.5077781959305827], [0.7030978662835697, -1.7768791068125875, -1.0474180026520434, -1.8713186029542763, -2.8745536374429124, -0.5980923191928362, 1.6660338806701667, -0.6262881729654338, 1.604757425414922, -1.0913747086549572, 1.216172524611663, 0.5404111734725756], [-0.012554443322595763, 0.2680029155480177, -0.45918597751977885, -0.4676719327168535, 0.7626430600598465, -0.08573764623933293, -0.5012969557560164, -1.0428698334178967, -1.7346025820384616, -0.41055769556212685, -0.7167529798293077, 0.9085736655919431], [-0.8680716344004715, 0.6659406230338698, -0.26785075799882263, -0.6774208098055015, -0.35839310083182374, 0.1497200249703331, 0.678489627063258, -2.093159000405533, 1.525011926251236, -0.8087081260151819, -1.1440415810021392, 1.942402009154991], [0.6393319892484532, 0.4593669255911572, 0.4461287581476852, 0.6412942713122599, -0.5917556795003194, 0.2208857466009968, 0.45878682347063643, 2.0001112043932716, -0.21400288762748948, -0.2811850720720512, 1.1782684541696429, 0.5115635810526684], [0.6783461447736402, 2.040898414273967, 0.8665858115924904, 0.09843472280990466, 1.6701154169619168, 0.42617281673843527, -0.7684264475809213, 0.005662711239713202, -0.3094847294096599, -1.0953706365833222, 0.7383787371121039, 0.4038081146723568], [-1.3920947014760159, -1.946050058350287, -0.08651079802072538, 0.41219882780364353, 1.2243149793228811, 0.10821365596265616, -0.06540766510313316, 1.22370464007477, 1.4292890890201908, -2.0298366329654254, -1.776940498308948, 0.6435044977782679], [-1.6850771123343238, -2.5669383423838172, -0.7068807309518769, -1.489130299232842, -1.6744612573998714, 0.5152200320700632, -0.7809364488606191, -0.8153968274302071, 0.30545933496081357, -0.14246444382554577, 0.48414608968150113, -0.7219447950108255], [1.444380167838822, 0.012034444020057043, -0.3075283630609095, -0.037820356585901625, -1.7748487019192052, 0.19391413467304242, -0.4579244950247126, -0.12723746897609273, 1.3289392700116949, 1.9589579471928384, -0.7972760112331297, 1.6413915316765564], [1.0265445182256887, -0.5692282431088299, 1.120749906518836, -1.6498959450906605, -0.8548837706915066, 1.9049818680852326, -0.11519980336434965, 1.2047050924796003, 1.5484906288994762, -1.7955963226213427, 0.15337336922790307, -1.3594021000061378], [-0.0694843867489997, -0.19070757726571316, -1.4674879664448552, -0.7016854926972682, 1.7883527721720547, -0.3630262506532432, -1.2427895718197257, -0.29957582365930796, 0.20950658646729758, 0.4156607221834465, -1.2427787861398125, 0.09272490424899958], [-1.2921579099440181, 1.5022607399599326, 0.9135980570588619, 0.22529094630425653, 0.21022953540992567, 0.46570878162344925, -0.8437731549536401, -1.0799206404475137, 0.5091899756870661, -0.6583548253505274, 0.5033161221046214, 1.53889587061273], [-1.1276653035193647, 2.7763939659662933, -0.21337452677142382, -0.7232127864025184, -1.5149210237310928, -0.7315200410769925, -0.04251474254042123, -0.17388571730341185, -0.29762968648774146, -1.2181436734198585, -0.9370467467502509, -0.5553668074453645], [0.15487313272649295, -0.24393672022022747, 1.6170949668201642, 1.7751522351710862, 0.013845990663654262, -0.5326818569022364, 0.7452915982131951, 0.7198460848276266, 1.3777026512071462, -0.5018482353275131, 0.23697381381530325, 0.5381858427713468], [0.0639105891980353, -0.8834538258743974, 0.053937266760458506, 1.6515407690670616, -0.8877338900565236, -1.8409533711626922, 0.9830351733144163, 0.2769534922589043, 0.07920322069739136, -0.7948554476828054, -1.9464314908262221, -1.0086029817986817], [-0.034839396793456434, 0.3669754684627693, -0.6125741348067143, -1.227822830174804, 0.4911740195549095, 0.08175157283756497, -0.2272218748950707, -0.4681731073672973, 1.0528940633692776, -1.0633058721161592, -1.469756852920623, -0.9070966192191492], [-2.2947061750550337, 0.39237527229617497, 1.2572073963851, -0.6958030507378874, -0.7261686965361858, -0.7307659279564637, 1.3474128692443628, -1.288472893694198, -0.5070327488250591, 0.2479228130476709, 0.895243516938364, 0.3035530642557127], [0.07557590533727117, -1.72808081642067, 1.0833124582558897, -0.6668480964601331, -1.653792677911376, 0.2524078372698134, 2.009077695342442, 1.4897575762364357, -1.0603306954109142, 1.1221679214299334, -1.968902573219164, -0.30185423691204355], [-0.977608392533116, 0.6406818118813107, -0.25756947103464994, -0.35216858200500395, -0.06713623928631132, -0.8683107590341993, 0.48325819660600966, 0.5372044767093782, -0.6534767019182663, -1.427701480870079, -1.1628654005796402, 0.12230378908751965], [-0.3357097059930965, -0.9594578953027593, -0.6897812415018477, 1.062074723319725, -0.5773257420126858, -0.057119704976331794, 1.2217155464650689, -0.6752000583055682, -1.9720677570683511, 0.9493962325501981, -0.09882564501289517, -0.3975349246036865], [0.31784173212157196, 0.3303555732144665, 0.19584763272071865, 1.0786744148429557, 0.6760429948434152, 0.2770543724676118, 2.0895641949456367, 1.35646014880379, 0.8658202516327698, 1.990811349433696, 0.6199134691753323, -0.24326375626750882], [-0.07497229927995738, 1.259727820561287, -0.774572000433079, -1.1901770067474882, 0.6697625247138859, -1.7838655387708993, -0.955209653117255, -0.22865744234886798, -0.16204209842051356, 0.9904425920834751, 0.3536865504507462, -0.23473374374963804], [1.0703619970029747, -0.49427579821041845, -0.007019827060019302, 0.6213522746128436, -0.6858622952117528, -2.1578208353217074, -1.3079208673876535, 0.8493237764016092, -0.8808650795587588, 0.1079547397259656, 0.4111223041022169, -0.05025310674741469], [-0.8158434968171119, 1.0456308906061202, 0.20355223110243842, -1.1952897333057821, 0.8343890000490165, -0.8098432094541318, 0.13037016246931876, -1.554718204442975, -0.33528990101747236, -0.9342343153153165, -0.417223502510937, 0.4744090641635099], [-1.0414057833665293, 0.6259282334661324, -0.059992855720884364, 0.8814803998317876, 0.6705240830541765, -1.2491977317705485, -0.7048079282809206, 0.3341400985882784, 0.35093949764398985, -1.0625652392591551, -1.5020542968086814, 1.1273347889362109], [1.0123727307055579, 0.56103757848531, -0.47872851120625776, -2.204236090498414, 1.5174558411824948, -0.44033355603996177, -0.08318740433315194, -0.9509709548530934, -0.34963157535328165, -0.845982847763549, -0.9509116134861006, 0.2708178279206663], [-1.9689276794769675, -0.06889093769182916, -0.8315296808629079, 0.14693992766398917, -0.2601379094634857, 0.5852389963874465, 1.413243667864175, -0.715917229106522, 0.16128532422282127, 1.3714491638730015, 1.058135300159426, -0.008281988648795953], [-1.4191325537130097, -0.9812770817411403, -0.7493825975708626, 0.9564365936784637, -0.43695645639005815, -0.3407331419100107, -0.6566457746123284, -1.2832681445465797, -0.23169985661912007, -0.4948131190369458, 0.5780984966644762, -0.19511814294848445], [0.20288549194340744, 0.27433257524212157, -0.06035804932742799, -1.2090064700889325, -1.7011701918063777, 2.023366184018231, -0.4078240970787369, -0.23938882431814723, -1.896816779483718, 0.4324139691513757, 0.09306283542825548, -0.7385095004096995], [0.6835726862831453, 0.4173110313012243, 1.3199119109409767, -0.7614615695849268, 0.5313854987564108, 1.6526020777774773, 1.4251690644505635, 0.46291432295167867, 1.8896859839740578, -1.352339438137541, 0.019234659276486318, 0.046271852007917516], [-0.2217588505227503, -1.8403153695764827, 0.7988658098405208, -0.9289887941760017, -0.9391048920793458, -0.1754926662283728, -0.8834341995428018, -0.9611650097274668, -0.6832000971323462, 2.1161087061452752, -0.7189496051643872, -0.9963171991752213], [0.6620836515765639, 0.013931999393795717, 0.9219231890391396, 0.00995189331893208, 0.39211434391711053, 1.4572523213409705, -1.024288466120194, 0.02803637773410497, 1.1995268739168876, 0.7558763029897846, 2.5945094302829643, 0.40039210783051715], [0.7666929707071195, -1.3560715078084955, 0.1046678917510338, -0.3916673721423641, -1.8078819489094773, 0.5701151037879548, 0.10781881553033941, -0.19958313607661213, -0.0013984468468305473, 0.48090769432932245, -0.1300025198452185, 1.5796956902423769], [0.45110939796295996, 1.0704677722332163, -0.5047866881308851, -1.0216432351604512, 0.8649507952402552, -0.12546288337950354, 0.8442538766581612, -1.950424243449742, 0.7467919720711631, -1.5628560059798249, -0.33867482026143353, -0.07607745204502842], [1.2409978938859334, -0.28735596130961005, 1.102078937816606, -0.3987730875234625, 0.7558477990159612, -0.4857056222707867, -0.2829238584827151, -1.1654937026215921, 0.89231642472838, 0.37381670803706574, 0.25568419696655, 0.01236131328783194], [1.150229590735076, -0.020339049796323422, -1.1989320141088482, 0.4434819116673914, -0.5850602624617496, -0.5839327573635571, 0.9489145528621861, 0.24980442131415198, 2.233079586580641, -0.22711379297824705, 1.681851276647767, -0.749048420499993], [-1.2400913983936095, -1.6197289283443308, 0.38677758485174224, -0.41452631939206547, 0.7026448217303332, 0.3253596598912201, 2.01889726240415, -0.3919775028758855, -0.7225354611225789, 2.044357627351966, 0.5198885524244629, -1.3769022307650318], [-0.23050672824921317, 0.24296886821461205, 0.6884238979529468, -0.13744601452458213, 0.13898425845912868, -0.5426413169183016, -1.9588549807374995, -0.1637224981292437, -2.2736459114935443, 0.1563650626979552, 1.4995187389583375, 0.1480222166407564], [-1.5812385927893131, -1.6567879777846601, 0.261187562079501, -0.7532884283728986, -0.27049075079748136, 1.1038910219381362, -0.19887192758644642, -0.6329745161130297, -0.15002314786910062, 0.4383878844300028, -0.2895270073848164, -0.987370875289065], [1.9326584259312862, -1.6966098685256041, 0.08551844493326528, 1.2778642084845233, 0.6031351880434782, 0.7282236121613413, -0.08611274249060295, -0.14155132692535607, 0.8906822157456001, -0.9998276753457169, 0.39477824367382724, -1.5403395884878262], [-1.6968494275270727, -0.40569183508452517, -0.6699979750741193, -1.713689918066252, 0.28824966107599653, -0.9229360619811812, 0.47397526429464204, 2.882054107853845, -0.4352381041076874, -1.0340794762692238, -0.530643332120981, 1.7588615673495556], [-0.2093011813462876, -0.3973156590774065, -0.7922976218986421, -0.25657017829198064, 0.03108728366246248, 0.93753751443115, -0.7595985690245555, -0.9016577298659321, 0.4608618827569022, 0.48691132693918465, -0.5810882151475085, -0.43631132326537925], [-0.3399013932275221, -1.391326366160239, 0.06743666429686884, 1.989599780442333, 0.44361870955787286, -0.30914847591337274, -0.9374791180122586, -0.15337279288317188, 0.5358458662759578, -0.6391298513488152, -1.1364047189766773, -0.6099607180978596], [1.0788976854999384, -0.43591654925791434, 1.04440239983328, 0.34047391217100353, 1.0191755250281778, -0.8495406858235584, 0.017933061183955417, 0.11849026963512233, 0.463285103704261, -0.23723553996330343, -0.2908976495113173, 1.2445309362687156], [-0.7380802782835015, -0.2870826642320072, -0.5597003281462114, 0.1135355626698719, 0.14814160290505057, -0.4651944024197248, -0.4658158414958164, -1.351204162179856, 0.7856676638908084, -2.6541099497871237, -0.7091294482809706, 1.4289705931931256], [1.2632946392032287, -1.3349684743487142, -0.43226177513715813, -0.5444185461963184, 0.09073131565550904, -0.1651318193222624, 1.1849045829574492, 0.8854510946649827, 0.7368583384317265, 1.3972694733273734, -2.3282319773558013, 0.8996573087488772], [-0.5804057533190552, 2.550187904993588, -0.6439094912342366, -1.0319110835043017, 0.39687558526785205, -0.5738762206166957, 2.2673981518051445, -0.7388677883512454, -0.5248000659445151, -1.358938696806281, -0.39328118558916153, 0.7078845019556181], [-0.46269652113714227, 0.5951197555965869, 0.03671234139950025, 1.4656599496655414, 1.163384588075551, 0.3701632762410871, 0.07954133349012557, 1.186977897238335, 0.8502404535139699, -2.1144297549938593, 0.15265398845756226, -0.920661689566876], [-0.4971515009019352, 0.45150529396353956, 0.20805019808186725, 1.8130127943922294, -0.23331744267753252, -0.7207911765648664, -1.5394950518663364, 0.038587455638845934, 0.8686036028018397, 0.8100469102334653, 1.4605165517675993, -1.3947517789578323], [-1.1768656753607174, -0.5560445976236643, -0.4460506459822798, 0.06754621182996685, 0.9091734368718918, -1.7025927284657143, 0.6038904000169183, -1.715400735134412, 0.8734299767089648, 0.7536138163129937, -0.8424052709058961, 0.6868130850415061], [-2.206441664562984, 0.26135835643084604, 0.23016350286951986, -1.3683019699840624, -0.39503718959935025, 1.704385009244786, 1.006758171224425, -0.6367735594428865, -0.023176418362271516, -0.20302817424933703, -1.5410477042963064, 0.4713387408063184], [-1.3294013927360175, 1.8422768379926195, 0.7372991803483372, 0.6830079945334623, 0.09778769546811805, -0.3312585697448038, 1.096692445259882, 0.5302199305195432, -0.39298640739033774, -1.3689959145356339, -0.5381966478163578, 0.5611599707160535], [1.0491231595403516, 0.7039198846465324, 0.24746287648249046, -1.805215506261173, 0.10027827226938786, -0.9829286719820535, -0.06993054256617591, -0.8786482151548005, 2.176076673947826, -0.8049945881509472, -1.1160922418339836, -0.4196049242061804], [-0.1464609894253511, -0.8840296557374476, -0.4409992414862613, 1.1798254054876691, -0.21973598909448908, -1.4630737898834312, 0.8526416526909842, -1.3438982717866808, 1.7673156018482883, 0.020179004836792566, -0.04505141865066363, 0.6767857480135744], [1.0588968659780553, -0.7705421936389284, 0.23071431265256406, 0.11744146090492101, 0.8537743424820651, 0.37959237462064266, -2.0973808202557613, -1.0161300722750983, -0.07231219275759275, 1.8674499306752, -0.5171293758012027, 0.12272918424216808], [-0.3438439159779404, -1.317185976692308, 0.6932635088089948, 0.1804631188308763, -0.415556911275599, 1.0424051197907502, -1.1872372510388052, -0.9664680718392639, 1.0443603482563684, -1.034087272410808, -0.8136014115679294, 1.0459159440337151], [1.6266502956791173, -0.3495441305175789, -0.8500624639597901, -0.3988842479168503, 0.7077233606796373, -0.7751923409535794, 0.20557797472908998, 0.5810567034560454, 0.666455801067333, 0.2845097162899476, -1.9295143454425425, -0.6962717664082191], [-0.9625345938566926, -1.5923866824172326, 0.06322610478284907, -0.5731429938841133, 0.6551026168650225, 0.11335276381645491, -1.7230478825850641, 0.04558007526708612, 0.4608694350330657, -0.31599707134010013, 0.007323647859946941, 1.720447332003632], [1.5832660557080436, 0.7871717825500814, 0.27837026205747634, 1.7025173356604664, 1.3785495721646213, -1.0775809820307625, 0.7988713814012929, -0.8438065947750494, -0.20595360883763486, -0.9668087601446502, 1.5194946019240199, 0.8112078476946541], [2.2772569627449997, 0.22863409363467138, -0.3353431498721245, -0.3179238417881277, -0.36968218169530165, 0.28294042374358924, 1.5015159267970923, 0.5159750563255041, -1.220541347048615, -1.8572811933291389, -0.7715663466418679, 0.09610900897714264], [0.2681041094571189, 0.9077485880985496, -0.4277486432190699, 0.004992448227458796, -1.180613835523126, -1.60461512626776, 0.7304214180840009, -0.23444086303785683, 0.14546347604186216, 1.4101810773756365, -1.5252846768222532, -0.27234947269296805], [0.2999901722423153, 1.2017503763778488, -0.058269982612526, 0.3670787048848793, -1.5038290517781534, 0.5011336774202495, 1.9160311723868773, 0.04233245046733544, 2.3316848210848304, 0.07553909850066506, -0.027938927062030394, 0.6082426987420323], [-1.1513547989012707, 0.5169967954596758, -1.5321325570812963, 0.43798641805816835, 1.544333235296682, 1.8658552921830387, 0.9802809862266745, 0.8623263412674881, -0.35101413575402285, 1.0747316552048503, -0.7792457255524277, -0.4441898873207242], [0.0005857327622763689, 0.38816864246199145, 2.240086391281661, 2.0539602298778226, 0.03202503078320779, 1.5776839964867868, 0.5374129577416522, -0.4562167137565702, 1.603807724099184, -1.0920526204633805, 0.9092280964456841, 1.2372904471018953], [-0.15086093370752043, 0.39192235776352735, -0.1928033323301056, 0.7616110173094016, 0.6632147711338608, -0.6733410135119303, -1.1526315087878398, 0.05153093577143982, 0.24649410276908362, 0.1046022580321926, 0.31941629515464587, -0.7171248319376513], [-1.5808130685546034, 0.25500807645488277, 0.7430692765207378, -1.2656107400704895, -0.14907327923004224, -0.09360996385986788, -0.7046391580227972, -0.6908142711255042, 2.1473528557288515, -1.242362078821444, -0.3937280726094381, -2.393355720346563], [-0.922527251032543, -0.3642833804433972, 1.4616561508679227, -0.9963736866271715, 0.7490981207863032, 1.2130601170077808, -0.6158713824321786, 0.7812470523338937, 0.5829582425943682, -0.6550820373819478, -1.0896018734902984, -1.2410596571851589], [-0.7201254987627409, -1.1574240594161354, -0.22947673817479144, 0.4888474086916731, -0.03254747985656569, -1.0401270023656752, -1.059760608415404, -0.7377092197410285, -0.8598622698727878, -0.5288656514129833, 0.9068451827011388, 0.7938389419004848], [0.5131104693914607, 0.6096450723992661, 0.7402108359620849, -1.1993878035678822, -0.12324249238899146, 1.3651659390885198, -0.3048190220560219, -0.5712732177051324, 0.06715849978090428, 0.17649596220607883, 0.2969574621061075, -0.5525577644134889], [0.1825940493111989, -0.5521198851455015, 1.1026676484416043, 0.5063811717486573, -0.4594840125408881, -0.099930953981197, -0.2399568944656517, 0.014326610546003994, -0.14730111561979375, -0.6911466851582168, -1.3007368959742522, -1.5318468199916428], [-0.3642824267422228, -0.2862399914414158, 0.8629441939836087, -1.0280759149383063, -1.229396189163484, -0.00041598364161871446, 0.40408058327914875, -0.43322823025988044, -0.5298061396394088, 1.886616807952533, 1.0613203341611082, 0.7921929315672308], [-0.5611990760608531, -1.2509192356703762, 1.3242621626574138, 0.3057631323251535, -0.348170290699797, 1.9197614057852541, 0.18439246096978065, 0.4332118846796213, 0.2639811545290081, 1.606352517526883, 0.4767928611038168, 0.30141705935089036], [-0.3729571106499434, -1.3084641570825872, -1.4557531955164655, -0.409911769971888, -0.32715958139577034, -0.33803675824320717, -0.14736750401771279, 0.6147195433775172, -1.5130580878062154, 0.3330551969329245, -0.09022119962226693, -0.13551152377488462], [0.29752729545208983, 0.9971862506497797, -1.006607892467547, -0.7313817933492436, -0.6959027589261366, -0.25217245405162814, 0.3664933780604374, -1.0720308165582206, -0.7574757898276675, -0.33991834617653927, -0.7179262109328974, 0.24772188086188626], [-0.5619074729658737, -1.4151350808660976, -0.9166538033589072, 0.3996374144473578, 0.463283351423209, -0.045731672013166615, 0.1542265254152702, -0.15721040277489381, -0.7461808441263742, -0.607578042687529, 0.37824593506977333, 1.5607830368602273], [-1.2499521267448155, -0.6502857781599294, -0.39575292713056287, 0.044795535127405375, 0.43816531344550175, -0.40877620657834907, -0.24335908539256548, 1.0439075999420897, 0.3010565755812552, -1.8140239501692337, 0.660919434077135, 0.1948323087913805], [-0.13290147228706697, -1.5220132878244839, 1.5949481186099697, 0.4058934467240595, 1.3244813545631111, 0.2578746502236274, 0.8930753420522576, -0.7179110641392966, 0.7726493301742626, 1.6611618326830313, 0.3079561753208661, -1.4940295158420613], [-0.5922575467471987, -1.277614200942076, 0.5161894909117589, -1.9139901299620865, 0.061373367527015395, -0.5737012477763929, 0.749087294612681, 0.045828134911836946, -0.26181171867898756, -1.6033927616867565, -0.7162756297421065, 0.4312225980723155], [0.4414745087723645, -0.6246425070066242, -2.86059129317577, -1.1144609981812053, -0.4063017908096266, 1.5843471542864385, 0.3377654708927646, 0.2038060034797712, -0.5254102807689153, -0.2180933943843385, 1.7712360991131288, 0.23367351554403862], [-0.9479227518399892, 1.9754597553560556, -0.3882439851920275, 0.3685159357218142, 0.39432259606451364, -1.071650927983927, -1.524383324018481, -1.4698431980046882, -0.2882210842719548, -1.1344211984294004, 0.40994579126905023, 0.6669214068819703], [-0.14097114102442362, -0.2669148519303285, 0.712374198775964, 1.667884177210996, -2.7464215768417297, 0.21170184457307267, 1.2749355096006867, -1.5718381561468067, 0.23744246672063196, 1.6743649197546555, 0.5739766028551606, -0.5535021852642019], [0.7842658397036512, 0.39621382322107374, -0.24041789315108136, 0.30203917574558453, 0.5761664489253037, 0.18067811312547136, -0.37004164877238427, -1.7039765666743785, -0.385628114309577, -0.24449010274872443, 0.4378542136495412, -1.0790529273252485], [-1.6931963241622783, 1.218135818327857, -0.9150922895054026, 1.025057469555756, 1.1595280755361317, -0.13985307282762885, -1.0021041626894287, -1.2942166381898121, -1.4340566291407517, -0.9888048509701187, 1.5606467640353878, -0.4176502970085241], [-0.40587691717469315, 1.8912578138643668, 0.014929447434436, 0.378480557205164, -0.12280639788124309, -1.6179308234552505, -0.8025168465049002, -0.8931301928033452, -1.3221330794993946, -1.35538559503803, -0.15264230503048062, 1.3159168033772712], [0.44065121886555125, -1.0584653715207222, -0.7357827209443271, -1.7022485000066971, -0.7471180916639881, -1.1851088329157415, 0.7680922659423088, -1.0437855867420962, 0.563386975669206, 0.13931754309101063, 1.056944826021624, -0.26752913605279627], [1.0001699728862936, 1.8789500949757525, -0.9590635406791213, -0.5852706526036454, 0.2340545940304659, 1.0100923842930616, 0.8559444656039575, -0.3499067935832412, 0.3205056960142858, 0.6737596710852964, 0.002480337193823204, -1.2970882732963682], [-0.27759853279474694, 0.5165083237354329, 0.85777836825695, -0.8912947752252594, 0.3427174527628377, -1.417883868620084, 0.6618474844023942, 0.37553734033906966, 0.4004993161207158, 0.989946273166854, 1.5367490375656097, 1.1229901609507695], [0.17242488402702444, -0.578863086550186, 0.26764045956784177, 1.6482644565575206, -0.42483923971699955, -0.9791777496263823, -0.05394399836761866, 0.6879924405323745, -0.32220662492813806, 0.08505614549879734, -0.9652938546480362, -0.36115995720136057], [0.09682115351713098, 1.4145589157302147, 0.3052521687656045, 1.2826202223669592, -0.2394843841523702, 1.0052421141908934, -0.9576014117716206, -1.2251108817924348, -1.0835118716088468, -1.0145493389778206, 0.17923577843249647, -0.09536632266076486], [-1.0105016515296457, 0.5513383242845263, 0.7743000432150638, -0.8390723388362922, 0.0945863964907067, -1.8597414574260431, 2.097861844983382, -0.00721564563689295, -0.45421525944681995, 0.45843332385196756, 0.2774060658097455, -0.16554377663821954], [-1.9890760424280685, -0.20602273065426907, 0.4750099445472013, -0.6805432415305422, -0.8944933818167898, 0.04938335104369027, -2.012032498980005, -0.5331253006333683, -1.0049148164218138, 0.5872204304532409, -1.9097752545123325, 0.6197004386262762], [1.173068417165836, -0.189591869446982, 0.6405479965387989, -0.019460727210844096, -0.04854507597863451, -0.7738185397427059, -0.44112488684026163, 1.258436297766077, -0.7896386163610788, 1.9982790384281595, 1.1561687356636947, 1.6145961897733534], [0.10799469713321892, 0.7300575016964472, -0.6492743801302625, 0.9765219498470704, 2.321243657782732, -0.8214639768966971, -0.04500232259027263, -1.5536082806685791, 0.3433688115491971, -1.0424005433983043, 0.21582966085017927, -0.8779516197321336], [0.07068916613160188, -1.704681495692834, 0.4030817046958016, -0.6514347760865716, 0.1587161438110504, 0.20841227786320335, -0.47763373313289176, -0.44039265501703945, -1.6179097550919783, 0.37462068638590656, 2.060480338809507, -0.3302786378001995], [1.0044442656289445, 1.208566103419679, 0.1298306784231716, -1.3477304457752588, -0.6582853400762497, -1.2543285301555627, -0.05702613202969385, -0.09128698430003859, -0.5260106055619146, -0.33541134769164893, 0.8193217956652036, 0.3279274686265413], [-0.6867727184570196, -1.1454514693984321, -0.0956016788547478, -0.5710073060648905, -1.3767982923435045, 0.1970732801307448, 1.1193760897486613, 0.5397263871856651, -0.22361628339152467, 0.16781639274930815, -0.4441547870582373, 0.6069528591393629], [0.01424360495850295, -0.07998591308561642, -1.7338907884388526, 1.075672550431193, -0.7318988321179561, 0.807759208000791, -1.0304394971218747, -0.245524634215542, -1.0211809204257603, -2.1477299701227506, -0.08380023070985801, -0.9624218506970492], [-0.2143729093513973, -0.2875852376685123, -0.32630670740435885, -0.3483946942995525, 1.2940215476994987, -1.6343276645056357, 1.9132653571383857, 0.011093665190733062, 0.1748545277700157, 0.25177659927131063, -0.07028436138070004, 0.9186170490277371], [-0.7229114158229061, -0.6615887253485971, 1.0587953222702353, -0.815437417285534, -0.36479862544002506, 1.3270328186122946, 0.6709507485296161, 0.4269384361970251, 0.6389909823728597, 1.3637842195559164, -0.9286926536758461, -0.17161687995541022], [0.49687455331979713, -0.3232589523412376, 0.5487921571540965, 1.3162710265268052, -0.28747116883418755, 1.0071779043104099, 0.31627478619269456, 0.8205868613033318, -1.7375586731075376, 0.45711422377770483, -1.71135870428441, 0.16263389409257564], [0.38609649757485787, 1.3192529986000856, 0.921473279030396, 1.5323126554863273, -2.0340681643533665, 0.3167077565460742, -0.7615391680633842, -1.0358972650948801, 1.1867179627707387, 0.0698978108488093, -0.18288600743854128, -1.4860736219185642], [1.0075747170551517, -1.8937303556685714, 2.744834398327182, -2.4435612961814206, 0.34657026089397985, 0.577090897064059, -2.74190289933237, -1.7637716350364205, -1.4769597688126326, 1.279551078099778, -0.5023119695693744, 1.0914587820367547], [-1.3658619676717871, -0.43813687967765724, 1.2231524685815252, -0.08250958258024446, -0.3527774415471519, 1.4304537545835074, -1.5825954921687533, 0.3983675912712768, 0.21095675545947573, 0.232588398717108, -0.17290167395598544, 1.4923947405586844], [0.9682323329827128, 0.08279357622390694, -0.27170957356271375, 0.69586320662691, -0.43619802195488033, -1.9482054028037867, 0.18267777301118668, -1.8549568906643097, 0.07708907923527902, 0.23018483427796813, 0.206882191779048, -0.33458031035082164], [0.9954088114103922, 0.8464790876426864, 0.3685496982963094, -0.5704416167611572, 0.39858453760781654, -2.1809830029144335, -0.09917722222564825, -0.6346763582170891, 0.4115724032854332, 1.2315187233376828, -1.4160346565156547, -0.07237776525090077], [0.6357423432270546, 1.7409738990903538, -0.5723767538685052, 0.22975672464583194, -0.23019388176527586, 0.33450698836347253, -0.4519226359772978, 1.583434233517235, 0.3069389710207004, -0.6453870906933679, 0.25680364007995665, -0.5145634129041984], [-1.58593675410517, -0.564360059791755, 0.16742665175580954, -0.20802547541327288, -0.045157728458356194, -1.476420034115744, 0.06661679643004864, 0.22043155205624168, 0.2887134796528085, 0.16521554066416172, 0.9057809963145522, -1.5433728613132605], [0.7381728662292438, -0.40357468269882596, -1.4415599048749486, 0.6480478617920571, 0.4331918550183177, 1.6887377410783018, 0.6245506416017587, 0.2120111588569755, 0.22226602241873497, 0.5945082604177097, 0.254218129790267, -1.6868483969081176], [0.23004681422779139, 0.32984254446588146, 0.9164339016071041, -0.048418473584045704, 2.100188204762616, -2.1198054772719055, 2.8061131895847096, 0.016264621964674403, -0.6973728827672903, 0.1040757351916023, 0.5927393068402633, 0.882095837360828], [-0.6174213886987362, 1.2614638708205503, 0.756072472519039, 0.5904814806155179, -1.334076488273273, 0.13175560522161897, -0.4966435391162256, -0.6919147787291096, 2.1233795980318737, -0.8870347132752412, -0.027675904347319456, 1.1300913203344127], [-1.0446529949057206, 0.23998505952447552, 0.7193230247892421, 0.6652793291717873, 0.4818511391509603, 1.678191330766246, 0.8947967919726562, 0.922253453428604, -0.8988199142314323, 2.8870389070233657, -0.33342403047694663, 0.529530157102108], [0.15599094198949046, -0.8913071620608853, -0.5230843239221352, 0.40404477860999743, -1.473338116841731, -0.30131552767517356, 1.1237729600497885, 0.08051921353721692, 0.6432486582463681, 1.4984794705377922, -1.6672291563204986, 0.5727963226714907], [-2.3382887910152417, 0.6223871755751232, -0.19624478702153614, -0.6828782429102842, -0.33081932125730407, 0.2208011706393235, 0.007361804668313408, 0.11424085085826896, -0.45232948392382044, 0.047366779568922476, 0.50170386790539, -0.2771068972579636], [0.16891856958872106, -1.4304608449353495, -0.6598762890089602, 0.39820825638471247, -0.806850158722233, -0.08591016903646947, 1.8998328973716099, 0.5070844722888678, -0.9565568298833668, -1.809738140343966, -1.5371408382097962, 0.5652694780496836], [-0.7732983844840378, -1.118060748833104, -0.44864398960676416, -0.7105906805502773, -2.07598706571247, -0.5240464776980492, 0.48241407262464253, -0.39050403804216616, -1.104636020924686, 1.1561369780285928, -2.688861031236809, 1.4299907781834238], [0.007874033453137317, 0.9672917448550358, 0.5057002290808066, 0.7382373414513282, -0.0416803195980506, 0.06777885262722283, -0.111015889875416, -0.09726349751616956, -0.4448413010679998, -1.1204630569558611, -0.10591465135961364, 0.027646196239202295], [0.8229237340434689, -0.8829844497379578, 0.1765066259877465, -0.34762325666333194, 1.5238983825959136, -0.5100854458692764, 0.7923353828633153, -0.6499903413758995, -0.9848835977794084, 1.0058835007194211, -0.44463453798489433, 0.7218464474067493], [0.4280319962442696, -0.45852975514793143, -0.5087846375495351, 0.34482003164604763, 1.45396020617007, -0.7209850314463039, -0.5148269142499522, -1.0972262140813316, -0.19217732811794375, -0.9113739797576572, -0.5051262392246615, 0.9610558330851963], [1.2763714125691945, 0.6034691645256355, -0.4268137002754012, 2.1773744961018022, 0.32187028599254197, 0.30844638692663034, 1.2093347442187785, -0.33368011738147635, -1.3407619987092616, -0.45221647419623057, 1.4791882778562981, -0.7113562861606257], [1.24211955547413, 0.6594098482762002, 1.0262135726946922, -0.551462595241846, -0.6705551187779846, 0.6415965241493794, -0.6453193661290707, 0.2503612187907194, -0.9577965174338713, -1.2682244166999848, -1.1559621884083902, -0.7843708619320948], [-0.20438321217489863, -0.5814688889293141, 1.0862578912772671, 2.3056868273927567, 0.44313515677166826, 0.580339348601429, -0.26880199153338563, -0.8363268275351918, -0.834146891031127, 0.9864893636373242, -0.9963105600064924, 1.1569131392510044], [-0.3063892871469968, -0.3791689390936639, -0.4151540158799812, 1.6789779304617198, 2.8060894981607216, 1.0752710808964425, -1.180807456235306, 0.3624440532488563, 0.5886834059229187, -0.948941077254395, -1.6964074573414942, -0.18749424470438963], [-0.18195303967483564, 0.19456350199043768, -0.6521636156601364, -0.10368275953139679, 1.9870075961830762, 0.11211123398139725, 1.2479880049203615, -2.5788962189165674, -1.1766694399002107, -0.9531660447809899, -0.2430707092718066, 1.5005605498254382], [0.15087648854417088, 0.874707170557316, -0.7849188614616155, -0.24169994144244125, -0.7678076295811843, -1.0912690296477612, 0.7852776833819266, 0.9816086764728084, -0.7477545001524283, 0.5946163550471741, -0.2452684559373158, 0.14653785163244562], [-1.8559958539669856, 0.9938486288892188, 1.1698182778624804, 1.0540646780393275, -0.49060536519622205, 1.1887747621511162, 0.7931844698394307, -0.5328081963655835, 0.45215366828866244, 0.5636400000584937, 0.2263490456081759, 1.51290739785691], [1.694305402979691, -1.1874129004638723, -2.7598827158227532, -0.2665333945715344, -0.6073755153398401, 1.863122202912264, -0.5385803148718997, -2.2487067507140757, -2.684049492404628, 0.5319466144167176, 1.6503292562406209, 0.06573197110612924], [-1.0924320006669204, 1.5157667830731212, -1.2887522602258572, -0.9190168377888704, -0.26203849579622607, -1.44060617866477, 0.46488397150206034, -2.0245848655501373, -1.859050788020331, -1.5899414746853804, 0.3060836970607, 0.6239546346332222], [1.0226751584943174, 0.9686463655621563, 0.12465587889800364, 0.29375980487215986, 1.5664440416974776, -0.12057292454381341, -0.852079393044443, 1.4191002212042372, -0.08000729990226971, 2.7854561368774498, -1.6522287396994886, 1.1118444898664779], [0.407641824326839, 2.6022547935654927, 0.20442318150021097, 0.25767701096196505, -2.2843517317264492, -1.965724212355123, 1.2284109159233385, -1.0852181446016993, 0.3379485096730454, 0.23116447544527527, -0.9547542286692361, 0.23662836874976098], [-0.6028634755760133, -0.21163851313553556, -0.9671900173384922, 0.8252632714990018, -0.1493848805309454, 0.05252693054013006, -0.8862222387071952, -0.14879228281088655, -1.1464169973450686, -0.36730449168916923, -1.5304962339027677, 0.21112717008045456], [0.46664018146250646, 0.36133963142351433, -0.8205288180168597, -1.2061338543353792, -1.0801365198829125, -0.8488051567186794, -1.0251846345684474, -0.24790095273653256, -0.2432739451381965, 0.04090754457955791, -0.30460625575147565, 1.3795786278895354], [-0.45499291331689656, -0.9886872186755815, 0.023352036286835076, 0.48323491698771975, -1.5609128778711114, 1.126048788163224, -1.662824754459709, 0.5574369129856749, 0.009435831227630939, -0.1014336177403462, -0.01004281047370725, 0.23056680084118505], [1.1064872304737419, -0.386645326262724, 0.8497962099325516, -0.3585572170850508, 1.2080799886635245, 0.009292783415787459, -1.154513724532321, 0.8430290100756972, 0.5583154158349312, -1.0097076561208758, 0.49039279122551216, -0.18091129747008566], [0.08500996679265367, 0.48313542730620557, 1.4737784830808336, 1.212007236492251, 0.9054316991209709, 0.7590589655602228, 0.23094128813717862, -0.6059819662846657, -0.2621869350121204, 0.8578505358571029, -2.067672104470709, -2.3246939184378865], [0.41989957169039643, 0.9773691547036388, 1.2189721333706336, 0.3739418527056882, -0.1625220558694602, -1.3265530401142511, -1.7341930297702208, 0.6516129414977795, 0.4042648665744131, -2.1727968757188463, 1.2208833543478452, -1.3551976546223885], [-0.032693280646394006, -0.39914611885594786, -0.2198800481351325, 0.42502059113470864, -0.7004976235597824, -0.8968687930872499, 0.18485816075290537, -0.3193215523351255, -0.9322219925678008, 1.5668321706682642, 0.7233773163111286, 0.006529254378576439], [0.8883757263036353, 0.821935039371816, 0.8302653267144218, -1.1123323477363378, -0.5554409577567747, -1.0433760200438256, 0.5654350529603425, -0.6991401825523794, 3.048834799553503, 1.2302340510385963, 0.8812955768326032, -0.5198403868408238], [0.9701029832835573, -0.10954057738860726, 0.7281546192506808, 1.757068994867712, -1.4266576557606188, -0.3118639548685436, 0.0886297721536272, 0.5268921093536235, -1.0518527324746494, -0.2914218502606045, 0.7701046070466782, 0.3432271352906517], [1.59563830822224, 0.8377256493751019, 0.6192991302310709, -0.27570261472902685, 0.4075748001844814, 0.5967135011888156, 0.3446791882909978, -0.5661935085765182, 0.6906246864938649, -0.42894332439557814, -0.2708517943431393, -0.472128531331169], [0.823400904115123, 0.5465435253779415, 1.0343191470731765, -0.9604374646531263, -0.5277802585251891, 0.8726953984621814, -0.5911770982547717, -0.42890912853781293, 3.102363030048286, 1.3972393305193638, -0.6327278738236318, -0.5591557044665307], [0.345614111900704, -1.94317074793844, 1.4863104527039541, -1.1421369840649025, 0.30071540949612074, 0.3654666852747562, 0.8032781294623587, 0.5585467840200495, 0.5799377252544272, -1.6852364047970192, -0.3822406175635432, 0.20081866715714308], [-0.46840299769052984, 0.5607932245708388, 0.41864353372181795, 1.1460929959404746, 0.5537332853867487, 0.4268488518730032, 0.11461820012884016, -0.6570985751948283, -0.8654105999345066, 0.16427005706475825, 0.36422247376917777, 1.1229097487910165], [0.6325031395844524, 0.17515060266414859, -0.264256353772819, -0.5060289433059373, -0.706492990651314, 1.2171025804045312, 0.5002087121445776, 1.2465325812252142, 0.9367023556356869, 0.18913930167639187, 1.1856716719457656, -0.7971744328305204], [-1.3098651299849557, -0.9010459737684317, -0.9004166626101786, -1.3461549843048006, -0.9947708284166575, -0.6140517904345528, 0.43382581480612503, -0.6171540915462334, 0.5888908652081595, -0.340281621471077, -1.5141819471896092, -0.6885653029683614], [-1.3470744078170442, 1.9745042202840604, -0.5649182322136366, 0.8623107404331183, 0.11754355577350475, -0.2610847087355544, 0.5764150998729045, -1.8938781011012957, 1.3772063225793512, 0.8544090056593662, 0.2942525729549777, 1.2706972826407632], [-1.6212170698515282, 0.14617289852326715, -0.08419596961322784, -0.010875882420815516, -1.1194872401963505, -0.4034861117233706, 0.5701664546270638, 0.02725968065198189, -1.1709986337752958, 0.8598200214204602, 0.5322511315064321, 0.8481073596529404], [0.19495546650015108, -0.0012592767904366588, -0.9983855988182371, 0.2042439190170603, -0.5683571162269255, 1.0143610720031355, 0.9015950735460253, 1.0414914905178843, -0.37749545730464257, 0.16541862757515513, 0.15321130978271255, -0.9179045506902019], [1.6342615844913928, 1.167515262689093, -0.467345885012954, -0.3018579259477265, -0.8609355629005238, -0.6567219965729997, -0.15476924042236131, 0.0841357314589598, 2.4624688055700887, 1.2366508787348327, -0.33067166148242594, -0.6175066940900212], [1.8443488655392748, -0.5724122890214304, -1.2451050125737286, -1.1764963278466884, 0.007691845764795267, -0.4599666182929433, 0.17040791638649855, 0.3420995719351307, -1.7130948385983242, 0.19166572872046403, -0.536965339793115, -2.205358377985858], [-0.9912441955505867, -0.5319565717826961, 0.593534340045733, -1.1260309014722685, -0.013320199656699703, 0.34278316045560964, 1.0615779310466116, -0.7264431015769595, 0.37605347335142675, -0.8608990418269612, -3.3546026109519014, -0.3333400803861488], [0.6100348027927124, 0.827337938248589, 1.4624170555744744, 1.2789645871547046, -0.7581740168223595, -0.85071574171221, -0.19201951498770445, 0.14629378882680596, -1.21507635022531, -0.5758321705582803, -1.00811662616985, -0.1207230192889248], [-0.5309925692688148, -0.7242248890843164, -0.07998288539456501, 0.6890629228394494, -0.8289525527732392, -1.5119121654749248, 0.4874748737386622, 0.7091041817268083, 0.40952598585108113, 0.6387363338899521, 0.14822976534272053, 0.23292615360613983], [-0.8095594438158197, 0.47026108934779554, 0.14445304212232407, 1.5424468051102165, -0.3308485606429949, 1.0156559783983574, -0.049527530850794955, -0.48413846177700937, 1.880283473137328, -0.5177865796556008, -0.9974411427286475, 1.0928722579574666], [0.9043497054429264, 0.29907657012008476, 0.028442077907060416, 1.8981642057811292, -1.5911104664672995, 0.12953000955055852, 1.1481913382196334, -0.1311798846246702, 0.5067275522291137, 0.6035501913984305, -0.22474676153312823, 0.4427044445397182], [-0.8777807114133469, 0.07024193566497963, -0.3346224548004271, -1.3412777551642594, 0.7141464055140142, 1.4079470516229287, -0.17711061450852594, 1.329689179620112, -0.11202337853606466, 1.4269567729431722, -0.1794114791581506, -2.115143552788969], [1.0773121821159561, 0.5962203870785601, -1.9325601800657937, 1.5349864220866114, -2.183962901121657, 0.19283952365418405, 1.4752232357517854, 1.064619205900494, 0.23801854111242604, -1.0640512296297897, 0.5566302616271391, -1.3417139129590065], [0.3745853097689427, 0.13261696568008552, -0.7074719419731619, 2.2703525708108616, 0.08159027950735012, -1.1489792097144278, 2.3035359394476336, -0.10506793219645799, 2.109782515175581, 0.7895972398659837, -0.40946542918715334, 0.20713145853681825], [0.1254227110670243, 0.9312700797320697, -0.2977444846884736, 1.0096679118630754, 0.22293865034578358, 0.596282210558416, -0.15162156719837436, -0.8116894665673196, -2.3959745886736106, -0.10512470989791775, -0.2607127061736593, 0.047300492359622894], [0.29937861999775006, -0.40751299036936184, -0.9623146309887459, -0.2805922488087509, 0.8788487896875385, -0.6219080985078503, 0.27516420964187027, -0.8843957808100739, -0.6081543679693425, -0.07535544593856859, 0.004800465326586055, -0.8368974066179163], [-2.156151671741188, -0.3266877124843684, -0.6833093330562167, -0.12139494240083555, 1.262422902176969, 1.4648237427111988, -0.9873672572053014, -0.7890986216826822, -1.182097045873863, -1.5720278601603153, -0.4798668194888615, 0.6966429644232823], [0.4269127570049411, 1.3258070415896333, 0.9565138838015463, -0.5738276373210979, 0.45233364276431426, -0.7097728644343634, 0.32128224949013945, -0.7326704880988311, -0.9886221159315159, 0.10416129977457647, 1.9965715538493742, 1.4114506914729692], [-0.41475724573042116, -0.14945246354666908, 0.9225479816009067, -0.4966680446978137, 0.5066581751528695, -0.9269083651343607, -2.867805668889341, -0.016134939219534305, 1.6625337041759416, -2.071816080917284, 0.13078056660337556, -1.0869145156665345], [1.9467260832799178, -0.3866123284415833, -0.17192035268390626, -0.7795518665014768, -0.6179166312146165, -0.7583380698464894, 0.28008320320020097, 0.29187173619268697, 0.5350831186623977, 1.6229822224572341, -1.2347030494345448, 1.9116839257516474], [0.6680464877023257, -0.5854680373819905, 0.17693189224807765, -0.8670383717953625, -0.3752057371883799, -0.6669623517081519, -0.7964300719187082, -2.3937216226236258, -1.5005481568951538, -0.8940775761676271, 1.6952256372364363, 2.2296451828256196], [-1.281102437451501, -0.4512517079277785, 1.3117296532457412, -0.9673027951439621, 1.6420484127153612, -0.4155425214150127, -0.21802763587499033, -2.1636019766507877, 1.6694826796184863, -0.5658568952590535, 0.6186975445704976, -0.00948612228224199], [0.3217449081477394, -0.4398012081926089, -1.030306274620592, 1.2360797406509894, 0.4570638248135404, -0.6238260666780044, -1.553769809801954, 1.107221895012283, 0.010327170327009087, 0.5488402102347184, -0.003196492140838625, -0.6756906423871504], [0.2003957032209025, 0.41145151974189637, 0.8730237423233944, 0.19623610438782044, 0.3816300600655706, 1.0438695873048267, 1.1153942395665395, 0.654978627130961, 1.2763394481244896, 1.148407810096469, -0.19096614561486833, -0.2345272582572501], [-0.24918022797896908, 1.788721741199886, 0.5905960459819185, -0.8418039410889798, 0.12941689607565587, 1.2949704196737557, 1.0691438435979457, -0.29843595473302487, -0.279534346538444, 0.2848760743979119, -1.4127826961460102, 1.153865841709258], [0.20564633761546056, 1.428733304803167, 2.0944768591664964, 2.6758537577056427, 0.812350751689581, 0.9132050147699797, -1.285668082806745, -0.6152222698512398, 0.0735939673421916, 0.3971520237426192, 0.12959452136952895, -0.5357655433593221], [0.07931719800379887, -0.7368580928300809, -0.06527008778900574, 0.5585002269234683, -0.23476721998249364, 0.65798840810686, -0.11200733853271652, -0.4825124009481955, 0.6478905334624226, -0.5798172811547181, 0.707967410048666, 0.7639551656256971], [0.15076759747838153, -0.44879387924571956, -1.0824219722357078, -1.2174830379519077, 1.1405184423554369, 0.12574034418249178, 0.6870351588864351, -1.353931957327374, -0.13316773184203087, -1.2128656316053799, 0.5098272029138281, -0.027739221149293693], [0.0024717709116986444, -1.1171413423783654, 1.1029061566176817, -0.15166826422379798, -0.3980864770303689, -0.8298372392007186, -0.18638500399360777, -0.6643835562174673, -0.050684170198113845, -0.29592693974815215, -0.44515175215758196, -0.3623611137257502], [-0.4365027888543783, 2.01641676420379, 1.1006570168702816, 0.22290217937750928, -0.39005242119267536, -0.06904957238032332, 0.9848210087331342, -1.0763310441193534, -0.6315639008542928, -1.1763353735117341, -0.053915170187024505, -1.0146060183899643], [-0.19235060608368218, -1.514479645980267, -0.6812792180514412, -1.3067628710893473, 0.08006094987991248, -1.4387143736032475, -0.6789581159586304, 0.47111506875101133, 0.6782962722874167, 1.8249152489037541, 0.5328887759417527, 2.5146843989586247], [-1.0706017364634726, -0.5833197997945294, 0.8271402632426309, 0.2634484744594253, -0.3975128958081296, -0.9023183657480609, -0.6822706103166541, 0.3970400343023306, -0.4628641680569958, 0.9452335507733662, -0.9898426121665368, -0.02764332950827532], [-1.8081536524825346, 0.2870071953735089, 0.42149429346186984, 0.6621723731070509, -0.5093562257342031, 0.9459733833142938, -0.14062296849931508, 0.6017952119010279, -1.582221574855319, 0.6989206548312918, -0.46439334167957164, 0.08991582490509044], [-1.4036140624846538, -1.2817353048985454, 0.2335121846479881, 0.6997330794691913, 0.44383663677830293, 0.4503277438301374, -0.24357478182698544, -0.9854526142607265, 0.8653262517864759, -0.21829798474664525, -0.8440926763313233, -0.4811971869100786], [-0.5188857056760484, -0.6713700566197885, 0.30325074475871966, -1.4555206654539339, -0.3456650310599472, -0.8847397176920586, 1.3897867785420992, 1.1471011988502504, 1.2655191886629782, -1.2369084521892704, -0.8527948690998688, -0.10902596277615798], [0.7027577305090718, 1.089470123550922, -1.2455923983499197, -0.6205270124390511, -0.05459517616883463, 0.09550796213054258, -1.3280265723840812, -0.7020404515921866, -0.03636652540284027, -0.3769727981913812, 0.4737348629704364, 0.43876648070872976], [-1.518913906909168, 0.5807332911968075, 0.2810329426448713, 1.633562368516624, -1.9342764996269937, -0.18846920427369107, 1.7350661477873814, -0.5960177756457237, -2.0297409839997664, 0.6046845387122686, -0.5595483583833097, 0.3763735571627928], [-2.427556620436844, 0.6873695715756066, -0.25198725195387495, 0.09930749912868815, 2.0871924266983353, 0.327506882835093, 0.3391046468682429, -0.9134283950016456, -0.23858292216490248, -1.6731007328490686, -0.7445887451088635, 0.9759427316755359], [-0.2412320185061464, 0.813560094033261, -2.086690614255493, -0.7914112582253254, 0.1786322094618272, -0.8918262782861002, 0.7953459766819594, 0.09551401501522935, 0.41401410610244654, -1.1833793311340193, 1.0028827306001828, -1.2863824766196978], [1.4434281186164861, -0.8904594216966846, 0.2552170412150856, -0.045105590074835174, 0.6494544224865223, -1.962196202932021, -0.3445593134151967, -1.7643717769360978, 1.5958092345143313, -0.08076880844186603, -0.9540061046857876, 0.17473265837728946], [-1.8646224574050572, -0.39737117965200813, 0.4194254985066792, 0.39024380351082505, 0.866940182301269, 0.7093493938198517, -0.3853058119557529, -0.9991442952587049, 0.4831314654604742, 0.36879697466072725, -0.7220001373054509, -0.6463250613484037], [0.37348396148587154, 0.45004197040731875, 0.4380207362259844, -1.109775850534536, 0.6844114708997476, -1.0190091307673943, -0.7391562027763431, 0.8550764357827214, 0.5723605990786119, 0.03340038221535875, -0.10396616773459966, 1.433580899137501], [-0.1420305348920662, -0.9477174756665155, 0.36031419000980475, -0.8924159299757797, 0.2891989833695574, 0.04642471238728108, 0.5486083403714923, -0.581368556857314, -0.6526447106831221, -1.4251769304503092, 0.42131970752677966, 0.9941360192461977], [-1.060144836777697, 2.652439820999267, 0.8572487630135436, -0.02924010414555474, -0.5771559719435464, 1.3490793655404216, 0.6879537191015972, -0.5241048710428159, -2.4119373249043026, -0.21064228734066506, 1.7583006386077202, 1.0448367955364979], [-0.0018693951601625068, -0.20017898870413403, -1.2285518901302659, 0.3274848226085382, 1.100731324687566, 0.4881181267513632, -0.12499841246370479, 0.27499133327422476, 0.021843300637166756, 0.2958548294255374, 0.4318053318410643, -2.6639000138366233], [-1.0128661062046058, -0.20407139815942982, 0.3856412321616334, 0.7531669743130287, -0.24253951817628447, 0.49150626512467416, 0.2516786261601551, 0.11018037839204657, -0.913381681219023, -0.4933664996958377, 0.24811662181298433, -0.7160985923123833], [0.0674761524039122, 1.768416417741651, -0.22206164007601156, -0.9033177211576111, -1.0948797623186768, 0.42032885140968657, -0.35247523004590675, -0.566683548295464, -0.9408366134520025, -2.4563060996523483, -1.4600146764469317, -1.4111088198763913], [0.02193167676217913, -1.2619114429533798, -1.601138760340738, -0.8576095124519714, 1.0014108090677578, 1.2130355273747713, -1.0627585103767672, -0.7008787895095837, -0.7276207541640188, 0.14359694067330225, -1.6967084067725864, -0.9584276176699801], [0.6373352025853644, -0.8375635796407636, -1.6000756375550427, 0.818910980687781, -0.6349233739726973, -0.6081020673558027, 0.788177212878949, 0.5279402798482531, 0.05411721376184067, 2.026845583547949, 1.4267845598683373, 0.4481639111804557], [2.287096288737441, 0.5321253927006611, 0.05032635041961942, -0.4052618145237401, 0.2168898239490315, 1.7650400834715358, 0.8010547693100238, -1.186659065059624, -0.3002138406892935, -0.9876949369047027, -0.8410870826590621, 0.29808579473126384], [-0.8843525769162232, 0.05310569963579086, -0.7629156606188008, 0.7179565463829448, 0.47871043844630434, 0.044020660611114766, 0.23664200627348056, 0.17347610598287186, -0.030715426689863705, 0.004174400472445276, 0.24640191372167858, -0.24871646411360238], [-0.3069229487393519, 1.8594252787263823, -0.3765367179689022, 1.3635702840482762, 0.37147377790740943, -0.018936032854013903, 1.059710631467886, -1.9143935085558614, 0.22381447944360294, -0.3336772053780842, 1.7743512235136356, 0.14661184408204528], [-0.13624968882468663, 1.1605586810536495, -1.4208979516686215, -0.814886535062292, 0.5600391083160812, 1.1342328565544917, -0.8017695023223662, 0.3447625495219225, 1.8698601231507685, 0.029647664935091217, -0.3664650155551474, 1.17235283825648], [1.4555304760070258, -0.11268827621678718, -1.7072244394836615, 0.9037923144584937, -0.08641340302138133, -0.8477684328906507, 0.22270305745024932, 0.6882168813729845, 1.5560688925744688, -0.23096737729245664, 0.6906360245102502, -0.8693544579795351], [1.4320415552093684, -0.6221151077530626, 0.38573228785867497, -1.445256228159655, -0.9002663275175095, 2.011679748977873, 1.7258600480131312, -0.22464128465274358, -1.0861750547689966, 1.5525009223356792, 0.7315636913533552, -0.567403114791677], [0.10178017224588651, 0.6374373992394041, 0.750097718022646, -1.656743477517054, -0.3571312565974751, -0.45564075418243094, 0.6271103388422069, 0.01048205565348539, -1.1247548375576593, -0.5909120782737828, 1.2493977164109613, 0.47814553624653894], [0.4454366270773639, 1.6977727878819686, 0.6916235644213331, -0.4974856875051417, 1.3269606528923639, -0.34199410676486713, -0.8559890897167831, -0.10436290666694625, 0.505131669090938, 0.22271981514855288, 0.8693579508055043, -0.35070189681609076], [-0.43666240292220493, 0.01826137423953062, 0.9731140215555691, 0.4847818963423138, -0.9070307613226913, 1.6877002878439422, -0.09670405307958081, -0.576149486055721, -0.19364919362583236, 1.947758277501561, 0.2691126185886686, 2.3097526068800516], [-0.695124789688599, 0.40324164939351104, 1.5449360143045592, 0.24045282999671502, -0.17270500879726122, -0.12964779736417265, -0.3719765139039306, 0.5806352338684404, -0.9507798760366486, 2.1419439336201784, -0.5918225571256801, -0.15622071607574728], [-2.2544149558009066, -0.954762905915159, 1.053925137945883, -0.4888950482333896, -0.26965756109283623, -0.626273964139677, -1.05711755760137, 0.5698133494110567, -0.03937665175088372, -2.6430685526570152, 1.287522687840108, 0.3126638137829928], [0.9729468329674171, 1.0494395390497864, -0.532916186043122, 0.05318079956546482, 0.680342757519338, -0.3602523311058911, 1.4261690719713243, -0.1158618287088091, 0.7784710549697561, -1.1307490141191794, -0.6632038572844334, -1.5726769319490614], [-1.5295621466053222, -0.3954698208442367, 1.2647109717650094, 1.3150293528799495, 0.9573458463676865, -0.04972204118849331, -0.14223805153168154, -0.36914332202911504, -0.5692047574940932, 1.0740169823196344, 0.45980304433390234, 0.4185742821154355], [-0.06995728795550858, 1.3649346953722317, -1.416635885119307, 2.1409976516140565, 0.6890447723896467, -0.2061553231274837, -0.6434268223474292, 0.7487615996248593, 1.0130926844830075, 2.529770836386602, 1.0611534080098977, 1.027630558526109], [-0.5822224843199099, 0.10055727208230747, 0.21052962845069542, 0.8494558526162441, 1.6282325946807896, -1.4155420745652856, 1.1155270113675506, -0.08181280891726608, -1.617455013381501, -1.9861566017254504, 0.9437134264803168, 1.5816231352427224], [1.607036671728962, 0.5639947329203228, -0.7643166503021319, 0.6655576613005304, -0.966542086781227, 0.28930419878439806, 0.1969347432563255, 1.0220245866335882, 0.4545948808705085, -0.1347086076235472, -0.525864174120527, 0.30942426073325485], [0.31735568416842475, 0.8267010762603327, 1.279456368596026, 0.09136240470089271, 1.07918515651281, -0.034579752069754534, -0.3945494426127943, 0.5803054433520648, -0.06927284726414977, -1.462220474997967, -0.4611461549772719, -0.2155800103407711], [-0.10533279810729733, 1.977512073014115, 0.10455909596393195, -0.6928842437714322, -0.34469942541407655, -0.0740273891787532, 0.3553695746397448, -0.31510936766617825, 0.9513126548798658, -0.8834346824495891, -1.008186301635205, 0.23395155952405475], [2.027438353710441, 0.27083679369181807, -0.23361960909713578, -0.6220633746597626, -0.7584326680355166, -0.7802139500186371, -0.36287875966616845, -0.6368558349079355, 0.2586481610670092, -0.26506742165311276, -0.6244518494213649, -0.5277501843422164], [-1.9128004801920329, 1.5440736357283054, 0.7566031093501792, -0.16412062581511577, 0.7710529884553762, -0.368719080880943, -0.936448249959508, -1.6961209141392064, 0.4593640914370595, 0.6660039232565756, -0.7284842973712997, -0.3433370366847018], [0.14326797605269984, -1.2259567410539798, 0.5670197522309788, 0.9474277330770567, 1.2675025442020207, -0.08888007038710703, 0.19088732177825413, -1.4205152681254598, -0.24494731649936008, 0.190683616342453, -0.18565972781750759, 0.9332557822376959], [0.6432749176175421, -0.830008662859414, 1.7119827333084376, -1.1174941644784429, 1.5034422740589213, 1.8004216176388699, 0.21471574088878367, 0.6146657883835404, 2.0542533255731716, 0.4534888238178736, -0.8558405077679728, 1.3655926419665754], [-0.0934928573891508, 1.229793411624495, -1.361062879233802, 1.185241715214439, 0.8577558289298683, -1.8934151612335248, -0.6909955010806799, -1.6929008537592163, 0.32340917112443457, -1.7807255237906892, -1.466562341731945, -0.4331783322322386], [0.7630696074322947, 0.23077416489472405, 1.5736127270781384, -0.7139139987707106, -1.5170435728119436, -0.7297324087653986, -0.9317928194015799, 0.8338957445848272, 2.6212435613212857, -0.22500415554552491, -0.6633313146643594, -0.2199430514619886], [-0.0421779537468883, 0.7789740479536011, -1.521335077524873, -1.0018389506058987, -1.4960146768936786, 2.5523072482663207, 0.3444230022331276, 0.4933584864859526, 1.3328642036834788, 2.651743028358975, -0.6393461840059921, -0.937401339530449], [-0.34318806081962755, 0.8098228466440685, 1.0943248496222404, 1.0164990847401474, 0.2764686361401625, 0.9974375385660381, 0.5537633022157571, 0.5015619851904595, 1.8322264222613054, 0.49239534428197923, -0.36651779591835654, -0.10021988561754132], [-0.5109093541656247, 0.33577627847446473, 0.45251683337884635, 0.8225372034824814, -1.3144597014684247, 1.7742006901763434, 0.2488154818634425, -0.4416386170902903, -0.22967511341321709, 0.349782122493363, -0.9828383869369225, 0.08020340534468097], [0.3282927367895029, 1.2748528982348504, -1.2640632832826286, 0.6038387141864123, -0.9774436034007125, -0.08769564379570745, -1.646420838575136, -0.30190822088240515, -1.034806027231458, 1.365534557449539, 0.23812435815499558, 0.5641882763352031], [-0.4129773468776012, 0.8542946514889079, -0.57212033466635, 0.8183628504850847, 0.08260282327484426, 0.864161866363602, 1.0701014527512602, 1.2848183767799612, 0.6790689466930341, 0.7894369129389264, 0.16525022901540135, -0.4265995612507275], [-0.8085489402071353, 0.8138030136802384, 0.8661083579701383, 1.7699981163455238, -0.4100340889256417, -0.15891952565887843, 1.9249015209426978, 0.22186411664733652, -0.7834201757569557, -1.6523182805730485, -1.086620186421379, -0.17502020537306953], [-1.2288477790714198, -1.2373168112816677, 1.99875406311317, -0.47274499948099324, 1.055040512491239, -0.1583742557085105, -0.8659768193110744, -1.8806312457002237, -0.7927741024402775, 1.687438912189789, -0.47336411882333607, -0.5829686195786323], [0.9640120224038561, -2.2902513958069965, -0.9981344579730358, -0.8140032584164119, -0.04690574271729646, -0.37280144329115733, -0.4143843942428087, 0.18946890888422402, 1.7735334891071386, -1.3966748741221982, -0.04841486054947013, 0.4286182260587757], [-1.931976048177586, -0.39551104842487145, 0.09876511302094816, -0.6038973022853444, -1.8799464541682844, -0.44576416562923127, -0.053810365696438905, 0.18614255942659116, 0.12560740978601084, 2.424796967826574, -1.4616359769539673, -0.0857821850733989], [0.6835992680892868, -0.7928116914419306, -0.45577338573925974, 0.10030419205547682, -1.4215013986659246, 0.7256053404160158, -0.1544193804937758, 1.5990352562506902, -0.7490385243364467, -1.3426693883560576, 0.29454633594846213, 1.0881951688983909], [-1.869462741291656, 0.10283591225573319, 0.2303060512423583, 0.6549323338918952, 0.7486158465029927, 0.8427440211992542, 0.5942317741308467, 2.382331108572868, 1.8756071035005213, 0.6788615731557623, 2.463964449935476, 0.09477010286961285], [0.43474607862983267, -0.14178238652146788, 1.308615414948624, -0.9050891843492144, 0.054519315198099876, -1.0242385428999923, 0.6519001765888931, -1.1325243723370528, -0.03920019286384361, -0.4851065479286687, -1.2505017287921296, -0.7241172181296734], [-1.3458940813050173, 1.337350066929916, -1.4139594058264766, -0.7853353435967575, -0.4382413195881902, 0.3868023653549892, -0.22372790397377978, 1.031247433161917, 1.0913150252941515, -0.8605367565339012, -0.16339124492935864, 1.253788167025585], [0.3745673941108123, -0.7963224527069775, -0.4587924372381681, 0.9299497739667768, -1.1291482594570112, -1.8724311165399372, 1.5960576299084257, 0.3436738590047325, 0.03008366845310413, -1.4982143427384815, 0.4080165173685655, -1.5309805686866134], [-1.10543092981772, -0.812350433692039, -0.901657227139037, 0.8060761184577223, -0.8547112891191966, -0.7189662866054807, 0.22233083840066276, 0.9898033130271593, 1.1212095901109467, 1.8767921394278317, 0.9081914023001033, -0.8605494903948265], [-1.3965795466643967, 0.6184631522987641, -0.36250588552552104, 1.2424750812484813, 1.4516162284672325, -0.14543721152063002, -1.157513211368219, 1.5783171994320728, 1.5108903358715147, -0.15407364043968677, 0.2719379148659537, 0.8922130398500768], [-2.4104937736729997, 2.0890705800365086, -1.2398787209824118, 2.073004448185619, -1.535433921875733, 0.2624060064206941, -0.3183751592073809, -0.13951161816443616, 0.2999143477201498, -1.6985046504749275, -1.5213425416892452, -0.7635092630986796], [1.1793462986614693, -0.24418504672874058, 0.6851104437599531, -1.3695068344851338, -1.8449517667578932, -1.2286858966753322, -0.8417341320660213, -0.354625012525692, -0.13256945587687285, 0.697892415103498, 0.3469284222939998, 0.3718296247113548], [1.3345104498519158, 0.8562752804705187, -1.2736070985724595, 0.6359147510746714, -1.0108061823088776, -0.24767847027012088, 0.00801703241965426, 0.4302145687116035, -0.5812642918944789, -0.16084037995826567, -0.3007292261736635, 0.27416398191980756], [0.5358542220893889, -0.03167209636003519, 1.099323291802006, -0.9299435541779895, -0.5379417401590383, 1.9926719453093744, -0.13206559066447043, 1.9292614090833993, -1.8723653176992097, 0.04935689425467638, -2.4997190077166045, 1.8580685838086433], [-1.5134663394476942, 1.7252773973077842, 0.9648403386962522, -0.0182628535685484, 0.04989644305181737, -0.5650725341497789, 0.9170992592564757, 0.6213784305199863, -0.5863980582281112, -1.4634430185654512, -1.1694783000683102, -0.756981087023097], [1.2875730274556938, 0.7984173859776668, -0.8644009383267128, 0.55661857673963, -0.34303008131141216, -0.5501565915184286, 0.9866496285496602, -0.17160867113087921, 0.5776401914927026, 0.9355698371317106, -1.7228038135177925, 0.29451537937867633], [-1.131451576147863, -0.3087118562291893, 1.654474594744117, -1.1273418739243275, 1.2302396210963098, 0.30653849120420906, 1.0950540833110642, -0.9484842904113293, 0.40429840462802585, -2.0190838890262146, -0.9137660479569074, -1.510585607090789], [-1.2391503047020929, -1.7569138007654879, 0.9521163709476179, -2.3798418674870216, 1.0757679763558607, -2.1616490903509256, 0.8027953790438486, -2.17979719484968, -0.539409601722928, -0.12309055794270528, 0.3721836651253158, -0.8041890565139708], [-1.334265598913095, -0.598681848660506, -0.8088340064810063, -0.47805338593058677, -1.0137193380011684, 0.7127279945926466, -1.98381259686906, 0.6551999460572793, -1.1039477042093193, 1.602537721169607, -1.1550951622702168, -0.597335218154116], [-0.10960531609093997, -0.252356346091473, 0.24563067637103705, -0.32226575740753094, -0.9964435148508063, -1.0902321268595756, 0.28699925707769075, -0.720359844982407, -1.3810588914549975, -0.9699471072669832, -0.36965085895360267, 0.10534525112715902], [0.807470462764774, -0.6429032778329055, -0.18174769811900146, -0.19011782741775465, -1.2923346277493792, 0.3727155522199335, 1.3571956196071235, 0.866177186670223, 0.8810663769505814, 1.5352242045563405, -0.6964666621263917, 2.476962268083965], [-0.1552817663043029, 0.5484264884010955, 2.1637724702352443, -0.6239361357581737, 0.7437421894855422, 1.8885773771643597, -1.0208627438490667, 0.342926479502286, 1.3224912546769918, -1.394782832666528, 1.1797710872910236, -1.1105592978521774], [-0.8571889880847822, -1.4863283139425842, -1.895628143287184, -1.2572060685428823, -0.1794092865059618, 0.16827266776710448, -1.4250435968105957, 0.17592416759365423, 0.8247349913915477, 0.7940764861211893, 0.3351075921100114, -0.1977982058059714], [1.316443544104905, -0.7250130646016688, 1.0745566625738392, -1.2319137580208788, 1.2793325821140817, -1.0526357933648365, 1.0542388175602921, -0.12119988194220743, -1.4389051723925266, -1.1363450627150313, 0.24953462280641003, 0.8816978133746598], [-0.869728222460772, 1.0068233716398036, -0.9249306011676227, 1.3820913834373605, 0.11419183861600785, 1.082281143680376, 0.6983479132440203, -0.6209627749380848, -1.2018821630058274, -0.6725546345159171, -0.4201925915762037, 1.6003100439955449], [0.7506084145622665, -1.1200428098035948, -0.9133080292424085, 0.09313659890881401, 0.03356715725001326, 1.3446416575156361, 0.8984396330196848, -0.9416858913685016, -1.0315117598935861, -1.4336694891022068, -0.7929390418913934, -0.0379720967552714], [0.947329868787379, -0.19911787046134868, 0.940919204129665, -1.5135171798464897, 0.8929126548380045, -0.49377839822729785, 0.423362668126341, -1.056740497941259, 0.08435516932289933, 0.7830909796912211, -0.633517769107887, 0.8703220836336704], [-1.558072209691456, 0.6083286957954464, -1.617016113025125, 0.6185619920530862, 1.1165790551459183, 0.23809845870231133, 1.2397725840031155, -1.2777938599593068, 1.9165436001707934, -1.7080121519898999, 0.984083421556798, 0.39699439008612686], [-0.3052323075713646, 2.504425420794356, 0.7649816972659732, 0.25135945464283505, -0.7262705209795224, -0.10442155687496363, 0.6457005487596011, -0.35854356305214835, -0.21220287157690743, 0.9221045800720004, 0.5940348510414016, -1.2101105726587988], [-2.20634132536848, 0.19447615895971945, -0.3765436534587039, 1.1795273572298794, -0.21535183192575105, -0.6470154013167791, -1.6739970821846186, -0.4327015718484487, -0.4091453678387515, 0.07211195451332993, -0.7954272523273874, -0.2831912420044293], [0.920010071791984, -2.0728550001563386, 0.6303007404742774, 0.21026230338482824, -1.3446130376599186, 0.8975358159544348, -2.1912519812263485, 1.1982949155255218, -0.8440250109447575, 0.9858366495056641, 0.22710766270129154, -1.6247887237479683], [-0.457074793803695, -0.4033617892797817, -0.4804808303938961, -0.015633168965923365, -1.5211491229199214, 1.5391558782056955, 0.6655861173728382, -1.8414737502310623, 1.4387569270556306, 0.6107921904023114, 0.34412951866119906, -0.21386930998230136], [1.095354307420372, 0.7943546810544645, -0.8494215576739377, 0.10547603104292834, 1.2276917153647635, 0.2295315545078757, 0.17676523656223433, 1.2853022875416482, 1.092678881298167, -0.4932409206200229, 0.3393690277767219, -0.9241924666676342], [-1.0696677396831717, 0.7149633574712261, 1.0559703141719048, 1.8232571559880393, 1.3282722330535435, 0.42843297058468877, 0.9644915696325255, 0.5573698680810891, 0.6844437245629591, -0.8474756753261453, 0.8942423508816308, -1.0907699868823222], [-0.7774206104150034, -0.9321677143276085, -0.8314465701311818, -0.7331059756357465, 1.6000323963714707, -0.054344691896791336, -1.674303536926744, -1.3501418320013205, -1.2097982607070292, -0.6584981902992644, 0.3485833628279476, 0.3666106474590363], [-0.22457294378659576, 0.15854787156326228, 1.6106575168131114, -0.21689962157414439, 1.383372042789926, -0.4796278122131246, 0.20288477055229565, -0.5966137774207089, 1.9209296306945147, -0.10991542207102527, 1.0370055712472301, -1.08766481311671], [-0.8971765779047631, -0.31688444839648877, -0.7873467783107722, -1.5964799880029181, 0.8552749168948901, 1.011648698977825, -1.7264258142918336, 0.5930082790508215, -1.4670656143461787, -1.4122592049103355, -0.7540898697840923, -0.8028386119474199], [0.05836607604664486, 0.2100826451253889, -0.5442998954121094, -1.2636873219683566, -0.5798542819403478, -0.28669953670582415, 1.3445554936699453, 1.6658005958209006, 2.098686085356378, -0.35249279318049825, 0.74195839826924, -1.908238020659237], [0.1533838515832163, -0.3609488588332428, -1.6287448148881531, 0.31514357084611827, -1.039036593756198, -1.979376192315338, -0.5481459446910641, -0.1386576275849644, 0.1463245454054466, -0.1699063175736591, 1.1978250574355918, 0.14242819400805365], [-1.9712557565558062, -0.8196941604334678, 0.8185017066903911, 0.7910515022461891, 1.6017097308158545, -1.2742514592437755, -0.42460621414524446, -0.44711046472460375, 0.6812509524925643, 0.8817049276260204, -0.3536764070942718, 1.0670134530955733], [-0.7806945670008566, 0.8763747676465777, 0.013495990309623, 1.1119259160023083, -0.12532721031765037, 0.4868381450732822, 0.30811430403757784, 0.07941102934956978, 0.08814289932599294, 0.8579714006698544, 0.2473154739213592, 0.9180589634999514], [0.2046704281037662, -0.38707843834940464, 1.2387941026382132, 1.1157502567427562, 0.07706958739514179, 1.2362694005092212, -0.6999390337917425, 0.18607763717437675, 0.7412099004574401, -1.9292032102288688, -0.6179896035228808, -1.8741651040838174], [1.4801676461776134, -1.8610998824306464, -0.749119451345166, -0.3418433940498811, 1.3307965692854589, -1.0365450089971542, -0.4328694292799845, 1.9442622815955997, 0.3643447786108301, -0.19140450823457744, -0.9541831232124989, 2.481053087782285], [1.46751574803546, 1.2880977231527662, 1.4806079270729906, 1.2436593583738824, 0.5836625860057674, -0.7969492193449433, -1.5009699977873303, 0.5916478268853489, -1.555232160799702, -2.6961228047394266, -1.495644948812446, -0.6898750574592916], [-1.1151985515750482, -0.6824689714970081, 0.838095419695699, -1.2276726783817034, -0.4367935441894253, -0.8803906608604095, 0.557142294551505, -1.0417540962598768, -1.9009541945730335, -1.7305309173460235, 0.24327713111380106, -0.254292834213448], [1.3511159603227851, -0.052345826225607295, -0.6721917815211457, 1.3770334657720125, 0.09848093567412547, -0.7246658973953866, 0.9312876715787644, -0.822543043805687, 1.2635243145483306, -1.0075034860684342, 1.5720137432362995, 0.39857777645467657], [-0.7366012946887865, -1.949510302660091, 0.526657610433531, 0.028218990950865067, 1.4200801289810134, 0.2409230997486913, -2.243702113275527, -0.22109160904214678, 0.9113777609697624, -1.4030053974218908, -0.13036264670650877, 0.09748397142833644], [-0.21707372135733044, -0.27358239818317226, 1.1029086060494278, -0.2886193482842899, 0.5825187775467449, 0.7962758166130716, 1.662552321249614, -1.5072823967465714, 0.9251038346865147, -0.11885215539414837, 0.7243074000373916, -1.5586490365336572], [-0.4961695584489029, 0.8403051582804595, 1.7372051702645102, 0.5168786362335117, 0.42131033850955313, -0.11608616049100229, 1.6736049672395397, -1.5289782826352083, -1.8686008325903816, 0.4429144192878081, -0.9397020729500213, -1.2525260466409247], [0.27689023886860037, -0.8321407121853323, 1.5377322891992502, 0.47110633830209364, -0.47638986683599766, -2.1167838259408542, -1.0757701334147454, -0.8275749426713007, -0.2537082913586633, -0.6734161520200787, 0.13819394072686875, -1.5761667813658629], [0.4588532539807755, -0.7568458933297351, -0.5706425433651978, -1.2533493832653366, 0.22566846913713942, -0.9168214710260155, -1.8298602985491028, -0.6468896151701007, 1.083045818871829, -0.20015733703842664, 0.2320645952666308, -0.5006994252621341], [-0.002968749346686863, -0.23525330785244764, 0.2309292694357107, 0.37062640341454434, -0.27971481259210634, 0.23599528747529191, 0.6553718938954696, -0.08492786709706594, 0.07855758504918987, -0.5576133503601582, -1.198370331118682, 0.07762710206408553], [0.531460061863597, -0.23861333150610103, -0.1272065619662702, 0.40536969989906096, -1.7746187140367102, 0.9406376964635048, -0.9504755159055831, 0.8183554576066905, -1.6341060166064683, 1.1697135138526555, 0.715353717236512, 0.9534104720198431], [-0.4202017025771119, 0.06024445985578841, 0.5763563348202572, -1.5720749897039081, -0.352379918163468, -0.49657177168934863, 0.37317265564678687, 0.15641029092950928, -1.169378638126556, 0.020022512816641285, 0.4818007105193764, -0.025765191548170432], [0.4889526279355749, -1.0383820126685843, -0.5083791321592518, -0.43833771833005913, 0.41817896407540806, -1.1515572435228658, 2.197247524801745, 0.38412303449860175, -0.36859621671009457, -0.8009108529479818, -1.3824478970847527, 0.9686052747265538], [0.513457370000412, -0.25843135399575773, 0.6330646774093888, -1.7581506135684675, -0.6781688758973816, -0.3095526044298768, 1.1479051458375797, -0.5027864390282136, -0.09092203787573096, 0.0847720848235985, 0.7773479544012171, -0.4358356665661423], [-0.8397961703479321, -1.0860313506539552, -0.08592471483596308, 0.4388981601914886, -1.088579948865115, -0.3217141997547084, 0.2964268738636206, -0.20575894872779985, -1.3164133696116591, -1.5761638176457387, -0.1472398539779676, -1.337475652500625], [0.05126903304911362, 1.9448265129272815, 0.6222727521927173, 1.1597285465613285, 1.910505839992805, -0.5483719491769287, 0.9895512554016608, 1.4199060215240076, 2.3980624240599324, -1.3167024798381068, 0.6583798610010293, -0.0655569024029307], [1.0924794690424013, -1.0651193472205258, -1.12588860401531, 0.4548879529293684, -0.016790121176331045, -1.0114675043784473, -0.8522589103116156, -0.6926691269103528, -0.7339339996300962, -0.5132980732120038, -1.6504313596340237, 0.3682942516989245], [-1.0018970111817855, 0.37973639972743867, 0.12281877398067016, -0.25372416393980424, 0.26347993916880286, 0.3825854741293839, -0.05562813550146556, 0.9996872803693586, 0.6204065536952603, 0.9179901214798876, 1.797982080111791, 0.9507401914610428], [0.1657325426141879, -0.7993003685286174, 0.6828504537213543, -0.874607775036338, -0.049201899170218014, 0.5251914575667226, -0.9080348039054715, -0.03190835052411321, 0.13561675239923834, -0.40375476979093383, 0.28267969876074145, 0.09124650518418918], [-0.17078824132044684, 1.3838805478524534, 0.21490862677709913, -1.1258948438182481, 0.4737621202245864, -0.17476720763456863, -1.597224159679323, 0.3383020768762175, -0.5218379899365573, 0.19641605064451015, 0.03826767422931168, -0.9047707061342622], [-0.5716353167884786, 0.053972633270899975, 0.743575995444726, 0.5543987817676077, -0.19443843078734382, 1.9067026685726456, -2.341798313885822, -1.5459006011230156, -0.11668799148091802, 1.6276436239730114, -0.06916843900555744, -0.7877989158768159], [-1.1009315183053139, -1.7058456984104347, 0.4513278883801764, 0.47673542433183114, 1.5490558299592996, -0.9594470734114907, -0.3889978064417793, 0.08126145471881938, -1.5304411042816037, 1.1411776225550965, 0.32803413669778964, 0.1554449103175454], [0.1173506851880499, 1.4994361415295268, 0.12236655752286658, 0.5890135316575955, -0.9011314476662212, -0.48374504955143816, 0.17739209547566892, 1.0743172728007122, 0.32150592585670534, 0.9974800605534629, 1.071420900942447, 0.31961548463691297], [0.42991890047181, 0.986022459996411, 0.385686314419905, -0.03089324610167131, -0.03133246033041878, -1.1879641651116246, 0.1633821052274989, -0.12728710430878343, -0.5534542778554582, -1.0013844299461985, -0.9772701668934343, -1.581240652781196], [0.5834257894316703, -0.4080964070808399, -1.0474564286794792, 1.5284110777350228, -0.6053215683980604, -0.6632516159812566, 2.334350954756958, 1.2278010306358575, -1.3438408693261021, 0.6062113952223094, -0.1750820409081598, -0.6496780551169477], [-0.08117185347658668, -0.44109787240613424, 0.7424153464716037, -1.7531531846200268, -0.3710496801510838, 0.0659285230464295, 0.22343229063480355, 0.9465422560990054, 2.215881439069174, -0.964358869415874, 0.2557107173355123, -1.289115583601586], [0.7844833136793243, -0.7324700324959297, -0.6419353956541866, -0.3862903249153808, -0.3370382430387731, 0.2607844448426594, -0.7608789642737471, 0.3626856764943916, -0.9448728384484634, -0.015476354778627131, -0.4890170112067591, -0.6570447237683915], [0.010548569763460396, -0.6538450774774169, 0.051898441778128905, 0.8181573958957766, -1.4948314319211173, -2.970944696488288, 1.9022211187580347, -1.361535256548223, 0.7383734132561651, 0.7938782492546069, -0.09081512715905168, 0.8582899384911843], [1.6238773328738754, -1.8364761101689997, -0.2398411732758979, -0.6706820768458394, -0.9470723430548512, -0.14807686961891112, -1.6597666721217113, -0.3710463568090128, 0.3167294585525428, -0.6195740157709769, 0.032711370574325896, 0.6197985138837916], [0.4638525381481749, -1.0383938870529554, -0.3632977767268138, -0.8989278120389721, 1.7760359758630655, 1.7368082577599184, -1.015381987122812, -1.3950584348623865, -0.031332770136601504, -1.8434677685764074, 0.0864565919815362, 5.149489857815966e-05], [1.4382722067789029, -0.04295686751426571, -0.4335845532190287, 1.7756085818084273, -0.0037145632596224587, 0.910593432970534, 1.173318695858812, -0.8305743858067839, 1.1822139953671105, -0.6940901696493222, 0.06139936688922458, -0.38793892394028057], [2.6449652862218858, -0.0020484507164043805, -1.5992619961670487, 2.1390977351691416, -1.8175315528838873, -0.706798873555476, -0.05562369274895821, -0.378745174584834, 0.4525320787964695, -1.652882189288569, -0.9468135331701747, 0.5830238135882522], [0.3786123483060025, -1.1414106894676388, -1.9848682718144963, 2.483186358996029, -0.5438329808529972, 0.8625765688979353, -0.025463306322461972, -2.038311960390032, 0.24230379124056506, -0.13242920406571526, 0.28285013168853557, 1.7204314562199228], [1.3256606846929708, 0.13424354973180352, -1.2575590763524287, 0.08399432868052531, -0.36214258332286076, 0.8103586019401129, 0.003996645505870219, 0.4603728949136048, -1.723973103876391, -2.145720864804217, -0.6206648824023411, -0.2683585267192441], [-0.9894488023866311, -0.09913623260176137, 0.5974281865366959, 0.46555152387237553, -0.2898704040119977, 1.096548451967629, -0.665074312339416, -0.19334072018307671, 0.416013790306127, 0.04940401952856933, -2.2023480248164855, 1.9065871068014246], [1.0387985483718962, -1.0566905187555349, -0.7110360957315377, -1.1430074644207981, 1.9824923708323636, -0.3077363302705776, 0.9104533958672405, -1.204718383019695, -0.06577834469758127, -0.5652282738744127, -0.7042150490555744, -1.4919885787083071], [-1.5433320864291378, -0.6033439441506276, -1.264681141680593, 0.2993940111105706, -0.2705752649707321, 0.7890869657698522, -1.3679659731390736, 1.1244677996157872, -1.2610757616416908, -0.9221825895917724, 1.4207628187294317, -0.5822837129899421], [-1.3103210616266618, 0.35411385910789556, 0.08432956168088596, -1.0431234770360804, 0.07855805005253645, -0.688572422745356, -0.6903495777120733, -1.2935884333884498, 0.8092078107196079, -0.6112365680486613, 0.6796036239779918, -0.2730468807326697], [2.394533058550156, 1.2097469907750809, -0.9231872144242218, -0.8742116634482096, -0.2047913638011077, 1.5293148520119069, 1.0121138838677746, -1.546722391381983, -0.44264259665224387, -0.5030154428974709, -0.5866736198160395, -0.14132823964981767], [-0.1811037763183633, 0.40602042536943816, -0.3569443580050401, 1.2770129240904238, -2.325922439090554, -1.414811230629549, -0.42582604339234, 0.9887889873532161, -1.51852743676619, -1.2240806263488488, -0.6331353025363564, -0.6889572250389242], [0.5137274138977536, 0.1521272119260181, 2.8193222610641766, -1.174183149366107, -0.1966729849691784, 2.2978661233109, -0.17338585851269323, -0.06164954311063153, 0.32032663749806006, 0.06626890415641565, -1.7005933385706629, -0.12098000153611153], [1.0502190992435756, -1.6764602273150673, -1.1128109872482697, 1.2230542751468867, 1.1826834098033852, -1.1720696108519326, -0.17974819243367948, -0.39664896504909214, -0.5073317246982149, 0.6080623233719541, -0.9373578583635298, -0.6260373405272044], [1.139838967513082, 2.07513762767031, 0.09304403367306883, -0.7435486195018808, 1.027989493919027, 0.670470765290404, 0.4123731744290462, 1.2764187962166271, -0.007223711032330491, 0.39036527625236184, 0.3584297256168548, -0.6331078601920199], [-0.060097716724150346, -0.7808630594936352, 0.9551620788724339, 0.4265842831733718, -1.452794839716794, -2.345585965294978, -0.8142244796654134, 0.20664609831218173, -0.3702883633402738, 0.3210124546635543, -0.9374372662398959, -0.105013581304597], [-0.1560720969419361, -0.9146749081717248, 1.1926812411775574, -0.35704325496012884, -0.23924033761121247, -0.43265953156178366, -0.39362377177605945, -1.6861090662611136, 0.5658728766484096, -0.14758053423903433, -0.3706002341196869, -1.0565143549193816], [0.8489642819877224, -1.0658350478431515, -0.8557719327997827, -0.8540544078450186, -0.028619644255140058, -0.6955344142550693, -0.3557211691344821, 0.3908710164263616, 0.14627717100869983, 0.59517278205793, -0.19617823565816184, -0.3513293603369566], [-0.13540609234333964, 0.8742214778151914, 0.7699812714245459, 1.7456627567210312, 0.5325823127367056, -0.31343091839841297, 0.6028168591337087, 0.3257891641652161, -1.387570692878429, 0.3635585250855624, 0.35440184657487106, 0.1688058535101904], [-2.10620398680612, 0.41858691766180756, 0.44015645755013094, -1.3529698352118307, -0.29399100685281937, 0.428712191245099, -0.5855158216181648, -0.9238256777993354, 0.7688122345310703, 0.19074864851340878, -1.2472778738811656, -1.3084242762795688], [1.2903935343667585, 0.14142910035788833, -0.27992358744527074, 0.44013678476867174, -0.20336968982457457, 0.6324724166716015, 0.2288135134010671, 0.44012306541065577, 0.5363641327716814, 0.5917551126566191, 2.5610184087294203, -0.004607010616291369], [-1.7941203492970235, -1.0686815041601292, 2.1697743148912423, 0.24643176750145784, 0.28610342128428473, -0.296690699716629, 0.7533652807994132, -1.5466389941591097, -0.23565854366818798, 0.964772611744033, 0.8897290042165974, 1.7212394380135592], [0.40626791034453485, 0.8559666824800841, 0.4220990265652096, 1.050121285481674, 0.7246288952787485, -0.18650498852934475, -0.03925604344140912, -1.182785858920962, -1.0397758239636725, -0.9003410284491722, -0.33139165817253524, -2.817435057959116], [0.20277095329080025, -0.5266284117854856, 0.2927551116412217, 1.0870820643547023, -0.08758616449944148, -1.7546543214128132, 0.7521559065974347, -1.3604967289504002, 0.10414748619736498, -0.7208588433142332, 0.46430118726982467, 0.029459868504819384], [1.8204879620284085, -0.7422258196156936, -0.1296068028752516, -0.7904729213109738, -0.45677619097559224, 1.9930555196587179, 1.767997639176375, -0.5334482624187723, -0.13247445388019682, -0.4489496364421636, 1.2443699569940323, -0.8752450553583866], [-0.35471679156116837, -0.4745247123694255, 0.024950516569238645, -1.0092624686874012, -1.3745909250854293, 1.5128028960033943, -1.6896946422265813, 0.15080010860934778, 0.6252176919887326, 0.15077882612717505, 0.26097517738142545, 0.41794087568678184], [-0.2974351455368069, -0.17253140344555493, 1.143782939281967, 0.8858020933847883, -0.20012338230398471, -1.3960844161642358, 0.8794928787682355, 1.5240406806521778, -0.8583417374968775, 0.1351716614705667, 0.19976387552352098, 0.684675919317639], [-0.5642382473553029, -1.0818834996275044, -0.6304689271361991, -0.4942404885494048, -0.0801792002390527, 1.5438939260267373, 0.07780860503201348, -0.548935906926342, 0.12386620968500935, 1.3708050508510077, 1.4674390565780282, -1.9667765308460239], [0.609375039841397, 0.49494586083321723, -1.6276987992404615, -0.12920431556718212, 1.0586769245117496, 0.7654386485891228, -0.474067205042844, -0.09320794765589233, -0.1353017653971333, 0.35493325369200907, 2.154154436004368, -1.327650508289617], [-0.17048527424180118, 0.3511713404972326, -1.0464281912019004, 1.4993960530761938, 0.1052630357121317, -0.029913872870358474, -0.46388192778126586, -1.4662339679491647, -1.3598325111020744, -1.3836275455342812, 0.2557702047214929, 0.1109277823707204], [-0.9475742120010219, -0.3403695258468959, -0.8433305480422612, -0.22249075083970515, -0.6063993137025216, 0.9741255065455816, -0.8052504140478579, -0.607109115954255, 0.23128178053730952, -0.577943663738456, -0.4891259850798491, -1.1600024379051752], [0.6006718220797209, -0.034721742865389794, -0.4278207674811213, 0.38124334579051294, -0.5650464653726772, 1.264458498930935, -0.8135950876611252, -2.1295180445495157, -0.04131815925677008, -1.4009587462917268, -0.8477071508119358, -0.7987876449509241], [-0.1416939135977431, 0.7981435525668458, 0.0975292055684631, 0.7423412164545442, -0.020956420728211765, 0.2270469443047927, -1.0586746020839037, 0.7582677995746924, 0.553005090495027, 0.10990862400292792, -1.4607151435747807, -0.22523240588840152], [0.4171557167759345, -0.8490701344742659, -0.5511188358855281, -0.7813954741576852, 0.3288120574260597, 0.5412766829268193, -0.7770843828148877, -0.5658941561593728, -0.13886370715543297, -0.20361943620057735, 0.757306181602041, -0.12075756597153536], [1.384095714861208, 0.051526980775262105, 0.5281792138605756, -0.3518534423396814, 0.016548063424932775, -0.04404365420192254, 2.7118787830652606, -0.28449283773215356, -1.1477563864942983, 0.6851830411742279, -1.0089112098436488, -2.103204188926419], [0.42179953308361967, 0.6356330250035852, 1.4855794697004123, 0.3392418008689999, -1.809602108149793, -0.548992551467194, -0.4984134406861113, 0.6831688224530849, 0.06734236091411246, -1.6079553860078228, -1.3781876475305013, 1.9380468945477574], [-0.18959429990389076, -0.6901175723213868, 0.27381224584597885, -0.37722472277913033, -0.04825793656597174, 1.1571107619653298, 0.819149210464528, 0.13023298241512804, 0.6493006132689103, 0.8373160726622824, 1.4703832144360016, 1.5285644031256191], [0.9535316372698999, -0.8087965395046353, -0.2554520300011291, 1.3713863026526183, 1.044987582056175, -2.0166583050224767, -0.09022261295986465, -0.2755143836667514, 0.4633341874255261, 0.30142074716348033, 1.1330599074278342, 1.3451322142791005], [-1.5287783316285244, 0.9528517022283461, -2.291402139401875, 1.0482538396771675, 1.5318600428151798, -0.06338359515046037, 1.02437955261771, -0.5227341981752925, -0.6154575684645434, 1.0420970196593164, 0.7444085832918022, -1.4032653308320313], [1.2386637124807582, 0.559608873307118, -0.6712741313965747, -1.8663305807392463, -0.6379031801960157, -0.39179620476376725, -0.4433197230014412, 1.2247107600644482, 1.104234381175151, 0.41157237180090595, -1.7336967083095967, -0.16677458396895764], [-0.8294045461996262, -1.8334887035655205, 0.7158999091177782, 1.1084252032834274, 0.7251173125448046, -0.1384173598329282, 1.8728215826982384, -1.7039986117569668, -0.21212357518804947, -0.7525650710667869, -1.8972237801472545, 0.7449056566205458], [-0.16581989710453116, 2.291235841295434, -0.31574024872175216, 0.580864382635509, -0.7502588775773161, -0.11535749638246932, 0.358999194553075, -2.8640778596529333, 0.8422528571292703, -0.8618687598310494, -0.3410430400060013, 0.950759730510918], [-0.5556108514381771, 2.6435310130409406, 1.4177790986473136, -0.04543501193379784, 1.2487585734452702, 0.9726746414790499, -2.2652035359606417, -0.1398682453201822, 0.963559931409941, -1.888353847033473, 0.2862818395831269, -0.20321058351982615], [-0.2679183877250624, 0.668020232374007, 1.6005062369661796, -1.1728710531358078, 1.6432405927639506, 1.1384705274327205, 0.3534239025181615, -0.39298381874886584, 1.1736205127170898, -1.2011825308072894, 0.7983518128260177, 0.07760431320058248], [0.25551903911264945, 0.7790117626038114, -0.7982127063874419, 0.8999264801259441, -1.7495926591344755, -0.6719192351339422, -1.4752662508014078, -0.3223842345375842, 0.8983469051835028, -0.33499630243755796, -0.5176586963363169, 1.364534690249603], [-0.06544597335429443, -1.002733165037812, -2.7123753929015955, -1.0807467489690346, 0.7033157714045748, 0.11319258993203037, -2.0204109995636883, 0.010218489934126319, 0.39295492724342446, -2.240308593270091, -0.15192027852485618, -0.2173983499415256], [-0.3158775990646171, -0.5970923288998553, -0.19765712666971455, -0.7854558911034903, -2.2891850720358184, 1.053728982815774, 2.261027068792109, 1.1063464012216884, 1.909095640222762, -0.04503298489662621, -0.9600300360016011, -0.6682218074328641], [0.17793655369668407, 0.6985570877605106, -0.06735313364194692, -0.601425751993164, 0.8793540519329044, 0.5639248822117694, 0.9001930029920984, -0.2816263712078574, 1.5859400795113408, -0.8003864545529815, 0.38502861581209874, 0.2950630045960389], [-0.2562237575963975, 1.0188652910165739, 0.9466796183525342, 2.0836958202290323, 0.705601269303227, -0.6589653533494126, -0.39043618243283335, 0.5861604815164707, -0.09156054722254275, 1.5388312658067462, -0.18975094650496235, -0.4101541560989944], [0.795891377995123, -2.656218415664327, -1.2532804537947042, 1.202297614265911, 0.4300215744205284, 1.3295203056356186, -1.5762541329424105, -1.4488711731811306, -0.5154095858506134, 0.36585249903830797, -0.0382768341617601, -0.15964926404407787], [0.4855558683531868, -0.24346286068307238, 1.44405590456453, 1.1287619991849034, 0.31038869548625986, -0.8802451112194893, 0.808961876765691, -0.831499523771131, -1.095667300509333, 0.49801956790115076, 0.5858602296338906, 0.2844549977139753], [-0.12896737564599856, -0.3022746759266639, 1.0490996698295625, -0.14066643111544894, -0.39414233556401124, -0.5292648780557547, 0.3596585378044245, -0.3568608678947615, -0.4551002040092758, -0.23863949412916766, -0.29762061194284134, 1.4834908579358088], [-1.7969969022862757, 0.014139601708319566, 0.029224453119396473, 0.18750312245055303, -0.2720215953258675, 1.0527224868390206, -0.4084381669854767, -1.2141029020711174, -1.6128659189633803, -0.048398520749600764, 0.627943276410182, -1.0159482973740723], [-0.5576665034972483, 0.8442185460212113, 0.529008881866461, 0.31845645320849697, 2.6914911445353384, -1.2993608736450923, -1.345383043719008, -1.537433873045726, -1.3185632490308579, 0.21856316862286226, 0.3333333854296227, 0.6431798546512975], [-0.42195639387360206, 1.5577477852512829, -0.35063878019921646, 0.7453498451213685, -0.3310026989895848, 0.27329654058955277, 1.9266286722031958, 0.06922921410748376, -0.10255647471600575, -2.6618401434886723, -0.4965240096011763, -0.2908238667645177], [-1.295489830698646, 0.616716691509472, 0.4318133419771046, 0.01658893975479992, -0.15662957956803136, 0.6692957672083075, -0.2834723420408318, -1.0465276808852613, -0.6364284537305714, -1.1228941109988715, 1.3977505532862171, -0.013248711794242564], [-1.2727501855263221, 0.5425667100144784, 0.46786593778518215, 0.057625331490546806, 1.086151007292523, -0.6401934413473644, 1.2986488519156825, -0.09948552307492149, -0.3951660078762371, 0.270730906317927, -1.4965567938807314, -0.037451827885974044], [-0.7561821863862742, 1.4522404522283416, -1.2825804632170545, 0.025000878690543165, -0.45726293511223687, -0.683754957561986, 0.14518787479904083, -0.3117873927557418, 0.1548388481484663, 0.3031600724786768, -0.45796538625958716, 1.8474218426404605], [0.08510326876934284, 0.7558883204266704, 0.9654837518263183, -0.13603789935136928, -0.5788736326803544, 0.4989937709575274, 0.50325553983206, -0.5479429325827317, -0.28103228237772365, -0.8118822720383478, 0.8304271298074648, 0.7741171651181645], [0.9892111147242967, 1.2351873090489076, 2.974717436005034, 2.089132323196626, -1.216790215761647, 1.5557762805814468, 1.30619145457104, 0.22274233229925514, -1.650075348575634, 0.9884482604517567, -0.5037144810150516, -0.25751571418870295], [0.35197184153812294, -0.21951852585543755, -0.3463891853631612, 1.5971072748261037, -0.30466803243889434, 0.39233228064588355, -0.2690130631424081, 1.2478906113286852, 0.5136966323872861, 0.3551061530902561, 1.20913448812746, 0.2155588157843726], [-0.4766640153201887, 0.4637105432482911, 2.003018871507778, 0.7306455620605585, 0.6703550233910919, 2.059549491713266, -0.1131946424647018, 1.0179632895253106, -2.286505806291911, 0.18540643487702202, -0.8419808461459619, 1.4315297136010918], [0.7058040330298935, 0.07831562179123625, 0.851657908700495, -0.08728633934172086, 1.0399233176702263, 1.0732980802179641, -0.49504947187341347, -0.7203724336748745, -1.3389920970381979, 1.501503759040333, 0.15839719218865925, -0.757505877514549], [-0.3535075027442643, -0.2936864034220216, -1.1838167721016757, -0.7321827203384672, -0.5181700369686196, 0.6469393893328509, -1.3000253821967755, -0.3884596231262868, 0.3528715164286682, 0.5375802806695256, -0.733360848484569, -1.2584934381419999], [1.062803958603328, -0.09892316231175267, -0.7638812406260734, 0.3474045786618132, 1.3512263452418463, -1.095327553814619, -0.2939572740335019, 0.6663293341279014, 0.0891027438243581, 1.8953024422663665, 0.3338513124257567, -0.31921310750774823], [-1.94008900328269, 1.8636729131944025, -1.8580237343037593, 0.7535196267480938, -0.909664844588024, -1.8270927870612879, -0.2215486008418484, -0.0031802688763571656, -0.3317151403490427, 1.4826592005537436, -1.1437495085765572, -1.19083144632349], [-0.11269187281916965, -1.229709437566338, 1.1807024849298198, 0.28985966335659147, 0.4241512186721306, 1.441866330483682, 0.4633630784275847, -0.7086984858203735, -1.5608460730097489, -0.8954158008107036, 0.697872453427426, 0.5899469261505514], [0.7310471663841437, 1.6338446065875771, -1.8721654612585676, -0.6859507253279596, -0.20963448396231327, -0.4109374240601921, 0.7132434363471036, -1.9457214545333414, 0.7988239864169623, 0.7768754943436741, 0.5876421739320397, -0.6225638728564075], [-2.178648808745837, 0.3967226331572366, 1.6944425759535873, 0.533837706555483, -0.2868988334899462, -0.7841624255030228, -0.9209316816414344, 0.3284337956496852, -0.08206287329227675, 0.5576831188847128, 1.269295043923099, -0.8457644082796574], [1.2787805757546413, 0.2678732100544729, -1.5283512635628842, 0.36573528789255316, 0.6834000427062107, -1.0850120704165946, -0.02111146972792229, 0.9583417334107388, -2.5301751661490064, 0.8801712639527628, -0.8484175876662453, -0.7310075187087028], [-0.014294585573724521, 0.4937316358506277, 1.7842721690529812, -0.1182109924961404, 0.5159582288293264, 0.8137188034992476, -0.6317850165076029, 1.1519076920277938, -0.6621208756632864, -0.9480390903465755, 1.3466487981735678, 0.8700135245433521], [-1.7860054585371121, -0.6023429511944665, 1.1424221688230587, 0.6065217725712615, -0.9710990024756034, 0.2587081728700161, 0.14715923741013637, 0.25019245095679377, -0.6530441339181853, -0.9874279491563258, 1.0626773104986595, -1.7087437710644877], [0.6208881449332238, 0.8481130489463888, 1.3764778007478105, -0.3259570437107722, -1.25001729093959, 0.4330751017726432, -0.24713687657523567, -0.5505067068240054, 1.0319511912144923, 0.5506372482826336, 3.3251084512912765, -1.2861148597577003], [0.03001975503654089, 1.8381267367332528, 0.5532220539885693, 0.6831976485375587, 0.18211967297048673, -1.2975135928716806, -0.1716859877912475, 1.1539990981778239, -1.2503569167273008, -0.8316603198085486, -0.8747377703886313, -0.33644490450359876], [-0.6839026219706276, -0.978793933215699, 0.31062825060153004, -1.3105760602379672, -0.03884203765680749, 2.474374230826122, 0.3904832421113162, -0.07181786614992157, -1.0164738463833882, -1.960002234692968, 1.133022837843533, 0.5662069264081513], [0.189765767794697, -0.8408668495581471, -0.6978671044736845, 1.6117381818263834, 1.6866133203208542, -1.2418912661786343, -0.06328579641255311, 1.5103765314110984, -0.045215550253868884, -1.0882572231452865, -1.1132839192978028, 0.8210538822821752], [-0.010560740109954702, -1.1131854238955683, 0.9006674215645383, -0.12630391516991163, 0.5213032367645498, -0.4123791096676837, -2.240929052240202, 1.400415968805243, 0.6009253702260992, 1.2714211587630806, 1.5587589625743266, 0.36074576421491444], [1.4752673513323322, -1.047488369819174, 1.9904405045535394, -0.036806999738974874, 0.4577303832450385, -1.3067196712627842, 0.19108453967877356, 0.036114391795985044, 0.11689283378792864, -0.8171095735650857, 0.7425277897367318, -0.7006998382401659], [0.5385927026008454, 1.1727285620356651, 0.42602701077366373, 1.0175261070161024, 0.03697905777842333, -1.7909573104298322, -0.5566693687744134, 1.8296089393593855, -0.2190496671131261, 0.25641928324063684, 0.3921357944687836, -0.4558707017361828], [1.0691841297798117, 1.8227900771225833, -0.07006435229533803, -0.5466265447784714, -0.03546677303853184, -1.5294528264146652, -0.1951381591320539, -1.0473566746059777, -0.14904017541113412, 0.3409601400173415, 0.3228482472891491, 0.16533916882717634], [-0.3543885543297725, -0.19797964084473593, -0.37059386251523263, -0.050989835413515476, 0.9464485541151261, 0.4432167801204374, 0.023448567717086966, -1.24408523990152, 0.8467152974226392, 0.55137238965689, -0.29874420376062605, -0.03781193294631762], [-0.4091638544185585, 1.347644280717843, 0.9379760850161106, -1.4743434410318716, 0.9795827369082838, 0.39364414208690895, -1.5996742893241565, -1.9833468315533829, -1.6839721136215346, 1.6050501322681934, -0.7353511718264689, -0.07446932001375135], [-0.25000930232409024, 0.9042160927743524, 0.7933936644662045, -0.7985706040164656, 0.7926899485058209, 0.9089822636019297, -1.1963618491900012, 0.1969449384348748, 2.19294683329709, -0.166425311108399, -1.7047069415353406, -1.3955779315507175], [-1.0080616220416385, 0.7856085911427749, 1.3996928506905646, -0.13162920186867672, -0.13810076149650968, 0.02203816578891594, 1.9612933379804176, -0.9979157212760295, 0.5233524001399223, -0.6993058346243389, -1.065172322767294, 0.033288914470595586], [0.5806211043860178, 0.7144740308194999, -0.9031538826580835, -0.42008823728941974, -1.08465590362241, -1.5278958815097452, -1.5291740458152272, -0.870592672813059, -0.30606505234368464, 0.5172456463147858, 0.6898792988843925, -1.1935494110367841], [1.2593904323594696, 2.202294567755119, -0.05542733518045043, 0.8315795939837453, -0.03121343035852472, 0.9214730188020989, -1.4840415606677502, -1.5038168995512988, 1.078478752379376, -0.10928822834327659, 0.9200050733834271, -0.9490256562630149], [1.0624207958748122, -0.41109219323881796, -0.4349844839356128, -0.997128116451203, 1.1481120039113109, -1.4838192439408624, 1.2186359965864053, -0.7166988364184762, -0.7122585510355449, -0.3642917126548677, 1.06008692874553, 1.3795897362145926], [0.3823996913425528, 0.7417472412451961, -0.8444836957251628, -0.010505528763578372, 1.2612311012447348, 0.1650240484131167, -0.639956920651703, 0.23562385549789552, -0.6538862682645902, 1.7979654188740044, -0.24289081859697212, -0.04338155904743328], [0.39806201410933895, -0.6538692697351028, -0.5409758743409198, -1.4442253680585235, 1.012386875122609, 1.8442199809353248, 2.3011134369477846, 2.152271035111839, 0.6683686185482287, -0.18831053849566667, -0.9625082439783025, -1.4081534547169015], [-0.11740414699966997, 0.60302930204844, -0.7984809726837538, -2.883349689267351, 0.49577123981951265, 0.6379197106328043, -0.028131848525263084, 0.42438189793106695, -0.8496075268975881, -0.43411478926911645, -0.8312349647630044, 0.39967468176009646], [2.204792627668454, 1.438931665926667, 0.17661497475888835, -2.7196603842140443, -1.673565116993088, 0.8384410503480678, -0.3301597842314306, -0.9433314716924791, 0.046841716236655395, -0.22436945606385936, 0.5089501707390386, -0.1428306428707918], [-0.1643037898637371, -0.6212126739549164, 1.827452414534294, 2.3345588087622295, -1.3461307628300112, 1.200057488897443, 0.2746786198698012, 1.0985942695119715, 0.1771835989798393, -0.46943713314976543, -1.3970161802996144, 1.7301509805834763], [0.4722260324410379, 0.20791571933037165, -0.200947107060273, -1.6606581709358226, 1.179554989065269, 0.7436130330998528, -0.768464791135442, 0.1996892554372393, -0.3084517085545138, -1.648109904422458, -0.6229341570446754, 0.9083369086266516], [2.488658162054416, -1.212449046296387, 0.29662460836647037, 0.38861245718342574, 2.196656733932363, 0.9677864658426577, -1.309611851592908, -1.7507579381538503, 0.8002665133014232, 0.05108967886042485, 1.347748866209181, -0.011008589942898302], [0.3407875602408173, 2.0015096873078093, -1.7481115744270237, -0.09438049015358041, -0.22432708776512747, 1.306876635072011, 0.9261149450126693, 1.2071300197359427, 0.9129320902561049, 0.38682616101590406, -1.2007743327286327, -0.06474507487288722], [1.3372648565060674, 0.12920519250388834, 0.8721525531069697, -0.29415512767174545, 1.382408813907849, 0.798930194575994, 1.0222236714300974, 0.19940366323814346, 0.8892571550465274, -0.7204580956079855, -0.797256572530864, 1.0779417831259563], [-0.7185585859279854, 0.8107741350385546, -1.450052022169096, 1.5429420703449528, 1.617711285275197, -0.822515209160997, 0.5575812418163834, -2.028045027108164, 0.4528151856825903, -0.05132964626873509, 1.7271527765423382, 0.8316389149754724], [0.7963830935218323, 0.6706024678937778, 0.3977437712736406, -0.05618706183587133, 1.923792824957379, -1.9294254597840297, -1.051981435020049, -1.0243334984202728, -0.1440813870210645, -0.35503922445278996, -0.013032348828465459, 1.3342923367113129], [-1.5511457531435153, 1.0812997752120954, 0.5928551093325283, 2.2198303803140402, -0.36735113570259487, 0.10145390626539653, 1.2159922204527842, 0.42751830519064865, 1.0135752505146707, 0.6362635793454607, -0.20881424005215304, 0.024261837317031555], [-0.7623287610150407, 0.8310244604802435, -0.8101397868340838, 0.4421950120453734, 0.0046180056029890065, -0.8030928533363528, -1.86131411353651, -0.7042280840203986, 0.2265813695666172, -0.7684871734766427, -1.4666028444217802, -0.3000760615417019], [-0.3215087126332586, 1.0145576300127634, -0.2745546252362384, 0.5990253423157138, 0.053471331849694666, 0.49360315011155426, -0.04947062308476991, 0.38229733040348296, 0.7795766440314814, 0.5778442647017359, -1.9117140779652326, -0.8649874174530372], [-1.5537597472050988, -0.12035789436399337, 0.38934974655333093, -0.7195333008603167, -1.4519738949818768, -0.6499531107560179, -1.196475975122923, -1.3413144113170978, -0.7733387328640149, 0.7284055291187058, 0.3708191410792209, 0.2737908620278692], [1.4289739108266433, 1.6477308801999053, -0.1459257246419499, -0.6220506857427007, -0.7642781229561713, 0.6515654853439792, 0.6366734962946039, -1.5415382719428623, -0.31284028310821216, -0.8771652368637357, 0.9669568066596952, -0.9856324474528405], [-0.4342785442259163, -0.9675717728368896, -0.6199585029628802, 0.3198160015455086, 0.4970599754296555, 0.26477961340365275, -0.8607972724357894, 0.8339689867794468, 0.3166588300056938, -0.597618595466913, 0.039913670628899126, -0.839256872159479], [-2.3889395872343577, -1.042153976346743, -2.2493503556781347, -0.03613727157840667, 0.33765711718042957, -0.555350572823691, 0.7862224710599309, -0.32534959054180135, -0.7722256671061937, 0.14712246117958655, -0.00422175998552751, -0.9656832252838701], [0.48542580582572253, 1.6106764495754085, 0.2914605178244232, 0.15055744903185175, 0.5897065434042501, 0.5606386982636483, 0.6718571289243089, 0.36410772739021935, 1.9302782272491097, 1.827269235499469, 0.37227212432651635, -0.2430077484398947], [0.9993574006838967, -0.04365827318575775, 0.7345499563096602, -0.44295819588272894, -1.7183705115578274, -0.30080893926560015, 1.855715077731294, 0.9166951173958, -0.020202780613698023, 0.03800691072040365, -0.25798074400639576, -0.06659444141479381], [1.3603059591392026, 1.797386816354428, 0.5515436790617524, -0.7348653347749537, 0.8716459956605025, 1.113540632103964, 2.016236967826596, 0.047753669780187656, 0.1994851260057303, 0.4547948648788483, -0.5294314773631873, -1.8447415860338805], [-1.5536143483799747, 1.2373046607943219, 0.19552984438286156, 0.8056639107438823, -1.4920146459136057, -0.17645165428919682, -0.2602134773004601, -0.3445793949422478, 1.289497403192871, 0.607295212182243, -1.3091797248888617, -0.17707797529119634], [0.34343009386827655, 0.12599051299393613, -1.2024464155657608, 0.18461566982858452, 0.8821476097816436, -0.6132216497563339, 1.0773653576787745, -2.2376962371654727, 0.6057346959450001, -1.1558120745203515, -0.1835731425017708, -0.01374872602674146], [0.20310564460154168, 0.47926375274908495, -0.10566852180541017, 0.5034663624040978, -0.38201571678361634, 2.2441115329328865, -0.38718068836545894, -0.9339821105775419, 1.0238139548708243, 0.8794082675567473, -0.41655066365694754, 1.2646713620918038], [-0.443427944458792, -1.7292236379588892, 1.1892941577308416, 0.820905688620136, -0.03403329284704702, -0.22497796815203835, -0.9908449528858053, 1.140893721665121, -0.7639590497268253, 1.0016370073608714, 0.8043255364583173, 2.2618436609937076], [-0.2516029754851532, -0.30745398423991477, -1.2469197839046524, -1.0623302346825896, 1.957188867453696, 0.7121122074476848, -0.7736909552683973, 1.460549601002131, 0.06264986403035505, -1.937438508920533, -0.631414971592673, -1.0713528283628286], [-0.07420593102315734, -0.25936573617521136, -0.6977148029760216, 0.12758387052230394, -0.815428374073205, -1.3954215417968647, -1.4317222999511934, -0.2893003749832515, 1.0872334906090506, -0.6451903594613536, -0.4434146081641811, 0.4338851638927629], [1.230905962499352, -0.40486387560947945, 1.1510663996144002, 1.332954609776585, 2.29887016203768, -1.2169999456915428, -0.003686768284445303, 0.33327583810675054, 0.18835690358676427, 1.0881926308667522, 0.7589782467493082, 0.7432592615286638], [-0.7177773107775515, -1.5290731478480513, 0.09136006118751841, -1.818413974865695, -0.4156424323792519, 0.8793984207251567, -1.055858320627308, 0.06464604654384014, -0.32796070381776693, -0.5842298471284937, -0.319038364644762, -1.0086072264705797], [0.030518113478270024, -0.777891707769433, 0.14218749494952596, -0.006944986883063396, 0.40778688288989795, -0.1032207549863335, 0.031026761093597012, -0.6271075188920903, -0.4213736282528866, -0.8642670971681486, -1.0832659256282746, 1.0498497458584317], [0.6401894796956208, -0.4289872950684204, -0.9937643540563738, -0.43847836085748604, -0.04332787010251041, 0.508503004378539, 0.8300837487882693, -1.3148869061615964, -1.0421875743205047, -2.622195508682387, -2.658802103113721, 0.7319420570803582], [-0.8323206608807628, 1.6519309272655924, -0.2243670310954625, -1.1486658658820914, 2.2426830533829256, -1.3473914127064373, 0.4730050411783899, -1.2472349466461512, 0.22084190983257865, 0.7139386884915846, 0.9972888502611464, -1.237954013799858], [-1.8126386353991923, 0.24701141358103582, 0.42601976965356103, 1.5345321416039068, 0.41303551898364566, -0.24733360277855582, 1.9062047787421805, -0.11391213722152092, -1.110467943407923, 0.14720823877679196, -0.9729274584502711, -0.3104646331974295], [-1.7385888768560323, 1.3129905452426471, -0.03279493668172343, 0.7745927933852338, -0.2497704860312682, 0.28969820323005163, -0.29172163152965974, 0.14215960870750688, -1.5840536805044774, -1.7279597103457893, -2.0432523127834914, -0.6794890839890789], [-0.533252939858, -0.8921753621044551, -0.2996089893513776, -0.7262670966064861, -0.2667093644950635, 0.03299444149866929, 0.8533114722948153, -0.12743369509573554, -0.4467587098553216, 0.27863366850042587, 0.3742440074202715, -0.8047672947597805], [0.17977336139443958, 0.12237318976382522, -0.962519821363355, -1.1540409621125227, 0.8193501312185748, -0.06389219666488768, -0.7334804056834379, -0.7227148966596544, -0.10125659201665006, 0.3174448773196064, 0.416761178342231, -1.5119554004400801], [0.12389484881194006, -1.02159468430676, 2.6256434175955348, 0.5866719796471361, 1.202023738131943, 0.20132038643534936, -0.6628223482727191, -0.42799022131081443, 0.37386743311325077, 0.14538612058337155, 0.8408772001824306, 0.2618594357268677], [-1.2073214476753609, -1.5340670858395495, 0.7628427312961794, -0.1474335468329955, -0.34930961622155565, 0.4219129789115312, -2.0563331770404414, 0.9603563760104726, 1.1773894254187074, 1.2925326045919727, 1.3512346721787891, -1.584445882124726], [0.5095226551342515, 0.7013068816397935, 0.796641725000207, 0.7603522579403607, 0.027757057495206648, -0.1160635542734164, 1.0345682208886262, 0.007387761526721239, 0.7344948976186723, -1.23188431140223, 0.5852318557425188, -0.1431318878825936], [0.7912026652113707, -0.2934855668033261, -1.75282946612053, -1.3768053718283693, -0.03433319847268095, -0.5923476980431125, 0.8270395868844419, -0.5158096021828685, -0.35680614221121837, 2.1126365307110544, 1.2035614921458995, -0.023529875923201958], [-1.0942535927831856, 0.4758187507704239, -0.8727457463188053, -0.26459544960738746, -0.0062110164338439215, 0.7286602967124054, 0.05552428200431363, -0.4804046150467947, -2.351047461344776, -1.246403151681944, -0.6265744055871252, -3.0207812812798713], [0.7946722937945249, -0.05950620174256851, 2.1622227625362727, -1.0700152485881806, -0.3568415762062006, -1.4427118382271509, -2.0505193114981646, -0.017763032480019744, -0.06406860179914758, -0.7409417879113498, 0.3968564384629838, 0.7852308897653237], [0.3870159163076881, 1.0958139054205427, 1.1618235632907967, 0.668449935832925, 0.684999507350958, -0.9438749893073733, 0.18378512029867186, -1.7156561186988888, -2.2097387117064082, 0.6556466774524915, 0.4934430260524547, 1.217330026092289], [-0.9376624768019164, 0.8534649516007549, 0.17566029392691146, 1.2180135170169029, 0.035961151106826815, -0.5449169117982345, 2.5245445243274336, 1.9509291471999837, -0.5964050009749308, 3.0833241483994467, -0.7491693640144322, -0.7575709997375983], [-1.345834557553974, -1.6290884974668023, 1.1666958967138137, -1.7711984898872175, 0.36053825235222164, -1.6132113938223989, 0.6344696092191472, 0.994775397879061, -0.34510727110577794, 0.061911328510510094, 2.1130434131765448, 0.3756293478190834], [-1.158498994163417, -0.19299709046901709, -0.19737433697801637, 0.024064637400408557, -1.011258986968432, 0.2793878206711095, 0.2943195277345559, -0.7799611662287712, 0.623758351255027, -0.22091509434331547, 1.3245676285630708, 0.3700674112926229], [0.9233333647755076, -0.8851647135882457, 0.06353121543182588, 0.4739278933933404, -0.825057679055311, -0.20683857767016653, 0.5711951097073997, -1.290320091321762, -0.06042291708316055, 1.2686069791150163, 0.2788182757356681, 0.45526217818232007], [0.3403530753148462, 0.943388649394151, 0.32984632691044735, -1.8072394798957596, -0.25300294954200003, 0.37588421361442576, -0.6176224534285695, 0.4174740878234388, 0.4872994728421234, 0.8828755749699551, 1.2976158616689561, -0.16250593605042912], [-1.6199189519857622, 1.7910613609856156, -0.7855708806397609, -0.2619071621969061, 0.6049022899751619, 1.399134037296519, 0.11515892755147253, -0.3265250239872992, 0.37014378532347963, -1.2181475878378518, -0.019248577704614266, -0.9264050880567491], [1.1582992659226143, 0.4841664811129678, -0.45749376328607033, -0.5620249212430121, 0.614685941172247, -0.46594254657594025, -0.04708209568471546, -1.4605450295758882, 0.19833787560536814, -1.0171270688423508, 1.6046659220226065, 1.2445819224561785], [0.4784604707952103, -0.29965636206170493, -0.3106232977430552, -0.8868387354131321, -0.001835370969109435, -0.4059717767712408, 0.8604564792987065, -1.3642677594321364, 0.33487841245420885, 0.7960186880209198, 1.5995445829474693, -0.2380591386892447], [1.1546954709070605, -0.22886112969661038, -0.08909111077587786, -0.21453661928208234, 1.5093835813987546, 1.6515859047835286, 1.2901698029573816, -1.1727375458232279, 0.07551685445878564, 0.5962643898776108, -0.4596402797159734, -0.4647649048613073], [1.1352012428422007, -1.1817857169331198, 2.1489750380685844, 1.7895714937616232, -1.5065840296471678, -0.28762838421395187, 0.29091602591740273, -0.9850971086186066, -1.9060399078116799, 0.38475256165697164, -1.1298717481723282, -0.24182468220688733], [-1.6646491673893957, -1.2408802741372935, -0.06393557224306522, -0.8595022269906547, -0.5424314870213663, -0.5723099637365197, -1.7808790298797292, 0.12681328536170988, 0.7542029312553487, -0.22712111973810714, -1.1426537264638967, 0.7122451181063626], [-0.9487947383681105, -1.0882180276664788, -1.0759137708996551, -0.18188403841849912, 0.5350724791375195, 1.3198418613251914, -0.6898238615812237, -1.078810834537576, -3.4882289432147893, 0.6635414098912084, 2.2598881026466806, -1.0215089566217312], [0.9804701942724122, 0.9528224509823143, 1.4126582060440225, 0.7333850056073371, 0.5488101191216274, 1.0300704691769407, -1.363632435303169, -0.5437726856039773, 2.0707429519145095, -0.05213240875260395, -2.3406872936929686, -0.45014982600190356], [0.6205929877968731, -0.7817646954444972, -0.708088209209811, -0.29964486170970583, 0.577890137034147, -1.502496198884228, -0.563260760766081, -0.9452181758325083, -0.24100322098890306, -2.000882395127964, 0.7977719527167644, -0.6662486908359321], [0.1241128842933345, 1.488566273383303, 1.4769768047621543, 0.01368243138160972, -0.4494091588975103, 0.7149521817508148, 1.1010891894356698, -0.5426663129253996, -0.38070525118785636, 0.5231573011469459, 1.3030147196946609, -0.41799987678201805], [-0.23521513645791045, 0.8105164103969917, -0.8332377695482471, 0.23173292931337908, -0.22540425862357094, -1.3513169891879437, -0.8751278586484681, 1.4428957732448981, 0.10767066757306422, -0.5694789671732631, -0.8124010414676083, 0.6547617620388351], [0.19260478332586006, -2.084704237718184, -1.842188489446008, 0.474788873868133, -2.5929557850995737, -0.3138752073017056, -0.16326812361852572, 0.10859517277583745, -1.2809716058272083, -0.49893013576508677, -1.3286371555505971, 0.14289509760352517], [0.5228443885706635, -1.209161166265435, -0.7767274594152836, -0.22677779491293518, 0.20286907863541695, -0.005895994092365231, -0.09102150754006999, -1.5512706587141514, 0.7336567930125408, -0.07386183147910673, -0.49039985481564385, -1.6204009378353892], [1.592387742439355, 0.05634414859598189, -2.243781137751344, -1.0872450882437936, 0.9629638021191809, -0.18965304551448633, 0.341372431592168, -2.0761670344054304, -0.6147145704407461, -1.3580418572581234, -0.45358062837146007, -0.8310050692552469], [-0.42234285161965424, 0.8302446614080566, 1.7821406711170704, 0.5889956241805708, -0.5485175063374873, 0.6726976946211617, -0.43142752230857545, -1.3669284444064411, -2.651717082774904, 0.028496964076570257, -0.5975327547365233, 1.5596902614660888], [2.186036528723368, 1.5549791390277308, -1.0752280950057733, 0.9320602953819247, -0.21509519521098694, -1.032749628036592, 1.3596083976898765, 0.12083019707332748, -2.062446821444194, -0.09286217027907531, -2.263666159183978, 0.43596807398548837], [0.8956948258724042, 1.4695164576089983, -0.04692260802988029, 0.8833697561913824, 0.8393471441362549, 0.7725596012090543, -0.9437139417368479, -1.0255486551433213, -0.12796111966095522, 0.9751689911518092, 1.202240800480828, -2.3412263531574236], [0.07037291914045282, 1.2434046958028007, -1.731275955832711, -0.7637524000227128, 0.3165952541243974, -0.6829925954917033, 1.619536388242471, -1.2955886511022667, 0.2611672483065503, -0.003907874344487856, -0.027400985317131542, 0.07949427767426384], [1.7185275954382573, -1.014450893461049, 0.22147086434606897, 0.9085488695095638, -0.8934217074628593, -0.5923067281037823, -0.32603579758933793, -2.692095426425319, -1.2962187727015486, 0.9617914898164938, -1.018484751065696, -0.1842984379388083], [0.5704916095898643, 1.4233631740540218, -0.13949089839912185, 1.8007827031869807, 0.5617862424283692, -1.0737007624485877, -0.8386654317401999, 1.6191662277520684, 1.1838996761687928, -0.22715180448394826, -0.8112901345003306, 0.8285002056013876], [-0.291872655942909, 0.17560851966394556, 1.351914797944962, 0.748807642229518, -0.019119047000144482, -0.8611328075478858, 0.3170446076257111, 0.8744178382919995, -0.9134678702285045, -0.34288128074807533, -0.5969093173868233, -1.6155442804647904], [0.24022304063050337, -1.4891915802109057, -0.03590043060768958, 1.721605686799803, 0.9891894719019713, -2.442322241182035, -0.29448605547564766, 0.7689573190484248, -0.9166313463761336, 0.4227779947284601, 1.6337649984201972, 0.08848506904304311], [0.6727574579743937, -1.940020852041527, 1.339056743503573, 0.3581743030393312, 0.7078485857688572, 0.9181782702154587, 1.3810926009618674, 1.4293203516529394, 0.5994360813275457, 0.9005994725720136, -0.005800940801538824, 1.1191973052287518], [-1.092178408555982, 0.40046309536156816, 0.831757109124571, 0.32920290367528443, 0.15634601523542296, -1.3225519840144695, 2.9535065239480613, -0.7726215711120242, -1.3520886525918414, -0.7518618551238422, 0.9014321264199254, -0.4383729795942502], [2.9652636058540023, 1.0097097432352382, -1.0003507308153374, -0.5567028746915439, -0.2872210701674991, -0.13552946335672558, -1.4113384869460677, 1.4092295624533546, 0.2518484845042224, 0.2925906143263997, 0.3183414065404228, 0.6783067609146956], [1.622124502094629, -1.4826452663403973, -0.3219724187913329, -0.250126340550663, -0.6789009021103303, -1.1182163421747666, 1.683286115862297, -0.29421846384360656, 0.08968395850220716, -2.343138471243119, 0.7587170414643597, -0.12760131807609418], [-1.3246442229723856, -0.06176667340280968, 1.1201240435347586, -1.3114783286922014, 0.4711439030476344, -0.8154719059240294, 0.7464993831027412, -1.321632191575198, -0.4229288539232343, 0.8311176034518855, -0.6496014116520766, 0.5460179579519364], [0.09013157270342365, 0.1357770739103688, 0.6760198748459562, 0.2952677315490522, -1.2957263993435393, -0.1127828161459211, -0.43057479547588035, -1.4312300774334734, 0.07294320343383266, -1.0801126681704807, -0.9541970451215418, 0.452144190644594], [-0.406966519953725, -2.222977836364067, 1.1517801678836204, 0.9396969782777006, 0.7533973858571049, -0.6115414993427472, -1.44109450119008, -0.010818149259481687, -0.8064190570806087, 0.9988463206659051, 0.5562775319760552, 1.0926219428810782], [1.3079391424689222, 0.6841492411351707, -2.6833671225960622, -0.33144340005128653, 0.274692327728012, -1.0652497479767602, 1.996765048566486, -0.31025398764071227, -0.24044040508661652, 1.8137973504143903, 1.1844942900229556, -0.7611996189011584], [-0.27538174806032467, 1.5559368683369659, 1.2943756671406383, 0.44462692709753576, -0.03807351338873092, -0.0016250071098907898, 0.192995569926297, 2.0661887201507776, -0.7211477316379986, -0.7023312719246001, 0.27180897101203527, -1.02864283275183], [-0.8464757085989697, -1.1743134570036167, -0.09711718276713778, 1.2844042663990214, -1.2721094564981834, -0.09114097532846656, -0.13923708821128064, 1.1129721640227983, 0.3913183435387139, 1.6482145649595088, 0.2782205767048502, -1.5218753636489133], [0.7833378838134397, 0.44706998484502164, -0.19802178360745012, -0.3361159897207168, -0.0536081593594293, -0.8179471392296935, 0.5845943274237164, -1.0623868796528593, -0.5951160954427853, 0.19461956023085294, 0.538822112974246, 0.14053886808974547], [1.3522452721909028, -0.26541410113201513, 1.1457007274891151, -0.5250577609735478, -0.8440772540702692, 1.094187399171282, 0.8836052403968214, -0.5269260333342168, 0.7623786364251613, -0.15664175878135714, -0.8223114881840765, -0.7418965490717613], [-0.5057851864085812, -0.05635831604418529, -0.9110391208259593, 1.4383176849557793, 0.6985221231549655, 1.9924502853592942, -1.6660054124872108, -1.6791114120514268, -0.565870931813791, 0.7227006457380928, -0.410104823879037, 2.311611871889445], [-1.2282564652114414, -0.6976821835994946, 0.6345011565798486, 0.05833871292177208, -0.9612394885242274, -0.08226821441829035, -0.46577946999162567, -2.051713283224802, -0.07473772303716197, 0.3957427900118135, 0.8302318505791687, -1.202520922901984], [-0.3745208151309827, 0.21135146415324318, -0.9932381047995807, -0.07279765689888275, 0.7450450432210195, -1.078720202647614, -1.0492566807151282, -0.64114080934599, 0.49998541941752167, -0.5757888942101791, 0.40537914922198093, 2.217746198810759], [-0.6636889273490284, 1.911372412200852, 0.8511810783643238, -2.447172276109792, 0.12885239534029808, 0.16292841492396798, -1.0186197840755098, 0.7711945241149953, -0.8806159068805556, 1.8031768688429206, 0.372697231579546, -0.4582543540659391], [0.8898150295580975, -1.554580164743325, -0.13469048971362135, 0.46259195536276637, 1.5574667528067403, -0.13094683446215105, -0.6873543544332888, -0.08279527323652432, -0.5350668138466044, -0.9502995430461929, -0.42059266028330206, -1.6935305594164825], [1.052180792031899, -1.8100700067748259, 0.9518081343273306, 2.1237095732355264, -0.5990901305067927, 0.8618583162283076, -1.2795555442799302, 1.1372891896184099, 0.023309555809352404, 0.7860628354507148, -0.24428831737578183, -1.2911448185740753], [0.4747203150318201, 1.118939316311134, -1.0472155373421055, 0.07945642113398821, -0.8516614840764959, -0.6006214957366837, -0.030453973561526577, -1.3811848081775822, -0.3098696503791821, -0.7136747900923491, 1.0534864128458856, 0.7070704630332806], [1.3907169519999294, 0.1901524511712743, 0.07166575844405831, 1.4020458581527526, -0.7224071065642214, -0.8862016764395964, 0.07456143463795047, 1.6471475929906636, 0.6164323618450209, -0.19296304499533534, -0.19797338552178326, 0.6963150750570495], [-1.7176451627285134, -0.11227671109908947, 0.4031029270639049, -1.6291019560252973, 2.540520612728143, 0.313914542096238, -0.5783200698972597, 0.6145894407536696, 0.09635154620600514, -0.3826547815775949, -0.061556110201613654, 0.862791387182947], [-0.4928571423291571, 1.7679614767005718, 0.18037717144988236, 0.9440397683733583, -2.0770290926837944, 0.5637102806646387, -0.12392004301821365, 1.2278602673520023, -0.3996775532017682, 0.7712801507377871, 1.5454918592061788, -2.1457656097537687], [1.5341943858998475, -0.32880539157529826, 2.814339435211636, -0.2694868817959815, 0.049340428968802516, 0.44280157176803725, -1.4399096322898761, 0.16139681212077145, 0.9672889991781404, 1.9888099555408438, -1.2844005504154294, -1.1924369299687592], [-1.1825820216963834, 0.6318279746705474, -0.9738348172082971, 0.9457530143995233, -0.934037665347915, -0.3453257420931386, 0.7693756222031961, -1.0145477270866428, -0.134286667861836, -0.36131272434607586, 0.16437002215686602, 1.1645018559068565], [0.3014946236950472, -0.19564903626383554, -0.9657173098135244, -1.2168778796850235, 1.2815767555398907, 0.8657032453247911, -0.8813114543999084, 1.2131082274923837, 0.8982349873222595, -2.178634959434726, -0.8373107539524284, -0.2662774648390674], [-0.3248527704261462, 1.16493087591401, 0.28569622629622765, -1.2984536312076926, -0.99182235034413, -0.9293144005717691, 0.7204798009216217, 0.569005843512122, -0.4893987430744219, 0.958156918142811, -1.2921721841231044, 0.026771742188578047], [-0.6999814847341952, 0.9699191381883425, 2.4751452114418195, 1.007198610123053, 1.8293299469034578, -0.6165998787907988, 0.699982654142334, 0.24346839602720882, -0.05601270577439169, -0.8137044905379174, -0.31070560211937726, -0.5969541683955365], [-0.2053009460968415, 1.210064561977169, 0.946387934388289, -0.362200899672221, -0.7126060310822027, 0.45662049368650465, -0.35412173829682836, 0.12180319835200344, 0.7194684329744192, -0.4484858666319893, -0.2637498517604416, -0.4467529214031335], [-1.0389248263204336, -0.6040756356364975, -0.0782015222634833, 1.1789897282030828, -0.20192588430461317, 0.747672588575094, -0.852508304716339, 0.123611491241575, 1.4963308610501973, -1.585364864859874, -1.0117055190069792, 0.13107368589487578], [-1.3104671286434801, 0.13138083668265174, 0.3193965463426692, -0.4602360761056315, 1.5454172954221415, 0.6028881202404776, 0.7020512784007347, 0.012661628229390381, 0.5613938441888295, -0.9577836124449625, -0.22251422023570588, -0.33513161508924816], [0.4988970646381814, 1.2206167526820029, 1.9534849382391966, 0.28167826231787463, -0.14534547934853623, -0.4931211768444473, -0.023374830920874015, -1.1979044362744398, -0.4693859137333808, 0.35833017630791186, -0.9199124240687122, 1.0531136330015756], [-0.008624450261197503, -0.5428390576935506, -1.442813882334891, 0.6856491147186207, -1.8785080993500256, 0.3545540446912876, -0.04874028806960278, 1.254528228052003, -0.33756093066964377, -0.4072844180000785, 1.367501354837106, 1.0129850380628382], [2.6083719146286906, -0.28487110086993406, 1.347089958125771, 1.6507824539193447, 0.051539774771269926, 0.5130730443518084, 0.30097919948729207, 0.9470618341311826, 0.5205509020257307, 0.17454313635122223, 0.14209237160049482, -2.6957696174296566], [-0.8368960374200315, -0.5765707150267952, -0.5011793231973287, -1.2723050584478808, -0.13848740047911878, 0.23710226374514273, 2.8255818615735064, 1.9094295363635587, -0.25890248504783764, 0.3178524594894864, -0.8456381199558162, -0.5421032722533483], [0.17774265733267613, 0.06745508199398632, -0.13769904711542585, 0.30277631986918696, 0.719342021405148, 0.07319159851679094, -0.10322031603848315, -0.8615938864491605, 0.28719415009174193, -0.12782340532552797, 1.222410389390486, 0.656564355000825], [0.5996855244797009, -0.20548565167670257, -0.821305428137297, -0.13868681575884712, 0.6500334071109632, 0.4148640216205557, 1.8434901088581714, -0.9593374722313693, -0.7651432641811907, -1.2921781805324177, 0.920936805832768, 0.3087969302018234], [0.6028837816601442, -0.7919728189597092, -0.4644882040612441, 1.913216833347924, 1.080694654239561, 1.1732928934646216, -0.44882535359823333, -1.1835563277681587, 0.1819214768565685, 2.334480623396159, -0.3452705091429223, -2.081204509168303], [0.7512892962803643, -0.03424296450889819, -1.1710117217777185, 1.5312434369797425, -0.42330642441144334, 0.32764942820402543, 0.8221497702834678, -0.5136944492365006, 0.4991034743216641, -1.8987813392254393, -0.5294900829967034, 0.9516491820615923], [-0.9045442227597432, 0.7382742160313502, -0.341256812476261, -0.8906859057423439, 0.23740667797574053, 0.875147638099149, -0.6761844342530868, -1.3324385766347127, 0.19547858115040706, -0.24858529050438255, -3.266778918424643, -0.2109774718871328], [-0.6782285633604604, 0.7336557236493495, 1.285631102894331, 1.24794407306709, -0.5308390297179875, 0.8354010045767172, 0.9501752207767488, -1.3623513980652453, 0.6579164125026485, -0.8008047679731554, -0.0951186100839043, 0.7385240637675944], [-0.15929314875070255, 1.0574954200878828, -0.47243230020366966, -1.3206764718536044, -1.408668344939241, -1.982861412018664, -1.6280438663193524, -0.4482819844273262, -0.6135096110703177, -0.3304354700921104, 0.1320162071205378, 0.7396390521552264], [1.0601646630866328, -0.006979373913828127, 0.4232891684120624, -0.4900314667788628, 0.23893933521123653, 1.0606738302917709, 0.9084921341762784, -0.17629888987435488, -0.49138684805425487, 1.1925093548889418, 0.7789666398362821, -0.2554610975734022], [1.277680019283913, 0.386805752970853, 0.5047011357851441, 0.49234931415392824, 0.007535932561253791, -0.09087820039593997, -1.39757918102051, -1.8850005859183574, 0.2493770972287161, 0.5945957879704641, 0.18004554658443228, 2.0218496456385044], [0.7769882645857719, -0.5698171243502802, 1.2042937097256499, 0.7012591472558811, 1.8847844778460299, -0.4288745254088376, -0.7765397143003635, -0.5847480338503376, 0.4927989741728515, -1.7047947207581617, 1.1764320942773723, 1.0694217988417238], [0.9560636802980687, 0.6507627601483499, 0.26200569819509006, -0.5546897547143383, -0.25203357136013227, 1.9404548722433432, -0.29507951117415515, 1.5271740412878596, -1.9768366357707894, 1.7675009500898191, 1.2667693876938015, 0.4535111080744728], [0.6024474127757866, -0.2509944318299925, 0.8804853428152525, -0.45463252665173004, -0.653262280232465, -0.921683274862423, 0.9918680100589854, 0.04599666527858624, -1.2224364417751228, -0.1354659507453005, 2.341104974857383, 0.11301738523448096], [1.529873484737741, -0.1788325680934188, 0.417963502957452, -2.5299268128944874, -0.8038013965222099, 0.3857126088305806, -1.96952080086282, -0.05777805421303625, 1.7129324180209289, -2.1029702693699734, -0.21692748060133565, -2.42467401837808], [0.05004207480320164, 1.0761898460421728, 0.32214423915328727, -1.606288987114711, 1.4393999725864066, -1.2028563326528543, 0.040058673099962146, 1.3326474173939007, 1.2336280504766606, 0.4108739362801392, 1.0792535046257536, -1.1185436327184595], [1.402347960905428, 0.906136753884094, 0.14559574547231194, -0.00020167928205118153, 1.5115675269897986, 0.008688989217927278, -0.26553688909329387, 2.4772847997006724, 0.26483457128946136, 0.2808557422550474, -0.028175589902286795, 1.0332929342055464], [0.7713377441909379, -0.6837869792815537, 0.3094593183248976, -0.02290955306073104, 1.8754755179332399, 1.498884076649163, -1.4076670365968271, 0.43232588850048936, -0.5223498022893664, -0.22464046835937437, -0.41154323333058423, -1.0264360646165809], [0.3435897701265371, 0.16335248810926922, -1.0836451563410119, 1.05570149296963, 0.6879226222522382, 0.4627648391644344, 1.9103252059424716, 0.93365153505559, -0.7359947002946691, -2.178004910736103, 1.0681641849417163, -0.993625188554285], [0.3772809821200675, 0.5928550093237512, 0.09432366001115795, 0.23269029068622385, 0.5938463309107946, -0.7794887162510655, -0.5143077508982354, 0.03487875209306791, 0.5746535287578587, 0.9586412287135364, -0.2712561282457853, 0.8773836794452172], [-0.13975502053150823, -1.8518526367653385, 0.30220020909283235, -1.2412024185104418, 1.8277802060898647, -1.0576009700336206, -3.4369181740607684, -0.5873301290471522, 0.48964223607809304, 1.0129026319429013, -2.4092765623602115, -0.8403106631443634], [0.09557886143999451, -0.054311700844268083, -2.5094383393401696, -1.1556623976356402, 1.4113808883595538, 0.4480410278691555, 0.1918086417655872, -0.4884920735104993, -0.2716862145937534, 2.1080125435147057, -1.1935225165435421, -0.26220472857582705], [0.5688042140041997, 1.2631326276145567, -1.710728561070028, 2.1376394745578757, 0.33430470927130124, 1.6280425170034183, -0.8203306772489247, 0.36556537660994953, -1.8553159136763953, 1.1543978607270045, -1.4003795178433738, -0.5753434047741718], [-0.12106529780954618, 2.699099426727608, -1.9132700172235286, 1.3400723529334893, -1.4445261432259644, 0.3246390181871125, -1.5779757465327724, -2.3513317329876426, -0.2792490785222486, -0.9598509189052263, 0.3080936921323816, 0.5340207870045919], [0.232714859671338, -0.7340050576274224, -0.5866653298409583, -1.5689560755179983, 0.3368820339243876, -1.5314488971550593, 0.770223422168599, -1.1518291274183183, -0.6620864383386851, 0.4681696793149573, -1.181667334356299, 2.069753556697064], [0.44972537083267067, -0.34492379079158847, -1.1070034706068408, -1.2204490835620225, -0.8003350275204802, 2.482342423276314, 0.6165903408171666, 0.5758771170958361, 0.1998213301403699, -0.6584187238930131, 0.3248644600835055, -1.6837015912840205], [0.2540516713894801, -0.32162613425002196, -1.5538725184741775, 1.160553785558263, -0.9115955717998975, 1.1817372170089757, 2.048536080175965, 0.03229156562790308, 0.015238947213459425, 0.6230840055750115, 0.49601497549842716, -0.21085999581482465], [0.5975013761205608, -1.4217167908979707, -0.45120631247909426, -2.0611391566515342, -0.31763887193613893, -0.7322576738239436, 0.976699935462961, 0.38478640467287795, 0.7693386203873537, 1.3169504764723003, 0.733787256536789, 0.6737013291221297], [-0.1467423646540765, 1.1594133340259993, 1.2552786393591242, 0.3335711471096242, 0.5867523463504103, 0.6153660200080099, -0.12405822653097796, -0.43388273083958173, 1.7764863793523553, -0.5839410604511979, 0.9351820491330569, -1.7443409555825007], [-0.22641410050288682, 1.3984645868191656, 1.249687808259664, -1.355341911295369, 0.5761318930058014, 0.33219976246409105, -0.11910221124677978, 0.7369881305725655, -0.9777596009521066, 0.6838274326450257, -0.18474279524276244, -0.2997254047950431], [-2.1694986871345017, -0.5635421554463704, 1.730238926277145, 0.36708688118987004, 0.2829710387633522, 0.6758745751679011, 0.5706325127282451, -1.8033828106510326, -1.5811132209556176, 0.1796138296481303, 0.7618199038218643, 0.9160883974681618], [-0.2588923832604136, -0.42817232088980695, 1.1875109485468827, -1.4817155721831086, 2.6173332491959282, -1.7000149166363174, -2.0364474804030896, -1.3513416504829192, -0.7972506170978818, 0.42922065201360393, 1.004459588582909, -0.11722474330005128], [-2.105194225243637, 0.8359181357970227, 1.52410062009278, -0.28725682151939885, -1.920775133862962, 0.6446568718173289, 0.1449726178250182, -0.27774936663531036, 1.846820959436872, -0.06544150888481728, 0.021756789189942095, 0.6659977278987216], [-1.9425432982956583, 1.4117309120122925, 1.0435587490717908, -0.048813547883521526, -0.007785105668198643, -0.12916632272524267, 0.8001937858709283, -0.7114830460174479, -0.21546660075122284, 0.3412446962194494, -0.17988693349101684, 0.9665762901981138], [0.5795560108104837, 0.23463675446285645, -1.106479402146909, -0.616288327734584, -0.38752800112153885, 0.38761283878805686, -1.5209619701780324, -0.7457333056290691, -0.20032383963706402, -0.22223489644803074, 1.7461787384889085, -0.3753406287585028], [-1.4985756617579016, 0.25815213763496914, -1.4442900773466933, 0.1744100913348624, 0.5465060797710529, -0.40978224254361106, -0.7071637271605147, -0.4336415539548487, 0.7501555470801388, -1.6448901906117415, 1.1338483558278971, -1.6264496860795707], [-1.5360233488248705, 1.502274741383134, 0.019918743092792898, 1.8226195972895267, -1.0002450597237351, 0.8978458721755751, -0.11424929605087578, 0.9151392835340738, -0.5810891183942809, 0.4083917505667896, 0.12276454237367597, 0.8353397870595872], [0.43215749081791077, -0.5906745932534548, -3.921659189785081, -0.5757521102547116, -0.23333580659118117, -2.1101375902968287, 3.417856819373216, -0.466610979202492, 0.37465977247015614, 2.0903335778579573, 0.7493743037251253, -0.06514988165913185], [0.08554961185152371, -0.2254049422017583, 0.1932566712036227, 1.4191967008451243, 1.1404302787179157, 0.9170805955931997, 0.21874760527010562, -0.11993113576304228, 1.3581195185946393, 0.1809031363997205, 0.4465771014327311, 0.729097522252951], [0.28582608449301894, 0.5342490646232351, -0.272044257921416, -2.296120141561303, -2.4214916561391293, 0.392581656282748, 0.47910764501773123, 1.071719377026292, -0.12402694080469255, -0.043947012660851145, -0.13974788330185214, -1.2693244371848924], [-0.3947771669570015, 0.37276422292611, 0.37680798516506847, 0.20484857940980702, -0.09180396052324213, 1.7062491126024406, 0.045199080960013446, 0.8124205412594958, -0.5648697109527726, -1.0030102208767149, 0.3515543343272681, 0.9749956332834852], [0.5703458110446998, -0.43765057755464276, 1.1966752058236878, 1.954741790368604, -0.060298404966676045, 1.4669913729051416, -0.5169336144503203, -0.33787178704327425, -1.6630068506208495, -0.8631320713143704, 0.2759812188076692, 0.15468561891629612], [0.9912175507131827, -0.020611609292263664, -0.4895437852580151, -1.1958499346831444, 0.6890565513935744, -0.16302640264594223, 1.6648684609622943, -0.03377039133778483, 1.0025476321976783, -1.2751263321424922, -1.5194045631945656, 0.7290747085486695], [0.13579452006083978, -0.7537491345440059, -0.47070301179745194, 1.6250508310565608, -0.4356913340922855, -0.30945796559653355, -1.1532147870019192, -0.6048849292527895, 0.05022986519233723, -0.39733595109462605, -0.6916821058149376, -0.34718639003523893], [0.09973888131245594, -0.09913492088900616, 0.16058539410269101, 0.32525054448602214, -0.4512354724754997, -0.321044074524324, -1.5749805268275814, 0.7353118921511975, -1.6291018699125184, -1.190404395532813, 0.013668746313167553, -0.8408061647917494], [-2.161627380570076, 0.324876891264606, -0.1753148104257708, -0.6125511098918144, -0.9984956510634293, -0.538110278279768, 0.37845358734592044, -0.037271864955323364, -0.13684273542798372, 1.1519963090275522, -0.5172191457353541, 0.714139032884947], [0.02426118890561495, -1.7880277494593875, 0.5197238430309058, -1.0227556761566543, -1.5353946822370295, -0.3125573087862937, -0.47008151324830344, -2.0282078935801557, 0.5954489543848728, -2.11237508173741, 0.04939940101555636, 0.7715907151840331], [-0.7216918010358788, -1.0650163391925658, 0.7637536134371161, 0.47195843424157036, -0.01713390829889677, 1.4692519783013123, -0.5596894026605139, 1.3991561112546052, -1.545002786959575, -0.618726297500309, 0.27405304361193694, -0.27213546111574377], [0.13163718582372536, -1.632668743960759, -0.32030586389388427, 1.3647810259543267, 0.05290245142586176, 0.45799454877082274, 0.9414768295088881, 0.931640842570903, -0.7124933330462522, 0.640817687364351, -1.071942310472169, -1.3341917968580157], [0.4335723051378435, 0.007029369542864721, -0.016006912226218445, 1.6587120025424407, 0.9110286267862924, 0.435883122628641, -1.0849917483837719, -0.8253284687924516, 0.11378983000894523, -0.24360226714708189, 0.43767181845464104, 0.833598827137438], [-0.5693564729677227, 1.0332271698742908, 0.6115743653876957, 0.39789423716837347, 0.6828012365930094, 0.8899434205057469, 0.5045750003423787, 0.39449412731440514, -1.9122034207016327, -0.9572777889384088, 1.3947803279770992, 0.07624191491086835], [1.2918044981298134, 0.23502760784999333, 1.3604436010342866, 0.013268123250214866, -0.8096961896505316, -0.7171138384021052, 1.266660891360256, 0.7784610715524595, -0.8895620853303714, -0.28054109311484154, -0.1596751122542953, 1.3639360268537604], [-0.6852525088277888, -0.3384592825800674, -0.3416765022318918, 0.3575817796123951, 2.8074826126633723, -0.04437226775290692, -0.0899931128279374, 1.2955773948530918, 1.211966467814867, -1.2860143627028973, -0.8873008082647669, -0.326174557208576], [1.3683271230342324, 0.6815731702431808, -0.9588398980100441, 0.5025740927477665, 0.15995833378207655, 1.1585257104713436, -0.23091421447591207, 0.1402150077482411, 0.8321192750181664, 0.2107906548055188, 1.0603601350543879, -0.26481870257364826], [0.09127499400798199, -0.4024130470784321, 0.5663120792752755, -2.296534808667929, 0.08099941879727242, 2.4159430403129356, 1.7266780426946873, -0.5494268705018444, 1.799675972515393, 0.6274366539216949, -1.2012600744659947, 0.10649029256639783], [0.3658393770140191, -0.22383301502822525, -0.06508469381224982, -0.9344278977436206, 1.539478015922385, 1.5873755926118551, -0.4525823487882148, -1.5630591924154893, 0.7631735635199822, -0.528657329029582, 0.15904385671260374, 1.6408218161903436], [-1.3623703988490612, -0.9953366834847532, 0.332483319478772, 0.29842225695982355, 1.4039141027952653, 0.013072569126529102, 0.006790439907738426, 0.2631974294875035, 0.48631302690487704, -0.2460315833783946, -2.0993002837951833, 0.10934984028351234], [0.48774154010096277, 2.3504875373702516, 0.09793667325334841, 0.7058766254873768, 2.4216208446850427, -0.03773923174584324, 0.5066232545615511, 0.736077180847754, 0.5578916088921183, -0.013776440810195344, -0.5668901419088832, -0.7808256039522902], [-0.9711393064107675, -0.05383187823173126, 0.36466775085093045, -0.06363128805357389, -0.8385872082144007, 0.27556566119043047, -0.2749243748106901, -0.37046750307519744, 1.3792241700909205, -0.7205411267630119, -0.2978307721030981, -0.6509050500482659], [0.3157162318008126, 0.2655182796147901, -2.0083386475989458, -1.4274165851043188, 1.549573468396185, -3.3575558011031235, -0.57762134094282, -1.2677655738543738, -0.6076701327671465, 0.2256821051740366, 0.1427194485004777, 0.27889476762717114], [0.5443221497765848, -0.38579908431999016, 0.9706067038755993, 0.46948576992765284, 1.7101644129539009, 0.3597993302337003, 0.454415567871958, -0.6966598275059452, 0.14305371174568718, -0.3928896267985085, -0.15033420586258303, 1.4989177821002084], [1.1105780860259067, 0.9065367659819905, -1.8587932787386947, -1.460725542147422, -0.35607573392084224, -2.293631227264536, -1.4654458520956144, 0.21458118240719368, -0.9978037925488153, 0.36405314322947946, 1.798037621227071, 0.0907928322306973], [1.5206556870232861, 1.282277465157153, 0.5411285176090803, -1.2249535223772858, 0.8825410298369648, -0.25322230787663835, 1.065074866750271, 2.377491241388857, -0.5435888533143713, 0.002022435824981914, -1.2448486599750048, 1.4723154618350545], [-1.0243013756932022, -0.16572098799225235, 0.0697801043944569, 1.8381092087999484, 0.9661954290249858, -0.7017518899847044, 0.039921880600213205, -2.0032254089070336, 0.5637212980310471, -2.067951471694264, -0.32861134973198153, 0.6732959668078203], [1.4958713276400912, -1.050609918968319, 0.7271711694632177, 0.06327193002908042, 1.905778839383404, -0.0016246103280935036, 0.4671288096062244, -2.1210305664169544, 1.0307502025352877, 0.007208579826039608, 0.22224343966314433, 1.2465680952804816], [-0.47783442154062966, -1.5940929490207285, -0.5719523840657214, -1.3776281240870285, 0.4586601556519115, 0.4759642267503672, 0.17376009260959846, 0.4237498383269624, -0.16552963011118263, 0.9007575587578924, 0.8758682020905344, -0.09975774406608034], [0.4415618936315376, -0.007133600488275045, 1.8976111616367464, -1.0125014353888961, -1.0628299029116357, -0.5586440603064562, -0.05628418912242778, -0.9863345758046155, -0.348347428149278, -2.9380071285263845, 0.507913409405341, 1.7833450482236741], [-0.6966849647231046, -0.9019753770360991, -0.24903136103121173, -1.1045862091004748, 0.0346274901191649, 0.9757671936111951, 2.1047841854173783, -0.40599477456366057, 2.2018435596522705, -0.5903505555337497, 0.18957163589200543, -0.35171032886057424], [2.616600545575166, 0.718212123736096, -0.8891481905907908, -0.5227567787771829, 0.9440652423213197, 1.0528627389660798, 0.920269860737136, -0.2759550497326752, -0.43020351059759493, 1.360047712321684, -0.9488393729588064, -0.11166826302838091], [2.624226176335953, 0.3326223562930259, 0.4869397802548531, -0.951450275168997, 0.20101273151926846, -0.9341832691127954, -1.3817820178796578, 0.5093614325936299, -0.1350624248564754, 0.532819568786575, 0.8503906113703354, 0.39807393645674416], [-1.410682187432542, -0.38072561914222064, 0.08592988123807774, -1.713189256701429, 0.9559636478442275, -2.290950344168195, 0.008773210076033386, -0.9758344362423618, 1.896060011363281, 0.749511762818795, 0.2148356420493406, -0.3389983565127427], [-0.7012151186664335, -0.3088265974016403, -1.1246740567867834, 0.7562604449069825, 0.4612647584539129, 1.8923309806790258, -0.917968475357883, 1.4309302437151883, -0.4386180477989092, 0.6124118509592249, -0.7106390581247354, -0.13123334132628853], [-1.201949633338715, 0.5921582146674282, 0.3022258274469867, 0.9679242698695252, -0.3247209401100131, 0.37224023536211764, -0.42898976336399774, -0.8064899146184987, 1.0372717730023686, 0.4960659175554925, -0.5775974284056342, -0.050606274097004585], [0.3224759269374868, -0.33302640259402616, -0.3210561580036727, 0.023294372249631535, 0.20881191679496713, -0.6546325308000178, -0.9227876114170996, -0.5197867131556274, -0.35814360038862664, -2.20538111997521, 0.20068558034306408, 0.3515416152198507], [-1.136916912285926, -0.2702745217058049, 0.6486605109452055, 3.515636479112382, -1.529053596000374, 0.7252189819886772, -0.8152848932501945, 2.1237013291655673, 2.5541236722046996, -0.12792496855240335, -0.44153559564387074, 0.2732129335987447], [0.42826642750566996, 0.9039857172805539, 1.2268389745343449, 0.2841564946665477, -0.3657919075675789, 1.1951632187294634, -0.5922136399234251, 0.9568051673515177, -0.4903624379168334, 0.16140225181071827, 0.40208647634575106, 0.5148238769701122], [0.05159972213306338, 1.8336115777233866, 0.7299566380184072, -0.3152677571901093, 0.2601336350815523, -0.04352093906109461, -1.1107567354724361, 1.6810966113494041, -0.3550009789246817, -0.794076638686564, -0.5348190172983426, -0.1462290243946041], [1.0402316657967483, 1.3332598299483007, 0.7954257482074586, -1.865728925509049, 1.2722074103786496, -0.3269102030335214, 0.7726530867302664, 2.1847450910539843, 0.02201720526833359, 0.4204466873445779, 0.5098402867186059, -0.48417605626236], [-1.4528069977298812, 1.0696995230778221, -0.2703763198055322, 0.9541896191250329, -1.0383157151976543, -0.06326647301017208, -0.2131895721899949, 0.27315863596946105, -0.03068330229205504, -0.05965677368730291, -0.1877450203813762, -0.9157541917098352], [-0.9767471014774599, 0.07218980747186138, -0.4260921823492592, -0.3214915672575845, -0.31692559023657696, 1.0402676884169504, -0.5460025908287789, -1.9618222082053123, 0.11087479237301089, 1.0404992286583827, -1.3000467643913423, 2.42140391528341], [0.5678063704556138, 0.27662645040865647, -0.907871280556306, 0.23418748575920453, -1.395161979595189, 0.22148802441321902, -0.5927713169942794, -0.5691729685894645, 0.048613541480039824, 0.7726476667544282, -0.21379483530728322, 1.1830248598885], [0.189966135545566, -1.1368874585553792, 0.4613715398954425, -1.158952316325665, 0.016282477559342808, 0.3737137616331276, 1.092755134133638, -0.5535536615114882, 0.03849218257628255, 0.8099026683353328, -0.3654002794282134, 0.06352790297774336], [0.8272294684695285, -0.8622405885094752, 1.5269726181619339, -0.11566391876456703, -1.1755810235811892, 0.4939726253707425, -0.023763046844441915, 0.26346900361615205, -0.42881777272291033, -0.3589105870766351, -1.073256783724179, -0.7724561080867229], [0.38603675972030616, -0.40884699017198695, -2.0859707280732636, -1.93311655203421, -0.6170891941867852, -0.5976939399948679, 0.7481099971312042, -0.6003508748700805, 0.4915984471447508, 0.8515607201999995, -1.3525899420898266, 2.11709820834814], [-1.9941186487633196, 1.7082260795262172, -0.0012960629259723268, 0.5019313798708677, -0.3321498459919344, 0.43276756347469053, 0.25012765109368906, -0.8753098559931598, -0.021617028074515966, 0.06094618664567124, 1.0350301391236476, 0.4494907858987772], [0.32730951968007216, 1.100671417235858, -1.1174220145717157, 0.22280019430879466, -0.9353136763682022, 0.7636425442350295, 0.24611681871128074, -1.3368441271052771, -0.6276532479821226, -0.9943263215950215, 0.642365141239503, -1.0468462056079686], [-1.9773439748983652, -0.0387830093674411, 0.39572975627193957, 0.4197820245278867, -1.1930623219696155, 0.3121736875586117, 0.5090641246622868, -0.4018765588359428, -2.517970882401885, 1.6625785549254335, -1.2608749862264577, 0.03523195138552369], [-0.055563301722388866, -0.2677275108318954, -1.204143428826681, -0.01747023745149699, -0.2740001896612083, -1.373712936609698, 1.295801537531344, 0.8648016861570251, -1.4183236247082065, -0.8193085582416174, 2.1592243720519977, -0.169705068833173], [0.3834728039089084, 0.02035155550305701, 0.5987555943582331, 0.5889821724976928, 1.1699859021809453, -1.2695677167403248, 0.9496812294709548, -0.2999498947916775, -1.2347864622733415, 0.014116772293060449, -0.4654494173758615, 0.7019394481110367], [-1.4506977296877948, 0.8702434204871928, 0.238086830387594, -1.2942572259669916, -1.3329967750129323, -0.9427323246770228, 0.9936402575352904, 0.3961248326824335, 2.2308851958443054, -0.6478938405908062, 0.7002528155047654, -1.2761866898101186], [-2.1971478092933485, 0.8806644177706321, 0.1022105351705784, 0.3092171570903251, -0.7303256188282047, -0.36148701018190327, 0.8132119299084155, 0.20352788373789155, 0.08733952280844637, -0.4754627313002534, 0.027714355502486146, 0.7341138256219911], [-0.11698110717624757, 0.9043974098225697, -0.4381292923772414, 2.2133500423329284, -1.2043288415161435, 0.1236665963374209, -0.5886527592585137, -0.18377300011133732, -0.15845760049252522, 0.17939145799956419, 1.262526917678158, -0.7458658291616582], [-0.9369474480261543, 0.1263595039756069, 0.5041774444352636, -0.3536993256260768, -1.7285117449635135, -0.32152357130413795, -0.5532804074940608, 1.0087058147957069, 1.411585358173167, -2.3000732799425463, -0.017455223958985217, -0.19832527330547425], [-1.0532668057255044, -0.4094570628822677, -0.0587717477889305, -0.33918512985036764, -1.2567500036809693, -0.12074238180944728, -0.3558499690851093, -0.8030483020797278, 1.2686202150586523, 0.5154731977648717, -0.2965411304509085, 0.5498172789425543], [1.7410153309461887, -1.9525070449601698, 1.8834184393782833, 0.27911298393592043, -0.0005290540333436967, 0.7182675949443449, 1.023783334385274, 0.7059899998123025, -1.1699771781965322, -0.615120736814194, -0.5997436283882034, -2.0302617850072324], [-0.36408919638180975, -0.5045760650677321, 0.8608496379826456, 0.0238594938345639, 0.5375042496125318, -1.135678281410374, -1.1601845713642767, 0.20782177867168722, -0.09815861265096949, 0.8517923399118597, 1.9282336868864076, -0.3149342482543552], [0.20660737186298977, 0.754417364781457, 0.30378260841630783, -0.9363368878791497, 0.12088861542346968, -0.1882456531514122, -1.0018463675811045, -0.3448199112040682, -0.46786224463841763, -1.489045174565222, -1.300618409636888, 0.22304689358459281], [-1.0246877142707078, 0.9542731174080118, -1.7786407123735077, -0.8696053246533871, 0.9579453841368551, 1.6684336805285467, 0.5215118634850828, -0.4233639753589937, 0.49361575167332766, -0.833533463647759, -0.8335928176074296, 0.7930953036460487], [2.341252759787168, 0.9278360332811328, 1.3196203494405823, -0.408659068062194, 0.011955431867316905, 0.8267409462250904, -1.733738993443847, -0.15125711930792343, -1.9883881337750755, -1.0509530898800448, 0.9953752507524871, -1.6747409285047445], [-0.25602182536768703, 1.2778696925266555, 0.6213999873772597, 0.3956329625474646, 1.7134406850137613, -0.3249130776275122, -0.3553350079433803, 0.5328742323590318, -0.6127874088314708, -0.35173299920862333, -0.3541163596707661, 0.08809070934147561], [1.0920269473603572, -2.1192154962848333, 0.25776725418789237, -1.6974109705401867, 0.36537118412186487, -0.6434256951759595, 0.8281290824634143, -1.5732976968604149, 2.094720369479602, 1.1407307621829312, 0.2625846884604342, 0.6886474373143887], [1.6856925448361029, 0.3616271928373487, -1.2519035437824886, 1.5583996111532568, 0.11554502281811185, -0.4922931517994415, -0.3163964767634848, -0.4726399920040722, -0.42417670669238755, 0.04852186806027586, -0.5707145028499491, -0.825710828786679], [0.17245932724514093, -1.0281788792381628, -0.12004031049634689, 0.7173885321732515, -0.811031904296969, -0.21397222629880763, 0.16624854135226189, -0.21727388685645793, -1.4690333002721214, -0.7613387613888851, -1.1173264245933083, -0.4445302013890274], [-0.9813129594458639, -0.7727384350857335, -0.5333656373317706, -0.0750028978933775, 1.0551243673256894, 0.2829479433794594, 0.9853234134452039, 0.46709247536061027, -1.1877834040870296, 0.09268682594226067, -0.20036431534770327, 1.2252206707126978], [-0.15689858196788026, 0.15272764978632994, 1.6406180044440444, 0.11846727073863716, -1.977741034713882, 0.6221883620715524, -0.22134229754520202, 0.09200008307304429, 1.2721273224517047, -2.1138557177595176, -0.29135650622159176, 0.5938544229615114], [-0.2249929985265043, 0.8563041606862257, -0.06215635889118203, -1.169824697927421, -0.7503322867993193, -1.9541345158556969, -0.015108239274643144, -0.4401736764857433, 0.17497206445551097, 0.7974615408129475, -0.27653464239317566, -0.40444652708194195], [-0.2715202062595814, -0.7289107820128765, -0.16167125592730808, 1.7656010537176041, -0.739367660846359, 0.5288997198208815, -1.414703288909999, 1.4894520259114998, -0.5702042259978285, 1.0282070415020677, -0.09202895553357832, 1.2500420313983107], [0.9931345431886324, -0.5865751181563253, 0.2774990296477985, 0.4999262201687291, 0.38037899651863105, -1.8906421707942498, -0.0567582700083927, -0.37268874043091166, -0.5329366942219013, -2.0576166907727607, -0.1528539569507149, -0.31837270152787883], [-0.48124990488113867, -0.3204752826864267, -0.9320447669206843, 0.32591280169293485, 0.5551612152974184, -0.16363833932243183, -1.2042593304926779, 0.35743429861874804, 1.9464291624912569, -0.5889435818154606, 0.4304313272746397, 0.8303477665790124], [0.8401913223119637, -0.10957537758083506, 1.5823599865641522, -0.8635926793757394, -0.816765589378974, -0.06778071133160064, -0.6125282110840372, 0.9411016942445588, 2.2494715107273984, 0.08765769338423289, -1.4418940321898703, -0.7347861509311553], [0.018399243560145814, 0.9609649211141701, -0.0625266194218021, 1.9275091838825282, 0.3294275862614241, 1.4206512544434662, -1.0475277017492048, -0.9655237825153619, -1.2505735134501965, -0.6598790726404149, -1.5250578654648448, 0.11284555973747439], [0.08498778268320827, 1.733495275299681, 0.5948360350778297, -2.5386229130384397, -0.4615360589803794, -0.7794667865860205, -0.5791580403160971, -1.7829898794423167, 1.0916929002801548, -0.25820999631558683, -1.1119309719044197, 0.2050437212536831], [1.7485282986711583, -0.2181494551917507, 0.2883660443837251, -0.641676386787446, -0.25795127368955323, -0.39966390245770467, 0.33643879821512795, -1.4645464102189707, -0.2925281009913344, -0.8322325145855132, -1.1982375128777165, 1.0304316181611524], [1.2626783089617348, 1.6979594673860627, -0.3839978680286698, -0.95243342875902, 1.1026251754792435, 0.1944825999169617, 1.479051837930983, -0.2830259970693893, 0.7027508524361622, 0.295099767287021, -0.33122642751192033, 0.23737338055376261], [0.3791720337754086, -0.1269372656474552, 1.020468213201447, 0.3322594687759625, 2.321019339841911, -1.463180272550214, -1.769284599348262, -1.050943343450144, 0.4703194970223368, 2.1863616713747507, -1.2035610159772157, -0.4644186199654316], [-0.08555426027040046, -0.7081171912462949, 0.7692234346443684, -0.9698232705587623, 1.0728196603005458, 0.14154847550591518, -1.496020775120909, -0.13419139415043252, 0.2126214419677176, 0.4683104769637048, -0.47672498114160405, -0.17513245601970684], [0.9629228763163884, 0.06903687824719967, 0.19197702399180874, 0.6069215173619273, -0.6932369651676569, 0.7998111919713545, 1.2812734327695214, -0.9062051005387078, -0.39780493858392346, -0.047767042619500474, 0.27817044148080333, -0.19292473920917266], [0.5175807396549954, -0.9560047100544627, -0.9381529178332499, -0.04619633147662138, 1.3881872162185163, -0.08043361225921862, 2.546801556288899, 0.8427141828446284, -0.5532116084866374, 1.2245704864236133, -0.636517380490793, 0.14659846326501486], [0.8218210956407754, -0.8367974753832145, -0.4225278355555889, -0.6596166192218205, 0.5210544371276731, 0.1309131805165992, 0.02002098587115336, -1.0017288079464977, -2.2450917785481663, 1.82762270706512, 0.3459626902926251, -0.7872913275482585], [-2.456790423745184, -0.05483889848062889, 0.19293345213450552, 1.0872430993324949, -0.08750233355847017, 0.44683928792626637, -1.267960888580304, -2.171320212721272, -0.24546158852614905, -1.3106872291909368, 1.2006049839145032, -1.3707032682936362], [1.387286056633444, 0.022293226839064376, 0.6051727966688011, 0.5053401447926147, -1.4317159981858825, 1.021749640936539, 0.4703471013447293, 0.021375588482991457, 0.011091608660679646, 0.02919273145320251, -0.8997481828145275, -0.7200783239373827], [-0.642813291742331, 0.9050120545998429, 0.2850138438363601, -0.45207806207858797, -0.10034971191094967, -1.833592702105624, 2.101933894378877, 0.8101285265030578, -1.0569626436347241, -0.03205906691531517, -3.017931316331787, 0.7233088471667616], [-0.3701464414130365, -0.23797011189040473, 0.06590729883055028, 0.5806759637445597, 1.7750515448733677, -0.7416106300071461, -0.45007521600324174, 1.5200720635589067, 0.39039414719704585, 0.665766196728245, 0.12854684246628997, -0.954180335329532], [-1.7411382368160688, -1.040073466719254, -0.007199556482669033, -0.7657336746303168, -0.9824871535731108, -0.15564764722587943, 0.8660959645229929, -1.7763913489257188, 1.1942070683876045, -0.8421898897659426, 0.9616307387622525, -1.661960970221178], [-0.20250042457835868, -0.9283867837028368, -0.22534768301043204, 0.7923779950576619, 1.1775047972025925, -0.5373243479009239, -1.6473707621239433, -0.9614233698947621, 0.47367780613671084, -0.7263182339798947, 2.5953637982029396, -0.44863176316793013], [-0.4516129578141594, -2.1297486459360813, -0.05652556673173862, -0.16167771898871722, 1.5098799200493318, 0.5838548038841543, 0.7565656761294631, -0.9000243855125878, 1.0132114165351016, -0.8642693909087981, -0.4434688655834891, 0.3557508718381033], [-1.7955516387868882, 0.7390697320276425, -0.9506632229408412, -0.4793813296795168, -0.675662859846524, -0.01778557920218192, 0.9965749800261818, -0.012157956001307072, -1.2002897181155945, 0.7582824295396573, -1.7005358389329317, -1.3557090504649447], [0.10913311736308974, 0.5229715609233883, 0.45234660007409067, 1.0461441740939055, 0.874952229236172, -1.217236602667762, 1.116984414341567, -0.43541086993607797, 2.2925562424858272, -0.7027735437270057, 1.1485073138635278, 0.42307101962568316], [0.2529474148961908, 1.1628412730457964, -1.4163064375532883, -0.1591284390915792, 1.1137105506385536, 0.6385101045357583, 0.6635615533827977, -0.37298453007123045, -1.489511053735099, -0.3402518858465087, -0.3627922286228851, 0.09296343911919744], [1.5527844432684024, -1.188396482085942, 0.6115952313217309, 0.1898930614418874, -0.8136937783393673, -0.7376621946579147, -0.7351174872925496, -0.16262058732317566, -1.099164130597901, -1.4746757646212332, -0.6394471126608718, -0.5673015207058649], [0.7481379391607388, -0.2681985628668627, -0.34076565121499114, 2.0267978675871174, -0.8730716921083013, 1.2631316565218367, -1.5374981884374843, -0.2853934546032385, -1.5482187075039375, 0.11016635729176948, -0.11631155043683117, 0.9456550039139933], [0.016215558848076815, -0.7300717285135708, -0.7844919661182999, -0.453962798080271, -0.11407140090489941, -0.2987166696087677, -0.28203775908963097, -0.7743495315906785, 0.6040530016845392, 1.5350062164964855, 0.35115577730331293, 0.6148960246814266], [2.8415383806838053, 0.2560818658570899, -1.1966571072871808, 0.20679646422375098, 0.958847196622372, -0.6282495414061439, -0.6539651641253623, -0.9226668083691222, 0.021378985008661606, 0.5189333520005511, -1.5867217166505003, -0.7003962891904385], [-0.42605235298630495, 1.556164830056591, -0.7664350061738184, -2.26515816563303, 0.7504753975972841, 0.6616494996169737, 0.16672606793340994, -1.043788044056625, -1.6944881698500769, 0.1543585951847136, -0.13776066675898704, 1.8794641560962166], [-0.7829621140392774, 1.4280524005686042, 0.3585091894746753, -0.7376519775339871, -0.10138575199625359, 0.5201731866274371, 0.21446270166992348, -0.6756754472737485, 0.31039398783372696, 0.48774803076041434, -0.21856394102944157, 0.18920704304583305], [0.32788416260333625, 2.01711228545068, 0.5293344944366225, -0.38094021397238914, -1.4363494593846635, -0.6726514046478183, 0.893208017710659, -0.7449657123864184, -0.563509079740135, 1.172687230796323, 0.39222000169070703, 0.6217189179531908], [0.11891734641951057, 0.6069573871188142, 0.02235008248151506, 1.3519830733775344, -1.2038851216134168, 0.07464727399003888, 0.2834141958064483, 0.579791588510108, -0.29071968982682694, -0.23960268311383026, 1.5193087317040008, 0.7465317564831359], [0.11559914643339907, -0.5341294929476099, -0.054268815512816704, 0.9827782048613968, 0.6514832066521077, -0.5475775074752359, -2.0200072488278713, -0.9353626537485923, 0.7117565397857392, -0.7736192456445048, -2.4594185697291304, -1.7334806532620985], [-3.211765210808513, -0.13427895767310238, 0.1675008588413798, 1.45219600442888, -0.6121685445275297, -1.0201699131312394, 0.08183503484562926, -0.37974284109801504, 0.2991307392942252, 0.2353366200018778, 0.06292101738687743, -0.12387065015027915], [0.1792340013127338, 0.10818309479790532, -0.9876833702134052, -2.1333981541141713, 1.3210033364598215, 0.1168120400247931, 0.3262132516485798, 0.17536121803849217, -1.0305821315421215, 1.97111720782191, -0.6275602832196205, -2.136727743977069], [0.6997425558241425, -1.074563252514775, 1.6259530190617069, 0.7256993314142718, 1.0222996410659448, -1.541671366265432, 1.40744851635989, -0.18397175316106149, 0.6535157747861612, -0.521042481055852, 0.11133087764231933, 0.8487175435257982], [0.1396602675948869, 0.5141453806427828, 0.20208983740335731, 0.20833670174489444, -0.25362375077297733, -1.2784163204498022, 0.32377018776886335, 0.8688501056198406, -0.3883739979688179, -1.1306660334198309, 0.09244244508048995, 0.8673221048407463], [-0.5461515124680992, 0.6066446130329716, 0.5935062845703364, 0.3565147195352036, 1.8962581468562343, -1.4870033602394168, 1.0600657616679778, 0.9629482620807878, 1.1859956067625905, -0.6414567984369699, 2.0109022057758312, 0.09308894079160912], [-0.6399791963838241, -0.9422471168500562, -0.8613048426397554, 0.3133027480262119, 0.8547770308561803, -1.5249542139263212, 1.1744450432101892, -0.08830342234384445, -0.596845388277264, -0.44923756055141895, -0.628310441086571, 1.0262647979163801], [-0.48416043743196213, -0.22625107524949883, -1.4925108384134822, -1.4347644425557926, 0.3214872888069165, -1.5754635973319693, -0.4447484262347564, -2.20603195632224, 0.734465070346544, 1.8466176015460585, 1.0867193462503124, 0.08677557217283044], [-0.8939573519561055, -0.7986608701302421, 0.05514502674663918, -1.7024930606571798, 0.024674209290691546, -0.20298743682928128, -0.026877355559018733, 0.7368004766287978, -0.6204818799559643, 0.5405581927750183, 0.24646727676662603, -0.7706874319637058], [1.4242911119359722, -1.3477976791324697, 0.26396059853989456, 1.0105837380736682, 0.2650222852431008, -1.0064979342155855, -0.10917015799928659, 0.17611416994559084, -0.9667986549034561, 0.2632990223913524, 1.3514150411138797, 0.9129396952766962], [0.5257824362247324, -0.004231746929804242, 0.7106031866328765, 0.28624868662213326, -0.9069733676516042, -0.1443817017212416, -1.1493035270205918, -0.6383296040644053, 1.5179507801430947, 2.03067132972045, -0.711110766247397, -1.8528071308836174], [-0.19178716979808835, -0.6609355984199219, -0.2674432466329597, 0.2891674875776713, 1.1262334295750343, 0.36116355366275565, -0.16906876718046046, 1.745674356331938, -1.0645533140098429, -1.0553593030279929, -1.1221238688691113, 1.8532190792086847], [-0.8106293439468778, 0.2600070650647877, 0.452975520657442, 0.03221669110021139, -1.0343378699601933, 0.9874445482945038, -0.27157792491510463, 0.5833614994454848, -0.413507129767985, -0.46936812197072403, 0.8776237702015495, 0.9518454928472105], [0.05533546850811512, -1.3514247099960486, -0.8844108444531255, -0.3206470364975145, -1.2714370148566478, 0.3785143954924006, -0.32628344025738104, 0.2703156459738713, -0.727410366547431, 0.9011098212642698, -0.13075688675915365, 1.7323250641063423], [-0.789604251504338, 0.19641835959578693, -1.040927338222548, -1.3416631302983162, 0.11303510215298497, -2.1842158920471006, 1.6779627253679037, 0.5047522513502904, 0.6486693418096735, 1.95946138295321, -1.2463441605486292, -2.426819201935205], [-0.1531837502113875, 1.2544046623481775, -1.2690325507713882, -0.5471775028970094, 0.18462659521684108, 1.5021309612832419, -0.26038749886721985, -2.109057664537978, -1.0374366049980064, 1.088528686725572, -0.36874378153387344, 0.7740444555690776], [-1.4797394670138289, 1.5924356534674913, -0.22897270029483138, -0.9941121773853082, 0.3573614853619612, 2.215569345437528, -0.8043830357230145, -0.10482887990331036, 0.729834625953597, 1.3221535568793656, -0.3107511723114111, -0.7761598039354529], [-0.02000584965252227, 0.5955677683680413, -0.7583651587509831, 0.5080866196324111, 0.17876524815508885, -0.0391176139381892, -0.12574839258833667, -0.6703740270731555, -0.6554032730531714, -0.1542203370379693, -0.4833456130028536, -0.7313716612400151], [0.1482256154472821, 2.617166144692302, 1.008415479874086, 0.4411089902064598, 2.159761485745129, 0.33023492420079553, -1.0881428597477647, 0.2981144859679081, 0.8085889129261121, 0.1333164375466723, -0.011450088493670692, 0.37067505485721947], [-0.7317174740480299, 1.0408585948870022, -0.3324387253747245, -0.4144191621323044, 0.606710611889202, -0.9137920393593978, 0.04450963399662904, 0.34621885623032916, 1.5216863750343907, -0.16030009723353533, -1.0947402169119649, -1.7428408976570782], [0.5634073125555427, 0.4077241867055637, -0.03817378944697821, 0.6789765227195511, 2.823927230965471, 0.5087905366585939, -0.9287578437589574, 0.892016060577792, -0.1459834722485383, -0.6695971077975323, -0.4182198970659845, 0.7183805034566823], [2.0960281522366415, 0.8528752635391884, -1.304337096685168, -1.66321609437315e-05, -0.5432930253415509, 0.5868353684857451, -0.25086076066714247, -0.4416578156519896, 0.9590553706472276, -0.6367404670739492, 2.106583341342237, -0.4281327188667728], [-0.11962125820511944, 0.3498079831569381, -0.30266467797286123, 1.622137266759074, -0.5135783224245013, 0.674755849534863, 0.49049722318777333, 0.8960613925450152, -0.8715332705412364, 0.7400951119206914, 0.6542154891913654, 1.365651956679702], [0.9590845835693182, 0.143197830644689, -0.707853432468578, 0.9269731397124252, 0.18444179353272636, -1.769983550007634, 0.42026695259406205, -0.9241856111099146, 0.2925716320237903, -0.5525621563046342, 0.07890332293236829, 0.16373925095657926], [-0.08080308542216355, 1.071987799643454, 0.940434305255703, 1.3655904298938504, 0.26995852702393675, -0.591096411018731, 0.23299318653496762, 0.65882070209295, 1.257617813567895, -0.16514579266783624, 0.8650700756452024, 0.729718596791573], [-0.7881297132673916, 1.56643264048219, -0.19148218526137004, -0.14806460326641493, 0.4003735628839275, 0.6255743037324025, 0.32377544098418126, -0.6488221394786682, -1.1699306152440179, 0.9627942642203889, 0.7977835811069477, -0.14036984950938], [-0.010124286705356984, 0.4376255697827119, 1.0852781068760304, 1.3431920254561245, 0.4667009855901252, 1.2118048316535015, 0.9628481995722284, 1.3138878858535248, 0.8802852031692113, -0.0803915461431425, 2.069170611437516, -0.19251606918877476], [0.8750157245935589, -0.7277733211632663, -1.5219785653398816, -0.0676394383583539, 0.6662606572644222, -0.01895417571165524, -0.09131994824615683, 1.7467084275709408, -0.7293386102813777, 0.8430400936780322, 0.0008860216671203792, 0.6167051991052224], [0.6882458198052426, 0.06490613280237846, -0.8852897761650518, 0.05820503888126226, -0.17887100516465085, -0.2063023704657081, -1.5365992687089731, 1.3708448521369752, 0.5532797865973378, 1.0477385405885369, 0.4534730671889889, -2.329045937994815], [0.6117671002123156, 2.7660589804490767, 0.3985638955101634, -1.8857083988959606, 0.7484179807516737, 1.1853197589686666, 0.031140114896404846, -1.898025301653815, -1.5766617574618815, 0.3983811151872766, 0.41565570657907747, -0.07833856635605192], [1.1718897117414924, 0.1421535899072977, 0.6792155397999546, -1.5900003632483826, -1.0508361491556357, 0.3726321461649592, 0.5291443306913446, -0.4579735708097546, 0.7046433913465238, 2.1444196468811083, 1.4865378195010643, 0.10195689152286017], [0.767237458442801, -1.3148130773646856, -0.4440069211283891, -0.10861795855188627, -0.4013341898394869, -0.6255474527752282, -1.180176761252152, 1.3173073090740888, -0.3534144120959305, -0.750549108578364, 1.107738628964394, 1.4673711603229305], [-0.5587629582252928, -0.10674528222786715, -1.445981089875528, -0.8821422139443306, -0.5841168803248469, -0.055784090775328504, 0.527237698103438, 0.2881185500066274, -0.3122357386673796, 0.8673540370159987, 0.7261338300140816, -0.286365393711783], [0.5791138919509332, 1.2598706367989985, -0.5284065268069463, 1.487147594412482, -0.43596737797594665, -1.6516377173879684, 0.11731073319843514, 1.9106634521493842, -0.45902722382690236, 1.312700688221499, -0.023427213936377405, 1.5794285395625098], [0.8513970653383076, 0.2150468651577582, 0.5683145155378049, 1.2422159192556346, 0.19827247870515685, 0.6973263984690672, 0.4800381926635943, -0.0317020926420543, -0.8154550983702509, 2.6101020682126967, 1.6526041942091214, 0.7331622551255268], [-1.5380163192391092, -0.1340062228852325, 1.0838035009407112, -0.8040834807670819, -0.186955577618494, -0.15142459106934414, 1.6385708517386113, -0.468396682876752, 1.8243856012865287, 0.794950456390736, 1.1313157004476, 1.5178914119317983], [1.171721264552726, -0.2659972971057888, -0.003932884720004318, 0.617555143077661, 2.4333130587406013, -0.9966868304406422, -0.2754274173502867, -1.9429454012417877, 0.7834676630212885, 1.0337724370450474, -1.6168676621696998, -0.26375554141250834], [1.0367479966907551, -0.4412104630422475, -1.3971590426633937, -1.3725266834215117, -0.23137122311576147, -0.24369833669328136, 0.08651133078448868, -0.28916649366506625, 0.0869901608874237, -0.49613200231289856, -0.6438135965889341, 0.10365798302244439], [0.29353652330278995, 1.4065311208610525, 1.2599138067605478, 0.8136257873354106, -0.49871435578590806, -0.2512105820931261, 0.513981768275219, 1.6880318098256517, -0.41624193492209755, 1.4267530785180844, -0.48910644646244805, 1.4736417701458189], [0.7291956689335624, -0.20217088775647524, 0.39190762655913164, 0.19689932080214262, 1.942380285905119, -1.5031331587174679, 1.3939862261560092, 1.0136115669667545, -1.5351907671935576, -2.104940572082595, -0.7414163782274312, -1.8110682640880007], [1.335487906957729, 1.5534059627813799, -0.4121260618272309, -0.09341210378033898, -0.0641779474050542, -0.10821061654938663, -0.3225017517898313, 2.627245304479026, -0.6819148227831321, 0.45421830503654864, 1.1452204423329668, -1.5084141488815481], [-1.5252813362958213, 0.8916972801499641, 1.5611259436648859, 0.31438043299715346, 0.5801854255282908, 0.20501025638234502, 1.0788025830088144, 1.2249903470498822, -0.6635177153863766, 0.9932238942904387, 0.10661306057323998, -0.1994275761020943], [-0.2990844781421783, -0.7337424630695161, -1.5657967150632772, 0.10043866801832049, 0.9657255723208492, 0.09976758667121458, -2.0808633524203333, -0.7599914966376692, 0.26839481094198364, 0.8193612632626787, 2.331574241770418, 0.8778342483255859], [-0.06038316538742116, -1.4346073264188146, 1.9366330193268713, 1.25985320710739, -0.9630618940845805, 1.418366517997445, 0.31197297865755624, 0.5113285772683797, 0.016906820336966256, 0.8077417476953841, 0.3793234486725232, -0.5471569845475032], [2.04866023044956, 1.4127790018682194, -0.1982547605065261, 0.8559689957674784, -0.07412172254725496, 0.3853103603687771, -0.32081094403562244, -0.07167841027629726, 0.423524961704857, 0.4408030647147315, 0.7162727435499053, -1.578833750672668], [0.9328048591184872, 1.3635787666017305, -1.6735708720385643, -0.5858757895080194, -2.4766561519050887, -0.7259639217449534, 0.7162373382436348, -1.3350102427717812, 0.08711491033130303, -0.6171334753320672, 0.1630030651429729, -0.24339220413231394], [-0.5236675735577142, -0.7875405532859061, 0.34682455510191745, 0.4221369817372399, -2.2041521143138465, -0.27022674153051135, -0.5767621743267002, 0.6275026060476122, -1.0023716836947607, 0.00941489513869517, 1.582682408925992, 0.6641890478480887], [0.697535464008434, 1.6309812854813517, 2.7121481608714926, 1.3911933312917475, 1.776670298362319, -0.4997132074103164, 0.9945959423428827, -0.5780277867536024, -2.3118698214952844, 1.605562376270996, 0.0279220435554274, -2.0793060213747445], [1.0747947308313068, -1.0365969678820761, 0.651954588023029, 1.7577159420207817, 0.21273036761812314, -1.567823788918302, 0.6511119704603922, 1.9058054945458034, -1.2140307852617256, 0.8187613633631909, 0.3056745458808121, -0.6943155350873372], [-0.6088501160578226, -0.030543943661491966, 2.505803727140237, 0.598744649842957, -0.21581332986233542, 1.0448435066625104, 2.0819705668497, 0.7719680429475579, 0.25785027059553295, 1.2150050564242345, 0.9187097864434354, 0.3903876720145639], [1.0414187928119143, 2.0033883690378054, -0.16864167435219765, 0.6485821293195729, 0.44341112642598973, 0.22398285193109987, 0.7340345591381812, -1.382289985908427, -1.0655909868027549, 0.21109193208347737, 1.2476886392745612, -0.6946224808797707], [0.7428595151847714, 0.1085167885846738, 0.1988773608589636, -0.8311048954326278, -2.023989774299992, 1.5854908262549896, -0.5980788389796876, -0.5799691148350762, 0.6734781581555527, -0.5991175043978783, -1.3309241950453123, 0.8539092823594455], [-0.32746765020575863, -0.37424725142960413, -3.532869163076072, 0.7220534769073399, 0.44041596610838024, -0.28614313458806717, 2.241337517997091, -0.6387834526475988, -0.48305997663195155, 0.2803835318390951, 0.3177742387874392, 0.7345184408521136], [1.1070173436470345, -0.4660775118060578, 1.2924413696802155, -0.05674927580926755, -0.11182485772455958, -1.5962953945206513, 0.9142908044519992, -2.3375717745767868, -0.7542259632366227, 1.4038337860394778, -0.26105820794415885, 1.3086894760076824], [0.4531953386510326, 0.3995474479970881, -1.3466366091156183, 0.4613216528273926, 0.4172066527514697, 0.8327001169612295, 2.651791188021363, -0.5386862558741078, -1.1589534477504606, -1.71277297632983, -1.672999670608736, 1.3051038795572376], [0.7305393520383306, 1.944949492829324, -1.1424027710388003, 0.7546644685929589, -0.18948728777042845, 0.791679336679374, -2.6621604195233783, 0.6732866568075944, 0.09099353557743063, 0.8448172805423599, -1.1479991907099516, -0.03689317487372543], [-0.42425543638985747, 0.9797418525044312, -1.6613529301059065, -0.8027806886616642, -1.663150108719845, 0.24545512140437975, 0.24295680328228444, -1.0339429962658266, -0.13356703820114485, 0.5197426892560677, -1.6131575052559797, -0.6506337087354331], [-0.948858481034771, 1.444078966461146, 1.782969302194044, -0.7488781628320892, -1.4053141148516393, -1.0674782221300658, -0.04213005632346922, 0.45620713727569, 0.431691534006609, -0.01795728526780704, 0.6995710089845455, -0.7316699441036768], [1.0977210986624018, 0.2797709505222343, -1.1039599257843693, -0.1843383501012772, 0.739596956893132, -0.6885104092467211, -2.2881003535695688, -1.7394464886587226, -0.7880152224538295, -1.1784003640615814, 0.7511158729459995, -1.1884353753136259], [-1.0727584047271819, -0.023155395336750415, -0.050253213136418326, 1.3388522925136321, -0.5849923327167871, -1.2880251202487136, -1.9995385528778375, 0.459594070874499, 1.8795964840910417, -0.5119529473626165, -0.6465083987940772, -1.382895014609819], [1.0483157501307243, -0.7656318416094848, 2.15741062805111, 0.023343737676514806, -0.6578323115169402, -1.1167180208303127, -0.2638281409977289, -0.7895748500185003, 1.5568442663794702, 0.6883753339126215, 1.4372100403208723, 1.7812763928943915], [-1.9336069247589522, 0.27329120721731126, -0.29785862952732345, 0.391590141305706, -1.2352453952592424, -1.3140579137681216, -1.316657114621671, -0.6428783296508169, 1.7751590115966511, 0.026918837324835413, -0.38721045185138864, -0.7424547860689072], [0.43822965853710905, -2.0571816141474306, -0.27881486677462475, -1.1710601628538275, -1.80317490323154, 1.0878104396580062, -0.12882109946856632, 1.001579088280538, 0.34834497811130755, 1.9452844613583262, 0.4950259037116168, 0.6195091035403871], [0.7332233638573672, 1.502631571679637, -1.3615039554068566, 0.9223427313059634, 1.1178211824064026, 0.4786931411513396, 2.618144941904764, -0.0439177694170744, 0.006315151582807491, -0.3372941335098838, 1.0794107290595305, 2.811144393111589]]} +RLMATH_EOF diff --git a/tasks/optimize-ea-kissing-d12-n841/tests/check.py b/tasks/optimize-ea-kissing-d12-n841/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e67c43884a1e3216148fc027eaa31c36e4ff51a4 --- /dev/null +++ b/tasks/optimize-ea-kissing-d12-n841/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-d12-n841/tests/instance.json b/tasks/optimize-ea-kissing-d12-n841/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a669df45a2f732de413a79514fb37331a337d2c9 --- /dev/null +++ b/tasks/optimize-ea-kissing-d12-n841/tests/instance.json @@ -0,0 +1 @@ +{"dim": 12, "n": 841, "direction": "minimize", "best_known": 0.0, "progress_scale": "log", "log_floor": 0.001, "baseline": 2937.410605800468, "family": "ea_kissing_number", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-kissing-d12-n841/tests/run.py b/tasks/optimize-ea-kissing-d12-n841/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ea-kissing-d12-n841/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-d12-n841/tests/test.sh b/tasks/optimize-ea-kissing-d12-n841/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ea-kissing-d12-n841/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