{
  "method": "SLSQP minimization of enclosing radius with cached, official 4096-point polygon intersection constraints; contact-specific area scaling, active-set refresh, and rounded repair.",
  "seed": 22001,
  "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  {\"x\": 0.545425, \"y\": 0.672150, \"theta\": -0.570778},\n  {\"x\": 1.135484, \"y\": -1.238740, \"theta\": 2.227365},\n  {\"x\": -0.584124, \"y\": -0.217653, \"theta\": -1.671787},\n  {\"x\": 1.843118, \"y\": 0.631801, \"theta\": -0.722762},\n  {\"x\": 0.278186, \"y\": 1.928675, \"theta\": 2.264578},\n  {\"x\": -0.723715, \"y\": 1.809349, \"theta\": 3.126118},\n  {\"x\": -1.624637, \"y\": 1.076193, \"theta\": -2.992325},\n  {\"x\": -0.569810, \"y\": 0.785952, \"theta\": -1.682231},\n  {\"x\": 0.032918, \"y\": 1.724683, \"theta\": -0.877015},\n  {\"x\": 1.261991, \"y\": 1.484613, \"theta\": 0.453135},\n  {\"x\": -1.944933, \"y\": -0.121111, \"theta\": -2.464295},\n  {\"x\": -1.573106, \"y\": -1.149938, \"theta\": -1.641622},\n  {\"x\": 1.049635, \"y\": -2.567295, \"theta\": 1.958950},\n  {\"x\": -0.789401, \"y\": -1.781407, \"theta\": -0.792106},\n  {\"x\": 1.811166, \"y\": -0.718041, \"theta\": -0.914204}\n]\n",
  "solution_sha256": "5dffe6db0b5f323e0fb487a3ba7330151e78ec29592a668a33f711fe6bee7019",
  "mec": {
    "x": -0.0001819080616875258,
    "y": 0.00013448997007248039,
    "radius": 2.948526950912552
  },
  "max_pair_area": 9.997822348073146e-07,
  "max_circular_pair_area": 1.0013726915863996e-06,
  "max_pair": [
    2,
    13
  ],
  "inherited_baseline": {
    "official_valid": true,
    "official_score": "2.94852695",
    "official_score_full": 2.948526950912552,
    "max_pair_area": 9.997822348073146e-07,
    "source": "https://raw.githubusercontent.com/rorz/shape-packing-challenge/main/solution.json",
    "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
      }
    ],
    "mec": [
      -0.0001819080616875258,
      0.00013448997007248039,
      2.948526950912552
    ]
  },
  "best_new_score": 2.948527420451899,
  "best_new_solution": [
    {
      "x": 0.141078,
      "y": 0.85404,
      "theta": -0.052534
    },
    {
      "x": 1.600225,
      "y": -0.513644,
      "theta": 2.745605
    },
    {
      "x": -0.399383,
      "y": -0.478444,
      "theta": -1.15355
    },
    {
      "x": 1.288363,
      "y": 1.461809,
      "theta": -0.204524
    },
    {
      "x": -0.713497,
      "y": 1.813197,
      "theta": 2.782807
    },
    {
      "x": -1.52473,
      "y": 1.213242,
      "theta": -2.638825
    },
    {
      "x": -1.944179,
      "y": 0.130083,
      "theta": -2.474077
    },
    {
      "x": -0.884088,
      "y": 0.40047,
      "theta": -1.16397
    },
    {
      "x": -0.825509,
      "y": 1.514511,
      "theta": -0.358786
    },
    {
      "x": 0.3611,
      "y": 1.914777,
      "theta": 0.971364
    },
    {
      "x": -1.629329,
      "y": -1.068663,
      "theta": -1.946051
    },
    {
      "x": -0.796694,
      "y": -1.77821,
      "theta": -1.123379
    },
    {
      "x": 2.183751,
      "y": -1.710276,
      "theta": 2.47719
    },
    {
      "x": 0.196904,
      "y": -1.938552,
      "theta": -0.273864
    },
    {
      "x": 1.929255,
      "y": 0.273383,
      "theta": -0.395962
    }
  ],
  "best_new_run": 10,
  "best_fresh_score": 3.3274827122654926,
  "best_fresh_solution": [
    {
      "x": -2.256067,
      "y": 0.570729,
      "theta": 1.591054
    },
    {
      "x": 1.391284,
      "y": -0.69855,
      "theta": 2.64132
    },
    {
      "x": -2.298243,
      "y": -1.019075,
      "theta": -0.417195
    },
    {
      "x": -0.982973,
      "y": -2.370097,
      "theta": 0.430159
    },
    {
      "x": -0.356653,
      "y": 1.264025,
      "theta": -2.947763
    },
    {
      "x": -3.141841,
      "y": -0.448301,
      "theta": 0.141731
    },
    {
      "x": 2.521079,
      "y": 0.937885,
      "theta": 2.942344
    },
    {
      "x": 0.216913,
      "y": -2.317353,
      "theta": -0.542797
    },
    {
      "x": 1.597626,
      "y": 2.741259,
      "theta": -2.098478
    },
    {
      "x": 2.327289,
      "y": -0.030032,
      "theta": -0.369365
    },
    {
      "x": -0.56724,
      "y": -0.284369,
      "theta": -0.823473
    },
    {
      "x": 0.644332,
      "y": 1.35589,
      "theta": -2.067835
    },
    {
      "x": -0.370872,
      "y": 2.297025,
      "theta": 0.723941
    },
    {
      "x": -1.898578,
      "y": 2.538596,
      "theta": -0.928222
    },
    {
      "x": 2.279619,
      "y": -2.053087,
      "theta": 2.301522
    }
  ],
  "best_fresh_run": 14,
  "strict_radius": 2.9486827155047965,
  "strict_comparison": {
    "solution": [
      {
        "x": 0.545901,
        "y": 0.671789,
        "theta": -0.571048
      },
      {
        "x": 1.135263,
        "y": -1.239403,
        "theta": 2.226971
      },
      {
        "x": -0.584012,
        "y": -0.217594,
        "theta": -1.672425
      },
      {
        "x": 1.843722,
        "y": 0.630915,
        "theta": -0.723217
      },
      {
        "x": 0.278848,
        "y": 1.928628,
        "theta": 2.264504
      },
      {
        "x": -0.723219,
        "y": 1.809507,
        "theta": 3.125352
      },
      {
        "x": -1.624227,
        "y": 1.076685,
        "theta": -2.992272
      },
      {
        "x": -0.569255,
        "y": 0.786089,
        "theta": -1.682039
      },
      {
        "x": 0.033904,
        "y": 1.724934,
        "theta": -0.877089
      },
      {
        "x": 1.262933,
        "y": 1.484036,
        "theta": 0.452515
      },
      {
        "x": -1.94495,
        "y": -0.120548,
        "theta": -2.464599
      },
      {
        "x": -1.573479,
        "y": -1.149577,
        "theta": -1.641984
      },
      {
        "x": 1.048949,
        "y": -2.567963,
        "theta": 1.958587
      },
      {
        "x": -0.789893,
        "y": -1.781413,
        "theta": -0.793076
      },
      {
        "x": 1.811219,
        "y": -0.718923,
        "theta": -0.914622
      }
    ],
    "min_gap": 3.952649940686115e-08,
    "official_score": 2.9486827155047513,
    "exact_radius": 2.9486827155047965,
    "method": "Diagnostic SLSQP on analytical separating clearances. It reached the iteration limit. After rounding, all 105 pairs had positive separating clearance and zero official polygon intersection area. This radius is an upper bound on the strict optimum."
  },
  "structure": {
    "full_disks": 0,
    "sliding_seams": [
      {
        "pieces": [
          1,
          14
        ],
        "center_offset": 0.8530378735583785
      },
      {
        "pieces": [
          4,
          8
        ],
        "center_offset": 0.31901273938198765
      }
    ],
    "enclosure_contacts": [
      3,
      4,
      5,
      6,
      9,
      10,
      11,
      12,
      13,
      14
    ],
    "arc_contacts": [
      3,
      4,
      5,
      6,
      9,
      10,
      11,
      13,
      14
    ],
    "flat_end_contacts": [
      12
    ],
    "flats": "Two nearly parallel, offset flat-to-flat seams. Piece 12 faces inward with both tips of its outward flat chord near the container. The remaining boundary contacts are on the curves.",
    "symmetry": "The boundary contacts have unequal angular spacings. The symmetry test matches centres and curved-side normals to 2e-5.",
    "matched_symmetries": {
      "rotations": 1,
      "reflections": 0
    },
    "convention": "Piece indices are zero-based. Boundary contacts are within 5e-6 of the scored circle."
  },
  "scorer_check": {
    "cases": {
      "sample": 1,
      "baseline": 1,
      "random": 64,
      "tight": 64
    },
    "validity_disagreements": {},
    "exact_circular_validity_disagreements": {
      "baseline": 1,
      "tight": 25
    },
    "max_abs_radius_difference": 9.78328529299688e-13,
    "max_abs_polygon_area_difference": 1.9699361386571468e-07,
    "degenerate_checks": [
      "identical half disks: pi/2 area",
      "opposing half disks: zero area",
      "coincident disks with perpendicular normals: pi/4 area",
      "coincident placements: MEC radius 1"
    ],
    "pair_threshold_disagreements": 197,
    "examples": [
      [
        "baseline",
        [
          1,
          3
        ],
        1.0013726915863996e-06,
        9.99594025502215e-07
      ],
      [
        "baseline",
        [
          1,
          13
        ],
        1.000348067327697e-06,
        9.985677175080334e-07
      ],
      [
        "baseline",
        [
          2,
          11
        ],
        1.000770396294634e-06,
        9.996466942502033e-07
      ],
      [
        "baseline",
        [
          3,
          9
        ],
        1.0007205146073117e-06,
        9.995983747504195e-07
      ],
      [
        "baseline",
        [
          7,
          8
        ],
        1.0001613924212616e-06,
        9.990352164717355e-07
      ],
      [
        "baseline",
        [
          8,
          9
        ],
        1.0008169527096072e-06,
        9.996957770875582e-07
      ]
    ],
    "sample_official_score": "3.500000",
    "rounding": "Applied Python round(float(value), 6) before both scorers.",
    "tests": "64 uniform random placements and 64 perturbed copies of the published baseline, plus sample and baseline. Master check seed 22001. The reported MEC comparison includes overlap-invalid configurations using official compute_mec.",
    "decision": "Use exact official-resolution polygon intersection for validity and the analytical outer radius for containment."
  },
  "runs": [
    {
      "seed": 1998107026,
      "start_kind": "baseline",
      "minutes": 4.159155377784433,
      "attempts": 5,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 0,
      "variant": "unboxed baseline",
      "error_counts": {
        "Iteration limit reached": 11
      }
    },
    {
      "seed": 3507690874,
      "start_kind": "fresh",
      "minutes": 2.602396395301912,
      "attempts": 3,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 1,
      "variant": "unboxed randomized",
      "error_counts": {
        "Iteration limit reached": 9
      }
    },
    {
      "seed": 64558881,
      "start_kind": "fresh",
      "minutes": 2.117016824850968,
      "attempts": 3,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 2,
      "variant": "unboxed randomized",
      "error_counts": {
        "Iteration limit reached": 9
      }
    },
    {
      "seed": 3573640302,
      "start_kind": "strict",
      "minutes": 0.9097722171029697,
      "attempts": 1,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 3,
      "variant": "near-zero area diagnostic",
      "error_counts": {
        "Iteration limit reached": 2
      }
    },
    {
      "seed": 976887956,
      "start_kind": "file:hand-built.json",
      "minutes": 4.728836220103161,
      "attempts": 4,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 4,
      "variant": "unboxed handed hand-built",
      "error_counts": {
        "Iteration limit reached": 12
      }
    },
    {
      "seed": 2758647879,
      "start_kind": "file:annealing.json",
      "minutes": 4.96339941015079,
      "attempts": 4,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 5,
      "variant": "unboxed handed annealing",
      "error_counts": {
        "Iteration limit reached": 12
      }
    },
    {
      "seed": 2511872574,
      "start_kind": "baseline-box",
      "minutes": 6.4787060657826565,
      "attempts": 12,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached",
        "Positive directional derivative for linesearch",
        "Optimization time budget reached",
        "Inequality constraints incompatible"
      ],
      "run_index": 6,
      "variant": "boxed and rigid transform repair",
      "error_counts": {
        "Iteration limit reached": 2,
        "Positive directional derivative for linesearch": 5,
        "Optimization time budget reached": 4,
        "Inequality constraints incompatible": 1
      }
    },
    {
      "seed": 3218320409,
      "start_kind": "baseline; SLSQP + lattice repair",
      "minutes": 7.128153007881095,
      "attempts": 155,
      "valid_count": 19,
      "best_radius": 2.94852746752574,
      "score_kind": "official rounded",
      "errors": [],
      "run_index": 7,
      "variant": "integer micro-coordinate repair",
      "error_counts": {}
    },
    {
      "seed": 2737567192,
      "start_kind": "fresh grid; SLSQP with dilation repair",
      "minutes": 7.071713971917052,
      "attempts": 81,
      "valid_count": 118,
      "best_radius": 3.354772102013024,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 8,
      "variant": "boxed and dilation repair",
      "error_counts": {
        "Iteration limit reached": 97
      }
    },
    {
      "seed": 2111643666,
      "start_kind": "fresh grid; SLSQP with dilation repair",
      "minutes": 7.083839110513994,
      "attempts": 69,
      "valid_count": 101,
      "best_radius": 3.359405165815283,
      "score_kind": "official rounded",
      "errors": [
        "Positive directional derivative for linesearch",
        "Iteration limit reached",
        "Optimization time budget reached"
      ],
      "run_index": 9,
      "variant": "boxed and dilation repair",
      "error_counts": {
        "Positive directional derivative for linesearch": 1,
        "Iteration limit reached": 81,
        "Optimization time budget reached": 1
      }
    },
    {
      "seed": 3661066181,
      "start_kind": "baseline; SLSQP + lattice repair",
      "minutes": 7.113886851619464,
      "attempts": 123,
      "valid_count": 110,
      "best_radius": 2.948527420451899,
      "score_kind": "official rounded",
      "errors": [],
      "run_index": 10,
      "variant": "integer repair with flat-seam cuts",
      "error_counts": {}
    },
    {
      "seed": 1729319237,
      "start_kind": "baseline; SLSQP + lattice repair",
      "minutes": 7.100150190332594,
      "attempts": 372,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [],
      "run_index": 11,
      "variant": "target-radius integer repair with fixed reference and LP bounds",
      "error_counts": {}
    },
    {
      "seed": 1679542170,
      "start_kind": "baseline; SLSQP + lattice repair",
      "minutes": 7.167983147300159,
      "attempts": 70,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [],
      "run_index": 12,
      "variant": "target-radius integer repair with larger displacement window",
      "error_counts": {}
    },
    {
      "seed": 1024725575,
      "start_kind": "fresh grid; SLSQP with dilation repair",
      "minutes": 3.4141076514031736,
      "attempts": 41,
      "valid_count": 66,
      "best_radius": 3.362115408132973,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 13,
      "variant": "boxed and dilation repair, analytical containment bounds",
      "error_counts": {
        "Iteration limit reached": 46
      }
    },
    {
      "seed": 710152017,
      "start_kind": "fresh grid; SLSQP with dilation repair",
      "minutes": 3.3208816705970094,
      "attempts": 37,
      "valid_count": 65,
      "best_radius": 3.3274827122654926,
      "score_kind": "official rounded",
      "errors": [
        "Iteration limit reached"
      ],
      "run_index": 14,
      "variant": "boxed and dilation repair, analytical containment bounds",
      "error_counts": {
        "Iteration limit reached": 39
      }
    },
    {
      "seed": 4260478027,
      "start_kind": "baseline; iterative boxed SLSQP",
      "minutes": 5.924903098098002,
      "attempts": 28,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [
        "Optimization time budget reached",
        "Positive directional derivative for linesearch"
      ],
      "run_index": 15,
      "variant": "iterated trust boxes with rigid rounding phases",
      "error_counts": {
        "Optimization time budget reached": 23,
        "Positive directional derivative for linesearch": 5
      }
    },
    {
      "seed": 590867963,
      "start_kind": "baseline; SLSQP + lattice repair",
      "minutes": 4.969334492351239,
      "attempts": 54,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded",
      "errors": [],
      "run_index": 16,
      "variant": "target-radius repair near the baseline lattice phase",
      "error_counts": {}
    }
  ],
  "repo_commit": "78a78626f098cd236f3a09bb2cb242f72951599d",
  "source_urls": [
    "https://www.paradigm.xyz/puzzles/packing/about",
    "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/geometry.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",
    "https://raw.githubusercontent.com/rorz/shape-packing-challenge/main/solution.json",
    "https://github.com/benedictbrady/shape-packing-challenge"
  ],
  "notes": [
    "The published baseline remains the best. It is numerically below 2.94853, but this search did not improve the published 2.94852695 packing.",
    "A small-box SLSQP candidate reached approximately 2.94852658657 before rounding. Direct six-decimal rounding put its largest polygon overlap above 1e-6, so that continuous result was excluded.",
    "The exploratory unbounded SLSQP variants hit iteration limits. Smaller boxes stabilized the baseline solve and dilation recovered validity in the fresh runs.",
    "Fresh-run valid_count counts verified candidates, which may repeat across attempts. Best-new and fresh scores exclude the inherited fallback.",
    "The final solution was reloaded with official run._load_solution and validated in a separate clean checkout at the pinned commit. No independent agent was available. The embedded SVG is plotted from the exact scored JSON.",
    "The best strict comparison uses a separate diagnostic SLSQP solve on analytic separation. After rounding, all 105 pairs have positive clearance. It gives a feasible upper bound for the zero-overlap problem.",
    "The handed results served as data. The hand-built boundary-integral routine was adapted for true circular areas. Comparator entries in inherited_results are the handed reports."
  ],
  "inherited_results": [
    {
      "input": "after-annealing",
      "sha256": "8f979bb6b01c9cb949349334957d1beb220831ee63038857fcf71b73cecf3e47",
      "reported_score": "2.97206264"
    },
    {
      "input": "after-basin-hopping",
      "sha256": "40fa4cfa3e5c2c82ecb82f7f28c5ad17771cf455cee37836c53b34061b47cb70",
      "reported_score": 2.98929011
    },
    {
      "input": "after-hand-built",
      "sha256": "38ed7fda0807c52d4aa6d2612f5a07cef42a050f7328558fe682b867207d3d08",
      "reported_score": 2.96147487
    },
    {
      "input": "after-penalty-lbfgs",
      "sha256": "bb9fa2b781a052c7a2751ba869c6d0adb055af032b1f2809b31141c6353bee5f",
      "reported_score": 3.16365945
    },
    {
      "input": "after-published",
      "sha256": "89ffaa96cbc8f60cbce1ebe7c61e0bfac270d013b5aff71bc9d5c7da1a374161",
      "reported_score": "2.94852695"
    }
  ],
  "plot_svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 388 418\" role=\"img\">\n<rect width=\"388\" height=\"418\" fill=\"#fafaf7\"/>\n<text x=\"194\" y=\"27\" text-anchor=\"middle\" font-family=\"sans-serif\" font-size=\"15\">15 unit semicircles \u00b7 R = 2.94852695</text>\n<path d=\"M194.30673 229.77068 A57.65591 57.65591 0 0 0 256.60819 132.73799 Z\" fill=\"#93bdcf\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"246.0484\" y=\"198.4751\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">0</text>\n<path d=\"M305.14660 256.23512 A57.65591 57.65591 0 0 0 213.80910 326.62175 Z\" fill=\"#b6d5dc\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"244.5413\" y=\"276.0460\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">1</text>\n<path d=\"M102.97015 226.74392 A57.65591 57.65591 0 0 0 217.69443 238.36955 Z\" fill=\"#a7c9b8\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"157.8653\" y=\"260.9020\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">2</text>\n<path d=\"M262.14013 226.82157 A57.65591 57.65591 0 0 0 338.41413 140.33982 Z\" fill=\"#ded0a1\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"318.6291\" y=\"203.7665\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">3</text>\n<path d=\"M254.37734 71.94022 A57.65591 57.65591 0 0 0 165.72177 145.67627 Z\" fill=\"#b9b7d9\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"194.4023\" y=\"93.9949\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">4</text>\n<path d=\"M153.17621 58.03909 A57.65591 57.65591 0 0 0 151.39187 173.33710 Z\" fill=\"#93bdcf\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"127.8170\" y=\"119.3094\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">5</text>\n<path d=\"M91.76633 100.94408 A57.65591 57.65591 0 0 0 108.91480 214.97366 Z\" fill=\"#b6d5dc\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"76.1427\" y=\"165.5979\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">6</text>\n<path d=\"M103.85927 168.28140 A57.65591 57.65591 0 0 0 218.45588 181.10456 Z\" fill=\"#a7c9b8\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"158.4364\" y=\"203.0111\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">7</text>\n<path d=\"M151.58061 157.43760 A57.65591 57.65591 0 0 0 240.23620 83.70158 Z\" fill=\"#ded0a1\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"211.5557\" y=\"143.3829\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">8</text>\n<path d=\"M292.01269 186.24826 A57.65591 57.65591 0 0 0 241.53076 82.57382 Z\" fill=\"#b9b7d9\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"288.7721\" y=\"127.6984\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">9</text>\n<path d=\"M45.74126 182.06105 A57.65591 57.65591 0 0 0 118.00596 271.91999 Z\" fill=\"#93bdcf\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"62.8050\" y=\"246.3256\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">10</text>\n<path d=\"M45.80027 282.22837 A57.65591 57.65591 0 0 0 160.82299 290.38858 Z\" fill=\"#b6d5dc\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"101.5800\" y=\"314.7171\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">11</text>\n<path d=\"M307.89500 346.20587 A57.65591 57.65591 0 0 0 201.16129 389.84909 Z\" fill=\"#a7c9b8\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"245.2668\" y=\"349.3779\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">12</text>\n<path d=\"M107.45542 363.21089 A57.65591 57.65591 0 0 0 189.53829 282.22190 Z\" fill=\"#ded0a1\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"165.6833\" y=\"344.1349\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">13</text>\n<path d=\"M252.76699 296.60145 A57.65591 57.65591 0 0 0 344.10282 226.21267 Z\" fill=\"#b9b7d9\" stroke=\"#365864\" stroke-width=\".9\"/>\n<text x=\"313.3719\" y=\"284.7891\" fill=\"#213840\" font-size=\"11\" text-anchor=\"middle\" font-family=\"sans-serif\">14</text>\n<circle cx=\"194\" cy=\"220\" r=\"170\" fill=\"none\" stroke=\"#213840\" stroke-width=\"1.4\"/></svg>\n",
  "final_check": {
    "checkout": "78a78626f098cd236f3a09bb2cb242f72951599d",
    "official_tests_passed": 31,
    "clean_recheck_used_offline_synced_environment": true
  },
  "search_scorer_source": "\"\"\"Run beside baseline.json, using the pinned official scorer's environment.\"\"\"\nimport itertools\nimport json\nimport sys\nimport time\nfrom functools import lru_cache\nfrom pathlib import Path\n\nimport numpy as np\nfrom scipy.optimize import minimize\nfrom scipy.spatial.distance import pdist\nfrom shapely import dwithin, intersection, area\nfrom semicircle_packing.geometry import Semicircle\nfrom semicircle_packing.scoring import validate_and_score\n\nPAIR = np.array(list(itertools.combinations(range(15), 2)))\nARC = np.linspace(-np.pi / 2, np.pi / 2, 4096)\nTOL = 1e-6\nKEYS = ('x', 'y', 'theta')\n\n\n@lru_cache(maxsize=2048)\ndef polygon(x, y, theta):\n    from shapely.geometry import Polygon\n    # Match official linspace endpoints, including floating-point operation order.\n    a = np.linspace(theta + ARC[0], theta + ARC[-1], len(ARC))\n    return Polygon(np.column_stack((x + np.cos(a), y + np.sin(a))))\n\n\ndef polygons(a):\n    return np.array([polygon(*p) for p in a], dtype=object)\n\n\ndef areas(a):\n    \"\"\"All 105 constraints, with an exact disk-distance broad phase.\"\"\"\n    p = polygons(a)\n    hits = pdist(a[:, :2]) <= 2\n    i, j = PAIR[hits].T\n    values = np.zeros(len(PAIR))\n    values[hits] = area(intersection(p[i], p[j]))\n    return values\n\n\ndef far(a, center=(0, 0), split=False):\n    \"\"\"Exact farthest radius, using the arc stationary point or a diameter endpoint.\"\"\"\n    d = a[:, :2] - center\n    u = np.column_stack((np.cos(a[:, 2]), np.sin(a[:, 2])))\n    v = u[:, ::-1] * [-1, 1]\n    sq = np.einsum('ij,ij->i', d, d)\n    along = np.einsum('ij,ij->i', d, u)\n    across = np.einsum('ij,ij->i', d, v)\n    ends = np.sqrt(1 + sq[:, None] + 2 * across[:, None] * [1, -1])\n    # The radial candidate uses the projection onto the forward half-plane.\n    # When behind the flat, this duplicates the larger endpoint constraint.\n    arc = np.sqrt(1 + sq + 2 * np.sqrt(across**2 + np.maximum(along, 0)**2))\n    return np.column_stack((ends, arc)) if split else arc\n\n\ndef rounded(a):\n    return np.array([[round(float(v), 6) for v in row] for row in a])\n\n\ndef objects(a):\n    return [dict(zip(KEYS, map(float, p))) for p in a]\n\n\ndef official(a):\n    return validate_and_score([Semicircle(*p) for p in a])\n\n\ndef perturb_polygon(p, axis, h):\n    q = p.copy()\n    q[axis] += h\n    return polygon(*q)\n\n\ndef optimize(start, budget, margin, callback, maxiter, strict=False, box=None):\n    began = time.monotonic()\n    # All geometrically near contacts plus those discovered after a local solve.\n    p = polygons(start)\n    i, j = PAIR.T\n    active = (pdist(start[:, :2]) < 2.12)\n    active[active] = dwithin(p[i[active]], p[j[active]], .12)\n    x = np.r_[start.ravel(), max(far(start))]\n    errors = []\n    for _ in range(3):\n        i, j = PAIR[active].T\n        rows = np.arange(len(i))\n        base = areas(x[:-1].reshape(15, 3))[active]\n        # Estimate the contact length (translation derivative of overlap).\n        # A smaller margin suffices for curved contacts with short boundaries.\n        a0 = x[:-1].reshape(15, 3)\n        pp = polygons(a0)\n        h0 = 2e-6\n        length = np.hypot(*[\n            (area(intersection(\n                np.array([perturb_polygon(t, axis, h0) for t in a0], dtype=object)[i],\n                pp[j])) - base) / h0 for axis in (0, 1)])\n        length = np.clip(length, .018, 2)\n        allowance = (np.full(len(i), 2e-13) if strict else\n                     TOL - np.clip(margin * length, 2e-10, .72 * TOL))\n        # sqrt compression keeps high-area violations from dominating.\n        denom = np.maximum(np.sqrt(TOL), length * 0.5 / np.sqrt(TOL))\n        cached = None\n\n        def values(z):\n            nonlocal cached\n            if cached is None or not np.array_equal(cached[0], z):\n                a = z[:-1].reshape(15, 3)\n                p = polygons(a)\n                ar = area(intersection(p[i], p[j]))\n                cached = z.copy(), a, p, ar\n            return cached[1:]\n\n        direction = np.column_stack((np.cos(a0[:, 2]), np.sin(a0[:, 2])))\n        use = np.ones((15, 3), dtype=bool)\n        if box is not None:\n            limit = box * (np.sqrt(2) + np.linalg.norm(a0[:, :2], axis=1))\n            inward = np.sum(direction*a0[:, :2], axis=1) < -limit\n            use[inward, 2] = False\n        select = np.r_[use.ravel(), np.ones(len(i), dtype=bool)]\n\n        def constraints(z):\n            a, _, ar = values(z)\n            return np.r_[z[-1] - far(a, split=True).ravel(),\n                         (np.sqrt(allowance + TOL) - np.sqrt(ar + TOL)) / denom][select]\n\n        def jac(z):\n            a, p, ar = values(z)\n            h = 2e-8\n            mat = np.zeros((45 + len(i), 46))\n            original = far(a, split=True).ravel()\n            for axis in range(3):\n                q = a.copy()\n                q[:, axis] += h\n                mat[np.arange(45), 3 * (np.arange(45) // 3) + axis] = (original - far(q, split=True).ravel()) / h\n                shifted = np.array([perturb_polygon(t, axis, h) for t in a], dtype=object)\n                factor = -0.5 / (h * np.sqrt(ar + TOL) * denom)\n                mat[45 + rows, 3 * i + axis] = (area(intersection(shifted[i], p[j])) - ar) * factor\n                if axis < 2:\n                    mat[45 + rows, 3 * j + axis] = -mat[45 + rows, 3 * i + axis]\n                else:\n                    mat[45 + rows, 3 * j + axis] = (area(intersection(p[i], shifted[j])) - ar) * factor\n            mat[:45, -1] = 1\n            return mat[select]\n\n        last = [x.copy()]\n\n        def step(z):\n            last[0] = z.copy()\n            callback(z[:-1].reshape(15, 3), False)\n            if time.monotonic() - began >= budget:\n                raise TimeoutError\n\n        objective_gradient = np.r_[np.zeros(45), 1.]\n        try:\n            opt = minimize(lambda z: z[-1], x, jac=lambda z: objective_gradient,\n                           method='SLSQP',\n                           bounds=None if box is None else [(v-box, v+box) for v in x[:-1]] + [(1,None)],\n                           constraints=[{'type': 'ineq', 'fun': constraints,\n                                                         'jac': jac}],\n                           callback=step, options={'maxiter': maxiter, 'ftol': 2e-12})\n            x = opt.x\n            if not opt.success:\n                errors.append(opt.message)\n        except TimeoutError:\n            x = last[0]\n            errors.append('Optimization time budget reached')\n        a = x[:-1].reshape(15, 3)\n        callback(a, True)\n        violation = (areas(a) > (2e-12 if strict else TOL)) & ~active\n        if not violation.any() or time.monotonic() - began >= budget:\n            break\n        active |= violation\n    return a, errors\n\n\ndef fresh(rng):\n    # Independent randomized triangular grid with one corner omitted.\n    a = np.array([(2.04*(i+.5*(j % 2)), 1.77*j)\n                  for j in range(4) for i in range(4) if (i,j) != (3,3)])\n    a -= a.mean(axis=0)\n    a += rng.normal(0, .16, a.shape)\n    rng.shuffle(a)\n    return np.column_stack((a, rng.uniform(-np.pi, np.pi, len(a))))\n\n\ndef expand(a):\n    other = a.copy()\n    # Preserve shape orientation. Keep a valid upper bracket throughout.\n    lo = 1.\n    hi = max(1.000001, 2.000005 / min(pdist(a[:,:2])))\n    for _ in range(25):\n        k = (lo+hi)/2\n        other[:,:2] = a[:,:2]*k\n        if max(areas(rounded(other))) <= TOL:\n            hi = k\n        else:\n            lo = k\n    other[:,:2] = a[:,:2]*hi\n    return rounded(other)\n\n\nfrom scipy.optimize import Bounds, LinearConstraint, milp\n\n\n\ndef lattice(a, center, seconds, margin, seams=True):\n    \"\"\"Integer micro-coordinate repair around one rounded geometry.\"\"\"\n    a = rounded(a)\n    n = np.flatnonzero(areas(a) > 1e-7)\n    i, j = PAIR[n].T\n    p = polygons(a)\n    aa = area(intersection(p[i], p[j]))\n    geom = far(a, center, True).ravel()\n    mat = np.zeros((len(n)+45, 48))\n    k = np.arange(len(n))\n    h = 2e-8\n    for axis in range(3):\n        q = a.copy()\n        q[:,axis] += h\n        plus = polygons(q)\n        q[:,axis] -= 2*h\n        minus = polygons(q)\n        mat[k,3*i+axis] = (area(intersection(plus[i],p[j])) -\n                           area(intersection(minus[i],p[j]))) / (2*h)\n        mat[k,3*j+axis] = -mat[k,3*i+axis] if axis < 2 else (\n            area(intersection(p[i],plus[j]))-area(intersection(p[i],minus[j]))) / (2*h)\n        mat[len(n)+np.arange(45),3*(np.arange(45)//3)+axis] = (\n            far(q+h*2*np.eye(3)[axis],center,True).ravel()-\n            far(q,center,True).ravel())/(2*h)\n    mat[len(n):,45:47] = -mat[len(n):,:45].reshape(45,15,3).sum(axis=1)[:,:2]\n    mat[len(n):,47] = -1\n    bound = np.r_[(1e-6-margin-aa)*1e6,(max(geom)-geom)*1e6]\n    for left, right in (zip(i, j) if seams else ()):\n        t = a[left,2]\n        alpha = (a[right,2]-t)%(2*np.pi)-np.pi\n        if abs(alpha) > 0.001:\n            continue\n        u = np.array([np.cos(t),np.sin(t)])\n        v = u[::-1]*[-1,1]\n        delta = a[right,:2]-a[left,:2]\n        normal, slide = delta@u, delta@v\n        if abs(normal) > 0.001 or abs(slide) >= 1.99:\n            continue\n        low, high = max(-1.,slide-1.), min(1.,slide+1.)\n        split = np.linspace(low,high,33)\n        l, r = np.r_[np.full(32,low),split[:-1]], np.r_[split[1:],np.full(32,high)]\n        width, mid = r-l,(r+l)/2\n        slope = np.tan(alpha)\n        cut = np.zeros((len(l),48))\n        cut[:,3*left:3*left+2] = -width[:,None]*(u+slope*v)\n        cut[:,3*right:3*right+2] = -cut[:,3*left:3*left+2]\n        cut[:,3*left+2] = width*mid\n        cut[:,3*right+2] = -width*(mid-slide)*(1+slope*slope)\n        mat = np.r_[mat,cut]\n        bound = np.r_[bound,(1e-6-max(margin,1e-9)-width*(normal-slope*(mid-slide)))*1e6]\n    # Normalize area rows to local contact sensitivity.\n    scale = np.maximum(np.linalg.norm(mat,axis=1),.01)\n    opt = milp(np.r_[np.zeros(47),1.], integrality=np.r_[np.ones(45),0,0,0],\n               bounds=Bounds(np.r_[np.full(47,-4.),-20.], np.r_[np.full(47,4.),20.]),\n               constraints=LinearConstraint(mat/scale[:,None], -np.inf, bound/scale),\n               options={'time_limit': seconds, 'mip_rel_gap': 0.001})\n    return None if opt.x is None else rounded(a+np.rint(opt.x[:45]).reshape(15,3)*1e-6)\n\n\nfrom math import acos, atan2, cos, hypot, pi, sin, sqrt\n\nfrom scipy.spatial import ConvexHull\n\n\n\ndef _parts(a, b):\n    \"\"\"Green's theorem boundary integral over the part of A inside B.\n\n    Adapted from after-hand-built/result.json, scorer_source.\n    \"\"\"\n    dx, dy = a[0]-b[0], a[1]-b[1]\n    t, nx, ny = a[2], cos(b[2]), sin(b[2])\n    start, end = t-pi/2, t+pi/2\n    cuts = [start, end]\n    d = hypot(dx, dy)\n    for x, y, offset in ((dx, dy, -d*d/2), (nx, ny, -dx*nx-dy*ny)):\n        norm = hypot(x, y)\n        if norm > 1e-15 and abs(offset) < norm:\n            angle = atan2(y, x)\n            delta = acos(offset/norm)\n            for root in (angle-delta, angle+delta):\n                q = start+(root-start)%(2*pi)\n                if start < q < end:\n                    cuts.append(q)\n    result = 0.\n    cuts.sort()\n    for l, r in zip(cuts, cuts[1:]):\n        m = (l+r)/2\n        x, y = dx+cos(m), dy+sin(m)\n        if x*x+y*y <= 1+1e-13 and x*nx+y*ny >= -1e-13:\n            result += (.5 if d < 1e-14 else 1.) * (\n                r-l+a[0]*(sin(r)-sin(l))-a[1]*(cos(r)-cos(l)))\n    vx, vy = sin(t), -cos(t)\n    px, py = dx-vx, dy-vy\n    dot, perpendicular = px*vx+py*vy, px*vy-py*vx\n    if abs(perpendicular) >= 1:\n        return result\n    half = sqrt(1-perpendicular**2)\n    lo, hi = max(0., -dot-half), min(2., -dot+half)\n    slope, height = vx*nx+vy*ny, px*nx+py*ny\n    weight = 1.\n    if slope > 1e-14:\n        lo = max(lo, -height/slope)\n    elif slope < -1e-14:\n        hi = min(hi, -height/slope)\n    elif height < -1e-14:\n        return result\n    elif abs(height) <= 1e-14:\n        if cos(t-b[2]) < 0:\n            return 0. if abs(sin(t-b[2])) < 1e-14 else result\n        weight = .5\n    return result+weight*max(0., hi-lo)*(a[0]*vy-a[1]*vx)\n\n\ndef circular_area(a, b):\n    if hypot(*(a[:2]-b[:2])) >= 2:\n        return 0.\n    if abs(sin(a[2]-b[2])) < 1e-14 and cos(a[2]-b[2]) < 0:\n        if abs(np.dot(a[:2]-b[:2], [cos(a[2]),sin(a[2])])) < 1e-14:\n            return 0.\n    aa = (0., 0., a[2])\n    bb = (*tuple(b[:2]-a[:2]), b[2])\n    return max(0., (_parts(aa, bb)+_parts(bb, aa))/2)\n\n\ndef mec(a):\n    u = np.column_stack((np.cos(a[:, 2]), np.sin(a[:, 2])))\n    v = u[:, ::-1] * [-1, 1]\n    xy = a[:, :2]\n    pts = np.r_[xy+v, xy-v, xy+u]\n    for _ in range(32):\n        p = pts[ConvexHull(pts).vertices]\n        pairs = np.array(list(itertools.combinations(p, 2)))\n        abc = np.array(list(itertools.combinations(p, 3)))\n        x, y = (abc[:, i] - abc[:, 0] for i in (1, 2))\n        det = 2*(x[:, 0]*y[:, 1]-x[:, 1]*y[:, 0])\n        use = abs(det) > 1e-13\n        x, y, det = x[use], y[use], det[use]\n        xx, yy = (np.sum(k*k, axis=1) for k in (x, y))\n        centers = np.r_[pairs.mean(axis=1), abc[use, 0] +\n                        np.column_stack((xx*y[:, 1]-yy*x[:, 1],\n                                         yy*x[:, 0]-xx*y[:, 0]))/det[:, None]]\n        rs = np.max(np.linalg.norm(centers[:, None]-p, axis=2), axis=1)\n        k = np.argmin(rs)\n        q = centers[k]\n        d = xy-q\n        length = np.linalg.norm(d, axis=1)\n        arc = np.sum(d*u, axis=1) >= 0\n        ext = xy + v*np.where(np.sum(d*v, axis=1) >= 0, 1, -1)[:, None]\n        ext[arc] = xy[arc] + d[arc]/np.maximum(length[arc, None], 1e-30)\n        upper = max(far(a, q))\n        if upper-rs[k] < 2e-12:\n            return (*q, upper)\n        pts = np.r_[pts, ext[np.linalg.norm(ext-q, axis=1) > rs[k]+1e-13]]\n    raise RuntimeError('MEC exchange did not close the bound')\n\n\ndef score(a, circular=False):\n    a = rounded(a)\n    if a.shape != (15, 3) or not np.isfinite(a).all():\n        return None\n    largest = max(circular_area(a[i], a[j]) for i, j in PAIR) if circular else max(areas(a))\n    return None if largest > TOL else mec(a)[-1]\n",
  "runtime": {
    "python": "3.14.4",
    "numpy": "2.5.5",
    "scipy": "1.18.1",
    "shapely": "2.2.0"
  },
  "commands": {
    "setup": [
      "git clone https://github.com/benedictbrady/shape-packing-challenge official",
      "cd official",
      "git checkout --detach 78a78626f098cd236f3a09bb2cb242f72951599d",
      "uv sync",
      "uv run python run.py",
      "uv pip install scipy"
    ],
    "extract": "Extract search_scorer_source as packing.py, solution_json as solution.json, and inherited_baseline.solution as input coordinates beside the official clone. Use its .venv/bin/python to import packing.",
    "baseline_local": "a = np.array([[p[k] for k in KEYS] for p in input_coordinates]); a[:, :2] -= official(a).mec[:2]; candidate, errors = optimize(a, 40, 0, lambda a,force: None, 120, box=2e-5)",
    "seed_derivation": "int(np.random.SeedSequence(22001).spawn(index + 1)[index].generate_state(1)[0])",
    "fresh": "a = expand(fresh(np.random.default_rng(seed))); call optimize with margin .15e-6, 45 iterations and box cycling .24,.12,.06,.03. Apply expand before official validation and recenter on the best scored MEC before the next attempt.",
    "lattice": "Round and linearize small rigid transforms of baseline_local. Starting at angle 0, then use rng.uniform(-pi,pi), plus uniform \u00b10.5e-6 x/y translations. Wrap each rotated theta with (theta + pi) % (2*pi) - pi. In run 7 call lattice(b, np.zeros(2), 2.5, margin, seams=False) with margins 0,3e-10,1.3e-9,0,2e-9; in run 10 use 3 seconds, seam cuts, and replace the third margin with 1e-9. Check all areas and official(r) after rounding.",
    "extraction_shell": [
      "jq -r .search_scorer_source result.json > packing.py",
      "jq -rj .solution_json result.json > solution.json",
      "jq .inherited_baseline.solution result.json > input_coordinates.json"
    ],
    "replay_run_10": "OPENBLAS_NUM_THREADS=1 timeout 465s official/.venv/bin/python - <<'PY'\nfrom packing import *\na=np.array([[p[k] for k in KEYS] for p in json.load(open('input_coordinates.json'))])\na[:,:2]-=official(a).mec[:2]\na,_=optimize(a,40,0,lambda a,force:None,120,box=2e-5)\nrng=np.random.default_rng(3661066181)\nbest=float('inf')\ndeadline=time.monotonic()+390\nfor k in range(130):\n    if time.monotonic()>=deadline:\n        break\n    angle=0 if k==0 else rng.uniform(-np.pi,np.pi)\n    c,s=np.cos(angle),np.sin(angle)\n    b=a.copy()\n    b[:,:2]=b[:,:2]@[[c,s],[-s,c]]+rng.uniform(-.5e-6,.5e-6,2)\n    b[:,2]=(b[:,2]+angle+np.pi)%(2*np.pi)-np.pi\n    b=lattice(b,np.zeros(2),3,[0,3e-10,1e-9,0,2e-9][k%5])\n    if b is not None and max(areas(b))<=TOL:\n        r=official(b)\n        if r.valid and r.score<best:\n            best=r.score\n            Path('replayed.json').write_text(json.dumps(objects(b)))\n            print(k,r.score,flush=True)\nPY\n",
    "final": [
      "uv run python run.py ../solution.json --save-plot ../official-plot.svg",
      "uv run python -c 'import json,sys\nfrom run import _load_solution\nfrom semicircle_packing.scoring import validate_and_score\nr=validate_and_score(_load_solution(sys.argv[1]))\nprint(json.dumps(dict(valid=r.valid, score=r.score, mec=r.mec, errors=r.errors)))\nassert r.valid' ../solution.json"
    ]
  }
}
