birgermoell commited on
Commit
3299b38
·
verified ·
1 Parent(s): 783202a

Add 108 offline Harbor tasks for zoning-check

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. tasks/zoning-check/zoning-check-capacity-d1-e0000/environment/Dockerfile +3 -0
  2. tasks/zoning-check/zoning-check-capacity-d1-e0000/environment/workdir/plots.csv +4 -0
  3. tasks/zoning-check/zoning-check-capacity-d1-e0000/environment/workdir/zoning_code.json +10 -0
  4. tasks/zoning-check/zoning-check-capacity-d1-e0000/instruction.md +5 -0
  5. tasks/zoning-check/zoning-check-capacity-d1-e0000/solution/oracle.py +33 -0
  6. tasks/zoning-check/zoning-check-capacity-d1-e0000/solution/solve.sh +4 -0
  7. tasks/zoning-check/zoning-check-capacity-d1-e0000/task.toml +25 -0
  8. tasks/zoning-check/zoning-check-capacity-d1-e0000/tests/checks.json +104 -0
  9. tasks/zoning-check/zoning-check-capacity-d1-e0000/tests/test.sh +3 -0
  10. tasks/zoning-check/zoning-check-capacity-d1-e0000/tests/verify.py +116 -0
  11. tasks/zoning-check/zoning-check-capacity-d1-e0012/environment/Dockerfile +3 -0
  12. tasks/zoning-check/zoning-check-capacity-d1-e0012/environment/workdir/plots.csv +4 -0
  13. tasks/zoning-check/zoning-check-capacity-d1-e0012/environment/workdir/zoning_code.json +10 -0
  14. tasks/zoning-check/zoning-check-capacity-d1-e0012/instruction.md +5 -0
  15. tasks/zoning-check/zoning-check-capacity-d1-e0012/solution/oracle.py +33 -0
  16. tasks/zoning-check/zoning-check-capacity-d1-e0012/solution/solve.sh +4 -0
  17. tasks/zoning-check/zoning-check-capacity-d1-e0012/task.toml +25 -0
  18. tasks/zoning-check/zoning-check-capacity-d1-e0012/tests/checks.json +104 -0
  19. tasks/zoning-check/zoning-check-capacity-d1-e0012/tests/test.sh +3 -0
  20. tasks/zoning-check/zoning-check-capacity-d1-e0012/tests/verify.py +116 -0
  21. tasks/zoning-check/zoning-check-capacity-d1-t0000/environment/Dockerfile +3 -0
  22. tasks/zoning-check/zoning-check-capacity-d1-t0000/environment/workdir/plots.csv +4 -0
  23. tasks/zoning-check/zoning-check-capacity-d1-t0000/environment/workdir/zoning_code.json +10 -0
  24. tasks/zoning-check/zoning-check-capacity-d1-t0000/instruction.md +5 -0
  25. tasks/zoning-check/zoning-check-capacity-d1-t0000/solution/oracle.py +33 -0
  26. tasks/zoning-check/zoning-check-capacity-d1-t0000/solution/solve.sh +4 -0
  27. tasks/zoning-check/zoning-check-capacity-d1-t0000/task.toml +25 -0
  28. tasks/zoning-check/zoning-check-capacity-d1-t0000/tests/checks.json +104 -0
  29. tasks/zoning-check/zoning-check-capacity-d1-t0000/tests/test.sh +3 -0
  30. tasks/zoning-check/zoning-check-capacity-d1-t0000/tests/verify.py +116 -0
  31. tasks/zoning-check/zoning-check-capacity-d1-t0012/environment/Dockerfile +3 -0
  32. tasks/zoning-check/zoning-check-capacity-d1-t0012/environment/workdir/plots.csv +4 -0
  33. tasks/zoning-check/zoning-check-capacity-d1-t0012/environment/workdir/zoning_code.json +10 -0
  34. tasks/zoning-check/zoning-check-capacity-d1-t0012/instruction.md +5 -0
  35. tasks/zoning-check/zoning-check-capacity-d1-t0012/solution/oracle.py +33 -0
  36. tasks/zoning-check/zoning-check-capacity-d1-t0012/solution/solve.sh +4 -0
  37. tasks/zoning-check/zoning-check-capacity-d1-t0012/task.toml +25 -0
  38. tasks/zoning-check/zoning-check-capacity-d1-t0012/tests/checks.json +104 -0
  39. tasks/zoning-check/zoning-check-capacity-d1-t0012/tests/test.sh +3 -0
  40. tasks/zoning-check/zoning-check-capacity-d1-t0012/tests/verify.py +116 -0
  41. tasks/zoning-check/zoning-check-capacity-d1-t0024/environment/Dockerfile +3 -0
  42. tasks/zoning-check/zoning-check-capacity-d1-t0024/environment/workdir/plots.csv +4 -0
  43. tasks/zoning-check/zoning-check-capacity-d1-t0024/environment/workdir/zoning_code.json +10 -0
  44. tasks/zoning-check/zoning-check-capacity-d1-t0024/instruction.md +5 -0
  45. tasks/zoning-check/zoning-check-capacity-d1-t0024/solution/oracle.py +33 -0
  46. tasks/zoning-check/zoning-check-capacity-d1-t0024/solution/solve.sh +4 -0
  47. tasks/zoning-check/zoning-check-capacity-d1-t0024/task.toml +25 -0
  48. tasks/zoning-check/zoning-check-capacity-d1-t0024/tests/checks.json +104 -0
  49. tasks/zoning-check/zoning-check-capacity-d1-t0024/tests/test.sh +3 -0
  50. tasks/zoning-check/zoning-check-capacity-d1-t0024/tests/verify.py +116 -0
tasks/zoning-check/zoning-check-capacity-d1-e0000/environment/Dockerfile ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ FROM python:3.12-slim
2
+ WORKDIR /app
3
+ COPY workdir/ /app/
tasks/zoning-check/zoning-check-capacity-d1-e0000/environment/workdir/plots.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ plot_id,width_m,depth_m,storeys
2
+ L01,54,40,4
3
+ L02,30,61,2
4
+ L00,65,35,4
tasks/zoning-check/zoning-check-capacity-d1-e0000/environment/workdir/zoning_code.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_far": 1.2,
3
+ "max_coverage": 0.4,
4
+ "setback_m": 4,
5
+ "height_m": 15,
6
+ "parking_area_m2": 25,
7
+ "parking_per_dwelling": 1.5,
8
+ "shop_m2_per_space": 40,
9
+ "office_m2_per_space": 60
10
+ }
tasks/zoning-check/zoning-check-capacity-d1-e0000/instruction.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Zoning Check: capacity
2
+
3
+ All records are synthetic. Apply only the fictional limits in `zoning_code.json`. Find the largest gross floor area for each rectangular plot with the stated number of storeys. Ignore parking and height in this exercise. Floor area cannot exceed any of: site area times max_far; site area times max_coverage times storeys; or max(0,width-2*setback) times max(0,depth-2*setback) times storeys. The smallest is binding; no ties occur.
4
+
5
+ Write `answer.json` as one JSON object. Round numbers to 2 decimal places without rounding intermediate calculations; numbers are accepted within 0.01. `plots` is keyed by plot id. Each value has `max_floor_m2`, `binding` (`far`, `coverage` or `setbacks`), and the three limits `far_limit_m2`, `coverage_limit_m2`, `setbacks_limit_m2`, all areas in square metres.
tasks/zoning-check/zoning-check-capacity-d1-e0000/solution/oracle.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Independent file-based planning review under the supplied fictional code."""
2
+ import csv,json,math
3
+ from pathlib import Path
4
+
5
+ def read(name):
6
+ with open(name) as f: return list(csv.DictReader(f))
7
+ def solve():
8
+ c=json.loads(Path('zoning_code.json').read_text()); out={}
9
+ if Path('proposals.csv').exists():
10
+ for r in read('proposals.csv'):
11
+ area=float(r['width_m'])*float(r['depth_m']); far=float(r['gross_floor_m2'])/area; cov=float(r['footprint_m2'])/area
12
+ bad=[k for k,fail in [('far',far>c['max_far']),('coverage',cov>c['max_coverage']),('height',float(r['height_m'])>c['height_m']),('setback',any(float(r[k])<c['setback_m'] for k in ['front_m','rear_m','left_m','right_m']))] if fail]
13
+ out[r['proposal_id']]={'site_m2':area,'far':far,'coverage_percent':cov*100,'violations':bad}
14
+ return {'proposals':out}
15
+ if Path('plots.csv').exists():
16
+ for r in read('plots.csv'):
17
+ w,h,s=float(r['width_m']),float(r['depth_m']),int(r['storeys']); limits=[('far',w*h*c['max_far']),('coverage',w*h*c['max_coverage']*s),('setbacks',max(w-2*c['setback_m'],0)*max(h-2*c['setback_m'],0)*s)]
18
+ binding,area=min(limits,key=lambda item:(item[1],item[0])); result={k+'_limit_m2':v for k,v in limits}; result.update(binding=binding,max_floor_m2=area); out[r['plot_id']]=result
19
+ return {'plots':out}
20
+ if Path('boundaries.json').exists():
21
+ boundaries=json.loads(Path('boundaries.json').read_text())
22
+ for r in read('buildings.csv'):
23
+ pts=boundaries[r['plot_id']]; ox,oy=pts[0]; signed=0
24
+ # Triangulate around the first vertex instead of the generator's edge sum.
25
+ for a,b in zip(pts[1:-1],pts[2:]): signed+=(a[0]-ox)*(b[1]-oy)-(b[0]-ox)*(a[1]-oy)
26
+ area=abs(signed)/2; out[r['plot_id']]={'site_m2':area,'far':float(r['floor_m2'])/area,'coverage_percent':100*float(r['footprint_m2'])/area}
27
+ return {'plots':out}
28
+ for r in read('uses.csv'):
29
+ total=int(r['dwellings'])*c['parking_per_dwelling']+float(r['shop_m2'])/c['shop_m2_per_space']+float(r['office_m2'])/c['office_m2_per_space']; n=math.ceil(total)
30
+ out[r['proposal_id']]={'unrounded_spaces':total,'required_spaces':n,'shortfall':max(0,n-int(r['provided_spaces'])),'required_parking_m2':n*c['parking_area_m2']}
31
+ return {'proposals':out}
32
+
33
+ if __name__=='__main__': Path('answer.json').write_text(json.dumps(solve()))
tasks/zoning-check/zoning-check-capacity-d1-e0000/solution/solve.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+ cd /app
4
+ python3 /solution/oracle.py
tasks/zoning-check/zoning-check-capacity-d1-e0000/task.toml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = "1.0"
2
+
3
+ [metadata]
4
+ author_name = "Renaissance Labs"
5
+ author_email = "unknown"
6
+ difficulty = "easy"
7
+ category = "zoning-check"
8
+ tags = ["zoning-check", "capacity", "isced-0731", "eval"]
9
+ isced_f = "0731"
10
+ family = "capacity"
11
+ split = "eval"
12
+ seed = 10000
13
+
14
+ [verifier]
15
+ timeout_sec = 120.0
16
+
17
+ [agent]
18
+ timeout_sec = 900.0
19
+
20
+ [environment]
21
+ build_timeout_sec = 600.0
22
+ cpus = 1
23
+ memory_mb = 1024
24
+ storage_mb = 2048
25
+ allow_internet = false
tasks/zoning-check/zoning-check-capacity-d1-e0000/tests/checks.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "path": "plots.L00.max_floor_m2",
4
+ "type": "number",
5
+ "value": 2730.0,
6
+ "abs_tol": 0.01,
7
+ "weight": 1.0
8
+ },
9
+ {
10
+ "path": "plots.L00.binding",
11
+ "type": "str",
12
+ "value": "far",
13
+ "weight": 1.0
14
+ },
15
+ {
16
+ "path": "plots.L00.far_limit_m2",
17
+ "type": "number",
18
+ "value": 2730.0,
19
+ "abs_tol": 0.01,
20
+ "weight": 1.0
21
+ },
22
+ {
23
+ "path": "plots.L00.coverage_limit_m2",
24
+ "type": "number",
25
+ "value": 3640.0,
26
+ "abs_tol": 0.01,
27
+ "weight": 1.0
28
+ },
29
+ {
30
+ "path": "plots.L00.setbacks_limit_m2",
31
+ "type": "number",
32
+ "value": 6156.0,
33
+ "abs_tol": 0.01,
34
+ "weight": 1.0
35
+ },
36
+ {
37
+ "path": "plots.L01.max_floor_m2",
38
+ "type": "number",
39
+ "value": 2592.0,
40
+ "abs_tol": 0.01,
41
+ "weight": 1.0
42
+ },
43
+ {
44
+ "path": "plots.L01.binding",
45
+ "type": "str",
46
+ "value": "far",
47
+ "weight": 1.0
48
+ },
49
+ {
50
+ "path": "plots.L01.far_limit_m2",
51
+ "type": "number",
52
+ "value": 2592.0,
53
+ "abs_tol": 0.01,
54
+ "weight": 1.0
55
+ },
56
+ {
57
+ "path": "plots.L01.coverage_limit_m2",
58
+ "type": "number",
59
+ "value": 3456.0,
60
+ "abs_tol": 0.01,
61
+ "weight": 1.0
62
+ },
63
+ {
64
+ "path": "plots.L01.setbacks_limit_m2",
65
+ "type": "number",
66
+ "value": 5888.0,
67
+ "abs_tol": 0.01,
68
+ "weight": 1.0
69
+ },
70
+ {
71
+ "path": "plots.L02.max_floor_m2",
72
+ "type": "number",
73
+ "value": 1464.0,
74
+ "abs_tol": 0.01,
75
+ "weight": 1.0
76
+ },
77
+ {
78
+ "path": "plots.L02.binding",
79
+ "type": "str",
80
+ "value": "coverage",
81
+ "weight": 1.0
82
+ },
83
+ {
84
+ "path": "plots.L02.far_limit_m2",
85
+ "type": "number",
86
+ "value": 2196.0,
87
+ "abs_tol": 0.01,
88
+ "weight": 1.0
89
+ },
90
+ {
91
+ "path": "plots.L02.coverage_limit_m2",
92
+ "type": "number",
93
+ "value": 1464.0,
94
+ "abs_tol": 0.01,
95
+ "weight": 1.0
96
+ },
97
+ {
98
+ "path": "plots.L02.setbacks_limit_m2",
99
+ "type": "number",
100
+ "value": 2332.0,
101
+ "abs_tol": 0.01,
102
+ "weight": 1.0
103
+ }
104
+ ]
tasks/zoning-check/zoning-check-capacity-d1-e0000/tests/test.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ mkdir -p /logs/verifier
3
+ python3 /tests/verify.py --answer /app/answer.json --checks /tests/checks.json --out /logs/verifier || echo 0 > /logs/verifier/reward.txt
tasks/zoning-check/zoning-check-capacity-d1-e0000/tests/verify.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Verifier for Renaissance Labs practice environments. Standard library only.
3
+
4
+ Reads the agent's answer (a JSON object) and a list of checks, and writes a reward in [0, 1].
5
+ The reward is the weighted share of checks that pass. A missing, unreadable or non-object
6
+ answer scores 0. Each check addresses one value in the answer by a dotted path.
7
+
8
+ Check types
9
+ int exact integer (a float with integral value is accepted; booleans are not)
10
+ number within abs_tol of value (default 1e-9); booleans and strings are rejected
11
+ str equal after trimming and case-folding
12
+ bool exact boolean
13
+ list ordered list; items compared as int/number/str according to "item" (default str)
14
+ set unordered collection of distinct strings (or ints)
15
+ custom a function in validators.py: name(answer, args) -> bool or float in [0, 1]
16
+ """
17
+ import argparse, json, math, os, sys
18
+
19
+ MISSING = object()
20
+
21
+ def lookup(obj, path):
22
+ cur = obj
23
+ for part in path.split("."):
24
+ if isinstance(cur, dict):
25
+ if part not in cur: return MISSING
26
+ cur = cur[part]
27
+ elif isinstance(cur, list):
28
+ try: cur = cur[int(part)]
29
+ except (ValueError, IndexError): return MISSING
30
+ else:
31
+ return MISSING
32
+ return cur
33
+
34
+ def is_num(x):
35
+ return isinstance(x, (int, float)) and not isinstance(x, bool) and not (isinstance(x, float) and (math.isnan(x) or math.isinf(x)))
36
+
37
+ def eq_int(got, want):
38
+ return is_num(got) and float(got) == float(int(got)) and int(got) == want
39
+
40
+ def eq_num(got, want, tol):
41
+ return is_num(got) and abs(float(got) - float(want)) <= tol + 1e-12
42
+
43
+ def eq_str(got, want):
44
+ return isinstance(got, str) and got.strip().casefold() == str(want).strip().casefold()
45
+
46
+ def eq_item(got, want, kind, tol):
47
+ if kind == "int": return eq_int(got, want)
48
+ if kind == "number": return eq_num(got, want, tol)
49
+ return eq_str(got, want)
50
+
51
+ def run_check(answer, chk, validators):
52
+ t = chk["type"]
53
+ if t == "custom":
54
+ fn = getattr(validators, chk["name"], None) if validators else None
55
+ if fn is None: return 0.0
56
+ try: r = fn(answer, chk.get("args", {}))
57
+ except Exception: return 0.0
58
+ if r is True: return 1.0
59
+ if r is False or r is None: return 0.0
60
+ return max(0.0, min(1.0, float(r))) if is_num(r) else 0.0
61
+ got = lookup(answer, chk["path"])
62
+ if got is MISSING: return 0.0
63
+ want, tol = chk["value"], chk.get("abs_tol", 1e-9)
64
+ if t == "int": ok = eq_int(got, want)
65
+ elif t == "number": ok = eq_num(got, want, tol)
66
+ elif t == "str": ok = eq_str(got, want)
67
+ elif t == "bool": ok = isinstance(got, bool) and got is want
68
+ elif t == "list":
69
+ ok = isinstance(got, list) and len(got) == len(want) and all(eq_item(g, w, chk.get("item", "str"), tol) for g, w in zip(got, want))
70
+ elif t == "set":
71
+ kind = chk.get("item", "str")
72
+ if not isinstance(got, list): ok = False
73
+ else:
74
+ norm = (lambda x: x.strip().casefold() if isinstance(x, str) else None) if kind == "str" else (lambda x: int(x) if eq_int(x, int(x) if is_num(x) else 0) else None)
75
+ g = [norm(x) for x in got]; w = [norm(x) for x in want]
76
+ ok = None not in g and len(g) == len(set(g)) and set(g) == set(w)
77
+ else: ok = False
78
+ return 1.0 if ok else 0.0
79
+
80
+ def grade(answer, checks, validators=None):
81
+ """Return (reward, details). answer is the parsed JSON, or None if it could not be read."""
82
+ if not isinstance(answer, dict):
83
+ return 0.0, [{"check": c.get("path", c.get("name")), "score": 0.0} for c in checks]
84
+ total = sum(c.get("weight", 1.0) for c in checks)
85
+ got, details = 0.0, []
86
+ for c in checks:
87
+ s = run_check(answer, c, validators)
88
+ got += s * c.get("weight", 1.0)
89
+ details.append({"check": c.get("path", c.get("name")), "score": s})
90
+ return (round(got / total, 6) if total else 0.0), details
91
+
92
+ def main():
93
+ ap = argparse.ArgumentParser()
94
+ ap.add_argument("--answer", default="/app/answer.json")
95
+ ap.add_argument("--checks", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "checks.json"))
96
+ ap.add_argument("--out", default="/logs/verifier")
97
+ a = ap.parse_args()
98
+ checks = json.load(open(a.checks))
99
+ try:
100
+ with open(a.answer) as f: answer = json.load(f)
101
+ except Exception:
102
+ answer = None
103
+ validators = None
104
+ here = os.path.dirname(os.path.abspath(__file__))
105
+ if os.path.exists(os.path.join(here, "validators.py")):
106
+ sys.path.insert(0, here)
107
+ import validators # noqa
108
+ reward, details = grade(answer, checks, validators)
109
+ os.makedirs(a.out, exist_ok=True)
110
+ with open(os.path.join(a.out, "reward.txt"), "w") as f: f.write(str(reward))
111
+ with open(os.path.join(a.out, "reward.json"), "w") as f:
112
+ json.dump({"reward": reward, "solved": reward == 1.0, "passed": sum(1 for d in details if d["score"] == 1.0), "checks": len(details)}, f)
113
+ print("reward", reward)
114
+
115
+ if __name__ == "__main__":
116
+ main()
tasks/zoning-check/zoning-check-capacity-d1-e0012/environment/Dockerfile ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ FROM python:3.12-slim
2
+ WORKDIR /app
3
+ COPY workdir/ /app/
tasks/zoning-check/zoning-check-capacity-d1-e0012/environment/workdir/plots.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ plot_id,width_m,depth_m,storeys
2
+ L00,26,33,1
3
+ L02,49,38,1
4
+ L01,27,24,4
tasks/zoning-check/zoning-check-capacity-d1-e0012/environment/workdir/zoning_code.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_far": 1.2,
3
+ "max_coverage": 0.4,
4
+ "setback_m": 4,
5
+ "height_m": 15,
6
+ "parking_area_m2": 25,
7
+ "parking_per_dwelling": 1.5,
8
+ "shop_m2_per_space": 40,
9
+ "office_m2_per_space": 60
10
+ }
tasks/zoning-check/zoning-check-capacity-d1-e0012/instruction.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Zoning Check: capacity
2
+
3
+ All records are synthetic. Apply only the fictional limits in `zoning_code.json`. Find the largest gross floor area for each rectangular plot with the stated number of storeys. Ignore parking and height in this exercise. Floor area cannot exceed any of: site area times max_far; site area times max_coverage times storeys; or max(0,width-2*setback) times max(0,depth-2*setback) times storeys. The smallest is binding; no ties occur.
4
+
5
+ Write `answer.json` as one JSON object. Round numbers to 2 decimal places without rounding intermediate calculations; numbers are accepted within 0.01. `plots` is keyed by plot id. Each value has `max_floor_m2`, `binding` (`far`, `coverage` or `setbacks`), and the three limits `far_limit_m2`, `coverage_limit_m2`, `setbacks_limit_m2`, all areas in square metres.
tasks/zoning-check/zoning-check-capacity-d1-e0012/solution/oracle.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Independent file-based planning review under the supplied fictional code."""
2
+ import csv,json,math
3
+ from pathlib import Path
4
+
5
+ def read(name):
6
+ with open(name) as f: return list(csv.DictReader(f))
7
+ def solve():
8
+ c=json.loads(Path('zoning_code.json').read_text()); out={}
9
+ if Path('proposals.csv').exists():
10
+ for r in read('proposals.csv'):
11
+ area=float(r['width_m'])*float(r['depth_m']); far=float(r['gross_floor_m2'])/area; cov=float(r['footprint_m2'])/area
12
+ bad=[k for k,fail in [('far',far>c['max_far']),('coverage',cov>c['max_coverage']),('height',float(r['height_m'])>c['height_m']),('setback',any(float(r[k])<c['setback_m'] for k in ['front_m','rear_m','left_m','right_m']))] if fail]
13
+ out[r['proposal_id']]={'site_m2':area,'far':far,'coverage_percent':cov*100,'violations':bad}
14
+ return {'proposals':out}
15
+ if Path('plots.csv').exists():
16
+ for r in read('plots.csv'):
17
+ w,h,s=float(r['width_m']),float(r['depth_m']),int(r['storeys']); limits=[('far',w*h*c['max_far']),('coverage',w*h*c['max_coverage']*s),('setbacks',max(w-2*c['setback_m'],0)*max(h-2*c['setback_m'],0)*s)]
18
+ binding,area=min(limits,key=lambda item:(item[1],item[0])); result={k+'_limit_m2':v for k,v in limits}; result.update(binding=binding,max_floor_m2=area); out[r['plot_id']]=result
19
+ return {'plots':out}
20
+ if Path('boundaries.json').exists():
21
+ boundaries=json.loads(Path('boundaries.json').read_text())
22
+ for r in read('buildings.csv'):
23
+ pts=boundaries[r['plot_id']]; ox,oy=pts[0]; signed=0
24
+ # Triangulate around the first vertex instead of the generator's edge sum.
25
+ for a,b in zip(pts[1:-1],pts[2:]): signed+=(a[0]-ox)*(b[1]-oy)-(b[0]-ox)*(a[1]-oy)
26
+ area=abs(signed)/2; out[r['plot_id']]={'site_m2':area,'far':float(r['floor_m2'])/area,'coverage_percent':100*float(r['footprint_m2'])/area}
27
+ return {'plots':out}
28
+ for r in read('uses.csv'):
29
+ total=int(r['dwellings'])*c['parking_per_dwelling']+float(r['shop_m2'])/c['shop_m2_per_space']+float(r['office_m2'])/c['office_m2_per_space']; n=math.ceil(total)
30
+ out[r['proposal_id']]={'unrounded_spaces':total,'required_spaces':n,'shortfall':max(0,n-int(r['provided_spaces'])),'required_parking_m2':n*c['parking_area_m2']}
31
+ return {'proposals':out}
32
+
33
+ if __name__=='__main__': Path('answer.json').write_text(json.dumps(solve()))
tasks/zoning-check/zoning-check-capacity-d1-e0012/solution/solve.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+ cd /app
4
+ python3 /solution/oracle.py
tasks/zoning-check/zoning-check-capacity-d1-e0012/task.toml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = "1.0"
2
+
3
+ [metadata]
4
+ author_name = "Renaissance Labs"
5
+ author_email = "unknown"
6
+ difficulty = "easy"
7
+ category = "zoning-check"
8
+ tags = ["zoning-check", "capacity", "isced-0731", "eval"]
9
+ isced_f = "0731"
10
+ family = "capacity"
11
+ split = "eval"
12
+ seed = 10012
13
+
14
+ [verifier]
15
+ timeout_sec = 120.0
16
+
17
+ [agent]
18
+ timeout_sec = 900.0
19
+
20
+ [environment]
21
+ build_timeout_sec = 600.0
22
+ cpus = 1
23
+ memory_mb = 1024
24
+ storage_mb = 2048
25
+ allow_internet = false
tasks/zoning-check/zoning-check-capacity-d1-e0012/tests/checks.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "path": "plots.L00.max_floor_m2",
4
+ "type": "number",
5
+ "value": 343.2,
6
+ "abs_tol": 0.01,
7
+ "weight": 1.0
8
+ },
9
+ {
10
+ "path": "plots.L00.binding",
11
+ "type": "str",
12
+ "value": "coverage",
13
+ "weight": 1.0
14
+ },
15
+ {
16
+ "path": "plots.L00.far_limit_m2",
17
+ "type": "number",
18
+ "value": 1029.6,
19
+ "abs_tol": 0.01,
20
+ "weight": 1.0
21
+ },
22
+ {
23
+ "path": "plots.L00.coverage_limit_m2",
24
+ "type": "number",
25
+ "value": 343.2,
26
+ "abs_tol": 0.01,
27
+ "weight": 1.0
28
+ },
29
+ {
30
+ "path": "plots.L00.setbacks_limit_m2",
31
+ "type": "number",
32
+ "value": 450.0,
33
+ "abs_tol": 0.01,
34
+ "weight": 1.0
35
+ },
36
+ {
37
+ "path": "plots.L01.max_floor_m2",
38
+ "type": "number",
39
+ "value": 777.6,
40
+ "abs_tol": 0.01,
41
+ "weight": 1.0
42
+ },
43
+ {
44
+ "path": "plots.L01.binding",
45
+ "type": "str",
46
+ "value": "far",
47
+ "weight": 1.0
48
+ },
49
+ {
50
+ "path": "plots.L01.far_limit_m2",
51
+ "type": "number",
52
+ "value": 777.6,
53
+ "abs_tol": 0.01,
54
+ "weight": 1.0
55
+ },
56
+ {
57
+ "path": "plots.L01.coverage_limit_m2",
58
+ "type": "number",
59
+ "value": 1036.8,
60
+ "abs_tol": 0.01,
61
+ "weight": 1.0
62
+ },
63
+ {
64
+ "path": "plots.L01.setbacks_limit_m2",
65
+ "type": "number",
66
+ "value": 1216.0,
67
+ "abs_tol": 0.01,
68
+ "weight": 1.0
69
+ },
70
+ {
71
+ "path": "plots.L02.max_floor_m2",
72
+ "type": "number",
73
+ "value": 744.8,
74
+ "abs_tol": 0.01,
75
+ "weight": 1.0
76
+ },
77
+ {
78
+ "path": "plots.L02.binding",
79
+ "type": "str",
80
+ "value": "coverage",
81
+ "weight": 1.0
82
+ },
83
+ {
84
+ "path": "plots.L02.far_limit_m2",
85
+ "type": "number",
86
+ "value": 2234.4,
87
+ "abs_tol": 0.01,
88
+ "weight": 1.0
89
+ },
90
+ {
91
+ "path": "plots.L02.coverage_limit_m2",
92
+ "type": "number",
93
+ "value": 744.8,
94
+ "abs_tol": 0.01,
95
+ "weight": 1.0
96
+ },
97
+ {
98
+ "path": "plots.L02.setbacks_limit_m2",
99
+ "type": "number",
100
+ "value": 1230.0,
101
+ "abs_tol": 0.01,
102
+ "weight": 1.0
103
+ }
104
+ ]
tasks/zoning-check/zoning-check-capacity-d1-e0012/tests/test.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ mkdir -p /logs/verifier
3
+ python3 /tests/verify.py --answer /app/answer.json --checks /tests/checks.json --out /logs/verifier || echo 0 > /logs/verifier/reward.txt
tasks/zoning-check/zoning-check-capacity-d1-e0012/tests/verify.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Verifier for Renaissance Labs practice environments. Standard library only.
3
+
4
+ Reads the agent's answer (a JSON object) and a list of checks, and writes a reward in [0, 1].
5
+ The reward is the weighted share of checks that pass. A missing, unreadable or non-object
6
+ answer scores 0. Each check addresses one value in the answer by a dotted path.
7
+
8
+ Check types
9
+ int exact integer (a float with integral value is accepted; booleans are not)
10
+ number within abs_tol of value (default 1e-9); booleans and strings are rejected
11
+ str equal after trimming and case-folding
12
+ bool exact boolean
13
+ list ordered list; items compared as int/number/str according to "item" (default str)
14
+ set unordered collection of distinct strings (or ints)
15
+ custom a function in validators.py: name(answer, args) -> bool or float in [0, 1]
16
+ """
17
+ import argparse, json, math, os, sys
18
+
19
+ MISSING = object()
20
+
21
+ def lookup(obj, path):
22
+ cur = obj
23
+ for part in path.split("."):
24
+ if isinstance(cur, dict):
25
+ if part not in cur: return MISSING
26
+ cur = cur[part]
27
+ elif isinstance(cur, list):
28
+ try: cur = cur[int(part)]
29
+ except (ValueError, IndexError): return MISSING
30
+ else:
31
+ return MISSING
32
+ return cur
33
+
34
+ def is_num(x):
35
+ return isinstance(x, (int, float)) and not isinstance(x, bool) and not (isinstance(x, float) and (math.isnan(x) or math.isinf(x)))
36
+
37
+ def eq_int(got, want):
38
+ return is_num(got) and float(got) == float(int(got)) and int(got) == want
39
+
40
+ def eq_num(got, want, tol):
41
+ return is_num(got) and abs(float(got) - float(want)) <= tol + 1e-12
42
+
43
+ def eq_str(got, want):
44
+ return isinstance(got, str) and got.strip().casefold() == str(want).strip().casefold()
45
+
46
+ def eq_item(got, want, kind, tol):
47
+ if kind == "int": return eq_int(got, want)
48
+ if kind == "number": return eq_num(got, want, tol)
49
+ return eq_str(got, want)
50
+
51
+ def run_check(answer, chk, validators):
52
+ t = chk["type"]
53
+ if t == "custom":
54
+ fn = getattr(validators, chk["name"], None) if validators else None
55
+ if fn is None: return 0.0
56
+ try: r = fn(answer, chk.get("args", {}))
57
+ except Exception: return 0.0
58
+ if r is True: return 1.0
59
+ if r is False or r is None: return 0.0
60
+ return max(0.0, min(1.0, float(r))) if is_num(r) else 0.0
61
+ got = lookup(answer, chk["path"])
62
+ if got is MISSING: return 0.0
63
+ want, tol = chk["value"], chk.get("abs_tol", 1e-9)
64
+ if t == "int": ok = eq_int(got, want)
65
+ elif t == "number": ok = eq_num(got, want, tol)
66
+ elif t == "str": ok = eq_str(got, want)
67
+ elif t == "bool": ok = isinstance(got, bool) and got is want
68
+ elif t == "list":
69
+ ok = isinstance(got, list) and len(got) == len(want) and all(eq_item(g, w, chk.get("item", "str"), tol) for g, w in zip(got, want))
70
+ elif t == "set":
71
+ kind = chk.get("item", "str")
72
+ if not isinstance(got, list): ok = False
73
+ else:
74
+ norm = (lambda x: x.strip().casefold() if isinstance(x, str) else None) if kind == "str" else (lambda x: int(x) if eq_int(x, int(x) if is_num(x) else 0) else None)
75
+ g = [norm(x) for x in got]; w = [norm(x) for x in want]
76
+ ok = None not in g and len(g) == len(set(g)) and set(g) == set(w)
77
+ else: ok = False
78
+ return 1.0 if ok else 0.0
79
+
80
+ def grade(answer, checks, validators=None):
81
+ """Return (reward, details). answer is the parsed JSON, or None if it could not be read."""
82
+ if not isinstance(answer, dict):
83
+ return 0.0, [{"check": c.get("path", c.get("name")), "score": 0.0} for c in checks]
84
+ total = sum(c.get("weight", 1.0) for c in checks)
85
+ got, details = 0.0, []
86
+ for c in checks:
87
+ s = run_check(answer, c, validators)
88
+ got += s * c.get("weight", 1.0)
89
+ details.append({"check": c.get("path", c.get("name")), "score": s})
90
+ return (round(got / total, 6) if total else 0.0), details
91
+
92
+ def main():
93
+ ap = argparse.ArgumentParser()
94
+ ap.add_argument("--answer", default="/app/answer.json")
95
+ ap.add_argument("--checks", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "checks.json"))
96
+ ap.add_argument("--out", default="/logs/verifier")
97
+ a = ap.parse_args()
98
+ checks = json.load(open(a.checks))
99
+ try:
100
+ with open(a.answer) as f: answer = json.load(f)
101
+ except Exception:
102
+ answer = None
103
+ validators = None
104
+ here = os.path.dirname(os.path.abspath(__file__))
105
+ if os.path.exists(os.path.join(here, "validators.py")):
106
+ sys.path.insert(0, here)
107
+ import validators # noqa
108
+ reward, details = grade(answer, checks, validators)
109
+ os.makedirs(a.out, exist_ok=True)
110
+ with open(os.path.join(a.out, "reward.txt"), "w") as f: f.write(str(reward))
111
+ with open(os.path.join(a.out, "reward.json"), "w") as f:
112
+ json.dump({"reward": reward, "solved": reward == 1.0, "passed": sum(1 for d in details if d["score"] == 1.0), "checks": len(details)}, f)
113
+ print("reward", reward)
114
+
115
+ if __name__ == "__main__":
116
+ main()
tasks/zoning-check/zoning-check-capacity-d1-t0000/environment/Dockerfile ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ FROM python:3.12-slim
2
+ WORKDIR /app
3
+ COPY workdir/ /app/
tasks/zoning-check/zoning-check-capacity-d1-t0000/environment/workdir/plots.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ plot_id,width_m,depth_m,storeys
2
+ L02,39,37,2
3
+ L00,42,63,4
4
+ L01,19,28,1
tasks/zoning-check/zoning-check-capacity-d1-t0000/environment/workdir/zoning_code.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_far": 1.2,
3
+ "max_coverage": 0.4,
4
+ "setback_m": 4,
5
+ "height_m": 15,
6
+ "parking_area_m2": 25,
7
+ "parking_per_dwelling": 1.5,
8
+ "shop_m2_per_space": 40,
9
+ "office_m2_per_space": 60
10
+ }
tasks/zoning-check/zoning-check-capacity-d1-t0000/instruction.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Zoning Check: capacity
2
+
3
+ All records are synthetic. Apply only the fictional limits in `zoning_code.json`. Find the largest gross floor area for each rectangular plot with the stated number of storeys. Ignore parking and height in this exercise. Floor area cannot exceed any of: site area times max_far; site area times max_coverage times storeys; or max(0,width-2*setback) times max(0,depth-2*setback) times storeys. The smallest is binding; no ties occur.
4
+
5
+ Write `answer.json` as one JSON object. Round numbers to 2 decimal places without rounding intermediate calculations; numbers are accepted within 0.01. `plots` is keyed by plot id. Each value has `max_floor_m2`, `binding` (`far`, `coverage` or `setbacks`), and the three limits `far_limit_m2`, `coverage_limit_m2`, `setbacks_limit_m2`, all areas in square metres.
tasks/zoning-check/zoning-check-capacity-d1-t0000/solution/oracle.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Independent file-based planning review under the supplied fictional code."""
2
+ import csv,json,math
3
+ from pathlib import Path
4
+
5
+ def read(name):
6
+ with open(name) as f: return list(csv.DictReader(f))
7
+ def solve():
8
+ c=json.loads(Path('zoning_code.json').read_text()); out={}
9
+ if Path('proposals.csv').exists():
10
+ for r in read('proposals.csv'):
11
+ area=float(r['width_m'])*float(r['depth_m']); far=float(r['gross_floor_m2'])/area; cov=float(r['footprint_m2'])/area
12
+ bad=[k for k,fail in [('far',far>c['max_far']),('coverage',cov>c['max_coverage']),('height',float(r['height_m'])>c['height_m']),('setback',any(float(r[k])<c['setback_m'] for k in ['front_m','rear_m','left_m','right_m']))] if fail]
13
+ out[r['proposal_id']]={'site_m2':area,'far':far,'coverage_percent':cov*100,'violations':bad}
14
+ return {'proposals':out}
15
+ if Path('plots.csv').exists():
16
+ for r in read('plots.csv'):
17
+ w,h,s=float(r['width_m']),float(r['depth_m']),int(r['storeys']); limits=[('far',w*h*c['max_far']),('coverage',w*h*c['max_coverage']*s),('setbacks',max(w-2*c['setback_m'],0)*max(h-2*c['setback_m'],0)*s)]
18
+ binding,area=min(limits,key=lambda item:(item[1],item[0])); result={k+'_limit_m2':v for k,v in limits}; result.update(binding=binding,max_floor_m2=area); out[r['plot_id']]=result
19
+ return {'plots':out}
20
+ if Path('boundaries.json').exists():
21
+ boundaries=json.loads(Path('boundaries.json').read_text())
22
+ for r in read('buildings.csv'):
23
+ pts=boundaries[r['plot_id']]; ox,oy=pts[0]; signed=0
24
+ # Triangulate around the first vertex instead of the generator's edge sum.
25
+ for a,b in zip(pts[1:-1],pts[2:]): signed+=(a[0]-ox)*(b[1]-oy)-(b[0]-ox)*(a[1]-oy)
26
+ area=abs(signed)/2; out[r['plot_id']]={'site_m2':area,'far':float(r['floor_m2'])/area,'coverage_percent':100*float(r['footprint_m2'])/area}
27
+ return {'plots':out}
28
+ for r in read('uses.csv'):
29
+ total=int(r['dwellings'])*c['parking_per_dwelling']+float(r['shop_m2'])/c['shop_m2_per_space']+float(r['office_m2'])/c['office_m2_per_space']; n=math.ceil(total)
30
+ out[r['proposal_id']]={'unrounded_spaces':total,'required_spaces':n,'shortfall':max(0,n-int(r['provided_spaces'])),'required_parking_m2':n*c['parking_area_m2']}
31
+ return {'proposals':out}
32
+
33
+ if __name__=='__main__': Path('answer.json').write_text(json.dumps(solve()))
tasks/zoning-check/zoning-check-capacity-d1-t0000/solution/solve.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+ cd /app
4
+ python3 /solution/oracle.py
tasks/zoning-check/zoning-check-capacity-d1-t0000/task.toml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = "1.0"
2
+
3
+ [metadata]
4
+ author_name = "Renaissance Labs"
5
+ author_email = "unknown"
6
+ difficulty = "easy"
7
+ category = "zoning-check"
8
+ tags = ["zoning-check", "capacity", "isced-0731", "train"]
9
+ isced_f = "0731"
10
+ family = "capacity"
11
+ split = "train"
12
+ seed = 0
13
+
14
+ [verifier]
15
+ timeout_sec = 120.0
16
+
17
+ [agent]
18
+ timeout_sec = 900.0
19
+
20
+ [environment]
21
+ build_timeout_sec = 600.0
22
+ cpus = 1
23
+ memory_mb = 1024
24
+ storage_mb = 2048
25
+ allow_internet = false
tasks/zoning-check/zoning-check-capacity-d1-t0000/tests/checks.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "path": "plots.L00.max_floor_m2",
4
+ "type": "number",
5
+ "value": 3175.2,
6
+ "abs_tol": 0.01,
7
+ "weight": 1.0
8
+ },
9
+ {
10
+ "path": "plots.L00.binding",
11
+ "type": "str",
12
+ "value": "far",
13
+ "weight": 1.0
14
+ },
15
+ {
16
+ "path": "plots.L00.far_limit_m2",
17
+ "type": "number",
18
+ "value": 3175.2,
19
+ "abs_tol": 0.01,
20
+ "weight": 1.0
21
+ },
22
+ {
23
+ "path": "plots.L00.coverage_limit_m2",
24
+ "type": "number",
25
+ "value": 4233.6,
26
+ "abs_tol": 0.01,
27
+ "weight": 1.0
28
+ },
29
+ {
30
+ "path": "plots.L00.setbacks_limit_m2",
31
+ "type": "number",
32
+ "value": 7480.0,
33
+ "abs_tol": 0.01,
34
+ "weight": 1.0
35
+ },
36
+ {
37
+ "path": "plots.L01.max_floor_m2",
38
+ "type": "number",
39
+ "value": 212.8,
40
+ "abs_tol": 0.01,
41
+ "weight": 1.0
42
+ },
43
+ {
44
+ "path": "plots.L01.binding",
45
+ "type": "str",
46
+ "value": "coverage",
47
+ "weight": 1.0
48
+ },
49
+ {
50
+ "path": "plots.L01.far_limit_m2",
51
+ "type": "number",
52
+ "value": 638.4,
53
+ "abs_tol": 0.01,
54
+ "weight": 1.0
55
+ },
56
+ {
57
+ "path": "plots.L01.coverage_limit_m2",
58
+ "type": "number",
59
+ "value": 212.8,
60
+ "abs_tol": 0.01,
61
+ "weight": 1.0
62
+ },
63
+ {
64
+ "path": "plots.L01.setbacks_limit_m2",
65
+ "type": "number",
66
+ "value": 220.0,
67
+ "abs_tol": 0.01,
68
+ "weight": 1.0
69
+ },
70
+ {
71
+ "path": "plots.L02.max_floor_m2",
72
+ "type": "number",
73
+ "value": 1154.4,
74
+ "abs_tol": 0.01,
75
+ "weight": 1.0
76
+ },
77
+ {
78
+ "path": "plots.L02.binding",
79
+ "type": "str",
80
+ "value": "coverage",
81
+ "weight": 1.0
82
+ },
83
+ {
84
+ "path": "plots.L02.far_limit_m2",
85
+ "type": "number",
86
+ "value": 1731.6,
87
+ "abs_tol": 0.01,
88
+ "weight": 1.0
89
+ },
90
+ {
91
+ "path": "plots.L02.coverage_limit_m2",
92
+ "type": "number",
93
+ "value": 1154.4,
94
+ "abs_tol": 0.01,
95
+ "weight": 1.0
96
+ },
97
+ {
98
+ "path": "plots.L02.setbacks_limit_m2",
99
+ "type": "number",
100
+ "value": 1798.0,
101
+ "abs_tol": 0.01,
102
+ "weight": 1.0
103
+ }
104
+ ]
tasks/zoning-check/zoning-check-capacity-d1-t0000/tests/test.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ mkdir -p /logs/verifier
3
+ python3 /tests/verify.py --answer /app/answer.json --checks /tests/checks.json --out /logs/verifier || echo 0 > /logs/verifier/reward.txt
tasks/zoning-check/zoning-check-capacity-d1-t0000/tests/verify.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Verifier for Renaissance Labs practice environments. Standard library only.
3
+
4
+ Reads the agent's answer (a JSON object) and a list of checks, and writes a reward in [0, 1].
5
+ The reward is the weighted share of checks that pass. A missing, unreadable or non-object
6
+ answer scores 0. Each check addresses one value in the answer by a dotted path.
7
+
8
+ Check types
9
+ int exact integer (a float with integral value is accepted; booleans are not)
10
+ number within abs_tol of value (default 1e-9); booleans and strings are rejected
11
+ str equal after trimming and case-folding
12
+ bool exact boolean
13
+ list ordered list; items compared as int/number/str according to "item" (default str)
14
+ set unordered collection of distinct strings (or ints)
15
+ custom a function in validators.py: name(answer, args) -> bool or float in [0, 1]
16
+ """
17
+ import argparse, json, math, os, sys
18
+
19
+ MISSING = object()
20
+
21
+ def lookup(obj, path):
22
+ cur = obj
23
+ for part in path.split("."):
24
+ if isinstance(cur, dict):
25
+ if part not in cur: return MISSING
26
+ cur = cur[part]
27
+ elif isinstance(cur, list):
28
+ try: cur = cur[int(part)]
29
+ except (ValueError, IndexError): return MISSING
30
+ else:
31
+ return MISSING
32
+ return cur
33
+
34
+ def is_num(x):
35
+ return isinstance(x, (int, float)) and not isinstance(x, bool) and not (isinstance(x, float) and (math.isnan(x) or math.isinf(x)))
36
+
37
+ def eq_int(got, want):
38
+ return is_num(got) and float(got) == float(int(got)) and int(got) == want
39
+
40
+ def eq_num(got, want, tol):
41
+ return is_num(got) and abs(float(got) - float(want)) <= tol + 1e-12
42
+
43
+ def eq_str(got, want):
44
+ return isinstance(got, str) and got.strip().casefold() == str(want).strip().casefold()
45
+
46
+ def eq_item(got, want, kind, tol):
47
+ if kind == "int": return eq_int(got, want)
48
+ if kind == "number": return eq_num(got, want, tol)
49
+ return eq_str(got, want)
50
+
51
+ def run_check(answer, chk, validators):
52
+ t = chk["type"]
53
+ if t == "custom":
54
+ fn = getattr(validators, chk["name"], None) if validators else None
55
+ if fn is None: return 0.0
56
+ try: r = fn(answer, chk.get("args", {}))
57
+ except Exception: return 0.0
58
+ if r is True: return 1.0
59
+ if r is False or r is None: return 0.0
60
+ return max(0.0, min(1.0, float(r))) if is_num(r) else 0.0
61
+ got = lookup(answer, chk["path"])
62
+ if got is MISSING: return 0.0
63
+ want, tol = chk["value"], chk.get("abs_tol", 1e-9)
64
+ if t == "int": ok = eq_int(got, want)
65
+ elif t == "number": ok = eq_num(got, want, tol)
66
+ elif t == "str": ok = eq_str(got, want)
67
+ elif t == "bool": ok = isinstance(got, bool) and got is want
68
+ elif t == "list":
69
+ ok = isinstance(got, list) and len(got) == len(want) and all(eq_item(g, w, chk.get("item", "str"), tol) for g, w in zip(got, want))
70
+ elif t == "set":
71
+ kind = chk.get("item", "str")
72
+ if not isinstance(got, list): ok = False
73
+ else:
74
+ norm = (lambda x: x.strip().casefold() if isinstance(x, str) else None) if kind == "str" else (lambda x: int(x) if eq_int(x, int(x) if is_num(x) else 0) else None)
75
+ g = [norm(x) for x in got]; w = [norm(x) for x in want]
76
+ ok = None not in g and len(g) == len(set(g)) and set(g) == set(w)
77
+ else: ok = False
78
+ return 1.0 if ok else 0.0
79
+
80
+ def grade(answer, checks, validators=None):
81
+ """Return (reward, details). answer is the parsed JSON, or None if it could not be read."""
82
+ if not isinstance(answer, dict):
83
+ return 0.0, [{"check": c.get("path", c.get("name")), "score": 0.0} for c in checks]
84
+ total = sum(c.get("weight", 1.0) for c in checks)
85
+ got, details = 0.0, []
86
+ for c in checks:
87
+ s = run_check(answer, c, validators)
88
+ got += s * c.get("weight", 1.0)
89
+ details.append({"check": c.get("path", c.get("name")), "score": s})
90
+ return (round(got / total, 6) if total else 0.0), details
91
+
92
+ def main():
93
+ ap = argparse.ArgumentParser()
94
+ ap.add_argument("--answer", default="/app/answer.json")
95
+ ap.add_argument("--checks", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "checks.json"))
96
+ ap.add_argument("--out", default="/logs/verifier")
97
+ a = ap.parse_args()
98
+ checks = json.load(open(a.checks))
99
+ try:
100
+ with open(a.answer) as f: answer = json.load(f)
101
+ except Exception:
102
+ answer = None
103
+ validators = None
104
+ here = os.path.dirname(os.path.abspath(__file__))
105
+ if os.path.exists(os.path.join(here, "validators.py")):
106
+ sys.path.insert(0, here)
107
+ import validators # noqa
108
+ reward, details = grade(answer, checks, validators)
109
+ os.makedirs(a.out, exist_ok=True)
110
+ with open(os.path.join(a.out, "reward.txt"), "w") as f: f.write(str(reward))
111
+ with open(os.path.join(a.out, "reward.json"), "w") as f:
112
+ json.dump({"reward": reward, "solved": reward == 1.0, "passed": sum(1 for d in details if d["score"] == 1.0), "checks": len(details)}, f)
113
+ print("reward", reward)
114
+
115
+ if __name__ == "__main__":
116
+ main()
tasks/zoning-check/zoning-check-capacity-d1-t0012/environment/Dockerfile ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ FROM python:3.12-slim
2
+ WORKDIR /app
3
+ COPY workdir/ /app/
tasks/zoning-check/zoning-check-capacity-d1-t0012/environment/workdir/plots.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ plot_id,width_m,depth_m,storeys
2
+ L00,19,70,4
3
+ L01,28,17,4
4
+ L02,36,74,2
tasks/zoning-check/zoning-check-capacity-d1-t0012/environment/workdir/zoning_code.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_far": 1.2,
3
+ "max_coverage": 0.4,
4
+ "setback_m": 4,
5
+ "height_m": 15,
6
+ "parking_area_m2": 25,
7
+ "parking_per_dwelling": 1.5,
8
+ "shop_m2_per_space": 40,
9
+ "office_m2_per_space": 60
10
+ }
tasks/zoning-check/zoning-check-capacity-d1-t0012/instruction.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Zoning Check: capacity
2
+
3
+ All records are synthetic. Apply only the fictional limits in `zoning_code.json`. Find the largest gross floor area for each rectangular plot with the stated number of storeys. Ignore parking and height in this exercise. Floor area cannot exceed any of: site area times max_far; site area times max_coverage times storeys; or max(0,width-2*setback) times max(0,depth-2*setback) times storeys. The smallest is binding; no ties occur.
4
+
5
+ Write `answer.json` as one JSON object. Round numbers to 2 decimal places without rounding intermediate calculations; numbers are accepted within 0.01. `plots` is keyed by plot id. Each value has `max_floor_m2`, `binding` (`far`, `coverage` or `setbacks`), and the three limits `far_limit_m2`, `coverage_limit_m2`, `setbacks_limit_m2`, all areas in square metres.
tasks/zoning-check/zoning-check-capacity-d1-t0012/solution/oracle.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Independent file-based planning review under the supplied fictional code."""
2
+ import csv,json,math
3
+ from pathlib import Path
4
+
5
+ def read(name):
6
+ with open(name) as f: return list(csv.DictReader(f))
7
+ def solve():
8
+ c=json.loads(Path('zoning_code.json').read_text()); out={}
9
+ if Path('proposals.csv').exists():
10
+ for r in read('proposals.csv'):
11
+ area=float(r['width_m'])*float(r['depth_m']); far=float(r['gross_floor_m2'])/area; cov=float(r['footprint_m2'])/area
12
+ bad=[k for k,fail in [('far',far>c['max_far']),('coverage',cov>c['max_coverage']),('height',float(r['height_m'])>c['height_m']),('setback',any(float(r[k])<c['setback_m'] for k in ['front_m','rear_m','left_m','right_m']))] if fail]
13
+ out[r['proposal_id']]={'site_m2':area,'far':far,'coverage_percent':cov*100,'violations':bad}
14
+ return {'proposals':out}
15
+ if Path('plots.csv').exists():
16
+ for r in read('plots.csv'):
17
+ w,h,s=float(r['width_m']),float(r['depth_m']),int(r['storeys']); limits=[('far',w*h*c['max_far']),('coverage',w*h*c['max_coverage']*s),('setbacks',max(w-2*c['setback_m'],0)*max(h-2*c['setback_m'],0)*s)]
18
+ binding,area=min(limits,key=lambda item:(item[1],item[0])); result={k+'_limit_m2':v for k,v in limits}; result.update(binding=binding,max_floor_m2=area); out[r['plot_id']]=result
19
+ return {'plots':out}
20
+ if Path('boundaries.json').exists():
21
+ boundaries=json.loads(Path('boundaries.json').read_text())
22
+ for r in read('buildings.csv'):
23
+ pts=boundaries[r['plot_id']]; ox,oy=pts[0]; signed=0
24
+ # Triangulate around the first vertex instead of the generator's edge sum.
25
+ for a,b in zip(pts[1:-1],pts[2:]): signed+=(a[0]-ox)*(b[1]-oy)-(b[0]-ox)*(a[1]-oy)
26
+ area=abs(signed)/2; out[r['plot_id']]={'site_m2':area,'far':float(r['floor_m2'])/area,'coverage_percent':100*float(r['footprint_m2'])/area}
27
+ return {'plots':out}
28
+ for r in read('uses.csv'):
29
+ total=int(r['dwellings'])*c['parking_per_dwelling']+float(r['shop_m2'])/c['shop_m2_per_space']+float(r['office_m2'])/c['office_m2_per_space']; n=math.ceil(total)
30
+ out[r['proposal_id']]={'unrounded_spaces':total,'required_spaces':n,'shortfall':max(0,n-int(r['provided_spaces'])),'required_parking_m2':n*c['parking_area_m2']}
31
+ return {'proposals':out}
32
+
33
+ if __name__=='__main__': Path('answer.json').write_text(json.dumps(solve()))
tasks/zoning-check/zoning-check-capacity-d1-t0012/solution/solve.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+ cd /app
4
+ python3 /solution/oracle.py
tasks/zoning-check/zoning-check-capacity-d1-t0012/task.toml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = "1.0"
2
+
3
+ [metadata]
4
+ author_name = "Renaissance Labs"
5
+ author_email = "unknown"
6
+ difficulty = "easy"
7
+ category = "zoning-check"
8
+ tags = ["zoning-check", "capacity", "isced-0731", "train"]
9
+ isced_f = "0731"
10
+ family = "capacity"
11
+ split = "train"
12
+ seed = 12
13
+
14
+ [verifier]
15
+ timeout_sec = 120.0
16
+
17
+ [agent]
18
+ timeout_sec = 900.0
19
+
20
+ [environment]
21
+ build_timeout_sec = 600.0
22
+ cpus = 1
23
+ memory_mb = 1024
24
+ storage_mb = 2048
25
+ allow_internet = false
tasks/zoning-check/zoning-check-capacity-d1-t0012/tests/checks.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "path": "plots.L00.max_floor_m2",
4
+ "type": "number",
5
+ "value": 1596.0,
6
+ "abs_tol": 0.01,
7
+ "weight": 1.0
8
+ },
9
+ {
10
+ "path": "plots.L00.binding",
11
+ "type": "str",
12
+ "value": "far",
13
+ "weight": 1.0
14
+ },
15
+ {
16
+ "path": "plots.L00.far_limit_m2",
17
+ "type": "number",
18
+ "value": 1596.0,
19
+ "abs_tol": 0.01,
20
+ "weight": 1.0
21
+ },
22
+ {
23
+ "path": "plots.L00.coverage_limit_m2",
24
+ "type": "number",
25
+ "value": 2128.0,
26
+ "abs_tol": 0.01,
27
+ "weight": 1.0
28
+ },
29
+ {
30
+ "path": "plots.L00.setbacks_limit_m2",
31
+ "type": "number",
32
+ "value": 2728.0,
33
+ "abs_tol": 0.01,
34
+ "weight": 1.0
35
+ },
36
+ {
37
+ "path": "plots.L01.max_floor_m2",
38
+ "type": "number",
39
+ "value": 571.2,
40
+ "abs_tol": 0.01,
41
+ "weight": 1.0
42
+ },
43
+ {
44
+ "path": "plots.L01.binding",
45
+ "type": "str",
46
+ "value": "far",
47
+ "weight": 1.0
48
+ },
49
+ {
50
+ "path": "plots.L01.far_limit_m2",
51
+ "type": "number",
52
+ "value": 571.2,
53
+ "abs_tol": 0.01,
54
+ "weight": 1.0
55
+ },
56
+ {
57
+ "path": "plots.L01.coverage_limit_m2",
58
+ "type": "number",
59
+ "value": 761.6,
60
+ "abs_tol": 0.01,
61
+ "weight": 1.0
62
+ },
63
+ {
64
+ "path": "plots.L01.setbacks_limit_m2",
65
+ "type": "number",
66
+ "value": 720.0,
67
+ "abs_tol": 0.01,
68
+ "weight": 1.0
69
+ },
70
+ {
71
+ "path": "plots.L02.max_floor_m2",
72
+ "type": "number",
73
+ "value": 2131.2,
74
+ "abs_tol": 0.01,
75
+ "weight": 1.0
76
+ },
77
+ {
78
+ "path": "plots.L02.binding",
79
+ "type": "str",
80
+ "value": "coverage",
81
+ "weight": 1.0
82
+ },
83
+ {
84
+ "path": "plots.L02.far_limit_m2",
85
+ "type": "number",
86
+ "value": 3196.8,
87
+ "abs_tol": 0.01,
88
+ "weight": 1.0
89
+ },
90
+ {
91
+ "path": "plots.L02.coverage_limit_m2",
92
+ "type": "number",
93
+ "value": 2131.2,
94
+ "abs_tol": 0.01,
95
+ "weight": 1.0
96
+ },
97
+ {
98
+ "path": "plots.L02.setbacks_limit_m2",
99
+ "type": "number",
100
+ "value": 3696.0,
101
+ "abs_tol": 0.01,
102
+ "weight": 1.0
103
+ }
104
+ ]
tasks/zoning-check/zoning-check-capacity-d1-t0012/tests/test.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ mkdir -p /logs/verifier
3
+ python3 /tests/verify.py --answer /app/answer.json --checks /tests/checks.json --out /logs/verifier || echo 0 > /logs/verifier/reward.txt
tasks/zoning-check/zoning-check-capacity-d1-t0012/tests/verify.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Verifier for Renaissance Labs practice environments. Standard library only.
3
+
4
+ Reads the agent's answer (a JSON object) and a list of checks, and writes a reward in [0, 1].
5
+ The reward is the weighted share of checks that pass. A missing, unreadable or non-object
6
+ answer scores 0. Each check addresses one value in the answer by a dotted path.
7
+
8
+ Check types
9
+ int exact integer (a float with integral value is accepted; booleans are not)
10
+ number within abs_tol of value (default 1e-9); booleans and strings are rejected
11
+ str equal after trimming and case-folding
12
+ bool exact boolean
13
+ list ordered list; items compared as int/number/str according to "item" (default str)
14
+ set unordered collection of distinct strings (or ints)
15
+ custom a function in validators.py: name(answer, args) -> bool or float in [0, 1]
16
+ """
17
+ import argparse, json, math, os, sys
18
+
19
+ MISSING = object()
20
+
21
+ def lookup(obj, path):
22
+ cur = obj
23
+ for part in path.split("."):
24
+ if isinstance(cur, dict):
25
+ if part not in cur: return MISSING
26
+ cur = cur[part]
27
+ elif isinstance(cur, list):
28
+ try: cur = cur[int(part)]
29
+ except (ValueError, IndexError): return MISSING
30
+ else:
31
+ return MISSING
32
+ return cur
33
+
34
+ def is_num(x):
35
+ return isinstance(x, (int, float)) and not isinstance(x, bool) and not (isinstance(x, float) and (math.isnan(x) or math.isinf(x)))
36
+
37
+ def eq_int(got, want):
38
+ return is_num(got) and float(got) == float(int(got)) and int(got) == want
39
+
40
+ def eq_num(got, want, tol):
41
+ return is_num(got) and abs(float(got) - float(want)) <= tol + 1e-12
42
+
43
+ def eq_str(got, want):
44
+ return isinstance(got, str) and got.strip().casefold() == str(want).strip().casefold()
45
+
46
+ def eq_item(got, want, kind, tol):
47
+ if kind == "int": return eq_int(got, want)
48
+ if kind == "number": return eq_num(got, want, tol)
49
+ return eq_str(got, want)
50
+
51
+ def run_check(answer, chk, validators):
52
+ t = chk["type"]
53
+ if t == "custom":
54
+ fn = getattr(validators, chk["name"], None) if validators else None
55
+ if fn is None: return 0.0
56
+ try: r = fn(answer, chk.get("args", {}))
57
+ except Exception: return 0.0
58
+ if r is True: return 1.0
59
+ if r is False or r is None: return 0.0
60
+ return max(0.0, min(1.0, float(r))) if is_num(r) else 0.0
61
+ got = lookup(answer, chk["path"])
62
+ if got is MISSING: return 0.0
63
+ want, tol = chk["value"], chk.get("abs_tol", 1e-9)
64
+ if t == "int": ok = eq_int(got, want)
65
+ elif t == "number": ok = eq_num(got, want, tol)
66
+ elif t == "str": ok = eq_str(got, want)
67
+ elif t == "bool": ok = isinstance(got, bool) and got is want
68
+ elif t == "list":
69
+ ok = isinstance(got, list) and len(got) == len(want) and all(eq_item(g, w, chk.get("item", "str"), tol) for g, w in zip(got, want))
70
+ elif t == "set":
71
+ kind = chk.get("item", "str")
72
+ if not isinstance(got, list): ok = False
73
+ else:
74
+ norm = (lambda x: x.strip().casefold() if isinstance(x, str) else None) if kind == "str" else (lambda x: int(x) if eq_int(x, int(x) if is_num(x) else 0) else None)
75
+ g = [norm(x) for x in got]; w = [norm(x) for x in want]
76
+ ok = None not in g and len(g) == len(set(g)) and set(g) == set(w)
77
+ else: ok = False
78
+ return 1.0 if ok else 0.0
79
+
80
+ def grade(answer, checks, validators=None):
81
+ """Return (reward, details). answer is the parsed JSON, or None if it could not be read."""
82
+ if not isinstance(answer, dict):
83
+ return 0.0, [{"check": c.get("path", c.get("name")), "score": 0.0} for c in checks]
84
+ total = sum(c.get("weight", 1.0) for c in checks)
85
+ got, details = 0.0, []
86
+ for c in checks:
87
+ s = run_check(answer, c, validators)
88
+ got += s * c.get("weight", 1.0)
89
+ details.append({"check": c.get("path", c.get("name")), "score": s})
90
+ return (round(got / total, 6) if total else 0.0), details
91
+
92
+ def main():
93
+ ap = argparse.ArgumentParser()
94
+ ap.add_argument("--answer", default="/app/answer.json")
95
+ ap.add_argument("--checks", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "checks.json"))
96
+ ap.add_argument("--out", default="/logs/verifier")
97
+ a = ap.parse_args()
98
+ checks = json.load(open(a.checks))
99
+ try:
100
+ with open(a.answer) as f: answer = json.load(f)
101
+ except Exception:
102
+ answer = None
103
+ validators = None
104
+ here = os.path.dirname(os.path.abspath(__file__))
105
+ if os.path.exists(os.path.join(here, "validators.py")):
106
+ sys.path.insert(0, here)
107
+ import validators # noqa
108
+ reward, details = grade(answer, checks, validators)
109
+ os.makedirs(a.out, exist_ok=True)
110
+ with open(os.path.join(a.out, "reward.txt"), "w") as f: f.write(str(reward))
111
+ with open(os.path.join(a.out, "reward.json"), "w") as f:
112
+ json.dump({"reward": reward, "solved": reward == 1.0, "passed": sum(1 for d in details if d["score"] == 1.0), "checks": len(details)}, f)
113
+ print("reward", reward)
114
+
115
+ if __name__ == "__main__":
116
+ main()
tasks/zoning-check/zoning-check-capacity-d1-t0024/environment/Dockerfile ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ FROM python:3.12-slim
2
+ WORKDIR /app
3
+ COPY workdir/ /app/
tasks/zoning-check/zoning-check-capacity-d1-t0024/environment/workdir/plots.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ plot_id,width_m,depth_m,storeys
2
+ L02,55,68,2
3
+ L00,61,67,2
4
+ L01,30,23,2
tasks/zoning-check/zoning-check-capacity-d1-t0024/environment/workdir/zoning_code.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_far": 1.2,
3
+ "max_coverage": 0.4,
4
+ "setback_m": 4,
5
+ "height_m": 15,
6
+ "parking_area_m2": 25,
7
+ "parking_per_dwelling": 1.5,
8
+ "shop_m2_per_space": 40,
9
+ "office_m2_per_space": 60
10
+ }
tasks/zoning-check/zoning-check-capacity-d1-t0024/instruction.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Zoning Check: capacity
2
+
3
+ All records are synthetic. Apply only the fictional limits in `zoning_code.json`. Find the largest gross floor area for each rectangular plot with the stated number of storeys. Ignore parking and height in this exercise. Floor area cannot exceed any of: site area times max_far; site area times max_coverage times storeys; or max(0,width-2*setback) times max(0,depth-2*setback) times storeys. The smallest is binding; no ties occur.
4
+
5
+ Write `answer.json` as one JSON object. Round numbers to 2 decimal places without rounding intermediate calculations; numbers are accepted within 0.01. `plots` is keyed by plot id. Each value has `max_floor_m2`, `binding` (`far`, `coverage` or `setbacks`), and the three limits `far_limit_m2`, `coverage_limit_m2`, `setbacks_limit_m2`, all areas in square metres.
tasks/zoning-check/zoning-check-capacity-d1-t0024/solution/oracle.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Independent file-based planning review under the supplied fictional code."""
2
+ import csv,json,math
3
+ from pathlib import Path
4
+
5
+ def read(name):
6
+ with open(name) as f: return list(csv.DictReader(f))
7
+ def solve():
8
+ c=json.loads(Path('zoning_code.json').read_text()); out={}
9
+ if Path('proposals.csv').exists():
10
+ for r in read('proposals.csv'):
11
+ area=float(r['width_m'])*float(r['depth_m']); far=float(r['gross_floor_m2'])/area; cov=float(r['footprint_m2'])/area
12
+ bad=[k for k,fail in [('far',far>c['max_far']),('coverage',cov>c['max_coverage']),('height',float(r['height_m'])>c['height_m']),('setback',any(float(r[k])<c['setback_m'] for k in ['front_m','rear_m','left_m','right_m']))] if fail]
13
+ out[r['proposal_id']]={'site_m2':area,'far':far,'coverage_percent':cov*100,'violations':bad}
14
+ return {'proposals':out}
15
+ if Path('plots.csv').exists():
16
+ for r in read('plots.csv'):
17
+ w,h,s=float(r['width_m']),float(r['depth_m']),int(r['storeys']); limits=[('far',w*h*c['max_far']),('coverage',w*h*c['max_coverage']*s),('setbacks',max(w-2*c['setback_m'],0)*max(h-2*c['setback_m'],0)*s)]
18
+ binding,area=min(limits,key=lambda item:(item[1],item[0])); result={k+'_limit_m2':v for k,v in limits}; result.update(binding=binding,max_floor_m2=area); out[r['plot_id']]=result
19
+ return {'plots':out}
20
+ if Path('boundaries.json').exists():
21
+ boundaries=json.loads(Path('boundaries.json').read_text())
22
+ for r in read('buildings.csv'):
23
+ pts=boundaries[r['plot_id']]; ox,oy=pts[0]; signed=0
24
+ # Triangulate around the first vertex instead of the generator's edge sum.
25
+ for a,b in zip(pts[1:-1],pts[2:]): signed+=(a[0]-ox)*(b[1]-oy)-(b[0]-ox)*(a[1]-oy)
26
+ area=abs(signed)/2; out[r['plot_id']]={'site_m2':area,'far':float(r['floor_m2'])/area,'coverage_percent':100*float(r['footprint_m2'])/area}
27
+ return {'plots':out}
28
+ for r in read('uses.csv'):
29
+ total=int(r['dwellings'])*c['parking_per_dwelling']+float(r['shop_m2'])/c['shop_m2_per_space']+float(r['office_m2'])/c['office_m2_per_space']; n=math.ceil(total)
30
+ out[r['proposal_id']]={'unrounded_spaces':total,'required_spaces':n,'shortfall':max(0,n-int(r['provided_spaces'])),'required_parking_m2':n*c['parking_area_m2']}
31
+ return {'proposals':out}
32
+
33
+ if __name__=='__main__': Path('answer.json').write_text(json.dumps(solve()))
tasks/zoning-check/zoning-check-capacity-d1-t0024/solution/solve.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+ cd /app
4
+ python3 /solution/oracle.py
tasks/zoning-check/zoning-check-capacity-d1-t0024/task.toml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = "1.0"
2
+
3
+ [metadata]
4
+ author_name = "Renaissance Labs"
5
+ author_email = "unknown"
6
+ difficulty = "easy"
7
+ category = "zoning-check"
8
+ tags = ["zoning-check", "capacity", "isced-0731", "train"]
9
+ isced_f = "0731"
10
+ family = "capacity"
11
+ split = "train"
12
+ seed = 24
13
+
14
+ [verifier]
15
+ timeout_sec = 120.0
16
+
17
+ [agent]
18
+ timeout_sec = 900.0
19
+
20
+ [environment]
21
+ build_timeout_sec = 600.0
22
+ cpus = 1
23
+ memory_mb = 1024
24
+ storage_mb = 2048
25
+ allow_internet = false
tasks/zoning-check/zoning-check-capacity-d1-t0024/tests/checks.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "path": "plots.L00.max_floor_m2",
4
+ "type": "number",
5
+ "value": 3269.6,
6
+ "abs_tol": 0.01,
7
+ "weight": 1.0
8
+ },
9
+ {
10
+ "path": "plots.L00.binding",
11
+ "type": "str",
12
+ "value": "coverage",
13
+ "weight": 1.0
14
+ },
15
+ {
16
+ "path": "plots.L00.far_limit_m2",
17
+ "type": "number",
18
+ "value": 4904.4,
19
+ "abs_tol": 0.01,
20
+ "weight": 1.0
21
+ },
22
+ {
23
+ "path": "plots.L00.coverage_limit_m2",
24
+ "type": "number",
25
+ "value": 3269.6,
26
+ "abs_tol": 0.01,
27
+ "weight": 1.0
28
+ },
29
+ {
30
+ "path": "plots.L00.setbacks_limit_m2",
31
+ "type": "number",
32
+ "value": 6254.0,
33
+ "abs_tol": 0.01,
34
+ "weight": 1.0
35
+ },
36
+ {
37
+ "path": "plots.L01.max_floor_m2",
38
+ "type": "number",
39
+ "value": 552.0,
40
+ "abs_tol": 0.01,
41
+ "weight": 1.0
42
+ },
43
+ {
44
+ "path": "plots.L01.binding",
45
+ "type": "str",
46
+ "value": "coverage",
47
+ "weight": 1.0
48
+ },
49
+ {
50
+ "path": "plots.L01.far_limit_m2",
51
+ "type": "number",
52
+ "value": 828.0,
53
+ "abs_tol": 0.01,
54
+ "weight": 1.0
55
+ },
56
+ {
57
+ "path": "plots.L01.coverage_limit_m2",
58
+ "type": "number",
59
+ "value": 552.0,
60
+ "abs_tol": 0.01,
61
+ "weight": 1.0
62
+ },
63
+ {
64
+ "path": "plots.L01.setbacks_limit_m2",
65
+ "type": "number",
66
+ "value": 660.0,
67
+ "abs_tol": 0.01,
68
+ "weight": 1.0
69
+ },
70
+ {
71
+ "path": "plots.L02.max_floor_m2",
72
+ "type": "number",
73
+ "value": 2992.0,
74
+ "abs_tol": 0.01,
75
+ "weight": 1.0
76
+ },
77
+ {
78
+ "path": "plots.L02.binding",
79
+ "type": "str",
80
+ "value": "coverage",
81
+ "weight": 1.0
82
+ },
83
+ {
84
+ "path": "plots.L02.far_limit_m2",
85
+ "type": "number",
86
+ "value": 4488.0,
87
+ "abs_tol": 0.01,
88
+ "weight": 1.0
89
+ },
90
+ {
91
+ "path": "plots.L02.coverage_limit_m2",
92
+ "type": "number",
93
+ "value": 2992.0,
94
+ "abs_tol": 0.01,
95
+ "weight": 1.0
96
+ },
97
+ {
98
+ "path": "plots.L02.setbacks_limit_m2",
99
+ "type": "number",
100
+ "value": 5640.0,
101
+ "abs_tol": 0.01,
102
+ "weight": 1.0
103
+ }
104
+ ]
tasks/zoning-check/zoning-check-capacity-d1-t0024/tests/test.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ mkdir -p /logs/verifier
3
+ python3 /tests/verify.py --answer /app/answer.json --checks /tests/checks.json --out /logs/verifier || echo 0 > /logs/verifier/reward.txt
tasks/zoning-check/zoning-check-capacity-d1-t0024/tests/verify.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Verifier for Renaissance Labs practice environments. Standard library only.
3
+
4
+ Reads the agent's answer (a JSON object) and a list of checks, and writes a reward in [0, 1].
5
+ The reward is the weighted share of checks that pass. A missing, unreadable or non-object
6
+ answer scores 0. Each check addresses one value in the answer by a dotted path.
7
+
8
+ Check types
9
+ int exact integer (a float with integral value is accepted; booleans are not)
10
+ number within abs_tol of value (default 1e-9); booleans and strings are rejected
11
+ str equal after trimming and case-folding
12
+ bool exact boolean
13
+ list ordered list; items compared as int/number/str according to "item" (default str)
14
+ set unordered collection of distinct strings (or ints)
15
+ custom a function in validators.py: name(answer, args) -> bool or float in [0, 1]
16
+ """
17
+ import argparse, json, math, os, sys
18
+
19
+ MISSING = object()
20
+
21
+ def lookup(obj, path):
22
+ cur = obj
23
+ for part in path.split("."):
24
+ if isinstance(cur, dict):
25
+ if part not in cur: return MISSING
26
+ cur = cur[part]
27
+ elif isinstance(cur, list):
28
+ try: cur = cur[int(part)]
29
+ except (ValueError, IndexError): return MISSING
30
+ else:
31
+ return MISSING
32
+ return cur
33
+
34
+ def is_num(x):
35
+ return isinstance(x, (int, float)) and not isinstance(x, bool) and not (isinstance(x, float) and (math.isnan(x) or math.isinf(x)))
36
+
37
+ def eq_int(got, want):
38
+ return is_num(got) and float(got) == float(int(got)) and int(got) == want
39
+
40
+ def eq_num(got, want, tol):
41
+ return is_num(got) and abs(float(got) - float(want)) <= tol + 1e-12
42
+
43
+ def eq_str(got, want):
44
+ return isinstance(got, str) and got.strip().casefold() == str(want).strip().casefold()
45
+
46
+ def eq_item(got, want, kind, tol):
47
+ if kind == "int": return eq_int(got, want)
48
+ if kind == "number": return eq_num(got, want, tol)
49
+ return eq_str(got, want)
50
+
51
+ def run_check(answer, chk, validators):
52
+ t = chk["type"]
53
+ if t == "custom":
54
+ fn = getattr(validators, chk["name"], None) if validators else None
55
+ if fn is None: return 0.0
56
+ try: r = fn(answer, chk.get("args", {}))
57
+ except Exception: return 0.0
58
+ if r is True: return 1.0
59
+ if r is False or r is None: return 0.0
60
+ return max(0.0, min(1.0, float(r))) if is_num(r) else 0.0
61
+ got = lookup(answer, chk["path"])
62
+ if got is MISSING: return 0.0
63
+ want, tol = chk["value"], chk.get("abs_tol", 1e-9)
64
+ if t == "int": ok = eq_int(got, want)
65
+ elif t == "number": ok = eq_num(got, want, tol)
66
+ elif t == "str": ok = eq_str(got, want)
67
+ elif t == "bool": ok = isinstance(got, bool) and got is want
68
+ elif t == "list":
69
+ ok = isinstance(got, list) and len(got) == len(want) and all(eq_item(g, w, chk.get("item", "str"), tol) for g, w in zip(got, want))
70
+ elif t == "set":
71
+ kind = chk.get("item", "str")
72
+ if not isinstance(got, list): ok = False
73
+ else:
74
+ norm = (lambda x: x.strip().casefold() if isinstance(x, str) else None) if kind == "str" else (lambda x: int(x) if eq_int(x, int(x) if is_num(x) else 0) else None)
75
+ g = [norm(x) for x in got]; w = [norm(x) for x in want]
76
+ ok = None not in g and len(g) == len(set(g)) and set(g) == set(w)
77
+ else: ok = False
78
+ return 1.0 if ok else 0.0
79
+
80
+ def grade(answer, checks, validators=None):
81
+ """Return (reward, details). answer is the parsed JSON, or None if it could not be read."""
82
+ if not isinstance(answer, dict):
83
+ return 0.0, [{"check": c.get("path", c.get("name")), "score": 0.0} for c in checks]
84
+ total = sum(c.get("weight", 1.0) for c in checks)
85
+ got, details = 0.0, []
86
+ for c in checks:
87
+ s = run_check(answer, c, validators)
88
+ got += s * c.get("weight", 1.0)
89
+ details.append({"check": c.get("path", c.get("name")), "score": s})
90
+ return (round(got / total, 6) if total else 0.0), details
91
+
92
+ def main():
93
+ ap = argparse.ArgumentParser()
94
+ ap.add_argument("--answer", default="/app/answer.json")
95
+ ap.add_argument("--checks", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "checks.json"))
96
+ ap.add_argument("--out", default="/logs/verifier")
97
+ a = ap.parse_args()
98
+ checks = json.load(open(a.checks))
99
+ try:
100
+ with open(a.answer) as f: answer = json.load(f)
101
+ except Exception:
102
+ answer = None
103
+ validators = None
104
+ here = os.path.dirname(os.path.abspath(__file__))
105
+ if os.path.exists(os.path.join(here, "validators.py")):
106
+ sys.path.insert(0, here)
107
+ import validators # noqa
108
+ reward, details = grade(answer, checks, validators)
109
+ os.makedirs(a.out, exist_ok=True)
110
+ with open(os.path.join(a.out, "reward.txt"), "w") as f: f.write(str(reward))
111
+ with open(os.path.join(a.out, "reward.json"), "w") as f:
112
+ json.dump({"reward": reward, "solved": reward == 1.0, "passed": sum(1 for d in details if d["score"] == 1.0), "checks": len(details)}, f)
113
+ print("reward", reward)
114
+
115
+ if __name__ == "__main__":
116
+ main()