{
  "method": "Remove one semicircle, rank 120 gap/angle proposals, select among best six, then joint SLSQP repair using exact support-separation and analytic containment. Separate contact-specific analytic-area local repair probes the official overlap tolerance. No boundary/interior membership constraints.",
  "seed": 23001,
  "derived_seeds": [
    826642270,
    700072903,
    1904490920,
    596237290,
    850229626,
    838169699
  ],
  "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": {
    "x": -0.0001819080616875258,
    "y": 0.00013448997007248039,
    "radius": 2.948526950912552
  },
  "max_pair_area": 9.997822348073144e-07,
  "max_pair_area_kind": "official 4096-point polygons",
  "inherited_baseline": {
    "selected": true,
    "official_valid": true,
    "official_score_full": 2.948526950912552,
    "official_score": "2.94852695",
    "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
      }
    ],
    "provenance": "Coordinates supplied in task; published packing, not a new record."
  },
  "best_new_score": 2.9485410237249945,
  "best_fresh_score": 3.0303876728689625,
  "strict_radius": null,
  "structure": {
    "full_disk_pairs": 0,
    "description": "Asymmetric arrangement; no shared disk centers. Two near-opposite sliding seams, not full disks. Curved arcs and diameter endpoints support the enclosing circle. No symmetry was imposed.",
    "baseline_measurements": {
      "sliding_seams": [
        {
          "pair": [
            1,
            14
          ],
          "angle_error": 2.365358979350418e-05,
          "normal_offset": 3.190160845822909e-06,
          "slide": 0.8530378735524133
        },
        {
          "pair": [
            4,
            8
          ],
          "angle_error": 3.464102071859543e-07,
          "normal_offset": 5.835752388549942e-07,
          "slide": 0.3190127393814539
        }
      ],
      "boundary_indices": [
        3,
        4,
        5,
        6,
        9,
        10,
        11,
        12,
        13,
        14
      ]
    },
    "flat_edges": "Two sliding seams (1,14) and (4,8); piece 12 points its curved side inward and its two diameter endpoints reach the rim. Other flats cross interior gaps.",
    "boundary_support": "Baseline: ten boundary pieces; nine supported by arcs and piece 12 by diameter endpoints.",
    "indexing": "zero-based"
  },
  "scorer_check": {
    "pair_cases": 250,
    "area_validity_disagreements": [],
    "max_area_difference": 1.804654903292402e-07,
    "mec_cases": 20,
    "max_radius_difference": 5.089262344881718e-13,
    "rounding": 6,
    "method": "analytic Green boundary integrals; analytic support separation; SLSQP analytic-farthest-point MEC",
    "baseline_tight_pairs": 105,
    "baseline_exact_vs_official_disagreements": [
      {
        "pair": [
          1,
          3
        ],
        "analytic_area": 1.0013726919593652e-06,
        "official_polygon_area": 9.99594025502215e-07
      },
      {
        "pair": [
          1,
          13
        ],
        "analytic_area": 1.0003480671780772e-06,
        "official_polygon_area": 9.985677175080334e-07
      },
      {
        "pair": [
          2,
          11
        ],
        "analytic_area": 1.0007703993338696e-06,
        "official_polygon_area": 9.996466942502033e-07
      },
      {
        "pair": [
          3,
          9
        ],
        "analytic_area": 1.0007205213311e-06,
        "official_polygon_area": 9.995983747504195e-07
      },
      {
        "pair": [
          7,
          8
        ],
        "analytic_area": 1.0001613894288636e-06,
        "official_polygon_area": 9.990352164717355e-07
      },
      {
        "pair": [
          8,
          9
        ],
        "analytic_area": 1.0008169198938432e-06,
        "official_polygon_area": 9.996957770875582e-07
      }
    ],
    "degenerate_cases": 4,
    "degenerate_max_area_difference": 1.5408506626179985e-07,
    "separation_cases": 10500,
    "separation_disagreements": 0
  },
  "runs": [
    {
      "seed": 1904490920,
      "start_kind": "fresh",
      "minutes": 7.028436592732517,
      "attempts": 66,
      "valid_count": 66,
      "best_radius": 3.0303876728689625,
      "score_kind": "official, rounded 6 decimals",
      "errors": [
        {
          "attempt": 0,
          "errors": [
            "Semicircles 3 and 6 overlap",
            "Semicircles 5 and 10 overlap"
          ]
        },
        {
          "attempt": 1,
          "errors": [
            "Semicircles 1 and 13 overlap",
            "Semicircles 5 and 10 overlap"
          ]
        },
        {
          "attempt": 2,
          "errors": [
            "Semicircles 5 and 10 overlap"
          ]
        },
        {
          "attempt": 4,
          "errors": [
            "Semicircles 3 and 6 overlap"
          ]
        },
        {
          "attempt": 5,
          "errors": [
            "Semicircles 5 and 10 overlap"
          ]
        }
      ],
      "error_examples_truncated": true,
      "exit_code": 0,
      "completed": true,
      "indices_attempted": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14
      ],
      "gap_proposals_per_attempt": 120
    },
    {
      "seed": 596237290,
      "start_kind": "baseline contact-specific exact-area local repair",
      "minutes": 3.0527912997669775,
      "attempts": 11,
      "valid_count": 0,
      "best_radius": null,
      "score_kind": "official rounded 6 decimals",
      "errors": [
        {
          "attempt": 1,
          "errors": [
            "Semicircles 0 and 8 overlap",
            "Semicircles 1 and 2 overlap",
            "Semicircles 2 and 11 overlap",
            "Semicircles 4 and 8 overlap",
            "Semicircles 5 and 6 overlap",
            "Semicircles 6 and 7 overlap",
            "Semicircles 8 and 9 overlap"
          ]
        },
        {
          "attempt": 2,
          "errors": [
            "Semicircles 1 and 12 overlap",
            "Semicircles 1 and 13 overlap",
            "Semicircles 1 and 14 overlap",
            "Semicircles 2 and 11 overlap",
            "Semicircles 3 and 9 overlap",
            "Semicircles 4 and 5 overlap",
            "Semicircles 6 and 10 overlap",
            "Semicircles 7 and 8 overlap",
            "Semicircles 12 and 14 overlap"
          ]
        },
        {
          "attempt": 3,
          "errors": [
            "Semicircles 0 and 3 overlap",
            "Semicircles 0 and 8 overlap",
            "Semicircles 0 and 9 overlap",
            "Semicircles 1 and 14 overlap",
            "Semicircles 2 and 7 overlap",
            "Semicircles 4 and 5 overlap",
            "Semicircles 6 and 7 overlap",
            "Semicircles 8 and 9 overlap",
            "Semicircles 11 and 13 overlap",
            "Semicircles 12 and 14 overlap"
          ]
        },
        {
          "attempt": 4,
          "errors": [
            "Semicircles 0 and 1 overlap",
            "Semicircles 0 and 9 overlap",
            "Semicircles 1 and 14 overlap",
            "Semicircles 2 and 7 overlap",
            "Semicircles 2 and 10 overlap",
            "Semicircles 4 and 5 overlap",
            "Semicircles 4 and 9 overlap",
            "Semicircles 5 and 6 overlap",
            "Semicircles 5 and 7 overlap",
            "Semicircles 5 and 8 overlap",
            "Semicircles 6 and 7 overlap",
            "Semicircles 6 and 10 overlap",
            "Semicircles 7 and 8 overlap",
            "Semicircles 8 and 9 overlap",
            "Semicircles 10 and 11 overlap",
            "Semicircles 11 and 13 overlap",
            "Semicircles 12 and 13 overlap"
          ]
        },
        {
          "attempt": 5,
          "errors": [
            "Semicircles 1 and 12 overlap",
            "Semicircles 1 and 13 overlap",
            "Semicircles 1 and 14 overlap",
            "Semicircles 2 and 7 overlap",
            "Semicircles 2 and 11 overlap",
            "Semicircles 4 and 8 overlap",
            "Semicircles 5 and 6 overlap",
            "Semicircles 6 and 7 overlap",
            "Semicircles 10 and 11 overlap",
            "Semicircles 12 and 14 overlap"
          ]
        },
        "Command exited 143; counters and best solution are from last saved checkpoint, not final progress."
      ],
      "error_examples_truncated": true,
      "exit_code": 143,
      "completed": false
    },
    {
      "seed": 700072903,
      "start_kind": "fresh",
      "minutes": 4.893034249567426,
      "attempts": 50,
      "valid_count": 36,
      "best_radius": 3.04629422644774,
      "score_kind": "official, rounded 6 decimals",
      "errors": [
        {
          "attempt": 2,
          "errors": [
            "Semicircles 1 and 11 overlap",
            "Semicircles 6 and 13 overlap"
          ]
        },
        {
          "attempt": 3,
          "errors": [
            "Semicircles 1 and 11 overlap",
            "Semicircles 6 and 13 overlap"
          ]
        },
        {
          "attempt": 4,
          "errors": [
            "Semicircles 6 and 13 overlap"
          ]
        },
        {
          "attempt": 5,
          "errors": [
            "Semicircles 6 and 13 overlap"
          ]
        },
        {
          "attempt": 5,
          "errors": [
            "Semicircles 6 and 13 overlap"
          ]
        },
        "Command exited 143; counters and best solution are from last saved checkpoint, not final progress."
      ],
      "error_examples_truncated": true,
      "exit_code": 143,
      "completed": false,
      "indices_attempted": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14
      ],
      "gap_proposals_per_attempt": 120
    },
    {
      "seed": 826642270,
      "start_kind": "baseline",
      "minutes": 3.974241161182484,
      "attempts": 41,
      "valid_count": 56,
      "best_radius": 2.948680927770609,
      "score_kind": "official, rounded 6 decimals",
      "errors": [
        {
          "attempt": 1,
          "errors": [
            "Semicircles 4 and 8 overlap"
          ]
        },
        {
          "attempt": 1,
          "errors": [
            "Semicircles 4 and 8 overlap"
          ]
        },
        {
          "attempt": 3,
          "errors": [
            "Semicircles 4 and 8 overlap"
          ]
        },
        {
          "attempt": 5,
          "errors": [
            "Semicircles 1 and 14 overlap"
          ]
        },
        {
          "attempt": 11,
          "errors": [
            "Semicircles 1 and 14 overlap"
          ]
        },
        "Command exited 143; counters and best solution are from last saved checkpoint, not final progress."
      ],
      "error_examples_truncated": true,
      "exit_code": 143,
      "completed": false,
      "indices_attempted": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14
      ],
      "gap_proposals_per_attempt": 120
    },
    {
      "seed": 850229626,
      "start_kind": "baseline contact-specific exact-area local repair",
      "minutes": 2.0204576258334175,
      "attempts": 8,
      "valid_count": 7,
      "best_radius": 2.9485410237249945,
      "score_kind": "official rounded 6 decimals",
      "errors": [
        {
          "attempt": 2,
          "errors": [
            "Semicircles 1 and 14 overlap",
            "Semicircles 4 and 8 overlap"
          ]
        }
      ],
      "error_examples_truncated": false,
      "exit_code": 0,
      "completed": true
    }
  ],
  "strategy_table": [
    {
      "strategy": "fresh",
      "seed": 1904490920,
      "best_radius": 3.0303876728689625
    },
    {
      "strategy": "baseline contact-specific exact-area local repair",
      "seed": 596237290,
      "best_radius": null
    },
    {
      "strategy": "fresh",
      "seed": 700072903,
      "best_radius": 3.04629422644774
    },
    {
      "strategy": "baseline",
      "seed": 826642270,
      "best_radius": 2.948680927770609
    },
    {
      "strategy": "baseline contact-specific exact-area local repair",
      "seed": 850229626,
      "best_radius": 2.9485410237249945
    }
  ],
  "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/scoring.py"
  ],
  "plot_svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"720\" height=\"760\" viewBox=\"-3.3 -3.5 6.6 7\"><rect x=\"-3.3\" y=\"-3.5\" width=\"6.6\" height=\"7\" fill=\"white\"/><text x=\"0\" y=\"-3.2\" text-anchor=\"middle\" font-size=\"0.16\">15 unit semicircles; R=2.94852695</text><g transform=\"scale(1,-1)\"><circle cx=\"-0.0001819080616875258\" cy=\"0.00013448997007248039\" r=\"2.948526950912552\" fill=\"none\" stroke=\"#bd2020\" stroke-width=\".025\"/><path d=\"M 0.005138116 -0.169330887 A 1 1 0 0 1 1.085711884 1.513630887 Z\" fill=\"hsl(0,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M 1.927575381 -0.628337474 A 1 1 0 0 1 0.343392619 -1.849142526 Z\" fill=\"hsl(137,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M -1.579028775 -0.116833909 A 1 1 0 0 1 0.410780775 -0.318472091 Z\" fill=\"hsl(274,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M 1.181659358 -0.118180643 A 1 1 0 0 1 2.504576642 1.381782643 Z\" fill=\"hsl(51,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M 1.047019330 2.568124224 A 1 1 0 0 1 -0.490647330 1.289225776 Z\" fill=\"hsl(188,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M -0.708240964 2.809229270 A 1 1 0 0 1 -0.739189036 0.809468730 Z\" fill=\"hsl(325,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M -1.773350970 2.065073253 A 1 1 0 0 1 -1.475923030 0.087312747 Z\" fill=\"hsl(102,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M -1.563607579 0.897156190 A 1 1 0 0 1 0.423987579 0.674747810 Z\" fill=\"hsl(239,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M -0.735915552 1.085234042 A 1 1 0 0 1 0.801751552 2.364131958 Z\" fill=\"hsl(16,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M 1.699777294 0.585533937 A 1 1 0 0 1 0.824204706 2.383692063 Z\" fill=\"hsl(153,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M -2.571622460 0.658158094 A 1 1 0 0 1 -1.318243540 -0.900380094 Z\" fill=\"hsl(290,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M -2.570598910 -1.079171525 A 1 1 0 0 1 -0.575613090 -1.220704475 Z\" fill=\"hsl(67,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M 1.975244435 -2.188814916 A 1 1 0 0 1 0.124025565 -2.945775084 Z\" fill=\"hsl(204,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M -1.501234994 -2.483754752 A 1 1 0 0 1 -0.077567006 -1.079059248 Z\" fill=\"hsl(341,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/><path d=\"M 1.019089057 -1.328462262 A 1 1 0 0 1 2.603242943 -0.107619738 Z\" fill=\"hsl(118,45%,78%)\" stroke=\"#333\" stroke-width=\".009\"/></g><text x=\"0.898847\" y=\"-0.445230\" font-size=\".13\" text-anchor=\"middle\">0</text><text x=\"0.879115\" y=\"0.906062\" font-size=\".13\" text-anchor=\"middle\">1</text><text x=\"-0.626468\" y=\"0.635513\" font-size=\".13\" text-anchor=\"middle\">2</text><text x=\"2.158110\" y=\"-0.353988\" font-size=\".13\" text-anchor=\"middle\">3</text><text x=\"0.009617\" y=\"-2.251585\" font-size=\".13\" text-anchor=\"middle\">4</text><text x=\"-1.143665\" y=\"-1.815848\" font-size=\".13\" text-anchor=\"middle\">5</text><text x=\"-2.039967\" y=\"-1.013733\" font-size=\".13\" text-anchor=\"middle\">6</text><text x=\"-0.616516\" y=\"-0.368557\" font-size=\".13\" text-anchor=\"middle\">7</text><text x=\"0.301487\" y=\"-1.401773\" font-size=\".13\" text-anchor=\"middle\">8</text><text x=\"1.639604\" y=\"-1.668483\" font-size=\".13\" text-anchor=\"middle\">9</text><text x=\"-2.272226\" y=\"0.384321\" font-size=\".13\" text-anchor=\"middle\">10</text><text x=\"-1.602828\" y=\"1.568885\" font-size=\".13\" text-anchor=\"middle\">11</text><text x=\"0.890673\" y=\"2.178539\" font-size=\".13\" text-anchor=\"middle\">12</text><text x=\"-0.494415\" y=\"2.080377\" font-size=\".13\" text-anchor=\"middle\">13</text><text x=\"2.067543\" y=\"1.050713\" font-size=\".13\" text-anchor=\"middle\">14</text></svg>",
  "search_scorer_source": {
    "search.py": "import json,time,sys,math\nfrom pathlib import Path\nimport numpy as np\nfrom scipy.optimize import minimize\nfrom semicircle_packing.geometry import Semicircle,semicircle_polygon\nfrom semicircle_packing.scoring import validate_and_score,compute_mec\nP=Path(__file__).parent\nI,J=np.triu_indices(15,1)\ndef objects(a): return [dict(zip(('x','y','theta'),map(float,v))) for v in np.round(a,6)]\ndef official(a): return validate_and_score([Semicircle(**v) for v in objects(a)])\ndef geom(a):\n c=a[:,:2];n=np.column_stack((np.cos(a[:,2]),np.sin(a[:,2])));t=np.column_stack((-n[:,1],n[:,0]));return c,n,t\n# Finite candidate separating axes: flat normals, arc/arc normals,\n# endpoint/arc normals and endpoint/endpoint normals. Both signs tested.\ndef gaps(a):\n c,n,t=geom(a);d=c[J]-c[I];ei=c[I,None,:]+np.array([-1,1])[None,:,None]*t[I,None,:];ej=c[J,None,:]+np.array([-1,1])[None,:,None]*t[J,None,:]\n v=np.concatenate((n[I,None,:],n[J,None,:],d[:,None,:],(ej[:,:,None,:]-ei[:,None,:,:]).reshape(-1,4,2),ej-c[I,None,:],c[J,None,:]-ei),axis=1)\n v=v/np.maximum(np.linalg.norm(v,axis=2,keepdims=True),1e-30);v=np.concatenate((v,-v),axis=1)\n ni=np.einsum('pki,pi->pk',v,n[I]);nj=np.einsum('pki,pi->pk',-v,n[J])\n hi=np.where(ni>=0,1,np.abs(np.einsum('pki,pi->pk',v,t[I])))\n hj=np.where(nj>=0,1,np.abs(np.einsum('pki,pi->pk',v,t[J])))\n return np.max(np.einsum('pki,pi->pk',v,d)-hi-hj,axis=1)\ndef far(a,q):\n c,n,t=geom(a);d=c-q;r=np.linalg.norm(d,axis=1)\n return np.where(np.sum(d*n,axis=1)>=0,r+1,np.sqrt(r*r+1+2*np.abs(np.sum(d*t,axis=1))))\ndef own_mec(a):\n q=np.mean(a[:,:2],axis=0);x=np.r_[q,max(far(a,q))]\n r=minimize(lambda x:x[2],x,method='SLSQP',constraints=[{'type':'ineq','fun':lambda x:x[2]-far(a,x[:2])}],options={'ftol':1e-12,'maxiter':200})\n return [*r.x[:2],float(max(far(a,r.x[:2])))]\ndef area(a,b):\n # Green's theorem on portions of each true circular arc and diameter\n # inside the other semicircle. Trigonometric roots split the arcs exactly.\n cs=np.array([a[:2],b[:2]]);ns=np.array([[math.cos(a[2]),math.sin(a[2])],[math.cos(b[2]),math.sin(b[2])]])\n dist=np.linalg.norm(cs[0]-cs[1])\n if dist>2:return 0.\n angle=abs(math.atan2(math.sin(a[2]-b[2]),math.cos(a[2]-b[2])))\n if dist<1e-12:return max(0.,math.pi-angle)/2\n if angle<1e-12 and abs(np.dot(cs[0]-cs[1],ns[0]))<1e-12:\n  return math.acos(dist/2)-dist*math.sqrt(max(0.,4-dist*dist))/4\n total=0.\n for k in range(2):\n  c=cs[k];o=cs[1-k];n=ns[k];m=ns[1-k];th=[a[2],b[2]][k];lo=th-math.pi/2;hi=th+math.pi/2;d=c-o\n  cuts=[lo,hi]\n  # Conditions d.u <= -|d|^2/2 for second disk, m.u >= -m.d\n  for v,h in [(d,-np.dot(d,d)/2),(m,-np.dot(m,d))]:\n   norm=np.linalg.norm(v)\n   if norm>1e-14 and abs(h/norm)<=1:\n    alpha=math.atan2(v[1],v[0]);beta=math.acos(np.clip(h/norm,-1,1))\n    for z in [alpha-beta,alpha+beta]:\n     z=lo+(z-lo)%(2*math.pi)\n     if lo<z<hi:cuts.append(z)\n  cuts=sorted(cuts)\n  for l,h in zip(cuts[:-1],cuts[1:]):\n   z=(l+h)/2;u=np.array([math.cos(z),math.sin(z)]);p=d+u\n   if np.dot(p,p)<=1+1e-12 and np.dot(p,m)>=-1e-12 and not(k==1 and np.linalg.norm(d)<1e-12):\n    total+=(h-l+c[0]*(math.sin(h)-math.sin(l))+c[1]*(math.cos(l)-math.cos(h)))/2\n  t=np.array([-n[1],n[0]]);l=-1.;h=1.\n  # diameter runs from +t to -t; integrate reversed parameter\n  dot=np.dot(d,t);disc=dot*dot+1-np.dot(d,d)\n  if disc<0:continue\n  l=max(l,-dot-math.sqrt(disc));h=min(h,-dot+math.sqrt(disc));v=np.dot(t,m);w=np.dot(d,m)\n  if abs(v)<1e-14:\n   if w< -1e-12:continue\n  elif v>0:l=max(l,-w/v)\n  else:h=min(h,-w/v)\n  if h>l:total-=(h-l)*(c[0]*t[1]-c[1]*t[0])/2\n return max(0.,float(total))\ndef repair(a,maxiter=150,allow=0.):\n x=np.r_[a.ravel(),max(far(a,np.zeros(2)))]\n def cons(x):\n  a=x[:-1].reshape(15,3)\n  return np.r_[gaps(a)+allow,x[-1]-far(a,np.zeros(2))]\n r=minimize(lambda x:x[-1],x,method='SLSQP',constraints=[{'type':'ineq','fun':cons}],options={'ftol':2e-10,'maxiter':maxiter})\n return r.x[:-1].reshape(15,3),r\n\ndef check():\n rng=np.random.default_rng(23001);base=np.array(json.load(open(P/'baseline.json')));r=official(base)\n print('BASELINE',r,flush=True);json.dump({'solution':objects(base),'valid':r.valid,'score':r.score,'mec':r.mec,'errors':r.errors},open(P/'fallback.json','w'))\n pairs=[]\n for k in range(200):pairs.append(np.round(rng.uniform([-2,-2,-math.pi],[2,2,math.pi],(2,3)),6))\n for k in range(50):\n  e=rng.uniform(-1e-4,1e-4);pairs.append(np.round([[0,0,0],[2+e,0,math.pi]],6))\n errors=[];diff=[]\n for a,b in pairs:\n  ar=area(a,b);pol=semicircle_polygon(Semicircle(*a)).intersection(semicircle_polygon(Semicircle(*b))).area\n  diff.append(abs(ar-pol))\n  if (ar>1e-6)!=(pol>1e-6):errors.append([a.tolist(),b.tolist(),ar,pol])\n md=[]\n for k in range(20):\n  a=base if k==0 else np.round(rng.uniform([-3,-3,-math.pi],[3,3,math.pi],(15,3)),6)\n  md.append(abs(own_mec(a)[2]-compute_mec([Semicircle(*v) for v in a])[2]))\n out={'pair_cases':250,'area_validity_disagreements':errors,'max_area_difference':max(diff),'mec_cases':20,'max_radius_difference':max(md),'rounding':6,'method':'analytic Green boundary integrals; analytic support separation; SLSQP analytic-farthest-point MEC'}\n pol=[semicircle_polygon(Semicircle(*v)) for v in base]\n out['baseline_tight_pairs']=105\n out['baseline_exact_vs_official_disagreements']=[]\n for i,j in zip(I,J):\n  ar=area(base[i],base[j]);ap=pol[i].intersection(pol[j]).area\n  if (ar>1e-6)!=(ap>1e-6):out['baseline_exact_vs_official_disagreements'].append({'pair':[int(i),int(j)],'analytic_area':ar,'official_polygon_area':ap})\n special=[[[2,3,0],[2,3,0]],[[2,3,0],[2,3,math.pi]],[[2,3,0],[2,3,math.pi/2]],[[2,3,0],[2,3.5,0]]]\n out['degenerate_cases']=len(special)\n out['degenerate_max_area_difference']=max(abs(area(a,b)-semicircle_polygon(Semicircle(*a)).intersection(semicircle_polygon(Semicircle(*b))).area) for a,b in special)\n out['separation_cases']=0;out['separation_disagreements']=0\n rng2=np.random.default_rng(11)\n for k in range(100):\n  a=rng2.uniform([-2,-2,-3.14],[2,2,3.14],(15,3))\n  for i,j,g in zip(I,J,gaps(a)):\n   out['separation_cases']+=1\n   out['separation_disagreements']+=int((g< -1e-8)!=(area(a[i],a[j])>1e-10))\n json.dump(out,open(P/'check.json','w'));print(out,flush=True)\n\ndef run(seed,kind,seconds):\n rng=np.random.default_rng(seed);start=time.monotonic();last=start;base=np.array(json.load(open(P/'baseline.json')))\n best=None;bestscore=1e9;attempts=0;valid=0;err=[];coverage=[]\n if kind=='fresh':\n  angles=rng.uniform(-math.pi,math.pi,15);rad=2.5*np.sqrt(rng.uniform(0,1,15));a=np.column_stack((rad*np.cos(angles),rad*np.sin(angles),rng.uniform(-math.pi,math.pi,15)))\n  a,r=repair(a,220)\n else:a=base.copy()\n anchor=a.copy();trace=[]\n def retain(q,label):\n  nonlocal best,bestscore,valid\n  q=np.round(q,6);r=official(q)\n  if r.valid:\n   valid+=1\n   if r.score<bestscore:\n    best=q.copy();bestscore=r.score;print('BEST',seed,attempts,label,r.score,flush=True)\n   trace.append({'attempt':attempts,'radius':r.score,'move':label})\n  else:\n   if len(err)<15:err.append({'attempt':attempts,'errors':r.errors})\n def save():\n  json.dump({'seed':seed,'start_kind':kind,'minutes':(time.monotonic()-start)/60,'attempts':attempts,'valid_count':valid,'best_radius':bestscore if best is not None else None,'solution':objects(best) if best is not None else None,'score_kind':'official, rounded 6 decimals','errors':err,'removed_indices':coverage,'trace':trace},open(P/f'run-{seed}.json','w'))\n if kind=='fresh':retain(a,'initial random repair')\n # Each index visited in order, multiple gap/orientation proposals per visit.\n while time.monotonic()-start<seconds:\n  i=attempts%15;coverage.append(i);q=(best.copy() if best is not None and rng.random()<.65 else anchor.copy());others=np.delete(q,i,axis=0)\n  cands=[]\n  # Include local hole, random positions across full container and facing options.\n  for k in range(120):\n   if k<30:xy=q[i,:2]+rng.normal(0,.3,2)\n   else:\n    ph=rng.uniform(-math.pi,math.pi);rr=2.8*math.sqrt(rng.random());xy=rr*np.array([math.cos(ph),math.sin(ph)])\n   th=rng.uniform(-math.pi,math.pi)\n   v=np.r_[xy,th];z=q.copy();z[i]=v;gg=gaps(z);mask=(I==i)|(J==i)\n   cost=np.sum(np.minimum(gg[mask],0)**2)+max(0,far(z,np.zeros(2))[i]-2.95)**2\n   cands.append((cost,v))\n  cands.sort(key=lambda x:x[0]);q[i]=cands[int(rng.integers(0, min(6,len(cands))))][1]\n  q,r=repair(q,100);attempts+=1;retain(q,f'reinsert {i}')\n  # Small outward scaling often repairs rounding without losing topology.\n  if gaps(q).min()>-2e-6:\n   q[:,:2]*=1.000001;retain(q,f'reinsert {i} rounding repair')\n  if time.monotonic()-last>=55:save();last=time.monotonic();print('CHECKPOINT',seed,attempts,flush=True)\n save()\nif __name__=='__main__':\n if sys.argv[1]=='check':check()\n else:run(int(sys.argv[1]),sys.argv[2],float(sys.argv[3]))\n",
    "polish.py": "import search as s\nimport numpy as np,json,time,sys\nfrom scipy.optimize import minimize\nfrom semicircle_packing.geometry import Semicircle,semicircle_polygon\nP=s.P\n# Sparse numerical Jacobian: every area constraint touches just two pieces.\ndef polish(a,targets,maxiter=70):\n x=np.r_[a.ravel(),max(s.far(a,np.zeros(2)))];scale=.01\n def cons(x):\n  a=x[:-1].reshape(15,3)\n  return np.r_[(targets-np.array([s.area(a[i],a[j]) for i,j in zip(s.I,s.J)]))/scale,x[-1]-s.far(a,np.zeros(2))]\n def jac(x):\n  a=x[:-1].reshape(15,3);out=np.zeros((120,46));eps=2e-7\n  for k,(i,j) in enumerate(zip(s.I,s.J)):\n   if np.linalg.norm(a[i,:2]-a[j,:2])>2.01:continue\n   ar=s.area(a[i],a[j])\n   for z in (i,j):\n    for dim in range(3):\n     b=a.copy();b[z,dim]+=eps\n     out[k,3*z+dim]=-(s.area(b[i],b[j])-ar)/eps/scale\n  f=s.far(a,np.zeros(2))\n  for dim in range(3):\n   b=a.copy();b[:,dim]+=eps\n   der=-(s.far(b,np.zeros(2))-f)/eps\n   out[105+np.arange(15),3*np.arange(15)+dim]=der\n  out[105:,-1]=1\n  return out\n r=minimize(lambda x:x[-1],x,jac=lambda x:np.r_[np.zeros(45),1],method='SLSQP',constraints=[{'type':'ineq','fun':cons,'jac':jac}],options={'ftol':1e-12,'maxiter':maxiter})\n return r.x[:-1].reshape(15,3),r\n\ndef main():\n seed=int(sys.argv[1]);seconds=float(sys.argv[2]);rng=np.random.default_rng(seed);start=time.monotonic();a=np.array(json.load(open(P/'baseline.json')));best=None;bs=1e9;valid=0;attempts=0;trace=[];errors=[];last=start\n # Targets compensate analytic-minus-polygon area measured for each contact.\n while time.monotonic()-start<seconds:\n  if attempts and best is not None:a=best.copy()\n  poly=[semicircle_polygon(Semicircle(*v)) for v in a]\n  delta=np.array([s.area(a[i],a[j])-poly[i].intersection(poly[j]).area for i,j in zip(s.I,s.J)])\n  targets=1e-6+delta-rng.uniform(2e-9,1e-8,105)\n  if seed==850229626:\n   targets=1e-6+delta-rng.uniform(1e-7,2e-7,105)\n   targets[((s.I==4)&(s.J==8))|((s.I==1)&(s.J==14))]=4e-7\n  q,r=polish(a,targets);q=np.round(q,6);attempts+=1\n  result=s.official(q)\n  if result.valid:\n   valid+=1;trace.append({'attempt':attempts,'radius':result.score})\n   if result.score<bs:bs=result.score;best=q.copy();print('BEST',bs,flush=True)\n  else:\n   errors.append({'attempt':attempts,'errors':result.errors});a=q\n   # Tighten just failing contacts on subsequent solve.\n   for e in result.errors:\n    words=e.split()\n    if len(words)>4 and words[0]=='Semicircles':\n     i=int(words[1]);j=int(words[3]);targets[(s.I==i)&(s.J==j)]-=5e-8\n   q,r=polish(q,targets,40);q=np.round(q,6);result=s.official(q)\n   if result.valid:\n    valid+=1;trace.append({'attempt':attempts,'radius':result.score,'repair':True})\n    if result.score<bs:bs=result.score;best=q.copy();print('BEST repair',bs,flush=True)\n  if time.monotonic()-last>50:\n   json.dump({'seed':seed,'start_kind':'baseline contact-specific exact-area local repair','minutes':(time.monotonic()-start)/60,'attempts':attempts,'valid_count':valid,'best_radius':bs if best is not None else None,'solution':s.objects(best) if best is not None else None,'score_kind':'official rounded 6 decimals','errors':errors[:20],'trace':trace},open(P/f'run-{seed}.json','w'));last=time.monotonic();print('CHECKPOINT',attempts,flush=True)\n json.dump({'seed':seed,'start_kind':'baseline contact-specific exact-area local repair','minutes':(time.monotonic()-start)/60,'attempts':attempts,'valid_count':valid,'best_radius':bs if best is not None else None,'solution':s.objects(best) if best is not None else None,'score_kind':'official rounded 6 decimals','errors':errors[:20],'trace':trace},open(P/f'run-{seed}.json','w'))\nif __name__=='__main__':main()\n"
  },
  "commands": [
    "git clone https://github.com/benedictbrady/shape-packing-challenge official",
    "git -C official checkout 78a78626f098cd236f3a09bb2cb242f72951599d",
    "cd official && uv sync && uv run python run.py",
    "cd official && uv pip install scipy",
    "Extract search_scorer_source files next to official; create baseline.json from inherited_baseline.solution as rows [x,y,theta].",
    "OPENBLAS_NUM_THREADS=1 official/.venv/bin/python search.py check",
    "OPENBLAS_NUM_THREADS=1 timeout 470 official/.venv/bin/python search.py 826642270 baseline 420",
    "OPENBLAS_NUM_THREADS=1 timeout 470 official/.venv/bin/python search.py 700072903 fresh 420",
    "OPENBLAS_NUM_THREADS=1 timeout 470 official/.venv/bin/python search.py 1904490920 fresh 420",
    "OPENBLAS_NUM_THREADS=1 timeout 470 official/.venv/bin/python polish.py 596237290 400",
    "OPENBLAS_NUM_THREADS=1 timeout 180 official/.venv/bin/python polish.py 850229626 120",
    "Extract solution_json verbatim as solution.json; cd official && uv run python run.py ../solution.json --save-plot ../packing.svg"
  ],
  "handed_inputs": [
    {
      "item": "cma-es",
      "reported_score": 3.02081451,
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "diff-evolution",
      "reported_score": 3.04084534,
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "flats-on-rim",
      "reported_score": 3.00113305,
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "flats-to-centre",
      "reported_score": 2.9632139,
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "no-pairs",
      "reported_score": "3.03051443",
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "pairs-1-4",
      "reported_score": 2.97438934,
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "pairs-5-5",
      "reported_score": 2.95475629,
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "pairs-6-3",
      "reported_score": 2.97726863,
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "pairs-7-1",
      "reported_score": "3.06352356",
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "rings-159-267",
      "reported_score": "2.99381251",
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "rings-312-411",
      "reported_score": 2.98539036,
      "independently_rescored": false,
      "reusable_source_present": false
    },
    {
      "item": "symmetric",
      "reported_score": 2.97035856,
      "independently_rescored": false,
      "reusable_source_present": false
    }
  ],
  "notes": [
    "No new record: retained inherited published packing.",
    "The inherited radius is below the displayed 2.94853 but this alone is not a new record.",
    "Sample scored VALID 3.500000. Final rounded solution was validated using unmodified validate_and_score imported from a second clean checkout of the pinned commit.",
    "No independent second agent was available; separate-checkout validation is not an independent-agent review.",
    "Only the assigned remove/reinsert strategy and its local repair were searched, not every strategy in the parent goal.",
    "valid_count counts successful official validation calls, including rounding-repair variants; it is not a count of unique packings. Attempts count remove/reinsert moves or local-area solves. Error arrays are bounded examples.",
    "Checkpoints were saved between completed attempts approximately once a minute and at run completion.",
    "Exact circular areas and official polygon areas disagree on six inherited near-threshold contacts; the official decision is authoritative.",
    "Strict zero-overlap enclosing radius was not measured. Plot is embedded as exact SVG text; solution JSON and source are embedded to honor the two-output-file scope.",
    "Search replay needs the official project dependencies and SciPy; packages are not embedded in the JSON.",
    "Three commands exited 143. Their last saved checkpoints are reported; later unsaved progress is excluded. No cause for the interruption is asserted.",
    "Unused derived seed 838169699 was generated but not run.",
    "No submission or sign-in was performed.",
    "Seed 850229626 repeats the contact-area repair with larger rounding margins, including tighter area targets on the two sliding seams."
  ],
  "seed_derivation": "numpy.random.default_rng(23001).integers(1, 2**31-1, 6); first five used, sixth unused."
}
