{
  "method": "Contact-scaled increasing quadratic penalties on exact pair areas and analytic containment with L-BFGS-B inner solves, analytic SLSQP repair, contact-specific polygon allowance estimates, and six-decimal rigid transforms plus optional local integer lattice repair.",
  "seed": 22003,
  "derived_seeds": {
    "generator": "numpy.random.default_rng(22003).integers(0, 2**32, size=8)",
    "values": [
      3042502191,
      52073344,
      2806424140,
      3115124627,
      3960364025,
      3399433720,
      2208747659,
      3838137447
    ]
  },
  "official_valid": true,
  "official_score": "2.94852695",
  "official_score_full": 2.948526950912552,
  "solution": [
    {
      "x": 0.545425,
      "y": 0.67215,
      "theta": -0.570778
    },
    {
      "x": 1.135484,
      "y": -1.23874,
      "theta": 2.227365
    },
    {
      "x": -0.584124,
      "y": -0.217653,
      "theta": -1.671787
    },
    {
      "x": 1.843118,
      "y": 0.631801,
      "theta": -0.722762
    },
    {
      "x": 0.278186,
      "y": 1.928675,
      "theta": 2.264578
    },
    {
      "x": -0.723715,
      "y": 1.809349,
      "theta": 3.126118
    },
    {
      "x": -1.624637,
      "y": 1.076193,
      "theta": -2.992325
    },
    {
      "x": -0.56981,
      "y": 0.785952,
      "theta": -1.682231
    },
    {
      "x": 0.032918,
      "y": 1.724683,
      "theta": -0.877015
    },
    {
      "x": 1.261991,
      "y": 1.484613,
      "theta": 0.453135
    },
    {
      "x": -1.944933,
      "y": -0.121111,
      "theta": -2.464295
    },
    {
      "x": -1.573106,
      "y": -1.149938,
      "theta": -1.641622
    },
    {
      "x": 1.049635,
      "y": -2.567295,
      "theta": 1.95895
    },
    {
      "x": -0.789401,
      "y": -1.781407,
      "theta": -0.792106
    },
    {
      "x": 1.811166,
      "y": -0.718041,
      "theta": -0.914204
    }
  ],
  "solution_json": "[\n  {\n    \"x\": 0.545425,\n    \"y\": 0.67215,\n    \"theta\": -0.570778\n  },\n  {\n    \"x\": 1.135484,\n    \"y\": -1.23874,\n    \"theta\": 2.227365\n  },\n  {\n    \"x\": -0.584124,\n    \"y\": -0.217653,\n    \"theta\": -1.671787\n  },\n  {\n    \"x\": 1.843118,\n    \"y\": 0.631801,\n    \"theta\": -0.722762\n  },\n  {\n    \"x\": 0.278186,\n    \"y\": 1.928675,\n    \"theta\": 2.264578\n  },\n  {\n    \"x\": -0.723715,\n    \"y\": 1.809349,\n    \"theta\": 3.126118\n  },\n  {\n    \"x\": -1.624637,\n    \"y\": 1.076193,\n    \"theta\": -2.992325\n  },\n  {\n    \"x\": -0.56981,\n    \"y\": 0.785952,\n    \"theta\": -1.682231\n  },\n  {\n    \"x\": 0.032918,\n    \"y\": 1.724683,\n    \"theta\": -0.877015\n  },\n  {\n    \"x\": 1.261991,\n    \"y\": 1.484613,\n    \"theta\": 0.453135\n  },\n  {\n    \"x\": -1.944933,\n    \"y\": -0.121111,\n    \"theta\": -2.464295\n  },\n  {\n    \"x\": -1.573106,\n    \"y\": -1.149938,\n    \"theta\": -1.641622\n  },\n  {\n    \"x\": 1.049635,\n    \"y\": -2.567295,\n    \"theta\": 1.95895\n  },\n  {\n    \"x\": -0.789401,\n    \"y\": -1.781407,\n    \"theta\": -0.792106\n  },\n  {\n    \"x\": 1.811166,\n    \"y\": -0.718041,\n    \"theta\": -0.914204\n  }\n]\n",
  "solution_sha256": "cefac3368caae7f9dea0c4cdc0e87d869f3a9bd76ba75292b1cd4b7fff7c8fb9",
  "mec": {
    "cx": -0.0001819080616875258,
    "cy": 0.00013448997007248039,
    "radius": 2.948526950912552
  },
  "max_pair_area": 9.997822348073146e-07,
  "max_pair_area_kind": "Official 4096-point polygon intersection area in square units",
  "max_exact_pair_area": 1.001372691834465e-06,
  "max_official_pair": [
    2,
    13
  ],
  "inherited_baseline": {
    "source": "Requester-supplied rows, also reported in after-published",
    "official_valid": true,
    "official_score": "2.94852695",
    "official_score_full": 2.948526950912552,
    "mec": [
      -0.0001819080616875258,
      0.00013448997007248039,
      2.948526950912552
    ],
    "solution": [
      {
        "x": 0.545425,
        "y": 0.67215,
        "theta": -0.570778
      },
      {
        "x": 1.135484,
        "y": -1.23874,
        "theta": 2.227365
      },
      {
        "x": -0.584124,
        "y": -0.217653,
        "theta": -1.671787
      },
      {
        "x": 1.843118,
        "y": 0.631801,
        "theta": -0.722762
      },
      {
        "x": 0.278186,
        "y": 1.928675,
        "theta": 2.264578
      },
      {
        "x": -0.723715,
        "y": 1.809349,
        "theta": 3.126118
      },
      {
        "x": -1.624637,
        "y": 1.076193,
        "theta": -2.992325
      },
      {
        "x": -0.56981,
        "y": 0.785952,
        "theta": -1.682231
      },
      {
        "x": 0.032918,
        "y": 1.724683,
        "theta": -0.877015
      },
      {
        "x": 1.261991,
        "y": 1.484613,
        "theta": 0.453135
      },
      {
        "x": -1.944933,
        "y": -0.121111,
        "theta": -2.464295
      },
      {
        "x": -1.573106,
        "y": -1.149938,
        "theta": -1.641622
      },
      {
        "x": 1.049635,
        "y": -2.567295,
        "theta": 1.95895
      },
      {
        "x": -0.789401,
        "y": -1.781407,
        "theta": -0.792106
      },
      {
        "x": 1.811166,
        "y": -0.718041,
        "theta": -0.914204
      }
    ],
    "solution_sha256": "cefac3368caae7f9dea0c4cdc0e87d869f3a9bd76ba75292b1cd4b7fff7c8fb9"
  },
  "best_new_score": "2.94852764",
  "best_new_score_full": 2.9485276412344295,
  "best_new_solution": [
    {
      "x": 0.853366,
      "y": 0.145442,
      "theta": -1.290872
    },
    {
      "x": 0.036922,
      "y": -1.680233,
      "theta": 1.507374
    },
    {
      "x": -0.582657,
      "y": 0.221291,
      "theta": -2.391712
    },
    {
      "x": 1.802323,
      "y": -0.740534,
      "theta": -1.44271
    },
    {
      "x": 1.481003,
      "y": 1.26625,
      "theta": 1.544799
    },
    {
      "x": 0.649126,
      "y": 1.837225,
      "theta": 2.406103
    },
    {
      "x": -0.511707,
      "y": 1.880137,
      "theta": 2.570698
    },
    {
      "x": 0.089844,
      "y": 0.966383,
      "theta": -2.402627
    },
    {
      "x": 1.161832,
      "y": 1.27455,
      "theta": -1.596795
    },
    {
      "x": 1.927747,
      "y": 0.283813,
      "theta": -0.266687
    },
    {
      "x": -1.542023,
      "y": 1.191187,
      "theta": 3.098848
    },
    {
      "x": -1.940876,
      "y": 0.172514,
      "theta": -2.361653
    },
    {
      "x": -0.90364,
      "y": -2.62245,
      "theta": 1.23896
    },
    {
      "x": -1.768053,
      "y": -0.818992,
      "theta": -1.512118
    },
    {
      "x": 0.888245,
      "y": -1.734295,
      "theta": -1.634196
    }
  ],
  "best_fresh_score": "3.04517557",
  "best_fresh_score_full": 3.0451755698579865,
  "best_fresh_solution": [
    {
      "x": -1.010975,
      "y": -2.692772,
      "theta": 1.21164
    },
    {
      "x": 2.634387,
      "y": 1.154599,
      "theta": -2.728528
    },
    {
      "x": -0.241387,
      "y": 2.03088,
      "theta": 2.866248
    },
    {
      "x": -0.467512,
      "y": 1.064714,
      "theta": -1.666769
    },
    {
      "x": -0.632041,
      "y": -0.729079,
      "theta": -2.555873
    },
    {
      "x": 0.81454,
      "y": -1.87597,
      "theta": -1.713294
    },
    {
      "x": -2.522117,
      "y": -1.382758,
      "theta": 0.501501
    },
    {
      "x": 1.235731,
      "y": -1.936399,
      "theta": 1.428298
    },
    {
      "x": -2.037776,
      "y": -0.173817,
      "theta": 1.885153
    },
    {
      "x": -0.495429,
      "y": -0.935014,
      "theta": 0.585721
    },
    {
      "x": 1.27646,
      "y": -0.007601,
      "theta": 2.742773
    },
    {
      "x": 0.760315,
      "y": 1.898595,
      "theta": 2.392877
    },
    {
      "x": -2.229822,
      "y": 1.816862,
      "theta": -0.683701
    },
    {
      "x": 0.792075,
      "y": 1.932775,
      "theta": -0.748716
    },
    {
      "x": 2.042406,
      "y": -0.106384,
      "theta": -1.239582
    }
  ],
  "strict_radius": null,
  "structure": {
    "full_disks": 0,
    "sliding_flat_seams": [
      [
        1,
        14
      ],
      [
        4,
        8
      ]
    ],
    "boundary_indices": [
      3,
      4,
      5,
      6,
      9,
      10,
      11,
      12,
      13,
      14
    ],
    "interior_indices": [
      0,
      1,
      2,
      7,
      8
    ],
    "outward_flat_index": 12,
    "arc_contact_count": 9,
    "index_base": 0,
    "flats": "Piece 12 has its curved-side normal pointing toward the enclosing center and both flat-edge endpoints on the boundary to within two microunits. The nine other boundary pieces touch on their arcs and have oblique flat diameters. The nearly opposed seam pairs have distinct disk centers.",
    "symmetry": "Piece 12 is the unique boundary piece with an outward flat, so any symmetry must fix it. This excludes rotations. Reflecting across the line through its disk center and the MEC center leaves unmatched disk centers.",
    "reflection_max_nearest_center_distance": 0.8530385793779125
  },
  "scorer_check": {
    "seed": 3960364025,
    "random_pairs": {
      "cases": 200,
      "disagreements": 0,
      "max_area_difference": 1.6626280718856634e-07,
      "example": null
    },
    "tight_pairs": {
      "cases": 100,
      "disagreements": 2,
      "max_area_difference": 1.813945461567104e-09,
      "example": {
        "rows": [
          [
            -0.740737,
            0.34017,
            2.392192
          ],
          [
            -2.204871,
            1.702514,
            -0.749401
          ]
        ],
        "exact": 1.0012197328278932e-06,
        "official_polygon": 9.994478816230288e-07
      }
    },
    "mec_cases": 38,
    "max_radius_diff": 1.06314956838105e-12,
    "sample_radius": 3.5000000000000004,
    "baseline_radius": 2.9485269509127683,
    "max_analytic_identity_error": 6.661338147750939e-16,
    "pair_gradient_cases": 256,
    "max_pair_gradient_difference": 6.279222697358477e-10,
    "clean_layout_rechecks": {
      "sample": {
        "exact_valid": true,
        "official_valid": true,
        "official_score": 3.5,
        "radius_abs_diff": 4.440892098500626e-16
      },
      "baseline": {
        "exact_valid": false,
        "official_valid": true,
        "official_score": 2.948526950912552,
        "radius_abs_diff": 2.162714451969805e-13
      },
      "selected": {
        "exact_valid": false,
        "official_valid": true,
        "official_score": 2.948526950912552,
        "radius_abs_diff": 2.162714451969805e-13
      },
      "run-3042502191": {
        "exact_valid": false,
        "official_valid": true,
        "official_score": 2.948528251140879,
        "radius_abs_diff": 1.376676550535194e-13
      },
      "run-52073344": {
        "exact_valid": false,
        "official_valid": true,
        "official_score": 3.050455956690072,
        "radius_abs_diff": 1.3322676295501878e-15
      },
      "run-2806424140": {
        "exact_valid": true,
        "official_valid": true,
        "official_score": 3.0451755698579865,
        "radius_abs_diff": 1.3322676295501878e-15
      },
      "run-3115124627": {
        "exact_valid": false,
        "official_valid": true,
        "official_score": 2.9485276412344295,
        "radius_abs_diff": 2.8821389719269064e-13
      },
      "run-3838137447": {
        "exact_valid": false,
        "official_valid": true,
        "official_score": 2.948527775950843,
        "radius_abs_diff": 3.4061642395499803e-13
      }
    }
  },
  "runs": [
    {
      "seed": 3042502191,
      "start_kind": "baseline",
      "minutes": 6.500326508873453,
      "attempts": 4462,
      "valid_count": 1,
      "best_radius": 2.948528251140879,
      "score_kind": "official rounded radius",
      "errors": {
        "SLSQP status false": 1
      },
      "official_calls": 1,
      "repairs": 6
    },
    {
      "seed": 52073344,
      "start_kind": "fresh",
      "minutes": 2.168235573808973,
      "attempts": 10894,
      "valid_count": 14,
      "best_radius": 3.050455956690072,
      "score_kind": "official rounded radius",
      "errors": {},
      "official_calls": 14,
      "repairs": 15
    },
    {
      "seed": 2806424140,
      "start_kind": "fresh",
      "minutes": 2.169246823589007,
      "attempts": 13501,
      "valid_count": 4,
      "best_radius": 3.0451755698579865,
      "score_kind": "official rounded radius",
      "errors": {
        "SLSQP status false": 1
      },
      "official_calls": 4,
      "repairs": 19
    },
    {
      "seed": 3115124627,
      "start_kind": "baseline",
      "minutes": 7.005051992290343,
      "attempts": 531,
      "valid_count": 7,
      "best_radius": 2.9485276412344295,
      "score_kind": "official rounded radius",
      "errors": {},
      "official_calls": 7,
      "repairs": 7
    },
    {
      "seed": 3399433720,
      "start_kind": "baseline",
      "minutes": 4.624336221938332,
      "attempts": 366,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded radius",
      "errors": {
        "SLSQP status false": 1,
        "Process exited 143; counts and minutes are from last durable checkpoint": 1
      },
      "official_calls": 0,
      "repairs": 5
    },
    {
      "seed": 2208747659,
      "start_kind": "baseline",
      "minutes": 1.9169809946635117,
      "attempts": 195,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded radius",
      "errors": {},
      "official_calls": 0,
      "repairs": 6
    },
    {
      "seed": 3838137447,
      "start_kind": "baseline",
      "minutes": 1.670903921717157,
      "attempts": 168,
      "valid_count": 5,
      "best_radius": 2.948527775950843,
      "score_kind": "official rounded radius",
      "errors": {},
      "official_calls": 5,
      "repairs": 4
    }
  ],
  "strategy_table": [
    {
      "strategy": "inherited fallback",
      "official_radius": "2.94852695"
    },
    {
      "strategy": "Penalty continuation, SLSQP, and rigid-transform rounding",
      "start_kind": "baseline",
      "seed": 3042502191,
      "official_radius": "2.94852825"
    },
    {
      "strategy": "Penalty continuation, SLSQP, and rigid-transform rounding",
      "start_kind": "fresh",
      "seed": 52073344,
      "official_radius": "3.05045596"
    },
    {
      "strategy": "Penalty continuation, SLSQP, and rigid-transform rounding",
      "start_kind": "fresh",
      "seed": 2806424140,
      "official_radius": "3.04517557"
    },
    {
      "strategy": "Penalty continuation, SLSQP, and radius-minimizing integer repair",
      "start_kind": "baseline",
      "seed": 3115124627,
      "official_radius": "2.94852764"
    },
    {
      "strategy": "Penalty continuation, SLSQP, and fixed-radius integer repair",
      "start_kind": "baseline",
      "seed": 3399433720,
      "official_radius": null
    },
    {
      "strategy": "Penalty continuation, SLSQP, and fixed-radius integer repair",
      "start_kind": "baseline",
      "seed": 2208747659,
      "official_radius": null
    },
    {
      "strategy": "Penalty continuation, SLSQP, and radius-minimizing integer repair with angle wrapping",
      "start_kind": "baseline",
      "seed": 3838137447,
      "official_radius": "2.94852778"
    }
  ],
  "repo_commit": "78a78626f098cd236f3a09bb2cb242f72951599d",
  "source_urls": [
    "https://www.paradigm.xyz/puzzles/packing/about",
    "https://github.com/benedictbrady/shape-packing-challenge",
    "https://raw.githubusercontent.com/benedictbrady/shape-packing-challenge/78a78626f098cd236f3a09bb2cb242f72951599d/README.md",
    "https://raw.githubusercontent.com/benedictbrady/shape-packing-challenge/78a78626f098cd236f3a09bb2cb242f72951599d/src/semicircle_packing/config.py",
    "https://raw.githubusercontent.com/benedictbrady/shape-packing-challenge/78a78626f098cd236f3a09bb2cb242f72951599d/src/semicircle_packing/scoring.py",
    "https://raw.githubusercontent.com/benedictbrady/shape-packing-challenge/78a78626f098cd236f3a09bb2cb242f72951599d/run.py"
  ],
  "inherited_inputs": [
    {
      "input": "after-annealing",
      "local_path": ".imd/reads/artifacts/after-annealing",
      "sha256": "8f979bb6b01c9cb949349334957d1beb220831ee63038857fcf71b73cecf3e47",
      "reported_official_score": "2.97206264"
    },
    {
      "input": "after-basin-hopping",
      "local_path": ".imd/reads/artifacts/after-basin-hopping",
      "sha256": "40fa4cfa3e5c2c82ecb82f7f28c5ad17771cf455cee37836c53b34061b47cb70",
      "reported_official_score": 2.98929011
    },
    {
      "input": "after-hand-built",
      "local_path": ".imd/reads/artifacts/after-hand-built",
      "sha256": "38ed7fda0807c52d4aa6d2612f5a07cef42a050f7328558fe682b867207d3d08",
      "reported_official_score": 2.96147487
    },
    {
      "input": "after-penalty-lbfgs",
      "local_path": ".imd/reads/artifacts/after-penalty-lbfgs",
      "sha256": "bb9fa2b781a052c7a2751ba869c6d0adb055af032b1f2809b31141c6353bee5f",
      "reported_official_score": 3.16365945
    },
    {
      "input": "after-published",
      "local_path": ".imd/reads/artifacts/after-published",
      "sha256": "89ffaa96cbc8f60cbce1ebe7c61e0bfac270d013b5aff71bc9d5c7da1a374161",
      "reported_official_score": "2.94852695"
    }
  ],
  "scorer_source": "import argparse\nimport json\nimport signal\nimport time\nfrom math import acos, atan2, cos, hypot, pi, sin, sqrt\nfrom pathlib import Path\n\nimport numpy as np\nfrom numba import njit\nfrom scipy.optimize import Bounds, LinearConstraint, milp, minimize\nfrom semicircle_packing.geometry import Semicircle, semicircle_polygon\nfrom semicircle_packing.scoring import validate_and_score\n\nI, J = np.triu_indices(15, 1)\nTOL = 1e-6\n\n@njit(cache=True)\ndef arc_cuts(cuts, count, base, x, y, h):\n    # Roots of x*cos(t)+y*sin(t)=h inside this arc.\n    d = hypot(x, y)\n    if d > abs(h):\n        mid, gap = atan2(y, x), acos(h/d)\n        for t in (mid-gap, mid+gap):\n            u = (t-base) % (2*pi)\n            if 0 < u < pi:\n                cuts[count] = u\n                count += 1\n    return count\n\n@njit(cache=True)\ndef clip(x, y, t, dx, dy, b, primary):\n    # Boundary of A, integrated in coordinates relative to the first center.\n    nx, ny = cos(b), sin(b)\n    base = t-pi/2\n    d2 = dx*dx + dy*dy\n    cuts = np.empty(6)\n    cuts[0], cuts[1] = 0, pi\n    k = arc_cuts(cuts, 2, base, dx, dy, d2/2)\n    flat = dx*nx+dy*ny\n    k = arc_cuts(cuts, k, base, nx, ny, flat)\n    cuts = np.sort(cuts[:k])\n    area, gx, gy, gt = 0., 0., 0., 0.\n    for i in range(k-1):\n        l, r = base+cuts[i], base+cuts[i+1]\n        m = (l+r)/2\n        u, v = cos(m), sin(m)\n        if ((d2 == 0 and primary) or 2*(u*dx+v*dy) > d2) and (flat <= -1 or (flat < 1 and u*nx+v*ny > flat)):\n            sx, sy = sin(r)-sin(l), cos(l)-cos(r)\n            area += (r-l+x*sx+y*sy)/2\n            gx += sx\n            gy += sy\n\n    # Chord traverses decreasing s along (-sin(t),cos(t)).\n    ex, ey = -sin(t), cos(t)\n    along = dx*ex+dy*ey\n    across = dx*ey-dy*ex\n    if abs(across) < 1:\n        half = sqrt(1-across*across)\n        lo, hi = max(-1., along-half), min(1., along+half)\n        slope, offset = ex*nx+ey*ny, dx*nx+dy*ny\n        if abs(slope) < 2e-15 and abs(offset) < 2e-15:\n            # Opposing coincident chords cancel. Same-side chords count once.\n            if primary is False and nx*ey-ny*ex > 0:\n                hi = lo\n        elif slope > 0:\n            lo = max(lo, offset/slope)\n        elif slope < 0:\n            hi = min(hi, offset/slope)\n        elif offset > 0:\n            hi = lo\n        if hi > lo:\n            length = hi-lo\n            area += length*(y*ex-x*ey)/2\n            gx -= length*ey\n            gy += length*ex\n            gt = length*(hi+lo)/2\n    return area, gx, gy, gt\n\n@njit(cache=True)\ndef pair(a,b):\n    dx, dy = b[0]-a[0], b[1]-a[1]\n    if dx*dx+dy*dy >= 4:\n        return 0., (0.,0.,0.), (0.,0.,0.)\n    u,gx,gy,gt = clip(0.,0.,a[2],dx,dy,b[2],True)\n    v,hx,hy,ht = clip(dx,dy,b[2],-dx,-dy,a[2],False)\n    return max(0.,u+v), (gx,gy,gt), (hx,hy,ht)\n\n@njit(cache=True)\ndef far(s, cx, cy):\n    x, y = s[0]-cx, s[1]-cy\n    nx, ny = cos(s[2]), sin(s[2])\n    d = hypot(x,y)\n    if d and x*nx+y*ny >= 0:\n        return d+1, x/d, y/d, 0.\n    sign = 1. if -x*ny+y*nx >= 0 else -1.\n    u, v = x-sign*ny, y+sign*nx\n    r = hypot(u,v)\n    return r,u/r,v/r,-sign*(u*nx+v*ny)/r\n\n@njit(cache=True)\ndef in_circle(p, c):\n    return hypot(p[0]-c[0], p[1]-c[1]) <= c[2]+2e-14\n\n@njit(cache=True)\ndef diameter(p,q):\n    return (p[0]+q[0])/2,(p[1]+q[1])/2,hypot(p[0]-q[0],p[1]-q[1])/2\n\n@njit(cache=True)\ndef circum(p,q,s):\n    x,y = q-p\n    u,v = s-p\n    d = 2*(x*v-y*u)\n    if abs(d) < 1e-18:\n        a,b,c = diameter(p,q),diameter(p,s),diameter(q,s)\n        best = a if a[2] >= b[2] else b\n        return best if best[2] >= c[2] else c\n    a,b = x*x+y*y,u*u+v*v\n    cx,cy = (v*a-y*b)/d,(x*b-u*a)/d\n    return p[0]+cx,p[1]+cy,hypot(cx,cy)\n\n@njit(cache=True)\ndef point_mec(points):\n    c = (points[0,0],points[0,1],0.)\n    for i,p in enumerate(points):\n        if not in_circle(p,c):\n            c = (p[0],p[1],0.)\n            for j in range(i):\n                q = points[j]\n                if not in_circle(q,c):\n                    c = diameter(p,q)\n                    for k in range(j):\n                        if not in_circle(points[k],c):\n                            c = circum(p,q,points[k])\n    return c\n\ndef mec(rows):\n    angles = rows[:,2,None] + np.linspace(-pi/2,pi/2,9)\n    points = (rows[:,None,:2]+np.stack((np.cos(angles),np.sin(angles)),axis=-1)).reshape(-1,2)\n    rng = np.random.default_rng(1)\n    for _ in range(60):\n        cx,cy,lower = point_mec(points[rng.permutation(len(points))])\n        rs = np.array([far(s,cx,cy)[:3] for s in rows])\n        upper = max(rs[:,0])\n        if upper-lower <= 2e-12:\n            return float(cx),float(cy),float(upper)\n        active = rs[rs[:,0]>lower+1e-13]\n        points = np.vstack((points,[cx,cy]+active[:,:1]*active[:,1:]))\n    raise RuntimeError(\"MEC bounds did not converge\")\n\n@njit(cache=True)\ndef constraints(z):\n    rows = z[:-1].reshape(15,3)\n    values, jac = np.empty(135), np.zeros((135,46))\n    for k,(i,j) in enumerate(zip(I,J)):\n        a,g,h = pair(rows[i],rows[j])\n        values[k] = a\n        for u in range(3):\n            jac[k,3*i+u],jac[k,3*j+u] = g[u],h[u]\n    # Use the endpoints separately to avoid a nonsmooth maximum at an outward flat.\n    for i,s in enumerate(rows):\n        x,y,t = s\n        nx,ny = cos(t),sin(t)\n        for k,sign in enumerate((-1.,1.)):\n            u,v = x-sign*ny,y+sign*nx\n            r = hypot(u,v)\n            index = 105+2*i+k\n            if x*nx+y*ny >= 0:\n                r,gx,gy,gt = far(s,0.,0.)\n            else:\n                gx,gy,gt = u/r,v/r,-sign*(u*nx+v*ny)/r\n            values[index] = r-z[-1]\n            jac[index,3*i],jac[index,3*i+1],jac[index,3*i+2] = gx,gy,gt\n            jac[index,-1] = -1\n    return values,jac\n\ndef rounded(rows):\n    return np.array([[round(float(v),6) for v in s] for s in rows])\n\ndef score_exact(rows):\n    rows = rounded(rows)\n    if rows.shape != (15,3):\n        raise ValueError(\"Expected 15 rows of x, y, theta\")\n    area = max(pair(rows[i],rows[j])[0] for i,j in zip(I,J))\n    return dict(valid=area<=TOL,mec=mec(rows),max_pair_area=area)\n\n\ndef official(rows):\n    return validate_and_score([Semicircle(*s) for s in rounded(rows)])\n\ndef poly_areas(rows):\n    p = [semicircle_polygon(Semicircle(*s)) for s in rows]\n    return np.array([p[i].intersection(p[j]).area if hypot(*(rows[i,:2]-rows[j,:2]))<2\n                     else 0. for i,j in zip(I,J)])\n\ndef transform(rows, angle, shift, wrap=0):\n    c,s = cos(angle),sin(angle)\n    a = rows.copy()\n    a[:,:2] = a[:,:2] @ np.array([[c,s],[-s,c]]) + shift\n    a[:,2] = (a[:,2]+angle+pi)%(2*pi)-pi\n    a[:,2] -= np.sign(a[:,2])*wrap*(2*pi)\n    return rounded(a)\n\ndef lattice(rows, target=None):\n    # Integer offsets in units of 1e-6. The MEC center and radius remain continuous.\n    cx,cy,r = mec(rows)\n    centered = rows.copy()\n    centered[:,:2] -= [cx,cy]\n    z = np.r_[centered.ravel(),r]\n    values,jac = constraints(z)\n    areas = poly_areas(rows)\n    active = np.r_[areas>5e-7,values[105:]>-12e-6]\n    center = -jac[:,:45].reshape(-1,15,3)[:,:,:2].sum(axis=1)\n    matrix = np.c_[jac[:,:45],center,jac[:,-1]][active]\n    ceiling = np.r_[TOL-areas,np.maximum(0.,-values[105:])][active]*1e6\n    objective = np.r_[np.zeros(47),1.]\n    bound = np.r_[np.full(45,2.),np.full(2,10.),20.]\n    # Pair-area Taylor error is checked explicitly; failed pairs tighten the halfspaces.\n    low, high = -bound.copy(), bound.copy()\n    if target is not None:\n        high[-1] = min(high[-1], (target-r)*1e6)\n        if high[-1] < low[-1]:\n            return None\n        objective[-1] = 0.\n    for _ in range(4 if target else 3):\n        fit = milp(objective,integrality=np.r_[np.ones(45),np.zeros(3)],\n                   bounds=Bounds(low,high),constraints=LinearConstraint(matrix,-np.inf,ceiling),\n                   options={'time_limit':.6 if target else .12,'mip_rel_gap':0.})\n        if fit.x is None:\n            return None\n        a = rounded(rows+np.rint(fit.x[:45]).reshape(15,3)*1e-6)\n        new = poly_areas(a)\n        if max(new)<=TOL:\n            return a\n        if np.any(new[~active[:105]]>TOL):\n            return None\n        excess = np.r_[np.maximum(new-TOL,0.)*1e6,np.zeros(30)][active]\n        ceiling -= 1.1*excess + 0.00005*(excess>0)\n    return None\n\n\ndef solve(rows, limits, first, deadline):\n    cx,cy,r = mec(rows)\n    a = rows.copy()\n    a[:,:2] -= [cx,cy]\n    z = np.r_[a.ravel(),r]\n    radius_grad = np.eye(1,46,45)[0]\n    # Areas scaled by each contact's local gradient and bounded away from zero.\n    def norm(x):\n        return np.maximum(.018,np.linalg.norm(constraints(x)[1][:105],axis=1))\n\n    if first:\n        for weight in (30,300,3000,30000,300000,3000000):\n            if time.monotonic() >= deadline:\n                break\n            scaling = np.r_[norm(z),np.ones(30)]\n            def penalty(x):\n                values,jac = constraints(x)\n                excess = np.maximum(0,(values-limits)/scaling)\n                return x[-1]+weight/2*(excess@excess), radius_grad+weight*(excess/scaling)@jac\n            z = minimize(penalty,z,method='L-BFGS-B',jac=True,\n                         options={'maxiter':650,'ftol':2e-15,'gtol':1e-9,'maxls':40}).x\n    scaling = np.r_[norm(z),np.ones(30)]\n    result = minimize(lambda x:x[-1],z,jac=lambda x:radius_grad,method='SLSQP',\n                      constraints={'type':'ineq','fun':lambda x:(limits-constraints(x)[0])/scaling,\n                                   'jac':lambda x:-constraints(x)[1]/scaling[:,None]},\n                      options={'maxiter':260,'ftol':2e-12})\n    return result.x[:-1].reshape(15,3),float(result.x[-1]),bool(result.success)\n\ndef rows_from(path):\n    data = json.loads(Path(path).read_text())\n    return np.array([[r[k] for k in ('x','y','theta')] if isinstance(r,dict) else r for r in data])\n\ndef random_rows(rng):\n    a = rng.uniform(-pi,pi,15)\n    r = 2.9*np.sqrt(rng.uniform(0,1,15))\n    return np.c_[r*np.cos(a),r*np.sin(a),rng.uniform(-pi,pi,15)]\n\ndef run(args):\n    rng = np.random.default_rng(args.seed)\n    start,deadline = time.monotonic(),time.monotonic()+args.seconds\n    baseline = rows_from(args.baseline)\n    def stop(_sig,_frame):\n        nonlocal deadline\n        deadline = time.monotonic()\n    signal.signal(signal.SIGTERM,stop)\n    source = baseline if args.kind=='baseline' else random_rows(rng)\n    best, best_rows = float('inf'),None\n    nvalid,attempts,checked,repairs = 0,0,0,0\n    errors = {}\n    last = start\n    def checkpoint():\n        state = dict(seed=args.seed,start_kind=args.kind,minutes=(time.monotonic()-start)/60,\n                     attempts=attempts,valid_count=nvalid,best_radius=None if best_rows is None else best,\n                     score_kind='official rounded radius',errors=errors,official_calls=checked,\n                     repairs=repairs,rows=None if best_rows is None else best_rows.tolist())\n        temp=Path(args.output+'.tmp')\n        temp.write_text(json.dumps(state))\n        temp.replace(args.output)\n    continuous = source\n    while time.monotonic()<deadline or repairs==0:\n        first = repairs==0 or (args.kind=='fresh' and repairs%6==0)\n        if first and repairs:\n            source = random_rows(rng)\n        limits = np.r_[np.full(105,TOL),np.zeros(30)]\n        if repairs:\n            aa = constraints(np.r_[continuous.ravel(),0.])[0][:105]\n            # Estimate shape-dependent allowance from inscribed polygon area.\n            allowance = np.clip(aa-poly_areas(continuous),0,1.7e-7)\n            limits[:105] += allowance*(.85 if repairs%4!=0 else 0.)\n            limits[:105] -= rng.uniform(0,1,(105,))*rng.choice([0.,2e-9,8e-9,3e-8,1e-7])\n        try:\n            continuous,_,success = solve(source if first else continuous,limits,first,deadline)\n            if not success:\n                errors['SLSQP status false'] = errors.get('SLSQP status false',0)+1\n        except (RuntimeError,ValueError) as exc:\n            errors[str(exc)] = errors.get(str(exc),0)+1\n            continuous = source\n        repairs += 1\n        for i in range(args.batch):\n            if i and time.monotonic()>=deadline:\n                break\n            anchor = baseline if args.target and i%5==0 else continuous\n            if i==0:\n                a = rounded(anchor)\n            else:\n                a = transform(anchor,rng.uniform(-pi,pi),rng.uniform(-.5e-6,.5e-6,2),\n                              rng.integers(2,size=15) if args.wrap else 0)\n            if time.monotonic()-last>=55:\n                checkpoint()\n                last=time.monotonic()\n            attempts += 1\n            if args.lattice:\n                a = lattice(a,args.target)\n                if a is None:\n                    continue\n            area = constraints(np.r_[a.ravel(),0.])[0][:105]\n            if max(area)<=TOL+1.8e-7 and mec(a)[2] < best+2e-12:\n                polygons = poly_areas(a) if max(area)>TOL else area\n                if max(polygons)<=TOL:\n                    checked += 1\n                    v = official(a)\n                    if v.valid:\n                        nvalid += 1\n                        if v.score<best:\n                            best,best_rows = v.score,a.copy()\n                            checkpoint()\n                    else:\n                        for error in v.errors:\n                            errors[error] = errors.get(error,0)+1\n    checkpoint()\n\nif __name__=='__main__':\n    p=argparse.ArgumentParser()\n    p.add_argument('kind',choices=['baseline','fresh'])\n    p.add_argument('seed',type=int)\n    p.add_argument('seconds',type=float)\n    p.add_argument('output')\n    p.add_argument('--wrap',action='store_true')\n    p.add_argument('--target',type=float)\n    p.add_argument('--lattice',action='store_true')\n    p.add_argument('--batch',type=int,default=750)\n    p.add_argument('--baseline',default='baseline-rows.json')\n    run(p.parse_args())\n",
  "commands": {
    "setup": [
      "git clone https://github.com/benedictbrady/shape-packing-challenge official",
      "git -C official checkout --detach 78a78626f098cd236f3a09bb2cb242f72951599d",
      "(cd official && uv sync && uv run python run.py)",
      "uv pip install --python official/.venv/bin/python scipy==1.18.1 numba==0.68.1",
      "export OPENBLAS_NUM_THREADS=1"
    ],
    "inputs": "Save scorer_source as search.py. Save inherited_baseline.solution as baseline-rows.json. The loader also accepts the original numeric rows.",
    "search": [
      "timeout 475s official/.venv/bin/python search.py baseline 3042502191 390 run-3042502191.json",
      "timeout 475s official/.venv/bin/python search.py fresh 52073344 130 run-52073344.json",
      "timeout 475s official/.venv/bin/python search.py fresh 2806424140 130 run-2806424140.json",
      "timeout 475s official/.venv/bin/python search.py baseline 3115124627 420 run-3115124627.json --lattice --batch 85",
      "timeout 475s official/.venv/bin/python search.py baseline 3399433720 415 run-3399433720.json --lattice --target 2.94852693 --batch 85",
      "timeout 475s official/.venv/bin/python search.py baseline 2208747659 115 run-2208747659.json --lattice --target 2.948526949 --batch 35",
      "timeout 475s official/.venv/bin/python search.py baseline 3838137447 100 run-3838137447.json --lattice --wrap --batch 55"
    ],
    "validation": [
      "Recreate solution.json using the verbatim solution_json string.",
      "(cd official && uv run python run.py ../solution.json --save-plot ../packing.svg)",
      "(cd official && uv run python -c 'from run import _load_solution; from semicircle_packing.scoring import validate_and_score; v=validate_and_score(_load_solution(\"../solution.json\")); assert v.valid, v.errors; print(repr(v.score), format(v.score, \".8f\"), v.mec)')"
    ],
    "clean_local_rerun": "git clone --no-hardlinks official clean && git -C clean checkout --detach 78a78626f098cd236f3a09bb2cb242f72951599d; (cd clean && uv sync --offline && uv run --offline python run.py ../solution.json)",
    "packages": {
      "python": "3.12.3",
      "numpy": "2.5.5",
      "scipy": "1.18.1",
      "shapely": "2.2.0",
      "numba": "0.68.1",
      "llvmlite": "0.50.0"
    }
  },
  "plot": {
    "format": "image/svg+xml",
    "filename": "packing.svg",
    "text": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"640\" height=\"660\" viewBox=\"-3.25 -3.29 6.5 6.7\" role=\"img\">\n<title>Fifteen unit semicircles. Official radius 2.94852695</title>\n<rect x=\"-3.25\" y=\"-3.29\" width=\"6.5\" height=\"6.7\" fill=\"#fbfaf7\"/>\n<g transform=\"scale(1 -1)\" stroke=\"#344556\" stroke-width=\".015\" stroke-linejoin=\"round\">\n<path fill=\"#a9d6e5\" d=\"M0.00532002,-0.16946538 A1,1 0 0 1 1.08589379,1.51349640 Z\"/>\n<path fill=\"#a9cbb7\" d=\"M1.92775729,-0.62847196 A1,1 0 0 1 0.34357453,-1.84927702 Z\"/>\n<path fill=\"#ffd09f\" d=\"M-1.57884687,-0.11696840 A1,1 0 0 1 0.41096268,-0.31860658 Z\"/>\n<path fill=\"#f8b4ae\" d=\"M1.18184127,-0.11831513 A1,1 0 0 1 2.50475855,1.38164815 Z\"/>\n<path fill=\"#c6b6eb\" d=\"M1.04720124,2.56798973 A1,1 0 0 1 -0.49046542,1.28909129 Z\"/>\n<path fill=\"#a9d6e5\" d=\"M-0.70805906,2.80909478 A1,1 0 0 1 -0.73900713,0.80933424 Z\"/>\n<path fill=\"#a9cbb7\" d=\"M-1.77316906,2.06493876 A1,1 0 0 1 -1.47574112,0.08717826 Z\"/>\n<path fill=\"#ffd09f\" d=\"M-1.56342567,0.89702170 A1,1 0 0 1 0.42416949,0.67461332 Z\"/>\n<path fill=\"#f8b4ae\" d=\"M-0.73573364,1.08509955 A1,1 0 0 1 0.80193346,2.36399747 Z\"/>\n<path fill=\"#c6b6eb\" d=\"M1.69995920,0.58539945 A1,1 0 0 1 0.82438661,2.38355757 Z\"/>\n<path fill=\"#a9d6e5\" d=\"M-2.57144055,0.65802360 A1,1 0 0 1 -1.31806163,-0.90051458 Z\"/>\n<path fill=\"#a9cbb7\" d=\"M-2.57041700,-1.07930602 A1,1 0 0 1 -0.57543118,-1.22083896 Z\"/>\n<path fill=\"#ffd09f\" d=\"M1.97542634,-2.18894941 A1,1 0 0 1 0.12420747,-2.94590957 Z\"/>\n<path fill=\"#f8b4ae\" d=\"M-1.50105309,-2.48388924 A1,1 0 0 1 -0.07738510,-1.07919374 Z\"/>\n<path fill=\"#c6b6eb\" d=\"M1.01927097,-1.32859675 A1,1 0 0 1 2.60342485,-0.10775423 Z\"/>\n<circle r=\"2.9485269509\" fill=\"none\" stroke=\"#1d2e40\" stroke-width=\".02\"/></g>\n<g fill=\"#142534\" text-anchor=\"middle\" font-family=\"sans-serif\" font-size=\".12\">\n<text x=\"0.8990\" y=\"-0.4451\">0</text>\n<text x=\"0.8793\" y=\"0.9062\">1</text>\n<text x=\"-0.6263\" y=\"0.6356\">2</text>\n<text x=\"2.1583\" y=\"-0.3539\">3</text>\n<text x=\"0.0098\" y=\"-2.2515\">4</text>\n<text x=\"-1.1435\" y=\"-1.8157\">5</text>\n<text x=\"-2.0398\" y=\"-1.0136\">6</text>\n<text x=\"-0.6163\" y=\"-0.3684\">7</text>\n<text x=\"0.3017\" y=\"-1.4016\">8</text>\n<text x=\"1.6398\" y=\"-1.6683\">9</text>\n<text x=\"-2.2720\" y=\"0.3845\">10</text>\n<text x=\"-1.6026\" y=\"1.5690\">11</text>\n<text x=\"0.8909\" y=\"2.1787\">12</text>\n<text x=\"-0.4942\" y=\"2.0805\">13</text>\n<text x=\"2.0677\" y=\"1.0508\">14</text>\n<text y=\"3.23\" font-size=\".15\">Official radius 2.94852695</text>\n</g></svg>"
  },
  "notes": [
    "The delivered packing scores 2.94852695, which is 3.05e-06 below 2.94853.",
    "The delivered result is the inherited packing. No newly generated candidate improved on its full-precision radius.",
    "Thirty near-active pair constraints in the baseline contact pattern leave little room for six-decimal coordinate changes. Continuous SLSQP diagnostics reached approximately 2.94852655 with contact-specific polygon allowances before rounding, with residual polygon area slightly above the cutoff. That radius is diagnostic only.",
    "Attempts count six-decimal candidates or rounding-repair attempts, including filtered candidates. One run also tried equivalent angular representations within two pi before rounding. Valid counts count successful official calls; the search only invokes the official scorer for candidates that can match or beat that run’s incumbent. Each run uses a wall-clock budget, so replay can reach a different attempt count.",
    "The inherited results and scorer implementations were inspected as data. The source here independently integrates clipped arcs and chords. MEC refinement brackets the exact circle radius with a finite-point lower bound and analytic farthest-point upper bound.",
    "The final file was loaded and validated with unmodified code in a second clean checkout. Its official repository test suite passed all 31 tests. A separate agent rerun was unavailable in this session.",
    "The two pair-verdict differences were near the 1e-6 threshold. All retained scores and max_pair_area use the official polygons. A strictly zero-overlap packing was not measured."
  ]
}
