diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/best/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/best/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..e32e8cbb91c4f3161d95afbd32263e37ecd62034 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/best/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1658809bd35f39db52456d6865c7227ac983c9ff82edab42c329f39ce8aeb36a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_0/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_0/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..783a89be6b2dce36832f1ca797633a1d157b39cc --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_0/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e879ac74db27b5974e0503ad813e76270adf2b257fd32271b38109828e34f42 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_1/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_1/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..d54a3743264a339c7ca9fdc861064a3bfecef140 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_1/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f56749c012b3e5c99f5f03f60a9155795c0ed397a86edf89d5bb628c0694d43e +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_10/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_10/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..7e0eb372193a735002ee18cbd33b9d54cd85475e --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_10/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b438d64dbf522fec87b1031577b197a5d6e274d090d3c02c3dcb0c6c79ab50a2 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_11/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_11/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..f848528d9e5825ddd134a66fd2967ff6ea478e63 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_11/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4141fb7a36ebbea7bf26f03a2fa60544844df4b01cb41269f54304701540be36 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_13/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_13/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..bce6ca026a5db1d62f3c26bea99a106d2b3cebc8 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_13/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62b9c55d27a4d80fb352b23296696a79d1555afb24b71b985a1dcbbe597d358f +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_15/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_15/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..3ff4637104ba34bc566f84eb9665450bd14ac0dc --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_15/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebae4eb0b1b166c3a12d60f145af5333e29a1504028a2f4b17c496768d02e18c +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_17/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_17/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..4eb34431eb049d52b467242ef7ab05be6e421a57 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_17/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71301870fa1413eef94e8709ecfd2f57572639ef0f9cc3d57732bb3a27a8b79b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_18/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_18/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..06c2ba55db170b081922ca152fde0ec985136b22 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_18/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0088290341837be7f792fc7fd6bc03cc7330aa8ff67ce0cebea9366aefb3f97b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_19/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_19/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..6797407e4d63d1317490afbe3962210ef9365d03 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_19/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce104f559aa852675b64416715817f0fd652315fa12417081234e22d50b37bcb +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_2/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_2/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..8c81fa4fdf62e5f255ba82093145bc72dcc92955 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_2/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b4fff58c92b2d247c9db2eb748fc0c093809de31c22ca55d9af74ecb7606bb2 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_20/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_20/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..15cfdaae9556e10e3ccdd6e610eb5d1e07d60b82 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_20/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20c9cf4878a349c983542a184d81273b302171acaa929eed05e43e097732cf99 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_22/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_22/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..cb64d32a1e9cc3680e5cd822dac3bca0c8b81358 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_22/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b50c918cb8025ae147788197786538c84131b581e34d91c472ca15bdbfce23f9 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_24/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_24/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..6797407e4d63d1317490afbe3962210ef9365d03 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_24/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce104f559aa852675b64416715817f0fd652315fa12417081234e22d50b37bcb +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_25/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_25/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..10a73bbaf70d23c26678263e12bbc74159d644fe --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_25/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b0a14f3b6a0b7e88da5fc9b29de9c3a2533e11a1098317c4af46d7ec80f62ae5 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_28/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_28/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..b388c8e96641c37bc3244d951a7423b7216aefc9 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_28/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5288e031ba3ca2bfd48d0a53868a1798c11c73854a30889b4d0fbd94f06b60cc +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_29/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_29/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..f00d91347a8549076fcb9aa7be84c38bc8da4f2c --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_29/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88df0b09589157dcbe879cade63c66b2ec15fcf58dd7be3cecd93cf169e2ed84 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_3/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_3/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..b151597a684b0fc58cbadd0838254a0dcb108864 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_3/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:527d230113bfdc7776760e71a9a0d51932c822ee8894b73e1b7ce90074123f1d +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_31/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_31/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..5a2a0e129f383a1c89843c0b96d5c7645b1ca08a --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_31/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da5d976ebf75c567eb9d754176f5ad85cb8ea0b00223fff131956014643c60c0 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_32/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_32/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..85f19ba6f732ed5ed95c2df950772d261ff7fed8 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_32/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e26c6de8f2ccb2cdd182d1f4dd00ba771241a9bfe3d1bcecf5fbdb5baf71a410 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_33/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_33/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..c62b01c88ac559b353937029e6d2dfe874939df7 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_33/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05b6afda35452dbe3f9a76d0594ed2cd1dcfb5c9544c1c239cf360dfd97cc94f +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_34/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_34/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..9777a4ec88b9a4cc55359f8617b36f3637b22b34 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_34/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c3e36dcfaf9bce630494bf3608cb613260e81db31e54b88da73592a495a1d5e +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_35/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_35/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..1171aa8e8fde3a09cea23707e93c349b5affd84f --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_35/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3cafd9c5254ba857ce64f59d35f876c3b3c0b95ecc7d7f55e9fb1bfa5b87cec1 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_36/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_36/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..10a73bbaf70d23c26678263e12bbc74159d644fe --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_36/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b0a14f3b6a0b7e88da5fc9b29de9c3a2533e11a1098317c4af46d7ec80f62ae5 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_37/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_37/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..8d1e0a560cc4eb16c11c3dae044e03caf95ee8f9 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_37/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9fcedba8f90eac77e33f363347785c79c7e4828c149deec4f7f357e144fb1997 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_38/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_38/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..c301149da7ccfba8699dfb21b31cce4b55de04a5 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_38/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7365514b67121649ccef0488e1b95f934a1be7d3047777227fdb73ec84e6d93b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_39/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_39/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..5a2a0e129f383a1c89843c0b96d5c7645b1ca08a --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_39/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da5d976ebf75c567eb9d754176f5ad85cb8ea0b00223fff131956014643c60c0 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_40/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_40/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..e2250f72ff7bd2a4c70940c6d1e82a546444bedb --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_40/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a959b597a73ee37f47c1cb845e120e1cec1e7ff16babc90201bed5a125132464 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_42/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_42/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..4bbf2d09bd250f8cac0da1df38201b5fafced5c9 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_42/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36841154be187272863fe5b8f41408c160040565797638e914ed1db881ef268f +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_43/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_43/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..5f4efde9eb839643617f1f354eafc97687a25291 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_43/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12cd25c81d57b966eab2b9cb0a4cfc160877dea70dc31e0bb1dd7fe6fbd7021b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_45/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_45/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..e8bd433ca6709526527b950ac30454fed655401d --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_45/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:524d113c399be482d32936b875c93da2e1cb02e17bb32a3c26fcdb61aef7a800 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_46/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_46/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..9c06eba167e20a698b8e00f2d60202e258d0c3b8 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_46/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1ba36763188fb0fbacfac5ffbb2ca649cad43413fb17fd8a3864a45a7fbec72 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_47/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_47/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..1c145be7914b160f50e02afdb21279636b78647e --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_47/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99a2046e6d5cac596d01348b48c375ad7630c0fd321579a41197363e9f80413d +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_5/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_5/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..737c16ad08a4cb84eb36074499311fbcb59b8ed4 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_5/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b12488ba2e2e493814c886cf89cc04b45db1ca908ba3133de50ca1926c7a028 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_52/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_52/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..718ea7b821ec1016a1d952008c9951d06e93d403 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_52/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3607863d0ce5ec085fe69917bf6f4c8d8a3dec2cf924496490763e4c2b15488a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_54/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_54/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..6a6bc7878f659705694a258ff2df35d52bd65b40 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_54/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc8c63d79f530b8109b49dc44ef0d0437c4790a84df134b34a7bbf27a12763ee +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_55/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_55/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..240a5c371b0f0da5ff65e194368042be8891cb58 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_55/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b43a06c3f08da39ea8cebd95a881113a3876e06051963875c839aade0ff021a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_56/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_56/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..5a2a0e129f383a1c89843c0b96d5c7645b1ca08a --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_56/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da5d976ebf75c567eb9d754176f5ad85cb8ea0b00223fff131956014643c60c0 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_57/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_57/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..5a2a0e129f383a1c89843c0b96d5c7645b1ca08a --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_57/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da5d976ebf75c567eb9d754176f5ad85cb8ea0b00223fff131956014643c60c0 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_6/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_6/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..8f7a582200d3935b9453d5c1d61e8e8f4a17f977 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_6/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53fe9aaf8aef640f3352d80f0c729b29c83d391b8ccb865aecce3e951b5cd2f9 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_60/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_60/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..712fb2c0da6195cd0537b5e407b89156235b9a1a --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_60/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1ea73afc8e426b0df5e5f3565a7530ec18cee4a2fb444b772e26480d8f2a31a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_62/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_62/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..c301149da7ccfba8699dfb21b31cce4b55de04a5 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_62/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7365514b67121649ccef0488e1b95f934a1be7d3047777227fdb73ec84e6d93b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_7/results/extra.npz b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_7/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..e5a1852c61951b5dd72764e0a7ff3dfd03565270 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_full_gen200_period1000_20260206_231230/gen_7/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a990a4eb7e5430dc5a870e63fe855af983e2f4483e4a2d4149284e0f79aaa710 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_100/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_100/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..78404e3111e09a5186eadd698af62b6673fdaede --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_100/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36f8a27c244a6daa2e32f9ab2c8e7da4e88895a66a1b9ac22859f0fd8de34bfb +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_105/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_105/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..b7ab4d2466c372bd5d3d1021ca64332dab6033c6 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_105/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d52a3e59455f82e39edc05d4eae990d40c7ec3edddacfcf2d7dac383a0499ba7 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_111/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_111/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..fe55637f24ceedcb2a6bef76d2c3f2b17d38a9b0 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_111/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c621b809e23bbbf70717a40b7a9469a7574b0382f03e66ca31939fd64a0c70b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_119/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_119/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..d8c788e2142d2082af02abcbd9c38d9b6a3a3046 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_119/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99dcbb07e502afcdacf411d7ba12b5259246883febe8a64bc9cc9e8bff2f0ce1 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_12/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_12/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..727a7d38129ea63a9fc338d1a81f8e39d55281c4 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_12/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9535e0dca1bfc3cd0e93809aa8ef7562c999b89030f5e52f00209aea5bfaa680 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_122/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_122/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..944392cfcf4b99377e925b7bc0737171cce4211f --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_122/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79541f8d8ed2c3926fa77a47c201122a6481b7df3487c22c3ae29b33ed1b4f38 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_129/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_129/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..790c713d3899da1b6881588636a534b7930c7168 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_129/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac39b9ecdf6a0df11dda4a87471786332084cc84015f80ebd1683a7af1de0f55 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_139/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_139/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..dc93af18fcfc8ac41ab330e24b8fdb4bbf039984 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_139/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88681ce906cf7cb4656487cddad3eb734c5ada482afe8269387f2602d1a99844 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_14/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_14/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..727a7d38129ea63a9fc338d1a81f8e39d55281c4 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_14/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9535e0dca1bfc3cd0e93809aa8ef7562c999b89030f5e52f00209aea5bfaa680 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_143/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_143/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..f866691ac43de10efa2d33d11a05c00de3f25a64 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_143/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6fe76cb13bf1fb1402e6e4782738209bf1843766bd2758315bf37d0e1233319 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_146/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_146/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..8ac03fb47599f5bec8cd2ec2f8ddb216736b7637 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_146/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c680a7ffc46271a637317fec2a1917983b331a5d6fe4fd9eb04d33fd377b4b5 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_15/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_15/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..558415421a156ae428da01db6f950722f9a4efb6 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_15/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b49af28981a450dc35a48fc02190a38a000a8300727e66715e58da14a59af8ca +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_150/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_150/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..9dad9d0785f33c1c86c10aa6a4c4ca2d9468996d --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_150/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:254bf23000fab0432b359ebae06714aba8c7258ae8495d4d082572fceed9b03e +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_154/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_154/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..934a5ea52faa1567945742e2c1efb4603a2da0f1 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_154/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f8a9e47071221d6b39a598c4fa2e410abf73e9b65960404c1e583c3b3e97741 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_155/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_155/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..5feba7280e7f837c3bb3833cecbede87157ce05d --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_155/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:283b114cce1bf322afac1ac0d21f3ead8b885bba2fa6527f7d59b0cd6e7fb020 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_16/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_16/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..fcf249ab708d8eb119d6f33dc2a4432814199179 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_16/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f39d22805371cf860148a903f2d776fbd9ba4ef6f68051307d8cafe97761cef5 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_161/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_161/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..521c7bfec104803aa31eaa8c4ff9aaef37213221 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_161/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b1172ffcfb4b8ed0d0ab90e4e5942c5e867f9cab58e88eeb4bfbf1bab65c982e +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_163/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_163/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..9a4effc150f27d1f784f72b33e82fbd6bc41a36d --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_163/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3060ee4b392106accf6537fcbc5821378fb267ad210f4afc385a26e586b409e5 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_165/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_165/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..e4d5c3f07ab77b5e03509b172aab4fc6afe53bff --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_165/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dec00fc1a65e548d14de57f39887d6c354250d4f6d4ba69593c87cd0b9a18cf3 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_166/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_166/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..ff8ef325482cab2bf51ff35208a835175dd87d87 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_166/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e04e3be5765d1f2ac566c4634518e6af08231e53677abbd830f921f9ad67622b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_167/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_167/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..ff1762fcf4586dc0ea55720a6e78a124403ec74f --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_167/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49c5ba9f7852dd5ff5726488c83be1fe958b7dd257fb189ea0c2e37a23d04e30 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_169/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_169/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..2ecb99d633865cbc5c2ba7ea235ad8770df80779 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_169/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2967bc340958c2acf697ab56dfd8d5fcc6cebb64ab987d5ca4b9e056a96f42f +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_172/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_172/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..8200f38b109f383bc0895cb50ab1b4b55094b744 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_172/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06283035800df72ddd75800c991be379ae49881ba03057e898f3276dbdeabd76 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_177/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_177/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..72f4963b20cca4ae865c4f043fbf691307b3d76b --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_177/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05a1ec4faf767fd2363cf94a12c41a6ec1b95fc09c43a3768d8b545b96f5ed43 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_184/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_184/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..39f2a1329a6aea14e8a43ba19ff4d939c228c3fc --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_184/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2915eac8a5bea27ac9e7b0f07bbcacde0284ba9ae2b0c1e27324e607389dba1a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_187/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_187/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..298142de5df28f729f595c8412a7844e514ccc12 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_187/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c87f983f9281471039c795026419453438cc293007cffc418f56edb7cf844424 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_198/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_198/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..44c5644ec615c44bf223493ac9a8c8295ed370d5 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_198/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:686d45d7cd655a7437c9191f7a7c243d863db3fd52f262b21be035ec1641cf05 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_199/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_199/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..261438e2237867c9a171c5507c3cff745660cece --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_199/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f61627c0c682e78b5aa6ff2ca7478d7d3e94e6d411c8e64d82d8b0b57fdaccf +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_21/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_21/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..d62c3880f8299ff84e588101e81d934d0b357b39 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_21/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b228e60282b8e88b419542e3ad85e0be47eff8e436ec5e3bb219ccacc88adee +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_23/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_23/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..44ee064c02ab7a0826157012a959ae0ef36f06c0 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_23/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b789df3abde4a5b755d50ee19c0a7a4d05c0ed73f4435cd10c10a7814f5f3a01 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_26/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_26/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..89be5291ed73267ff3b5111859bba5255c91920e --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_26/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec543f3c904e472820629cf2ae6f24c7d4cc31951f6846bb75dcb23de3b8cd5a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_27/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_27/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..5a8e7bf5a3d1c4ee82ad31de9d0bec98b7e253fe --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_27/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aefcce859a8bb97548c9963f2a460b373a76a8b0d0f59c0f006fc7b6b99257ae +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_30/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_30/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..b469336f223280877f41f0b5ba868d4aa2a2087c --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_30/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c21e0ee51545c821f279c8cdab682a8899e77eeff029d76b049cd94e54133192 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_34/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_34/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..bf4103da56cf78b94b5a67a56a34d15dacca209d --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_34/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3037e9ba7141c56493fd99aecdea26a6a26b40c811161adb95d2254da3c317ed +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_41/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_41/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..89be5291ed73267ff3b5111859bba5255c91920e --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_41/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec543f3c904e472820629cf2ae6f24c7d4cc31951f6846bb75dcb23de3b8cd5a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_49/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_49/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..89be5291ed73267ff3b5111859bba5255c91920e --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_49/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec543f3c904e472820629cf2ae6f24c7d4cc31951f6846bb75dcb23de3b8cd5a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_50/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_50/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..0814b7af02e95849ca36d6b8ec0851116c989368 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_50/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ececd9c3bf2238a9afdc3681fccd96312fdf3e0607db6656a8fa6bb9605e494b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_53/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_53/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..1a667678d6d71f50f464ab90644aaefa56fbffad --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_53/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:009aafb571b5866b9d16b2f28156552c7708db03b0936be19eb57532026a5364 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_58/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_58/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..c37f4f06717595671e34d385eeb4ebb20086ff9b --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_58/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:572acb60211d4b4b221e39e88e85c7e15b252b1b2aeeea1127f01915a74b17df +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_63/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_63/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..a847495880c5ca548cc24338f479d902dea6c635 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_63/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f65b5120193d08034cab9e9d1a18a0c0a3c4a5ca884d4ceefdee53ee8a51a056 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_64/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_64/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..46feb7794dcfdd5b629e546d6151f9f1a7128c7e --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_64/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50d2407911cbe1d6f65f8d6dc264d963a87f8973a73058c3392778f757f6144a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_70/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_70/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..26574156b8c64477f149b12c7029859d5cd5fac2 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_70/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:439f79ce43d67d26861c6feac79bc61d0c7177de86c4935453fdd3192a93900b +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_77/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_77/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..f316cd14bfe67a73b528a744aac33af15475edf4 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_77/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ecb8075a24dc1e1e8af3ac519b2f37a4ebf29baf77b581f043004eb4329084bb +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_78/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_78/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..d447a6338f89a056930eef698a9360700401aa8a --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_78/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab9f18f637e271f58ac79754e82dd77c6d77adcbf3b2f4fbeaa405b71510315f +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_79/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_79/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..7069827dce4138b51e3dd46c7e45a3c360727423 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_79/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2235fd749895c9ecb2790203d5278a89336f8a122a458d94fdf48faad38e6b26 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_8/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_8/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..3c5f2508be238e4e5c1ea31ae48ff244dfa52a14 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_8/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f68fa6cbf395ec68e6e4ba18acd301e733013a502c9e6120ea68cfe6a05335a +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_81/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_81/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..2e68e7622bc8ec37dec1aa0c52f33d41eff0ade8 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_81/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26d02a074f1dce87ceee542db62025e82ff4ba29c2ca12f1467fd3493b97213c +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_83/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_83/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..694f3a036d36e0486502a5e377ea20be671432ed --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_83/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f372c34b1b78972361b103b3e55c7815ba09ce423b7452f641b9c431c9927fb6 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_85/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_85/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..f457c6c858f2736401434231d834577d8ceb9e5c --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_85/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a376774f9608cfbb02d19941f2ccc9deca6b26b25e9b588f28bb90f96c9c1f44 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_88/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_88/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..397f3752bd44d9134799cd3b4cfd6bb732eafb08 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_88/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c97b7d4f35f108e26f38b00a02e071bbfab332ad1ebf7f31855c3e661598fd37 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_9/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_9/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..dc96c19e27536342f306c93b464ee1b233c4c4b4 --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_9/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7765a1e28a48c4bf54cfb72ef8b2a1b2ba5512a9cb8a78ccd643f4f652e918f +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_90/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_90/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..b1f760210f5f58748a431d2c95857ff8a692f54d --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_90/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb1d98e8253bdb262796adbd059a953d30c006de0d7f96e91da448e0e087c891 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_91/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_91/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..152131eb8b3680e531f6eb71b071b009453ffffc --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_91/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d756cf45ddd40f1c57e555c17772f7fd8a0678cec872810a0eedce7f9c9d0a2 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_92/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_92/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..f91901c20fbdd7a51442160fc46b6944386d005e --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_92/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebeaf8536d823c6f6608f1387442ae33505d02f49bba4907b58d55a353811b66 +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_96/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_96/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..e2f2fddf0ae6ed7ec71f31a8f989c66042acb6be --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_96/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d983d8d3ce4ff291bcac91a68ffe60b3057ec9f1fdcb31fc1cff46e41a2fa64c +size 1398 diff --git a/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_97/results/extra.npz b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_97/results/extra.npz new file mode 100644 index 0000000000000000000000000000000000000000..4dd2619c8c3e2f058cec649472a058be88b0560a --- /dev/null +++ b/examples_deprecated/circle_packing/results/results_mmv1_1_gen200_periodic10_20260208_083104/gen_97/results/extra.npz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ba7f09568ac93a3da1c80296c561380a4f4f820daa0c551b310a21282dcf82b +size 1398 diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4621670eacf698bd4ccc4812b0b357beac3e9fff Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..327fb6e52eb55d804870d9c26e99cf73a671c5f0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8804681751563488, + "spatial_uniformity_details": { + "cell_size_mean": 0.20270657167019365, + "cell_size_std": 0.02751932122335693, + "coefficient_of_variation": 0.13575939280533955 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5577976708150423, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0007617865475655272, + "mean_density": 0.03481547363688676, + "cv": 0.792764746648764 + }, + "packing_efficiency": 0.75611967936404, + "packing_efficiency_details": { + "total_area": 0.75611967936404, + "square_area": 1.0, + "efficiency": 0.75611967936404, + "relative_to_estimated_best": 0.900142475433381 + }, + "radius_distribution": 0.9341661379115739, + "radius_distribution_details": { + "mean": 0.09054996655537094, + "std": 0.03252139033185766, + "min": 0.0021668311906022242, + "max": 0.16726074564317145, + "range": 0.1650939144525692, + "small_count": 8, + "medium_count": 13, + "large_count": 5, + "diversity_score": 0.9341661379115739 + }, + "gap_analysis": 0.7568, + "gap_analysis_details": { + "covered_samples": 1892, + "total_samples": 2500, + "coverage": 0.7568, + "gap_ratio": 0.24319999999999997 + }, + "geometric_quality": 0.666371996286751, + "geometric_quality_details": { + "num_triangles": 43, + "avg_triangle_quality": 0.666371996286751, + "min_quality": 0.2357507016856368, + "max_quality": 0.9287603573964867 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..9701798c59ba850a11833a1cc077bca8deb971d5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 924.30 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3543 + + Auxiliary Metrics: + • spatial_uniformity: 0.880 + • edge_utilization: 0.785 + • density_variance: 0.558 + • packing_efficiency: 0.756 + • radius_distribution: 0.934 + • gap_analysis: 0.757 + • geometric_quality: 0.666 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3543 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.880 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.756 + • Area coverage (1 - gap ratio): 0.757 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.558 + • Radius size diversity: 0.934 + • Delaunay triangulation quality: 0.666 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..000b9c12e86b7c4c28a90e2cf6fcd041031410b3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/best/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3542991304396446, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0958, 0.0853)\n centers[2] = (0.2670, 0.1025)\n centers[3] = (0.4063, 0.0980)\n centers[4] = (0.7392, 0.0607)\n centers[5] = (0.9017, 0.0988)\n centers[6] = (0.1048, 0.2847)\n centers[7] = (0.3015, 0.2698)\n centers[8] = (0.5758, 0.0900)\n centers[9] = (0.9454, 0.2552)\n centers[10] = (0.0706, 0.4681)\n centers[11] = (0.2484, 0.4723)\n centers[12] = (0.7204, 0.3095)\n centers[13] = (0.9005, 0.5184)\n centers[14] = (0.0022, 0.7226)\n centers[15] = (0.1260, 0.6721)\n centers[16] = (0.3782, 0.6738)\n centers[17] = (0.6680, 0.6521)\n centers[18] = (0.9110, 0.7151)\n centers[19] = (0.0967, 0.9037)\n centers[20] = (0.2951, 0.8999)\n centers[21] = (0.5085, 0.8888)\n centers[22] = (0.7163, 0.9047)\n centers[23] = (0.9074, 0.9058)\n centers[24] = (0.4068, 0.3942)\n centers[25] = (0.4703, 0.2519)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8804681751563488, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5577976708150423, + "aux_packing_efficiency": 0.75611967936404, + "aux_radius_distribution": 0.9341661379115739, + "aux_gap_analysis": 0.7568, + "aux_geometric_quality": 0.666371996286751 + }, + "private": { + "reported_sum_of_radii": 2.3542991304396446 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3543\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.880\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.756\n \u2022 Area coverage (1 - gap ratio): 0.757\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.558\n \u2022 Radius size diversity: 0.934\n \u2022 Delaunay triangulation quality: 0.666\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/packing_viz.png", + "execution_time_mean": 924.3037533126771, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e0542dda83a4076113b7a26e8cc66972ef3035cc Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..206da01f8f99836dd5c3caf5c585bd267746214d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.920877417390816, + "spatial_uniformity_details": { + "cell_size_mean": 0.25155279836314015, + "cell_size_std": 0.021613633663181253, + "coefficient_of_variation": 0.08592086320605773 + }, + "edge_utilization": 0.9346153846153846, + "edge_utilization_details": { + "corners_touched": 5, + "edges_touched": 12, + "corner_score": 1.25, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.36970166202203575, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00022950534779955865, + "mean_density": 0.008885903591248082, + "cv": 1.7048837014435598 + }, + "packing_efficiency": 0.2470950006766815, + "packing_efficiency_details": { + "total_area": 0.2470950006766815, + "square_area": 1.0, + "efficiency": 0.2470950006766815, + "relative_to_estimated_best": 0.2941607150912875 + }, + "radius_distribution": 0.697045471102817, + "radius_distribution_details": { + "mean": 0.036914008346007936, + "std": 0.040773311984858826, + "min": 0.0, + "max": 0.13033211187711455, + "range": 0.13033211187711455, + "small_count": 17, + "medium_count": 1, + "large_count": 8, + "diversity_score": 0.697045471102817 + }, + "gap_analysis": 0.246, + "gap_analysis_details": { + "covered_samples": 615, + "total_samples": 2500, + "coverage": 0.246, + "gap_ratio": 0.754 + }, + "geometric_quality": 0.7119216893148237, + "geometric_quality_details": { + "num_triangles": 32, + "avg_triangle_quality": 0.7119216893148237, + "min_quality": 0.5785297957619108, + "max_quality": 0.9021969830785408 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3c5fc6a9301a2f43474a4aaf0267d88d0a01b513 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 0.9598 + + Auxiliary Metrics: + • spatial_uniformity: 0.921 + • edge_utilization: 0.935 + • density_variance: 0.370 + • packing_efficiency: 0.247 + • radius_distribution: 0.697 + • gap_analysis: 0.246 + • geometric_quality: 0.712 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 0.9598 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.921 + • Boundary and corner utilization: 0.935 + • Delaunay triangulation quality: 0.712 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.370 + → Balance circle density across different regions + • Area utilization efficiency: 0.247 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.246 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.697 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 75.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..0cf1f8446d137dcc94dcca0d0a5a1bb92823de8b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 0.9597642169962064, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.8000, 0.5000)\n centers[2] = (0.7121, 0.7121)\n centers[3] = (0.5000, 0.8000)\n centers[4] = (0.2879, 0.7121)\n centers[5] = (0.2000, 0.5000)\n centers[6] = (0.2879, 0.2879)\n centers[7] = (0.5000, 0.2000)\n centers[8] = (0.7121, 0.2879)\n centers[9] = (0.9900, 0.5000)\n centers[10] = (0.9900, 0.7679)\n centers[11] = (0.9900, 0.9900)\n centers[12] = (0.7679, 0.9900)\n centers[13] = (0.5000, 0.9900)\n centers[14] = (0.2321, 0.9900)\n centers[15] = (0.0100, 0.9900)\n centers[16] = (0.0100, 0.7679)\n centers[17] = (0.0100, 0.5000)\n centers[18] = (0.0100, 0.2321)\n centers[19] = (0.0100, 0.0100)\n centers[20] = (0.2321, 0.0100)\n centers[21] = (0.5000, 0.0100)\n centers[22] = (0.7679, 0.0100)\n centers[23] = (0.9900, 0.0100)\n centers[24] = (0.9900, 0.2321)\n centers[25] = (0.0100, 0.0100)", + "num_circles": 26, + "aux_spatial_uniformity": 0.920877417390816, + "aux_edge_utilization": 0.9346153846153846, + "aux_density_variance": 0.36970166202203575, + "aux_packing_efficiency": 0.2470950006766815, + "aux_radius_distribution": 0.697045471102817, + "aux_gap_analysis": 0.246, + "aux_geometric_quality": 0.7119216893148237 + }, + "private": { + "reported_sum_of_radii": 0.9597642169962064 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 0.9598\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.921\n \u2022 Boundary and corner utilization: 0.935\n \u2022 Delaunay triangulation quality: 0.712\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.370\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.247\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.246\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.697\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 75.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_0/results/packing_viz.png", + "execution_time_mean": 0.002060260158032179, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b137209c86eec6c049164f4e42d81dfd06361caf Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..0f5cb7adb007a2594fc45f367367eac70bbdfd6e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9010925032874436, + "spatial_uniformity_details": { + "cell_size_mean": 0.1553201317063341, + "cell_size_std": 0.017048555457957307, + "coefficient_of_variation": 0.10976397689661549 + }, + "edge_utilization": 0.015384615384615385, + "edge_utilization_details": { + "corners_touched": 0, + "edges_touched": 1, + "corner_score": 0.0, + "edge_score": 0.038461538461538464 + }, + "density_variance": 0.3804110084222156, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00012059700250030251, + "mean_density": 0.006742447530886933, + "cv": 1.6287357039103 + }, + "packing_efficiency": 0.2792841594856408, + "packing_efficiency_details": { + "total_area": 0.2792841594856408, + "square_area": 1.0, + "efficiency": 0.2792841594856408, + "relative_to_estimated_best": 0.33248114224481046 + }, + "radius_distribution": 0.9986351900937254, + "radius_distribution_details": { + "mean": 0.05071840890792653, + "std": 0.02910037467566572, + "min": 0.007947004280846513, + "max": 0.10494675708089769, + "range": 0.09699975280005119, + "small_count": 9, + "medium_count": 9, + "large_count": 8, + "diversity_score": 0.9986351900937254 + }, + "gap_analysis": 0.2788, + "gap_analysis_details": { + "covered_samples": 697, + "total_samples": 2500, + "coverage": 0.2788, + "gap_ratio": 0.7212000000000001 + }, + "geometric_quality": 0.7033897343937137, + "geometric_quality_details": { + "num_triangles": 39, + "avg_triangle_quality": 0.7033897343937137, + "min_quality": 0.53748384988657, + "max_quality": 0.9013878188659971 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..87edb2b413db04f21141b6ac9d09f5d0047aac1a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.3187 + + Auxiliary Metrics: + • spatial_uniformity: 0.901 + • edge_utilization: 0.015 + • density_variance: 0.380 + • packing_efficiency: 0.279 + • radius_distribution: 0.999 + • gap_analysis: 0.279 + • geometric_quality: 0.703 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.3187 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.901 + • Delaunay triangulation quality: 0.703 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.015 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.380 + → Balance circle density across different regions + • Area utilization efficiency: 0.279 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.279 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.999 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 0/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 72.1% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..9b04bab3568b86c135f2322bd255354ca47ddfea --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.31867863160609, + "public": { + "centers_str": " centers[0] = (0.2000, 0.2000)\n centers[1] = (0.2000, 0.4000)\n centers[2] = (0.2000, 0.6000)\n centers[3] = (0.2000, 0.8000)\n centers[4] = (0.4000, 0.2000)\n centers[5] = (0.4000, 0.4000)\n centers[6] = (0.4000, 0.6000)\n centers[7] = (0.4000, 0.8000)\n centers[8] = (0.6000, 0.2000)\n centers[9] = (0.6000, 0.4000)\n centers[10] = (0.6000, 0.6000)\n centers[11] = (0.6000, 0.8000)\n centers[12] = (0.8000, 0.2000)\n centers[13] = (0.8000, 0.4000)\n centers[14] = (0.8000, 0.6000)\n centers[15] = (0.8000, 0.8000)\n centers[16] = (0.3000, 0.3000)\n centers[17] = (0.3000, 0.5000)\n centers[18] = (0.3000, 0.7000)\n centers[19] = (0.5000, 0.3000)\n centers[20] = (0.5000, 0.5000)\n centers[21] = (0.5000, 0.7000)\n centers[22] = (0.7000, 0.3000)\n centers[23] = (0.7000, 0.5000)\n centers[24] = (0.7000, 0.7000)\n centers[25] = (0.0500, 0.5000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9010925032874436, + "aux_edge_utilization": 0.015384615384615385, + "aux_density_variance": 0.3804110084222156, + "aux_packing_efficiency": 0.2792841594856408, + "aux_radius_distribution": 0.9986351900937254, + "aux_gap_analysis": 0.2788, + "aux_geometric_quality": 0.7033897343937137 + }, + "private": { + "reported_sum_of_radii": 1.31867863160609 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.3187\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.901\n \u2022 Delaunay triangulation quality: 0.703\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.015\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.380\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.279\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.279\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.999\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 0/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 72.1% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_1/results/packing_viz.png", + "execution_time_mean": 0.001994268037378788, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5a07f1d82b8ddec4b2b58fbc10456ec85afc8210 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..875014f03c289f3f76f70e8ed1e1afa9407cb535 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/edit.diff @@ -0,0 +1,128 @@ +--- a/original.py ++++ b/original.py +@@ -1,107 +1,109 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + # Initialize arrays for 26 circles + n = 26 + centers = np.zeros((n, 2)) + idx = 0 + +- # Strategy: A symmetric layered structure of 5-5-6-5-5 circles. +- # This provides a dense packing with good spatial uniformity. +- y_coords = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) +- x_coords_5 = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) +- x_coords_6 = np.linspace(1/12, 11/12, 6) ++ # Strategy: A 5x5 main grid to ensure good boundary and corner utilization, ++ # and one additional interstitial circle to fill a gap. This strategy ++ # previously yielded a higher sum of radii compared to the current 5-5-6-5-5 layout. + +- # Rows with 5 circles +- row_indices_5 = [0, 1, 3, 4] +- for i in row_indices_5: +- y = y_coords[i] +- for x in x_coords_5: +- centers[idx] = [x, y] ++ # 1. Main 5x5 Grid (25 circles) ++ # This configuration places circle centers such that they are initially 0.1 units ++ # away from the borders, allowing for a good initial radius. ++ d = 0.1 # Initial radius and half-spacing ++ spacing = 2 * d # Distance between centers is 0.2 ++ offset = d # Distance from wall to first center is 0.1 ++ ++ for i in range(5): ++ for j in range(5): ++ centers[idx] = [offset + i * spacing, offset + j * spacing] + idx += 1 + +- # Central row with 6 circles +- y = y_coords[2] +- for x in x_coords_6: +- centers[idx] = [x, y] +- idx += 1 ++ # 2. Additional Interstitial Circle (1 circle) ++ # Place the 26th circle in a significant gap created by the 5x5 grid. ++ # An interstitial point like (0.2, 0.2) is a good candidate to maximize overall radius sum. ++ centers[idx] = [0.2, 0.2] ++ idx += 1 + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop for better convergence + of radii given fixed center positions. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively limit by distance to other circles until radii converge + max_iterations = 200 + tolerance = 1e-8 + + for _ in range(max_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_ri = radii[i] + old_rj = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + if not changed and (abs(radii[i] - old_ri) > tolerance or \ + abs(radii[j] - old_rj) > tolerance): + changed = True + if not changed: + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/main.py new file mode 100644 index 0000000000000000000000000000000000000000..5876eeb63798b20a3cb739f2ff553df073abd088 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/main.py @@ -0,0 +1,109 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + # Initialize arrays for 26 circles + n = 26 + centers = np.zeros((n, 2)) + idx = 0 + + # Strategy: A 5x5 main grid to ensure good boundary and corner utilization, + # and one additional interstitial circle to fill a gap. This strategy + # previously yielded a higher sum of radii compared to the current 5-5-6-5-5 layout. + + # 1. Main 5x5 Grid (25 circles) + # This configuration places circle centers such that they are initially 0.1 units + # away from the borders, allowing for a good initial radius. + d = 0.1 # Initial radius and half-spacing + spacing = 2 * d # Distance between centers is 0.2 + offset = d # Distance from wall to first center is 0.1 + + for i in range(5): + for j in range(5): + centers[idx] = [offset + i * spacing, offset + j * spacing] + idx += 1 + + # 2. Additional Interstitial Circle (1 circle) + # Place the 26th circle in a significant gap created by the 5x5 grid. + # An interstitial point like (0.2, 0.2) is a good candidate to maximize overall radius sum. + centers[idx] = [0.2, 0.2] + idx += 1 + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop for better convergence + of radii given fixed center positions. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively limit by distance to other circles until radii converge + max_iterations = 200 + tolerance = 1e-8 + + for _ in range(max_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_ri = radii[i] + old_rj = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + if not changed and (abs(radii[i] - old_ri) > tolerance or \ + abs(radii[j] - old_rj) > tolerance): + changed = True + if not changed: + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/original.py new file mode 100644 index 0000000000000000000000000000000000000000..7a6b8e77938305902f0789b23108d7a62d28a1dc --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/original.py @@ -0,0 +1,107 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + # Initialize arrays for 26 circles + n = 26 + centers = np.zeros((n, 2)) + idx = 0 + + # Strategy: A symmetric layered structure of 5-5-6-5-5 circles. + # This provides a dense packing with good spatial uniformity. + y_coords = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) + x_coords_5 = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) + x_coords_6 = np.linspace(1/12, 11/12, 6) + + # Rows with 5 circles + row_indices_5 = [0, 1, 3, 4] + for i in row_indices_5: + y = y_coords[i] + for x in x_coords_5: + centers[idx] = [x, y] + idx += 1 + + # Central row with 6 circles + y = y_coords[2] + for x in x_coords_6: + centers[idx] = [x, y] + idx += 1 + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop for better convergence + of radii given fixed center positions. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively limit by distance to other circles until radii converge + max_iterations = 200 + tolerance = 1e-8 + + for _ in range(max_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_ri = radii[i] + old_rj = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + if not changed and (abs(radii[i] - old_ri) > tolerance or \ + abs(radii[j] - old_rj) > tolerance): + changed = True + if not changed: + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..9d7162e81884a1cbb06aa53da686300c7e67058d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576736 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5261424497752976, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00020708924409982752, + "mean_density": 0.015978436533757218, + "cv": 0.9006259624690521 + }, + "packing_efficiency": 0.49240606516668184, + "packing_efficiency_details": { + "total_area": 0.49240606516668184, + "square_area": 1.0, + "efficiency": 0.49240606516668184, + "relative_to_estimated_best": 0.5861976966270022 + }, + "radius_distribution": 0.7543533534342522, + "radius_distribution_details": { + "mean": 0.07372908132592121, + "std": 0.024339193856461577, + "min": 0.03669894819221307, + "max": 0.10261558125579377, + "range": 0.0659166330635807, + "small_count": 12, + "medium_count": 1, + "large_count": 13, + "diversity_score": 0.7543533534342522 + }, + "gap_analysis": 0.496, + "gap_analysis_details": { + "covered_samples": 1240, + "total_samples": 2500, + "coverage": 0.496, + "gap_ratio": 0.504 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..bfaa41d61f491b6fc12de1471858bd64114155e0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9170 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.526 + • packing_efficiency: 0.492 + • radius_distribution: 0.754 + • gap_analysis: 0.496 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9170 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.492 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.496 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.526 + • Radius size diversity: 0.754 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 50.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..542161c285f654c13b269835796945f78869eab4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9169561144739513, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.1000, 0.3000)\n centers[2] = (0.1000, 0.5000)\n centers[3] = (0.1000, 0.7000)\n centers[4] = (0.1000, 0.9000)\n centers[5] = (0.3000, 0.1000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.3000, 0.5000)\n centers[8] = (0.3000, 0.7000)\n centers[9] = (0.3000, 0.9000)\n centers[10] = (0.5000, 0.1000)\n centers[11] = (0.5000, 0.3000)\n centers[12] = (0.5000, 0.5000)\n centers[13] = (0.5000, 0.7000)\n centers[14] = (0.5000, 0.9000)\n centers[15] = (0.7000, 0.1000)\n centers[16] = (0.7000, 0.3000)\n centers[17] = (0.7000, 0.5000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.7000, 0.9000)\n centers[20] = (0.9000, 0.1000)\n centers[21] = (0.9000, 0.3000)\n centers[22] = (0.9000, 0.5000)\n centers[23] = (0.9000, 0.7000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5261424497752976, + "aux_packing_efficiency": 0.49240606516668184, + "aux_radius_distribution": 0.7543533534342522, + "aux_gap_analysis": 0.496, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9169561144739513 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9170\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.492\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.496\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.526\n \u2022 Radius size diversity: 0.754\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 50.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/results/packing_viz.png", + "execution_time_mean": 0.0021551428362727165, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..052d4db9bbd8a721cd47538be641cc6282850a5a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_10/search_replace.txt @@ -0,0 +1,60 @@ + +The current solution (5-5-6-5-5 layered structure) resulted in a sum of radii of 1.8667. This is lower than a previous attempt (from the prior programs list) which used a 5x5 grid plus one interstitial circle, achieving a sum of radii of 1.9170. + +Analyzing the auxiliary metrics: +- The 5x5 + 1 interstitial solution had better `density_variance` (0.53 vs 0.476), indicating a more uniform distribution of circles. +- It also had better `packing_efficiency` (0.49 vs 0.456) and `gap_analysis` (0.50 vs 0.454), meaning it utilized the area more effectively and left less unused space. +- `edge_utilization` was also slightly better (0.56 vs 0.542). + +The visualization of the current 5-5-6-5-5 pattern clearly shows that the central row with 6 circles (y=0.5) has significantly smaller radii compared to the outer rows (y=0.1, y=0.9) and even the intermediate rows (y=0.3, y=0.7). This large disparity in radii contributes to poor density uniformity and wasted space, as indicated by the metrics. + +Therefore, the proposed change is to revert to the previously more successful strategy of a 5x5 grid for 25 circles, and then placing the 26th circle in a central interstitial gap, specifically at (0.2, 0.2). This setup previously showed better performance metrics across the board compared to the current implementation. + +This is a step back to a proven better configuration, which can then be further refined in subsequent iterations. + + + +<<<<<<< SEARCH + # Strategy: A symmetric layered structure of 5-5-6-5-5 circles. + # This provides a dense packing with good spatial uniformity. + y_coords = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) + x_coords_5 = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) + x_coords_6 = np.linspace(1/12, 11/12, 6) + + # Rows with 5 circles + row_indices_5 = [0, 1, 3, 4] + for i in row_indices_5: + y = y_coords[i] + for x in x_coords_5: + centers[idx] = [x, y] + idx += 1 + + # Central row with 6 circles + y = y_coords[2] + for x in x_coords_6: + centers[idx] = [x, y] + idx += 1 +======= + # Strategy: A 5x5 main grid to ensure good boundary and corner utilization, + # and one additional interstitial circle to fill a gap. This strategy + # previously yielded a higher sum of radii compared to the current 5-5-6-5-5 layout. + + # 1. Main 5x5 Grid (25 circles) + # This configuration places circle centers such that they are initially 0.1 units + # away from the borders, allowing for a good initial radius. + d = 0.1 # Initial radius and half-spacing + spacing = 2 * d # Distance between centers is 0.2 + offset = d # Distance from wall to first center is 0.1 + + for i in range(5): + for j in range(5): + centers[idx] = [offset + i * spacing, offset + j * spacing] + idx += 1 + + # 2. Additional Interstitial Circle (1 circle) + # Place the 26th circle in a significant gap created by the 5x5 grid. + # An interstitial point like (0.2, 0.2) is a good candidate to maximize overall radius sum. + centers[idx] = [0.2, 0.2] + idx += 1 +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6215285b9f2297b0a3a3df0b7bc11c58871666ad Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..a1a77d322887559cf4f6d2ff097f7db12f7119c8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/edit.diff @@ -0,0 +1,243 @@ +--- a/original.py ++++ b/original.py +@@ -1,168 +1,184 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + +-def _get_interstitial_candidates(): +- """Generates a 4x4 grid of candidate points for the interstitial circle.""" +- coords = np.linspace(0.2, 0.8, 4) +- return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) ++def _generate_interstitial_candidates(grid_size, start_coord, end_coord): ++ """ ++ Generates potential interstitial points within the grid cells. ++ For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. ++ """ ++ if grid_size < 2: ++ return np.array([]) ++ step = (end_coord - start_coord) / (grid_size - 1) ++ interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) ++ return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + +-def _get_base_centers(): ++def _generate_base_grid_and_central_centers(grid_size, start_coord, end_coord): + """ +- Generates the 25 base circle centers, with the central circle first +- for priority during radius relaxation. ++ Generates the 25 base circle centers (1 central + 24 grid), with the central circle first ++ for priority during radius relaxation. The central circle remains at (0.5, 0.5). + """ +- # 1. Central circle at (0.5, 0.5) +- central_center = np.array([[0.5, 0.5]]) ++ central_point_coords = np.array([[0.5, 0.5]]) + +- # 2. 24 grid circles from a 5x5 grid, skipping the center +- grid_size = 5 +- coords = np.linspace(0.1, 0.9, grid_size) +- grid_centers = [] +- for i in range(grid_size): +- for j in range(grid_size): +- if i == 2 and j == 2: +- continue +- grid_centers.append([coords[j], coords[i]]) ++ coords = np.linspace(start_coord, end_coord, grid_size) ++ all_grid_centers = np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + +- return central_center, np.array(grid_centers) ++ # Identify the grid point closest to (0.5, 0.5) to ensure we don't accidentally remove a non-central point. ++ distances_to_true_center = np.linalg.norm(all_grid_centers - np.array([0.5, 0.5]), axis=1) ++ central_idx_in_all_grid = np.argmin(distances_to_true_center) ++ ++ # Remove the grid point closest to (0.5,0.5) to make space for the explicitly placed central circle. ++ other_grid_centers = np.delete(all_grid_centers, central_idx_in_all_grid, axis=0) ++ ++ # Ensure we have 24 grid circles remaining. ++ if len(other_grid_centers) != 24: ++ raise ValueError("Expected 24 other grid centers after removing one closest to 0.5,0.5") ++ ++ return central_point_coords, other_grid_centers + + + def construct_packing(): + """ + Constructs a circle packing by searching for the optimal position of one + interstitial circle and the optimal perturbation of its neighbors. + + This version changes the program structure from a static constructor to + a search-based optimizer. It iterates through a parameter space of + configurations to find a better packing. + """ + best_sum_radii = -1.0 + best_centers = None + best_radii = None + +- # Define the search space for interstitial position and perturbation strength +- interstitial_candidates = _get_interstitial_candidates() +- perturbation_deltas = [0.0, 0.01, 0.015, 0.02, 0.025] ++ n_circles = 26 ++ grid_size = 5 + +- # Pre-generate the static part of the configuration +- central_center, base_grid_centers = _get_base_centers() ++ # Define the search space for grid boundary parameter ++ start_coord_search_space = np.linspace(0.08, 0.12, 5) # Range found effective in prior high-scoring programs ++ perturbation_deltas = [0.0, 0.01, 0.02] # Reduced search space for faster evaluation + +- # --- Search Loop --- +- for interstitial_point in interstitial_candidates: +- for delta in perturbation_deltas: +- # 1. Create a mutable copy of grid centers for this iteration +- current_grid_centers = np.copy(base_grid_centers) ++ # --- Main Search Loop --- ++ for start_coord in start_coord_search_space: ++ end_coord = 1.0 - start_coord + +- # 2. Apply a dynamic, context-aware perturbation +- if delta > 0: +- # Find 4 nearest grid neighbors to the current interstitial point +- distances = np.linalg.norm(current_grid_centers - interstitial_point, axis=1) +- neighbor_indices = np.argsort(distances)[:4] ++ # Pre-generate the static part of the configuration for current grid boundaries ++ central_center, base_grid_centers = _generate_base_grid_and_central_centers(grid_size, start_coord, end_coord) ++ interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + +- # Move neighbors away from the interstitial point +- for idx in neighbor_indices: +- # Vector from interstitial point to the neighbor +- vec = current_grid_centers[idx] - interstitial_point +- norm_vec = vec / (np.linalg.norm(vec) + 1e-9) # Normalized vector +- current_grid_centers[idx] += norm_vec * delta ++ # Inner Search Loop for interstitial position and perturbation strength ++ for interstitial_point in interstitial_candidates: ++ for delta in perturbation_deltas: ++ # 1. Create a mutable copy of grid centers for this iteration ++ current_grid_centers = np.copy(base_grid_centers) + +- # 3. Assemble the full set of 26 centers for evaluation +- # Order: [central, 24 perturbed grid, 1 interstitial] +- current_centers = np.vstack([central_center, current_grid_centers, [interstitial_point]]) ++ # 2. Apply a dynamic, context-aware perturbation ++ if delta > 0: ++ # Find 4 nearest grid neighbors to the current interstitial point ++ distances = np.linalg.norm(current_grid_centers - interstitial_point, axis=1) ++ neighbor_indices = np.argsort(distances)[:4] + +- # Clip centers to be safely within the box after perturbation +- current_centers = np.clip(current_centers, 0.001, 0.999) ++ # Move neighbors away from the interstitial point ++ for idx in neighbor_indices: ++ # Vector from interstitial point to the neighbor ++ vec = current_grid_centers[idx] - interstitial_point ++ norm_vec = vec / (np.linalg.norm(vec) + 1e-9) # Normalized vector ++ current_grid_centers[idx] += norm_vec * delta + +- # 4. Compute radii and evaluate the configuration's score +- # The interstitial circle is always the last one added (index n_circles - 1) +- n_circles = 26 # Define n_circles here for consistency +- interstitial_idx = n_circles - 1 +- radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) +- current_sum_radii = np.sum(radii) ++ # 3. Assemble the full set of 26 centers for evaluation ++ # Order: [central, 24 perturbed grid, 1 interstitial] ++ current_centers = np.vstack([central_center, current_grid_centers, [interstitial_point]]) + +- # 5. Keep track of the best result found so far +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = radii ++ # Clip centers to be safely within the box after perturbation ++ current_centers = np.clip(current_centers, 0.001, 0.999) ++ ++ # 4. Compute radii and evaluate the configuration's score ++ # The interstitial circle is always the last one added (index n_circles - 1) ++ interstitial_idx = n_circles - 1 ++ radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) ++ current_sum_radii = np.sum(radii) ++ ++ # 5. Keep track of the best result found so far ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = current_centers ++ best_radii = radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # Initialize radii based on distance to boundaries + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # Iteratively resolve overlaps and expand radii + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # For simplicity, all other circles have weight 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero for tiny radii + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/main.py new file mode 100644 index 0000000000000000000000000000000000000000..6cbb8b10a590edc9c4a3a17573dd9c3717f7f540 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/main.py @@ -0,0 +1,184 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + +def _generate_base_grid_and_central_centers(grid_size, start_coord, end_coord): + """ + Generates the 25 base circle centers (1 central + 24 grid), with the central circle first + for priority during radius relaxation. The central circle remains at (0.5, 0.5). + """ + central_point_coords = np.array([[0.5, 0.5]]) + + coords = np.linspace(start_coord, end_coord, grid_size) + all_grid_centers = np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + # Identify the grid point closest to (0.5, 0.5) to ensure we don't accidentally remove a non-central point. + distances_to_true_center = np.linalg.norm(all_grid_centers - np.array([0.5, 0.5]), axis=1) + central_idx_in_all_grid = np.argmin(distances_to_true_center) + + # Remove the grid point closest to (0.5,0.5) to make space for the explicitly placed central circle. + other_grid_centers = np.delete(all_grid_centers, central_idx_in_all_grid, axis=0) + + # Ensure we have 24 grid circles remaining. + if len(other_grid_centers) != 24: + raise ValueError("Expected 24 other grid centers after removing one closest to 0.5,0.5") + + return central_point_coords, other_grid_centers + + +def construct_packing(): + """ + Constructs a circle packing by searching for the optimal position of one + interstitial circle and the optimal perturbation of its neighbors. + + This version changes the program structure from a static constructor to + a search-based optimizer. It iterates through a parameter space of + configurations to find a better packing. + """ + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + n_circles = 26 + grid_size = 5 + + # Define the search space for grid boundary parameter + start_coord_search_space = np.linspace(0.08, 0.12, 5) # Range found effective in prior high-scoring programs + perturbation_deltas = [0.0, 0.01, 0.02] # Reduced search space for faster evaluation + + # --- Main Search Loop --- + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + # Pre-generate the static part of the configuration for current grid boundaries + central_center, base_grid_centers = _generate_base_grid_and_central_centers(grid_size, start_coord, end_coord) + interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # Inner Search Loop for interstitial position and perturbation strength + for interstitial_point in interstitial_candidates: + for delta in perturbation_deltas: + # 1. Create a mutable copy of grid centers for this iteration + current_grid_centers = np.copy(base_grid_centers) + + # 2. Apply a dynamic, context-aware perturbation + if delta > 0: + # Find 4 nearest grid neighbors to the current interstitial point + distances = np.linalg.norm(current_grid_centers - interstitial_point, axis=1) + neighbor_indices = np.argsort(distances)[:4] + + # Move neighbors away from the interstitial point + for idx in neighbor_indices: + # Vector from interstitial point to the neighbor + vec = current_grid_centers[idx] - interstitial_point + norm_vec = vec / (np.linalg.norm(vec) + 1e-9) # Normalized vector + current_grid_centers[idx] += norm_vec * delta + + # 3. Assemble the full set of 26 centers for evaluation + # Order: [central, 24 perturbed grid, 1 interstitial] + current_centers = np.vstack([central_center, current_grid_centers, [interstitial_point]]) + + # Clip centers to be safely within the box after perturbation + current_centers = np.clip(current_centers, 0.001, 0.999) + + # 4. Compute radii and evaluate the configuration's score + # The interstitial circle is always the last one added (index n_circles - 1) + interstitial_idx = n_circles - 1 + radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(radii) + + # 5. Keep track of the best result found so far + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # Initialize radii based on distance to boundaries + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # Iteratively resolve overlaps and expand radii + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # For simplicity, all other circles have weight 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero for tiny radii + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/original.py new file mode 100644 index 0000000000000000000000000000000000000000..924880fdf52537ce5787ff658119f3b59f510b9a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/original.py @@ -0,0 +1,168 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _get_interstitial_candidates(): + """Generates a 4x4 grid of candidate points for the interstitial circle.""" + coords = np.linspace(0.2, 0.8, 4) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + +def _get_base_centers(): + """ + Generates the 25 base circle centers, with the central circle first + for priority during radius relaxation. + """ + # 1. Central circle at (0.5, 0.5) + central_center = np.array([[0.5, 0.5]]) + + # 2. 24 grid circles from a 5x5 grid, skipping the center + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + grid_centers = [] + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: + continue + grid_centers.append([coords[j], coords[i]]) + + return central_center, np.array(grid_centers) + + +def construct_packing(): + """ + Constructs a circle packing by searching for the optimal position of one + interstitial circle and the optimal perturbation of its neighbors. + + This version changes the program structure from a static constructor to + a search-based optimizer. It iterates through a parameter space of + configurations to find a better packing. + """ + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Define the search space for interstitial position and perturbation strength + interstitial_candidates = _get_interstitial_candidates() + perturbation_deltas = [0.0, 0.01, 0.015, 0.02, 0.025] + + # Pre-generate the static part of the configuration + central_center, base_grid_centers = _get_base_centers() + + # --- Search Loop --- + for interstitial_point in interstitial_candidates: + for delta in perturbation_deltas: + # 1. Create a mutable copy of grid centers for this iteration + current_grid_centers = np.copy(base_grid_centers) + + # 2. Apply a dynamic, context-aware perturbation + if delta > 0: + # Find 4 nearest grid neighbors to the current interstitial point + distances = np.linalg.norm(current_grid_centers - interstitial_point, axis=1) + neighbor_indices = np.argsort(distances)[:4] + + # Move neighbors away from the interstitial point + for idx in neighbor_indices: + # Vector from interstitial point to the neighbor + vec = current_grid_centers[idx] - interstitial_point + norm_vec = vec / (np.linalg.norm(vec) + 1e-9) # Normalized vector + current_grid_centers[idx] += norm_vec * delta + + # 3. Assemble the full set of 26 centers for evaluation + # Order: [central, 24 perturbed grid, 1 interstitial] + current_centers = np.vstack([central_center, current_grid_centers, [interstitial_point]]) + + # Clip centers to be safely within the box after perturbation + current_centers = np.clip(current_centers, 0.001, 0.999) + + # 4. Compute radii and evaluate the configuration's score + # The interstitial circle is always the last one added (index n_circles - 1) + n_circles = 26 # Define n_circles here for consistency + interstitial_idx = n_circles - 1 + radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(radii) + + # 5. Keep track of the best result found so far + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # Initialize radii based on distance to boundaries + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # Iteratively resolve overlaps and expand radii + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # For simplicity, all other circles have weight 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero for tiny radii + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4f2fa0fa5d20eb774470ee593633a23aae91f72e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9262086329869444, + "spatial_uniformity_details": { + "cell_size_mean": 0.19918567919627053, + "cell_size_std": 0.015869193082024863, + "coefficient_of_variation": 0.07967035113361523 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6507510260642492, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013170432818898175, + "mean_density": 0.021383546041597867, + "cv": 0.5366860134635718 + }, + "packing_efficiency": 0.5976921448748342, + "packing_efficiency_details": { + "total_area": 0.5976921448748342, + "square_area": 1.0, + "efficiency": 0.5976921448748342, + "relative_to_estimated_best": 0.711538267708136 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08344656629652222, + "std": 0.0188156578764126, + "min": 0.021087230548853864, + "max": 0.10168799482571135, + "range": 0.08060076427685749, + "small_count": 6, + "medium_count": 9, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.5936, + "gap_analysis_details": { + "covered_samples": 1484, + "total_samples": 2500, + "coverage": 0.5936, + "gap_ratio": 0.4064 + }, + "geometric_quality": 0.6967135021967905, + "geometric_quality_details": { + "num_triangles": 35, + "avg_triangle_quality": 0.6967135021967905, + "min_quality": 0.4912522368342203, + "max_quality": 0.7075815525423831 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..a9b8417720260255d1988cbbdd6e97e9b3566c3c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.53 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1696 + + Auxiliary Metrics: + • spatial_uniformity: 0.926 + • edge_utilization: 0.723 + • density_variance: 0.651 + • packing_efficiency: 0.598 + • radius_distribution: 0.974 + • gap_analysis: 0.594 + • geometric_quality: 0.697 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1696 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.926 + • Boundary and corner utilization: 0.723 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.651 + • Area utilization efficiency: 0.598 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.594 + • Delaunay triangulation quality: 0.697 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 40.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..f6d44bdb5e660141df2e9999173ba65fe5a9a43b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1696107237095776, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.1000, 0.3000)\n centers[3] = (0.1000, 0.5000)\n centers[4] = (0.1000, 0.7000)\n centers[5] = (0.1000, 0.9000)\n centers[6] = (0.3000, 0.1000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.3000, 0.5000)\n centers[9] = (0.2929, 0.6929)\n centers[10] = (0.2929, 0.9071)\n centers[11] = (0.5000, 0.1000)\n centers[12] = (0.5000, 0.3000)\n centers[13] = (0.5071, 0.6929)\n centers[14] = (0.5071, 0.9071)\n centers[15] = (0.7000, 0.1000)\n centers[16] = (0.7000, 0.3000)\n centers[17] = (0.7000, 0.5000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.7000, 0.9000)\n centers[20] = (0.9000, 0.1000)\n centers[21] = (0.9000, 0.3000)\n centers[22] = (0.9000, 0.5000)\n centers[23] = (0.9000, 0.7000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.8000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9262086329869444, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6507510260642492, + "aux_packing_efficiency": 0.5976921448748342, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.5936, + "aux_geometric_quality": 0.6967135021967905 + }, + "private": { + "reported_sum_of_radii": 2.1696107237095776 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1696\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.926\n \u2022 Boundary and corner utilization: 0.723\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.651\n \u2022 Area utilization efficiency: 0.598\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.594\n \u2022 Delaunay triangulation quality: 0.697\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 40.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/results/packing_viz.png", + "execution_time_mean": 0.5330785908736289, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..1487662b9c18c9dae63e9acafb5e48290864aef0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_102/search_replace.txt @@ -0,0 +1,198 @@ +grid_boundary_search +Introduce a systematic search over `start_coord` and `end_coord` for the grid, as `start_coord` significantly impacts edge utilization and overall packing density. This was a successful pattern in a previous high-scoring program. The interstitial candidates are now also generated relative to this dynamic grid boundary. This should improve `packing_efficiency` and `gap_analysis` by finding a better-fitting grid. + +The helper functions `_get_interstitial_candidates` and `_get_base_centers` are modified to accept `grid_size`, `start_coord`, and `end_coord` to support this dynamic search. Their implementation is also updated to be more robust and consistent with grid-based interstitial generation. +The main `construct_packing` function now includes an outer loop that iterates through various `start_coord` values, re-generating the grid and interstitial candidates for each. This allows the packing to adapt to different boundary conditions. To keep the search space manageable, the `start_coord_search_space` and `perturbation_deltas` ranges have been adjusted. + +<<<<<<< SEARCH +def _get_interstitial_candidates(): + """Generates a 4x4 grid of candidate points for the interstitial circle.""" + coords = np.linspace(0.2, 0.8, 4) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + +def _get_base_centers(): + """ + Generates the 25 base circle centers, with the central circle first + for priority during radius relaxation. + """ + # 1. Central circle at (0.5, 0.5) + central_center = np.array([[0.5, 0.5]]) + + # 2. 24 grid circles from a 5x5 grid, skipping the center + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + grid_centers = [] + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: + continue + grid_centers.append([coords[j], coords[i]]) + + return central_center, np.array(grid_centers) + + +def construct_packing(): + """ + Constructs a circle packing by searching for the optimal position of one + interstitial circle and the optimal perturbation of its neighbors. + + This version changes the program structure from a static constructor to + a search-based optimizer. It iterates through a parameter space of + configurations to find a better packing. + """ + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Define the search space for interstitial position and perturbation strength + interstitial_candidates = _get_interstitial_candidates() + perturbation_deltas = [0.0, 0.01, 0.015, 0.02, 0.025] + + # Pre-generate the static part of the configuration + central_center, base_grid_centers = _get_base_centers() + + # --- Search Loop --- + for interstitial_point in interstitial_candidates: + for delta in perturbation_deltas: + # 1. Create a mutable copy of grid centers for this iteration + current_grid_centers = np.copy(base_grid_centers) + + # 2. Apply a dynamic, context-aware perturbation + if delta > 0: + # Find 4 nearest grid neighbors to the current interstitial point + distances = np.linalg.norm(current_grid_centers - interstitial_point, axis=1) + neighbor_indices = np.argsort(distances)[:4] + + # Move neighbors away from the interstitial point + for idx in neighbor_indices: + # Vector from interstitial point to the neighbor + vec = current_grid_centers[idx] - interstitial_point + norm_vec = vec / (np.linalg.norm(vec) + 1e-9) # Normalized vector + current_grid_centers[idx] += norm_vec * delta + + # 3. Assemble the full set of 26 centers for evaluation + # Order: [central, 24 perturbed grid, 1 interstitial] + current_centers = np.vstack([central_center, current_grid_centers, [interstitial_point]]) + + # Clip centers to be safely within the box after perturbation + current_centers = np.clip(current_centers, 0.001, 0.999) + + # 4. Compute radii and evaluate the configuration's score + # The interstitial circle is always the last one added (index n_circles - 1) + n_circles = 26 # Define n_circles here for consistency + interstitial_idx = n_circles - 1 + radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(radii) + + # 5. Keep track of the best result found so far + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = radii + + return best_centers, best_radii +======= +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + +def _generate_base_grid_and_central_centers(grid_size, start_coord, end_coord): + """ + Generates the 25 base circle centers (1 central + 24 grid), with the central circle first + for priority during radius relaxation. The central circle remains at (0.5, 0.5). + """ + central_point_coords = np.array([[0.5, 0.5]]) + + coords = np.linspace(start_coord, end_coord, grid_size) + all_grid_centers = np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + # Identify the grid point closest to (0.5, 0.5) to ensure we don't accidentally remove a non-central point. + distances_to_true_center = np.linalg.norm(all_grid_centers - np.array([0.5, 0.5]), axis=1) + central_idx_in_all_grid = np.argmin(distances_to_true_center) + + # Remove the grid point closest to (0.5,0.5) to make space for the explicitly placed central circle. + other_grid_centers = np.delete(all_grid_centers, central_idx_in_all_grid, axis=0) + + # Ensure we have 24 grid circles remaining. + if len(other_grid_centers) != 24: + raise ValueError("Expected 24 other grid centers after removing one closest to 0.5,0.5") + + return central_point_coords, other_grid_centers + + +def construct_packing(): + """ + Constructs a circle packing by searching for the optimal position of one + interstitial circle and the optimal perturbation of its neighbors. + + This version changes the program structure from a static constructor to + a search-based optimizer. It iterates through a parameter space of + configurations to find a better packing. + """ + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + n_circles = 26 + grid_size = 5 + + # Define the search space for grid boundary parameter + start_coord_search_space = np.linspace(0.08, 0.12, 5) # Range found effective in prior high-scoring programs + perturbation_deltas = [0.0, 0.01, 0.02] # Reduced search space for faster evaluation + + # --- Main Search Loop --- + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + # Pre-generate the static part of the configuration for current grid boundaries + central_center, base_grid_centers = _generate_base_grid_and_central_centers(grid_size, start_coord, end_coord) + interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # Inner Search Loop for interstitial position and perturbation strength + for interstitial_point in interstitial_candidates: + for delta in perturbation_deltas: + # 1. Create a mutable copy of grid centers for this iteration + current_grid_centers = np.copy(base_grid_centers) + + # 2. Apply a dynamic, context-aware perturbation + if delta > 0: + # Find 4 nearest grid neighbors to the current interstitial point + distances = np.linalg.norm(current_grid_centers - interstitial_point, axis=1) + neighbor_indices = np.argsort(distances)[:4] + + # Move neighbors away from the interstitial point + for idx in neighbor_indices: + # Vector from interstitial point to the neighbor + vec = current_grid_centers[idx] - interstitial_point + norm_vec = vec / (np.linalg.norm(vec) + 1e-9) # Normalized vector + current_grid_centers[idx] += norm_vec * delta + + # 3. Assemble the full set of 26 centers for evaluation + # Order: [central, 24 perturbed grid, 1 interstitial] + current_centers = np.vstack([central_center, current_grid_centers, [interstitial_point]]) + + # Clip centers to be safely within the box after perturbation + current_centers = np.clip(current_centers, 0.001, 0.999) + + # 4. Compute radii and evaluate the configuration's score + # The interstitial circle is always the last one added (index n_circles - 1) + interstitial_idx = n_circles - 1 + radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(radii) + + # 5. Keep track of the best result found so far + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = radii + + return best_centers, best_radii +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c512ff1ac76a254fbbfb2afa93e496855e45d97d Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..228c3de6e74ba7c6c93012a3c9c0fb1327a01955 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8802248193193365, + "spatial_uniformity_details": { + "cell_size_mean": 0.19736041730378753, + "cell_size_std": 0.02685550241565221, + "coefficient_of_variation": 0.13607339630946064 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.6434635292946417, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00014985448562135342, + "mean_density": 0.022093006966367207, + "cv": 0.5540896328595187 + }, + "packing_efficiency": 0.6212618985207012, + "packing_efficiency_details": { + "total_area": 0.6212618985207012, + "square_area": 1.0, + "efficiency": 0.6212618985207012, + "relative_to_estimated_best": 0.7395974982389301 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.0853251197057126, + "std": 0.018042713035590515, + "min": 0.0321579654943708, + "max": 0.11001227108607238, + "range": 0.07785430559170159, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.6288, + "gap_analysis_details": { + "covered_samples": 1572, + "total_samples": 2500, + "coverage": 0.6288, + "gap_ratio": 0.3712 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865471, + "max_quality": 0.7071067811865479 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..b6c45538a6197067c6ea3cf14eea5b4e2ad9e34c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 59.09 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2185 + + Auxiliary Metrics: + • spatial_uniformity: 0.880 + • edge_utilization: 0.738 + • density_variance: 0.643 + • packing_efficiency: 0.621 + • radius_distribution: 0.974 + • gap_analysis: 0.629 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2185 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.880 + • Boundary and corner utilization: 0.738 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.643 + • Area utilization efficiency: 0.621 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.629 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 37.1% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..23ad6f4050de9007b2211bb5312cd0d48de4abf4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2184531123485276, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4000, 0.2000)\n centers[25] = (0.6000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8802248193193365, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.6434635292946417, + "aux_packing_efficiency": 0.6212618985207012, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.6288, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.2184531123485276 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2185\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.880\n \u2022 Boundary and corner utilization: 0.738\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.643\n \u2022 Area utilization efficiency: 0.621\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.629\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 37.1% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_104/results/packing_viz.png", + "execution_time_mean": 59.09231684124097, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7b48d2e18a3f63d4da6d4218c35d377f0c8da8ec Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..7a3009904cd0f501770a5caffd644282eb457cd9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576736 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5105830537596325, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00021141110769266143, + "mean_density": 0.015168801418505552, + "cv": 0.9585452212653547 + }, + "packing_efficiency": 0.49857578883693093, + "packing_efficiency_details": { + "total_area": 0.49857578883693093, + "square_area": 1.0, + "efficiency": 0.49857578883693093, + "relative_to_estimated_best": 0.5935426057582511 + }, + "radius_distribution": 0.8828951237442825, + "radius_distribution_details": { + "mean": 0.07473483850156191, + "std": 0.022773047806612795, + "min": 0.03946019296101107, + "max": 0.10261558125579376, + "range": 0.06315538829478269, + "small_count": 11, + "medium_count": 3, + "large_count": 12, + "diversity_score": 0.8828951237442825 + }, + "gap_analysis": 0.498, + "gap_analysis_details": { + "covered_samples": 1245, + "total_samples": 2500, + "coverage": 0.498, + "gap_ratio": 0.502 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..53999cc3cbb86eb6a6b05414f0267a2c92ae1ff8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.36 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9431 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.511 + • packing_efficiency: 0.499 + • radius_distribution: 0.883 + • gap_analysis: 0.498 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9431 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.499 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.498 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.511 + • Radius size diversity: 0.883 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 50.2% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..fd4f6078213341a07dbeb6abb7b2dcd871f288e9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9431058010406097, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.5000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5105830537596325, + "aux_packing_efficiency": 0.49857578883693093, + "aux_radius_distribution": 0.8828951237442825, + "aux_gap_analysis": 0.498, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9431058010406097 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9431\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.499\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.498\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.511\n \u2022 Radius size diversity: 0.883\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 50.2% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_107/results/packing_viz.png", + "execution_time_mean": 0.3565068142488599, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..74d38c5bd70d01fcc0a153fda7b80e2e0ae08a6e Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5c327313348259d4bd43d75faea831eb4ba556c9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8802248193193365, + "spatial_uniformity_details": { + "cell_size_mean": 0.19736041730378753, + "cell_size_std": 0.02685550241565221, + "coefficient_of_variation": 0.13607339630946064 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.662240135647969, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013350998874884403, + "mean_density": 0.022655013063977415, + "cv": 0.5100262671659876 + }, + "packing_efficiency": 0.6216487529561742, + "packing_efficiency_details": { + "total_area": 0.6216487529561742, + "square_area": 1.0, + "efficiency": 0.6216487529561742, + "relative_to_estimated_best": 0.7400580392335407 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08544772261069246, + "std": 0.017588018229831755, + "min": 0.03763886318562511, + "max": 0.1110746929211277, + "range": 0.0734358297355026, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.6336, + "gap_analysis_details": { + "covered_samples": 1584, + "total_samples": 2500, + "coverage": 0.6336, + "gap_ratio": 0.36639999999999995 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865471, + "max_quality": 0.7071067811865479 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3e84c896b5b12d33b1f1e725b23e5f4848841cbf --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 59.02 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2216 + + Auxiliary Metrics: + • spatial_uniformity: 0.880 + • edge_utilization: 0.738 + • density_variance: 0.662 + • packing_efficiency: 0.622 + • radius_distribution: 0.974 + • gap_analysis: 0.634 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2216 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.880 + • Boundary and corner utilization: 0.738 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.662 + • Area utilization efficiency: 0.622 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.634 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 36.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..4fe5a7c897794e9ecab7aaeb1301e5f1e8d47013 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.221640787878004, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4000, 0.2000)\n centers[25] = (0.6000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8802248193193365, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.662240135647969, + "aux_packing_efficiency": 0.6216487529561742, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.6336, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.221640787878004 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2216\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.880\n \u2022 Boundary and corner utilization: 0.738\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.662\n \u2022 Area utilization efficiency: 0.622\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.634\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 36.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_108/results/packing_viz.png", + "execution_time_mean": 59.0213918578811, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7a1ffc5e54055bedc7f27bdec5b23dcf37285182 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f90fdcf6a80d6ce6a2dfbc9f2eb02fa971d70a01 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.017519526578765064, + "coefficient_of_variation": 0.08804167661183826 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6653173552577553, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00011640972508199662, + "mean_density": 0.021448171409387297, + "cv": 0.5030421077961856 + }, + "packing_efficiency": 0.5934508890040798, + "packing_efficiency_details": { + "total_area": 0.5934508890040798, + "square_area": 1.0, + "efficiency": 0.5934508890040798, + "relative_to_estimated_best": 0.7064891535762855 + }, + "radius_distribution": 0.9903496169664631, + "radius_distribution_details": { + "mean": 0.08363012016372973, + "std": 0.016475346349763585, + "min": 0.034061396543213454, + "max": 0.1020139199022079, + "range": 0.06795252335899445, + "small_count": 9, + "medium_count": 7, + "large_count": 10, + "diversity_score": 0.9903496169664631 + }, + "gap_analysis": 0.6032, + "gap_analysis_details": { + "covered_samples": 1508, + "total_samples": 2500, + "coverage": 0.6032, + "gap_ratio": 0.39680000000000004 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..0c5a037f33986b995464b7982355a038c31a69d3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 5.63 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1744 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.665 + • packing_efficiency: 0.593 + • radius_distribution: 0.990 + • gap_analysis: 0.603 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1744 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.665 + • Area utilization efficiency: 0.593 + • Radius size diversity: 0.990 + • Area coverage (1 - gap ratio): 0.603 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 39.7% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..75770f6a33ffcf2fea93d7fce44daee231df07cf --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.174383124256973, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6653173552577553, + "aux_packing_efficiency": 0.5934508890040798, + "aux_radius_distribution": 0.9903496169664631, + "aux_gap_analysis": 0.6032, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.174383124256973 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1744\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.665\n \u2022 Area utilization efficiency: 0.593\n \u2022 Radius size diversity: 0.990\n \u2022 Area coverage (1 - gap ratio): 0.603\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 39.7% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_109/results/packing_viz.png", + "execution_time_mean": 5.629588218405843, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..631e364351fd32f014c8f3d0e46e8a8fe6713a48 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..36c8edab3678e0e94205036da21e60a800920485 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/edit.diff @@ -0,0 +1,139 @@ +--- a/original.py ++++ b/original.py +@@ -1,107 +1,123 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + # Initialize arrays for 26 circles + n = 26 + centers = np.zeros((n, 2)) + idx = 0 + +- # Strategy: A 5x5 main grid for 25 circles, providing excellent base +- # coverage and boundary utilization, plus one interstitial circle. ++ # Strategy: A symmetric layered structure of 5-5-6-5-5 circles. ++ # This provides a dense packing with good spatial uniformity and improved ++ # overall coverage compared to a simple 5x5 grid with one outlier. + +- # 1. Main 5x5 Grid (25 circles) +- # This configuration is based on the optimal packing for 25 circles. +- coords = np.linspace(0.1, 0.9, 5) +- for i in range(5): +- for j in range(5): +- centers[idx] = [coords[i], coords[j]] ++ # Y-coordinates for the five rows ++ y_coords = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) ++ ++ # X-coordinates for rows with 5 circles ++ x_coords_5 = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) ++ ++ # X-coordinates for the central row with 6 circles. ++ # Modified to use 0.1 and 0.9 as bounds for consistency with 5-circle rows, ++ # aiming for better edge utilization and potentially larger radii. ++ x_coords_6 = np.linspace(0.1, 0.9, 6) ++ ++ # Place circles in rows with 5 circles (y-coords 0.1, 0.3, 0.7, 0.9) ++ # This covers 4 * 5 = 20 circles. ++ row_indices_5 = [0, 1, 3, 4] ++ for i in row_indices_5: ++ y = y_coords[i] ++ for x in x_coords_5: ++ centers[idx] = [x, y] + idx += 1 + +- # 2. Additional Interstitial Circle (1 circle) +- # Place the 26th circle in a large gap created by the 5x5 grid. The gap +- # at (0.2, 0.2) is a good candidate, centered between four grid circles. +- centers[25] = [0.2, 0.2] ++ # Place circles in the central row with 6 circles (y-coord 0.5) ++ # This covers the remaining 6 circles, bringing the total to 26. ++ central_row_index = 2 ++ y = y_coords[central_row_index] ++ for x in x_coords_6: ++ centers[idx] = [x, y] ++ idx += 1 + +- # Compute maximum valid radii for this configuration ++ # Compute maximum valid radii for this configuration using the robust iterative method + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop for better convergence + of radii given fixed center positions. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.ones(n) + + # 1. Limit radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively limit by distance to other circles until radii converge. + # This loop is crucial for ensuring all overlaps are resolved and radii + # are maximally grown given the fixed center positions. + max_sub_iterations = 200 # Sufficient iterations for robust convergence + tolerance = 1e-9 # Stop when changes are very small + + for _ in range(max_sub_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If current radii would cause overlap (with a tolerance) + if radii[i] + radii[j] > dist + tolerance: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_radii_i = radii[i] + old_radii_j = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check if significant change occurred + if not changed and (abs(radii[i] - old_radii_i) > tolerance or \ + abs(radii[j] - old_radii_j) > tolerance): + changed = True + if not changed: + break # Radii have converged sufficiently + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/main.py new file mode 100644 index 0000000000000000000000000000000000000000..b9c5896f798b522437b23715c5653a2d1bfc3e83 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/main.py @@ -0,0 +1,123 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + # Initialize arrays for 26 circles + n = 26 + centers = np.zeros((n, 2)) + idx = 0 + + # Strategy: A symmetric layered structure of 5-5-6-5-5 circles. + # This provides a dense packing with good spatial uniformity and improved + # overall coverage compared to a simple 5x5 grid with one outlier. + + # Y-coordinates for the five rows + y_coords = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) + + # X-coordinates for rows with 5 circles + x_coords_5 = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) + + # X-coordinates for the central row with 6 circles. + # Modified to use 0.1 and 0.9 as bounds for consistency with 5-circle rows, + # aiming for better edge utilization and potentially larger radii. + x_coords_6 = np.linspace(0.1, 0.9, 6) + + # Place circles in rows with 5 circles (y-coords 0.1, 0.3, 0.7, 0.9) + # This covers 4 * 5 = 20 circles. + row_indices_5 = [0, 1, 3, 4] + for i in row_indices_5: + y = y_coords[i] + for x in x_coords_5: + centers[idx] = [x, y] + idx += 1 + + # Place circles in the central row with 6 circles (y-coord 0.5) + # This covers the remaining 6 circles, bringing the total to 26. + central_row_index = 2 + y = y_coords[central_row_index] + for x in x_coords_6: + centers[idx] = [x, y] + idx += 1 + + # Compute maximum valid radii for this configuration using the robust iterative method + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop for better convergence + of radii given fixed center positions. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.ones(n) + + # 1. Limit radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively limit by distance to other circles until radii converge. + # This loop is crucial for ensuring all overlaps are resolved and radii + # are maximally grown given the fixed center positions. + max_sub_iterations = 200 # Sufficient iterations for robust convergence + tolerance = 1e-9 # Stop when changes are very small + + for _ in range(max_sub_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If current radii would cause overlap (with a tolerance) + if radii[i] + radii[j] > dist + tolerance: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_radii_i = radii[i] + old_radii_j = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check if significant change occurred + if not changed and (abs(radii[i] - old_radii_i) > tolerance or \ + abs(radii[j] - old_radii_j) > tolerance): + changed = True + if not changed: + break # Radii have converged sufficiently + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/original.py new file mode 100644 index 0000000000000000000000000000000000000000..4fa3295e3bb6ef7ab7033cd7c066ff3bce79357d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/original.py @@ -0,0 +1,107 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + # Initialize arrays for 26 circles + n = 26 + centers = np.zeros((n, 2)) + idx = 0 + + # Strategy: A 5x5 main grid for 25 circles, providing excellent base + # coverage and boundary utilization, plus one interstitial circle. + + # 1. Main 5x5 Grid (25 circles) + # This configuration is based on the optimal packing for 25 circles. + coords = np.linspace(0.1, 0.9, 5) + for i in range(5): + for j in range(5): + centers[idx] = [coords[i], coords[j]] + idx += 1 + + # 2. Additional Interstitial Circle (1 circle) + # Place the 26th circle in a large gap created by the 5x5 grid. The gap + # at (0.2, 0.2) is a good candidate, centered between four grid circles. + centers[25] = [0.2, 0.2] + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop for better convergence + of radii given fixed center positions. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.ones(n) + + # 1. Limit radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively limit by distance to other circles until radii converge. + # This loop is crucial for ensuring all overlaps are resolved and radii + # are maximally grown given the fixed center positions. + max_sub_iterations = 200 # Sufficient iterations for robust convergence + tolerance = 1e-9 # Stop when changes are very small + + for _ in range(max_sub_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If current radii would cause overlap (with a tolerance) + if radii[i] + radii[j] > dist + tolerance: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_radii_i = radii[i] + old_radii_j = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check if significant change occurred + if not changed and (abs(radii[i] - old_radii_i) > tolerance or \ + abs(radii[j] - old_radii_j) > tolerance): + changed = True + if not changed: + break # Radii have converged sufficiently + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..09c4c1e7fffca3c2577d0ef57bdb418367ede4a8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9314347181917908, + "spatial_uniformity_details": { + "cell_size_mean": 0.19961673840457253, + "cell_size_std": 0.014694296576662642, + "coefficient_of_variation": 0.07361254682595045 + }, + "edge_utilization": 0.5423076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 6, + "corner_score": 0.75, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.48029739461536514, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00017960349310577412, + "mean_density": 0.012385475689155824, + "cv": 1.0820433573261967 + }, + "packing_efficiency": 0.4470101147692018, + "packing_efficiency_details": { + "total_area": 0.4470101147692018, + "square_area": 1.0, + "efficiency": 0.4470101147692018, + "relative_to_estimated_best": 0.532154898534764 + }, + "radius_distribution": 0.9986351900937254, + "radius_distribution_details": { + "mean": 0.07099750157814955, + "std": 0.020783649977774505, + "min": 0.033855379925845905, + "max": 0.09999999999999998, + "range": 0.06614462007415407, + "small_count": 8, + "medium_count": 9, + "large_count": 9, + "diversity_score": 0.9986351900937254 + }, + "gap_analysis": 0.4404, + "gap_analysis_details": { + "covered_samples": 1101, + "total_samples": 2500, + "coverage": 0.4404, + "gap_ratio": 0.5596 + }, + "geometric_quality": 0.7233963440447444, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7233963440447444, + "min_quality": 0.6246950475544243, + "max_quality": 0.8574929257125443 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..6f6e94edc5317086652248d6f69ed3962886d332 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8459 + + Auxiliary Metrics: + • spatial_uniformity: 0.931 + • edge_utilization: 0.542 + • density_variance: 0.480 + • packing_efficiency: 0.447 + • radius_distribution: 0.999 + • gap_analysis: 0.440 + • geometric_quality: 0.723 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8459 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.931 + • Delaunay triangulation quality: 0.723 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.480 + → Balance circle density across different regions + • Area utilization efficiency: 0.447 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.440 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.542 + • Radius size diversity: 0.999 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 56.0% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..751cac569825452c8b84b10644bdbbecb429309c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8459350410318882, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.7000)\n centers[11] = (0.3000, 0.7000)\n centers[12] = (0.5000, 0.7000)\n centers[13] = (0.7000, 0.7000)\n centers[14] = (0.9000, 0.7000)\n centers[15] = (0.1000, 0.9000)\n centers[16] = (0.3000, 0.9000)\n centers[17] = (0.5000, 0.9000)\n centers[18] = (0.7000, 0.9000)\n centers[19] = (0.9000, 0.9000)\n centers[20] = (0.1000, 0.5000)\n centers[21] = (0.2600, 0.5000)\n centers[22] = (0.4200, 0.5000)\n centers[23] = (0.5800, 0.5000)\n centers[24] = (0.7400, 0.5000)\n centers[25] = (0.9000, 0.5000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9314347181917908, + "aux_edge_utilization": 0.5423076923076923, + "aux_density_variance": 0.48029739461536514, + "aux_packing_efficiency": 0.4470101147692018, + "aux_radius_distribution": 0.9986351900937254, + "aux_gap_analysis": 0.4404, + "aux_geometric_quality": 0.7233963440447444 + }, + "private": { + "reported_sum_of_radii": 1.8459350410318882 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8459\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.931\n \u2022 Delaunay triangulation quality: 0.723\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.480\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.447\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.440\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.542\n \u2022 Radius size diversity: 0.999\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 56.0% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/results/packing_viz.png", + "execution_time_mean": 0.0022509447298943996, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..b9c5896f798b522437b23715c5653a2d1bfc3e83 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_11/rewrite.txt @@ -0,0 +1,123 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + # Initialize arrays for 26 circles + n = 26 + centers = np.zeros((n, 2)) + idx = 0 + + # Strategy: A symmetric layered structure of 5-5-6-5-5 circles. + # This provides a dense packing with good spatial uniformity and improved + # overall coverage compared to a simple 5x5 grid with one outlier. + + # Y-coordinates for the five rows + y_coords = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) + + # X-coordinates for rows with 5 circles + x_coords_5 = np.array([0.1, 0.3, 0.5, 0.7, 0.9]) + + # X-coordinates for the central row with 6 circles. + # Modified to use 0.1 and 0.9 as bounds for consistency with 5-circle rows, + # aiming for better edge utilization and potentially larger radii. + x_coords_6 = np.linspace(0.1, 0.9, 6) + + # Place circles in rows with 5 circles (y-coords 0.1, 0.3, 0.7, 0.9) + # This covers 4 * 5 = 20 circles. + row_indices_5 = [0, 1, 3, 4] + for i in row_indices_5: + y = y_coords[i] + for x in x_coords_5: + centers[idx] = [x, y] + idx += 1 + + # Place circles in the central row with 6 circles (y-coord 0.5) + # This covers the remaining 6 circles, bringing the total to 26. + central_row_index = 2 + y = y_coords[central_row_index] + for x in x_coords_6: + centers[idx] = [x, y] + idx += 1 + + # Compute maximum valid radii for this configuration using the robust iterative method + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop for better convergence + of radii given fixed center positions. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.ones(n) + + # 1. Limit radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively limit by distance to other circles until radii converge. + # This loop is crucial for ensuring all overlaps are resolved and radii + # are maximally grown given the fixed center positions. + max_sub_iterations = 200 # Sufficient iterations for robust convergence + tolerance = 1e-9 # Stop when changes are very small + + for _ in range(max_sub_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If current radii would cause overlap (with a tolerance) + if radii[i] + radii[j] > dist + tolerance: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_radii_i = radii[i] + old_radii_j = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check if significant change occurred + if not changed and (abs(radii[i] - old_radii_i) > tolerance or \ + abs(radii[j] - old_radii_j) > tolerance): + changed = True + if not changed: + break # Radii have converged sufficiently + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ec3f7f65139ff9a8b1fa85d55ccf2c7c93065218 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f1af47085210764fc216a07c34750f1c74cd6ab2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9025481561329106, + "spatial_uniformity_details": { + "cell_size_mean": 0.19788394253348698, + "cell_size_std": 0.021366344873668446, + "coefficient_of_variation": 0.10797412105370094 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.5830887405128328, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00033254376514370613, + "mean_density": 0.025504418073140127, + "cv": 0.7150048191986855 + }, + "packing_efficiency": 0.63520368082137, + "packing_efficiency_details": { + "total_area": 0.63520368082137, + "square_area": 1.0, + "efficiency": 0.63520368082137, + "relative_to_estimated_best": 0.7561948581206787 + }, + "radius_distribution": 0.982944883585438, + "radius_distribution_details": { + "mean": 0.08393901002516543, + "std": 0.02703410868460706, + "min": 0.00886607423255575, + "max": 0.14827549657001646, + "range": 0.1394094223374607, + "small_count": 7, + "medium_count": 11, + "large_count": 8, + "diversity_score": 0.982944883585438 + }, + "gap_analysis": 0.6424, + "gap_analysis_details": { + "covered_samples": 1606, + "total_samples": 2500, + "coverage": 0.6424, + "gap_ratio": 0.35760000000000003 + }, + "geometric_quality": 0.6508639533790093, + "geometric_quality_details": { + "num_triangles": 43, + "avg_triangle_quality": 0.6508639533790093, + "min_quality": 0.24696480060824066, + "max_quality": 0.8425157095387555 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..666f46cf4572ba72839499693d65c582d913e9ed --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 165.49 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1824 + + Auxiliary Metrics: + • spatial_uniformity: 0.903 + • edge_utilization: 0.723 + • density_variance: 0.583 + • packing_efficiency: 0.635 + • radius_distribution: 0.983 + • gap_analysis: 0.642 + • geometric_quality: 0.651 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1824 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.903 + • Boundary and corner utilization: 0.723 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.583 + • Area utilization efficiency: 0.635 + • Radius size diversity: 0.983 + • Area coverage (1 - gap ratio): 0.642 + • Delaunay triangulation quality: 0.651 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 35.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..17bbf5a4d8f8806c94580a9458e1ca014100f23e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1824142606543013, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.1000, 0.3000)\n centers[3] = (0.1000, 0.5000)\n centers[4] = (0.1000, 0.7000)\n centers[5] = (0.0902, 0.9098)\n centers[6] = (0.3000, 0.1000)\n centers[7] = (0.2985, 0.3002)\n centers[8] = (0.3000, 0.5000)\n centers[9] = (0.3000, 0.7000)\n centers[10] = (0.2992, 0.9043)\n centers[11] = (0.4929, 0.0901)\n centers[12] = (0.4593, 0.2808)\n centers[13] = (0.4687, 0.6989)\n centers[14] = (0.5020, 0.8999)\n centers[15] = (0.6954, 0.1001)\n centers[16] = (0.6629, 0.4295)\n centers[17] = (0.6619, 0.7081)\n centers[18] = (0.7096, 0.9166)\n centers[19] = (0.9017, 0.0983)\n centers[20] = (0.8933, 0.3031)\n centers[21] = (0.9050, 0.5060)\n centers[22] = (0.9012, 0.7005)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.1895, 0.8010)\n centers[25] = (0.6150, 0.2322)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9025481561329106, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.5830887405128328, + "aux_packing_efficiency": 0.63520368082137, + "aux_radius_distribution": 0.982944883585438, + "aux_gap_analysis": 0.6424, + "aux_geometric_quality": 0.6508639533790093 + }, + "private": { + "reported_sum_of_radii": 2.1824142606543013 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1824\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.903\n \u2022 Boundary and corner utilization: 0.723\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.583\n \u2022 Area utilization efficiency: 0.635\n \u2022 Radius size diversity: 0.983\n \u2022 Area coverage (1 - gap ratio): 0.642\n \u2022 Delaunay triangulation quality: 0.651\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 35.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_110/results/packing_viz.png", + "execution_time_mean": 165.49249547487125, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6ddab8b8bb4dec96b36494e5cb5fc66080daccee Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5c327313348259d4bd43d75faea831eb4ba556c9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8802248193193365, + "spatial_uniformity_details": { + "cell_size_mean": 0.19736041730378753, + "cell_size_std": 0.02685550241565221, + "coefficient_of_variation": 0.13607339630946064 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.662240135647969, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013350998874884403, + "mean_density": 0.022655013063977415, + "cv": 0.5100262671659876 + }, + "packing_efficiency": 0.6216487529561742, + "packing_efficiency_details": { + "total_area": 0.6216487529561742, + "square_area": 1.0, + "efficiency": 0.6216487529561742, + "relative_to_estimated_best": 0.7400580392335407 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08544772261069246, + "std": 0.017588018229831755, + "min": 0.03763886318562511, + "max": 0.1110746929211277, + "range": 0.0734358297355026, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.6336, + "gap_analysis_details": { + "covered_samples": 1584, + "total_samples": 2500, + "coverage": 0.6336, + "gap_ratio": 0.36639999999999995 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865471, + "max_quality": 0.7071067811865479 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..9ddf48e2e4f3dc8e63650e81c8ede442b398d296 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 174.47 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2216 + + Auxiliary Metrics: + • spatial_uniformity: 0.880 + • edge_utilization: 0.738 + • density_variance: 0.662 + • packing_efficiency: 0.622 + • radius_distribution: 0.974 + • gap_analysis: 0.634 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2216 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.880 + • Boundary and corner utilization: 0.738 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.662 + • Area utilization efficiency: 0.622 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.634 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 36.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..6667c344fc11d4b477843e481734b5e1e53f55fb --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.221640787878004, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4000, 0.2000)\n centers[25] = (0.6000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8802248193193365, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.662240135647969, + "aux_packing_efficiency": 0.6216487529561742, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.6336, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.221640787878004 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2216\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.880\n \u2022 Boundary and corner utilization: 0.738\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.662\n \u2022 Area utilization efficiency: 0.622\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.634\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 36.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_112/results/packing_viz.png", + "execution_time_mean": 174.46826071990654, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..461b9c2d10459b9e29bb03b430372452f47413fb Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4a92a5c59ec3c42d49b4476d2f6527f32c8a278e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9117210425902676, + "spatial_uniformity_details": { + "cell_size_mean": 0.1987792212888621, + "cell_size_std": 0.019247139945923503, + "coefficient_of_variation": 0.09682671923302896 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.6504970101742126, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001453922280290544, + "mean_density": 0.02244217714414363, + "cv": 0.5372860818102538 + }, + "packing_efficiency": 0.6169664043985423, + "packing_efficiency_details": { + "total_area": 0.6169664043985423, + "square_area": 1.0, + "efficiency": 0.6169664043985423, + "relative_to_estimated_best": 0.7344838147601694 + }, + "radius_distribution": 0.982944883585438, + "radius_distribution_details": { + "mean": 0.08465427058488938, + "std": 0.019671848519542307, + "min": 0.03215796549437079, + "max": 0.11001227108607238, + "range": 0.07785430559170159, + "small_count": 7, + "medium_count": 8, + "large_count": 11, + "diversity_score": 0.982944883585438 + }, + "gap_analysis": 0.6236, + "gap_analysis_details": { + "covered_samples": 1559, + "total_samples": 2500, + "coverage": 0.6236, + "gap_ratio": 0.37639999999999996 + }, + "geometric_quality": 0.6954918959464219, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.6954918959464219, + "min_quality": 0.47140452079103157, + "max_quality": 0.74535599249993 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..8a29e7eca7135c92b04da848638647f6cb887f97 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 931.84 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2010 + + Auxiliary Metrics: + • spatial_uniformity: 0.912 + • edge_utilization: 0.738 + • density_variance: 0.650 + • packing_efficiency: 0.617 + • radius_distribution: 0.983 + • gap_analysis: 0.624 + • geometric_quality: 0.695 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2010 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.912 + • Boundary and corner utilization: 0.738 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.650 + • Area utilization efficiency: 0.617 + • Radius size diversity: 0.983 + • Area coverage (1 - gap ratio): 0.624 + • Delaunay triangulation quality: 0.695 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 37.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..e8f10d3b9309cdade861dd741bc34fdeaf04c593 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2010110352071237, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.1000, 0.3000)\n centers[3] = (0.1000, 0.5000)\n centers[4] = (0.1000, 0.7000)\n centers[5] = (0.1000, 0.9000)\n centers[6] = (0.3000, 0.1000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.3000, 0.5000)\n centers[9] = (0.3000, 0.7000)\n centers[10] = (0.3000, 0.9000)\n centers[11] = (0.5000, 0.1000)\n centers[12] = (0.5000, 0.3000)\n centers[13] = (0.5000, 0.7000)\n centers[14] = (0.5000, 0.9000)\n centers[15] = (0.7000, 0.1000)\n centers[16] = (0.7000, 0.5000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.7000, 0.9000)\n centers[19] = (0.9000, 0.1000)\n centers[20] = (0.9000, 0.3000)\n centers[21] = (0.9000, 0.5000)\n centers[22] = (0.9000, 0.7000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4333, 0.5667)\n centers[25] = (0.7000, 0.3000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9117210425902676, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.6504970101742126, + "aux_packing_efficiency": 0.6169664043985423, + "aux_radius_distribution": 0.982944883585438, + "aux_gap_analysis": 0.6236, + "aux_geometric_quality": 0.6954918959464219 + }, + "private": { + "reported_sum_of_radii": 2.2010110352071237 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2010\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.912\n \u2022 Boundary and corner utilization: 0.738\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.650\n \u2022 Area utilization efficiency: 0.617\n \u2022 Radius size diversity: 0.983\n \u2022 Area coverage (1 - gap ratio): 0.624\n \u2022 Delaunay triangulation quality: 0.695\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 37.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_113/results/packing_viz.png", + "execution_time_mean": 931.8388924580067, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7c09852a503b00736d25fbc98f1bf5f81c1bda3a Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..a90bc0ec8cff188c38b943fc0214be83e087eceb --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8807949373604872, + "spatial_uniformity_details": { + "cell_size_mean": 0.19694376947241674, + "cell_size_std": 0.026653984372321443, + "coefficient_of_variation": 0.13533804246961195 + }, + "edge_utilization": 0.573076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 8, + "corner_score": 0.75, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.5611128638989856, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00035809720031711824, + "mean_density": 0.024193450836005496, + "cv": 0.7821726507058392 + }, + "packing_efficiency": 0.6732578255798843, + "packing_efficiency_details": { + "total_area": 0.6732578255798843, + "square_area": 1.0, + "efficiency": 0.6732578255798843, + "relative_to_estimated_best": 0.8014974114046243 + }, + "radius_distribution": 0.9903496169664631, + "radius_distribution_details": { + "mean": 0.08474582832324237, + "std": 0.03256731546981701, + "min": 0.001729013373975295, + "max": 0.1359024303353374, + "range": 0.1341734169613621, + "small_count": 7, + "medium_count": 9, + "large_count": 10, + "diversity_score": 0.9903496169664631 + }, + "gap_analysis": 0.6732, + "gap_analysis_details": { + "covered_samples": 1683, + "total_samples": 2500, + "coverage": 0.6732, + "gap_ratio": 0.3268 + }, + "geometric_quality": 0.826002678003708, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.826002678003708, + "min_quality": 0.356557467874084, + "max_quality": 0.9620107984968304 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..0229b8be650a80cc60abb3e4910fa38586893c6d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 13.12 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2034 + + Auxiliary Metrics: + • spatial_uniformity: 0.881 + • edge_utilization: 0.573 + • density_variance: 0.561 + • packing_efficiency: 0.673 + • radius_distribution: 0.990 + • gap_analysis: 0.673 + • geometric_quality: 0.826 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2034 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.881 + • Delaunay triangulation quality: 0.826 + +📊 Other Metrics: + • Boundary and corner utilization: 0.573 + • Spatial density uniformity across grid: 0.561 + • Area utilization efficiency: 0.673 + • Radius size diversity: 0.990 + • Area coverage (1 - gap ratio): 0.673 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 32.7% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..85b1d7a487e459cfb0cbc5f322fa5779d5b372ff --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2033915364043017, + "public": { + "centers_str": " centers[0] = (0.5992, 0.4060)\n centers[1] = (0.5412, 0.9352)\n centers[2] = (0.5816, 0.5540)\n centers[3] = (0.3166, 0.3091)\n centers[4] = (0.4318, 0.5908)\n centers[5] = (0.8990, 0.3590)\n centers[6] = (0.2856, 0.5093)\n centers[7] = (0.4545, 0.4393)\n centers[8] = (0.9054, 0.5614)\n centers[9] = (0.8689, 0.1251)\n centers[10] = (0.1101, 0.3918)\n centers[11] = (0.3684, 0.9030)\n centers[12] = (0.1082, 0.6212)\n centers[13] = (0.5279, 0.7482)\n centers[14] = (0.7403, 0.4728)\n centers[15] = (0.3955, 0.1053)\n centers[16] = (0.6244, 0.1013)\n centers[17] = (0.1394, 0.1359)\n centers[18] = (0.7093, 0.2884)\n centers[19] = (0.9229, 0.9264)\n centers[20] = (0.5155, 0.2739)\n centers[21] = (0.7318, 0.6633)\n centers[22] = (0.9059, 0.7550)\n centers[23] = (0.1311, 0.8699)\n centers[24] = (0.3081, 0.7084)\n centers[25] = (0.7283, 0.8831)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8807949373604872, + "aux_edge_utilization": 0.573076923076923, + "aux_density_variance": 0.5611128638989856, + "aux_packing_efficiency": 0.6732578255798843, + "aux_radius_distribution": 0.9903496169664631, + "aux_gap_analysis": 0.6732, + "aux_geometric_quality": 0.826002678003708 + }, + "private": { + "reported_sum_of_radii": 2.2033915364043017 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2034\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.881\n \u2022 Delaunay triangulation quality: 0.826\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.573\n \u2022 Spatial density uniformity across grid: 0.561\n \u2022 Area utilization efficiency: 0.673\n \u2022 Radius size diversity: 0.990\n \u2022 Area coverage (1 - gap ratio): 0.673\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 32.7% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_114/results/packing_viz.png", + "execution_time_mean": 13.116749315988272, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..88a5825dc35d95036d1a9cdfb35c5a7e6838ce6c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..925638b1d2fefd8ca99a9609c36fff920d2f0e7d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8775208602190939, + "spatial_uniformity_details": { + "cell_size_mean": 0.1969623813367115, + "cell_size_std": 0.027490837256877614, + "coefficient_of_variation": 0.13957404927140565 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.6213573693989514, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00017531261336512858, + "mean_density": 0.021727937666643434, + "cv": 0.609379801783498 + }, + "packing_efficiency": 0.6075305410089185, + "packing_efficiency_details": { + "total_area": 0.6075305410089185, + "square_area": 1.0, + "efficiency": 0.6075305410089185, + "relative_to_estimated_best": 0.7232506440582362 + }, + "radius_distribution": 0.982944883585438, + "radius_distribution_details": { + "mean": 0.0827499873088621, + "std": 0.024294987589788836, + "min": 0.003176951994389182, + "max": 0.11625101074719098, + "range": 0.1130740587528018, + "small_count": 7, + "medium_count": 8, + "large_count": 11, + "diversity_score": 0.982944883585438 + }, + "gap_analysis": 0.6064, + "gap_analysis_details": { + "covered_samples": 1516, + "total_samples": 2500, + "coverage": 0.6064, + "gap_ratio": 0.39359999999999995 + }, + "geometric_quality": 0.6436603724026907, + "geometric_quality_details": { + "num_triangles": 43, + "avg_triangle_quality": 0.6436603724026907, + "min_quality": 0.24954845222486702, + "max_quality": 0.7333809538169677 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..da9039b359b2800413a38c961d01b439d28b1fa0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 5.04 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1515 + + Auxiliary Metrics: + • spatial_uniformity: 0.878 + • edge_utilization: 0.738 + • density_variance: 0.621 + • packing_efficiency: 0.608 + • radius_distribution: 0.983 + • gap_analysis: 0.606 + • geometric_quality: 0.644 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1515 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.878 + • Boundary and corner utilization: 0.738 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.621 + • Area utilization efficiency: 0.608 + • Radius size diversity: 0.983 + • Area coverage (1 - gap ratio): 0.606 + • Delaunay triangulation quality: 0.644 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 39.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..df6482c2e2b9c86fe6258f0306628749d0888933 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1514996700304145, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5021, 0.0980)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.8987, 0.1013)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.2945, 0.3055)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7056, 0.2944)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.4991)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7004, 0.5004)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1056, 0.6962)\n centers[16] = (0.4910, 0.6916)\n centers[17] = (0.7035, 0.6970)\n centers[18] = (0.9001, 0.6969)\n centers[19] = (0.0969, 0.9014)\n centers[20] = (0.3003, 0.8941)\n centers[21] = (0.5012, 0.9049)\n centers[22] = (0.6997, 0.8975)\n centers[23] = (0.9020, 0.9001)\n centers[24] = (0.5946, 0.4060)\n centers[25] = (0.4028, 0.1959)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8775208602190939, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.6213573693989514, + "aux_packing_efficiency": 0.6075305410089185, + "aux_radius_distribution": 0.982944883585438, + "aux_gap_analysis": 0.6064, + "aux_geometric_quality": 0.6436603724026907 + }, + "private": { + "reported_sum_of_radii": 2.1514996700304145 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1515\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.878\n \u2022 Boundary and corner utilization: 0.738\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.621\n \u2022 Area utilization efficiency: 0.608\n \u2022 Radius size diversity: 0.983\n \u2022 Area coverage (1 - gap ratio): 0.606\n \u2022 Delaunay triangulation quality: 0.644\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 39.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_115/results/packing_viz.png", + "execution_time_mean": 5.0373476799577475, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..ccf1da6ef52d1dd7877d1ea3af00b2a9d7ad9f8b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": false, + "error": "invalid syntax (main.py, line 106)" +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..762b968c5c571d0e327ac12f91e14b6e0fb363f1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/job_log.out @@ -0,0 +1,35 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results +Auxiliary Metrics: ENABLED +====================================================================== + +Evaluation error: invalid syntax (main.py, line 106) +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/metrics.json + +====================================================================== +❌ EVALUATION FAILED +Error: invalid syntax (main.py, line 106) +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 0.0000 + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..fec2021a6a036637c9d3049ae9778c77cef78421 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_116/results/metrics.json @@ -0,0 +1,9 @@ +{ + "combined_score": 0.0, + "execution_time_mean": 0.0, + "execution_time_std": 0.0, + "num_successful_runs": 0, + "num_valid_runs": 0, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1a67a5a70076964cb2620bcc618e579d2ee77820 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..09fda6d0557badd1e6f3f0d20257e2ec1ba62d92 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/edit.diff @@ -0,0 +1,333 @@ +--- a/original.py ++++ b/original.py +@@ -1,189 +1,215 @@ + # EVOLVE-BLOCK-START + """ +-Constructor-based circle packing for n=26 circles using a systematic +-search over grid parameters and interstitial positions, combined with +-an advanced iterative relaxation method. ++Hybrid circle packing for n=26 circles, combining a systematic search for ++initial configurations with a force-directed dynamic optimizer for refinement. + """ + + import numpy as np ++ ++ ++class DynamicPackingOptimizer: ++ """ ++ Optimizes circle packing using a force-directed approach. Starting from an ++ initial configuration, it iteratively adjusts circle centers based on ++ repulsion forces and boundaries, while repeatedly calculating maximum radii ++ to guide the optimization towards a better packing. ++ """ ++ def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): ++ self.n_circles = num_circles ++ self.num_steps = num_steps ++ self.initial_learning_rate = initial_learning_rate ++ self.central_fixed = central_fixed ++ ++ self.centers = np.copy(initial_centers) ++ self.interstitial_idx = interstitial_idx ++ self.central_idx = 0 # The central circle is at index 0 by convention ++ ++ # Initialize best configuration with max radii for the starting layout ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) ++ self.best_sum_radii = np.sum(self.radii) ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(self.radii) ++ ++ def optimize(self): ++ """Runs the force-directed optimization loop.""" ++ for step in range(self.num_steps): ++ # Linearly decay the learning rate ++ learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) ++ learning_rate = max(learning_rate, 1e-7) ++ ++ # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. ++ radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) ++ ++ # Check if this configuration might be the best so far ++ test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) ++ current_sum_radii = np.sum(test_radii_for_sum) ++ ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(test_radii_for_sum) ++ ++ # --- Calculate force vectors for center movement --- ++ force_vectors = np.zeros_like(self.centers) ++ ++ # 1. Repulsion between circles ++ for i in range(self.n_circles): ++ for j in range(i + 1, self.n_circles): ++ dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) ++ target_dist = current_radii[i] + current_radii[j] ++ ++ buffer_factor = 0.05 # Apply force even before contact for smoother movement ++ if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: ++ overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) ++ direction = (self.centers[i] - self.centers[j]) / dist_ij ++ force_vectors[i] += direction * overlap_factor ++ force_vectors[j] -= direction * overlap_factor ++ ++ # 2. Boundary repulsion forces ++ K_boundary = 10.0 # Strong boundary force ++ for i in range(self.n_circles): ++ x, y = self.centers[i] ++ r = current_radii[i] ++ if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) ++ if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) ++ if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) ++ if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) ++ ++ # --- Update centers --- ++ self.centers += learning_rate * force_vectors ++ ++ if self.central_fixed: ++ self.centers[self.central_idx] = np.array([0.5, 0.5]) ++ ++ # Clip centers to ensure they stay within radius distance of boundaries ++ for i in range(self.n_circles): ++ r = current_radii[i] ++ self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) ++ self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) ++ ++ return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) +- # Using np.meshgrid and reshape is more concise and efficient than nested loops + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + + def _generate_interstitial_candidates(grid_size, start_coord, end_coord): +- """ +- Generates potential interstitial points within the grid cells. +- For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. +- """ ++ """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + + def construct_packing(): + """ +- Constructs an arrangement of 26 circles by performing a systematic search +- for the optimal grid boundary parameter and the best position for an +- interstitial circle. This approach aims to maximize edge utilization and +- overall packing density using advanced relaxation heuristics. +- +- Returns: +- Tuple of (centers, radii) ++ Constructs an arrangement of 26 circles by searching for optimal initial ++ configurations and refining each with a dynamic optimizer. + """ + n_circles = 26 + grid_size = 5 +- + best_sum_radii = -1.0 +- best_centers = None +- best_radii = None +- +- # Search space for the grid's start coordinate. This parameter controls +- # how far the outer grid circles are from the boundary, directly influencing +- # edge utilization and overall packing density. +- start_coord_search_space = np.linspace(0.08, 0.12, 9) # Range found effective in prior high-scoring programs +- +- # --- Main Search Loop --- +- for current_start_coord in start_coord_search_space: +- current_end_coord = 1.0 - current_start_coord +- +- # 1. Generate base centers for 25 circles (24 grid + 1 central). +- # The central circle is placed at index 0 for prioritized relaxation. +- all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) ++ best_centers, best_radii = None, None ++ ++ # Search space for the grid's boundary parameter ++ start_coord_search_space = np.linspace(0.08, 0.12, 5) ++ ++ for start_coord in start_coord_search_space: ++ end_coord = 1.0 - start_coord ++ ++ # 1. Generate base 25 centers (1 central + 24 on a grid) ++ all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) +- +- # Find the index of the center point to separate it. +- # Use np.isclose for robust float comparison. +- central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] +- +- # These are the 24 non-central grid points. From these, we will select 23. +- potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- +- # 2. Generate a denser set of interstitial candidates. +- # A grid_size of 7 for candidates means (7-1)x(7-1) = 36 candidates. +- candidate_interstitial_points = _generate_interstitial_candidates(grid_size + 2, current_start_coord, current_end_coord) +- +- # Iterate through each of the 24 potential peripheral circles to *exclude* one, +- # effectively choosing 23 peripheral circles. +- for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): +- current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) +- +- # Iterate through unique pairs of interstitial candidates. +- num_interstitial_candidates = len(candidate_interstitial_points) +- for i in range(num_interstitial_candidates): +- for j in range(i + 1, num_interstitial_candidates): +- interstitial_point_1 = candidate_interstitial_points[i] +- interstitial_point_2 = candidate_interstitial_points[j] +- +- # 3. Assemble the full set of 26 centers for evaluation. +- # Order: [central (1), 23 peripheral, interstitial1, interstitial2] +- current_centers = np.vstack([central_point_coords.reshape(1,2), # Ensure central is (1,2) +- current_peripheral_centers_23, +- interstitial_point_1.reshape(1,2), # Ensure interstitial is (1,2) +- interstitial_point_2.reshape(1,2)]) +- +- # The interstitial circles are the last two elements. +- interstitial_indices = [n_circles - 2, n_circles - 1] +- +- # 4. Compute radii using the advanced relaxation method. +- current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_indices) +- current_sum_radii = np.sum(current_radii) +- +- # 5. Keep track of the best configuration found. +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii ++ central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] ++ ++ base_centers = np.zeros((n_circles - 1, 2)) ++ base_centers[0] = central_point_coords ++ base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) ++ ++ # 2. Generate interstitial candidates for the 26th circle ++ candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) ++ ++ # 3. For each candidate, run the dynamic optimizer ++ for interstitial_point in candidate_points: ++ initial_centers_config = np.vstack([base_centers, interstitial_point]) ++ interstitial_idx = n_circles - 1 ++ ++ # Instantiate and run the optimizer for this initial configuration ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=initial_centers_config, ++ interstitial_idx=interstitial_idx, ++ num_steps=2000, ++ initial_learning_rate=0.015 ++ ) ++ optimized_centers, optimized_radii = optimizer.optimize() ++ current_sum_radii = np.sum(optimized_radii) ++ ++ # 4. Keep track of the best result found across all runs ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = optimized_centers ++ best_radii = optimized_radii + + return best_centers, best_radii + + +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None): +- """ +- Computes maximum radii using an iterative relaxation approach with two key +- heuristics for improved packing: +- 1. Weighted proportional scaling to protect the central circle (index 0). +- 2. Initial radius capping for interstitial circles to allow the main +- grid to form optimally. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates. +- max_iterations: Maximum iterations for the relaxation process. +- tolerance: Convergence tolerance. +- interstitial_idx: Index or list/array of indices of interstitial circles +- to apply the heuristic. Defaults to None (no specific heuristic). +- +- Returns: +- np.array: Array of radii for each circle. ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): ++ """ ++ Computes maximum radii for a fixed set of centers using iterative relaxation. ++ Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + +- # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Cap the initial radius of the interstitial circle(s). +- # This prevents them from growing too large initially and sub-optimally +- # squeezing their neighbors, allowing for a better overall packing. +- if interstitial_idx is not None: +- if isinstance(interstitial_idx, int): # Handle single index +- if interstitial_idx < n: +- radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) +- elif isinstance(interstitial_idx, (list, np.ndarray)): # Handle multiple indices +- for idx in interstitial_idx: +- if idx < n: +- radii[idx] = min(radii[idx], 0.05) +- +- # 2. Iteratively adjust radii to resolve overlaps until convergence. ++ # Heuristic: Cap the initial radius of the interstitial circle ++ if interstitial_idx != -1 and interstitial_idx < n: ++ radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) ++ + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) +- + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist +- +- # Weighted proportional scaling: The central circle (index 0) is more +- # resistant to shrinking, allowing it to grow larger. ++ ++ # Weighted scaling: Central circle (index 0) shrinks less + w_i = 1.5 if i == 0 else 1.0 +- w_j = 1.0 # j is always > i, so it's never the central circle in this specific case ++ w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j +- + total_weighted_radii = weighted_r_i + weighted_r_j + +- if total_weighted_radii > 1e-12: # Avoid division by zero if both radii are tiny ++ if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling for extremely small radii sum ++ elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + +- # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) +- + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/main.py new file mode 100644 index 0000000000000000000000000000000000000000..aa2254bcc1f8a8463dfb25a88996707619162e3c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/main.py @@ -0,0 +1,215 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Check if this configuration might be the best so far + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + buffer_factor = 0.05 # Apply force even before contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by searching for optimal initial + configurations and refining each with a dynamic optimizer. + """ + n_circles = 26 + grid_size = 5 + best_sum_radii = -1.0 + best_centers, best_radii = None, None + + # Search space for the grid's boundary parameter + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + # 1. Generate base 25 centers (1 central + 24 on a grid) + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # 2. Generate interstitial candidates for the 26th circle + candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # 3. For each candidate, run the dynamic optimizer + for interstitial_point in candidate_points: + initial_centers_config = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + # Instantiate and run the optimizer for this initial configuration + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers_config, + interstitial_idx=interstitial_idx, + num_steps=2000, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best result found across all runs + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/original.py new file mode 100644 index 0000000000000000000000000000000000000000..302f79cd0a78f19d86ac5582165919d3585926c6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/original.py @@ -0,0 +1,189 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a systematic +search over grid parameters and interstitial positions, combined with +an advanced iterative relaxation method. +""" + +import numpy as np + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + # Using np.meshgrid and reshape is more concise and efficient than nested loops + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. This approach aims to maximize edge utilization and + overall packing density using advanced relaxation heuristics. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Search space for the grid's start coordinate. This parameter controls + # how far the outer grid circles are from the boundary, directly influencing + # edge utilization and overall packing density. + start_coord_search_space = np.linspace(0.08, 0.12, 9) # Range found effective in prior high-scoring programs + + # --- Main Search Loop --- + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + + # 1. Generate base centers for 25 circles (24 grid + 1 central). + # The central circle is placed at index 0 for prioritized relaxation. + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + + # Find the index of the center point to separate it. + # Use np.isclose for robust float comparison. + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + # These are the 24 non-central grid points. From these, we will select 23. + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # 2. Generate a denser set of interstitial candidates. + # A grid_size of 7 for candidates means (7-1)x(7-1) = 36 candidates. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size + 2, current_start_coord, current_end_coord) + + # Iterate through each of the 24 potential peripheral circles to *exclude* one, + # effectively choosing 23 peripheral circles. + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Iterate through unique pairs of interstitial candidates. + num_interstitial_candidates = len(candidate_interstitial_points) + for i in range(num_interstitial_candidates): + for j in range(i + 1, num_interstitial_candidates): + interstitial_point_1 = candidate_interstitial_points[i] + interstitial_point_2 = candidate_interstitial_points[j] + + # 3. Assemble the full set of 26 centers for evaluation. + # Order: [central (1), 23 peripheral, interstitial1, interstitial2] + current_centers = np.vstack([central_point_coords.reshape(1,2), # Ensure central is (1,2) + current_peripheral_centers_23, + interstitial_point_1.reshape(1,2), # Ensure interstitial is (1,2) + interstitial_point_2.reshape(1,2)]) + + # The interstitial circles are the last two elements. + interstitial_indices = [n_circles - 2, n_circles - 1] + + # 4. Compute radii using the advanced relaxation method. + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_indices) + current_sum_radii = np.sum(current_radii) + + # 5. Keep track of the best configuration found. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None): + """ + Computes maximum radii using an iterative relaxation approach with two key + heuristics for improved packing: + 1. Weighted proportional scaling to protect the central circle (index 0). + 2. Initial radius capping for interstitial circles to allow the main + grid to form optimally. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index or list/array of indices of interstitial circles + to apply the heuristic. Defaults to None (no specific heuristic). + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle(s). + # This prevents them from growing too large initially and sub-optimally + # squeezing their neighbors, allowing for a better overall packing. + if interstitial_idx is not None: + if isinstance(interstitial_idx, int): # Handle single index + if interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + elif isinstance(interstitial_idx, (list, np.ndarray)): # Handle multiple indices + for idx in interstitial_idx: + if idx < n: + radii[idx] = min(radii[idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # j is always > i, so it's never the central circle in this specific case + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero if both radii are tiny + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling for extremely small radii sum + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..690b6bc10b446c6f86734a935085ede001f72e2d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8908425207981184, + "spatial_uniformity_details": { + "cell_size_mean": 0.19685110690999227, + "cell_size_std": 0.024120728653927663, + "coefficient_of_variation": 0.12253285699035317 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5563743306016086, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0007210274794148679, + "mean_density": 0.03367645065080537, + "cv": 0.7973510728266314 + }, + "packing_efficiency": 0.7133396259231691, + "packing_efficiency_details": { + "total_area": 0.7133396259231691, + "square_area": 1.0, + "efficiency": 0.7133396259231691, + "relative_to_estimated_best": 0.8492138403847251 + }, + "radius_distribution": 0.9629470128958899, + "radius_distribution_details": { + "mean": 0.08662723337757064, + "std": 0.035055910567723246, + "min": 0.00286032714895015, + "max": 0.16655415996646833, + "range": 0.16369383281751818, + "small_count": 8, + "medium_count": 12, + "large_count": 6, + "diversity_score": 0.9629470128958899 + }, + "gap_analysis": 0.7104, + "gap_analysis_details": { + "covered_samples": 1776, + "total_samples": 2500, + "coverage": 0.7104, + "gap_ratio": 0.28959999999999997 + }, + "geometric_quality": 0.6658557606711873, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6658557606711873, + "min_quality": 0.34543181803243744, + "max_quality": 0.9166875469028108 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..09e5e00cc64a9d22909b095ed82c308cb005401d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 920.18 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2523 + + Auxiliary Metrics: + • spatial_uniformity: 0.891 + • edge_utilization: 0.785 + • density_variance: 0.556 + • packing_efficiency: 0.713 + • radius_distribution: 0.963 + • gap_analysis: 0.710 + • geometric_quality: 0.666 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2523 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.891 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.713 + • Area coverage (1 - gap ratio): 0.710 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.556 + • Radius size diversity: 0.963 + • Delaunay triangulation quality: 0.666 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..a9777689ec5fa5bfec4afc249ab36d88f62f8d9d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.252308067816837, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0988, 0.1000)\n centers[2] = (0.1000, 0.3000)\n centers[3] = (0.0872, 0.4532)\n centers[4] = (0.0405, 0.7617)\n centers[5] = (0.0879, 0.8946)\n centers[6] = (0.2985, 0.1000)\n centers[7] = (0.2429, 0.3181)\n centers[8] = (0.2980, 0.4931)\n centers[9] = (0.1235, 0.6317)\n centers[10] = (0.2767, 0.9013)\n centers[11] = (0.4978, 0.0910)\n centers[12] = (0.3912, 0.2429)\n centers[13] = (0.3537, 0.6859)\n centers[14] = (0.4894, 0.8894)\n centers[15] = (0.6686, 0.0029)\n centers[16] = (0.7228, 0.0806)\n centers[17] = (0.6397, 0.3174)\n centers[18] = (0.6407, 0.6470)\n centers[19] = (0.6975, 0.9059)\n centers[20] = (0.9050, 0.0950)\n centers[21] = (0.9050, 0.2849)\n centers[22] = (0.8857, 0.4937)\n centers[23] = (0.9045, 0.7038)\n centers[24] = (0.9032, 0.9032)\n centers[25] = (0.7948, 0.7995)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8908425207981184, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5563743306016086, + "aux_packing_efficiency": 0.7133396259231691, + "aux_radius_distribution": 0.9629470128958899, + "aux_gap_analysis": 0.7104, + "aux_geometric_quality": 0.6658557606711873 + }, + "private": { + "reported_sum_of_radii": 2.252308067816837 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2523\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.891\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.713\n \u2022 Area coverage (1 - gap ratio): 0.710\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.556\n \u2022 Radius size diversity: 0.963\n \u2022 Delaunay triangulation quality: 0.666\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/results/packing_viz.png", + "execution_time_mean": 920.179937697947, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..4a491b2945e031620e4c92cea9922463992057e9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_117/rewrite.txt @@ -0,0 +1,206 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Check if this configuration might be the best so far + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + buffer_factor = 0.05 # Apply force even before contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by searching for optimal initial + configurations and refining each with a dynamic optimizer. + """ + n_circles = 26 + grid_size = 5 + best_sum_radii = -1.0 + best_centers, best_radii = None, None + + # Search space for the grid's boundary parameter + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + # 1. Generate base 25 centers (1 central + 24 on a grid) + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # 2. Generate interstitial candidates for the 26th circle + candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # 3. For each candidate, run the dynamic optimizer + for interstitial_point in candidate_points: + initial_centers_config = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + # Instantiate and run the optimizer for this initial configuration + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers_config, + interstitial_idx=interstitial_idx, + num_steps=2000, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best result found across all runs + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6fb2f2688ffe4cf6721a9a7a9dd2a9f91f9828b1 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..146242c78b800e007c4bca90203528a061d56d1c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8727472506038995, + "spatial_uniformity_details": { + "cell_size_mean": 0.202343769169487, + "cell_size_std": 0.029503159201501847, + "coefficient_of_variation": 0.14580710429972438 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5727107968383462, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0007914232735515471, + "mean_density": 0.037706641225678614, + "cv": 0.746081976314235 + }, + "packing_efficiency": 0.7506653998535874, + "packing_efficiency_details": { + "total_area": 0.7506653998535874, + "square_area": 1.0, + "efficiency": 0.7506653998535874, + "relative_to_estimated_best": 0.893649285539985 + }, + "radius_distribution": 0.9450467888248784, + "radius_distribution_details": { + "mean": 0.08918976806707178, + "std": 0.03514751061608098, + "min": 0.00030720884294206815, + "max": 0.17246872592789986, + "range": 0.17216151708495778, + "small_count": 7, + "medium_count": 13, + "large_count": 6, + "diversity_score": 0.9450467888248784 + }, + "gap_analysis": 0.7488, + "gap_analysis_details": { + "covered_samples": 1872, + "total_samples": 2500, + "coverage": 0.7488, + "gap_ratio": 0.2512 + }, + "geometric_quality": 0.6435187414440939, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6435187414440939, + "min_quality": 0.30229438257628566, + "max_quality": 0.9225492360171196 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..a527aa6174173d7518c4478bca76202f26d0ab15 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 938.10 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3189 + + Auxiliary Metrics: + • spatial_uniformity: 0.873 + • edge_utilization: 0.785 + • density_variance: 0.573 + • packing_efficiency: 0.751 + • radius_distribution: 0.945 + • gap_analysis: 0.749 + • geometric_quality: 0.644 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3189 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.873 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.751 + • Area coverage (1 - gap ratio): 0.749 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.573 + • Radius size diversity: 0.945 + • Delaunay triangulation quality: 0.644 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..4ad4ceae56ce25344e00273eb594eb1c61d20fb6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3189339697438665, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.0855)\n centers[2] = (0.2973, 0.0782)\n centers[3] = (0.4614, 0.1002)\n centers[4] = (0.7529, 0.0599)\n centers[5] = (0.9063, 0.0948)\n centers[6] = (0.1013, 0.2791)\n centers[7] = (0.3181, 0.2104)\n centers[8] = (0.4662, 0.2810)\n centers[9] = (0.6095, 0.0807)\n centers[10] = (0.9228, 0.2744)\n centers[11] = (0.0915, 0.4814)\n centers[12] = (0.2914, 0.4079)\n centers[13] = (0.6874, 0.3084)\n centers[14] = (0.9008, 0.4628)\n centers[15] = (0.0003, 0.6643)\n centers[16] = (0.1078, 0.6888)\n centers[17] = (0.3629, 0.6614)\n centers[18] = (0.6807, 0.6396)\n centers[19] = (0.9195, 0.7232)\n centers[20] = (0.0983, 0.9017)\n centers[21] = (0.2957, 0.9017)\n centers[22] = (0.5092, 0.8867)\n centers[23] = (0.7157, 0.9067)\n centers[24] = (0.9045, 0.9045)\n centers[25] = (0.4913, 0.3963)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8727472506038995, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5727107968383462, + "aux_packing_efficiency": 0.7506653998535874, + "aux_radius_distribution": 0.9450467888248784, + "aux_gap_analysis": 0.7488, + "aux_geometric_quality": 0.6435187414440939 + }, + "private": { + "reported_sum_of_radii": 2.3189339697438665 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3189\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.873\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.751\n \u2022 Area coverage (1 - gap ratio): 0.749\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.573\n \u2022 Radius size diversity: 0.945\n \u2022 Delaunay triangulation quality: 0.644\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_120/results/packing_viz.png", + "execution_time_mean": 938.0969733810052, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4b8c3e83d9fe2c3515492fd6ab37074ca16c26a3 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..6d146221f980920db1875e7a49b56bfd40890139 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/edit.diff @@ -0,0 +1,330 @@ +--- a/original.py ++++ b/original.py +@@ -1,189 +1,217 @@ + # EVOLVE-BLOCK-START + """ +-Constructor-based circle packing for n=26 circles using a systematic +-search over grid parameters and interstitial positions, combined with +-an advanced iterative relaxation method. ++Hybrid circle packing for n=26 circles, combining a systematic search for ++initial configurations with an advanced force-directed dynamic optimizer. + """ + + import numpy as np ++ ++ ++class DynamicPackingOptimizer: ++ """ ++ Optimizes circle packing using a force-directed approach. This version uses a soft ++ restoring force to guide the central circle towards the middle, rather than fixing it, ++ allowing for more global relaxation of the packing. ++ """ ++ def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2500, initial_learning_rate=0.015): ++ self.n_circles = num_circles ++ self.num_steps = num_steps ++ self.initial_learning_rate = initial_learning_rate ++ ++ self.centers = np.copy(initial_centers) ++ self.interstitial_idx = interstitial_idx ++ self.central_idx = 0 # The central circle is at index 0 ++ ++ # Initialize best configuration ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) ++ self.best_sum_radii = np.sum(self.radii) ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(self.radii) ++ ++ def optimize(self): ++ """Runs the force-directed optimization loop.""" ++ for step in range(self.num_steps): ++ learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) ++ learning_rate = max(learning_rate, 1e-7) ++ ++ # Increased iterations for more stable force calculation ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) ++ ++ # Re-evaluate with full iterations to check for a new best configuration ++ test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) ++ current_sum_radii = np.sum(test_radii_for_sum) ++ ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(test_radii_for_sum) ++ ++ # --- Calculate force vectors --- ++ force_vectors = np.zeros_like(self.centers) ++ ++ # 1. Repulsion between circles ++ buffer_factor = 0.05 ++ for i in range(self.n_circles): ++ for j in range(i + 1, self.n_circles): ++ diff = self.centers[i] - self.centers[j] ++ dist_ij = np.linalg.norm(diff) ++ target_dist = current_radii[i] + current_radii[j] ++ ++ if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: ++ overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) ++ direction = diff / dist_ij ++ force_vectors[i] += direction * overlap_factor ++ force_vectors[j] -= direction * overlap_factor ++ ++ # 2. Boundary repulsion forces ++ K_boundary = 10.0 ++ for i in range(self.n_circles): ++ x, y = self.centers[i] ++ r = current_radii[i] ++ if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) ++ if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) ++ if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) ++ if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) ++ ++ # 3. Central restoring force (NEW) ++ K_center = 5.0 # Force constant for the central spring ++ force_vectors[self.central_idx] += K_center * (np.array([0.5, 0.5]) - self.centers[self.central_idx]) ++ ++ # --- Update centers --- ++ self.centers += learning_rate * force_vectors ++ ++ # Clip centers to ensure they stay within valid radius-dependent bounds ++ for i in range(self.n_circles): ++ r = current_radii[i] ++ self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) ++ self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) ++ ++ return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) +- # Using np.meshgrid and reshape is more concise and efficient than nested loops + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + + def _generate_interstitial_candidates(grid_size, start_coord, end_coord): +- """ +- Generates potential interstitial points within the grid cells. +- For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. +- """ ++ """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + + def construct_packing(): + """ +- Constructs an arrangement of 26 circles by performing a systematic search +- for the optimal grid boundary parameter and the best position for an +- interstitial circle. This approach aims to maximize edge utilization and +- overall packing density using advanced relaxation heuristics. +- +- Returns: +- Tuple of (centers, radii) ++ Constructs an arrangement of 26 circles by searching for optimal initial ++ configurations (25 grid + 1 interstitial) and refining each with a ++ dynamic force-directed optimizer. + """ + n_circles = 26 + grid_size = 5 +- + best_sum_radii = -1.0 +- best_centers = None +- best_radii = None +- +- # Search space for the grid's start coordinate. This parameter controls +- # how far the outer grid circles are from the boundary, directly influencing +- # edge utilization and overall packing density. +- start_coord_search_space = np.linspace(0.08, 0.12, 9) # Range found effective in prior high-scoring programs +- +- # --- Main Search Loop --- +- for current_start_coord in start_coord_search_space: +- current_end_coord = 1.0 - current_start_coord +- +- # 1. Generate base centers for 25 circles (24 grid + 1 central). +- # The central circle is placed at index 0 for prioritized relaxation. +- all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) ++ best_centers, best_radii = None, None ++ ++ start_coord_search_space = np.linspace(0.08, 0.12, 5) ++ ++ for start_coord in start_coord_search_space: ++ end_coord = 1.0 - start_coord ++ ++ # 1. Generate base 25 centers (1 central + 24 on a grid) ++ all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) +- +- # Find the index of the center point to separate it. +- # Use np.isclose for robust float comparison. +- central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] +- +- # These are the 24 non-central grid points. From these, we will select 23. +- potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- +- # 2. Generate a denser set of interstitial candidates. +- # A grid_size of 7 for candidates means (7-1)x(7-1) = 36 candidates. +- candidate_interstitial_points = _generate_interstitial_candidates(grid_size + 2, current_start_coord, current_end_coord) +- +- # Iterate through each of the 24 potential peripheral circles to *exclude* one, +- # effectively choosing 23 peripheral circles. +- for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): +- current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) +- +- # Iterate through unique pairs of interstitial candidates. +- num_interstitial_candidates = len(candidate_interstitial_points) +- for i in range(num_interstitial_candidates): +- for j in range(i + 1, num_interstitial_candidates): +- interstitial_point_1 = candidate_interstitial_points[i] +- interstitial_point_2 = candidate_interstitial_points[j] +- +- # 3. Assemble the full set of 26 centers for evaluation. +- # Order: [central (1), 23 peripheral, interstitial1, interstitial2] +- current_centers = np.vstack([central_point_coords.reshape(1,2), # Ensure central is (1,2) +- current_peripheral_centers_23, +- interstitial_point_1.reshape(1,2), # Ensure interstitial is (1,2) +- interstitial_point_2.reshape(1,2)]) +- +- # The interstitial circles are the last two elements. +- interstitial_indices = [n_circles - 2, n_circles - 1] +- +- # 4. Compute radii using the advanced relaxation method. +- current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_indices) +- current_sum_radii = np.sum(current_radii) +- +- # 5. Keep track of the best configuration found. +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii ++ central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] ++ ++ base_centers = np.zeros((n_circles - 1, 2)) ++ base_centers[0] = central_point_coords ++ base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) ++ ++ # 2. Generate interstitial candidates for the 26th circle ++ candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) ++ ++ # 3. For each candidate, run the dynamic optimizer ++ for interstitial_point in candidate_points: ++ initial_centers_config = np.vstack([base_centers, interstitial_point]) ++ interstitial_idx = n_circles - 1 ++ ++ # Instantiate and run the optimizer for this initial configuration ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=initial_centers_config, ++ interstitial_idx=interstitial_idx, ++ num_steps=2500, ++ initial_learning_rate=0.015 ++ ) ++ optimized_centers, optimized_radii = optimizer.optimize() ++ current_sum_radii = np.sum(optimized_radii) ++ ++ # 4. Keep track of the best result found across all runs ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = optimized_centers ++ best_radii = optimized_radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None): + """ +- Computes maximum radii using an iterative relaxation approach with two key +- heuristics for improved packing: +- 1. Weighted proportional scaling to protect the central circle (index 0). +- 2. Initial radius capping for interstitial circles to allow the main +- grid to form optimally. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates. +- max_iterations: Maximum iterations for the relaxation process. +- tolerance: Convergence tolerance. +- interstitial_idx: Index or list/array of indices of interstitial circles +- to apply the heuristic. Defaults to None (no specific heuristic). +- +- Returns: +- np.array: Array of radii for each circle. ++ Computes maximum radii for a fixed set of centers using iterative relaxation, ++ with heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + +- # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle(s). +- # This prevents them from growing too large initially and sub-optimally +- # squeezing their neighbors, allowing for a better overall packing. + if interstitial_idx is not None: +- if isinstance(interstitial_idx, int): # Handle single index +- if interstitial_idx < n: +- radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) +- elif isinstance(interstitial_idx, (list, np.ndarray)): # Handle multiple indices +- for idx in interstitial_idx: +- if idx < n: +- radii[idx] = min(radii[idx], 0.05) +- +- # 2. Iteratively adjust radii to resolve overlaps until convergence. ++ indices = [interstitial_idx] if isinstance(interstitial_idx, int) else interstitial_idx ++ for idx in indices: ++ if idx < n: ++ radii[idx] = min(radii[idx], 0.05) ++ + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) +- + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + +- # Weighted proportional scaling: The central circle (index 0) is more +- # resistant to shrinking, allowing it to grow larger. ++ # Weighted scaling: Central circle (index 0) shrinks less + w_i = 1.5 if i == 0 else 1.0 +- w_j = 1.0 # j is always > i, so it's never the central circle in this specific case ++ w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j +- + total_weighted_radii = weighted_r_i + weighted_r_j + +- if total_weighted_radii > 1e-12: # Avoid division by zero if both radii are tiny ++ if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling for extremely small radii sum ++ elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + +- # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) +- + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/main.py new file mode 100644 index 0000000000000000000000000000000000000000..2306bed3bd3a338e773953122b9cc73901a59e68 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/main.py @@ -0,0 +1,217 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with an advanced force-directed dynamic optimizer. +""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. This version uses a soft + restoring force to guide the central circle towards the middle, rather than fixing it, + allowing for more global relaxation of the packing. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is at index 0 + + # Initialize best configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Increased iterations for more stable force calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Re-evaluate with full iterations to check for a new best configuration + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # --- Calculate force vectors --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + diff = self.centers[i] - self.centers[j] + dist_ij = np.linalg.norm(diff) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = diff / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Central restoring force (NEW) + K_center = 5.0 # Force constant for the central spring + force_vectors[self.central_idx] += K_center * (np.array([0.5, 0.5]) - self.centers[self.central_idx]) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within valid radius-dependent bounds + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by searching for optimal initial + configurations (25 grid + 1 interstitial) and refining each with a + dynamic force-directed optimizer. + """ + n_circles = 26 + grid_size = 5 + best_sum_radii = -1.0 + best_centers, best_radii = None, None + + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + # 1. Generate base 25 centers (1 central + 24 on a grid) + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # 2. Generate interstitial candidates for the 26th circle + candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # 3. For each candidate, run the dynamic optimizer + for interstitial_point in candidate_points: + initial_centers_config = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + # Instantiate and run the optimizer for this initial configuration + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers_config, + interstitial_idx=interstitial_idx, + num_steps=2500, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best result found across all runs + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation, + with heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle(s). + if interstitial_idx is not None: + indices = [interstitial_idx] if isinstance(interstitial_idx, int) else interstitial_idx + for idx in indices: + if idx < n: + radii[idx] = min(radii[idx], 0.05) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/original.py new file mode 100644 index 0000000000000000000000000000000000000000..302f79cd0a78f19d86ac5582165919d3585926c6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/original.py @@ -0,0 +1,189 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a systematic +search over grid parameters and interstitial positions, combined with +an advanced iterative relaxation method. +""" + +import numpy as np + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + # Using np.meshgrid and reshape is more concise and efficient than nested loops + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. This approach aims to maximize edge utilization and + overall packing density using advanced relaxation heuristics. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Search space for the grid's start coordinate. This parameter controls + # how far the outer grid circles are from the boundary, directly influencing + # edge utilization and overall packing density. + start_coord_search_space = np.linspace(0.08, 0.12, 9) # Range found effective in prior high-scoring programs + + # --- Main Search Loop --- + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + + # 1. Generate base centers for 25 circles (24 grid + 1 central). + # The central circle is placed at index 0 for prioritized relaxation. + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + + # Find the index of the center point to separate it. + # Use np.isclose for robust float comparison. + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + # These are the 24 non-central grid points. From these, we will select 23. + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # 2. Generate a denser set of interstitial candidates. + # A grid_size of 7 for candidates means (7-1)x(7-1) = 36 candidates. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size + 2, current_start_coord, current_end_coord) + + # Iterate through each of the 24 potential peripheral circles to *exclude* one, + # effectively choosing 23 peripheral circles. + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Iterate through unique pairs of interstitial candidates. + num_interstitial_candidates = len(candidate_interstitial_points) + for i in range(num_interstitial_candidates): + for j in range(i + 1, num_interstitial_candidates): + interstitial_point_1 = candidate_interstitial_points[i] + interstitial_point_2 = candidate_interstitial_points[j] + + # 3. Assemble the full set of 26 centers for evaluation. + # Order: [central (1), 23 peripheral, interstitial1, interstitial2] + current_centers = np.vstack([central_point_coords.reshape(1,2), # Ensure central is (1,2) + current_peripheral_centers_23, + interstitial_point_1.reshape(1,2), # Ensure interstitial is (1,2) + interstitial_point_2.reshape(1,2)]) + + # The interstitial circles are the last two elements. + interstitial_indices = [n_circles - 2, n_circles - 1] + + # 4. Compute radii using the advanced relaxation method. + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_indices) + current_sum_radii = np.sum(current_radii) + + # 5. Keep track of the best configuration found. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None): + """ + Computes maximum radii using an iterative relaxation approach with two key + heuristics for improved packing: + 1. Weighted proportional scaling to protect the central circle (index 0). + 2. Initial radius capping for interstitial circles to allow the main + grid to form optimally. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index or list/array of indices of interstitial circles + to apply the heuristic. Defaults to None (no specific heuristic). + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle(s). + # This prevents them from growing too large initially and sub-optimally + # squeezing their neighbors, allowing for a better overall packing. + if interstitial_idx is not None: + if isinstance(interstitial_idx, int): # Handle single index + if interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + elif isinstance(interstitial_idx, (list, np.ndarray)): # Handle multiple indices + for idx in interstitial_idx: + if idx < n: + radii[idx] = min(radii[idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # j is always > i, so it's never the central circle in this specific case + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero if both radii are tiny + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling for extremely small radii sum + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..af5936f3d8861c9daf971ebdf1b09003ee58718c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8497367230059858, + "spatial_uniformity_details": { + "cell_size_mean": 0.19702320314299612, + "cell_size_std": 0.034840617684094924, + "coefficient_of_variation": 0.1768350983613493 + }, + "edge_utilization": 0.6346153846153846, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 12, + "corner_score": 0.75, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5790937708300904, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0008241472516786544, + "mean_density": 0.03949716612349767, + "cv": 0.7268360503456459 + }, + "packing_efficiency": 0.7580236524882682, + "packing_efficiency_details": { + "total_area": 0.7580236524882682, + "square_area": 1.0, + "efficiency": 0.7580236524882682, + "relative_to_estimated_best": 0.9024091101050812 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08789325241541132, + "std": 0.03943378248309363, + "min": 0.003754741793781901, + "max": 0.16719285897209385, + "range": 0.16343811717831194, + "small_count": 9, + "medium_count": 11, + "large_count": 6, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.7668, + "gap_analysis_details": { + "covered_samples": 1917, + "total_samples": 2500, + "coverage": 0.7668, + "gap_ratio": 0.23319999999999996 + }, + "geometric_quality": 0.6654421989271546, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6654421989271546, + "min_quality": 0.3133764334102639, + "max_quality": 0.9102767403796231 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..e3447f0f30d76907a3dcab3ad4f6491c53973c2e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 1170.82 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2852 + + Auxiliary Metrics: + • spatial_uniformity: 0.850 + • edge_utilization: 0.635 + • density_variance: 0.579 + • packing_efficiency: 0.758 + • radius_distribution: 0.974 + • gap_analysis: 0.767 + • geometric_quality: 0.665 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2852 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.850 + • Area utilization efficiency: 0.758 + • Area coverage (1 - gap ratio): 0.767 + +📊 Other Metrics: + • Boundary and corner utilization: 0.635 + • Spatial density uniformity across grid: 0.579 + • Radius size diversity: 0.974 + • Delaunay triangulation quality: 0.665 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..25e265d5105bf85c024f9fbebd14cb499bc28922 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2852245628006944, + "public": { + "centers_str": " centers[0] = (0.4988, 0.4987)\n centers[1] = (0.1008, 0.1043)\n centers[2] = (0.0930, 0.3044)\n centers[3] = (0.0749, 0.4216)\n centers[4] = (0.0648, 0.7562)\n centers[5] = (0.0878, 0.9122)\n centers[6] = (0.2722, 0.0333)\n centers[7] = (0.1814, 0.4183)\n centers[8] = (0.3016, 0.4841)\n centers[9] = (0.1139, 0.5803)\n centers[10] = (0.2784, 0.9054)\n centers[11] = (0.5313, 0.0931)\n centers[12] = (0.3116, 0.2349)\n centers[13] = (0.3429, 0.6824)\n centers[14] = (0.4892, 0.8940)\n centers[15] = (0.6645, 0.0038)\n centers[16] = (0.7322, 0.1034)\n centers[17] = (0.6137, 0.3340)\n centers[18] = (0.6414, 0.6511)\n centers[19] = (0.6963, 0.9080)\n centers[20] = (0.9182, 0.0818)\n centers[21] = (0.8826, 0.2799)\n centers[22] = (0.9018, 0.4983)\n centers[23] = (0.9030, 0.6969)\n centers[24] = (0.8978, 0.8978)\n centers[25] = (0.1824, 0.7812)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8497367230059858, + "aux_edge_utilization": 0.6346153846153846, + "aux_density_variance": 0.5790937708300904, + "aux_packing_efficiency": 0.7580236524882682, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.7668, + "aux_geometric_quality": 0.6654421989271546 + }, + "private": { + "reported_sum_of_radii": 2.2852245628006944 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2852\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.850\n \u2022 Area utilization efficiency: 0.758\n \u2022 Area coverage (1 - gap ratio): 0.767\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.635\n \u2022 Spatial density uniformity across grid: 0.579\n \u2022 Radius size diversity: 0.974\n \u2022 Delaunay triangulation quality: 0.665\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/results/packing_viz.png", + "execution_time_mean": 1170.8195567838848, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..3a80155c05427b46a8ab4ec50fa3333b7a48fa63 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_123/rewrite.txt @@ -0,0 +1,208 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with an advanced force-directed dynamic optimizer. +""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. This version uses a soft + restoring force to guide the central circle towards the middle, rather than fixing it, + allowing for more global relaxation of the packing. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is at index 0 + + # Initialize best configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Increased iterations for more stable force calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Re-evaluate with full iterations to check for a new best configuration + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # --- Calculate force vectors --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + diff = self.centers[i] - self.centers[j] + dist_ij = np.linalg.norm(diff) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = diff / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Central restoring force (NEW) + K_center = 5.0 # Force constant for the central spring + force_vectors[self.central_idx] += K_center * (np.array([0.5, 0.5]) - self.centers[self.central_idx]) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within valid radius-dependent bounds + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by searching for optimal initial + configurations (25 grid + 1 interstitial) and refining each with a + dynamic force-directed optimizer. + """ + n_circles = 26 + grid_size = 5 + best_sum_radii = -1.0 + best_centers, best_radii = None, None + + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + # 1. Generate base 25 centers (1 central + 24 on a grid) + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # 2. Generate interstitial candidates for the 26th circle + candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # 3. For each candidate, run the dynamic optimizer + for interstitial_point in candidate_points: + initial_centers_config = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + # Instantiate and run the optimizer for this initial configuration + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers_config, + interstitial_idx=interstitial_idx, + num_steps=2500, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best result found across all runs + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation, + with heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle(s). + if interstitial_idx is not None: + indices = [interstitial_idx] if isinstance(interstitial_idx, int) else interstitial_idx + for idx in indices: + if idx < n: + radii[idx] = min(radii[idx], 0.05) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dfd30db2768e368a4c2065d45c322017169d7ada Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..9a6c75ebdabd4f7badc2a7ae61932579d29ae45c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9252426198410459, + "spatial_uniformity_details": { + "cell_size_mean": 0.1986633461250563, + "cell_size_std": 0.0160515210239986, + "coefficient_of_variation": 0.08079759682038556 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.6368702090797984, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00017320713346479101, + "mean_density": 0.023081919553891272, + "cv": 0.5701786419636127 + }, + "packing_efficiency": 0.657026208066829, + "packing_efficiency_details": { + "total_area": 0.657026208066829, + "square_area": 1.0, + "efficiency": 0.657026208066829, + "relative_to_estimated_best": 0.7821740572224155 + }, + "radius_distribution": 0.982944883585438, + "radius_distribution_details": { + "mean": 0.08743441552591144, + "std": 0.019974729258027173, + "min": 0.022819999898844673, + "max": 0.12046280438739371, + "range": 0.09764280448854903, + "small_count": 7, + "medium_count": 8, + "large_count": 11, + "diversity_score": 0.982944883585438 + }, + "gap_analysis": 0.6656, + "gap_analysis_details": { + "covered_samples": 1664, + "total_samples": 2500, + "coverage": 0.6656, + "gap_ratio": 0.33440000000000003 + }, + "geometric_quality": 0.6541172792892348, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6541172792892348, + "min_quality": 0.3236094643333471, + "max_quality": 0.8150363699482288 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..9be418118e0e099ed1dd1da07a99703ee337a249 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 232.10 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2733 + + Auxiliary Metrics: + • spatial_uniformity: 0.925 + • edge_utilization: 0.738 + • density_variance: 0.637 + • packing_efficiency: 0.657 + • radius_distribution: 0.983 + • gap_analysis: 0.666 + • geometric_quality: 0.654 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2733 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.925 + • Boundary and corner utilization: 0.738 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.637 + • Area utilization efficiency: 0.657 + • Radius size diversity: 0.983 + • Area coverage (1 - gap ratio): 0.666 + • Delaunay triangulation quality: 0.654 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..dd22f439a567ade19b6d5ef13e0c38214c71e7d1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2732948036736973, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0934, 0.1000)\n centers[2] = (0.1000, 0.3000)\n centers[3] = (0.1000, 0.5000)\n centers[4] = (0.0696, 0.7179)\n centers[5] = (0.1000, 0.9000)\n centers[6] = (0.2885, 0.0996)\n centers[7] = (0.2622, 0.2985)\n centers[8] = (0.3000, 0.5000)\n centers[9] = (0.3211, 0.7100)\n centers[10] = (0.3002, 0.9000)\n centers[11] = (0.4904, 0.0964)\n centers[12] = (0.4766, 0.3209)\n centers[13] = (0.5000, 0.7000)\n centers[14] = (0.4853, 0.9000)\n centers[15] = (0.6932, 0.1001)\n centers[16] = (0.6895, 0.5098)\n centers[17] = (0.6990, 0.7086)\n centers[18] = (0.6909, 0.9005)\n centers[19] = (0.9000, 0.1000)\n centers[20] = (0.8994, 0.3016)\n centers[21] = (0.9029, 0.5003)\n centers[22] = (0.8999, 0.6986)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.1893, 0.6321)\n centers[25] = (0.6972, 0.3019)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9252426198410459, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.6368702090797984, + "aux_packing_efficiency": 0.657026208066829, + "aux_radius_distribution": 0.982944883585438, + "aux_gap_analysis": 0.6656, + "aux_geometric_quality": 0.6541172792892348 + }, + "private": { + "reported_sum_of_radii": 2.2732948036736973 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2733\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.925\n \u2022 Boundary and corner utilization: 0.738\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.637\n \u2022 Area utilization efficiency: 0.657\n \u2022 Radius size diversity: 0.983\n \u2022 Area coverage (1 - gap ratio): 0.666\n \u2022 Delaunay triangulation quality: 0.654\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_124/results/packing_viz.png", + "execution_time_mean": 232.09958620695397, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b1eb64f6e5e17e497e34d05db64ad43c50944a61 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..b06ca585cc197701b905cd8428f2c796faec01f4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/edit.diff @@ -0,0 +1,436 @@ +--- a/original.py ++++ b/original.py +@@ -1,238 +1,291 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" ++""" ++Hybrid circle packing optimization for n=26 circles combining ++a combinatorial search for initial configurations with a dynamic, ++force-directed refinement stage. ++""" + + import numpy as np + import itertools + + +-def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates centers for a square grid of circles with potentially asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the square grid. +- sc_x (float): The starting x-coordinate for linspace. +- ec_x (float): The ending x-coordinate for linspace. +- sc_y (float): The starting y-coordinate for linspace. +- ec_y (float): The ending y-coordinate for linspace. +- +- Returns: +- np.array: An array of (x, y) coordinates for the grid centers. +- """ +- x_coords = np.linspace(sc_x, ec_x, grid_size) +- y_coords = np.linspace(sc_y, ec_y, grid_size) +- grid_centers = [] +- for y in y_coords: +- for x in x_coords: +- grid_centers.append([x, y]) +- return np.array(grid_centers) +- +- +-def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates potential interstitial points within the grid formed by _generate_grid_centers, +- with potentially asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the base grid. +- sc_x (float): The starting x-coordinate of the grid. +- ec_x (float): The ending x-coordinate of the grid. +- sc_y (float): The starting y-coordinate of the grid. +- ec_y (float): The ending y-coordinate of the grid. +- +- Returns: +- np.array: An array of (x, y) coordinates for the candidate interstitial centers. +- """ ++class DynamicPackingOptimizer: ++ """ ++ Optimizes circle packing using a force-directed approach with iterative radius maximization. ++ This version includes a restoring force for the central circle and uses weighted radius relaxation. ++ It takes an initial set of centers and iteratively adjusts them. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=1500, initial_learning_rate=0.01): ++ self.n_circles = num_circles ++ self.num_steps = num_steps ++ self.initial_learning_rate = initial_learning_rate ++ self.w_central = w_central ++ ++ self.centers = np.copy(initial_centers) ++ self.interstitial_indices = interstitial_indices ++ self.central_idx = 0 # Assumed central circle is always at index 0 ++ ++ # Initialize best configuration with max radii for the starting configuration ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ self.best_sum_radii = np.sum(self.radii) ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(self.radii) ++ ++ def optimize(self): ++ """ ++ Runs the dynamic optimization process. ++ Returns the best centers and radii found during the optimization. ++ """ ++ for step in range(self.num_steps): ++ # Annealing learning rate ++ learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) ++ if learning_rate < 1e-7: ++ learning_rate = 1e-7 ++ ++ # Use fewer iterations for speed during intermediate steps, more for final refinement. ++ radii_iter_count = 50 if step < self.num_steps * 0.9 else 2000 ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ ++ # Check if this configuration improves the best found so far ++ # Recompute radii with full iterations for accurate sum comparison ++ test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ current_sum_radii = np.sum(test_radii_for_sum) ++ ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(test_radii_for_sum) ++ ++ # Calculate force vectors for center movement ++ force_vectors = np.zeros_like(self.centers) ++ ++ # Repulsion between circles ++ for i in range(self.n_circles): ++ for j in range(i + 1, self.n_circles): ++ dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) ++ target_dist = current_radii[i] + current_radii[j] ++ buffer_factor = 0.05 # Small buffer to ensure slight separation ++ if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: ++ overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) ++ direction = (self.centers[i] - self.centers[j]) / dist_ij ++ force_vectors[i] += direction * overlap_factor ++ force_vectors[j] -= direction * overlap_factor ++ ++ # Boundary repulsion forces ++ K_boundary = 10.0 ++ for i in range(self.n_circles): ++ x, y = self.centers[i] ++ r = current_radii[i] ++ if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) ++ if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) ++ if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) ++ if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) ++ ++ # Add a restoring force pulling the central circle towards the geometric center ++ K_center = 5.0 # Spring constant to keep the central circle near the middle ++ center_pos = self.centers[self.central_idx] ++ center_offset = np.array([0.5, 0.5]) - center_pos ++ force_vectors[self.central_idx] += K_center * center_offset ++ ++ # Update centers based on forces ++ self.centers += learning_rate * force_vectors ++ ++ # Clip centers to ensure they stay within bounds (considering radii) ++ for i in range(self.n_circles): ++ r = current_radii[i] # Use the quickly computed radii for clipping ++ self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) ++ self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) ++ ++ return self.best_centers, self.best_radii ++ ++ ++def _generate_grid_centers(grid_size, sc, ec): ++ """Generates centers for a square grid of circles with symmetric bounds.""" ++ coords = np.linspace(sc, ec, grid_size) ++ return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) ++ ++ ++def _generate_interstitial_candidates(grid_size, sc, ec): ++ """Generates potential interstitial points within the grid cells (symmetric bounds).""" + if grid_size < 2: + return np.array([]) +- +- step_x = (ec_x - sc_x) / (grid_size - 1) +- step_y = (ec_y - sc_y) / (grid_size - 1) +- +- candidates = [] +- # Interstitial points are halfway between grid points +- for i in range(grid_size - 1): # y-indices +- for j in range(grid_size - 1): # x-indices +- interstitial_x = sc_x + j * step_x + step_x / 2 +- interstitial_y = sc_y + i * step_y + step_y / 2 +- candidates.append([interstitial_x, interstitial_y]) +- return np.array(candidates) ++ step = (ec - sc) / (grid_size - 1) ++ interstitial_coords = np.linspace(sc + step / 2, ec - step / 2, grid_size - 1) ++ return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates. +- max_iterations: Maximum iterations for the relaxation process. +- tolerance: Convergence tolerance. +- interstitial_indices: A list of indices for interstitial circles to apply +- an adaptive initial radius heuristic. Defaults to None. +- w_central (float): Weight factor for the central circle during overlap resolution. +- +- Returns: +- np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). +- # This prevents them from growing too large initially and sub-optimally +- # squeezing their neighbors, allowing for a better overall packing. + if interstitial_indices is not None: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to half the distance to the nearest neighbor. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). +- # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. +- # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + w_i = w_central if i == 0 else 1.0 # Central circle (index 0) is protected + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) +- # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + def construct_packing(): + """ +- Construct a specific arrangement of 26 circles in a unit square +- that attempts to maximize the sum of their radii by re-instating the +- powerful `1+23+2` combinatorial search strategy. +- It places: +- - 1 fixed central circle. +- - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). +- - 2 interstitial circles, chosen from the 16 available interstitial candidate positions. +- This version also optimizes grid boundary parameters and the central circle's weight. +- +- Returns: +- Tuple of (centers, radii) ++ Constructs an arrangement of 26 circles using a two-stage hybrid process: ++ 1. A broad combinatorial search for initial topologies. ++ 2. A deep dynamic refinement of the top candidates found. + """ + n_circles = 26 + grid_size = 5 +- +- # Ranges for optimizing grid boundaries and central weight. +- # Asymmetric grid boundary options (re-instated from prior successful versions) +- sc_options_x = np.array([0.09, 0.1, 0.11]) +- ec_options_x = np.array([0.89, 0.9, 0.91]) +- sc_options_y = np.array([0.09, 0.1, 0.11]) +- ec_options_y = np.array([0.89, 0.9, 0.91]) +- +- central_weight_options = np.linspace(1.5, 2.5, 3) # [1.5, 2.0, 2.5] +- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None ++ top_n_to_refine = 5 # Number of best initial configs to pass to dynamic optimization ++ ++ # --- STAGE 1: Coarse Combinatorial Search --- ++ # Reduced search space for start/end coords for symmetric grids to speed up Stage 1 ++ start_coord_options = np.array([0.09, 0.1, 0.11]) ++ end_coord_options = np.array([0.89, 0.9, 0.91]) ++ central_weight_options = np.array([1.5, 2.0]) # Fewer options for speed ++ ++ top_n_configs = [] # Stores (sum_r, centers, interstitial_indices, w_central) + + num_fixed_central = 1 +- num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 +- ++ num_peripheral_to_select = n_circles - num_fixed_central - num_interstitial_to_select # 23 ++ ++ # Indices for interstitial circles in the `current_centers` array + interstitial_circle_indices_to_pass = [ +- num_fixed_central + num_peripheral_to_select, +- num_fixed_central + num_peripheral_to_select + 1 ++ num_fixed_central + num_peripheral_to_select, # index 24 ++ num_fixed_central + num_peripheral_to_select + 1 # index 25 + ] + + for w_central in central_weight_options: +- for sc_x in sc_options_x: +- for ec_x in ec_options_x: +- # Ensure end_coord > start_coord and grid is centered along X +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): ++ for sc in start_coord_options: ++ for ec in end_coord_options: ++ if ec <= sc: + continue +- for sc_y in sc_options_y: +- for ec_y in ec_options_y: +- # Ensure end_coord > start_coord and grid is centered along Y +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): +- continue +- +- all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) +- +- central_point = np.array([0.5, 0.5]) +- +- peripheral_grid_points = [] +- for center in all_grid_centers: +- if not np.allclose(center, central_point): +- peripheral_grid_points.append(center) +- peripheral_grid_points = np.array(peripheral_grid_points) +- +- # C(24, 23) combinations for peripheral points +- for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] +- +- # C(16, 2) combinations for interstitial points +- for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] +- +- # Construct the full set of 26 centers +- current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) +- current_centers = np.array(current_centers_list) +- +- # Compute radii for this configuration +- current_radii = compute_max_radii( +- current_centers, +- interstitial_indices=interstitial_circle_indices_to_pass, +- w_central=w_central +- ) +- current_sum_radii = np.sum(current_radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii +- +- return best_centers, best_radii ++ # Ensure the grid's center aligns with 0.5 for the central point heuristic. ++ mid_coord = sc + (ec - sc) / (grid_size - 1) * (grid_size // 2) ++ if not np.isclose(mid_coord, 0.5): ++ continue ++ ++ all_grid_centers = _generate_grid_centers(grid_size, sc, ec) ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec) ++ ++ central_point = np.array([0.5, 0.5]) ++ peripheral_grid_points = [] ++ for center in all_grid_centers: ++ if not np.allclose(center, central_point): ++ peripheral_grid_points.append(center) ++ peripheral_grid_points = np.array(peripheral_grid_points) # These are 24 points ++ ++ # Iterate through all combinations of 23 peripheral points from the 24 available ++ for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): ++ selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] ++ ++ # Iterate through all combinations of 2 interstitial points from the 16 available candidates ++ for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): ++ selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] ++ ++ # Assemble config: 1 central, 23 peripheral, 2 interstitial ++ current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) ++ current_centers = np.array(current_centers_list) ++ ++ # Fast evaluation with fewer iterations for the initial combinatorial search ++ radii = compute_max_radii(current_centers, max_iterations=500, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) ++ sum_r = np.sum(radii) ++ ++ # Maintain a list of the top N configurations ++ if len(top_n_configs) < top_n_to_refine: ++ top_n_configs.append((sum_r, current_centers, interstitial_circle_indices_to_pass, w_central)) ++ top_n_configs.sort(key=lambda x: x[0], reverse=True) ++ elif sum_r > top_n_configs[-1][0]: ++ top_n_configs[-1] = (sum_r, current_centers, interstitial_circle_indices_to_pass, w_central) ++ top_n_configs.sort(key=lambda x: x[0], reverse=True) ++ ++ # --- STAGE 2: Dynamic Refinement --- ++ best_overall_sum_radii = -1.0 ++ best_overall_centers = None ++ best_overall_radii = None ++ ++ if not top_n_configs: ++ # Fallback in case no configs were generated (should not happen with chosen parameters) ++ # A simple 5x5 grid with some elements removed and added for 26 circles ++ centers_base = _generate_grid_centers(5, 0.1, 0.9) ++ centers = np.vstack([centers_base[:24], [0.2, 0.2], [0.8, 0.8]]) # Make sure it's 26 circles ++ radii = compute_max_radii(centers) ++ return centers, radii ++ ++ for sum_r_initial, initial_centers, interstitial_idx, w_central in top_n_configs: ++ optimizer = DynamicPackingOptimizer(initial_centers=initial_centers, ++ interstitial_indices=interstitial_idx, ++ w_central=w_central, ++ num_circles=n_circles, ++ num_steps=1500, # Increased steps for deeper optimization ++ initial_learning_rate=0.01) ++ ++ optimized_centers, optimized_radii = optimizer.optimize() ++ current_sum_radii = np.sum(optimized_radii) ++ ++ if current_sum_radii > best_overall_sum_radii: ++ best_overall_sum_radii = current_sum_radii ++ best_overall_centers = optimized_centers ++ best_overall_radii = optimized_radii ++ ++ return best_overall_centers, best_overall_radii + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/main.py new file mode 100644 index 0000000000000000000000000000000000000000..74357a9dd07b01ae1672d3797b0dd9700b85a089 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/main.py @@ -0,0 +1,291 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing optimization for n=26 circles combining +a combinatorial search for initial configurations with a dynamic, +force-directed refinement stage. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version includes a restoring force for the central circle and uses weighted radius relaxation. + It takes an initial set of centers and iteratively adjusts them. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=1500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.central_idx = 0 # Assumed central circle is always at index 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """ + Runs the dynamic optimization process. + Returns the best centers and radii found during the optimization. + """ + for step in range(self.num_steps): + # Annealing learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Use fewer iterations for speed during intermediate steps, more for final refinement. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 2000 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Check if this configuration improves the best found so far + # Recompute radii with full iterations for accurate sum comparison + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + buffer_factor = 0.05 # Small buffer to ensure slight separation + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force pulling the central circle towards the geometric center + K_center = 5.0 # Spring constant to keep the central circle near the middle + center_pos = self.centers[self.central_idx] + center_offset = np.array([0.5, 0.5]) - center_pos + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] # Use the quickly computed radii for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc, ec): + """Generates centers for a square grid of circles with symmetric bounds.""" + coords = np.linspace(sc, ec, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, sc, ec): + """Generates potential interstitial points within the grid cells (symmetric bounds).""" + if grid_size < 2: + return np.array([]) + step = (ec - sc) / (grid_size - 1) + interstitial_coords = np.linspace(sc + step / 2, ec - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices is not None: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to half the distance to the nearest neighbor. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = w_central if i == 0 else 1.0 # Central circle (index 0) is protected + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search for initial topologies. + 2. A deep dynamic refinement of the top candidates found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 5 # Number of best initial configs to pass to dynamic optimization + + # --- STAGE 1: Coarse Combinatorial Search --- + # Reduced search space for start/end coords for symmetric grids to speed up Stage 1 + start_coord_options = np.array([0.09, 0.1, 0.11]) + end_coord_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.array([1.5, 2.0]) # Fewer options for speed + + top_n_configs = [] # Stores (sum_r, centers, interstitial_indices, w_central) + + num_fixed_central = 1 + num_interstitial_to_select = 2 + num_peripheral_to_select = n_circles - num_fixed_central - num_interstitial_to_select # 23 + + # Indices for interstitial circles in the `current_centers` array + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, # index 24 + num_fixed_central + num_peripheral_to_select + 1 # index 25 + ] + + for w_central in central_weight_options: + for sc in start_coord_options: + for ec in end_coord_options: + if ec <= sc: + continue + # Ensure the grid's center aligns with 0.5 for the central point heuristic. + mid_coord = sc + (ec - sc) / (grid_size - 1) * (grid_size // 2) + if not np.isclose(mid_coord, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) # These are 24 points + + # Iterate through all combinations of 23 peripheral points from the 24 available + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + # Iterate through all combinations of 2 interstitial points from the 16 available candidates + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) + current_centers = np.array(current_centers_list) + + # Fast evaluation with fewer iterations for the initial combinatorial search + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + sum_r = np.sum(radii) + + # Maintain a list of the top N configurations + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_circle_indices_to_pass, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_circle_indices_to_pass, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_overall_sum_radii = -1.0 + best_overall_centers = None + best_overall_radii = None + + if not top_n_configs: + # Fallback in case no configs were generated (should not happen with chosen parameters) + # A simple 5x5 grid with some elements removed and added for 26 circles + centers_base = _generate_grid_centers(5, 0.1, 0.9) + centers = np.vstack([centers_base[:24], [0.2, 0.2], [0.8, 0.8]]) # Make sure it's 26 circles + radii = compute_max_radii(centers) + return centers, radii + + for sum_r_initial, initial_centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers, + interstitial_indices=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + num_steps=1500, # Increased steps for deeper optimization + initial_learning_rate=0.01) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_overall_sum_radii: + best_overall_sum_radii = current_sum_radii + best_overall_centers = optimized_centers + best_overall_radii = optimized_radii + + return best_overall_centers, best_overall_radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/original.py new file mode 100644 index 0000000000000000000000000000000000000000..a4b8b8ae793a08b9896dc8b18c0c59d09c2f4f33 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/original.py @@ -0,0 +1,238 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with potentially asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + sc_x (float): The starting x-coordinate for linspace. + ec_x (float): The ending x-coordinate for linspace. + sc_y (float): The starting y-coordinate for linspace. + ec_y (float): The ending y-coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers, + with potentially asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + sc_x (float): The starting x-coordinate of the grid. + ec_x (float): The ending x-coordinate of the grid. + sc_y (float): The starting y-coordinate of the grid. + ec_y (float): The ending y-coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + # This prevents them from growing too large initially and sub-optimally + # squeezing their neighbors, allowing for a better overall packing. + if interstitial_indices is not None: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to half the distance to the nearest neighbor. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + w_i = w_central if i == 0 else 1.0 # Central circle (index 0) is protected + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii by re-instating the + powerful `1+23+2` combinatorial search strategy. + It places: + - 1 fixed central circle. + - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). + - 2 interstitial circles, chosen from the 16 available interstitial candidate positions. + This version also optimizes grid boundary parameters and the central circle's weight. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + # Ranges for optimizing grid boundaries and central weight. + # Asymmetric grid boundary options (re-instated from prior successful versions) + sc_options_x = np.array([0.09, 0.1, 0.11]) + ec_options_x = np.array([0.89, 0.9, 0.91]) + sc_options_y = np.array([0.09, 0.1, 0.11]) + ec_options_y = np.array([0.89, 0.9, 0.91]) + + central_weight_options = np.linspace(1.5, 2.5, 3) # [1.5, 2.0, 2.5] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + for w_central in central_weight_options: + for sc_x in sc_options_x: + for ec_x in ec_options_x: + # Ensure end_coord > start_coord and grid is centered along X + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + for sc_y in sc_options_y: + for ec_y in ec_options_y: + # Ensure end_coord > start_coord and grid is centered along Y + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) + + # C(24, 23) combinations for peripheral points + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + # C(16, 2) combinations for interstitial points + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Construct the full set of 26 centers + current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) + current_centers = np.array(current_centers_list) + + # Compute radii for this configuration + current_radii = compute_max_radii( + current_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central + ) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..0e936e0cb993f4206795c4f27c675bc3811430db --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8562016706962297, + "spatial_uniformity_details": { + "cell_size_mean": 0.19743547849225404, + "cell_size_std": 0.03315911784333308, + "coefficient_of_variation": 0.16794913421138172 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.5360809750710591, + "density_variance_details": { + "grid_size": 10, + "variance": 0.000710036553891236, + "mean_density": 0.030791337328517968, + "cv": 0.8653898319511283 + }, + "packing_efficiency": 0.6844696134654787, + "packing_efficiency_details": { + "total_area": 0.6844696134654787, + "square_area": 1.0, + "efficiency": 0.6844696134654787, + "relative_to_estimated_best": 0.8148447779350938 + }, + "radius_distribution": 0.9118485864013028, + "radius_distribution_details": { + "mean": 0.08699690540658, + "std": 0.02848308840354122, + "min": 0.04585760616613399, + "max": 0.17291959213580066, + "range": 0.12706198596966667, + "small_count": 9, + "medium_count": 13, + "large_count": 4, + "diversity_score": 0.9118485864013028 + }, + "gap_analysis": 0.6836, + "gap_analysis_details": { + "covered_samples": 1709, + "total_samples": 2500, + "coverage": 0.6836, + "gap_ratio": 0.3164 + }, + "geometric_quality": 0.6812373596818921, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6812373596818921, + "min_quality": 0.3087038246940515, + "max_quality": 0.946614956410452 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..199cc68feaea85a98f289c53d16a586d4cfd9197 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 86.99 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2619 + + Auxiliary Metrics: + • spatial_uniformity: 0.856 + • edge_utilization: 0.738 + • density_variance: 0.536 + • packing_efficiency: 0.684 + • radius_distribution: 0.912 + • gap_analysis: 0.684 + • geometric_quality: 0.681 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2619 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.856 + • Boundary and corner utilization: 0.738 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.536 + • Area utilization efficiency: 0.684 + • Radius size diversity: 0.912 + • Area coverage (1 - gap ratio): 0.684 + • Delaunay triangulation quality: 0.681 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 31.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..24e55fb00d1b5235a692dfbfba8f3296a1faf4cd --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.26191954057108, + "public": { + "centers_str": " centers[0] = (0.4980, 0.4974)\n centers[1] = (0.0914, 0.1000)\n centers[2] = (0.1000, 0.3000)\n centers[3] = (0.0878, 0.5128)\n centers[4] = (0.1000, 0.7000)\n centers[5] = (0.0911, 0.9001)\n centers[6] = (0.2876, 0.1008)\n centers[7] = (0.2335, 0.2733)\n centers[8] = (0.2979, 0.4987)\n centers[9] = (0.2517, 0.6983)\n centers[10] = (0.2839, 0.8995)\n centers[11] = (0.4893, 0.0910)\n centers[12] = (0.4120, 0.2778)\n centers[13] = (0.3829, 0.7373)\n centers[14] = (0.4846, 0.9045)\n centers[15] = (0.6901, 0.1019)\n centers[16] = (0.6551, 0.3556)\n centers[17] = (0.6364, 0.6764)\n centers[18] = (0.7153, 0.9213)\n centers[19] = (0.9001, 0.0999)\n centers[20] = (0.8997, 0.3019)\n centers[21] = (0.9029, 0.5031)\n centers[22] = (0.9041, 0.7004)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.1883, 0.4122)\n centers[25] = (0.4033, 0.5825)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8562016706962297, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.5360809750710591, + "aux_packing_efficiency": 0.6844696134654787, + "aux_radius_distribution": 0.9118485864013028, + "aux_gap_analysis": 0.6836, + "aux_geometric_quality": 0.6812373596818921 + }, + "private": { + "reported_sum_of_radii": 2.26191954057108 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2619\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.856\n \u2022 Boundary and corner utilization: 0.738\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.536\n \u2022 Area utilization efficiency: 0.684\n \u2022 Radius size diversity: 0.912\n \u2022 Area coverage (1 - gap ratio): 0.684\n \u2022 Delaunay triangulation quality: 0.681\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 31.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/results/packing_viz.png", + "execution_time_mean": 86.98690003715456, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..7b003489380f204ef8b7863f411d12fa4f03e622 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_125/rewrite.txt @@ -0,0 +1,282 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing optimization for n=26 circles combining +a combinatorial search for initial configurations with a dynamic, +force-directed refinement stage. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version includes a restoring force for the central circle and uses weighted radius relaxation. + It takes an initial set of centers and iteratively adjusts them. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=1500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.central_idx = 0 # Assumed central circle is always at index 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """ + Runs the dynamic optimization process. + Returns the best centers and radii found during the optimization. + """ + for step in range(self.num_steps): + # Annealing learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Use fewer iterations for speed during intermediate steps, more for final refinement. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 2000 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Check if this configuration improves the best found so far + # Recompute radii with full iterations for accurate sum comparison + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + buffer_factor = 0.05 # Small buffer to ensure slight separation + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force pulling the central circle towards the geometric center + K_center = 5.0 # Spring constant to keep the central circle near the middle + center_pos = self.centers[self.central_idx] + center_offset = np.array([0.5, 0.5]) - center_pos + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] # Use the quickly computed radii for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc, ec): + """Generates centers for a square grid of circles with symmetric bounds.""" + coords = np.linspace(sc, ec, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, sc, ec): + """Generates potential interstitial points within the grid cells (symmetric bounds).""" + if grid_size < 2: + return np.array([]) + step = (ec - sc) / (grid_size - 1) + interstitial_coords = np.linspace(sc + step / 2, ec - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices is not None: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to half the distance to the nearest neighbor. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = w_central if i == 0 else 1.0 # Central circle (index 0) is protected + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search for initial topologies. + 2. A deep dynamic refinement of the top candidates found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 5 # Number of best initial configs to pass to dynamic optimization + + # --- STAGE 1: Coarse Combinatorial Search --- + # Reduced search space for start/end coords for symmetric grids to speed up Stage 1 + start_coord_options = np.array([0.09, 0.1, 0.11]) + end_coord_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.array([1.5, 2.0]) # Fewer options for speed + + top_n_configs = [] # Stores (sum_r, centers, interstitial_indices, w_central) + + num_fixed_central = 1 + num_interstitial_to_select = 2 + num_peripheral_to_select = n_circles - num_fixed_central - num_interstitial_to_select # 23 + + # Indices for interstitial circles in the `current_centers` array + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, # index 24 + num_fixed_central + num_peripheral_to_select + 1 # index 25 + ] + + for w_central in central_weight_options: + for sc in start_coord_options: + for ec in end_coord_options: + if ec <= sc: + continue + # Ensure the grid's center aligns with 0.5 for the central point heuristic. + mid_coord = sc + (ec - sc) / (grid_size - 1) * (grid_size // 2) + if not np.isclose(mid_coord, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) # These are 24 points + + # Iterate through all combinations of 23 peripheral points from the 24 available + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + # Iterate through all combinations of 2 interstitial points from the 16 available candidates + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) + current_centers = np.array(current_centers_list) + + # Fast evaluation with fewer iterations for the initial combinatorial search + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + sum_r = np.sum(radii) + + # Maintain a list of the top N configurations + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_circle_indices_to_pass, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_circle_indices_to_pass, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_overall_sum_radii = -1.0 + best_overall_centers = None + best_overall_radii = None + + if not top_n_configs: + # Fallback in case no configs were generated (should not happen with chosen parameters) + # A simple 5x5 grid with some elements removed and added for 26 circles + centers_base = _generate_grid_centers(5, 0.1, 0.9) + centers = np.vstack([centers_base[:24], [0.2, 0.2], [0.8, 0.8]]) # Make sure it's 26 circles + radii = compute_max_radii(centers) + return centers, radii + + for sum_r_initial, initial_centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers, + interstitial_indices=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + num_steps=1500, # Increased steps for deeper optimization + initial_learning_rate=0.01) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_overall_sum_radii: + best_overall_sum_radii = current_sum_radii + best_overall_centers = optimized_centers + best_overall_radii = optimized_radii + + return best_overall_centers, best_overall_radii + +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e79d37029065801ca8d6e443b4cc8ce112151e68 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f0c199bc5a3051f4992fec9c318933f92192919f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9002664109167563, + "spatial_uniformity_details": { + "cell_size_mean": 0.20319367687907505, + "cell_size_std": 0.022510264215309616, + "coefficient_of_variation": 0.11078230607502444 + }, + "edge_utilization": 0.8, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 13, + "corner_score": 1.0, + "edge_score": 0.5 + }, + "density_variance": 0.5866962887478102, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0005801750256959895, + "mean_density": 0.03419192391063286, + "cv": 0.7044593926685758 + }, + "packing_efficiency": 0.7374859782474821, + "packing_efficiency_details": { + "total_area": 0.7374859782474821, + "square_area": 1.0, + "efficiency": 0.7374859782474821, + "relative_to_estimated_best": 0.8779594979136691 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.08955446133856726, + "std": 0.031761755916530715, + "min": 0.0003014256069998983, + "max": 0.1628427995253594, + "range": 0.16254137391835952, + "small_count": 5, + "medium_count": 15, + "large_count": 6, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.742, + "gap_analysis_details": { + "covered_samples": 1855, + "total_samples": 2500, + "coverage": 0.742, + "gap_ratio": 0.258 + }, + "geometric_quality": 0.6613439657108249, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6613439657108249, + "min_quality": 0.30276344657827353, + "max_quality": 0.9206428353794938 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..b8fe8887231771d6c1a65f9087f3b448d2faef6d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 335.48 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3284 + + Auxiliary Metrics: + • spatial_uniformity: 0.900 + • edge_utilization: 0.800 + • density_variance: 0.587 + • packing_efficiency: 0.737 + • radius_distribution: 0.885 + • gap_analysis: 0.742 + • geometric_quality: 0.661 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3284 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.900 + • Boundary and corner utilization: 0.800 + • Area utilization efficiency: 0.737 + • Area coverage (1 - gap ratio): 0.742 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.587 + • Radius size diversity: 0.885 + • Delaunay triangulation quality: 0.661 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..777513118236ddcf553a37d6ae8e901ca1a58836 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3284159948027487, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1003, 0.0862)\n centers[2] = (0.3001, 0.0995)\n centers[3] = (0.4276, 0.0748)\n centers[4] = (0.7544, 0.0532)\n centers[5] = (0.9017, 0.0989)\n centers[6] = (0.0964, 0.2739)\n centers[7] = (0.2834, 0.2459)\n centers[8] = (0.5993, 0.1210)\n centers[9] = (0.9421, 0.2569)\n centers[10] = (0.0831, 0.4599)\n centers[11] = (0.2477, 0.4924)\n centers[12] = (0.7466, 0.3465)\n centers[13] = (0.9059, 0.5343)\n centers[14] = (0.0003, 0.6983)\n centers[15] = (0.1394, 0.6828)\n centers[16] = (0.3955, 0.6873)\n centers[17] = (0.6764, 0.6640)\n centers[18] = (0.9180, 0.7158)\n centers[19] = (0.0914, 0.9086)\n centers[20] = (0.2901, 0.9003)\n centers[21] = (0.5066, 0.8917)\n centers[22] = (0.7082, 0.9138)\n centers[23] = (0.9006, 0.9006)\n centers[24] = (0.3720, 0.3921)\n centers[25] = (0.5109, 0.3032)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9002664109167563, + "aux_edge_utilization": 0.8, + "aux_density_variance": 0.5866962887478102, + "aux_packing_efficiency": 0.7374859782474821, + "aux_radius_distribution": 0.8854530804755598, + "aux_gap_analysis": 0.742, + "aux_geometric_quality": 0.6613439657108249 + }, + "private": { + "reported_sum_of_radii": 2.3284159948027487 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3284\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.900\n \u2022 Boundary and corner utilization: 0.800\n \u2022 Area utilization efficiency: 0.737\n \u2022 Area coverage (1 - gap ratio): 0.742\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.587\n \u2022 Radius size diversity: 0.885\n \u2022 Delaunay triangulation quality: 0.661\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_128/results/packing_viz.png", + "execution_time_mean": 335.47552504669875, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ef736ac549c5fc4e54787c9e21cb1924f6d6590e Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..60cd0a0c2b1f2b0ce8ccf0b02d464f8d2537dbac --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.893714457932387, + "spatial_uniformity_details": { + "cell_size_mean": 0.18109594102043464, + "cell_size_std": 0.021536946384885583, + "coefficient_of_variation": 0.11892561558588309 + }, + "edge_utilization": 0.19615384615384615, + "edge_utilization_details": { + "corners_touched": 1, + "edges_touched": 3, + "corner_score": 0.25, + "edge_score": 0.11538461538461539 + }, + "density_variance": 0.4223699183377275, + "density_variance_details": { + "grid_size": 10, + "variance": 0.000125145248319413, + "mean_density": 0.008179943549269143, + "cv": 1.367592853050673 + }, + "packing_efficiency": 0.3573906393724674, + "packing_efficiency_details": { + "total_area": 0.3573906393724674, + "square_area": 1.0, + "efficiency": 0.3573906393724674, + "relative_to_estimated_best": 0.425465046871985 + }, + "radius_distribution": 0.9947372351472321, + "radius_distribution_details": { + "mean": 0.06372089098674963, + "std": 0.017750214614115682, + "min": 0.032460624246911915, + "max": 0.09999999999999998, + "range": 0.06753937575308806, + "small_count": 10, + "medium_count": 8, + "large_count": 8, + "diversity_score": 0.9947372351472321 + }, + "gap_analysis": 0.3568, + "gap_analysis_details": { + "covered_samples": 892, + "total_samples": 2500, + "coverage": 0.3568, + "gap_ratio": 0.6432 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 36, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865478 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..8ec4c3cc7180da2a0622d5d27df6a49a66a9999a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.6567 + + Auxiliary Metrics: + • spatial_uniformity: 0.894 + • edge_utilization: 0.196 + • density_variance: 0.422 + • packing_efficiency: 0.357 + • radius_distribution: 0.995 + • gap_analysis: 0.357 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.6567 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.894 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.196 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.422 + → Balance circle density across different regions + • Area utilization efficiency: 0.357 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.357 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.995 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 1/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 64.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..bffa865c543f56aebb7dc54c77dec05fbb001d3c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.6567431656554905, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.1000, 0.3000)\n centers[2] = (0.1000, 0.5000)\n centers[3] = (0.1000, 0.7000)\n centers[4] = (0.1000, 0.9000)\n centers[5] = (0.3000, 0.1000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.3000, 0.5000)\n centers[8] = (0.3000, 0.7000)\n centers[9] = (0.3000, 0.9000)\n centers[10] = (0.5000, 0.3000)\n centers[11] = (0.5000, 0.7000)\n centers[12] = (0.7000, 0.1000)\n centers[13] = (0.7000, 0.3000)\n centers[14] = (0.7000, 0.5000)\n centers[15] = (0.7000, 0.7000)\n centers[16] = (0.7000, 0.9000)\n centers[17] = (0.9000, 0.1000)\n centers[18] = (0.9000, 0.3000)\n centers[19] = (0.9000, 0.5000)\n centers[20] = (0.9000, 0.7000)\n centers[21] = (0.9000, 0.9000)\n centers[22] = (0.2000, 0.2000)\n centers[23] = (0.2000, 0.8000)\n centers[24] = (0.8000, 0.2000)\n centers[25] = (0.8000, 0.8000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.893714457932387, + "aux_edge_utilization": 0.19615384615384615, + "aux_density_variance": 0.4223699183377275, + "aux_packing_efficiency": 0.3573906393724674, + "aux_radius_distribution": 0.9947372351472321, + "aux_gap_analysis": 0.3568, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.6567431656554905 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.6567\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.894\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.196\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.422\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.357\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.357\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.995\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 1/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 64.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_13/results/packing_viz.png", + "execution_time_mean": 0.0037476387806236744, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..212dd030fac3fdc56bcf016134df4e1cc93c319b Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4b8aa5f3cb7fdd78d764faea87323df07452f466 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8727986538797037, + "spatial_uniformity_details": { + "cell_size_mean": 0.19955413537153388, + "cell_size_std": 0.02908294445402623, + "coefficient_of_variation": 0.14573962225407858 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.5372179809033187, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0007283593425369406, + "mean_density": 0.03132902630986299, + "cv": 0.8614417900132918 + }, + "packing_efficiency": 0.70869337576817, + "packing_efficiency_details": { + "total_area": 0.70869337576817, + "square_area": 1.0, + "efficiency": 0.70869337576817, + "relative_to_estimated_best": 0.8436825902002024 + }, + "radius_distribution": 0.8956403029078803, + "radius_distribution_details": { + "mean": 0.08796803095452346, + "std": 0.030625763136210314, + "min": 0.028633238716572876, + "max": 0.16714911848258704, + "range": 0.13851587976601415, + "small_count": 8, + "medium_count": 14, + "large_count": 4, + "diversity_score": 0.8956403029078803 + }, + "gap_analysis": 0.7132, + "gap_analysis_details": { + "covered_samples": 1783, + "total_samples": 2500, + "coverage": 0.7132, + "gap_ratio": 0.28680000000000005 + }, + "geometric_quality": 0.6896845565474884, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6896845565474884, + "min_quality": 0.31227858085566496, + "max_quality": 0.9985548696367464 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3434378f9b23a1eb9cd69e32242509561d413e97 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 149.18 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2872 + + Auxiliary Metrics: + • spatial_uniformity: 0.873 + • edge_utilization: 0.723 + • density_variance: 0.537 + • packing_efficiency: 0.709 + • radius_distribution: 0.896 + • gap_analysis: 0.713 + • geometric_quality: 0.690 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2872 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.873 + • Boundary and corner utilization: 0.723 + • Area utilization efficiency: 0.709 + • Area coverage (1 - gap ratio): 0.713 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.537 + • Radius size diversity: 0.896 + • Delaunay triangulation quality: 0.690 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..ccacdabf18d6ade4a0984945fee8e75a40576791 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.28716880481761, + "public": { + "centers_str": " centers[0] = (0.5013, 0.4938)\n centers[1] = (0.0999, 0.1000)\n centers[2] = (0.1000, 0.3000)\n centers[3] = (0.0967, 0.5002)\n centers[4] = (0.0876, 0.6872)\n centers[5] = (0.1000, 0.9000)\n centers[6] = (0.3001, 0.1000)\n centers[7] = (0.2954, 0.2954)\n centers[8] = (0.2671, 0.4853)\n centers[9] = (0.2922, 0.9533)\n centers[10] = (0.5000, 0.1000)\n centers[11] = (0.4986, 0.2807)\n centers[12] = (0.3142, 0.7415)\n centers[13] = (0.5135, 0.9071)\n centers[14] = (0.6913, 0.0422)\n centers[15] = (0.7113, 0.1682)\n centers[16] = (0.6848, 0.3847)\n centers[17] = (0.6398, 0.6699)\n centers[18] = (0.7112, 0.9146)\n centers[19] = (0.9000, 0.1000)\n centers[20] = (0.9016, 0.2987)\n centers[21] = (0.8927, 0.5041)\n centers[22] = (0.9039, 0.7075)\n centers[23] = (0.9018, 0.9018)\n centers[24] = (0.4087, 0.4055)\n centers[25] = (0.4094, 0.5459)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8727986538797037, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.5372179809033187, + "aux_packing_efficiency": 0.70869337576817, + "aux_radius_distribution": 0.8956403029078803, + "aux_gap_analysis": 0.7132, + "aux_geometric_quality": 0.6896845565474884 + }, + "private": { + "reported_sum_of_radii": 2.28716880481761 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2872\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.873\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Area utilization efficiency: 0.709\n \u2022 Area coverage (1 - gap ratio): 0.713\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.537\n \u2022 Radius size diversity: 0.896\n \u2022 Delaunay triangulation quality: 0.690\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_130/results/packing_viz.png", + "execution_time_mean": 149.18401742586866, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..88ea5fd627608212ce4262595b082d713b592230 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..5f2dbeb0fd407a320cb26a50cbde3142e708337a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/edit.diff @@ -0,0 +1,363 @@ +--- a/original.py ++++ b/original.py +@@ -1,215 +1,265 @@ + # EVOLVE-BLOCK-START + """ + Hybrid circle packing for n=26 circles, combining a systematic search for + initial configurations with a force-directed dynamic optimizer for refinement. + """ + + import numpy as np ++import itertools + + + class DynamicPackingOptimizer: + """ +- Optimizes circle packing using a force-directed approach. Starting from an +- initial configuration, it iteratively adjusts circle centers based on +- repulsion forces and boundaries, while repeatedly calculating maximum radii +- to guide the optimization towards a better packing. +- """ +- def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): +- self.n_circles = num_circles ++ Optimizes circle packing using a force-directed approach. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2000, initial_learning_rate=0.015): ++ self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate +- self.central_fixed = central_fixed ++ self.central_fixed = True + + self.centers = np.copy(initial_centers) +- self.interstitial_idx = interstitial_idx +- self.central_idx = 0 # The central circle is at index 0 by convention +- +- # Initialize best configuration with max radii for the starting layout +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) ++ self.interstitial_indices = interstitial_indices ++ self.w_central = w_central ++ self.central_idx = 0 ++ ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): +- # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + +- # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. +- radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) +- +- # Check if this configuration might be the best so far +- test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) +- current_sum_radii = np.sum(test_radii_for_sum) +- +- if current_sum_radii > self.best_sum_radii: +- self.best_sum_radii = current_sum_radii +- self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(test_radii_for_sum) +- +- # --- Calculate force vectors for center movement --- ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ ++ if step % 50 == 0 or step == self.num_steps - 1: ++ test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ current_sum_radii = np.sum(test_radii) ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(test_radii) ++ + force_vectors = np.zeros_like(self.centers) +- +- # 1. Repulsion between circles ++ buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] +- +- buffer_factor = 0.05 # Apply force even before contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + +- # 2. Boundary repulsion forces +- K_boundary = 10.0 # Strong boundary force ++ K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + +- # --- Update centers --- + self.centers += learning_rate * force_vectors +- + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + +- # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +-def _generate_grid_centers(grid_size, start_coord, end_coord): +- """Generates centers for a square grid of circles.""" +- coords = np.linspace(start_coord, end_coord, grid_size) +- return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) +- +- +-def _generate_interstitial_candidates(grid_size, start_coord, end_coord): +- """Generates potential interstitial points within the grid cells.""" ++def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): ++ """ ++ Generates centers for a square grid of circles with asymmetric bounds. ++ """ ++ x_coords = np.linspace(sc_x, ec_x, grid_size) ++ y_coords = np.linspace(sc_y, ec_y, grid_size) ++ grid_centers = [] ++ for y in y_coords: ++ for x in x_coords: ++ grid_centers.append([x, y]) ++ return np.array(grid_centers) ++ ++ ++def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): ++ """ ++ Generates potential interstitial points with asymmetric bounds and variable density. ++ """ + if grid_size < 2: + return np.array([]) +- step = (end_coord - start_coord) / (grid_size - 1) +- interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) +- return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) ++ num_interstitial_intervals_x = (grid_size - 1) * density_factor ++ num_interstitial_intervals_y = (grid_size - 1) * density_factor ++ step_x = (ec_x - sc_x) / num_interstitial_intervals_x ++ step_y = (ec_y - sc_y) / num_interstitial_intervals_y ++ candidates = [] ++ for i in range(num_interstitial_intervals_y): ++ for j in range(num_interstitial_intervals_x): ++ candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) ++ return np.array(candidates) + + + def construct_packing(): + """ +- Constructs an arrangement of 26 circles by searching for optimal initial +- configurations and refining each with a dynamic optimizer. ++ Constructs an arrangement of 26 circles using a two-stage process: ++ 1. A broad combinatorial search finds promising initial topologies. ++ 2. A force-directed dynamic optimizer refines the best candidates. + """ + n_circles = 26 + grid_size = 5 ++ sc_options = np.array([0.09, 0.1, 0.11]) ++ ec_options = np.array([0.89, 0.9, 0.91]) ++ central_weight_options = np.linspace(1.2, 2.2, 3) ++ ++ TOP_N_CANDIDATES = 20 ++ top_candidates = [] ++ + best_sum_radii = -1.0 +- best_centers, best_radii = None, None +- +- # Search space for the grid's boundary parameter +- start_coord_search_space = np.linspace(0.08, 0.12, 5) +- +- for start_coord in start_coord_search_space: +- end_coord = 1.0 - start_coord +- +- # 1. Generate base 25 centers (1 central + 24 on a grid) +- all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) +- central_point_coords = np.array([0.5, 0.5]) +- central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] +- +- base_centers = np.zeros((n_circles - 1, 2)) +- base_centers[0] = central_point_coords +- base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- +- # 2. Generate interstitial candidates for the 26th circle +- candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) +- +- # 3. For each candidate, run the dynamic optimizer +- for interstitial_point in candidate_points: +- initial_centers_config = np.vstack([base_centers, interstitial_point]) +- interstitial_idx = n_circles - 1 +- +- # Instantiate and run the optimizer for this initial configuration +- optimizer = DynamicPackingOptimizer( +- initial_centers=initial_centers_config, +- interstitial_idx=interstitial_idx, +- num_steps=2000, +- initial_learning_rate=0.015 +- ) +- optimized_centers, optimized_radii = optimizer.optimize() +- current_sum_radii = np.sum(optimized_radii) +- +- # 4. Keep track of the best result found across all runs +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = optimized_centers +- best_radii = optimized_radii ++ best_centers = None ++ best_radii = None ++ ++ num_fixed_central = 1 ++ num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 ++ num_interstitial_to_select = 2 ++ ++ interstitial_circle_indices_to_pass = [ ++ num_fixed_central + num_peripheral_to_select, ++ num_fixed_central + num_peripheral_to_select + 1 ++ ] ++ ++ # STAGE 1: Coarse Combinatorial Search ++ for w_central in central_weight_options: ++ for sc_x in sc_options: ++ for ec_x in ec_options: ++ if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): ++ continue ++ for sc_y in sc_options: ++ for ec_y in ec_options: ++ if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): ++ continue ++ ++ all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) ++ ++ central_point = np.array([0.5, 0.5]) ++ peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) ++ ++ for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): ++ selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] ++ ++ for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): ++ selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] ++ current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) ++ ++ coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ if len(top_candidates) < TOP_N_CANDIDATES: ++ top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ elif coarse_sum_radii > top_candidates[-1][0]: ++ top_candidates.pop() ++ top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ ++ # STAGE 2: Refine Top Candidates with Dynamic Optimizer ++ if not top_candidates: ++ # Fallback if no valid configurations were found ++ return np.random.rand(n_circles, 2), np.zeros(n_circles) ++ ++ # Initialize with the best result from the coarse search ++ best_sum_radii = top_candidates[0][0] ++ best_centers = top_candidates[0][1] ++ best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) ++ ++ for _, initial_centers, w_central in top_candidates: ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=initial_centers, ++ interstitial_indices=interstitial_circle_indices_to_pass, ++ w_central=w_central, ++ num_steps=2000, ++ initial_learning_rate=0.015, ++ ) ++ optimized_centers, optimized_radii = optimizer.optimize() ++ current_sum_radii = np.sum(optimized_radii) ++ ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = optimized_centers ++ best_radii = optimized_radii + + return best_centers, best_radii + + +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.5): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Cap the initial radius of the interstitial circle +- if interstitial_idx != -1 and interstitial_idx < n: +- radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) ++ # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). ++ if interstitial_indices: ++ for idx in interstitial_indices: ++ if idx < n: ++ other_centers_mask = np.ones(n, dtype=bool) ++ other_centers_mask[idx] = False ++ other_centers = centers[other_centers_mask] ++ if other_centers.shape[0] > 0: ++ distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) ++ min_dist_to_neighbor = np.min(distances_to_others) ++ radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less +- w_i = 1.5 if i == 0 else 1.0 ++ w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/main.py new file mode 100644 index 0000000000000000000000000000000000000000..25db6e7c31910f3af00f4e3436bc1c8456f96bf9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/main.py @@ -0,0 +1,265 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2000, initial_learning_rate=0.015): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = True + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 + + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimizer refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + # Fallback if no valid configurations were found + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + # Initialize with the best result from the coarse search + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=2000, + initial_learning_rate=0.015, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.5): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if other_centers.shape[0] > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/original.py new file mode 100644 index 0000000000000000000000000000000000000000..5a8344c65d3a7e7122489488fc507a1d756c51e2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/original.py @@ -0,0 +1,215 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Check if this configuration might be the best so far + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + buffer_factor = 0.05 # Apply force even before contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by searching for optimal initial + configurations and refining each with a dynamic optimizer. + """ + n_circles = 26 + grid_size = 5 + best_sum_radii = -1.0 + best_centers, best_radii = None, None + + # Search space for the grid's boundary parameter + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + # 1. Generate base 25 centers (1 central + 24 on a grid) + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # 2. Generate interstitial candidates for the 26th circle + candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # 3. For each candidate, run the dynamic optimizer + for interstitial_point in candidate_points: + initial_centers_config = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + # Instantiate and run the optimizer for this initial configuration + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers_config, + interstitial_idx=interstitial_idx, + num_steps=2000, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best result found across all runs + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f0c199bc5a3051f4992fec9c318933f92192919f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9002664109167563, + "spatial_uniformity_details": { + "cell_size_mean": 0.20319367687907505, + "cell_size_std": 0.022510264215309616, + "coefficient_of_variation": 0.11078230607502444 + }, + "edge_utilization": 0.8, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 13, + "corner_score": 1.0, + "edge_score": 0.5 + }, + "density_variance": 0.5866962887478102, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0005801750256959895, + "mean_density": 0.03419192391063286, + "cv": 0.7044593926685758 + }, + "packing_efficiency": 0.7374859782474821, + "packing_efficiency_details": { + "total_area": 0.7374859782474821, + "square_area": 1.0, + "efficiency": 0.7374859782474821, + "relative_to_estimated_best": 0.8779594979136691 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.08955446133856726, + "std": 0.031761755916530715, + "min": 0.0003014256069998983, + "max": 0.1628427995253594, + "range": 0.16254137391835952, + "small_count": 5, + "medium_count": 15, + "large_count": 6, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.742, + "gap_analysis_details": { + "covered_samples": 1855, + "total_samples": 2500, + "coverage": 0.742, + "gap_ratio": 0.258 + }, + "geometric_quality": 0.6613439657108249, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6613439657108249, + "min_quality": 0.30276344657827353, + "max_quality": 0.9206428353794938 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..6ede00d2657261e0e8821db733b6658c026e1ba0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 324.59 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3284 + + Auxiliary Metrics: + • spatial_uniformity: 0.900 + • edge_utilization: 0.800 + • density_variance: 0.587 + • packing_efficiency: 0.737 + • radius_distribution: 0.885 + • gap_analysis: 0.742 + • geometric_quality: 0.661 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3284 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.900 + • Boundary and corner utilization: 0.800 + • Area utilization efficiency: 0.737 + • Area coverage (1 - gap ratio): 0.742 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.587 + • Radius size diversity: 0.885 + • Delaunay triangulation quality: 0.661 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..0ab6bd5693eb139f1d78c57d31deb067a9b00c71 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3284159948027487, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1003, 0.0862)\n centers[2] = (0.3001, 0.0995)\n centers[3] = (0.4276, 0.0748)\n centers[4] = (0.7544, 0.0532)\n centers[5] = (0.9017, 0.0989)\n centers[6] = (0.0964, 0.2739)\n centers[7] = (0.2834, 0.2459)\n centers[8] = (0.5993, 0.1210)\n centers[9] = (0.9421, 0.2569)\n centers[10] = (0.0831, 0.4599)\n centers[11] = (0.2477, 0.4924)\n centers[12] = (0.7466, 0.3465)\n centers[13] = (0.9059, 0.5343)\n centers[14] = (0.0003, 0.6983)\n centers[15] = (0.1394, 0.6828)\n centers[16] = (0.3955, 0.6873)\n centers[17] = (0.6764, 0.6640)\n centers[18] = (0.9180, 0.7158)\n centers[19] = (0.0914, 0.9086)\n centers[20] = (0.2901, 0.9003)\n centers[21] = (0.5066, 0.8917)\n centers[22] = (0.7082, 0.9138)\n centers[23] = (0.9006, 0.9006)\n centers[24] = (0.3720, 0.3921)\n centers[25] = (0.5109, 0.3032)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9002664109167563, + "aux_edge_utilization": 0.8, + "aux_density_variance": 0.5866962887478102, + "aux_packing_efficiency": 0.7374859782474821, + "aux_radius_distribution": 0.8854530804755598, + "aux_gap_analysis": 0.742, + "aux_geometric_quality": 0.6613439657108249 + }, + "private": { + "reported_sum_of_radii": 2.3284159948027487 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3284\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.900\n \u2022 Boundary and corner utilization: 0.800\n \u2022 Area utilization efficiency: 0.737\n \u2022 Area coverage (1 - gap ratio): 0.742\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.587\n \u2022 Radius size diversity: 0.885\n \u2022 Delaunay triangulation quality: 0.661\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/results/packing_viz.png", + "execution_time_mean": 324.58603211306036, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..28e43eb41e70692bf06438d00997a46086cbc660 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_131/search_replace.txt @@ -0,0 +1,480 @@ +I apologize for the error in the previous submission. The `SEARCH` block mismatch was likely due to a copy-paste error. I will now re-submit the intended changes with meticulous attention to detail, breaking down the overhaul into multiple, sequential `DIFF` blocks to ensure correctness. + +The core problem with the current code is its oversimplified search strategy. It explores only minor variations of a rigid 5x5 grid with a single interstitial circle, which severely limits its ability to find a dense packing. The score of 2.2523 reflects this limitation. + +My solution is to reinstate a more powerful, two-stage combinatorial search strategy inspired by a previously successful program that achieved a score of 2.33. This strategy explores a much richer set of topologies and parameters. + +The changes are as follows: + +1. **Import `itertools`**: This is necessary for the combinatorial search. +2. **Generalize `DynamicPackingOptimizer`**: I will update the class to accept `interstitial_indices` and a `w_central` weight. The optimization loop is also improved with adaptive radius calculation iterations and more efficient checks for the best configuration. +3. **Generalize Helper Functions**: `_generate_grid_centers` and `_generate_interstitial_candidates` will be updated to handle asymmetric grid boundaries, enabling a more flexible search. +4. **Implement Two-Stage Combinatorial Search**: `construct_packing` will be completely replaced. The new version first performs a broad, coarse search over different grid layouts, central weights, and the placement of **two** interstitial circles. It identifies the top 20 most promising configurations. In the second stage, it runs the full, computationally intensive `DynamicPackingOptimizer` only on this elite subset of candidates. +5. **Improve `compute_max_radii`**: The radius calculation will be updated to handle multiple `interstitial_indices` and `w_central`, using a more robust heuristic that caps the initial interstitial radius based on the distance to its nearest neighbors, preventing suboptimal initial states. + +This strategic overhaul reverts a previous oversimplification and restores a proven, more effective search methodology that is much more likely to find a high-quality packing. + + +reinstate_two_stage_combinatorial_search + + + +The current implementation uses a restrictive single-stage search on a fixed grid topology, resulting in a suboptimal primary score. To fix this, I am reintroducing a more powerful, two-stage combinatorial search that has proven effective in past iterations. + +This involves several coordinated changes: +1. Importing `itertools` to support the combinatorial search logic. +2. Generalizing the `DynamicPackingOptimizer` and `compute_max_radii` functions to handle flexible parameters like multiple interstitial circles (`interstitial_indices`) and a variable central weight (`w_central`). The radius initialization heuristic for interstitial circles is also made more adaptive. +3. Replacing the main `construct_packing` function with a two-stage process: a broad, coarse search to identify a list of top candidate topologies, followed by a fine-grained refinement of only those candidates using the `DynamicPackingOptimizer`. +4. Updating the grid generation helper functions to support the asymmetric and denser search space required by the new constructor. + +This change reverts an unproductive simplification and restores a more sophisticated search mechanism, significantly expanding the solution space to improve the chances of finding a denser packing. + + + +<<<<<<< SEARCH +import numpy as np +======= +import numpy as np +import itertools +>>>>>>> REPLACE +<<<<<<< SEARCH +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Check if this configuration might be the best so far + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + buffer_factor = 0.05 # Apply force even before contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii +======= +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2000, initial_learning_rate=0.015): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = True + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 + + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii +>>>>>>> REPLACE +<<<<<<< SEARCH +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) +======= +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) +>>>>>>> REPLACE +<<<<<<< SEARCH +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) +======= +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) +>>>>>>> REPLACE +<<<<<<< SEARCH +def construct_packing(): + """ + Constructs an arrangement of 26 circles by searching for optimal initial + configurations and refining each with a dynamic optimizer. + """ + n_circles = 26 + grid_size = 5 + best_sum_radii = -1.0 + best_centers, best_radii = None, None + + # Search space for the grid's boundary parameter + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + # 1. Generate base 25 centers (1 central + 24 on a grid) + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + base_centers[1:] = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # 2. Generate interstitial candidates for the 26th circle + candidate_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # 3. For each candidate, run the dynamic optimizer + for interstitial_point in candidate_points: + initial_centers_config = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + # Instantiate and run the optimizer for this initial configuration + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers_config, + interstitial_idx=interstitial_idx, + num_steps=2000, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best result found across all runs + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +======= +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimizer refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + # Fallback if no valid configurations were found + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + # Initialize with the best result from the coarse search + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=2000, + initial_learning_rate=0.015, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +>>>>>>> REPLACE +<<<<<<< SEARCH +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +======= +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.5): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if other_centers.shape[0] > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0fdb59a535808e397b9df036a83cf6adb1c157a1 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..fe38dd047690656eced5f20f9a5d1b472aa8937c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9242253938308607, + "spatial_uniformity_details": { + "cell_size_mean": 0.19994172149083023, + "cell_size_std": 0.016392652030176355, + "coefficient_of_variation": 0.08198715018536543 + }, + "edge_utilization": 0.7538461538461538, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 10, + "corner_score": 1.0, + "edge_score": 0.38461538461538464 + }, + "density_variance": 0.6920938109737996, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00011205729620627986, + "mean_density": 0.023793952952680594, + "cv": 0.4448908285900805 + }, + "packing_efficiency": 0.626161698733688, + "packing_efficiency_details": { + "total_area": 0.626161698733688, + "square_area": 1.0, + "efficiency": 0.626161698733688, + "relative_to_estimated_best": 0.745430593730581 + }, + "radius_distribution": 0.9135702362373822, + "radius_distribution_details": { + "mean": 0.0845333711048771, + "std": 0.022803759362255156, + "min": 0.014832614272651284, + "max": 0.11385548305236347, + "range": 0.09902286877971218, + "small_count": 5, + "medium_count": 14, + "large_count": 7, + "diversity_score": 0.9135702362373822 + }, + "gap_analysis": 0.6284, + "gap_analysis_details": { + "covered_samples": 1571, + "total_samples": 2500, + "coverage": 0.6284, + "gap_ratio": 0.37160000000000004 + }, + "geometric_quality": 0.6708766849570243, + "geometric_quality_details": { + "num_triangles": 39, + "avg_triangle_quality": 0.6708766849570243, + "min_quality": 0.33331644847083597, + "max_quality": 0.8835828183379196 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..a23fb9587ffeefa147df063b58ba94216832f9e1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 207.83 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1979 + + Auxiliary Metrics: + • spatial_uniformity: 0.924 + • edge_utilization: 0.754 + • density_variance: 0.692 + • packing_efficiency: 0.626 + • radius_distribution: 0.914 + • gap_analysis: 0.628 + • geometric_quality: 0.671 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1979 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.924 + • Boundary and corner utilization: 0.754 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.692 + • Area utilization efficiency: 0.626 + • Radius size diversity: 0.914 + • Area coverage (1 - gap ratio): 0.628 + • Delaunay triangulation quality: 0.671 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 37.2% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..2513184fcf1864f6b48204ad8d9f9932c2d79a5b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1978676487268047, + "public": { + "centers_str": " centers[0] = (0.4060, 0.5000)\n centers[1] = (0.5940, 0.5000)\n centers[2] = (0.1000, 0.1000)\n centers[3] = (0.1000, 0.3000)\n centers[4] = (0.1000, 0.5001)\n centers[5] = (0.1000, 0.7000)\n centers[6] = (0.1000, 0.9000)\n centers[7] = (0.3010, 0.1000)\n centers[8] = (0.3000, 0.3000)\n centers[9] = (0.3000, 0.5000)\n centers[10] = (0.3000, 0.7000)\n centers[11] = (0.3000, 0.9000)\n centers[12] = (0.5000, 0.1000)\n centers[13] = (0.5000, 0.3000)\n centers[14] = (0.5000, 0.7000)\n centers[15] = (0.5000, 0.9000)\n centers[16] = (0.6995, 0.0969)\n centers[17] = (0.6957, 0.3031)\n centers[18] = (0.7000, 0.5000)\n centers[19] = (0.6957, 0.6975)\n centers[20] = (0.7000, 0.9024)\n centers[21] = (0.9000, 0.1000)\n centers[22] = (0.9043, 0.3001)\n centers[23] = (0.9000, 0.5004)\n centers[24] = (0.9043, 0.7001)\n centers[25] = (0.9000, 0.9000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9242253938308607, + "aux_edge_utilization": 0.7538461538461538, + "aux_density_variance": 0.6920938109737996, + "aux_packing_efficiency": 0.626161698733688, + "aux_radius_distribution": 0.9135702362373822, + "aux_gap_analysis": 0.6284, + "aux_geometric_quality": 0.6708766849570243 + }, + "private": { + "reported_sum_of_radii": 2.1978676487268047 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1979\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.924\n \u2022 Boundary and corner utilization: 0.754\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.692\n \u2022 Area utilization efficiency: 0.626\n \u2022 Radius size diversity: 0.914\n \u2022 Area coverage (1 - gap ratio): 0.628\n \u2022 Delaunay triangulation quality: 0.671\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 37.2% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_132/results/packing_viz.png", + "execution_time_mean": 207.8274505971931, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8eeecd3715fc1fec50b582b275d07ac0ede4ddc0 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..4ee881c5751feeb2dbf52193020b0834bd2d3bfe --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/edit.diff @@ -0,0 +1,395 @@ +--- a/original.py ++++ b/original.py +@@ -1,234 +1,242 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" ++""" ++Hybrid circle packing for n=26 circles, combining a systematic combinatorial search ++for promising initial configurations with a force-directed dynamic optimizer for refinement. ++""" + + import numpy as np + import itertools + + ++class DynamicPackingOptimizer: ++ """ ++ Optimizes circle packing using a force-directed approach. Starting from an ++ initial configuration, it iteratively adjusts circle centers based on ++ repulsion forces, boundaries, and a central restoring force, while repeatedly ++ calculating maximum radii to guide the optimization. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015): ++ self.n_circles = num_circles ++ self.num_steps = num_steps ++ self.initial_learning_rate = initial_learning_rate ++ self.w_central = w_central ++ self.interstitial_indices = interstitial_indices ++ self.central_idx = 0 ++ ++ self.centers = np.copy(initial_centers) ++ ++ # Initialize best configuration with max radii for the starting layout ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ self.best_sum_radii = np.sum(self.radii) ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(self.radii) ++ ++ def optimize(self): ++ """Runs the force-directed optimization loop.""" ++ for step in range(self.num_steps): ++ # Linearly decay the learning rate ++ learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) ++ learning_rate = max(learning_rate, 1e-7) ++ ++ # Adaptively determine iteration count for radii calculation for speed ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ ++ # Periodically check for improvement with a full, accurate radius calculation ++ if step % 50 == 0 or step == self.num_steps - 1: ++ test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ current_sum_radii = np.sum(test_radii) ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(test_radii) ++ ++ # --- Calculate force vectors for center movement --- ++ force_vectors = np.zeros_like(self.centers) ++ ++ # 1. Repulsion between circles ++ buffer_factor = 0.05 # Apply force even before contact for smoother movement ++ for i in range(self.n_circles): ++ for j in range(i + 1, self.n_circles): ++ dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) ++ target_dist = current_radii[i] + current_radii[j] ++ if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: ++ overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) ++ direction = (self.centers[i] - self.centers[j]) / dist_ij ++ force_vectors[i] += direction * overlap_factor ++ force_vectors[j] -= direction * overlap_factor ++ ++ # 2. Boundary repulsion forces ++ K_boundary = 10.0 # Strong boundary force ++ for i in range(self.n_circles): ++ x, y = self.centers[i] ++ r = current_radii[i] ++ if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) ++ if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) ++ if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) ++ if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) ++ ++ # 3. Restoring force on central circle ++ K_center = 5.0 ++ center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] ++ force_vectors[self.central_idx] += K_center * center_offset ++ ++ # --- Update centers --- ++ self.centers += learning_rate * force_vectors ++ ++ # Clip centers to ensure they stay within radius distance of boundaries ++ for i in range(self.n_circles): ++ r = current_radii[i] ++ self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) ++ self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) ++ ++ return self.best_centers, self.best_radii ++ ++ + def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates centers for a square grid of circles with potentially asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the square grid. +- sc_x (float): The starting x-coordinate for linspace. +- ec_x (float): The ending x-coordinate for linspace. +- sc_y (float): The starting y-coordinate for linspace. +- ec_y (float): The ending y-coordinate for linspace. +- +- Returns: +- np.array: An array of (x, y) coordinates for the grid centers. +- """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates potential interstitial points within the grid formed by _generate_grid_centers, +- with potentially asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the base grid. +- sc_x (float): The starting x-coordinate of the grid. +- ec_x (float): The ending x-coordinate of the grid. +- sc_y (float): The starting y-coordinate of the grid. +- ec_y (float): The ending y-coordinate of the grid. +- +- Returns: +- np.array: An array of (x, y) coordinates for the candidate interstitial centers. +- """ +- if grid_size < 2: +- return np.array([]) +- ++ if grid_size < 2: return np.array([]) + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) +- + candidates = [] +- # Interstitial points are halfway between grid points +- for i in range(grid_size - 1): # y-indices +- for j in range(grid_size - 1): # x-indices +- interstitial_x = sc_x + j * step_x + step_x / 2 +- interstitial_y = sc_y + i * step_y + step_y / 2 +- candidates.append([interstitial_x, interstitial_y]) ++ for i in range(grid_size - 1): ++ for j in range(grid_size - 1): ++ candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): +- """ +- Compute maximum radii using an iterative relaxation approach. Includes a +- heuristic for interstitial circles and weighted scaling for the central one. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates. +- max_iterations: Maximum iterations for the relaxation process. +- tolerance: Convergence tolerance. +- interstitial_indices: A list of indices for interstitial circles to apply +- an adaptive initial radius heuristic. Defaults to None. +- w_central (float): Weight factor for the central circle during overlap resolution. +- +- Returns: +- np.array: Array of radii for each circle. +- """ + n = centers.shape[0] + radii = np.zeros(n) +- +- # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: +- if idx < n: # Ensure index is valid ++ if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + +- # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) +- + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) +- + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist +- +- # Weighted proportional scaling to protect the central circle (at index 0). + w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 # Other circles have normal weight +- ++ w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j +- + total_weighted_radii = weighted_r_i + weighted_r_j +- +- if total_weighted_radii > 1e-12: # Avoid division by zero ++ if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- else: +- scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 +- radii[i] *= scale_factor +- radii[j] *= scale_factor +- +- # Ensure no radii become negative + radii[radii < 0] = 0 +- + if np.allclose(radii, prev_radii, atol=tolerance): + break +- + return radii + + + def construct_packing(): + """ +- Constructs a packing for 26 circles by performing a combinatorial search +- over grid parameters, peripheral circle selections, interstitial circle selections, +- and central circle weighting. This reinstates a previously successful strategy. +- +- It places: +- - 1 fixed central circle. +- - 23 peripheral circles, chosen from 24 available grid points. +- - 2 interstitial circles, chosen from 16 available candidates. +- +- Returns: +- Tuple of (centers, radii) for the best found packing. ++ Constructs an arrangement of 26 circles using a two-stage process: ++ 1. A broad combinatorial search finds promising initial topologies. ++ 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 +- +- # Ranges for optimizing grid boundaries and central weight. +- # Reverting to asymmetric search space as in G97, which performed better. +- sc_options_x = np.array([0.09, 0.1, 0.11]) +- ec_options_x = np.array([0.89, 0.9, 0.91]) +- sc_options_y = np.array([0.09, 0.1, 0.11]) +- ec_options_y = np.array([0.89, 0.9, 0.91]) +- central_weight_options = np.array([1.5, 2.0]) # Reverting to G97 values +- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None ++ sc_options = np.array([0.09, 0.1, 0.11]) ++ central_weight_options = np.linspace(1.5, 2.5, 3) ++ ++ TOP_N_CANDIDATES = 10 ++ top_candidates = [] + + num_fixed_central = 1 +- num_peripheral_to_select = 23 ++ num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + +- # Indices of interstitial circles in the final array of centers + interstitial_circle_indices = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + ++ # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: +- for sc_x in sc_options_x: +- for ec_x in ec_options_x: +- # Ensure end_coord is strictly greater than start_coord for valid linspace +- if ec_x <= sc_x: +- continue +- # Ensure the x-dimension grid's center aligns with 0.5 +- if not np.isclose((sc_x + ec_x) / 2.0, 0.5): +- continue +- +- for sc_y in sc_options_y: +- for ec_y in ec_options_y: +- # Ensure end_coord is strictly greater than start_coord for valid linspace +- if ec_y <= sc_y: +- continue +- # Ensure the y-dimension grid's center aligns with 0.5 +- if not np.isclose((sc_y + ec_y) / 2.0, 0.5): +- continue +- +- all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) +- +- central_point = np.array([0.5, 0.5]) +- +- peripheral_grid_points = [] +- for center in all_grid_centers: +- if not np.allclose(center, central_point): +- peripheral_grid_points.append(center) +- peripheral_grid_points = np.array(peripheral_grid_points) +- +- for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral = peripheral_grid_points[list(p_indices)] +- +- for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial = all_interstitial_candidates[list(i_indices)] +- +- centers_list = [central_point] + list(selected_peripheral) + list(selected_interstitial) +- current_centers = np.array(centers_list) +- +- current_radii = compute_max_radii( +- current_centers, +- interstitial_indices=interstitial_circle_indices, +- w_central=w_central +- ) +- current_sum_radii = np.sum(current_radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii ++ for sc in sc_options: ++ ec = 1.0 - sc ++ ++ all_grid_centers = _generate_grid_centers(grid_size, sc, ec, sc, ec) ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec, sc, ec) ++ ++ central_point = np.array([0.5, 0.5]) ++ peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) ++ ++ for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): ++ selected_peripheral = peripheral_grid_points[list(p_indices)] ++ for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): ++ selected_interstitial = all_interstitial_candidates[list(i_indices)] ++ current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) ++ ++ coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=interstitial_circle_indices, w_central=w_central) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ if len(top_candidates) < TOP_N_CANDIDATES: ++ top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ elif coarse_sum_radii > top_candidates[-1][0]: ++ top_candidates.pop() ++ top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ ++ # STAGE 2: Refine Top Candidates with Dynamic Optimizer ++ if not top_candidates: ++ return np.random.rand(n_circles, 2), np.zeros(n_circles) ++ ++ best_sum_radii = 0.0 ++ best_centers = None ++ best_radii = None ++ ++ # Initialize with the best candidate from Stage 1 ++ best_sum_radii = top_candidates[0][0] ++ best_centers = top_candidates[0][1] ++ best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) ++ ++ for _, initial_centers, w_central in top_candidates: ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=initial_centers, ++ interstitial_indices=interstitial_circle_indices, ++ w_central=w_central ++ ) ++ optimized_centers, optimized_radii = optimizer.optimize() ++ current_sum_radii = np.sum(optimized_radii) ++ ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = optimized_centers ++ best_radii = optimized_radii + + return best_centers, best_radii +- + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/main.py new file mode 100644 index 0000000000000000000000000000000000000000..e7c09466666de29e21d9e6d4506a3242b70e7097 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/main.py @@ -0,0 +1,242 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic combinatorial search +for promising initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces, boundaries, and a central restoring force, while repeatedly + calculating maximum radii to guide the optimization. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.interstitial_indices = interstitial_indices + self.central_idx = 0 + + self.centers = np.copy(initial_centers) + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation for speed + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Restoring force on central circle + K_center = 5.0 + center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * center_offset + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + if grid_size < 2: return np.array([]) + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + central_weight_options = np.linspace(1.5, 2.5, 3) + + TOP_N_CANDIDATES = 10 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc in sc_options: + ec = 1.0 - sc + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec, sc, ec) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices)] + for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(i_indices)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=interstitial_circle_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = 0.0 + best_centers = None + best_radii = None + + # Initialize with the best candidate from Stage 1 + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/original.py new file mode 100644 index 0000000000000000000000000000000000000000..d760ef38038c9f2722747bd0b569db401bb6bb1c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/original.py @@ -0,0 +1,234 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with potentially asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + sc_x (float): The starting x-coordinate for linspace. + ec_x (float): The ending x-coordinate for linspace. + sc_y (float): The starting y-coordinate for linspace. + ec_y (float): The ending y-coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers, + with potentially asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + sc_x (float): The starting x-coordinate of the grid. + ec_x (float): The ending x-coordinate of the grid. + sc_y (float): The starting y-coordinate of the grid. + ec_y (float): The ending y-coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Constructs a packing for 26 circles by performing a combinatorial search + over grid parameters, peripheral circle selections, interstitial circle selections, + and central circle weighting. This reinstates a previously successful strategy. + + It places: + - 1 fixed central circle. + - 23 peripheral circles, chosen from 24 available grid points. + - 2 interstitial circles, chosen from 16 available candidates. + + Returns: + Tuple of (centers, radii) for the best found packing. + """ + n_circles = 26 + grid_size = 5 + + # Ranges for optimizing grid boundaries and central weight. + # Reverting to asymmetric search space as in G97, which performed better. + sc_options_x = np.array([0.09, 0.1, 0.11]) + ec_options_x = np.array([0.89, 0.9, 0.91]) + sc_options_y = np.array([0.09, 0.1, 0.11]) + ec_options_y = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.array([1.5, 2.0]) # Reverting to G97 values + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = 23 + num_interstitial_to_select = 2 + + # Indices of interstitial circles in the final array of centers + interstitial_circle_indices = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + for w_central in central_weight_options: + for sc_x in sc_options_x: + for ec_x in ec_options_x: + # Ensure end_coord is strictly greater than start_coord for valid linspace + if ec_x <= sc_x: + continue + # Ensure the x-dimension grid's center aligns with 0.5 + if not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + + for sc_y in sc_options_y: + for ec_y in ec_options_y: + # Ensure end_coord is strictly greater than start_coord for valid linspace + if ec_y <= sc_y: + continue + # Ensure the y-dimension grid's center aligns with 0.5 + if not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) + + for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices)] + + for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(i_indices)] + + centers_list = [central_point] + list(selected_peripheral) + list(selected_interstitial) + current_centers = np.array(centers_list) + + current_radii = compute_max_radii( + current_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central + ) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..0d83110d32e896386f4fac3e61273a9d427cdee8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8754089319041515, + "spatial_uniformity_details": { + "cell_size_mean": 0.19900416679498745, + "cell_size_std": 0.028322925340928187, + "coefficient_of_variation": 0.14232327721953164 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.5453971406207829, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0006517428624067812, + "mean_density": 0.03062801289935764, + "cv": 0.8335262976659139 + }, + "packing_efficiency": 0.6986933420785711, + "packing_efficiency_details": { + "total_area": 0.6986933420785711, + "square_area": 1.0, + "efficiency": 0.6986933420785711, + "relative_to_estimated_best": 0.8317777881887752 + }, + "radius_distribution": 0.8956403029078803, + "radius_distribution_details": { + "mean": 0.08783763130882884, + "std": 0.028955743333452896, + "min": 0.03103837820097783, + "max": 0.1680084694217926, + "range": 0.13697009122081477, + "small_count": 8, + "medium_count": 14, + "large_count": 4, + "diversity_score": 0.8956403029078803 + }, + "gap_analysis": 0.7012, + "gap_analysis_details": { + "covered_samples": 1753, + "total_samples": 2500, + "coverage": 0.7012, + "gap_ratio": 0.29879999999999995 + }, + "geometric_quality": 0.6869686524190703, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6869686524190703, + "min_quality": 0.3144593384331082, + "max_quality": 0.9773489256744429 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..7c5343f7aca6ca8574a0bfeb9523293f75f0646a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 136.78 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2838 + + Auxiliary Metrics: + • spatial_uniformity: 0.875 + • edge_utilization: 0.723 + • density_variance: 0.545 + • packing_efficiency: 0.699 + • radius_distribution: 0.896 + • gap_analysis: 0.701 + • geometric_quality: 0.687 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2838 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.875 + • Boundary and corner utilization: 0.723 + • Area coverage (1 - gap ratio): 0.701 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.545 + • Area utilization efficiency: 0.699 + • Radius size diversity: 0.896 + • Delaunay triangulation quality: 0.687 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..7d66e2721ef55446a8fc822b0c07a523acf87936 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2837784140295496, + "public": { + "centers_str": " centers[0] = (0.4954, 0.4990)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5001, 0.0985)\n centers[4] = (0.6896, 0.0983)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.2954, 0.2954)\n centers[8] = (0.4921, 0.2685)\n centers[9] = (0.9445, 0.2934)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.2839, 0.5001)\n centers[12] = (0.7380, 0.3224)\n centers[13] = (0.9069, 0.5093)\n centers[14] = (0.0464, 0.6920)\n centers[15] = (0.1736, 0.7147)\n centers[16] = (0.3858, 0.6816)\n centers[17] = (0.6694, 0.6382)\n centers[18] = (0.9143, 0.7101)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.2992, 0.9010)\n centers[21] = (0.5038, 0.8942)\n centers[22] = (0.7062, 0.9034)\n centers[23] = (0.9014, 0.9014)\n centers[24] = (0.4049, 0.4082)\n centers[25] = (0.5521, 0.4113)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8754089319041515, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.5453971406207829, + "aux_packing_efficiency": 0.6986933420785711, + "aux_radius_distribution": 0.8956403029078803, + "aux_gap_analysis": 0.7012, + "aux_geometric_quality": 0.6869686524190703 + }, + "private": { + "reported_sum_of_radii": 2.2837784140295496 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2838\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.875\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Area coverage (1 - gap ratio): 0.701\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.545\n \u2022 Area utilization efficiency: 0.699\n \u2022 Radius size diversity: 0.896\n \u2022 Delaunay triangulation quality: 0.687\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/results/packing_viz.png", + "execution_time_mean": 136.7790869786404, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..d1dfd2b54520c2e8504e17a2dc2f70394d0d1bec --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_133/rewrite.txt @@ -0,0 +1,233 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic combinatorial search +for promising initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces, boundaries, and a central restoring force, while repeatedly + calculating maximum radii to guide the optimization. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.interstitial_indices = interstitial_indices + self.central_idx = 0 + + self.centers = np.copy(initial_centers) + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation for speed + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Restoring force on central circle + K_center = 5.0 + center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * center_offset + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + if grid_size < 2: return np.array([]) + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + central_weight_options = np.linspace(1.5, 2.5, 3) + + TOP_N_CANDIDATES = 10 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc in sc_options: + ec = 1.0 - sc + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec, sc, ec) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices)] + for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(i_indices)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=interstitial_circle_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = 0.0 + best_centers = None + best_radii = None + + # Initialize with the best candidate from Stage 1 + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ee02431a6a745d59b69f09c16c87f8501fa4893c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..65ac8d858d9e7dd0f8089c04dd78e830fbe39a55 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/edit.diff @@ -0,0 +1,299 @@ +--- a/original.py ++++ b/original.py +@@ -1,262 +1,223 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + class DynamicPackingOptimizer: + """ +- Optimizes circle packing using a force-directed approach with iterative radius maximization. +- This class manages the iterative adjustments of circle centers based on +- repulsion forces and boundaries, while repeatedly calculating maximum radii +- for the current center configuration. +- """ +- def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): ++ Optimizes circle packing using a force-directed approach. A soft restoring force ++ guides the central circle, allowing global relaxation. ++ """ ++ def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate +- self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx +- self.central_idx = 0 # The central circle is always at index 0 in our setup +- +- # Initialize best configuration with max radii for the starting configuration ++ self.central_idx = 0 # The central circle is at index 0 ++ + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): ++ """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): +- # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) +- if learning_rate < 1e-7: +- learning_rate = 1e-7 +- +- # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. +- # More iterations are used towards the end of the simulation. +- radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 ++ learning_rate = max(learning_rate, 1e-7) ++ ++ # Use more iterations for more stable force calculation (from inspiration code) ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + +- # Check if this configuration is the best so far (using full radii calculation) +- # We re-evaluate with full iterations only if it potentially improves the current best + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations +- +- # Calculate force vectors for center movement ++ self.best_radii = np.copy(test_radii_for_sum) ++ + force_vectors = np.zeros_like(self.centers) + +- # Repulsion between circles +- # Forces are applied if circles are very close or overlapping slightly, to push them apart ++ # 1. Repulsion between circles ++ buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + +- # Apply force if distance is less than target_dist * (1 + buffer_factor) +- buffer_factor = 0.05 # Allows forces to act even before full contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: +- # Force magnitude is proportional to how much they 'want' to separate + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij +- + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + +- # Boundary repulsion forces +- K_boundary = 10.0 # Stronger boundary force to keep circles inside effectively ++ # 2. Boundary repulsion forces ++ K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] +- r = current_radii[i] # Use the radii from this iteration for boundary checks +- +- # If a circle is closer to a boundary than its radius, apply repulsive force ++ r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + +- # Update centers based on calculated forces ++ # 3. Central restoring force (from inspiration code) ++ K_center = 5.0 ++ force_vectors[self.central_idx] += K_center * (np.array([0.5, 0.5]) - self.centers[self.central_idx]) ++ ++ # Update centers + self.centers += learning_rate * force_vectors + +- # Fix the central circle if specified, ensuring it remains at (0.5, 0.5) +- if self.central_fixed: +- self.centers[self.central_idx] = np.array([0.5, 0.5]) +- +- # Clip centers to ensure the circles remain entirely within the unit square +- # This is crucial: a circle's center cannot be closer to a boundary than its radius. ++ # Clip centers to ensure circles remain within the unit square + for i in range(self.n_circles): +- r = current_radii[i] # Use the radii from this iteration for clipping ++ r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + + def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + +- # Search space for the grid's start coordinate. This parameter controls +- # how far the outer grid circles are from the boundary, directly influencing +- # edge utilization and overall packing density. +- # The range is from 0.08 to 0.12, with 5 points. + start_coord_search_space = np.linspace(0.08, 0.12, 5) + +- # --- Main Search Loop --- + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + +- # 1. Generate base centers for 25 circles (24 grid + 1 central). +- # The central circle is placed at index 0 for prioritized relaxation. + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) +- +- # Find the index of the center point to separate it. + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + +- # Prepare the base 25 centers (central at index 0, others follow) + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + +- # 2. Generate interstitial candidates for the current grid configuration. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) + +- # 3. For each candidate interstitial point, run the dynamic optimizer. + for interstitial_point in candidate_interstitial_points: + initial_centers_for_optimizer = np.vstack([base_centers, interstitial_point]) +- interstitial_idx = n_circles - 1 # The interstitial circle is always the last one added +- +- # Initialize and run the dynamic packing optimizer ++ interstitial_idx = n_circles - 1 ++ ++ # Initialize and run the dynamic packing optimizer with increased steps and no fixed center + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers_for_optimizer, + interstitial_idx=interstitial_idx, + num_circles=n_circles, +- num_steps=2000, +- initial_learning_rate=0.015, +- central_fixed=True) ++ num_steps=2500, # Increased steps ++ initial_learning_rate=0.015) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + +- # 4. Keep track of the best configuration found. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + +- # Initialize radii based on distance to boundaries + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Cap the initial radius of the interstitial circle. +- # This prevents it from growing too large initially and sub-optimally +- # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + +- +- # Iteratively resolve overlaps and expand radii + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist +- +- # Weighted proportional scaling: The central circle (index 0) is more +- # resistant to shrinking, allowing it to grow larger. ++ + w_i = 1.5 if i == 0 else 1.0 +- w_j = 1.0 # For simplicity, all other circles have weight 1.0 ++ w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + +- if total_weighted_radii > 1e-12: # Avoid division by zero for tiny radii ++ if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling ++ elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + +- # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/main.py new file mode 100644 index 0000000000000000000000000000000000000000..0aa31c0d4e9de1dbe3c8e4bcd86e4ec78803b1ec --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/main.py @@ -0,0 +1,223 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. A soft restoring force + guides the central circle, allowing global relaxation. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is at index 0 + + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Use more iterations for more stable force calculation (from inspiration code) + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Central restoring force (from inspiration code) + K_center = 5.0 + force_vectors[self.central_idx] += K_center * (np.array([0.5, 0.5]) - self.centers[self.central_idx]) + + # Update centers + self.centers += learning_rate * force_vectors + + # Clip centers to ensure circles remain within the unit square + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) + + for interstitial_point in candidate_interstitial_points: + initial_centers_for_optimizer = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + # Initialize and run the dynamic packing optimizer with increased steps and no fixed center + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers_for_optimizer, + interstitial_idx=interstitial_idx, + num_circles=n_circles, + num_steps=2500, # Increased steps + initial_learning_rate=0.015) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/original.py new file mode 100644 index 0000000000000000000000000000000000000000..ff84f132a5d371a975c1050ed566d6cbcb6c6df6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/original.py @@ -0,0 +1,262 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This class manages the iterative adjustments of circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + for the current center configuration. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is always at index 0 in our setup + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. + # More iterations are used towards the end of the simulation. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Check if this configuration is the best so far (using full radii calculation) + # We re-evaluate with full iterations only if it potentially improves the current best + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + # Forces are applied if circles are very close or overlapping slightly, to push them apart + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + # Apply force if distance is less than target_dist * (1 + buffer_factor) + buffer_factor = 0.05 # Allows forces to act even before full contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + # Force magnitude is proportional to how much they 'want' to separate + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + K_boundary = 10.0 # Stronger boundary force to keep circles inside effectively + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] # Use the radii from this iteration for boundary checks + + # If a circle is closer to a boundary than its radius, apply repulsive force + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + + # Fix the central circle if specified, ensuring it remains at (0.5, 0.5) + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure the circles remain entirely within the unit square + # This is crucial: a circle's center cannot be closer to a boundary than its radius. + for i in range(self.n_circles): + r = current_radii[i] # Use the radii from this iteration for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Search space for the grid's start coordinate. This parameter controls + # how far the outer grid circles are from the boundary, directly influencing + # edge utilization and overall packing density. + # The range is from 0.08 to 0.12, with 5 points. + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + # --- Main Search Loop --- + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + + # 1. Generate base centers for 25 circles (24 grid + 1 central). + # The central circle is placed at index 0 for prioritized relaxation. + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + + # Find the index of the center point to separate it. + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + # Prepare the base 25 centers (central at index 0, others follow) + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the current grid configuration. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) + + # 3. For each candidate interstitial point, run the dynamic optimizer. + for interstitial_point in candidate_interstitial_points: + initial_centers_for_optimizer = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 # The interstitial circle is always the last one added + + # Initialize and run the dynamic packing optimizer + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers_for_optimizer, + interstitial_idx=interstitial_idx, + num_circles=n_circles, + num_steps=2000, + initial_learning_rate=0.015, + central_fixed=True) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best configuration found. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # Initialize radii based on distance to boundaries + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # Iteratively resolve overlaps and expand radii + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # For simplicity, all other circles have weight 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero for tiny radii + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..af5936f3d8861c9daf971ebdf1b09003ee58718c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8497367230059858, + "spatial_uniformity_details": { + "cell_size_mean": 0.19702320314299612, + "cell_size_std": 0.034840617684094924, + "coefficient_of_variation": 0.1768350983613493 + }, + "edge_utilization": 0.6346153846153846, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 12, + "corner_score": 0.75, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5790937708300904, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0008241472516786544, + "mean_density": 0.03949716612349767, + "cv": 0.7268360503456459 + }, + "packing_efficiency": 0.7580236524882682, + "packing_efficiency_details": { + "total_area": 0.7580236524882682, + "square_area": 1.0, + "efficiency": 0.7580236524882682, + "relative_to_estimated_best": 0.9024091101050812 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08789325241541132, + "std": 0.03943378248309363, + "min": 0.003754741793781901, + "max": 0.16719285897209385, + "range": 0.16343811717831194, + "small_count": 9, + "medium_count": 11, + "large_count": 6, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.7668, + "gap_analysis_details": { + "covered_samples": 1917, + "total_samples": 2500, + "coverage": 0.7668, + "gap_ratio": 0.23319999999999996 + }, + "geometric_quality": 0.6654421989271546, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6654421989271546, + "min_quality": 0.3133764334102639, + "max_quality": 0.9102767403796231 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..59f54ea103d7960be67f44a32afab9c027912406 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 1145.47 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2852 + + Auxiliary Metrics: + • spatial_uniformity: 0.850 + • edge_utilization: 0.635 + • density_variance: 0.579 + • packing_efficiency: 0.758 + • radius_distribution: 0.974 + • gap_analysis: 0.767 + • geometric_quality: 0.665 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2852 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.850 + • Area utilization efficiency: 0.758 + • Area coverage (1 - gap ratio): 0.767 + +📊 Other Metrics: + • Boundary and corner utilization: 0.635 + • Spatial density uniformity across grid: 0.579 + • Radius size diversity: 0.974 + • Delaunay triangulation quality: 0.665 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..8bb04644baaa81f57a6d09c0f498bc1e568639fd --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2852245628006944, + "public": { + "centers_str": " centers[0] = (0.4988, 0.4987)\n centers[1] = (0.1008, 0.1043)\n centers[2] = (0.0930, 0.3044)\n centers[3] = (0.0749, 0.4216)\n centers[4] = (0.0648, 0.7562)\n centers[5] = (0.0878, 0.9122)\n centers[6] = (0.2722, 0.0333)\n centers[7] = (0.1814, 0.4183)\n centers[8] = (0.3016, 0.4841)\n centers[9] = (0.1139, 0.5803)\n centers[10] = (0.2784, 0.9054)\n centers[11] = (0.5313, 0.0931)\n centers[12] = (0.3116, 0.2349)\n centers[13] = (0.3429, 0.6824)\n centers[14] = (0.4892, 0.8940)\n centers[15] = (0.6645, 0.0038)\n centers[16] = (0.7322, 0.1034)\n centers[17] = (0.6137, 0.3340)\n centers[18] = (0.6414, 0.6511)\n centers[19] = (0.6963, 0.9080)\n centers[20] = (0.9182, 0.0818)\n centers[21] = (0.8826, 0.2799)\n centers[22] = (0.9018, 0.4983)\n centers[23] = (0.9030, 0.6969)\n centers[24] = (0.8978, 0.8978)\n centers[25] = (0.1824, 0.7812)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8497367230059858, + "aux_edge_utilization": 0.6346153846153846, + "aux_density_variance": 0.5790937708300904, + "aux_packing_efficiency": 0.7580236524882682, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.7668, + "aux_geometric_quality": 0.6654421989271546 + }, + "private": { + "reported_sum_of_radii": 2.2852245628006944 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2852\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.850\n \u2022 Area utilization efficiency: 0.758\n \u2022 Area coverage (1 - gap ratio): 0.767\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.635\n \u2022 Spatial density uniformity across grid: 0.579\n \u2022 Radius size diversity: 0.974\n \u2022 Delaunay triangulation quality: 0.665\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/results/packing_viz.png", + "execution_time_mean": 1145.4717502789572, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..c9000d59618ee49fd41c0c59b7c8953e5f4b9f2c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_134/rewrite.txt @@ -0,0 +1,214 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. A soft restoring force + guides the central circle, allowing global relaxation. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is at index 0 + + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Use more iterations for more stable force calculation (from inspiration code) + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Central restoring force (from inspiration code) + K_center = 5.0 + force_vectors[self.central_idx] += K_center * (np.array([0.5, 0.5]) - self.centers[self.central_idx]) + + # Update centers + self.centers += learning_rate * force_vectors + + # Clip centers to ensure circles remain within the unit square + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) + + for interstitial_point in candidate_interstitial_points: + initial_centers_for_optimizer = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + # Initialize and run the dynamic packing optimizer with increased steps and no fixed center + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers_for_optimizer, + interstitial_idx=interstitial_idx, + num_circles=n_circles, + num_steps=2500, # Increased steps + initial_learning_rate=0.015) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..15ee648aa0264dd02242ba0fa9c34c9e5359d3d2 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..307e74e116f077c9819a6356b3c65424a5e72b6c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/edit.diff @@ -0,0 +1,459 @@ +--- a/original.py ++++ b/original.py +@@ -1,290 +1,240 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" +- + import numpy as np + import itertools + +- + def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates centers for a square grid of circles with asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the square grid. +- sc_x (float): The starting x-coordinate for linspace. +- ec_x (float): The ending x-coordinate for linspace. +- sc_y (float): The starting y-coordinate for linspace. +- ec_y (float): The ending y-coordinate for linspace. +- +- Returns: +- np.array: An array of (x, y) coordinates for the grid centers. +- """ ++ """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + +- +-def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2): +- """ +- Generates potential interstitial points within the grid formed by _generate_grid_centers, +- with asymmetric bounds and higher density. +- +- Args: +- grid_size (int): The number of circles along one dimension of the base grid. +- sc_x (float): The starting x-coordinate of the grid. +- ec_x (float): The ending x-coordinate of the grid. +- sc_y (float): The starting y-coordinate of the grid. +- ec_y (float): The ending y-coordinate of the grid. +- density_factor (int): Factor to increase the density of interstitial candidates. +- e.g., 2 means each original grid cell is divided into 4. +- +- Returns: +- np.array: An array of (x, y) coordinates for the candidate interstitial centers. +- """ ++def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): ++ """Generates potential interstitial points with asymmetric bounds and variable density.""" + if grid_size < 2: + return np.array([]) +- +- # Number of interstitial intervals along each dimension, increased by density_factor + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor +- + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y +- + candidates = [] +- # Interstitial points are halfway between conceptual grid points +- for i in range(num_interstitial_intervals_y): # y-indices +- for j in range(num_interstitial_intervals_x): # x-indices +- interstitial_x = sc_x + j * step_x + step_x / 2 +- interstitial_y = sc_y + i * step_y + step_y / 2 +- candidates.append([interstitial_x, interstitial_y]) ++ for i in range(num_interstitial_intervals_y): ++ for j in range(num_interstitial_intervals_x): ++ candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + +- + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): +- """ +- Compute maximum radii using an iterative relaxation approach. Includes a +- heuristic for interstitial circles and weighted scaling for the central one. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates. +- max_iterations: Maximum iterations for the relaxation process. +- tolerance: Convergence tolerance. +- interstitial_indices: A list of indices for interstitial circles to apply +- an adaptive initial radius heuristic. Defaults to None. +- w_central (float): Weight factor for the central circle during overlap resolution. +- +- Returns: +- np.array: Array of radii for each circle. +- """ ++ """Computes maximum radii for a fixed set of centers using iterative relaxation.""" + n = centers.shape[0] + radii = np.zeros(n) + +- # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). +- # This prevents them from growing too large initially and sub-optimally +- # squeezing their neighbors, allowing for a better overall packing. + if interstitial_indices: + for idx in interstitial_indices: +- if idx < n: # Ensure index is valid ++ if idx < n: + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] +- + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + +- # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) +- + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) +- + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist +- +- # Weighted proportional scaling to protect the central circle (at index 0). +- # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. +- # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 # Other circles have normal weight (j is always > i, so j is never the first circle if i=0) +- ++ w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j +- + total_weighted_radii = weighted_r_i + weighted_r_j +- +- if total_weighted_radii > 1e-12: # Avoid division by zero ++ if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- else: +- # Fallback for extremely tiny radii sums (should be rare) +- # Just scale down proportionally to prevent infinite loop or negative radii +- scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 ++ elif (radii[i] + radii[j]) > 1e-12: ++ scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor +- +- # Ensure no radii become negative + radii[radii < 0] = 0 +- + if np.allclose(radii, prev_radii, atol=tolerance): + break +- + return radii ++ ++ ++class PackingSolver: ++ """Encapsulates the two-stage pipeline for solving the circle packing problem.""" ++ ++ def __init__(self, n_circles=26, grid_size=5): ++ self.n_circles = n_circles ++ self.grid_size = grid_size ++ self.best_sum_radii = -1.0 ++ self.best_centers = None ++ self.best_radii = None ++ self.top_candidates = [] ++ ++ # --- Hyperparameters --- ++ self.sc_options = np.array([0.09, 0.1, 0.11]) ++ self.ec_options = np.array([0.89, 0.9, 0.91]) ++ self.central_weight_options = np.linspace(1.2, 2.2, 3) ++ self.TOP_N_CANDIDATES = 15 ++ self.NUM_PERIPHERAL = self.n_circles - 1 - 2 # 23 ++ self.NUM_INTERSTITIAL = 2 ++ self.interstitial_indices = list(range(1 + self.NUM_PERIPHERAL, self.n_circles)) ++ ++ ++ def _generate_and_select_candidates(self): ++ """Stage 1: Coarse combinatorial search for promising initial topologies.""" ++ for w_central in self.central_weight_options: ++ for sc in self.sc_options: ++ ec = 1.0 - sc # Enforce symmetry for grid generation ++ ++ all_grid_centers = _generate_grid_centers(self.grid_size, sc, ec, sc, ec) ++ all_interstitial_candidates = _generate_interstitial_candidates(self.grid_size, sc, ec, sc, ec, density_factor=1) ++ ++ central_point = np.array([0.5, 0.5]) ++ peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) ++ ++ if len(peripheral_grid_points) < self.NUM_PERIPHERAL: continue ++ ++ for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.NUM_PERIPHERAL): ++ selected_peripheral = peripheral_grid_points[list(p_indices_combo)] ++ ++ for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), self.NUM_INTERSTITIAL): ++ selected_interstitial = all_interstitial_candidates[list(i_indices_combo)] ++ current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) ++ ++ coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=self.interstitial_indices, w_central=w_central) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ if len(self.top_candidates) < self.TOP_N_CANDIDATES: ++ self.top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ self.top_candidates.sort(key=lambda x: x[0], reverse=True) ++ elif coarse_sum_radii > self.top_candidates[-1][0]: ++ self.top_candidates.pop() ++ self.top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ self.top_candidates.sort(key=lambda x: x[0], reverse=True) ++ ++ def _refine_with_dynamics(self, initial_centers, w_central): ++ """Stage 2: Refine a single candidate using force-directed optimization.""" ++ centers = np.copy(initial_centers) ++ ++ best_cfg_radii = compute_max_radii(centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=w_central) ++ best_cfg_sum_radii = np.sum(best_cfg_radii) ++ best_cfg_centers = np.copy(centers) ++ ++ # Multi-stage optimization parameters ++ stages = [ ++ {'steps': 800, 'lr': 0.02, 'buffer': 0.1, 'jiggle_freq': 100, 'jiggle_mag': 0.005}, ++ {'steps': 800, 'lr': 0.005, 'buffer': 0.05, 'jiggle_freq': 200, 'jiggle_mag': 0.001}, ++ {'steps': 400, 'lr': 0.001, 'buffer': 0.01, 'jiggle_freq': 0, 'jiggle_mag': 0}, ++ ] ++ ++ total_steps_done = 0 ++ for stage in stages: ++ for step in range(stage['steps']): ++ lr = stage['lr'] * (1 - step / stage['steps']) ++ ++ # Jiggle non-central circles to escape local optima ++ if stage['jiggle_freq'] > 0 and step % stage['jiggle_freq'] == 0: ++ jiggle_vec = (np.random.rand(self.n_circles - 1, 2) - 0.5) * stage['jiggle_mag'] ++ centers[1:] += jiggle_vec ++ ++ radii_iter_count = 50 if total_steps_done < 1600 else 200 ++ current_radii = compute_max_radii(centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=w_central) ++ ++ force_vectors = np.zeros_like(centers) ++ # Repulsion forces ++ for i in range(self.n_circles): ++ for j in range(i + 1, self.n_circles): ++ dist_ij = np.linalg.norm(centers[i] - centers[j]) ++ target_dist = current_radii[i] + current_radii[j] ++ if dist_ij < target_dist * (1 + stage['buffer']) and dist_ij > 1e-9: ++ overlap = (target_dist * (1 + stage['buffer']) - dist_ij) ++ direction = (centers[i] - centers[j]) / dist_ij ++ force_vectors[i] += direction * overlap ++ force_vectors[j] -= direction * overlap ++ ++ # Boundary forces ++ K_boundary = 10.0 ++ for i in range(self.n_circles): ++ x, y = centers[i]; r = current_radii[i] ++ if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) ++ if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) ++ if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) ++ if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) ++ ++ # Apply forces (central circle is fixed) ++ centers[1:] += lr * force_vectors[1:] ++ ++ # Clip to bounds ++ for i in range(self.n_circles): ++ r = current_radii[i] ++ centers[i] = np.clip(centers[i], r, 1.0 - r) ++ ++ # Update best config found during this refinement ++ if total_steps_done % 50 == 0: ++ test_radii = compute_max_radii(centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=w_central) ++ current_sum_radii = np.sum(test_radii) ++ if current_sum_radii > best_cfg_sum_radii: ++ best_cfg_sum_radii = current_sum_radii ++ best_cfg_centers = np.copy(centers) ++ best_cfg_radii = test_radii ++ total_steps_done += 1 ++ ++ return best_cfg_centers, best_cfg_radii ++ ++ def solve(self): ++ """Orchestrates the pipeline to find the best packing.""" ++ self._generate_and_select_candidates() ++ ++ if not self.top_candidates: ++ return np.random.rand(self.n_circles, 2), np.zeros(self.n_circles) ++ ++ # Initialize with the best result from the coarse search ++ initial_best_score, initial_best_centers, initial_best_w = self.top_candidates[0] ++ self.best_radii = compute_max_radii(initial_best_centers, interstitial_indices=self.interstitial_indices, w_central=initial_best_w) ++ self.best_sum_radii = np.sum(self.best_radii) ++ self.best_centers = initial_best_centers ++ ++ # Stage 2: Refine the top candidates dynamically ++ for _, initial_centers, w_central in self.top_candidates: ++ optimized_centers, optimized_radii = self._refine_with_dynamics(initial_centers, w_central) ++ current_sum_radii = np.sum(optimized_radii) ++ ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = optimized_centers ++ self.best_radii = optimized_radii ++ ++ return self.best_centers, self.best_radii + + + def construct_packing(): + """ +- Construct a specific arrangement of 26 circles in a unit square +- that attempts to maximize the sum of their radii. +- +- This version implements a combinatorial search for peripheral and interstitial circles, +- while also optimizing grid boundary parameters (asymmetric), the central circle's weight, +- and applies a micro-perturbation for interstitial circles. +- It places: +- - 1 fixed central circle. +- - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). +- - 2 interstitial circles, chosen from a denser set of interstitial candidate positions. +- +- Returns: +- Tuple of (centers, radii) +- centers: np.array of shape (26, 2) with (x, y) coordinates +- radii: np.array of shape (26) with radius of each circle ++ Constructs an arrangement of 26 circles by creating and running a PackingSolver instance. ++ The solver uses a two-stage pipeline: ++ 1. A coarse combinatorial search to find promising initial topologies. ++ 2. A multi-stage force-directed dynamic optimization to refine the best candidates. + """ +- n_circles = 26 +- grid_size = 5 # For a 5x5 grid +- +- # Ranges for optimizing grid boundaries (Recommendation 4: Asymmetrical Grid Boundary Parameters) +- # These options ensure that (sc + ec) / 2.0 can be 0.5 +- sc_options = np.array([0.09, 0.1, 0.11]) # 3 options +- ec_options = np.array([0.89, 0.9, 0.91]) # 3 options +- +- # Range for optimizing central circle weight (Recommendation 3) +- central_weight_options = np.linspace(1.2, 2.2, 3) # e.g., [1.2, 1.7, 2.2] +- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None +- best_w_central = 1.5 # Store the best weight for later micro-perturbation +- +- # Define the number of circles to select for each category +- num_fixed_central = 1 +- num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 +- num_interstitial_to_select = 2 +- +- # The interstitial circles will always be the last two circles in the `current_centers` array. +- # Their 0-indexed positions will be after the central (index 0) and the 23 peripheral circles. +- # So, indices are 1 (for central) + 23 (for peripheral) = 24 and 25. +- interstitial_circle_indices_to_pass = [ +- num_fixed_central + num_peripheral_to_select, +- num_fixed_central + num_peripheral_to_select + 1 +- ] +- +- # Iterate through all combinations of asymmetric grid boundary parameters +- for w_central in central_weight_options: +- for sc_x in sc_options: +- for ec_x in ec_options: +- # Ensure end_coord is strictly greater than start_coord for valid linspace +- # And ensure the midpoint of the grid aligns with 0.5 for the central point heuristic. +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): +- continue +- +- for sc_y in sc_options: +- for ec_y in ec_options: +- # Same checks for y-coordinates +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): +- continue +- +- all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- +- # Generate denser interstitial candidates (Recommendation 5) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) +- +- # Identify the central point (0.5, 0.5) and the 24 peripheral grid points. +- central_point = np.array([0.5, 0.5]) # Fixed central point +- peripheral_grid_points = [] +- for center in all_grid_centers: +- if not np.allclose(center, central_point): +- peripheral_grid_points.append(center) +- peripheral_grid_points = np.array(peripheral_grid_points) # These are the 24 peripheral points +- +- # Iterate through all combinations of 23 peripheral points from the 24 available +- # Note: itertools.combinations(N, N-1) is equivalent to N choices. +- for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] +- +- # Iterate through all combinations of 2 interstitial points from the denser set of candidates (64 candidates) +- for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] +- +- # Construct the full set of 26 centers for the current combination +- current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) +- current_centers = np.array(current_centers_list) +- +- # Compute radii for this specific configuration +- current_radii = compute_max_radii(current_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) +- current_sum_radii = np.sum(current_radii) +- +- # Keep track of the configuration that yields the highest sum of radii +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii +- best_w_central = w_central # Store the best weight +- +- # Recommendation 2: Apply Localized Micro-Perturbation to Selected Interstitial Circles +- if best_centers is not None: +- perturb_deltas = [-0.005, 0, 0.005] # Small perturbations +- +- # Indices of the two interstitial circles (these are the last two in the array) +- interstitial_indices_to_perturb = interstitial_circle_indices_to_pass # [24, 25] +- +- original_interstitial_centers = np.copy(best_centers[interstitial_indices_to_perturb]) +- +- # Perturb both interstitial circles simultaneously for maximum exploration of local optima +- # Iterate over all combinations of perturbations for the two interstitial centers +- for dx1, dy1 in itertools.product(perturb_deltas, repeat=2): +- for dx2, dy2 in itertools.product(perturb_deltas, repeat=2): +- temp_centers = np.copy(best_centers) # Start from the best configuration found so far +- +- # Apply perturbation to the first interstitial circle +- new_pos1 = original_interstitial_centers[0] + np.array([dx1, dy1]) +- temp_centers[interstitial_indices_to_perturb[0]] = np.clip(new_pos1, 0, 1) # Clamp to unit square +- +- # Apply perturbation to the second interstitial circle +- new_pos2 = original_interstitial_centers[1] + np.array([dx2, dy2]) +- temp_centers[interstitial_indices_to_perturb[1]] = np.clip(new_pos2, 0, 1) # Clamp to unit square +- +- current_radii_perturbed = compute_max_radii(temp_centers, +- interstitial_indices=interstitial_circle_indices_to_pass, +- w_central=best_w_central) # Use the best w_central found +- current_sum_radii_perturbed = np.sum(current_radii_perturbed) +- +- if current_sum_radii_perturbed > best_sum_radii: +- best_sum_radii = current_sum_radii_perturbed +- best_centers = temp_centers +- best_radii = current_radii_perturbed +- +- return best_centers, best_radii ++ solver = PackingSolver(n_circles=26) ++ return solver.solve() + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/main.py new file mode 100644 index 0000000000000000000000000000000000000000..ffb1214a3063a5faf778e760ffa1fceb3c0aa3a3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/main.py @@ -0,0 +1,240 @@ +# EVOLVE-BLOCK-START +import numpy as np +import itertools + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points with asymmetric bounds and variable density.""" + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """Computes maximum radii for a fixed set of centers using iterative relaxation.""" + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + +class PackingSolver: + """Encapsulates the two-stage pipeline for solving the circle packing problem.""" + + def __init__(self, n_circles=26, grid_size=5): + self.n_circles = n_circles + self.grid_size = grid_size + self.best_sum_radii = -1.0 + self.best_centers = None + self.best_radii = None + self.top_candidates = [] + + # --- Hyperparameters --- + self.sc_options = np.array([0.09, 0.1, 0.11]) + self.ec_options = np.array([0.89, 0.9, 0.91]) + self.central_weight_options = np.linspace(1.2, 2.2, 3) + self.TOP_N_CANDIDATES = 15 + self.NUM_PERIPHERAL = self.n_circles - 1 - 2 # 23 + self.NUM_INTERSTITIAL = 2 + self.interstitial_indices = list(range(1 + self.NUM_PERIPHERAL, self.n_circles)) + + + def _generate_and_select_candidates(self): + """Stage 1: Coarse combinatorial search for promising initial topologies.""" + for w_central in self.central_weight_options: + for sc in self.sc_options: + ec = 1.0 - sc # Enforce symmetry for grid generation + + all_grid_centers = _generate_grid_centers(self.grid_size, sc, ec, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(self.grid_size, sc, ec, sc, ec, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + if len(peripheral_grid_points) < self.NUM_PERIPHERAL: continue + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.NUM_PERIPHERAL): + selected_peripheral = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), self.NUM_INTERSTITIAL): + selected_interstitial = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=self.interstitial_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(self.top_candidates) < self.TOP_N_CANDIDATES: + self.top_candidates.append((coarse_sum_radii, current_centers, w_central)) + self.top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > self.top_candidates[-1][0]: + self.top_candidates.pop() + self.top_candidates.append((coarse_sum_radii, current_centers, w_central)) + self.top_candidates.sort(key=lambda x: x[0], reverse=True) + + def _refine_with_dynamics(self, initial_centers, w_central): + """Stage 2: Refine a single candidate using force-directed optimization.""" + centers = np.copy(initial_centers) + + best_cfg_radii = compute_max_radii(centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=w_central) + best_cfg_sum_radii = np.sum(best_cfg_radii) + best_cfg_centers = np.copy(centers) + + # Multi-stage optimization parameters + stages = [ + {'steps': 800, 'lr': 0.02, 'buffer': 0.1, 'jiggle_freq': 100, 'jiggle_mag': 0.005}, + {'steps': 800, 'lr': 0.005, 'buffer': 0.05, 'jiggle_freq': 200, 'jiggle_mag': 0.001}, + {'steps': 400, 'lr': 0.001, 'buffer': 0.01, 'jiggle_freq': 0, 'jiggle_mag': 0}, + ] + + total_steps_done = 0 + for stage in stages: + for step in range(stage['steps']): + lr = stage['lr'] * (1 - step / stage['steps']) + + # Jiggle non-central circles to escape local optima + if stage['jiggle_freq'] > 0 and step % stage['jiggle_freq'] == 0: + jiggle_vec = (np.random.rand(self.n_circles - 1, 2) - 0.5) * stage['jiggle_mag'] + centers[1:] += jiggle_vec + + radii_iter_count = 50 if total_steps_done < 1600 else 200 + current_radii = compute_max_radii(centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=w_central) + + force_vectors = np.zeros_like(centers) + # Repulsion forces + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(centers[i] - centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + stage['buffer']) and dist_ij > 1e-9: + overlap = (target_dist * (1 + stage['buffer']) - dist_ij) + direction = (centers[i] - centers[j]) / dist_ij + force_vectors[i] += direction * overlap + force_vectors[j] -= direction * overlap + + # Boundary forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = centers[i]; r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Apply forces (central circle is fixed) + centers[1:] += lr * force_vectors[1:] + + # Clip to bounds + for i in range(self.n_circles): + r = current_radii[i] + centers[i] = np.clip(centers[i], r, 1.0 - r) + + # Update best config found during this refinement + if total_steps_done % 50 == 0: + test_radii = compute_max_radii(centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > best_cfg_sum_radii: + best_cfg_sum_radii = current_sum_radii + best_cfg_centers = np.copy(centers) + best_cfg_radii = test_radii + total_steps_done += 1 + + return best_cfg_centers, best_cfg_radii + + def solve(self): + """Orchestrates the pipeline to find the best packing.""" + self._generate_and_select_candidates() + + if not self.top_candidates: + return np.random.rand(self.n_circles, 2), np.zeros(self.n_circles) + + # Initialize with the best result from the coarse search + initial_best_score, initial_best_centers, initial_best_w = self.top_candidates[0] + self.best_radii = compute_max_radii(initial_best_centers, interstitial_indices=self.interstitial_indices, w_central=initial_best_w) + self.best_sum_radii = np.sum(self.best_radii) + self.best_centers = initial_best_centers + + # Stage 2: Refine the top candidates dynamically + for _, initial_centers, w_central in self.top_candidates: + optimized_centers, optimized_radii = self._refine_with_dynamics(initial_centers, w_central) + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = optimized_centers + self.best_radii = optimized_radii + + return self.best_centers, self.best_radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by creating and running a PackingSolver instance. + The solver uses a two-stage pipeline: + 1. A coarse combinatorial search to find promising initial topologies. + 2. A multi-stage force-directed dynamic optimization to refine the best candidates. + """ + solver = PackingSolver(n_circles=26) + return solver.solve() +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/original.py new file mode 100644 index 0000000000000000000000000000000000000000..cb3c32a7869b674ac00a1cf621199a05b1d6f3e2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/original.py @@ -0,0 +1,290 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + sc_x (float): The starting x-coordinate for linspace. + ec_x (float): The ending x-coordinate for linspace. + sc_y (float): The starting y-coordinate for linspace. + ec_y (float): The ending y-coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers, + with asymmetric bounds and higher density. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + sc_x (float): The starting x-coordinate of the grid. + ec_x (float): The ending x-coordinate of the grid. + sc_y (float): The starting y-coordinate of the grid. + ec_y (float): The ending y-coordinate of the grid. + density_factor (int): Factor to increase the density of interstitial candidates. + e.g., 2 means each original grid cell is divided into 4. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + # Number of interstitial intervals along each dimension, increased by density_factor + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + + candidates = [] + # Interstitial points are halfway between conceptual grid points + for i in range(num_interstitial_intervals_y): # y-indices + for j in range(num_interstitial_intervals_x): # x-indices + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + # This prevents them from growing too large initially and sub-optimally + # squeezing their neighbors, allowing for a better overall packing. + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # Other circles have normal weight (j is always > i, so j is never the first circle if i=0) + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This version implements a combinatorial search for peripheral and interstitial circles, + while also optimizing grid boundary parameters (asymmetric), the central circle's weight, + and applies a micro-perturbation for interstitial circles. + It places: + - 1 fixed central circle. + - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). + - 2 interstitial circles, chosen from a denser set of interstitial candidate positions. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n_circles = 26 + grid_size = 5 # For a 5x5 grid + + # Ranges for optimizing grid boundaries (Recommendation 4: Asymmetrical Grid Boundary Parameters) + # These options ensure that (sc + ec) / 2.0 can be 0.5 + sc_options = np.array([0.09, 0.1, 0.11]) # 3 options + ec_options = np.array([0.89, 0.9, 0.91]) # 3 options + + # Range for optimizing central circle weight (Recommendation 3) + central_weight_options = np.linspace(1.2, 2.2, 3) # e.g., [1.2, 1.7, 2.2] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + best_w_central = 1.5 # Store the best weight for later micro-perturbation + + # Define the number of circles to select for each category + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 + + # The interstitial circles will always be the last two circles in the `current_centers` array. + # Their 0-indexed positions will be after the central (index 0) and the 23 peripheral circles. + # So, indices are 1 (for central) + 23 (for peripheral) = 24 and 25. + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # Iterate through all combinations of asymmetric grid boundary parameters + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + # Ensure end_coord is strictly greater than start_coord for valid linspace + # And ensure the midpoint of the grid aligns with 0.5 for the central point heuristic. + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + + for sc_y in sc_options: + for ec_y in ec_options: + # Same checks for y-coordinates + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + + # Generate denser interstitial candidates (Recommendation 5) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + # Identify the central point (0.5, 0.5) and the 24 peripheral grid points. + central_point = np.array([0.5, 0.5]) # Fixed central point + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) # These are the 24 peripheral points + + # Iterate through all combinations of 23 peripheral points from the 24 available + # Note: itertools.combinations(N, N-1) is equivalent to N choices. + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + # Iterate through all combinations of 2 interstitial points from the denser set of candidates (64 candidates) + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Construct the full set of 26 centers for the current combination + current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) + current_centers = np.array(current_centers_list) + + # Compute radii for this specific configuration + current_radii = compute_max_radii(current_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + current_sum_radii = np.sum(current_radii) + + # Keep track of the configuration that yields the highest sum of radii + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + best_w_central = w_central # Store the best weight + + # Recommendation 2: Apply Localized Micro-Perturbation to Selected Interstitial Circles + if best_centers is not None: + perturb_deltas = [-0.005, 0, 0.005] # Small perturbations + + # Indices of the two interstitial circles (these are the last two in the array) + interstitial_indices_to_perturb = interstitial_circle_indices_to_pass # [24, 25] + + original_interstitial_centers = np.copy(best_centers[interstitial_indices_to_perturb]) + + # Perturb both interstitial circles simultaneously for maximum exploration of local optima + # Iterate over all combinations of perturbations for the two interstitial centers + for dx1, dy1 in itertools.product(perturb_deltas, repeat=2): + for dx2, dy2 in itertools.product(perturb_deltas, repeat=2): + temp_centers = np.copy(best_centers) # Start from the best configuration found so far + + # Apply perturbation to the first interstitial circle + new_pos1 = original_interstitial_centers[0] + np.array([dx1, dy1]) + temp_centers[interstitial_indices_to_perturb[0]] = np.clip(new_pos1, 0, 1) # Clamp to unit square + + # Apply perturbation to the second interstitial circle + new_pos2 = original_interstitial_centers[1] + np.array([dx2, dy2]) + temp_centers[interstitial_indices_to_perturb[1]] = np.clip(new_pos2, 0, 1) # Clamp to unit square + + current_radii_perturbed = compute_max_radii(temp_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=best_w_central) # Use the best w_central found + current_sum_radii_perturbed = np.sum(current_radii_perturbed) + + if current_sum_radii_perturbed > best_sum_radii: + best_sum_radii = current_sum_radii_perturbed + best_centers = temp_centers + best_radii = current_radii_perturbed + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..eb1be2405c52a9c2d7ee83d2c5e32824d7e17b53 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8686613948484987, + "spatial_uniformity_details": { + "cell_size_mean": 0.19893973087283903, + "cell_size_std": 0.030079000918360528, + "coefficient_of_variation": 0.15119654900101517 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.5878165919480111, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00030750090218092897, + "mean_density": 0.025007743975253627, + "cv": 0.7012109111891897 + }, + "packing_efficiency": 0.6754408797597644, + "packing_efficiency_details": { + "total_area": 0.6754408797597644, + "square_area": 1.0, + "efficiency": 0.6754408797597644, + "relative_to_estimated_best": 0.804096285428291 + }, + "radius_distribution": 0.9450467888248784, + "radius_distribution_details": { + "mean": 0.08795311771396912, + "std": 0.023096774462132527, + "min": 0.03246441133514246, + "max": 0.14036169503179186, + "range": 0.10789728369664939, + "small_count": 7, + "medium_count": 13, + "large_count": 6, + "diversity_score": 0.9450467888248784 + }, + "gap_analysis": 0.6792, + "gap_analysis_details": { + "covered_samples": 1698, + "total_samples": 2500, + "coverage": 0.6792, + "gap_ratio": 0.3208 + }, + "geometric_quality": 0.6622528281081173, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6622528281081173, + "min_quality": 0.33805301520822423, + "max_quality": 0.801209867321722 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..083e4bdbb2cbf17b98bbd3ebeffc64079b5f01ba --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 169.91 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2868 + + Auxiliary Metrics: + • spatial_uniformity: 0.869 + • edge_utilization: 0.738 + • density_variance: 0.588 + • packing_efficiency: 0.675 + • radius_distribution: 0.945 + • gap_analysis: 0.679 + • geometric_quality: 0.662 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2868 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.869 + • Boundary and corner utilization: 0.738 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.588 + • Area utilization efficiency: 0.675 + • Radius size diversity: 0.945 + • Area coverage (1 - gap ratio): 0.679 + • Delaunay triangulation quality: 0.662 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..0824c25bced4dc5c922403f99a9f725fc7101326 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.286781060563197, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0992, 0.0855)\n centers[2] = (0.3002, 0.0983)\n centers[3] = (0.4973, 0.0991)\n centers[4] = (0.7005, 0.0938)\n centers[5] = (0.8983, 0.0988)\n centers[6] = (0.0973, 0.2843)\n centers[7] = (0.2953, 0.2544)\n centers[8] = (0.4895, 0.2763)\n centers[9] = (0.7011, 0.2610)\n centers[10] = (0.9110, 0.2979)\n centers[11] = (0.0797, 0.4775)\n centers[12] = (0.2834, 0.4657)\n centers[13] = (0.6911, 0.4785)\n centers[14] = (0.9154, 0.5170)\n centers[15] = (0.1110, 0.6820)\n centers[16] = (0.4360, 0.6736)\n centers[17] = (0.7110, 0.6660)\n centers[18] = (0.9161, 0.7079)\n centers[19] = (0.0948, 0.9051)\n centers[20] = (0.2989, 0.8950)\n centers[21] = (0.5064, 0.9038)\n centers[22] = (0.7045, 0.8981)\n centers[23] = (0.9036, 0.9036)\n centers[24] = (0.5833, 0.4105)\n centers[25] = (0.7982, 0.4088)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8686613948484987, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.5878165919480111, + "aux_packing_efficiency": 0.6754408797597644, + "aux_radius_distribution": 0.9450467888248784, + "aux_gap_analysis": 0.6792, + "aux_geometric_quality": 0.6622528281081173 + }, + "private": { + "reported_sum_of_radii": 2.286781060563197 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2868\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.869\n \u2022 Boundary and corner utilization: 0.738\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.588\n \u2022 Area utilization efficiency: 0.675\n \u2022 Radius size diversity: 0.945\n \u2022 Area coverage (1 - gap ratio): 0.679\n \u2022 Delaunay triangulation quality: 0.662\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/results/packing_viz.png", + "execution_time_mean": 169.90931518608704, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..55f13a340578a4eb81d3e1b4e1311d2ea55a6120 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_136/rewrite.txt @@ -0,0 +1,231 @@ +# EVOLVE-BLOCK-START +import numpy as np +import itertools + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points with asymmetric bounds and variable density.""" + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """Computes maximum radii for a fixed set of centers using iterative relaxation.""" + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + +class PackingSolver: + """Encapsulates the two-stage pipeline for solving the circle packing problem.""" + + def __init__(self, n_circles=26, grid_size=5): + self.n_circles = n_circles + self.grid_size = grid_size + self.best_sum_radii = -1.0 + self.best_centers = None + self.best_radii = None + self.top_candidates = [] + + # --- Hyperparameters --- + self.sc_options = np.array([0.09, 0.1, 0.11]) + self.ec_options = np.array([0.89, 0.9, 0.91]) + self.central_weight_options = np.linspace(1.2, 2.2, 3) + self.TOP_N_CANDIDATES = 15 + self.NUM_PERIPHERAL = self.n_circles - 1 - 2 # 23 + self.NUM_INTERSTITIAL = 2 + self.interstitial_indices = list(range(1 + self.NUM_PERIPHERAL, self.n_circles)) + + + def _generate_and_select_candidates(self): + """Stage 1: Coarse combinatorial search for promising initial topologies.""" + for w_central in self.central_weight_options: + for sc in self.sc_options: + ec = 1.0 - sc # Enforce symmetry for grid generation + + all_grid_centers = _generate_grid_centers(self.grid_size, sc, ec, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(self.grid_size, sc, ec, sc, ec, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + if len(peripheral_grid_points) < self.NUM_PERIPHERAL: continue + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.NUM_PERIPHERAL): + selected_peripheral = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), self.NUM_INTERSTITIAL): + selected_interstitial = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=self.interstitial_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(self.top_candidates) < self.TOP_N_CANDIDATES: + self.top_candidates.append((coarse_sum_radii, current_centers, w_central)) + self.top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > self.top_candidates[-1][0]: + self.top_candidates.pop() + self.top_candidates.append((coarse_sum_radii, current_centers, w_central)) + self.top_candidates.sort(key=lambda x: x[0], reverse=True) + + def _refine_with_dynamics(self, initial_centers, w_central): + """Stage 2: Refine a single candidate using force-directed optimization.""" + centers = np.copy(initial_centers) + + best_cfg_radii = compute_max_radii(centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=w_central) + best_cfg_sum_radii = np.sum(best_cfg_radii) + best_cfg_centers = np.copy(centers) + + # Multi-stage optimization parameters + stages = [ + {'steps': 800, 'lr': 0.02, 'buffer': 0.1, 'jiggle_freq': 100, 'jiggle_mag': 0.005}, + {'steps': 800, 'lr': 0.005, 'buffer': 0.05, 'jiggle_freq': 200, 'jiggle_mag': 0.001}, + {'steps': 400, 'lr': 0.001, 'buffer': 0.01, 'jiggle_freq': 0, 'jiggle_mag': 0}, + ] + + total_steps_done = 0 + for stage in stages: + for step in range(stage['steps']): + lr = stage['lr'] * (1 - step / stage['steps']) + + # Jiggle non-central circles to escape local optima + if stage['jiggle_freq'] > 0 and step % stage['jiggle_freq'] == 0: + jiggle_vec = (np.random.rand(self.n_circles - 1, 2) - 0.5) * stage['jiggle_mag'] + centers[1:] += jiggle_vec + + radii_iter_count = 50 if total_steps_done < 1600 else 200 + current_radii = compute_max_radii(centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=w_central) + + force_vectors = np.zeros_like(centers) + # Repulsion forces + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(centers[i] - centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + stage['buffer']) and dist_ij > 1e-9: + overlap = (target_dist * (1 + stage['buffer']) - dist_ij) + direction = (centers[i] - centers[j]) / dist_ij + force_vectors[i] += direction * overlap + force_vectors[j] -= direction * overlap + + # Boundary forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = centers[i]; r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Apply forces (central circle is fixed) + centers[1:] += lr * force_vectors[1:] + + # Clip to bounds + for i in range(self.n_circles): + r = current_radii[i] + centers[i] = np.clip(centers[i], r, 1.0 - r) + + # Update best config found during this refinement + if total_steps_done % 50 == 0: + test_radii = compute_max_radii(centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > best_cfg_sum_radii: + best_cfg_sum_radii = current_sum_radii + best_cfg_centers = np.copy(centers) + best_cfg_radii = test_radii + total_steps_done += 1 + + return best_cfg_centers, best_cfg_radii + + def solve(self): + """Orchestrates the pipeline to find the best packing.""" + self._generate_and_select_candidates() + + if not self.top_candidates: + return np.random.rand(self.n_circles, 2), np.zeros(self.n_circles) + + # Initialize with the best result from the coarse search + initial_best_score, initial_best_centers, initial_best_w = self.top_candidates[0] + self.best_radii = compute_max_radii(initial_best_centers, interstitial_indices=self.interstitial_indices, w_central=initial_best_w) + self.best_sum_radii = np.sum(self.best_radii) + self.best_centers = initial_best_centers + + # Stage 2: Refine the top candidates dynamically + for _, initial_centers, w_central in self.top_candidates: + optimized_centers, optimized_radii = self._refine_with_dynamics(initial_centers, w_central) + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = optimized_centers + self.best_radii = optimized_radii + + return self.best_centers, self.best_radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by creating and running a PackingSolver instance. + The solver uses a two-stage pipeline: + 1. A coarse combinatorial search to find promising initial topologies. + 2. A multi-stage force-directed dynamic optimization to refine the best candidates. + """ + solver = PackingSolver(n_circles=26) + return solver.solve() +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a8e9a428d7e74155ecc91309e784bc4c43d9041f Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..b1f8dfd6673d8855cb6791ec98f2c3379f71fbfd --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8706193999341978, + "spatial_uniformity_details": { + "cell_size_mean": 0.20030829410452045, + "cell_size_std": 0.029767321312549905, + "coefficient_of_variation": 0.1486075316901748 + }, + "edge_utilization": 0.5461538461538462, + "edge_utilization_details": { + "corners_touched": 2, + "edges_touched": 16, + "corner_score": 0.5, + "edge_score": 0.6153846153846154 + }, + "density_variance": 0.5204944022575321, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0012583444289322166, + "mean_density": 0.038505444020777185, + "cv": 0.9212502491145264 + }, + "packing_efficiency": 0.7281770716223204, + "packing_efficiency_details": { + "total_area": 0.7281770716223204, + "square_area": 1.0, + "efficiency": 0.7281770716223204, + "relative_to_estimated_best": 0.8668774662170481 + }, + "radius_distribution": 0.9450467888248784, + "radius_distribution_details": { + "mean": 0.08609535634712186, + "std": 0.03876124689972704, + "min": 0.03426018412656563, + "max": 0.16916563319961753, + "range": 0.1349054490730519, + "small_count": 7, + "medium_count": 13, + "large_count": 6, + "diversity_score": 0.9450467888248784 + }, + "gap_analysis": 0.726, + "gap_analysis_details": { + "covered_samples": 1815, + "total_samples": 2500, + "coverage": 0.726, + "gap_ratio": 0.274 + }, + "geometric_quality": 0.6364681235323418, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6364681235323418, + "min_quality": 0.19688693690654557, + "max_quality": 0.982069363743738 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..ecaa0cc55c95f17044d85fa15f59fc66521b8120 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 486.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2385 + + Auxiliary Metrics: + • spatial_uniformity: 0.871 + • edge_utilization: 0.546 + • density_variance: 0.520 + • packing_efficiency: 0.728 + • radius_distribution: 0.945 + • gap_analysis: 0.726 + • geometric_quality: 0.636 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2385 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.871 + • Area utilization efficiency: 0.728 + • Area coverage (1 - gap ratio): 0.726 + +📊 Other Metrics: + • Boundary and corner utilization: 0.546 + • Spatial density uniformity across grid: 0.520 + • Radius size diversity: 0.945 + • Delaunay triangulation quality: 0.636 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..7b74143ac5be08ca910cde9a6c238b6e666efca5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2384792650251684, + "public": { + "centers_str": " centers[0] = (0.5731, 0.6101)\n centers[1] = (0.2270, 0.6595)\n centers[2] = (0.0990, 0.9269)\n centers[3] = (0.6230, 0.0343)\n centers[4] = (0.0427, 0.4279)\n centers[5] = (0.9371, 0.6115)\n centers[6] = (0.2532, 0.4012)\n centers[7] = (0.7592, 0.1196)\n centers[8] = (0.7580, 0.9413)\n centers[9] = (0.9368, 0.7480)\n centers[10] = (0.8213, 0.5867)\n centers[11] = (0.2551, 0.9220)\n centers[12] = (0.7507, 0.7599)\n centers[13] = (0.0733, 0.5777)\n centers[14] = (0.9263, 0.8995)\n centers[15] = (0.2383, 0.0714)\n centers[16] = (0.0800, 0.7549)\n centers[17] = (0.4482, 0.5512)\n centers[18] = (0.4680, 0.8001)\n centers[19] = (0.9538, 0.0547)\n centers[20] = (0.0733, 0.2390)\n centers[21] = (0.6614, 0.4132)\n centers[22] = (0.0800, 0.0800)\n centers[23] = (0.4641, 0.1551)\n centers[24] = (0.9085, 0.2801)\n centers[25] = (0.9154, 0.4629)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8706193999341978, + "aux_edge_utilization": 0.5461538461538462, + "aux_density_variance": 0.5204944022575321, + "aux_packing_efficiency": 0.7281770716223204, + "aux_radius_distribution": 0.9450467888248784, + "aux_gap_analysis": 0.726, + "aux_geometric_quality": 0.6364681235323418 + }, + "private": { + "reported_sum_of_radii": 2.2384792650251684 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2385\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.871\n \u2022 Area utilization efficiency: 0.728\n \u2022 Area coverage (1 - gap ratio): 0.726\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.546\n \u2022 Spatial density uniformity across grid: 0.520\n \u2022 Radius size diversity: 0.945\n \u2022 Delaunay triangulation quality: 0.636\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_137/results/packing_viz.png", + "execution_time_mean": 486.0031184460968, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4598e49227482aa4e477d27bc2ec3d4fe0e22720 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..654f088f8e0af1fdf03023bff1bbe7d7402bd3ec --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8674137451680204, + "spatial_uniformity_details": { + "cell_size_mean": 0.20175216966084505, + "cell_size_std": 0.030838299325038235, + "coefficient_of_variation": 0.15285237935248228 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5477561996207105, + "density_variance_details": { + "grid_size": 10, + "variance": 0.000816387506376763, + "mean_density": 0.03460691147819891, + "cv": 0.825629724852849 + }, + "packing_efficiency": 0.7380506210194775, + "packing_efficiency_details": { + "total_area": 0.7380506210194775, + "square_area": 1.0, + "efficiency": 0.7380506210194775, + "relative_to_estimated_best": 0.8786316916898542 + }, + "radius_distribution": 0.9341661379115739, + "radius_distribution_details": { + "mean": 0.08867828392557701, + "std": 0.03423281159657376, + "min": 0.0029843501805328822, + "max": 0.1669084261323459, + "range": 0.16392407595181302, + "small_count": 8, + "medium_count": 13, + "large_count": 5, + "diversity_score": 0.9341661379115739 + }, + "gap_analysis": 0.7432, + "gap_analysis_details": { + "covered_samples": 1858, + "total_samples": 2500, + "coverage": 0.7432, + "gap_ratio": 0.25680000000000003 + }, + "geometric_quality": 0.6578597858976948, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6578597858976948, + "min_quality": 0.24514080994249549, + "max_quality": 0.9472956076771955 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..5e113f89c2fe45316c4dac0186b1d7d407404cf8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 325.98 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3056 + + Auxiliary Metrics: + • spatial_uniformity: 0.867 + • edge_utilization: 0.785 + • density_variance: 0.548 + • packing_efficiency: 0.738 + • radius_distribution: 0.934 + • gap_analysis: 0.743 + • geometric_quality: 0.658 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3056 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.867 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.738 + • Area coverage (1 - gap ratio): 0.743 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.548 + • Radius size diversity: 0.934 + • Delaunay triangulation quality: 0.658 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..bcffb02a1589b98eb7a2f1ecf4b3e38e8bf5f263 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3056353820650024, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0998, 0.0942)\n centers[2] = (0.2643, 0.0646)\n centers[3] = (0.4981, 0.0896)\n centers[4] = (0.6791, 0.0599)\n centers[5] = (0.8993, 0.0978)\n centers[6] = (0.0959, 0.2927)\n centers[7] = (0.2775, 0.2636)\n centers[8] = (0.4416, 0.2539)\n centers[9] = (0.9241, 0.2816)\n centers[10] = (0.0712, 0.4695)\n centers[11] = (0.2660, 0.4626)\n centers[12] = (0.6814, 0.2940)\n centers[13] = (0.9022, 0.4658)\n centers[14] = (0.0030, 0.7090)\n centers[15] = (0.1376, 0.6758)\n centers[16] = (0.4003, 0.6766)\n centers[17] = (0.6880, 0.6361)\n centers[18] = (0.9207, 0.7164)\n centers[19] = (0.0964, 0.9036)\n centers[20] = (0.2988, 0.8953)\n centers[21] = (0.5056, 0.9018)\n centers[22] = (0.7052, 0.9028)\n centers[23] = (0.9029, 0.9029)\n centers[24] = (0.3576, 0.1383)\n centers[25] = (0.4329, 0.3975)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8674137451680204, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5477561996207105, + "aux_packing_efficiency": 0.7380506210194775, + "aux_radius_distribution": 0.9341661379115739, + "aux_gap_analysis": 0.7432, + "aux_geometric_quality": 0.6578597858976948 + }, + "private": { + "reported_sum_of_radii": 2.3056353820650024 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3056\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.867\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.738\n \u2022 Area coverage (1 - gap ratio): 0.743\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.548\n \u2022 Radius size diversity: 0.934\n \u2022 Delaunay triangulation quality: 0.658\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_138/results/packing_viz.png", + "execution_time_mean": 325.98210950102657, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..68dc88253890bb786df24df1b687be11ba3058fc Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..1968abc40d1d48cbdf79e2e5053fee7dd91be037 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/edit.diff @@ -0,0 +1,431 @@ +--- a/original.py ++++ b/original.py +@@ -1,265 +1,284 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np ++import itertools + + + class DynamicPackingOptimizer: + """ +- Optimizes circle packing using a force-directed approach with iterative radius maximization. +- This class manages the iterative adjustments of circle centers based on +- repulsion forces and boundaries, while repeatedly calculating maximum radii +- for the current center configuration. +- """ +- def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): +- self.n_circles = num_circles ++ Optimizes circle packing using a force-directed approach. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2500, initial_learning_rate=0.015): ++ self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate +- self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) +- self.interstitial_idx = interstitial_idx +- self.central_idx = 0 # The central circle is always at index 0 in our setup ++ self.interstitial_indices = interstitial_indices ++ self.w_central = w_central ++ self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): ++ """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) +- if learning_rate < 1e-7: +- learning_rate = 1e-7 +- +- # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. +- # More iterations are used towards the end of the simulation. +- radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) +- +- # Check if this configuration is the best so far (using full radii calculation) +- # We re-evaluate with full iterations only if it potentially improves the current best +- test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) +- current_sum_radii = np.sum(test_radii_for_sum) +- +- if current_sum_radii > self.best_sum_radii: +- self.best_sum_radii = current_sum_radii +- self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations +- +- # Calculate force vectors for center movement ++ learning_rate = max(learning_rate, 1e-7) ++ ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ ++ # Periodically check for new best configuration with full radii calculation ++ if step % 50 == 0 or step == self.num_steps - 1: ++ test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ current_sum_radii = np.sum(test_radii) ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(test_radii) ++ + force_vectors = np.zeros_like(self.centers) +- +- # Repulsion between circles +- # Forces are applied if circles are very close or overlapping slightly, to push them apart ++ buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] +- +- # Apply force if distance is less than target_dist * (1 + buffer_factor) +- buffer_factor = 0.05 # Allows forces to act even before full contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: +- # Force magnitude is proportional to how much they 'want' to separate + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij +- + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + +- # Boundary repulsion forces +- K_boundary = 10.0 # Stronger boundary force to keep circles inside effectively ++ K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] +- r = current_radii[i] # Use the radii from this iteration for boundary checks +- +- # If a circle is closer to a boundary than its radius, apply repulsive force ++ r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + +- # Add a restoring force to the central circle to keep it near the center. +- if self.central_fixed: # Re-purposing central_fixed to mean "central-attracted" +- K_center = 5.0 # Strength of the restoring force, allows for some flexibility +- center_target = np.array([0.5, 0.5]) +- displacement = center_target - self.centers[self.central_idx] +- force_vectors[self.central_idx] += K_center * displacement ++ # Add a soft restoring force to the central circle to keep it near the center. ++ K_center = 2.0 # Reduced strength for more flexibility ++ center_target = np.array([0.5, 0.5]) ++ displacement = center_target - self.centers[self.central_idx] ++ force_vectors[self.central_idx] += K_center * displacement + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + +- # Clip centers to ensure the circles remain entirely within the unit square +- # This is crucial: a circle's center cannot be closer to a boundary than its radius. ++ # Clip centers to ensure they stay within bounds + for i in range(self.n_circles): +- r = current_radii[i] # Use the radii from this iteration for clipping ++ r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +-def _generate_grid_centers(grid_size, start_coord, end_coord): +- """Generates centers for a square grid of circles.""" +- coords = np.linspace(start_coord, end_coord, grid_size) +- return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) +- +- +-def _generate_interstitial_candidates(grid_size, start_coord, end_coord): +- """ +- Generates potential interstitial points within the grid cells. +- For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. ++def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): ++ """ ++ Generates centers for a square grid of circles with asymmetric bounds. ++ """ ++ x_coords = np.linspace(sc_x, ec_x, grid_size) ++ y_coords = np.linspace(sc_y, ec_y, grid_size) ++ grid_centers = [] ++ for y in y_coords: ++ for x in x_coords: ++ grid_centers.append([x, y]) ++ return np.array(grid_centers) ++ ++ ++def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): ++ """ ++ Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) +- step = (end_coord - start_coord) / (grid_size - 1) +- interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) +- return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) ++ num_interstitial_intervals_x = (grid_size - 1) * density_factor ++ num_interstitial_intervals_y = (grid_size - 1) * density_factor ++ step_x = (ec_x - sc_x) / num_interstitial_intervals_x ++ step_y = (ec_y - sc_y) / num_interstitial_intervals_y ++ candidates = [] ++ for i in range(num_interstitial_intervals_y): ++ for j in range(num_interstitial_intervals_x): ++ candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) ++ return np.array(candidates) + + + def construct_packing(): + """ +- Constructs an arrangement of 26 circles by performing a systematic search +- for the optimal grid boundary parameter and the best position for an +- interstitial circle. Each initial configuration is then refined using +- a force-directed dynamic packing optimizer. +- +- Returns: +- Tuple of (centers, radii) ++ Constructs an arrangement of 26 circles using a two-stage process: ++ 1. A broad combinatorial search finds promising initial topologies. ++ 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 ++ # Define search space for grid parameters and central weight ++ sc_options = np.array([0.09, 0.1, 0.11]) ++ central_weight_options = np.linspace(1.2, 2.2, 4) ++ ++ TOP_N_CANDIDATES = 20 ++ top_candidates = [] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + +- # Search space for the grid's start coordinate. This parameter controls +- # how far the outer grid circles are from the boundary, directly influencing +- # edge utilization and overall packing density. +- # The range is from 0.08 to 0.12, with 5 points. +- start_coord_search_space = np.linspace(0.08, 0.12, 5) +- +- # --- Main Search Loop --- +- for current_start_coord in start_coord_search_space: +- current_end_coord = 1.0 - current_start_coord +- +- # 1. Generate base centers for 25 circles (24 grid + 1 central). +- # The central circle is placed at index 0 for prioritized relaxation. +- all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) +- central_point_coords = np.array([0.5, 0.5]) +- +- # Find the index of the center point to separate it. +- central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] +- +- # Prepare the base 25 centers (central at index 0, others follow) +- base_centers = np.zeros((n_circles - 1, 2)) +- base_centers[0] = central_point_coords +- other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- base_centers[1:] = other_grid_centers +- +- # 2. Generate interstitial candidates for the current grid configuration. +- candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) +- +- # 3. For each candidate interstitial point, run the dynamic optimizer. +- for interstitial_point in candidate_interstitial_points: +- initial_centers_for_optimizer = np.vstack([base_centers, interstitial_point]) +- interstitial_idx = n_circles - 1 # The interstitial circle is always the last one added +- +- # Initialize and run the dynamic packing optimizer +- optimizer = DynamicPackingOptimizer(initial_centers=initial_centers_for_optimizer, +- interstitial_idx=interstitial_idx, +- num_circles=n_circles, +- num_steps=2000, +- initial_learning_rate=0.015, +- central_fixed=True) +- +- optimized_centers, optimized_radii = optimizer.optimize() +- current_sum_radii = np.sum(optimized_radii) +- +- # 4. Keep track of the best configuration found. +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = optimized_centers +- best_radii = optimized_radii ++ num_fixed_central = 1 ++ num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 ++ num_interstitial_to_select = 2 ++ ++ interstitial_indices_to_pass = list(range(num_fixed_central + num_peripheral_to_select, n_circles)) ++ ++ # STAGE 1: Coarse Combinatorial Search ++ for w_central in central_weight_options: ++ for sc in sc_options: ++ ec = 1.0 - sc # Enforce symmetry for a more focused search ++ ++ all_grid_centers = _generate_grid_centers(grid_size, sc, ec, sc, ec) ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec, sc, ec, density_factor=1) ++ ++ central_point = np.array([0.5, 0.5]) ++ peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) ++ ++ # Pruning: if not enough points, skip ++ if len(peripheral_grid_points) < num_peripheral_to_select or len(all_interstitial_candidates) < num_interstitial_to_select: ++ continue ++ ++ # Iterate through combinations of peripheral and interstitial points ++ for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): ++ selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] ++ ++ for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): ++ selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] ++ current_centers = np.vstack(([central_point], selected_peripheral_points, selected_interstitial_points)) ++ ++ coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_indices_to_pass, w_central=w_central) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ if len(top_candidates) < TOP_N_CANDIDATES: ++ top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ elif coarse_sum_radii > top_candidates[-1][0]: ++ top_candidates.pop() ++ top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ ++ # STAGE 2: Refine Top Candidates with Dynamic Optimizer ++ if not top_candidates: ++ return np.random.rand(n_circles, 2), np.zeros(n_circles) ++ ++ # Initialize with the best result from the coarse search ++ best_sum_radii, best_centers, w_central_best = top_candidates[0] ++ best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_indices_to_pass, w_central=w_central_best) ++ ++ for _, initial_centers, w_central in top_candidates: ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=initial_centers, ++ interstitial_indices=interstitial_indices_to_pass, ++ w_central=w_central, ++ num_steps=2500, # Increased steps for better refinement ++ initial_learning_rate=0.015, ++ ) ++ optimized_centers, optimized_radii = optimizer.optimize() ++ current_sum_radii = np.sum(optimized_radii) ++ ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = optimized_centers ++ best_radii = optimized_radii + + return best_centers, best_radii + + +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): +- """ +- Compute the maximum possible radii for a given set of circle centers. +- Uses an iterative relaxation method for robust convergence. +- Includes heuristics for weighted central circle scaling and interstitial circle capping. ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): ++ """ ++ Compute maximum radii using an iterative relaxation approach. Includes a ++ heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. +- interstitial_idx: Index of the interstitial circle to apply the heuristic. ++ interstitial_indices: A list of indices for interstitial circles to apply ++ an adaptive initial radius heuristic. Defaults to None. ++ w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: +- np.array of shape (n) with radius of each circle ++ np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + +- # Initialize radii based on distance to boundaries ++ # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Cap the initial radius of the interstitial circle. +- # This prevents it from growing too large initially and sub-optimally +- # squeezing its neighbors, allowing for a better overall packing. +- if interstitial_idx != -1 and interstitial_idx < n: +- radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) +- +- +- # Iteratively resolve overlaps and expand radii ++ # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). ++ if interstitial_indices: ++ for idx in interstitial_indices: ++ if idx < n: # Ensure index is valid ++ other_centers_mask = np.ones(n, dtype=bool) ++ other_centers_mask[idx] = False ++ other_centers = centers[other_centers_mask] ++ ++ if len(other_centers) > 0: ++ distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) ++ min_dist_to_neighbor = np.min(distances_to_others) ++ # Cap radius at half distance to nearest neighbor, provides a better heuristic than a fixed value. ++ radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) ++ ++ # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + +- # Weighted proportional scaling: The central circle (index 0) is more +- # resistant to shrinking, allowing it to grow larger. +- w_i = 1.5 if i == 0 else 1.0 +- w_j = 1.0 # For simplicity, all other circles have weight 1.0 ++ w_i = w_central if i == 0 else 1.0 ++ w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + +- if total_weighted_radii > 1e-12: # Avoid division by zero for tiny radii ++ if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling +- scale_factor = dist / (radii[i] + radii[j]) ++ elif (radii[i] + radii[j]) > 1e-12: ++ scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + ++ # Ensure no radii become negative ++ radii[radii < 0] = 0 ++ + if np.allclose(radii, prev_radii, atol=tolerance): + break + +- # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/main.py new file mode 100644 index 0000000000000000000000000000000000000000..f35075121da80ae1a6d3effa4302fd69b7e4c729 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/main.py @@ -0,0 +1,284 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for new best configuration with full radii calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a soft restoring force to the central circle to keep it near the center. + K_center = 2.0 # Reduced strength for more flexibility + center_target = np.array([0.5, 0.5]) + displacement = center_target - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * displacement + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + # Define search space for grid parameters and central weight + sc_options = np.array([0.09, 0.1, 0.11]) + central_weight_options = np.linspace(1.2, 2.2, 4) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_indices_to_pass = list(range(num_fixed_central + num_peripheral_to_select, n_circles)) + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc in sc_options: + ec = 1.0 - sc # Enforce symmetry for a more focused search + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec, sc, ec, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + # Pruning: if not enough points, skip + if len(peripheral_grid_points) < num_peripheral_to_select or len(all_interstitial_candidates) < num_interstitial_to_select: + continue + + # Iterate through combinations of peripheral and interstitial points + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.vstack(([central_point], selected_peripheral_points, selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + # Initialize with the best result from the coarse search + best_sum_radii, best_centers, w_central_best = top_candidates[0] + best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_indices_to_pass, w_central=w_central_best) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_indices_to_pass, + w_central=w_central, + num_steps=2500, # Increased steps for better refinement + initial_learning_rate=0.015, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap radius at half distance to nearest neighbor, provides a better heuristic than a fixed value. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/original.py new file mode 100644 index 0000000000000000000000000000000000000000..9df6c3b59b1c167291e2082ea1c61d4bfbf574d6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/original.py @@ -0,0 +1,265 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This class manages the iterative adjustments of circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + for the current center configuration. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is always at index 0 in our setup + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. + # More iterations are used towards the end of the simulation. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Check if this configuration is the best so far (using full radii calculation) + # We re-evaluate with full iterations only if it potentially improves the current best + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + # Forces are applied if circles are very close or overlapping slightly, to push them apart + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + # Apply force if distance is less than target_dist * (1 + buffer_factor) + buffer_factor = 0.05 # Allows forces to act even before full contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + # Force magnitude is proportional to how much they 'want' to separate + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + K_boundary = 10.0 # Stronger boundary force to keep circles inside effectively + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] # Use the radii from this iteration for boundary checks + + # If a circle is closer to a boundary than its radius, apply repulsive force + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force to the central circle to keep it near the center. + if self.central_fixed: # Re-purposing central_fixed to mean "central-attracted" + K_center = 5.0 # Strength of the restoring force, allows for some flexibility + center_target = np.array([0.5, 0.5]) + displacement = center_target - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * displacement + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure the circles remain entirely within the unit square + # This is crucial: a circle's center cannot be closer to a boundary than its radius. + for i in range(self.n_circles): + r = current_radii[i] # Use the radii from this iteration for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Search space for the grid's start coordinate. This parameter controls + # how far the outer grid circles are from the boundary, directly influencing + # edge utilization and overall packing density. + # The range is from 0.08 to 0.12, with 5 points. + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + # --- Main Search Loop --- + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + + # 1. Generate base centers for 25 circles (24 grid + 1 central). + # The central circle is placed at index 0 for prioritized relaxation. + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + + # Find the index of the center point to separate it. + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + # Prepare the base 25 centers (central at index 0, others follow) + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the current grid configuration. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) + + # 3. For each candidate interstitial point, run the dynamic optimizer. + for interstitial_point in candidate_interstitial_points: + initial_centers_for_optimizer = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 # The interstitial circle is always the last one added + + # Initialize and run the dynamic packing optimizer + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers_for_optimizer, + interstitial_idx=interstitial_idx, + num_circles=n_circles, + num_steps=2000, + initial_learning_rate=0.015, + central_fixed=True) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best configuration found. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # Initialize radii based on distance to boundaries + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # Iteratively resolve overlaps and expand radii + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # For simplicity, all other circles have weight 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero for tiny radii + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..1d10b8215bf1b2bb90585ee7d4b1ca283a36cb00 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8612792621201251, + "spatial_uniformity_details": { + "cell_size_mean": 0.20089118283785762, + "cell_size_std": 0.032356257117987355, + "coefficient_of_variation": 0.16106359920753213 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5373159241689373, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0011230761304255245, + "mean_density": 0.038917931236240585, + "cv": 0.8611024818344867 + }, + "packing_efficiency": 0.754594487472869, + "packing_efficiency_details": { + "total_area": 0.754594487472869, + "square_area": 1.0, + "efficiency": 0.754594487472869, + "relative_to_estimated_best": 0.8983267708010345 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.08871828223957647, + "std": 0.03697744204778768, + "min": 0.0011747026733460264, + "max": 0.17976863692662565, + "range": 0.17859393425327963, + "small_count": 10, + "medium_count": 10, + "large_count": 6, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.7612, + "gap_analysis_details": { + "covered_samples": 1903, + "total_samples": 2500, + "coverage": 0.7612, + "gap_ratio": 0.2388 + }, + "geometric_quality": 0.6672973984898922, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6672973984898922, + "min_quality": 0.32500489651840747, + "max_quality": 0.9317138836315704 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..66af133ab9df724eadf376a3a1683c8353d6ac79 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 265.51 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3067 + + Auxiliary Metrics: + • spatial_uniformity: 0.861 + • edge_utilization: 0.785 + • density_variance: 0.537 + • packing_efficiency: 0.755 + • radius_distribution: 0.977 + • gap_analysis: 0.761 + • geometric_quality: 0.667 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3067 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.861 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.755 + • Area coverage (1 - gap ratio): 0.761 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.537 + • Radius size diversity: 0.977 + • Delaunay triangulation quality: 0.667 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..acac9fb2f8f39b4af8d9b23109fc4680c363b086 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.306675338228988, + "public": { + "centers_str": " centers[0] = (0.4961, 0.5069)\n centers[1] = (0.1001, 0.0981)\n centers[2] = (0.2723, 0.0744)\n centers[3] = (0.5021, 0.0860)\n centers[4] = (0.6937, 0.0426)\n centers[5] = (0.9029, 0.0971)\n centers[6] = (0.0856, 0.2992)\n centers[7] = (0.2558, 0.2335)\n centers[8] = (0.4229, 0.2661)\n centers[9] = (0.9314, 0.2760)\n centers[10] = (0.0608, 0.4874)\n centers[11] = (0.2469, 0.4555)\n centers[12] = (0.6759, 0.2730)\n centers[13] = (0.9031, 0.4477)\n centers[14] = (0.0012, 0.7105)\n centers[15] = (0.1265, 0.6717)\n centers[16] = (0.3869, 0.6812)\n centers[17] = (0.6971, 0.6411)\n centers[18] = (0.9300, 0.7304)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3014, 0.9013)\n centers[21] = (0.5118, 0.8904)\n centers[22] = (0.7125, 0.9102)\n centers[23] = (0.9022, 0.9022)\n centers[24] = (0.3856, 0.1312)\n centers[25] = (0.4232, 0.4019)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8612792621201251, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5373159241689373, + "aux_packing_efficiency": 0.754594487472869, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.7612, + "aux_geometric_quality": 0.6672973984898922 + }, + "private": { + "reported_sum_of_radii": 2.306675338228988 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3067\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.861\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.755\n \u2022 Area coverage (1 - gap ratio): 0.761\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.537\n \u2022 Radius size diversity: 0.977\n \u2022 Delaunay triangulation quality: 0.667\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/results/packing_viz.png", + "execution_time_mean": 265.51409282302484, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..ceba7510753a327408376660e38f6c8b545db53c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_141/search_replace.txt @@ -0,0 +1,558 @@ +This submission reinstates and enhances a proven two-stage optimization strategy that was highly effective in previous versions. The core idea is to combine a broad combinatorial search for promising initial configurations with a refined force-directed optimizer. This approach fell out of use in recent iterations, leading to a drop in performance. By bringing it back with improvements, I aim to significantly increase the sum of radii. + +**Key Changes:** + +1. **Reinstated Combinatorial Search (`construct_packing`):** The main function now performs a wide search for initial topologies. It explores combinations of grid parameters, central circle weights, and placements for two interstitial circles. This allows the discovery of more complex and efficient packing structures than the recent simplified `grid + 1` model. A "Top N" candidate list is used to prune the vast search space, focusing optimization efforts on the most promising starting points. + +2. **Enhanced Force-Directed Optimizer (`DynamicPackingOptimizer`):** The optimizer is updated to be cleaner and more flexible. + * The confusing `central_fixed` parameter is removed; a soft restoring force on the central circle is now standard, allowing it to shift slightly for better global packing. The force constant `K_center` is reduced to give it more freedom. + * The number of optimization steps is increased to `2500` for more thorough refinement. + +3. **Improved Radius Calculation (`compute_max_radii`):** + * The function now accepts a list of `interstitial_indices`, enabling the use of multiple interstitial circles. + * The hardcoded initial radius cap for interstitial circles (`0.05`) is replaced with an adaptive heuristic that caps the radius at half the distance to the nearest neighbor, preventing premature blocking and allowing for better relaxation. + * The weight of the central circle (`w_central`) is now a parameter, allowing the combinatorial search to find its optimal value. + +By merging the strengths of past successful strategies (broad combinatorial search) with the refined components of recent versions (soft central force, adaptive heuristics), this change aims to explore a much richer solution space and achieve a higher sum of radii. + + +reinstate_combinatorial_search + + + +I am reinstating a two-stage optimization process that was successful in previous iterations but was recently simplified. This involves: + +1. **A comprehensive combinatorial search (Stage 1):** The `construct_packing` function is overhauled to systematically search for promising initial configurations. It iterates through different grid parameters and central circle weights, and for each setting, it tries combinations of 23 peripheral and 2 interstitial circles. It uses a fast, coarse radius calculation to evaluate these many candidates and keeps a "Top 20" list. + +2. **Refined dynamic optimization (Stage 2):** The top candidates from Stage 1 are then passed to an improved `DynamicPackingOptimizer`. This optimizer now consistently uses a soft restoring force on the central circle (instead of a hard fix) for better global relaxation and runs for more steps (`2500`) for a more thorough refinement. + +3. **More flexible components:** Both the `DynamicPackingOptimizer` and `compute_max_radii` functions are updated to handle multiple interstitial circles and a parameterized central circle weight, which are essential for the expanded combinatorial search. The initial radius heuristic for interstitial circles is also made more adaptive. + +This hybrid approach leverages a powerful global search to find good starting points and a refined local search to perfect them, which should significantly improve the final packing quality and increase the sum of radii. + + + +<<<<<<< SEARCH +import numpy as np + + +class DynamicPackingOptimizer: +======= +import numpy as np +import itertools + + +class DynamicPackingOptimizer: +>>>>>>> REPLACE +<<<<<<< SEARCH + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This class manages the iterative adjustments of circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + for the current center configuration. + """ + def __init__(self, initial_centers, interstitial_idx, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 # The central circle is always at index 0 in our setup + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Compute radii for current centers. Use fewer iterations for speed during intermediate steps. + # More iterations are used towards the end of the simulation. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx) + + # Check if this configuration is the best so far (using full radii calculation) + # We re-evaluate with full iterations only if it potentially improves the current best + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + # Forces are applied if circles are very close or overlapping slightly, to push them apart + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + # Apply force if distance is less than target_dist * (1 + buffer_factor) + buffer_factor = 0.05 # Allows forces to act even before full contact for smoother movement + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + # Force magnitude is proportional to how much they 'want' to separate + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + K_boundary = 10.0 # Stronger boundary force to keep circles inside effectively + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] # Use the radii from this iteration for boundary checks + + # If a circle is closer to a boundary than its radius, apply repulsive force + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force to the central circle to keep it near the center. + if self.central_fixed: # Re-purposing central_fixed to mean "central-attracted" + K_center = 5.0 # Strength of the restoring force, allows for some flexibility + center_target = np.array([0.5, 0.5]) + displacement = center_target - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * displacement + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure the circles remain entirely within the unit square + # This is crucial: a circle's center cannot be closer to a boundary than its radius. + for i in range(self.n_circles): + r = current_radii[i] # Use the radii from this iteration for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii +======= + """ + Optimizes circle packing using a force-directed approach. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for new best configuration with full radii calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a soft restoring force to the central circle to keep it near the center. + K_center = 2.0 # Reduced strength for more flexibility + center_target = np.array([0.5, 0.5]) + displacement = center_target - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * displacement + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii +>>>>>>> REPLACE +<<<<<<< SEARCH +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) +======= +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) +>>>>>>> REPLACE +<<<<<<< SEARCH +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + For a GxG grid, this creates a (G-1)x(G-1) grid of candidates. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) +======= +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) +>>>>>>> REPLACE +<<<<<<< SEARCH +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Search space for the grid's start coordinate. This parameter controls + # how far the outer grid circles are from the boundary, directly influencing + # edge utilization and overall packing density. + # The range is from 0.08 to 0.12, with 5 points. + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + # --- Main Search Loop --- + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + + # 1. Generate base centers for 25 circles (24 grid + 1 central). + # The central circle is placed at index 0 for prioritized relaxation. + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + + # Find the index of the center point to separate it. + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + # Prepare the base 25 centers (central at index 0, others follow) + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the current grid configuration. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) + + # 3. For each candidate interstitial point, run the dynamic optimizer. + for interstitial_point in candidate_interstitial_points: + initial_centers_for_optimizer = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 # The interstitial circle is always the last one added + + # Initialize and run the dynamic packing optimizer + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers_for_optimizer, + interstitial_idx=interstitial_idx, + num_circles=n_circles, + num_steps=2000, + initial_learning_rate=0.015, + central_fixed=True) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best configuration found. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +======= +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + # Define search space for grid parameters and central weight + sc_options = np.array([0.09, 0.1, 0.11]) + central_weight_options = np.linspace(1.2, 2.2, 4) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_indices_to_pass = list(range(num_fixed_central + num_peripheral_to_select, n_circles)) + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc in sc_options: + ec = 1.0 - sc # Enforce symmetry for a more focused search + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec, sc, ec, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + # Pruning: if not enough points, skip + if len(peripheral_grid_points) < num_peripheral_to_select or len(all_interstitial_candidates) < num_interstitial_to_select: + continue + + # Iterate through combinations of peripheral and interstitial points + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.vstack(([central_point], selected_peripheral_points, selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + # Initialize with the best result from the coarse search + best_sum_radii, best_centers, w_central_best = top_candidates[0] + best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_indices_to_pass, w_central=w_central_best) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_indices_to_pass, + w_central=w_central, + num_steps=2500, # Increased steps for better refinement + initial_learning_rate=0.015, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +>>>>>>> REPLACE +<<<<<<< SEARCH +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=-1): + """ + Compute the maximum possible radii for a given set of circle centers. + Uses an iterative relaxation method for robust convergence. + Includes heuristics for weighted central circle scaling and interstitial circle capping. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # Initialize radii based on distance to boundaries + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # Iteratively resolve overlaps and expand radii + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # For simplicity, all other circles have weight 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero for tiny radii + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + # Ensure radii are non-negative, as floating point arithmetic can sometimes yield tiny negative values. + return np.maximum(radii, 0) +======= +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap radius at half distance to nearest neighbor, provides a better heuristic than a fixed value. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0dfc8222c69c3259916ebd5fce0504892bb2841f Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..782f6f76259dad0347a5e14e36641c4c7c6661ef --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/edit.diff @@ -0,0 +1,400 @@ +--- a/original.py ++++ b/original.py +@@ -1,238 +1,237 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" ++""" ++Hybrid circle packing for n=26 circles, combining a systematic combinatorial search ++for promising initial configurations with a force-directed dynamic optimizer for refinement. ++""" + + import numpy as np + import itertools + + ++class DynamicPackingOptimizer: ++ """ ++ Optimizes circle packing using a force-directed approach. Starting from an ++ initial configuration, it iteratively adjusts circle centers based on ++ repulsion forces and boundaries, while repeatedly calculating maximum radii ++ to guide the optimization towards a better packing. The central circle is ++ kept fixed to provide a stable anchor. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): ++ self.n_circles = num_circles ++ self.num_steps = num_steps ++ self.initial_learning_rate = initial_learning_rate ++ self.central_fixed = central_fixed ++ ++ self.centers = np.copy(initial_centers) ++ self.interstitial_indices = interstitial_indices ++ self.w_central = w_central ++ self.central_idx = 0 # The central circle is at index 0 by convention ++ ++ # Initialize best configuration with max radii for the starting layout ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ self.best_sum_radii = np.sum(self.radii) ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(self.radii) ++ ++ def optimize(self): ++ """Runs the force-directed optimization loop.""" ++ for step in range(self.num_steps): ++ # Linearly decay the learning rate ++ learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) ++ learning_rate = max(learning_rate, 1e-7) ++ ++ # Adaptively determine iteration count for radii calculation ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ ++ # Periodically check for improvement with a full, accurate radius calculation ++ if step % 50 == 0 or step == self.num_steps - 1: ++ test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ current_sum_radii = np.sum(test_radii) ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(test_radii) ++ ++ # --- Calculate force vectors for center movement --- ++ force_vectors = np.zeros_like(self.centers) ++ ++ # 1. Repulsion between circles ++ buffer_factor = 0.05 # Apply force even before contact for smoother movement ++ for i in range(self.n_circles): ++ for j in range(i + 1, self.n_circles): ++ dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) ++ target_dist = current_radii[i] + current_radii[j] ++ if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: ++ overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) ++ direction = (self.centers[i] - self.centers[j]) / dist_ij ++ force_vectors[i] += direction * overlap_factor ++ force_vectors[j] -= direction * overlap_factor ++ ++ # 2. Boundary repulsion forces ++ K_boundary = 10.0 # Strong boundary force ++ for i in range(self.n_circles): ++ x, y = self.centers[i] ++ r = current_radii[i] ++ if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) ++ if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) ++ if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) ++ if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) ++ ++ # --- Update centers --- ++ self.centers += learning_rate * force_vectors ++ ++ if self.central_fixed: ++ self.centers[self.central_idx] = np.array([0.5, 0.5]) ++ ++ # Clip centers to ensure they stay within radius distance of boundaries ++ for i in range(self.n_circles): ++ r = current_radii[i] ++ self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) ++ self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) ++ ++ return self.best_centers, self.best_radii ++ ++ + def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates centers for a square grid of circles with potentially asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the square grid. +- sc_x (float): The starting x-coordinate for linspace. +- ec_x (float): The ending x-coordinate for linspace. +- sc_y (float): The starting y-coordinate for linspace. +- ec_y (float): The ending y-coordinate for linspace. +- +- Returns: +- np.array: An array of (x, y) coordinates for the grid centers. +- """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) +- grid_centers = [] +- for y in y_coords: +- for x in x_coords: +- grid_centers.append([x, y]) +- return np.array(grid_centers) ++ return np.array([[x, y] for y in y_coords for x in x_coords]) + + + def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates potential interstitial points within the grid formed by _generate_grid_centers, +- with potentially asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the base grid. +- sc_x (float): The starting x-coordinate of the grid. +- ec_x (float): The ending x-coordinate of the grid. +- sc_y (float): The starting y-coordinate of the grid. +- ec_y (float): The ending y-coordinate of the grid. +- +- Returns: +- np.array: An array of (x, y) coordinates for the candidate interstitial centers. +- """ + if grid_size < 2: + return np.array([]) +- + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) +- + candidates = [] +- # Interstitial points are halfway between grid points +- for i in range(grid_size - 1): # y-indices +- for j in range(grid_size - 1): # x-indices +- interstitial_x = sc_x + j * step_x + step_x / 2 +- interstitial_y = sc_y + i * step_y + step_y / 2 +- candidates.append([interstitial_x, interstitial_y]) ++ for i in range(grid_size - 1): ++ for j in range(grid_size - 1): ++ candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): +- """ +- Compute maximum radii using an iterative relaxation approach. Includes a +- heuristic for interstitial circles and weighted scaling for the central one. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates. +- max_iterations: Maximum iterations for the relaxation process. +- tolerance: Convergence tolerance. +- interstitial_indices: A list of indices for interstitial circles to apply +- an adaptive initial radius heuristic. Defaults to None. +- w_central (float): Weight factor for the central circle during overlap resolution. +- +- Returns: +- np.array: Array of radii for each circle. +- """ + n = centers.shape[0] + radii = np.zeros(n) +- +- # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). +- # This prevents them from growing too large initially and sub-optimally +- # squeezing their neighbors, allowing for a better overall packing. + if interstitial_indices is not None: + for idx in interstitial_indices: +- if idx < n: # Ensure index is valid ++ if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) +- # Cap the initial radius to half the distance to the nearest neighbor. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + +- # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) +- + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) +- + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist +- +- # Weighted proportional scaling to protect the central circle (at index 0). +- # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. +- # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. +- w_i = w_central if i == 0 else 1.0 # Central circle (index 0) is protected +- w_j = 1.0 # Other circles have normal weight +- ++ w_i = w_central if i == 0 else 1.0 ++ w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j +- + total_weighted_radii = weighted_r_i + weighted_r_j +- +- if total_weighted_radii > 1e-12: # Avoid division by zero ++ if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- else: +- # Fallback for extremely tiny radii sums (should be rare) +- # Just scale down proportionally to prevent infinite loop or negative radii +- scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 +- radii[i] *= scale_factor +- radii[j] *= scale_factor +- +- # Ensure no radii become negative + radii[radii < 0] = 0 +- + if np.allclose(radii, prev_radii, atol=tolerance): + break +- +- return radii ++ return np.maximum(radii, 0) + + + def construct_packing(): + """ +- Construct a specific arrangement of 26 circles in a unit square +- that attempts to maximize the sum of their radii by re-instating the +- powerful `1+23+2` combinatorial search strategy. +- It places: +- - 1 fixed central circle. +- - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). +- - 2 interstitial circles, chosen from the 16 available interstitial candidate positions. +- This version also optimizes grid boundary parameters and the central circle's weight. +- +- Returns: +- Tuple of (centers, radii) ++ Constructs an arrangement of 26 circles using a two-stage hybrid process: ++ 1. A broad combinatorial search finds promising initial topologies. ++ 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 +- +- # Ranges for optimizing grid boundaries and central weight. +- # Asymmetric grid boundary options (re-instated from prior successful versions) +- sc_options_x = np.array([0.09, 0.1, 0.11]) +- ec_options_x = np.array([0.89, 0.9, 0.91]) +- sc_options_y = np.array([0.09, 0.1, 0.11]) +- ec_options_y = np.array([0.89, 0.9, 0.91]) +- +- central_weight_options = np.linspace(1.5, 2.5, 3) # [1.5, 2.0, 2.5] +- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None ++ ++ # Stage 1 Parameters ++ sc_options = np.array([0.09, 0.1, 0.11]) ++ ec_options = np.array([0.89, 0.9, 0.91]) ++ central_weight_options = np.linspace(1.2, 2.2, 3) ++ TOP_N_CANDIDATES = 15 ++ top_candidates = [] + + num_fixed_central = 1 +- num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 ++ num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 +- +- interstitial_circle_indices_to_pass = [ +- num_fixed_central + num_peripheral_to_select, +- num_fixed_central + num_peripheral_to_select + 1 +- ] +- ++ interstitial_circle_indices = list(range(1 + num_peripheral_to_select, n_circles)) ++ ++ # STAGE 1: Coarse Combinatorial Search for promising initial configurations + for w_central in central_weight_options: +- for sc_x in sc_options_x: +- for ec_x in ec_options_x: +- # Ensure end_coord > start_coord and grid is centered along X +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): +- continue +- for sc_y in sc_options_y: +- for ec_y in ec_options_y: +- # Ensure end_coord > start_coord and grid is centered along Y +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): +- continue ++ for sc_x in sc_options: ++ for ec_x in ec_options: ++ if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue ++ for sc_y in sc_options: ++ for ec_y in ec_options: ++ if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) +- +- peripheral_grid_points = [] +- for center in all_grid_centers: +- if not np.allclose(center, central_point): +- peripheral_grid_points.append(center) +- peripheral_grid_points = np.array(peripheral_grid_points) +- +- # C(24, 23) combinations for peripheral points +- for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] +- +- # C(16, 2) combinations for interstitial points +- for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] +- +- # Construct the full set of 26 centers +- current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) +- current_centers = np.array(current_centers_list) +- +- # Compute radii for this configuration +- current_radii = compute_max_radii( +- current_centers, +- interstitial_indices=interstitial_circle_indices_to_pass, +- w_central=w_central +- ) +- current_sum_radii = np.sum(current_radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii ++ peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) ++ ++ for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): ++ selected_peripheral = peripheral_grid_points[list(p_indices)] ++ for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): ++ selected_interstitial = all_interstitial_candidates[list(i_indices)] ++ current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) ++ ++ coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=interstitial_circle_indices, w_central=w_central) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ if len(top_candidates) < TOP_N_CANDIDATES: ++ top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ elif coarse_sum_radii > top_candidates[-1][0]: ++ top_candidates.pop() ++ top_candidates.append((coarse_sum_radii, current_centers, w_central)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ ++ # STAGE 2: Refine Top Candidates with Dynamic Optimizer ++ if not top_candidates: ++ return np.random.rand(n_circles, 2), np.zeros(n_circles) ++ ++ best_sum_radii = 0.0 ++ best_centers = top_candidates[0][1] ++ best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) ++ best_sum_radii = np.sum(best_radii) ++ ++ for _, initial_centers, w_central in top_candidates: ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=initial_centers, ++ interstitial_indices=interstitial_circle_indices, ++ w_central=w_central ++ ) ++ optimized_centers, optimized_radii = optimizer.optimize() ++ current_sum_radii = np.sum(optimized_radii) ++ ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = optimized_centers ++ best_radii = optimized_radii + + return best_centers, best_radii +- + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/main.py new file mode 100644 index 0000000000000000000000000000000000000000..863dda41ac616ad8aa577b60682725aab8bd55f5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/main.py @@ -0,0 +1,237 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic combinatorial search +for promising initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. The central circle is + kept fixed to provide a stable anchor. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + if grid_size < 2: + return np.array([]) + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices is not None: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return np.maximum(radii, 0) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + + # Stage 1 Parameters + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + TOP_N_CANDIDATES = 15 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + interstitial_circle_indices = list(range(1 + num_peripheral_to_select, n_circles)) + + # STAGE 1: Coarse Combinatorial Search for promising initial configurations + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices)] + for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(i_indices)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=interstitial_circle_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = 0.0 + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/original.py new file mode 100644 index 0000000000000000000000000000000000000000..a4b8b8ae793a08b9896dc8b18c0c59d09c2f4f33 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/original.py @@ -0,0 +1,238 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with potentially asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + sc_x (float): The starting x-coordinate for linspace. + ec_x (float): The ending x-coordinate for linspace. + sc_y (float): The starting y-coordinate for linspace. + ec_y (float): The ending y-coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers, + with potentially asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + sc_x (float): The starting x-coordinate of the grid. + ec_x (float): The ending x-coordinate of the grid. + sc_y (float): The starting y-coordinate of the grid. + ec_y (float): The ending y-coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + # This prevents them from growing too large initially and sub-optimally + # squeezing their neighbors, allowing for a better overall packing. + if interstitial_indices is not None: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to half the distance to the nearest neighbor. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + w_i = w_central if i == 0 else 1.0 # Central circle (index 0) is protected + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii by re-instating the + powerful `1+23+2` combinatorial search strategy. + It places: + - 1 fixed central circle. + - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). + - 2 interstitial circles, chosen from the 16 available interstitial candidate positions. + This version also optimizes grid boundary parameters and the central circle's weight. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + # Ranges for optimizing grid boundaries and central weight. + # Asymmetric grid boundary options (re-instated from prior successful versions) + sc_options_x = np.array([0.09, 0.1, 0.11]) + ec_options_x = np.array([0.89, 0.9, 0.91]) + sc_options_y = np.array([0.09, 0.1, 0.11]) + ec_options_y = np.array([0.89, 0.9, 0.91]) + + central_weight_options = np.linspace(1.5, 2.5, 3) # [1.5, 2.0, 2.5] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + for w_central in central_weight_options: + for sc_x in sc_options_x: + for ec_x in ec_options_x: + # Ensure end_coord > start_coord and grid is centered along X + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + for sc_y in sc_options_y: + for ec_y in ec_options_y: + # Ensure end_coord > start_coord and grid is centered along Y + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) + + # C(24, 23) combinations for peripheral points + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + # C(16, 2) combinations for interstitial points + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Construct the full set of 26 centers + current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) + current_centers = np.array(current_centers_list) + + # Compute radii for this configuration + current_radii = compute_max_radii( + current_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central + ) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f0c199bc5a3051f4992fec9c318933f92192919f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9002664109167563, + "spatial_uniformity_details": { + "cell_size_mean": 0.20319367687907505, + "cell_size_std": 0.022510264215309616, + "coefficient_of_variation": 0.11078230607502444 + }, + "edge_utilization": 0.8, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 13, + "corner_score": 1.0, + "edge_score": 0.5 + }, + "density_variance": 0.5866962887478102, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0005801750256959895, + "mean_density": 0.03419192391063286, + "cv": 0.7044593926685758 + }, + "packing_efficiency": 0.7374859782474821, + "packing_efficiency_details": { + "total_area": 0.7374859782474821, + "square_area": 1.0, + "efficiency": 0.7374859782474821, + "relative_to_estimated_best": 0.8779594979136691 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.08955446133856726, + "std": 0.031761755916530715, + "min": 0.0003014256069998983, + "max": 0.1628427995253594, + "range": 0.16254137391835952, + "small_count": 5, + "medium_count": 15, + "large_count": 6, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.742, + "gap_analysis_details": { + "covered_samples": 1855, + "total_samples": 2500, + "coverage": 0.742, + "gap_ratio": 0.258 + }, + "geometric_quality": 0.6613439657108249, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6613439657108249, + "min_quality": 0.30276344657827353, + "max_quality": 0.9206428353794938 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..4a4f88b026ab3b6fc407ac633aa3ed155d3908c2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 301.78 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3284 + + Auxiliary Metrics: + • spatial_uniformity: 0.900 + • edge_utilization: 0.800 + • density_variance: 0.587 + • packing_efficiency: 0.737 + • radius_distribution: 0.885 + • gap_analysis: 0.742 + • geometric_quality: 0.661 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3284 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.900 + • Boundary and corner utilization: 0.800 + • Area utilization efficiency: 0.737 + • Area coverage (1 - gap ratio): 0.742 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.587 + • Radius size diversity: 0.885 + • Delaunay triangulation quality: 0.661 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..839b488e549e5d7123e38414846c4174df16616b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3284159948027487, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1003, 0.0862)\n centers[2] = (0.3001, 0.0995)\n centers[3] = (0.4276, 0.0748)\n centers[4] = (0.7544, 0.0532)\n centers[5] = (0.9017, 0.0989)\n centers[6] = (0.0964, 0.2739)\n centers[7] = (0.2834, 0.2459)\n centers[8] = (0.5993, 0.1210)\n centers[9] = (0.9421, 0.2569)\n centers[10] = (0.0831, 0.4599)\n centers[11] = (0.2477, 0.4924)\n centers[12] = (0.7466, 0.3465)\n centers[13] = (0.9059, 0.5343)\n centers[14] = (0.0003, 0.6983)\n centers[15] = (0.1394, 0.6828)\n centers[16] = (0.3955, 0.6873)\n centers[17] = (0.6764, 0.6640)\n centers[18] = (0.9180, 0.7158)\n centers[19] = (0.0914, 0.9086)\n centers[20] = (0.2901, 0.9003)\n centers[21] = (0.5066, 0.8917)\n centers[22] = (0.7082, 0.9138)\n centers[23] = (0.9006, 0.9006)\n centers[24] = (0.3720, 0.3921)\n centers[25] = (0.5109, 0.3032)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9002664109167563, + "aux_edge_utilization": 0.8, + "aux_density_variance": 0.5866962887478102, + "aux_packing_efficiency": 0.7374859782474821, + "aux_radius_distribution": 0.8854530804755598, + "aux_gap_analysis": 0.742, + "aux_geometric_quality": 0.6613439657108249 + }, + "private": { + "reported_sum_of_radii": 2.3284159948027487 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3284\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.900\n \u2022 Boundary and corner utilization: 0.800\n \u2022 Area utilization efficiency: 0.737\n \u2022 Area coverage (1 - gap ratio): 0.742\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.587\n \u2022 Radius size diversity: 0.885\n \u2022 Delaunay triangulation quality: 0.661\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/results/packing_viz.png", + "execution_time_mean": 301.77516125375405, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..bb89eb61cc7ff261ea7970de8c5f16f6210d89ed --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_142/rewrite.txt @@ -0,0 +1,228 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic combinatorial search +for promising initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. The central circle is + kept fixed to provide a stable anchor. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + if grid_size < 2: + return np.array([]) + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices is not None: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return np.maximum(radii, 0) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + + # Stage 1 Parameters + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + TOP_N_CANDIDATES = 15 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + interstitial_circle_indices = list(range(1 + num_peripheral_to_select, n_circles)) + + # STAGE 1: Coarse Combinatorial Search for promising initial configurations + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices)] + for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(i_indices)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=interstitial_circle_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = 0.0 + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e97e9655bf619ba5a34e195bdf8cc454d620233b Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..009382d393a533d91d7c37ee5eb2345ea4cb2633 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/edit.diff @@ -0,0 +1,270 @@ +--- a/original.py ++++ b/original.py +@@ -1,257 +1,259 @@ + # EVOLVE-BLOCK-START + """ + Constructor-based circle packing for n=26 circles using a two-stage hybrid + optimization strategy. It combines a broad combinatorial search for initial + topologies with a deep, force-directed refinement of the best candidates. + """ + + import numpy as np + from itertools import combinations + + + class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version includes a restoring force for the central circle and uses weighted radius relaxation. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=2500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + if learning_rate < 1e-7: + learning_rate = 1e-7 + +- # Adaptive parameters that decay over the optimization process ++ # Adaptive parameters that change over the optimization process + decay_factor = 1 - progress_ratio +- buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor +- K_boundary = 5.0 + (15.0 - 5.0) * decay_factor +- K_center = 2.0 + (10.0 - 2.0) * decay_factor +- +- # Use fewer iterations for speed during intermediate steps. +- radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 ++ buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Buffer decreases for tighter packing ++ ++ # Force constants increase over time for more precise final arrangement ++ K_boundary = 5.0 + (15.0 - 5.0) * progress_ratio ++ K_center = 2.0 + (10.0 - 2.0) * progress_ratio ++ ++ # Use more iterations for radius calculation as the packing gets tighter ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 25 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force pulling the central circle towards the geometric center + center_pos = self.centers[self.central_idx] + center_offset = np.array([0.5, 0.5]) - center_pos + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] # Use the quickly computed radii for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + + def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search over `1+23+2` configurations, optimizing for + grid spacing and central circle weight. + 2. A deep dynamic refinement of the top N best configurations found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 10 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 5) # Expanded search space +- w_central_search_space = np.array([1.5, 2.0, 2.5]) ++ w_central_search_space = np.array([1.5, 2.0, 2.5, 3.0]) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] + if not central_idx_in_grid_list.size: continue # Should not happen with centered grids + central_idx_in_grid = central_idx_in_grid_list[0] + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + interstitial_candidates = _generate_interstitial_candidates(grid_size + 1, start_coord, end_coord) + num_interstitial_cand = len(interstitial_candidates) + + # Loop over removing 1 of 24 peripheral points + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Loop over pairs of interstitial candidates + for i, j in combinations(range(num_interstitial_cand), 2): + interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation with fewer iterations and central weight + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + # Maintain a list of the top N configurations + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: # Fallback in case no configs were generated + # A reasonable fallback: a 5x5 grid with one corner removed and one interstitial + centers = _generate_grid_centers(5, 0.1, 0.9) + centers = np.vstack([centers[:24], [0.2, 0.2]])[:26] + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + num_steps=2500, + initial_learning_rate=0.01) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of interstitial circle(s). + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + # Use an adaptive heuristic based on distance to nearest neighbor + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + # Iteratively adjust radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/main.py new file mode 100644 index 0000000000000000000000000000000000000000..efc47ef44881b3d68564de8651592e1ed1e3f92a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/main.py @@ -0,0 +1,259 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a two-stage hybrid +optimization strategy. It combines a broad combinatorial search for initial +topologies with a deep, force-directed refinement of the best candidates. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version includes a restoring force for the central circle and uses weighted radius relaxation. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=2500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Adaptive parameters that change over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Buffer decreases for tighter packing + + # Force constants increase over time for more precise final arrangement + K_boundary = 5.0 + (15.0 - 5.0) * progress_ratio + K_center = 2.0 + (10.0 - 2.0) * progress_ratio + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 25 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force pulling the central circle towards the geometric center + center_pos = self.centers[self.central_idx] + center_offset = np.array([0.5, 0.5]) - center_pos + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] # Use the quickly computed radii for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search over `1+23+2` configurations, optimizing for + grid spacing and central circle weight. + 2. A deep dynamic refinement of the top N best configurations found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 10 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 5) # Expanded search space + w_central_search_space = np.array([1.5, 2.0, 2.5, 3.0]) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] + if not central_idx_in_grid_list.size: continue # Should not happen with centered grids + central_idx_in_grid = central_idx_in_grid_list[0] + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + interstitial_candidates = _generate_interstitial_candidates(grid_size + 1, start_coord, end_coord) + num_interstitial_cand = len(interstitial_candidates) + + # Loop over removing 1 of 24 peripheral points + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Loop over pairs of interstitial candidates + for i, j in combinations(range(num_interstitial_cand), 2): + interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation with fewer iterations and central weight + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + # Maintain a list of the top N configurations + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: # Fallback in case no configs were generated + # A reasonable fallback: a 5x5 grid with one corner removed and one interstitial + centers = _generate_grid_centers(5, 0.1, 0.9) + centers = np.vstack([centers[:24], [0.2, 0.2]])[:26] + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + num_steps=2500, + initial_learning_rate=0.01) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of interstitial circle(s). + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + # Use an adaptive heuristic based on distance to nearest neighbor + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + # Iteratively adjust radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/original.py new file mode 100644 index 0000000000000000000000000000000000000000..ab2a51680bfc2e4294701177a1095b0857be148b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/original.py @@ -0,0 +1,257 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a two-stage hybrid +optimization strategy. It combines a broad combinatorial search for initial +topologies with a deep, force-directed refinement of the best candidates. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version includes a restoring force for the central circle and uses weighted radius relaxation. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=2500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Adaptive parameters that decay over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor + K_boundary = 5.0 + (15.0 - 5.0) * decay_factor + K_center = 2.0 + (10.0 - 2.0) * decay_factor + + # Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 25 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force pulling the central circle towards the geometric center + center_pos = self.centers[self.central_idx] + center_offset = np.array([0.5, 0.5]) - center_pos + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] # Use the quickly computed radii for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search over `1+23+2` configurations, optimizing for + grid spacing and central circle weight. + 2. A deep dynamic refinement of the top N best configurations found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 10 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 5) # Expanded search space + w_central_search_space = np.array([1.5, 2.0, 2.5]) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] + if not central_idx_in_grid_list.size: continue # Should not happen with centered grids + central_idx_in_grid = central_idx_in_grid_list[0] + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + interstitial_candidates = _generate_interstitial_candidates(grid_size + 1, start_coord, end_coord) + num_interstitial_cand = len(interstitial_candidates) + + # Loop over removing 1 of 24 peripheral points + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Loop over pairs of interstitial candidates + for i, j in combinations(range(num_interstitial_cand), 2): + interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation with fewer iterations and central weight + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + # Maintain a list of the top N configurations + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: # Fallback in case no configs were generated + # A reasonable fallback: a 5x5 grid with one corner removed and one interstitial + centers = _generate_grid_centers(5, 0.1, 0.9) + centers = np.vstack([centers[:24], [0.2, 0.2]])[:26] + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + num_steps=2500, + initial_learning_rate=0.01) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of interstitial circle(s). + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + # Use an adaptive heuristic based on distance to nearest neighbor + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + # Iteratively adjust radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f95acd77601c447f82ac33bc0a9350a276be6e7f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8844319328556008, + "spatial_uniformity_details": { + "cell_size_mean": 0.20172281702500708, + "cell_size_std": 0.026358971574896396, + "coefficient_of_variation": 0.13066926108294175 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5673042458609039, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0005977656411874467, + "mean_density": 0.0320552273246979, + "cv": 0.7627225731097169 + }, + "packing_efficiency": 0.7296092943000779, + "packing_efficiency_details": { + "total_area": 0.7296092943000779, + "square_area": 1.0, + "efficiency": 0.7296092943000779, + "relative_to_estimated_best": 0.8685824932143785 + }, + "radius_distribution": 0.9194324210397706, + "radius_distribution_details": { + "mean": 0.08823740096753685, + "std": 0.03386059614867828, + "min": 0.0006322812504906961, + "max": 0.16809954706321, + "range": 0.1674672658127193, + "small_count": 6, + "medium_count": 14, + "large_count": 6, + "diversity_score": 0.9194324210397706 + }, + "gap_analysis": 0.7332, + "gap_analysis_details": { + "covered_samples": 1833, + "total_samples": 2500, + "coverage": 0.7332, + "gap_ratio": 0.26680000000000004 + }, + "geometric_quality": 0.6531702495997176, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6531702495997176, + "min_quality": 0.3089997372270971, + "max_quality": 0.9147545546551468 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..da4f17b355b92e75843fd725a67b0609161c419d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 422.80 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2942 + + Auxiliary Metrics: + • spatial_uniformity: 0.884 + • edge_utilization: 0.785 + • density_variance: 0.567 + • packing_efficiency: 0.730 + • radius_distribution: 0.919 + • gap_analysis: 0.733 + • geometric_quality: 0.653 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2942 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.884 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.730 + • Area coverage (1 - gap ratio): 0.733 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.567 + • Radius size diversity: 0.919 + • Delaunay triangulation quality: 0.653 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..75db60990fe4da52e7795de9034a13adbb9f0cc4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.294172425155958, + "public": { + "centers_str": " centers[0] = (0.4979, 0.4976)\n centers[1] = (0.0854, 0.0854)\n centers[2] = (0.0926, 0.3081)\n centers[3] = (0.0938, 0.4647)\n centers[4] = (0.0145, 0.7388)\n centers[5] = (0.0974, 0.8865)\n centers[6] = (0.2790, 0.0926)\n centers[7] = (0.2735, 0.3167)\n centers[8] = (0.1070, 0.6462)\n centers[9] = (0.2917, 0.9088)\n centers[10] = (0.4628, 0.0816)\n centers[11] = (0.4409, 0.2647)\n centers[12] = (0.3471, 0.6846)\n centers[13] = (0.4920, 0.8984)\n centers[14] = (0.7067, 0.0006)\n centers[15] = (0.6666, 0.1120)\n centers[16] = (0.6625, 0.3630)\n centers[17] = (0.6493, 0.6690)\n centers[18] = (0.7151, 0.9142)\n centers[19] = (0.8992, 0.0997)\n centers[20] = (0.9010, 0.2990)\n centers[21] = (0.8897, 0.5089)\n centers[22] = (0.9068, 0.7135)\n centers[23] = (0.9036, 0.9036)\n centers[24] = (0.1743, 0.2171)\n centers[25] = (0.3372, 0.4634)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8844319328556008, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5673042458609039, + "aux_packing_efficiency": 0.7296092943000779, + "aux_radius_distribution": 0.9194324210397706, + "aux_gap_analysis": 0.7332, + "aux_geometric_quality": 0.6531702495997176 + }, + "private": { + "reported_sum_of_radii": 2.294172425155958 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2942\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.884\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.730\n \u2022 Area coverage (1 - gap ratio): 0.733\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.567\n \u2022 Radius size diversity: 0.919\n \u2022 Delaunay triangulation quality: 0.653\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/results/packing_viz.png", + "execution_time_mean": 422.7989132478833, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..a30b816fbed936b5480dcb0ee064eb0ccd1f2125 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_145/search_replace.txt @@ -0,0 +1,42 @@ + +adaptive_optimizer_stiffness + + +The `DynamicPackingOptimizer` parameters for boundary and center-restoring forces (`K_boundary`, `K_center`) are reversed to increase over time, rather than decrease. This starts the optimization in a "looser" state to encourage broad exploration and gradually "stiffens" the constraints to achieve a more precise, tightly packed final configuration. This is more analogous to a simulated annealing process. Additionally, the number of iterations for the intermediate radius calculations (`radii_iter_count`) is doubled (from 50/200 to 100/400) to provide more accurate force vectors as the circles get closer and precision becomes more critical. + + +<<<<<<< SEARCH + # Adaptive parameters that decay over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor + K_boundary = 5.0 + (15.0 - 5.0) * decay_factor + K_center = 2.0 + (10.0 - 2.0) * decay_factor + + # Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 +======= + # Adaptive parameters that change over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Buffer decreases for tighter packing + + # Force constants increase over time for more precise final arrangement + K_boundary = 5.0 + (15.0 - 5.0) * progress_ratio + K_center = 2.0 + (10.0 - 2.0) * progress_ratio + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 +>>>>>>> REPLACE + + +expand_central_weight_search + + +The search space for the central circle's weight (`w_central`) in the initial combinatorial search is expanded by adding a higher value of 3.0. High-density packings often feature a few dominant circles. By increasing the weight, we encourage the exploration of initial configurations where the central circle is significantly larger, potentially creating different and more favorable starting topologies for the subsequent dynamic refinement stage to optimize. + + +<<<<<<< SEARCH + w_central_search_space = np.array([1.5, 2.0, 2.5]) +======= + w_central_search_space = np.array([1.5, 2.0, 2.5, 3.0]) +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..4b8057345d713d62bb62bc901b338dde2a4d92d8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/edit.diff @@ -0,0 +1,255 @@ +--- a/original.py ++++ b/original.py +@@ -1,237 +1,29 @@ + # EVOLVE-BLOCK-START +-""" +-Hybrid circle packing optimization for n=26 circles combining +-a combinatorial search for initial configurations with a dynamic, +-force-directed refinement stage. +-""" ++ ++modular_hybrid_optimizer ++ + +-import numpy as np +-from itertools import combinations ++ ++This redesign introduces a `CirclePackingSolver` class to encapsulate the entire optimization process, improving modularity and manageability of parameters and state. The `construct_packing` function now acts as a simple entry point, instantiating and running the solver. + ++Key improvements: ++1. **Modular Architecture:** Centralizes configuration and control flow within `CirclePackingSolver`, making the code more organized and easier to extend or modify. ++2. **Adaptive Dynamic Optimization (R2 & R5):** The `DynamicPackingOptimizer` now features smoothly decaying `buffer_factor`, `K_boundary`, and `K_center` parameters. This allows for strong initial repulsion and boundary adherence, gradually softening to enable denser packing as the optimization progresses. `num_steps` is also increased for longer refinement. ++3. **Intermediate Refinement in Combinatorial Search (R3):** A light-weight dynamic refinement step (`_perform_intermediate_refinement`) is introduced *before* the coarse evaluation of each combinatorial candidate. This pre-adjusts the centers, leading to a more accurate `coarse_sum_radii` and better initial ranking of candidates, despite the added computational cost. ++4. **Enhanced Combinatorial Search Strategy (R1 & R4):** ++ * The pool of `TOP_N_CANDIDATES_COARSE` for the combinatorial search is increased to promote broader exploration and potential diversity (R1). ++ * The `_generate_interstitial_candidates_for_range` function has been clarified to ensure it effectively generates a useful number of candidates, contributing to a richer initial search space (R4). ++5. **Parameter Consolidation:** Search space parameters for grid bounds and central weight (`w_central`) are managed within the `CirclePackingSolver` class, improving clarity. ++ + +-class DynamicPackingOptimizer: +- """ +- Optimizes circle packing using a force-directed approach with iterative radius maximization. +- This class is inspired by the successful refinement stages of parent programs. +- It takes an initial set of centers and iteratively adjusts them to find a better packing. +- """ +- def __init__(self, initial_centers, interstitial_idx, w_central, num_circles=26, num_steps=1500, initial_learning_rate=0.01): +- self.n_circles = num_circles +- self.num_steps = num_steps +- self.initial_learning_rate = initial_learning_rate +- self.w_central = w_central +- self.interstitial_idx = interstitial_idx +- self.central_idx = 0 +- +- self.centers = np.copy(initial_centers) +- +- # Initialize the best configuration with the starting one +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) +- self.best_sum_radii = np.sum(self.radii) +- self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(self.radii) +- +- def optimize(self): +- """ +- Runs the dynamic optimization process. +- """ +- for step in range(self.num_steps): +- # Annealing learning rate +- learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) +- learning_rate = max(learning_rate, 1e-7) +- +- # Use fewer iterations for speed during intermediate steps, more for final refinement. +- radii_iter_count = 50 if step < self.num_steps * 0.9 else 2000 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) +- +- # For accurate sum comparison, always use high-iteration radius calculation +- test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) +- current_sum_radii = np.sum(test_radii_for_sum) +- +- if current_sum_radii > self.best_sum_radii: +- self.best_sum_radii = current_sum_radii +- self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(test_radii_for_sum) +- +- force_vectors = np.zeros_like(self.centers) +- +- # Repulsion forces between circles +- for i in range(self.n_circles): +- for j in range(i + 1, self.n_circles): +- dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) +- target_dist = current_radii[i] + current_radii[j] +- buffer_factor = 0.05 # Ensure slight separation +- if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: +- overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) +- direction = (self.centers[i] - self.centers[j]) / dist_ij +- force_vectors[i] += direction * overlap_factor +- force_vectors[j] -= direction * overlap_factor +- +- # Boundary repulsion forces +- K_boundary = 10.0 +- for i in range(self.n_circles): +- x, y = self.centers[i] +- r = current_radii[i] +- if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) +- if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) +- if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) +- if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) +- +- # Restoring force to keep the central circle near the geometric center +- K_center = 5.0 +- center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] +- force_vectors[self.central_idx] += K_center * center_offset +- +- # Update centers +- self.centers += learning_rate * force_vectors +- +- # Clip centers to stay within bounds +- for i in range(self.n_circles): +- r = current_radii[i] +- self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) +- self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) +- +- return self.best_centers, self.best_radii +- +- +-def _generate_grid_centers(grid_size, start_coord, end_coord): +- """Generates centers for a symmetric square grid.""" +- coords = np.linspace(start_coord, end_coord, grid_size) +- return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) +- +- +-def _generate_interstitial_candidates(grid_size, start_coord, end_coord): +- """Generates potential interstitial points within the grid cells.""" +- if grid_size < 2: return np.array([]) +- step = (end_coord - start_coord) / (grid_size - 1) +- interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) +- return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): +- """Computes maximum radii using iterative relaxation.""" +- n = centers.shape[0] +- radii = np.zeros(n) +- +- for i in range(n): +- x, y = centers[i] +- radii[i] = min(x, y, 1 - x, 1 - y) +- +- if interstitial_idx is not None: +- indices = np.atleast_1d(interstitial_idx) +- for idx in indices: +- if idx < n: +- other_centers = np.delete(centers, idx, axis=0) +- if len(other_centers) > 0: +- distances = np.linalg.norm(centers[idx] - other_centers, axis=1) +- radii[idx] = min(radii[idx], 0.5 * np.min(distances)) +- +- for _ in range(max_iterations): +- prev_radii = np.copy(radii) +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.linalg.norm(centers[i] - centers[j]) +- if radii[i] + radii[j] > dist: +- overlap = radii[i] + radii[j] - dist +- w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 +- weighted_r_i = radii[i] / w_i +- weighted_r_j = radii[j] / w_j +- total_weighted = weighted_r_i + weighted_r_j +- if total_weighted > 1e-12: +- radii[i] -= overlap * (weighted_r_i / total_weighted) +- radii[j] -= overlap * (weighted_r_j / total_weighted) +- +- if np.allclose(radii, prev_radii, atol=tolerance): +- break +- +- return np.maximum(radii, 0) +- +- +-def construct_packing(): +- """ +- Constructs an arrangement of 26 circles using a two-stage hybrid process. +- """ +- n_circles = 26 +- grid_size = 5 +- top_n_to_refine = 10 +- +- # --- STAGE 1: Coarse Combinatorial Search --- +- start_coord_search_space = np.linspace(0.08, 0.12, 3) +- w_central_search_space = np.array([1.5, 2.0, 2.5]) +- top_n_configs = [] +- +- for w_central in w_central_search_space: +- for start_coord in start_coord_search_space: +- end_coord = 1.0 - start_coord +- all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) +- central_point_coords = np.array([[0.5, 0.5]]) +- +- # The 24 peripheral points are the grid points that are not the center +- potential_peripheral_centers_24 = np.array([p for p in all_grid_centers if not np.allclose(p, central_point_coords)]) +- +- # Using grid_size generates (grid_size-1)^2 = 16 interstitial candidates +- interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord) +- num_interstitial_cand = len(interstitial_candidates) +- +- # C(24, 23) combinations for peripheral points +- for p_combo in combinations(range(len(potential_peripheral_centers_24)), 23): +- current_peripheral_centers_23 = potential_peripheral_centers_24[list(p_combo)] +- +- # C(16, 2) combinations for interstitial points +- for i_combo in combinations(range(num_interstitial_cand), 2): +- interstitial_points = interstitial_candidates[list(i_combo)] +- +- # Assemble config: 1 central, 23 peripheral, 2 interstitial +- current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) +- interstitial_indices = [n_circles - 2, n_circles - 1] +- +- # Fast evaluation for ranking +- radii = compute_max_radii(current_centers, max_iterations=500, interstitial_idx=interstitial_indices, w_central=w_central) +- sum_r = np.sum(radii) +- +- if len(top_n_configs) < top_n_to_refine: +- top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) +- top_n_configs.sort(key=lambda x: x[0], reverse=True) +- elif sum_r > top_n_configs[-1][0]: +- top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) +- top_n_configs.sort(key=lambda x: x[0], reverse=True) +- +- # --- STAGE 2: Dynamic Refinement --- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None +- +- if not top_n_configs: # Fallback +- centers = _generate_grid_centers(5, 0.1, 0.9) +- centers = np.vstack([centers[:24], [0.2, 0.2], [0.8, 0.8]])[:26] +- radii = compute_max_radii(centers) +- return centers, radii +- +- for _, centers, interstitial_idx, w_central in top_n_configs: +- optimizer = DynamicPackingOptimizer(initial_centers=centers, +- interstitial_idx=interstitial_idx, +- w_central=w_central, +- num_circles=n_circles, +- num_steps=1500, +- initial_learning_rate=0.01) +- +- optimized_centers, optimized_radii = optimizer.optimize() +- current_sum_radii = np.sum(optimized_radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = optimized_centers +- best_radii = optimized_radii +- +- return best_centers, best_radii ++ + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/main.py new file mode 100644 index 0000000000000000000000000000000000000000..8832dcf2b912efdb055fbd879c42a519695d77c2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/main.py @@ -0,0 +1,29 @@ +# EVOLVE-BLOCK-START + +modular_hybrid_optimizer + + + +This redesign introduces a `CirclePackingSolver` class to encapsulate the entire optimization process, improving modularity and manageability of parameters and state. The `construct_packing` function now acts as a simple entry point, instantiating and running the solver. + +Key improvements: +1. **Modular Architecture:** Centralizes configuration and control flow within `CirclePackingSolver`, making the code more organized and easier to extend or modify. +2. **Adaptive Dynamic Optimization (R2 & R5):** The `DynamicPackingOptimizer` now features smoothly decaying `buffer_factor`, `K_boundary`, and `K_center` parameters. This allows for strong initial repulsion and boundary adherence, gradually softening to enable denser packing as the optimization progresses. `num_steps` is also increased for longer refinement. +3. **Intermediate Refinement in Combinatorial Search (R3):** A light-weight dynamic refinement step (`_perform_intermediate_refinement`) is introduced *before* the coarse evaluation of each combinatorial candidate. This pre-adjusts the centers, leading to a more accurate `coarse_sum_radii` and better initial ranking of candidates, despite the added computational cost. +4. **Enhanced Combinatorial Search Strategy (R1 & R4):** + * The pool of `TOP_N_CANDIDATES_COARSE` for the combinatorial search is increased to promote broader exploration and potential diversity (R1). + * The `_generate_interstitial_candidates_for_range` function has been clarified to ensure it effectively generates a useful number of candidates, contributing to a richer initial search space (R4). +5. **Parameter Consolidation:** Search space parameters for grid bounds and central weight (`w_central`) are managed within the `CirclePackingSolver` class, improving clarity. + + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/original.py new file mode 100644 index 0000000000000000000000000000000000000000..8de8125d69362424e6c2e951f0e23ceb9e799917 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/original.py @@ -0,0 +1,237 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing optimization for n=26 circles combining +a combinatorial search for initial configurations with a dynamic, +force-directed refinement stage. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This class is inspired by the successful refinement stages of parent programs. + It takes an initial set of centers and iteratively adjusts them to find a better packing. + """ + def __init__(self, initial_centers, interstitial_idx, w_central, num_circles=26, num_steps=1500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + self.centers = np.copy(initial_centers) + + # Initialize the best configuration with the starting one + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """ + Runs the dynamic optimization process. + """ + for step in range(self.num_steps): + # Annealing learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Use fewer iterations for speed during intermediate steps, more for final refinement. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 2000 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # For accurate sum comparison, always use high-iteration radius calculation + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + force_vectors = np.zeros_like(self.centers) + + # Repulsion forces between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + buffer_factor = 0.05 # Ensure slight separation + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Restoring force to keep the central circle near the geometric center + K_center = 5.0 + center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers + self.centers += learning_rate * force_vectors + + # Clip centers to stay within bounds + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a symmetric square grid.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """Generates potential interstitial points within the grid cells.""" + if grid_size < 2: return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """Computes maximum radii using iterative relaxation.""" + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 10 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 3) + w_central_search_space = np.array([1.5, 2.0, 2.5]) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + + # The 24 peripheral points are the grid points that are not the center + potential_peripheral_centers_24 = np.array([p for p in all_grid_centers if not np.allclose(p, central_point_coords)]) + + # Using grid_size generates (grid_size-1)^2 = 16 interstitial candidates + interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + num_interstitial_cand = len(interstitial_candidates) + + # C(24, 23) combinations for peripheral points + for p_combo in combinations(range(len(potential_peripheral_centers_24)), 23): + current_peripheral_centers_23 = potential_peripheral_centers_24[list(p_combo)] + + # C(16, 2) combinations for interstitial points + for i_combo in combinations(range(num_interstitial_cand), 2): + interstitial_points = interstitial_candidates[list(i_combo)] + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation for ranking + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: # Fallback + centers = _generate_grid_centers(5, 0.1, 0.9) + centers = np.vstack([centers[:24], [0.2, 0.2], [0.8, 0.8]])[:26] + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + num_steps=1500, + initial_learning_rate=0.01) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..571a51e01c1fa9eec3a24b50195615cc3de2ec16 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": false, + "error": "invalid syntax (main.py, line 2)" +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..77842fadf6ac5ff02c77c987b01c22845806515e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/job_log.out @@ -0,0 +1,35 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results +Auxiliary Metrics: ENABLED +====================================================================== + +Evaluation error: invalid syntax (main.py, line 2) +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/metrics.json + +====================================================================== +❌ EVALUATION FAILED +Error: invalid syntax (main.py, line 2) +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 0.0000 + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..fec2021a6a036637c9d3049ae9778c77cef78421 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/results/metrics.json @@ -0,0 +1,9 @@ +{ + "combined_score": 0.0, + "execution_time_mean": 0.0, + "execution_time_std": 0.0, + "num_successful_runs": 0, + "num_valid_runs": 0, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..70d07e2650ad9da2cd871f81d28608331b2d064b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_147/rewrite.txt @@ -0,0 +1,18 @@ + +modular_hybrid_optimizer + + + +This redesign introduces a `CirclePackingSolver` class to encapsulate the entire optimization process, improving modularity and manageability of parameters and state. The `construct_packing` function now acts as a simple entry point, instantiating and running the solver. + +Key improvements: +1. **Modular Architecture:** Centralizes configuration and control flow within `CirclePackingSolver`, making the code more organized and easier to extend or modify. +2. **Adaptive Dynamic Optimization (R2 & R5):** The `DynamicPackingOptimizer` now features smoothly decaying `buffer_factor`, `K_boundary`, and `K_center` parameters. This allows for strong initial repulsion and boundary adherence, gradually softening to enable denser packing as the optimization progresses. `num_steps` is also increased for longer refinement. +3. **Intermediate Refinement in Combinatorial Search (R3):** A light-weight dynamic refinement step (`_perform_intermediate_refinement`) is introduced *before* the coarse evaluation of each combinatorial candidate. This pre-adjusts the centers, leading to a more accurate `coarse_sum_radii` and better initial ranking of candidates, despite the added computational cost. +4. **Enhanced Combinatorial Search Strategy (R1 & R4):** + * The pool of `TOP_N_CANDIDATES_COARSE` for the combinatorial search is increased to promote broader exploration and potential diversity (R1). + * The `_generate_interstitial_candidates_for_range` function has been clarified to ensure it effectively generates a useful number of candidates, contributing to a richer initial search space (R4). +5. **Parameter Consolidation:** Search space parameters for grid bounds and central weight (`w_central`) are managed within the `CirclePackingSolver` class, improving clarity. + + + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..191e5d2e52fca61a62c6a975266774a52e226456 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f445cd5b8f5fe17b8199614425116b4f60d995d6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8642023288949685, + "spatial_uniformity_details": { + "cell_size_mean": 0.20126046668184025, + "cell_size_std": 0.03162535193772316, + "coefficient_of_variation": 0.15713643271324226 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5465594836505738, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0009114772564249228, + "mean_density": 0.03639066714721834, + "cv": 0.8296270212362092 + }, + "packing_efficiency": 0.7484248327199299, + "packing_efficiency_details": { + "total_area": 0.7484248327199299, + "square_area": 1.0, + "efficiency": 0.7484248327199299, + "relative_to_estimated_best": 0.8909819437142023 + }, + "radius_distribution": 0.9629470128958899, + "radius_distribution_details": { + "mean": 0.08915983788709608, + "std": 0.034831809802369114, + "min": 0.003079504206130831, + "max": 0.17384890830896355, + "range": 0.17076940410283273, + "small_count": 8, + "medium_count": 12, + "large_count": 6, + "diversity_score": 0.9629470128958899 + }, + "gap_analysis": 0.754, + "gap_analysis_details": { + "covered_samples": 1885, + "total_samples": 2500, + "coverage": 0.754, + "gap_ratio": 0.246 + }, + "geometric_quality": 0.6735853959170799, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6735853959170799, + "min_quality": 0.3271947227356239, + "max_quality": 0.9583066607401381 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..6cc23796fffa5808abeebcc82313fe01c6c48844 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 272.38 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3182 + + Auxiliary Metrics: + • spatial_uniformity: 0.864 + • edge_utilization: 0.785 + • density_variance: 0.547 + • packing_efficiency: 0.748 + • radius_distribution: 0.963 + • gap_analysis: 0.754 + • geometric_quality: 0.674 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3182 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.864 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.748 + • Area coverage (1 - gap ratio): 0.754 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.547 + • Radius size diversity: 0.963 + • Delaunay triangulation quality: 0.674 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..32ad6951105debcf227c3beb81234563065860b7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3181557850644983, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1006, 0.0930)\n centers[2] = (0.2671, 0.0655)\n centers[3] = (0.5007, 0.0893)\n centers[4] = (0.6786, 0.0622)\n centers[5] = (0.8990, 0.1002)\n centers[6] = (0.0949, 0.2955)\n centers[7] = (0.2711, 0.2379)\n centers[8] = (0.4417, 0.2512)\n centers[9] = (0.9268, 0.2859)\n centers[10] = (0.0660, 0.4718)\n centers[11] = (0.2557, 0.4542)\n centers[12] = (0.6821, 0.2987)\n centers[13] = (0.9039, 0.4677)\n centers[14] = (0.0031, 0.7232)\n centers[15] = (0.1252, 0.6682)\n centers[16] = (0.3866, 0.6753)\n centers[17] = (0.6894, 0.6468)\n centers[18] = (0.9258, 0.7222)\n centers[19] = (0.0991, 0.9009)\n centers[20] = (0.3005, 0.9007)\n centers[21] = (0.5129, 0.8927)\n centers[22] = (0.7145, 0.9096)\n centers[23] = (0.9039, 0.9039)\n centers[24] = (0.3778, 0.1186)\n centers[25] = (0.4305, 0.3954)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8642023288949685, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5465594836505738, + "aux_packing_efficiency": 0.7484248327199299, + "aux_radius_distribution": 0.9629470128958899, + "aux_gap_analysis": 0.754, + "aux_geometric_quality": 0.6735853959170799 + }, + "private": { + "reported_sum_of_radii": 2.3181557850644983 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3182\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.864\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.748\n \u2022 Area coverage (1 - gap ratio): 0.754\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.547\n \u2022 Radius size diversity: 0.963\n \u2022 Delaunay triangulation quality: 0.674\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_148/results/packing_viz.png", + "execution_time_mean": 272.37510333489627, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3c89c2896fe85708d6d2f73ad4dd3df2e50bca15 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..e390536e4806e9202214861b0ecbbb4799486dc7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8829902949200347, + "spatial_uniformity_details": { + "cell_size_mean": 0.20176326587550117, + "cell_size_std": 0.026736715554966248, + "coefficient_of_variation": 0.13251527876709215 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5626562773011233, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0006699682256808642, + "mean_density": 0.03330023981133587, + "cv": 0.7772840015162903 + }, + "packing_efficiency": 0.7326755394496178, + "packing_efficiency_details": { + "total_area": 0.7326755394496178, + "square_area": 1.0, + "efficiency": 0.7326755394496178, + "relative_to_estimated_best": 0.8722327850590689 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.08815740652577833, + "std": 0.0346148762554707, + "min": 0.0006606977168351407, + "max": 0.17160440838775085, + "range": 0.1709437106709157, + "small_count": 6, + "medium_count": 15, + "large_count": 5, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.7376, + "gap_analysis_details": { + "covered_samples": 1844, + "total_samples": 2500, + "coverage": 0.7376, + "gap_ratio": 0.26239999999999997 + }, + "geometric_quality": 0.65092848630219, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.65092848630219, + "min_quality": 0.3090308272653143, + "max_quality": 0.9299700708306973 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..85d17620a0f0c59667f1d0465007bd4b6d803020 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 349.63 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2921 + + Auxiliary Metrics: + • spatial_uniformity: 0.883 + • edge_utilization: 0.785 + • density_variance: 0.563 + • packing_efficiency: 0.733 + • radius_distribution: 0.885 + • gap_analysis: 0.738 + • geometric_quality: 0.651 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2921 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.883 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.733 + • Area coverage (1 - gap ratio): 0.738 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.563 + • Radius size diversity: 0.885 + • Delaunay triangulation quality: 0.651 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..2ab047fdea90c340f7878c1a561548d9f2572b65 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2920925696702366, + "public": { + "centers_str": " centers[0] = (0.4974, 0.4978)\n centers[1] = (0.0854, 0.0854)\n centers[2] = (0.3083, 0.0925)\n centers[3] = (0.4653, 0.0936)\n centers[4] = (0.7374, 0.0132)\n centers[5] = (0.8861, 0.0976)\n centers[6] = (0.0926, 0.2791)\n centers[7] = (0.3194, 0.2751)\n centers[8] = (0.6409, 0.1019)\n centers[9] = (0.9084, 0.2905)\n centers[10] = (0.0811, 0.4625)\n centers[11] = (0.2633, 0.4392)\n centers[12] = (0.6816, 0.3391)\n centers[13] = (0.8984, 0.4883)\n centers[14] = (0.0007, 0.7068)\n centers[15] = (0.1091, 0.6669)\n centers[16] = (0.3592, 0.6627)\n centers[17] = (0.6715, 0.6480)\n centers[18] = (0.9162, 0.7211)\n centers[19] = (0.0998, 0.8986)\n centers[20] = (0.2993, 0.9009)\n centers[21] = (0.5109, 0.8878)\n centers[22] = (0.7150, 0.9080)\n centers[23] = (0.9038, 0.9037)\n centers[24] = (0.2178, 0.1749)\n centers[25] = (0.4625, 0.3358)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8829902949200347, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5626562773011233, + "aux_packing_efficiency": 0.7326755394496178, + "aux_radius_distribution": 0.8854530804755598, + "aux_gap_analysis": 0.7376, + "aux_geometric_quality": 0.65092848630219 + }, + "private": { + "reported_sum_of_radii": 2.2920925696702366 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2921\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.883\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.733\n \u2022 Area coverage (1 - gap ratio): 0.738\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.563\n \u2022 Radius size diversity: 0.885\n \u2022 Delaunay triangulation quality: 0.651\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_149/results/packing_viz.png", + "execution_time_mean": 349.6331897438504, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c11d0827bc0edd89267ffb988a2475fc8e2e3c01 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..8c4f0d465984aae5b43b504557c3062ffe54774a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/edit.diff @@ -0,0 +1,305 @@ +--- a/original.py ++++ b/original.py +@@ -1,292 +1,294 @@ + # EVOLVE-BLOCK-START + """ + Constructor-based circle packing for n=26 circles using a two-stage hybrid + optimization strategy. It combines a broad combinatorial search for initial + topologies with a deep, force-directed refinement of the best candidates. + """ + + import numpy as np + from itertools import combinations + + + class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version includes a restoring force for the central circle and uses weighted radius relaxation. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=2500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + if learning_rate < 1e-7: + learning_rate = 1e-7 + +- # Adaptive parameters that decay over the optimization process ++ # Adaptive parameters that change over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Start higher, decay to lower +- K_boundary = 5.0 + (15.0 - 5.0) * decay_factor # Start stronger, decay to lower +- K_center = 2.0 + (10.0 - 2.0) * decay_factor # Start stronger, decay to lower ++ ++ # Force constants increase over time for a more precise final arrangement. ++ K_boundary = 5.0 + (15.0 - 5.0) * progress_ratio ++ K_center = 2.0 + (10.0 - 2.0) * progress_ratio + + # Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 2000 # Increased for final refinement + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Check if this configuration improves the best found so far + # Using the unified compute_max_radii for final sum_radii evaluation + # (only check periodically to save computation time) + if step % 25 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force pulling the central circle towards the geometric center + center_pos = self.centers[self.central_idx] + center_offset = np.array([0.5, 0.5]) - center_pos + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] # Use the quickly computed radii for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + + def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + Note: 'grid_size' here refers to the effective number of grid cells per side, + so for N grid points, you'd have (N-1) interstitial cells. + If called with (actual_grid_size + 1), it effectively generates (actual_grid_size)^2 interstitial points. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of interstitial circle(s). + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + # Use an adaptive heuristic based on distance to nearest neighbor + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + # Iteratively adjust radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search for initial topologies (1 central + 23 peripheral + 2 interstitial), + optimizing for grid spacing and central circle weight. + 2. A deep dynamic refinement using force-directed simulation on the top N best candidates. + """ + n_circles = 26 + grid_size = 5 # For the base grid of 25 centers + + # Stage 1: Coarse Combinatorial Search to identify promising initial configurations + # `start_coord_search_space` from 2.27 inspiration program. +- start_coord_search_space = np.linspace(0.08, 0.12, 3) # [0.08, 0.10, 0.12] +- # `w_central_search_space` from current program (wider range). +- w_central_search_space = np.linspace(1.5, 2.5, 3) # [1.5, 2.0, 2.5] ++ # Expanded search space for grid bounds and central weight to find better initial seeds. ++ start_coord_search_space = np.linspace(0.08, 0.12, 5) ++ w_central_search_space = np.linspace(1.5, 3.0, 4) + top_n_to_refine = 10 # Number of top configurations to pass to Stage 2 + + top_n_configs = [] # Stores (sum_r, initial_centers, interstitial_indices, w_central) + + # Define the number of circles to select for each category + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 + + # The interstitial circles will be the last two circles in the `current_centers` array. + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, # index 24 + num_fixed_central + num_peripheral_to_select + 1 # index 25 + ] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord # Enforce symmetry for grid bounds (center at 0.5) + + # Generate grid centers for the 5x5 grid + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) # The true center circle + + # Filter out the true central point to get the 24 peripheral grid points + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point_coords): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) + + # Generate interstitial candidates. + # Using grid_size + 1 ensures (grid_size)^2 candidates (e.g. 5x5=25 for grid_size=5), + # matching the behavior of the 2.27 score inspiration program. + all_interstitial_candidates = _generate_interstitial_candidates(grid_size + 1, start_coord, end_coord) + num_interstitial_cand = len(all_interstitial_candidates) + + # Combinatorial selection of 23 peripheral and 2 interstitial circles + for p_indices_combo in combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in combinations(range(num_interstitial_cand), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Assemble current configuration: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords.reshape(1, -1), selected_peripheral_points, selected_interstitial_points]) + + # Fast evaluation with fewer iterations (500) for Stage 1 ranking + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_idx=interstitial_circle_indices_to_pass, w_central=w_central) + sum_r = np.sum(radii) + + # Maintain a list of the top N configurations + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_circle_indices_to_pass, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_circle_indices_to_pass, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # Stage 2: Dynamic Refinement of the top configurations + best_overall_sum_radii = -1.0 + best_overall_centers = None + best_overall_radii = None + + if not top_n_configs: # Fallback in case no configurations were generated (should not happen with current search space) + # A reasonable fallback using the same grid generation logic as Stage 1 + fallback_start_coord = 0.1 + fallback_end_coord = 0.9 + centers_fallback = _generate_grid_centers(grid_size, fallback_start_coord, fallback_end_coord) + # Ensure we have n_circles, for 26, take 25 grid points and add one. + # For simplicity, just take the first 25 grid points and an interstitial. + peripheral_fallback = centers_fallback[np.where(~np.all(np.isclose(centers_fallback, [0.5, 0.5]), axis=1))][0:23] # 23 peripheral + interstitial_fallback_cand = _generate_interstitial_candidates(grid_size + 1, fallback_start_coord, fallback_end_coord) + interstitial_fallback = interstitial_fallback_cand[0:2] # Take first 2 interstitial + centers_fallback = np.vstack([[0.5, 0.5], peripheral_fallback, interstitial_fallback]) + + radii_fallback = compute_max_radii(centers_fallback, interstitial_idx=interstitial_circle_indices_to_pass, w_central=1.5) + return centers_fallback, radii_fallback + + + for _, initial_centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, +- num_steps=1500, +- initial_learning_rate=0.01) ++ num_steps=2500, ++ initial_learning_rate=0.015) + + optimized_centers, optimized_radii = optimizer.optimize() + current_refined_sum_radii = np.sum(optimized_radii) + + if current_refined_sum_radii > best_overall_sum_radii: + best_overall_sum_radii = current_refined_sum_radii + best_overall_centers = optimized_centers + best_overall_radii = optimized_radii + + return best_overall_centers, best_overall_radii + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/main.py new file mode 100644 index 0000000000000000000000000000000000000000..74e5f9248e495f5b651f8eaeda6b90167a011b5e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/main.py @@ -0,0 +1,294 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a two-stage hybrid +optimization strategy. It combines a broad combinatorial search for initial +topologies with a deep, force-directed refinement of the best candidates. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version includes a restoring force for the central circle and uses weighted radius relaxation. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=2500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Adaptive parameters that change over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Start higher, decay to lower + + # Force constants increase over time for a more precise final arrangement. + K_boundary = 5.0 + (15.0 - 5.0) * progress_ratio + K_center = 2.0 + (10.0 - 2.0) * progress_ratio + + # Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 2000 # Increased for final refinement + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Check if this configuration improves the best found so far + # Using the unified compute_max_radii for final sum_radii evaluation + # (only check periodically to save computation time) + if step % 25 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force pulling the central circle towards the geometric center + center_pos = self.centers[self.central_idx] + center_offset = np.array([0.5, 0.5]) - center_pos + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] # Use the quickly computed radii for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + Note: 'grid_size' here refers to the effective number of grid cells per side, + so for N grid points, you'd have (N-1) interstitial cells. + If called with (actual_grid_size + 1), it effectively generates (actual_grid_size)^2 interstitial points. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of interstitial circle(s). + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + # Use an adaptive heuristic based on distance to nearest neighbor + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + # Iteratively adjust radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search for initial topologies (1 central + 23 peripheral + 2 interstitial), + optimizing for grid spacing and central circle weight. + 2. A deep dynamic refinement using force-directed simulation on the top N best candidates. + """ + n_circles = 26 + grid_size = 5 # For the base grid of 25 centers + + # Stage 1: Coarse Combinatorial Search to identify promising initial configurations + # `start_coord_search_space` from 2.27 inspiration program. + # Expanded search space for grid bounds and central weight to find better initial seeds. + start_coord_search_space = np.linspace(0.08, 0.12, 5) + w_central_search_space = np.linspace(1.5, 3.0, 4) + top_n_to_refine = 10 # Number of top configurations to pass to Stage 2 + + top_n_configs = [] # Stores (sum_r, initial_centers, interstitial_indices, w_central) + + # Define the number of circles to select for each category + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 + + # The interstitial circles will be the last two circles in the `current_centers` array. + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, # index 24 + num_fixed_central + num_peripheral_to_select + 1 # index 25 + ] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord # Enforce symmetry for grid bounds (center at 0.5) + + # Generate grid centers for the 5x5 grid + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) # The true center circle + + # Filter out the true central point to get the 24 peripheral grid points + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point_coords): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) + + # Generate interstitial candidates. + # Using grid_size + 1 ensures (grid_size)^2 candidates (e.g. 5x5=25 for grid_size=5), + # matching the behavior of the 2.27 score inspiration program. + all_interstitial_candidates = _generate_interstitial_candidates(grid_size + 1, start_coord, end_coord) + num_interstitial_cand = len(all_interstitial_candidates) + + # Combinatorial selection of 23 peripheral and 2 interstitial circles + for p_indices_combo in combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in combinations(range(num_interstitial_cand), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Assemble current configuration: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords.reshape(1, -1), selected_peripheral_points, selected_interstitial_points]) + + # Fast evaluation with fewer iterations (500) for Stage 1 ranking + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_idx=interstitial_circle_indices_to_pass, w_central=w_central) + sum_r = np.sum(radii) + + # Maintain a list of the top N configurations + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_circle_indices_to_pass, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_circle_indices_to_pass, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # Stage 2: Dynamic Refinement of the top configurations + best_overall_sum_radii = -1.0 + best_overall_centers = None + best_overall_radii = None + + if not top_n_configs: # Fallback in case no configurations were generated (should not happen with current search space) + # A reasonable fallback using the same grid generation logic as Stage 1 + fallback_start_coord = 0.1 + fallback_end_coord = 0.9 + centers_fallback = _generate_grid_centers(grid_size, fallback_start_coord, fallback_end_coord) + # Ensure we have n_circles, for 26, take 25 grid points and add one. + # For simplicity, just take the first 25 grid points and an interstitial. + peripheral_fallback = centers_fallback[np.where(~np.all(np.isclose(centers_fallback, [0.5, 0.5]), axis=1))][0:23] # 23 peripheral + interstitial_fallback_cand = _generate_interstitial_candidates(grid_size + 1, fallback_start_coord, fallback_end_coord) + interstitial_fallback = interstitial_fallback_cand[0:2] # Take first 2 interstitial + centers_fallback = np.vstack([[0.5, 0.5], peripheral_fallback, interstitial_fallback]) + + radii_fallback = compute_max_radii(centers_fallback, interstitial_idx=interstitial_circle_indices_to_pass, w_central=1.5) + return centers_fallback, radii_fallback + + + for _, initial_centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + num_steps=2500, + initial_learning_rate=0.015) + + optimized_centers, optimized_radii = optimizer.optimize() + current_refined_sum_radii = np.sum(optimized_radii) + + if current_refined_sum_radii > best_overall_sum_radii: + best_overall_sum_radii = current_refined_sum_radii + best_overall_centers = optimized_centers + best_overall_radii = optimized_radii + + return best_overall_centers, best_overall_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/original.py new file mode 100644 index 0000000000000000000000000000000000000000..0a57111dc230036e1b1f5475605bab04cfa6903e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/original.py @@ -0,0 +1,292 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a two-stage hybrid +optimization strategy. It combines a broad combinatorial search for initial +topologies with a deep, force-directed refinement of the best candidates. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version includes a restoring force for the central circle and uses weighted radius relaxation. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=2500, initial_learning_rate=0.01): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Adaptive parameters that decay over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Start higher, decay to lower + K_boundary = 5.0 + (15.0 - 5.0) * decay_factor # Start stronger, decay to lower + K_center = 2.0 + (10.0 - 2.0) * decay_factor # Start stronger, decay to lower + + # Use fewer iterations for speed during intermediate steps. + radii_iter_count = 50 if step < self.num_steps * 0.9 else 2000 # Increased for final refinement + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Check if this configuration improves the best found so far + # Using the unified compute_max_radii for final sum_radii evaluation + # (only check periodically to save computation time) + if step % 25 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Add a restoring force pulling the central circle towards the geometric center + center_pos = self.centers[self.central_idx] + center_offset = np.array([0.5, 0.5]) - center_pos + force_vectors[self.central_idx] += K_center * center_offset + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] # Use the quickly computed radii for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid cells. + Note: 'grid_size' here refers to the effective number of grid cells per side, + so for N grid points, you'd have (N-1) interstitial cells. + If called with (actual_grid_size + 1), it effectively generates (actual_grid_size)^2 interstitial points. + """ + if grid_size < 2: + return np.array([]) + step = (end_coord - start_coord) / (grid_size - 1) + interstitial_coords = np.linspace(start_coord + step / 2, end_coord - step / 2, grid_size - 1) + return np.array(np.meshgrid(interstitial_coords, interstitial_coords)).T.reshape(-1, 2) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of interstitial circle(s). + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + # Use an adaptive heuristic based on distance to nearest neighbor + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + # Iteratively adjust radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search for initial topologies (1 central + 23 peripheral + 2 interstitial), + optimizing for grid spacing and central circle weight. + 2. A deep dynamic refinement using force-directed simulation on the top N best candidates. + """ + n_circles = 26 + grid_size = 5 # For the base grid of 25 centers + + # Stage 1: Coarse Combinatorial Search to identify promising initial configurations + # `start_coord_search_space` from 2.27 inspiration program. + start_coord_search_space = np.linspace(0.08, 0.12, 3) # [0.08, 0.10, 0.12] + # `w_central_search_space` from current program (wider range). + w_central_search_space = np.linspace(1.5, 2.5, 3) # [1.5, 2.0, 2.5] + top_n_to_refine = 10 # Number of top configurations to pass to Stage 2 + + top_n_configs = [] # Stores (sum_r, initial_centers, interstitial_indices, w_central) + + # Define the number of circles to select for each category + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 + + # The interstitial circles will be the last two circles in the `current_centers` array. + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, # index 24 + num_fixed_central + num_peripheral_to_select + 1 # index 25 + ] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord # Enforce symmetry for grid bounds (center at 0.5) + + # Generate grid centers for the 5x5 grid + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([0.5, 0.5]) # The true center circle + + # Filter out the true central point to get the 24 peripheral grid points + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point_coords): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) + + # Generate interstitial candidates. + # Using grid_size + 1 ensures (grid_size)^2 candidates (e.g. 5x5=25 for grid_size=5), + # matching the behavior of the 2.27 score inspiration program. + all_interstitial_candidates = _generate_interstitial_candidates(grid_size + 1, start_coord, end_coord) + num_interstitial_cand = len(all_interstitial_candidates) + + # Combinatorial selection of 23 peripheral and 2 interstitial circles + for p_indices_combo in combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in combinations(range(num_interstitial_cand), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Assemble current configuration: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords.reshape(1, -1), selected_peripheral_points, selected_interstitial_points]) + + # Fast evaluation with fewer iterations (500) for Stage 1 ranking + radii = compute_max_radii(current_centers, max_iterations=500, interstitial_idx=interstitial_circle_indices_to_pass, w_central=w_central) + sum_r = np.sum(radii) + + # Maintain a list of the top N configurations + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_circle_indices_to_pass, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_circle_indices_to_pass, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # Stage 2: Dynamic Refinement of the top configurations + best_overall_sum_radii = -1.0 + best_overall_centers = None + best_overall_radii = None + + if not top_n_configs: # Fallback in case no configurations were generated (should not happen with current search space) + # A reasonable fallback using the same grid generation logic as Stage 1 + fallback_start_coord = 0.1 + fallback_end_coord = 0.9 + centers_fallback = _generate_grid_centers(grid_size, fallback_start_coord, fallback_end_coord) + # Ensure we have n_circles, for 26, take 25 grid points and add one. + # For simplicity, just take the first 25 grid points and an interstitial. + peripheral_fallback = centers_fallback[np.where(~np.all(np.isclose(centers_fallback, [0.5, 0.5]), axis=1))][0:23] # 23 peripheral + interstitial_fallback_cand = _generate_interstitial_candidates(grid_size + 1, fallback_start_coord, fallback_end_coord) + interstitial_fallback = interstitial_fallback_cand[0:2] # Take first 2 interstitial + centers_fallback = np.vstack([[0.5, 0.5], peripheral_fallback, interstitial_fallback]) + + radii_fallback = compute_max_radii(centers_fallback, interstitial_idx=interstitial_circle_indices_to_pass, w_central=1.5) + return centers_fallback, radii_fallback + + + for _, initial_centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=initial_centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + num_steps=1500, + initial_learning_rate=0.01) + + optimized_centers, optimized_radii = optimizer.optimize() + current_refined_sum_radii = np.sum(optimized_radii) + + if current_refined_sum_radii > best_overall_sum_radii: + best_overall_sum_radii = current_refined_sum_radii + best_overall_centers = optimized_centers + best_overall_radii = optimized_radii + + return best_overall_centers, best_overall_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..64a9a7ef0c1076bc88f8049fe6a32b251b1f64c8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8841485438729839, + "spatial_uniformity_details": { + "cell_size_mean": 0.2016931357506122, + "cell_size_std": 0.026428187599594824, + "coefficient_of_variation": 0.13103166535742128 + }, + "edge_utilization": 0.6499999999999999, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 13, + "corner_score": 0.75, + "edge_score": 0.5 + }, + "density_variance": 0.5759478887248626, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0005534949378046221, + "mean_density": 0.03195367206627662, + "cv": 0.7362681929679101 + }, + "packing_efficiency": 0.7224854837339799, + "packing_efficiency_details": { + "total_area": 0.7224854837339799, + "square_area": 1.0, + "efficiency": 0.7224854837339799, + "relative_to_estimated_best": 0.8601017663499761 + }, + "radius_distribution": 0.9194324210397706, + "radius_distribution_details": { + "mean": 0.08778077315124744, + "std": 0.033759445735745984, + "min": 0.0010155584952521695, + "max": 0.16637155635868683, + "range": 0.16535599786343466, + "small_count": 6, + "medium_count": 14, + "large_count": 6, + "diversity_score": 0.9194324210397706 + }, + "gap_analysis": 0.7272, + "gap_analysis_details": { + "covered_samples": 1818, + "total_samples": 2500, + "coverage": 0.7272, + "gap_ratio": 0.27280000000000004 + }, + "geometric_quality": 0.6553085448924135, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6553085448924135, + "min_quality": 0.30006665781149783, + "max_quality": 0.9101542228355949 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..1c020ffca2e93d7135c9f654b7e7f0fea0ecdfe0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 411.66 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2823 + + Auxiliary Metrics: + • spatial_uniformity: 0.884 + • edge_utilization: 0.650 + • density_variance: 0.576 + • packing_efficiency: 0.722 + • radius_distribution: 0.919 + • gap_analysis: 0.727 + • geometric_quality: 0.655 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2823 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.884 + • Area utilization efficiency: 0.722 + • Area coverage (1 - gap ratio): 0.727 + +📊 Other Metrics: + • Boundary and corner utilization: 0.650 + • Spatial density uniformity across grid: 0.576 + • Radius size diversity: 0.919 + • Delaunay triangulation quality: 0.655 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..d539a36ed8a08a0c213b57e50e9d574ec4e45c09 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2823001019324334, + "public": { + "centers_str": " centers[0] = (0.4955, 0.4951)\n centers[1] = (0.0850, 0.0851)\n centers[2] = (0.0891, 0.3119)\n centers[3] = (0.0917, 0.4578)\n centers[4] = (0.0117, 0.7407)\n centers[5] = (0.0974, 0.8813)\n centers[6] = (0.2756, 0.0927)\n centers[7] = (0.2689, 0.3183)\n centers[8] = (0.1122, 0.6475)\n centers[9] = (0.2947, 0.9076)\n centers[10] = (0.4607, 0.0800)\n centers[11] = (0.4369, 0.2636)\n centers[12] = (0.3544, 0.6847)\n centers[13] = (0.4993, 0.8981)\n centers[14] = (0.7152, 0.0010)\n centers[15] = (0.6668, 0.1129)\n centers[16] = (0.6590, 0.3631)\n centers[17] = (0.6509, 0.6648)\n centers[18] = (0.7093, 0.9133)\n centers[19] = (0.8993, 0.1000)\n centers[20] = (0.9006, 0.3000)\n centers[21] = (0.8923, 0.5080)\n centers[22] = (0.9065, 0.7121)\n centers[23] = (0.9032, 0.9032)\n centers[24] = (0.1679, 0.2178)\n centers[25] = (0.3388, 0.4643)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8841485438729839, + "aux_edge_utilization": 0.6499999999999999, + "aux_density_variance": 0.5759478887248626, + "aux_packing_efficiency": 0.7224854837339799, + "aux_radius_distribution": 0.9194324210397706, + "aux_gap_analysis": 0.7272, + "aux_geometric_quality": 0.6553085448924135 + }, + "private": { + "reported_sum_of_radii": 2.2823001019324334 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2823\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.884\n \u2022 Area utilization efficiency: 0.722\n \u2022 Area coverage (1 - gap ratio): 0.727\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.650\n \u2022 Spatial density uniformity across grid: 0.576\n \u2022 Radius size diversity: 0.919\n \u2022 Delaunay triangulation quality: 0.655\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/results/packing_viz.png", + "execution_time_mean": 411.65501435287297, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..c888addec74053cca2715900213f18b8f165a1d7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_151/search_replace.txt @@ -0,0 +1,55 @@ + +fix_optimizer_force_schedule + + +This change corrects a logic regression within the `DynamicPackingOptimizer`. The boundary and central restoring forces were incorrectly set to decrease over time. This edit reverses that logic, causing these forces to increase as the optimization progresses. This provides a weaker force for exploration in the beginning and a stronger force for precise placement and constraint satisfaction at the end, which is crucial for achieving stable and compact final packings. + + +<<<<<<< SEARCH + # Adaptive parameters that decay over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Start higher, decay to lower + K_boundary = 5.0 + (15.0 - 5.0) * decay_factor # Start stronger, decay to lower + K_center = 2.0 + (10.0 - 2.0) * decay_factor # Start stronger, decay to lower +======= + # Adaptive parameters that change over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Start higher, decay to lower + + # Force constants increase over time for a more precise final arrangement. + K_boundary = 5.0 + (15.0 - 5.0) * progress_ratio + K_center = 2.0 + (10.0 - 2.0) * progress_ratio +>>>>>>> REPLACE + + +expand_combinatorial_search + + +To discover better initial configurations, this change widens the Stage 1 combinatorial search. The search space for the grid's starting coordinate (`start_coord_search_space`) is expanded from 3 to 5 points. The search space for the central circle's weight (`w_central_search_space`) is also broadened from 3 to 4 points and given a higher upper bound. This significantly increases the number of initial topologies evaluated, improving the probability of finding superior candidates for the dynamic refinement stage. + + +<<<<<<< SEARCH + start_coord_search_space = np.linspace(0.08, 0.12, 3) # [0.08, 0.10, 0.12] + # `w_central_search_space` from current program (wider range). + w_central_search_space = np.linspace(1.5, 2.5, 3) # [1.5, 2.0, 2.5] +======= + # Expanded search space for grid bounds and central weight to find better initial seeds. + start_coord_search_space = np.linspace(0.08, 0.12, 5) + w_central_search_space = np.linspace(1.5, 3.0, 4) +>>>>>>> REPLACE + + +enhance_dynamic_refinement + + +This edit strengthens the Stage 2 dynamic refinement process. The number of optimization steps in the `DynamicPackingOptimizer` is increased from 1500 to 2500, allowing more time for the simulation to converge to a superior local optimum. Furthermore, the `initial_learning_rate` is increased from 0.01 to 0.015. This encourages larger, more exploratory steps early in the optimization, which can help the algorithm escape from poor local minima and find denser packings. + + +<<<<<<< SEARCH + num_steps=1500, + initial_learning_rate=0.01) +======= + num_steps=2500, + initial_learning_rate=0.015) +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5cfa57f17da1dee2b0341d8919d01eb0121a3858 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..c63bfa3cb72e05c95a639a7bd2cd80684187e6dc --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/edit.diff @@ -0,0 +1,341 @@ +--- a/original.py ++++ b/original.py +@@ -1,283 +1,321 @@ + # EVOLVE-BLOCK-START + """ + Hybrid circle packing for n=26 circles, combining a systematic search for + initial configurations with a force-directed dynamic optimizer for refinement. + """ + + import numpy as np + import itertools + + + class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + +- # Adaptive parameters that decay over the optimization process +- decay_factor = 1 - progress_ratio +- buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Decays from 0.1 to 0.01 +- K_boundary = 5.0 + (15.0 - 5.0) * decay_factor # Decays from 15.0 to 5.0 +- K_center = 2.0 + (10.0 - 2.0) * decay_factor # Decays from 10.0 to 2.0 ++ # Adaptive parameters for forces and buffer ++ # Buffer factor decays for tighter packing ++ buffer_factor = 0.01 + (0.1 - 0.01) * (1 - progress_ratio) ++ ++ # K_boundary and K_center forces increase for stricter enforcement at later stages ++ K_boundary = 5.0 + (15.0 - 5.0) * progress_ratio ++ K_center = 2.0 + (10.0 - 2.0) * progress_ratio + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation +- if step % 50 == 0 or step == self.num_steps - 1: ++ if step % 25 == 0 or step == self.num_steps - 1: # Increased check frequency + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Add a restoring force pulling the central circle towards the geometric center + center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * center_offset + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 +- sc_options = np.array([0.09, 0.1, 0.11]) +- ec_options = np.array([0.89, 0.9, 0.91]) +- central_weight_options = np.linspace(1.2, 2.2, 3) +- +- TOP_N_CANDIDATES = 20 ++ # Expanded search space for grid coordinates to explore more configurations ++ sc_options = np.array([0.08, 0.09, 0.1, 0.11, 0.12]) ++ ec_options = np.array([0.88, 0.89, 0.9, 0.91, 0.92]) ++ central_weight_options = np.linspace(1.2, 2.5, 5) # Broader range for central weight ++ ++ TOP_N_CANDIDATES = 30 # Increased number of top candidates for refinement + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue ++ # Ensure symmetry around 0.5 for a well-centered grid ++ if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5, atol=1e-5): continue + for sc_y in sc_options: + for ec_y in ec_options: +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue ++ # Ensure symmetry around 0.5 for a well-centered grid ++ if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5, atol=1e-5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) ++ # Increase density of interstitial candidates (e.g., from 4x4=16 to 5x5=25 for grid_size=5) ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=grid_size / (grid_size - 1)) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) ++ ++ # Only proceed if enough peripheral points exist after removing the central one ++ if len(peripheral_grid_points) < num_peripheral_to_select: continue ++ ++ # Only proceed if enough interstitial candidates exist ++ if len(all_interstitial_candidates) < num_interstitial_to_select: continue + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + +- coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) ++ # Use consistent tolerance for coarse evaluation ++ coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-7, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: +- return np.random.rand(n_circles, 2), np.zeros(n_circles) ++ # Fallback to a default configuration if no candidates are found ++ # (This should be rare with the expanded search space) ++ default_start_coord = 0.1 ++ default_end_coord = 0.9 ++ default_grid_centers = _generate_grid_centers(grid_size, default_start_coord, default_end_coord, default_start_coord, default_end_coord) ++ default_central_point = np.array([0.5, 0.5]) ++ ++ # Ensure enough peripheral points for fallback ++ default_peripheral_grid_points = np.array([p for p in default_grid_centers if not np.allclose(p, default_central_point)]) ++ if len(default_peripheral_grid_points) < num_peripheral_to_select: ++ default_peripheral_points = default_peripheral_grid_points # Use all available ++ else: ++ default_peripheral_points = default_peripheral_grid_points[np.random.choice(len(default_peripheral_grid_points), num_peripheral_to_select, replace=False)] ++ ++ default_interstitial_candidates = _generate_interstitial_candidates(grid_size, default_start_coord, default_end_coord, default_start_coord, default_end_coord, density_factor=grid_size / (grid_size - 1)) ++ ++ # Ensure enough interstitial points for fallback ++ if len(default_interstitial_candidates) < num_interstitial_to_select: ++ default_interstitial_points = default_interstitial_candidates # Use all available ++ else: ++ default_interstitial_points = default_interstitial_candidates[np.random.choice(len(default_interstitial_candidates), num_interstitial_to_select, replace=False)] ++ ++ default_centers = np.array([default_central_point] + list(default_peripheral_points) + list(default_interstitial_points)) ++ default_radii = compute_max_radii(default_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=1.5) ++ return default_centers, default_radii + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + ++ # Refine all top candidates to ensure comprehensive exploration + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, +- num_steps=2500, ++ num_steps=2500, # Number of steps for dynamic optimization + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/main.py new file mode 100644 index 0000000000000000000000000000000000000000..a31f660009a719f83a2c5c434ffa162e11fe0859 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/main.py @@ -0,0 +1,321 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive parameters for forces and buffer + # Buffer factor decays for tighter packing + buffer_factor = 0.01 + (0.1 - 0.01) * (1 - progress_ratio) + + # K_boundary and K_center forces increase for stricter enforcement at later stages + K_boundary = 5.0 + (15.0 - 5.0) * progress_ratio + K_center = 2.0 + (10.0 - 2.0) * progress_ratio + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 25 == 0 or step == self.num_steps - 1: # Increased check frequency + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Add a restoring force pulling the central circle towards the geometric center + center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * center_offset + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + # Expanded search space for grid coordinates to explore more configurations + sc_options = np.array([0.08, 0.09, 0.1, 0.11, 0.12]) + ec_options = np.array([0.88, 0.89, 0.9, 0.91, 0.92]) + central_weight_options = np.linspace(1.2, 2.5, 5) # Broader range for central weight + + TOP_N_CANDIDATES = 30 # Increased number of top candidates for refinement + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + # Ensure symmetry around 0.5 for a well-centered grid + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5, atol=1e-5): continue + for sc_y in sc_options: + for ec_y in ec_options: + # Ensure symmetry around 0.5 for a well-centered grid + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5, atol=1e-5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + # Increase density of interstitial candidates (e.g., from 4x4=16 to 5x5=25 for grid_size=5) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=grid_size / (grid_size - 1)) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + # Only proceed if enough peripheral points exist after removing the central one + if len(peripheral_grid_points) < num_peripheral_to_select: continue + + # Only proceed if enough interstitial candidates exist + if len(all_interstitial_candidates) < num_interstitial_to_select: continue + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + # Use consistent tolerance for coarse evaluation + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-7, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + # Fallback to a default configuration if no candidates are found + # (This should be rare with the expanded search space) + default_start_coord = 0.1 + default_end_coord = 0.9 + default_grid_centers = _generate_grid_centers(grid_size, default_start_coord, default_end_coord, default_start_coord, default_end_coord) + default_central_point = np.array([0.5, 0.5]) + + # Ensure enough peripheral points for fallback + default_peripheral_grid_points = np.array([p for p in default_grid_centers if not np.allclose(p, default_central_point)]) + if len(default_peripheral_grid_points) < num_peripheral_to_select: + default_peripheral_points = default_peripheral_grid_points # Use all available + else: + default_peripheral_points = default_peripheral_grid_points[np.random.choice(len(default_peripheral_grid_points), num_peripheral_to_select, replace=False)] + + default_interstitial_candidates = _generate_interstitial_candidates(grid_size, default_start_coord, default_end_coord, default_start_coord, default_end_coord, density_factor=grid_size / (grid_size - 1)) + + # Ensure enough interstitial points for fallback + if len(default_interstitial_candidates) < num_interstitial_to_select: + default_interstitial_points = default_interstitial_candidates # Use all available + else: + default_interstitial_points = default_interstitial_candidates[np.random.choice(len(default_interstitial_candidates), num_interstitial_to_select, replace=False)] + + default_centers = np.array([default_central_point] + list(default_peripheral_points) + list(default_interstitial_points)) + default_radii = compute_max_radii(default_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=1.5) + return default_centers, default_radii + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + # Refine all top candidates to ensure comprehensive exploration + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=2500, # Number of steps for dynamic optimization + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..e134b19aa5c6638f2069b9bf38521994068f8f58 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": false, + "error": "'float' object cannot be interpreted as an integer" +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..c84745586b9fc98972c423d1b4e9d857379bff20 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/job_log.out @@ -0,0 +1,35 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results +Auxiliary Metrics: ENABLED +====================================================================== + +Evaluation error: 'float' object cannot be interpreted as an integer +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/metrics.json + +====================================================================== +❌ EVALUATION FAILED +Error: 'float' object cannot be interpreted as an integer +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 0.0000 + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..fec2021a6a036637c9d3049ae9778c77cef78421 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_153/results/metrics.json @@ -0,0 +1,9 @@ +{ + "combined_score": 0.0, + "execution_time_mean": 0.0, + "execution_time_std": 0.0, + "num_successful_runs": 0, + "num_valid_runs": 0, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..150e1cc19e78a0a82773793c2ce479b26c74c047 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..7914c4572e008cb6a67e737524fd817039cd8c62 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/edit.diff @@ -0,0 +1,312 @@ +--- a/original.py ++++ b/original.py +@@ -1,245 +1,234 @@ + # EVOLVE-BLOCK-START + """ + Hybrid circle packing for n=26 circles, combining a systematic combinatorial search + for promising initial configurations with a force-directed dynamic optimizer for refinement. + """ + + import numpy as np + import itertools + + + class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on +- repulsion forces and boundaries. This version uses a fixed central circle +- to provide a stable anchor for the packing. +- """ +- def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2500, initial_learning_rate=0.02, central_fixed=True): ++ repulsion forces and boundaries to find a better packing. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, num_circles=26, num_steps=2500, initial_learning_rate=0.02): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate +- self.w_central = w_central + self.interstitial_indices = interstitial_indices +- self.central_idx = 0 +- self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + + # Initialize best configuration with max radii for the starting layout +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation for speed + radii_iter_count = 150 if step < self.num_steps * 0.9 else 500 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: +- test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + +- if self.central_fixed: +- self.centers[self.central_idx] = np.array([0.5, 0.5]) +- + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +-def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): ++def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + if grid_size < 2: return np.array([]) +- step_x = (ec_x - sc_x) / (grid_size - 1) +- step_y = (ec_y - sc_y) / (grid_size - 1) ++ num_intervals_x = (grid_size - 1) * density_factor ++ num_intervals_y = (grid_size - 1) * density_factor ++ step_x = (ec_x - sc_x) / num_intervals_x ++ step_y = (ec_y - sc_y) / num_intervals_y + candidates = [] +- for i in range(grid_size - 1): +- for j in range(grid_size - 1): ++ for i in range(num_intervals_y): ++ for j in range(num_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist +- w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 +- weighted_r_i = radii[i] / w_i +- weighted_r_j = radii[j] / w_j +- total_weighted_radii = weighted_r_i + weighted_r_j +- if total_weighted_radii > 1e-12: +- radii[i] -= overlap * (weighted_r_i / total_weighted_radii) +- radii[j] -= overlap * (weighted_r_j / total_weighted_radii) ++ total_radii = radii[i] + radii[j] ++ if total_radii > 1e-12: ++ radii[i] -= overlap * (radii[i] / total_radii) ++ radii[j] -= overlap * (radii[j] / total_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return np.maximum(radii, 0) + + + def construct_packing(): + """ +- Constructs an arrangement of 26 circles using a two-stage process: +- 1. A broad combinatorial search finds promising initial topologies. +- 2. A force-directed dynamic optimization refines the best candidates. ++ Constructs an arrangement of 26 circles by removing the fixed central circle ++ constraint and exploring a richer combinatorial space. ++ 1. A broad combinatorial search finds promising initial topologies by selecting ++ circles from a grid and a denser set of interstitial candidates. ++ 2. A force-directed dynamic optimizer refines the best candidates without any ++ fixed points, allowing the entire configuration to settle globally. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) +- central_weight_options = np.linspace(1.2, 2.4, 4) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + +- num_fixed_central = 1 +- num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 ++ # Configuration: 24 circles from the grid, 2 from interstitial points. ++ num_grid_to_select = 24 + num_interstitial_to_select = 2 + +- interstitial_circle_indices = [ +- num_fixed_central + num_peripheral_to_select, +- num_fixed_central + num_peripheral_to_select + 1 +- ] +- +- # STAGE 1: Coarse Combinatorial Search with Asymmetric Grids +- for w_central in central_weight_options: +- for sc_x in sc_options: +- for ec_x in ec_options: +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue +- for sc_y in sc_options: +- for ec_y in ec_options: +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue +- +- all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) +- +- central_point = np.array([0.5, 0.5]) +- peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) +- +- for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral = peripheral_grid_points[list(p_indices)] +- for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial = all_interstitial_candidates[list(i_indices)] +- current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) +- +- coarse_radii = compute_max_radii(current_centers, max_iterations=200, interstitial_indices=interstitial_circle_indices, w_central=w_central) +- coarse_sum_radii = np.sum(coarse_radii) +- +- if len(top_candidates) < TOP_N_CANDIDATES: +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) +- elif coarse_sum_radii > top_candidates[-1][0]: +- top_candidates.pop() +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) ++ interstitial_circle_indices = list(range(num_grid_to_select, n_circles)) ++ ++ # STAGE 1: Coarse Combinatorial Search without a fixed center ++ for sc_x in sc_options: ++ for ec_x in ec_options: ++ if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue ++ for sc_y in sc_options: ++ for ec_y in ec_options: ++ if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue ++ ++ # Generate a 5x5 grid of 25 points ++ all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) ++ # Generate a denser 8x8 grid of 64 interstitial candidates ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) ++ ++ # Iterate through combinations of leaving out one grid point ++ for grid_indices in itertools.combinations(range(len(all_grid_centers)), num_grid_to_select): ++ selected_grid = all_grid_centers[list(grid_indices)] ++ # Iterate through combinations of picking two interstitial points ++ for interstitial_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): ++ selected_interstitial = all_interstitial_candidates[list(interstitial_indices_combo)] ++ ++ current_centers = np.vstack((selected_grid, selected_interstitial)) ++ ++ coarse_radii = compute_max_radii(current_centers, max_iterations=200, interstitial_indices=interstitial_circle_indices) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ if len(top_candidates) < TOP_N_CANDIDATES: ++ top_candidates.append((coarse_sum_radii, current_centers)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ elif coarse_sum_radii > top_candidates[-1][0]: ++ top_candidates.pop() ++ top_candidates.append((coarse_sum_radii, current_centers)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + +- best_sum_radii = 0.0 ++ best_sum_radii = -1.0 + best_centers = top_candidates[0][1] +- best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) ++ best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices) + best_sum_radii = np.sum(best_radii) + +- for _, initial_centers, w_central in top_candidates: ++ for _, initial_centers in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, +- w_central=w_central, + num_steps=2500, +- initial_learning_rate=0.02, +- central_fixed=True ++ initial_learning_rate=0.02 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/main.py new file mode 100644 index 0000000000000000000000000000000000000000..1c41d1e2229958b9e483754d5370f0d87e3f4cd4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/main.py @@ -0,0 +1,234 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic combinatorial search +for promising initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries to find a better packing. + """ + def __init__(self, initial_centers, interstitial_indices, num_circles=26, num_steps=2500, initial_learning_rate=0.02): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.interstitial_indices = interstitial_indices + + self.centers = np.copy(initial_centers) + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation for speed + radii_iter_count = 150 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + if grid_size < 2: return np.array([]) + num_intervals_x = (grid_size - 1) * density_factor + num_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_intervals_x + step_y = (ec_y - sc_y) / num_intervals_y + candidates = [] + for i in range(num_intervals_y): + for j in range(num_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + total_radii = radii[i] + radii[j] + if total_radii > 1e-12: + radii[i] -= overlap * (radii[i] / total_radii) + radii[j] -= overlap * (radii[j] / total_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return np.maximum(radii, 0) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by removing the fixed central circle + constraint and exploring a richer combinatorial space. + 1. A broad combinatorial search finds promising initial topologies by selecting + circles from a grid and a denser set of interstitial candidates. + 2. A force-directed dynamic optimizer refines the best candidates without any + fixed points, allowing the entire configuration to settle globally. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + # Configuration: 24 circles from the grid, 2 from interstitial points. + num_grid_to_select = 24 + num_interstitial_to_select = 2 + + interstitial_circle_indices = list(range(num_grid_to_select, n_circles)) + + # STAGE 1: Coarse Combinatorial Search without a fixed center + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + # Generate a 5x5 grid of 25 points + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + # Generate a denser 8x8 grid of 64 interstitial candidates + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + # Iterate through combinations of leaving out one grid point + for grid_indices in itertools.combinations(range(len(all_grid_centers)), num_grid_to_select): + selected_grid = all_grid_centers[list(grid_indices)] + # Iterate through combinations of picking two interstitial points + for interstitial_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(interstitial_indices_combo)] + + current_centers = np.vstack((selected_grid, selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=200, interstitial_indices=interstitial_circle_indices) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = -1.0 + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + num_steps=2500, + initial_learning_rate=0.02 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/original.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cc224b6fbbb9094100e794a771f6c02b78a2a5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/original.py @@ -0,0 +1,245 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic combinatorial search +for promising initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries. This version uses a fixed central circle + to provide a stable anchor for the packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2500, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.interstitial_indices = interstitial_indices + self.central_idx = 0 + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation for speed + radii_iter_count = 150 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + if grid_size < 2: return np.array([]) + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return np.maximum(radii, 0) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.4, 4) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search with Asymmetric Grids + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices)] + for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(i_indices)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=200, interstitial_indices=interstitial_circle_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = 0.0 + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central, + num_steps=2500, + initial_learning_rate=0.02, + central_fixed=True + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..de2141f4665413eb458e390c2ecb3823b2537f7d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8249664420372869, + "spatial_uniformity_details": { + "cell_size_mean": 0.19545107788612165, + "cell_size_std": 0.04146895679853913, + "coefficient_of_variation": 0.21217051875523676 + }, + "edge_utilization": 0.7538461538461538, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 10, + "corner_score": 1.0, + "edge_score": 0.38461538461538464 + }, + "density_variance": 0.48745721036883183, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0019306210753343566, + "mean_density": 0.041788317088505667, + "cv": 1.0514621155021082 + }, + "packing_efficiency": 0.6837865521459312, + "packing_efficiency_details": { + "total_area": 0.6837865521459312, + "square_area": 1.0, + "efficiency": 0.6837865521459312, + "relative_to_estimated_best": 0.8140316096975372 + }, + "radius_distribution": 0.9214632373450521, + "radius_distribution_details": { + "mean": 0.08144149503529648, + "std": 0.04169734110430519, + "min": 0.00044424317876957015, + "max": 0.2055553599975234, + "range": 0.20511111681875382, + "small_count": 10, + "medium_count": 12, + "large_count": 4, + "diversity_score": 0.9214632373450521 + }, + "gap_analysis": 0.6872, + "gap_analysis_details": { + "covered_samples": 1718, + "total_samples": 2500, + "coverage": 0.6872, + "gap_ratio": 0.31279999999999997 + }, + "geometric_quality": 0.6492502042173413, + "geometric_quality_details": { + "num_triangles": 39, + "avg_triangle_quality": 0.6492502042173413, + "min_quality": 0.3453526746027319, + "max_quality": 0.9947094220309104 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..0e2bb48b43538aa84034d7086490360027e1752b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/job_log.out @@ -0,0 +1,73 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 1220.67 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1175 + + Auxiliary Metrics: + • spatial_uniformity: 0.825 + • edge_utilization: 0.754 + • density_variance: 0.487 + • packing_efficiency: 0.684 + • radius_distribution: 0.921 + • gap_analysis: 0.687 + • geometric_quality: 0.649 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1175 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.825 + • Boundary and corner utilization: 0.754 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.487 + → Balance circle density across different regions + +📊 Other Metrics: + • Area utilization efficiency: 0.684 + • Radius size diversity: 0.921 + • Area coverage (1 - gap ratio): 0.687 + • Delaunay triangulation quality: 0.649 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..e0868935fceee345508713ecebb638d3fe6b1e6c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1174788709177084, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7373, 0.0555)\n centers[4] = (0.8906, 0.0947)\n centers[5] = (0.0996, 0.3002)\n centers[6] = (0.4651, 0.3050)\n centers[7] = (0.6443, 0.0442)\n centers[8] = (0.9114, 0.2832)\n centers[9] = (0.1000, 0.5000)\n centers[10] = (0.2581, 0.3984)\n centers[11] = (0.4236, 0.4398)\n centers[12] = (0.6509, 0.2423)\n centers[13] = (0.9109, 0.4670)\n centers[14] = (0.0004, 0.6709)\n centers[15] = (0.0694, 0.7301)\n centers[16] = (0.2826, 0.6414)\n centers[17] = (0.6451, 0.6015)\n centers[18] = (0.9151, 0.7146)\n centers[19] = (0.0978, 0.9022)\n centers[20] = (0.2916, 0.9042)\n centers[21] = (0.4988, 0.8880)\n centers[22] = (0.7081, 0.9054)\n centers[23] = (0.9026, 0.9026)\n centers[24] = (0.2429, 0.2388)\n centers[25] = (0.3767, 0.3391)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8249664420372869, + "aux_edge_utilization": 0.7538461538461538, + "aux_density_variance": 0.48745721036883183, + "aux_packing_efficiency": 0.6837865521459312, + "aux_radius_distribution": 0.9214632373450521, + "aux_gap_analysis": 0.6872, + "aux_geometric_quality": 0.6492502042173413 + }, + "private": { + "reported_sum_of_radii": 2.1174788709177084 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1175\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.825\n \u2022 Boundary and corner utilization: 0.754\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.487\n \u2192 Balance circle density across different regions\n\n\ud83d\udcca Other Metrics:\n \u2022 Area utilization efficiency: 0.684\n \u2022 Radius size diversity: 0.921\n \u2022 Area coverage (1 - gap ratio): 0.687\n \u2022 Delaunay triangulation quality: 0.649\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/results/packing_viz.png", + "execution_time_mean": 1220.6732184789144, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..a7b072c0005f03ffd1061e78d37b1a6bae7ce53e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_156/search_replace.txt @@ -0,0 +1,466 @@ +Based on my expertise in computational geometry and an analysis of the provided performance metrics and visualization, the current approach is fundamentally limited by its assumption of a fixed circle at the center of the square `(0.5, 0.5)`. Many optimal packings for `N=26` do not have a circle at this specific location; instead, they often exhibit `C2` rotational symmetry around the center, with the center itself being an interstitial space between circles. The provided visualization supports this, showing a packing with two large circles symmetrically offset from the center, which is a known high-performing motif. + +My proposed edits remove this constraint entirely, allowing the optimizer to explore a much broader and more promising family of configurations. The changes are: + +1. **Eliminate the Fixed Central Circle:** The concept of a "central circle" with special weight (`w_central`) and a fixed position is removed from all parts of the code (`DynamicPackingOptimizer`, `compute_max_radii`, `construct_packing`). This allows all 26 circles to move freely, enabling the system to find a true global energy minimum for the given initial topology. + +2. **Generalize the Combinatorial Search:** Instead of picking 23 peripheral circles around a fixed center, the initial search now selects 24 circles from the 25 available grid points. This explores all possibilities of which single grid point to omit, effectively testing which "hole" in the initial grid is most beneficial. + +3. **Enrich Interstitial Candidate Locations:** The number of potential locations for the two "filler" (interstitial) circles is significantly increased by using a denser grid for candidate generation (`density_factor=2`). This increases the number of candidates from 16 to 64, giving the algorithm more refined choices for placing small circles into gaps, which is crucial for maximizing total radius sum. + +These changes transform the search from a locally-constrained optimization to a more global one, directly targeting the structural limitations of the previous approach and opening the door to discovering fundamentally better packing geometries. + + +remove_central_circle_constraint + + +Removes the `w_central` and `central_fixed` parameters from the `DynamicPackingOptimizer`. This eliminates the special treatment of a central circle, allowing all circles to be optimized freely. The optimizer's logic is simplified to treat all circles equally during force calculations and updates, apart from the initial radius heuristic for interstitial circles. This change is fundamental to exploring packings without a fixed center. + + +<<<<<<< SEARCH +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries. This version uses a fixed central circle + to provide a stable anchor for the packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2500, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.interstitial_indices = interstitial_indices + self.central_idx = 0 + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation for speed + radii_iter_count = 150 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii +======= +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries to find a better packing. + """ + def __init__(self, initial_centers, interstitial_indices, num_circles=26, num_steps=2500, initial_learning_rate=0.02): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.interstitial_indices = interstitial_indices + + self.centers = np.copy(initial_centers) + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation for speed + radii_iter_count = 150 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii +>>>>>>> REPLACE + + + +increase_interstitial_density + + +Parameterizes the `_generate_interstitial_candidates` function with a `density_factor`. This allows for the creation of a denser grid of candidate points for the interstitial circles. By increasing the density, we provide the combinatorial search with more refined options for placing smaller circles in the gaps between larger ones, which is critical for improving overall packing efficiency. + + +<<<<<<< SEARCH +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + if grid_size < 2: return np.array([]) + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) +======= +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + if grid_size < 2: return np.array([]) + num_intervals_x = (grid_size - 1) * density_factor + num_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_intervals_x + step_y = (ec_y - sc_y) / num_intervals_y + candidates = [] + for i in range(num_intervals_y): + for j in range(num_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) +>>>>>>> REPLACE + + + +simplify_radius_computation + + +Removes the `w_central` parameter from `compute_max_radii`, simplifying the overlap resolution logic. Instead of giving special weight to a central circle, overlaps are now resolved by reducing radii proportionally to their current size for all circles. This makes the function more general and aligns with the new strategy of not having a designated central circle. + + +<<<<<<< SEARCH +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return np.maximum(radii, 0) +======= +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + total_radii = radii[i] + radii[j] + if total_radii > 1e-12: + radii[i] -= overlap * (radii[i] / total_radii) + radii[j] -= overlap * (radii[j] / total_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return np.maximum(radii, 0) +>>>>>>> REPLACE + + + +refactor_combinatorial_search + + +Overhauls the `construct_packing` function to implement the new search strategy. It removes the fixed central point and instead searches through combinations of 24 circles chosen from a 25-point grid and 2 circles from a richer set of 64 interstitial candidates. This allows the exploration of more topologically diverse and potentially superior packing configurations, free from the artificial constraint of a fixed center. + + +<<<<<<< SEARCH +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.4, 4) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search with Asymmetric Grids + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices)] + for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(i_indices)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=200, interstitial_indices=interstitial_circle_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = 0.0 + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central, + num_steps=2500, + initial_learning_rate=0.02, + central_fixed=True + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +======= +def construct_packing(): + """ + Constructs an arrangement of 26 circles by removing the fixed central circle + constraint and exploring a richer combinatorial space. + 1. A broad combinatorial search finds promising initial topologies by selecting + circles from a grid and a denser set of interstitial candidates. + 2. A force-directed dynamic optimizer refines the best candidates without any + fixed points, allowing the entire configuration to settle globally. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + # Configuration: 24 circles from the grid, 2 from interstitial points. + num_grid_to_select = 24 + num_interstitial_to_select = 2 + + interstitial_circle_indices = list(range(num_grid_to_select, n_circles)) + + # STAGE 1: Coarse Combinatorial Search without a fixed center + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + # Generate a 5x5 grid of 25 points + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + # Generate a denser 8x8 grid of 64 interstitial candidates + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + # Iterate through combinations of leaving out one grid point + for grid_indices in itertools.combinations(range(len(all_grid_centers)), num_grid_to_select): + selected_grid = all_grid_centers[list(grid_indices)] + # Iterate through combinations of picking two interstitial points + for interstitial_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(interstitial_indices_combo)] + + current_centers = np.vstack((selected_grid, selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=200, interstitial_indices=interstitial_circle_indices) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = -1.0 + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + num_steps=2500, + initial_learning_rate=0.02 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_157/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_157/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..7076c3bc255e75dff9e642f69311c6edbe2d0ee2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_157/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8749167747201808, + "spatial_uniformity_details": { + "cell_size_mean": 0.20222315282007872, + "cell_size_std": 0.028911006208747442, + "coefficient_of_variation": 0.1429658556036073 + }, + "edge_utilization": 0.6499999999999999, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 13, + "corner_score": 0.75, + "edge_score": 0.5 + }, + "density_variance": 0.5540620948312523, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0006639316363675258, + "mean_density": 0.032014425911957446, + "cv": 0.804851855647271 + }, + "packing_efficiency": 0.7290420226833401, + "packing_efficiency_details": { + "total_area": 0.7290420226833401, + "square_area": 1.0, + "efficiency": 0.7290420226833401, + "relative_to_estimated_best": 0.8679071698611192 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.0892863139602616, + "std": 0.03087698351626982, + "min": 0.015420731352147825, + "max": 0.17363864334763676, + "range": 0.15821791199548893, + "small_count": 6, + "medium_count": 15, + "large_count": 5, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.734, + "gap_analysis_details": { + "covered_samples": 1835, + "total_samples": 2500, + "coverage": 0.734, + "gap_ratio": 0.266 + }, + "geometric_quality": 0.6637276166163725, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6637276166163725, + "min_quality": 0.2966519394570392, + "max_quality": 0.9495998499742955 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e572c43a8079fcbed56b1e2e8be73f1209d2b24d Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..6650f50232f5c0dc546c8f7407e9fe5a97b2789c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8570112822049748, + "spatial_uniformity_details": { + "cell_size_mean": 0.20050956026829636, + "cell_size_std": 0.03345417460273236, + "coefficient_of_variation": 0.16684578227154087 + }, + "edge_utilization": 0.7692307692307692, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 11, + "corner_score": 1.0, + "edge_score": 0.4230769230769231 + }, + "density_variance": 0.526469436829828, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0012650837778439383, + "mean_density": 0.03954438097878192, + "cv": 0.8994454949209753 + }, + "packing_efficiency": 0.7681780328679287, + "packing_efficiency_details": { + "total_area": 0.7681780328679287, + "square_area": 1.0, + "efficiency": 0.7681780328679287, + "relative_to_estimated_best": 0.9144976581761056 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.0889335013794211, + "std": 0.03867035380743027, + "min": 0.0011864465008110466, + "max": 0.18222705404029396, + "range": 0.18104060753948292, + "small_count": 10, + "medium_count": 10, + "large_count": 6, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.77, + "gap_analysis_details": { + "covered_samples": 1925, + "total_samples": 2500, + "coverage": 0.77, + "gap_ratio": 0.22999999999999998 + }, + "geometric_quality": 0.6635985964158795, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6635985964158795, + "min_quality": 0.31020211060437325, + "max_quality": 0.9696841649239951 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..061fc4a00521d9ab4546733c305da5f92d18b500 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 302.47 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3123 + + Auxiliary Metrics: + • spatial_uniformity: 0.857 + • edge_utilization: 0.769 + • density_variance: 0.526 + • packing_efficiency: 0.768 + • radius_distribution: 0.977 + • gap_analysis: 0.770 + • geometric_quality: 0.664 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3123 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.857 + • Boundary and corner utilization: 0.769 + • Area utilization efficiency: 0.768 + • Area coverage (1 - gap ratio): 0.770 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.526 + • Radius size diversity: 0.977 + • Delaunay triangulation quality: 0.664 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..6c8949a8c533142da3b7dbf4a9b90a5c28066138 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3122710358649488, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.0789, 0.2774)\n centers[3] = (0.0816, 0.5008)\n centers[4] = (0.0446, 0.6970)\n centers[5] = (0.0990, 0.9010)\n centers[6] = (0.2908, 0.0870)\n centers[7] = (0.2278, 0.2561)\n centers[8] = (0.2807, 0.4129)\n centers[9] = (0.2720, 0.9319)\n centers[10] = (0.4895, 0.0621)\n centers[11] = (0.4474, 0.2492)\n centers[12] = (0.2723, 0.6696)\n centers[13] = (0.4413, 0.9031)\n centers[14] = (0.7087, 0.0012)\n centers[15] = (0.6720, 0.1224)\n centers[16] = (0.6760, 0.3851)\n centers[17] = (0.6392, 0.7006)\n centers[18] = (0.7344, 0.9321)\n centers[19] = (0.9001, 0.0999)\n centers[20] = (0.9010, 0.3013)\n centers[21] = (0.8915, 0.5133)\n centers[22] = (0.9105, 0.7138)\n centers[23] = (0.9031, 0.9031)\n centers[24] = (0.1427, 0.3892)\n centers[25] = (0.4074, 0.4326)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8570112822049748, + "aux_edge_utilization": 0.7692307692307692, + "aux_density_variance": 0.526469436829828, + "aux_packing_efficiency": 0.7681780328679287, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.77, + "aux_geometric_quality": 0.6635985964158795 + }, + "private": { + "reported_sum_of_radii": 2.3122710358649488 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3123\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.857\n \u2022 Boundary and corner utilization: 0.769\n \u2022 Area utilization efficiency: 0.768\n \u2022 Area coverage (1 - gap ratio): 0.770\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.526\n \u2022 Radius size diversity: 0.977\n \u2022 Delaunay triangulation quality: 0.664\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_158/results/packing_viz.png", + "execution_time_mean": 302.4657006887719, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6265689c83ab461813fb18d15c3000c7129d8293 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..5e3a6b1254eb492e55bae9bdbca4fa93737d1ecd --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/edit.diff @@ -0,0 +1,352 @@ +--- a/original.py ++++ b/original.py +@@ -1,329 +1,273 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + import itertools + + + class DynamicPackingOptimizer: + """ +- Optimizes circle packing using a force-directed approach. Starting from an +- initial configuration, it iteratively adjusts circle centers based on +- repulsion forces and boundaries, while repeatedly calculating maximum radii +- to guide the optimization towards a better packing. +- """ +- def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2500, initial_learning_rate=0.015, central_fixed=True): ++ Optimizes circle packing using a force-directed approach. This version uses a ++ restoring force to gently guide the central circle towards the middle, rather ++ than fixing it rigidly. This provides more flexibility for the packing to settle. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=3000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate +- self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Jiggle mechanism to escape local optima, applied periodically. + if step > 0 and step % 150 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - step / self.num_steps) # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude +- if self.central_fixed: +- jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle + self.centers += jiggle_vec + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles +- # Adaptive buffer factor: starts larger to separate circles, then shrinks for tight packing. + progress = step / self.num_steps + buffer_factor = 0.1 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces +- K_boundary = 10.0 # Strong boundary force ++ K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) ++ ++ # 3. Restoring force on central circle ++ K_center = 5.0 # Strength of the restoring force ++ center_target = np.array([0.5, 0.5]) ++ displacement = center_target - self.centers[self.central_idx] ++ force_vectors[self.central_idx] += K_center * displacement + + # --- Update centers --- + self.centers += learning_rate * force_vectors +- +- if self.central_fixed: +- self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with potentially asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the square grid. +- sc_x (float): The starting x-coordinate for linspace. +- ec_x (float): The ending x-coordinate for linspace. +- sc_y (float): The starting y-coordinate for linspace. +- ec_y (float): The ending y-coordinate for linspace. +- +- Returns: +- np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + """ +- Generates potential interstitial points within the grid formed by _generate_grid_centers, +- with potentially asymmetric bounds. +- +- Args: +- grid_size (int): The number of circles along one dimension of the base grid. +- sc_x (float): The starting x-coordinate of the grid. +- ec_x (float): The ending x-coordinate of the grid. +- sc_y (float): The starting y-coordinate of the grid. +- ec_y (float): The ending y-coordinate of the grid. +- +- Returns: +- np.array: An array of (x, y) coordinates for the candidate interstitial centers. ++ Generates potential interstitial points within the grid formed by _generate_grid_centers. + """ + if grid_size < 2: + return np.array([]) + + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + + candidates = [] +- # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates. +- max_iterations: Maximum iterations for the relaxation process. +- tolerance: Convergence tolerance. +- interstitial_indices: A list of indices for interstitial circles to apply +- an adaptive initial radius heuristic. Defaults to None. +- w_central (float): The weight applied to the central circle (index 0) during overlap resolution. +- +- Returns: +- np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + +- # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: +- if idx < n: # Ensure index is valid ++ if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + +- # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist +- +- # Weighted proportional scaling to protect the central circle (at index 0). +- # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. +- # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 # Other circles have normal weight +- ++ w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j +- + total_weighted_radii = weighted_r_i + weighted_r_j + +- if total_weighted_radii > 1e-12: # Avoid division by zero ++ if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: +- # Fallback for extremely tiny radii sums (should be rare) + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor +- +- # Ensure no radii become negative + radii[radii < 0] = 0 +- + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + +- # Stage 1 Parameters + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) +- central_weight_options = np.linspace(1.2, 2.2, 3) # Wider search space for central weight +- TOP_N_CANDIDATES = 10 ++ central_weight_options = np.linspace(1.2, 2.4, 4) ++ TOP_N_CANDIDATES = 15 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search for promising initial configurations + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + +- # Use fewer iterations for a faster coarse evaluation + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + +- # Store top N candidates + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: +- # Fallback if no valid candidates were found + return np.random.rand(n_circles, 2), np.zeros(n_circles) + +- # Initialize best result with the top candidate from Stage 1 + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] +- # Re-compute radii with high precision for the initial best candidate + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) +- best_sum_radii = np.sum(best_radii) # Update sum with high-precision value ++ best_sum_radii = np.sum(best_radii) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, +- w_central=w_central, +- num_steps=2500, +- initial_learning_rate=0.015 ++ w_central=w_central + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/main.py new file mode 100644 index 0000000000000000000000000000000000000000..c43e9831f65fd78ed7d77462c5d85d2f327af99a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/main.py @@ -0,0 +1,273 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. This version uses a + restoring force to gently guide the central circle towards the middle, rather + than fixing it rigidly. This provides more flexibility for the packing to settle. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=3000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Jiggle mechanism to escape local optima, applied periodically. + if step > 0 and step % 150 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - step / self.num_steps) # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + self.centers += jiggle_vec + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + progress = step / self.num_steps + buffer_factor = 0.1 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Restoring force on central circle + K_center = 5.0 # Strength of the restoring force + center_target = np.array([0.5, 0.5]) + displacement = center_target - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * displacement + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with potentially asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers. + """ + if grid_size < 2: + return np.array([]) + + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.4, 4) + TOP_N_CANDIDATES = 15 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search for promising initial configurations + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/original.py new file mode 100644 index 0000000000000000000000000000000000000000..4a2d4876627ac1f41db087d45aead180985f7324 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/original.py @@ -0,0 +1,329 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2500, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Jiggle mechanism to escape local optima, applied periodically. + if step > 0 and step % 150 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - step / self.num_steps) # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle + self.centers += jiggle_vec + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + # Adaptive buffer factor: starts larger to separate circles, then shrinks for tight packing. + progress = step / self.num_steps + buffer_factor = 0.1 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with potentially asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + sc_x (float): The starting x-coordinate for linspace. + ec_x (float): The ending x-coordinate for linspace. + sc_y (float): The starting y-coordinate for linspace. + ec_y (float): The ending y-coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers, + with potentially asymmetric bounds. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + sc_x (float): The starting x-coordinate of the grid. + ec_x (float): The ending x-coordinate of the grid. + sc_y (float): The starting y-coordinate of the grid. + ec_y (float): The ending y-coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): The weight applied to the central circle (index 0) during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + + # Stage 1 Parameters + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) # Wider search space for central weight + TOP_N_CANDIDATES = 10 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search for promising initial configurations + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + # Use fewer iterations for a faster coarse evaluation + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + # Store top N candidates + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + # Fallback if no valid candidates were found + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + # Initialize best result with the top candidate from Stage 1 + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + # Re-compute radii with high precision for the initial best candidate + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + best_sum_radii = np.sum(best_radii) # Update sum with high-precision value + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=2500, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..bb16353535434295bd17e410b1a1ecc95df1c6db --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8368038700605034, + "spatial_uniformity_details": { + "cell_size_mean": 0.20036158094746392, + "cell_size_std": 0.039075147632882286, + "coefficient_of_variation": 0.19502315390546296 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5515208400824584, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0009784637144038407, + "mean_density": 0.0384673272210179, + "cv": 0.8131681113817731 + }, + "packing_efficiency": 0.7410100799729358, + "packing_efficiency_details": { + "total_area": 0.7410100799729358, + "square_area": 1.0, + "efficiency": 0.7410100799729358, + "relative_to_estimated_best": 0.8821548571106379 + }, + "radius_distribution": 0.8956403029078803, + "radius_distribution_details": { + "mean": 0.08770689009031035, + "std": 0.037141036507982006, + "min": 0.021969610505448902, + "max": 0.1708047705396102, + "range": 0.1488351600341613, + "small_count": 8, + "medium_count": 14, + "large_count": 4, + "diversity_score": 0.8956403029078803 + }, + "gap_analysis": 0.742, + "gap_analysis_details": { + "covered_samples": 1855, + "total_samples": 2500, + "coverage": 0.742, + "gap_ratio": 0.258 + }, + "geometric_quality": 0.6273293040141202, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6273293040141202, + "min_quality": 0.22624997749696443, + "max_quality": 0.9660044922863621 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..1a243d83dafc0e87698ae7291daeffc7f5a7af51 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 411.15 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2804 + + Auxiliary Metrics: + • spatial_uniformity: 0.837 + • edge_utilization: 0.785 + • density_variance: 0.552 + • packing_efficiency: 0.741 + • radius_distribution: 0.896 + • gap_analysis: 0.742 + • geometric_quality: 0.627 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2804 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.837 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.741 + • Area coverage (1 - gap ratio): 0.742 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.552 + • Radius size diversity: 0.896 + • Delaunay triangulation quality: 0.627 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..745df6b022616cdb01281f7a7624a76a99ac681e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2803791423480693, + "public": { + "centers_str": " centers[0] = (0.4931, 0.5022)\n centers[1] = (0.0893, 0.0794)\n centers[2] = (0.2520, 0.0220)\n centers[3] = (0.5184, 0.0792)\n centers[4] = (0.7197, 0.0580)\n centers[5] = (0.9032, 0.0968)\n centers[6] = (0.0950, 0.2681)\n centers[7] = (0.2928, 0.1499)\n centers[8] = (0.4508, 0.2600)\n centers[9] = (0.6143, 0.0699)\n centers[10] = (0.9364, 0.2725)\n centers[11] = (0.0941, 0.4757)\n centers[12] = (0.2979, 0.3884)\n centers[13] = (0.6985, 0.2866)\n centers[14] = (0.9030, 0.4774)\n centers[15] = (0.1054, 0.6886)\n centers[16] = (0.3583, 0.6556)\n centers[17] = (0.6716, 0.6324)\n centers[18] = (0.9175, 0.7055)\n centers[19] = (0.0966, 0.9034)\n centers[20] = (0.2942, 0.8999)\n centers[21] = (0.4963, 0.9013)\n centers[22] = (0.6976, 0.9010)\n centers[23] = (0.8994, 0.8994)\n centers[24] = (0.4518, 0.1358)\n centers[25] = (0.5143, 0.4153)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8368038700605034, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5515208400824584, + "aux_packing_efficiency": 0.7410100799729358, + "aux_radius_distribution": 0.8956403029078803, + "aux_gap_analysis": 0.742, + "aux_geometric_quality": 0.6273293040141202 + }, + "private": { + "reported_sum_of_radii": 2.2803791423480693 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2804\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.837\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.741\n \u2022 Area coverage (1 - gap ratio): 0.742\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.552\n \u2022 Radius size diversity: 0.896\n \u2022 Delaunay triangulation quality: 0.627\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/results/packing_viz.png", + "execution_time_mean": 411.15392548404634, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..1efb46a812a5935b6ef2d01b9c2659f4ade0ef0d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_159/rewrite.txt @@ -0,0 +1,264 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. This version uses a + restoring force to gently guide the central circle towards the middle, rather + than fixing it rigidly. This provides more flexibility for the packing to settle. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=3000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Jiggle mechanism to escape local optima, applied periodically. + if step > 0 and step % 150 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - step / self.num_steps) # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + self.centers += jiggle_vec + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + progress = step / self.num_steps + buffer_factor = 0.1 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Restoring force on central circle + K_center = 5.0 # Strength of the restoring force + center_target = np.array([0.5, 0.5]) + displacement = center_target - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * displacement + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with potentially asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers. + """ + if grid_size < 2: + return np.array([]) + + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.4, 4) + TOP_N_CANDIDATES = 15 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search for promising initial configurations + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3ed66e82960283253c5a7de0bbb4a6cf0398d1ce Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4c93242413b707d4c71784994fd8b071d8401b70 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.840472432189816, + "spatial_uniformity_details": { + "cell_size_mean": 0.19940626066267014, + "cell_size_std": 0.03784870831073565, + "coefficient_of_variation": 0.18980702007624625 + }, + "edge_utilization": 0.8, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 13, + "corner_score": 1.0, + "edge_score": 0.5 + }, + "density_variance": 0.5083320479801293, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0013337933676518718, + "mean_density": 0.03775894532121028, + "cv": 0.9672180889903089 + }, + "packing_efficiency": 0.7388188354206047, + "packing_efficiency_details": { + "total_area": 0.7388188354206047, + "square_area": 1.0, + "efficiency": 0.7388188354206047, + "relative_to_estimated_best": 0.879546232643577 + }, + "radius_distribution": 0.8956403029078803, + "radius_distribution_details": { + "mean": 0.08912434674416841, + "std": 0.03319607290619549, + "min": 0.04130978265112339, + "max": 0.1943797549233245, + "range": 0.1530699722722011, + "small_count": 8, + "medium_count": 14, + "large_count": 4, + "diversity_score": 0.8956403029078803 + }, + "gap_analysis": 0.7404, + "gap_analysis_details": { + "covered_samples": 1851, + "total_samples": 2500, + "coverage": 0.7404, + "gap_ratio": 0.25960000000000005 + }, + "geometric_quality": 0.6481063639259432, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6481063639259432, + "min_quality": 0.32977670030097644, + "max_quality": 0.8882805554875277 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..9834b1809391e164098004c4bd5d5c7488623482 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 367.17 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3172 + + Auxiliary Metrics: + • spatial_uniformity: 0.840 + • edge_utilization: 0.800 + • density_variance: 0.508 + • packing_efficiency: 0.739 + • radius_distribution: 0.896 + • gap_analysis: 0.740 + • geometric_quality: 0.648 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3172 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.840 + • Boundary and corner utilization: 0.800 + • Area utilization efficiency: 0.739 + • Area coverage (1 - gap ratio): 0.740 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.508 + • Radius size diversity: 0.896 + • Delaunay triangulation quality: 0.648 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..3254b9c186f9179fa4b95e0a02c9d4d9574c6821 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.317233015348379, + "public": { + "centers_str": " centers[0] = (0.4964, 0.4993)\n centers[1] = (0.0945, 0.0811)\n centers[2] = (0.3042, 0.0558)\n centers[3] = (0.5007, 0.0656)\n centers[4] = (0.7592, 0.0413)\n centers[5] = (0.8956, 0.1007)\n centers[6] = (0.1054, 0.2679)\n centers[7] = (0.2932, 0.2005)\n centers[8] = (0.4724, 0.2296)\n centers[9] = (0.6359, 0.0937)\n centers[10] = (0.9199, 0.2867)\n centers[11] = (0.0960, 0.4701)\n centers[12] = (0.2897, 0.4018)\n centers[13] = (0.6854, 0.3306)\n centers[14] = (0.9025, 0.4720)\n centers[15] = (0.1059, 0.6849)\n centers[16] = (0.3485, 0.6485)\n centers[17] = (0.6875, 0.6736)\n centers[18] = (0.9390, 0.7310)\n centers[19] = (0.0995, 0.9005)\n centers[20] = (0.3052, 0.9006)\n centers[21] = (0.5079, 0.9035)\n centers[22] = (0.7224, 0.9333)\n centers[23] = (0.8992, 0.8992)\n centers[24] = (0.4116, 0.1102)\n centers[25] = (0.4583, 0.3771)", + "num_circles": 26, + "aux_spatial_uniformity": 0.840472432189816, + "aux_edge_utilization": 0.8, + "aux_density_variance": 0.5083320479801293, + "aux_packing_efficiency": 0.7388188354206047, + "aux_radius_distribution": 0.8956403029078803, + "aux_gap_analysis": 0.7404, + "aux_geometric_quality": 0.6481063639259432 + }, + "private": { + "reported_sum_of_radii": 2.317233015348379 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3172\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.840\n \u2022 Boundary and corner utilization: 0.800\n \u2022 Area utilization efficiency: 0.739\n \u2022 Area coverage (1 - gap ratio): 0.740\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.508\n \u2022 Radius size diversity: 0.896\n \u2022 Delaunay triangulation quality: 0.648\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_160/results/packing_viz.png", + "execution_time_mean": 367.1707471013069, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..820637ab9f0671c59815f8207cb5456066997abf Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..94e01a20d71c3ba6767ff9b4630b073e8988672e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8410684926450399, + "spatial_uniformity_details": { + "cell_size_mean": 0.20012540721309252, + "cell_size_std": 0.03781645973600491, + "coefficient_of_variation": 0.18896381061088524 + }, + "edge_utilization": 0.6038461538461538, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 10, + "corner_score": 0.75, + "edge_score": 0.38461538461538464 + }, + "density_variance": 0.5190019219217723, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0007481662454943331, + "mean_density": 0.029513768441411434, + "cv": 0.9267751385142792 + }, + "packing_efficiency": 0.7234314343610836, + "packing_efficiency_details": { + "total_area": 0.7234314343610836, + "square_area": 1.0, + "efficiency": 0.7234314343610836, + "relative_to_estimated_best": 0.8612278980489091 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.08912984591420475, + "std": 0.0302095325526665, + "min": 0.026744602425439946, + "max": 0.17557563611235966, + "range": 0.14883103368691972, + "small_count": 6, + "medium_count": 15, + "large_count": 5, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.7252, + "gap_analysis_details": { + "covered_samples": 1813, + "total_samples": 2500, + "coverage": 0.7252, + "gap_ratio": 0.27480000000000004 + }, + "geometric_quality": 0.678484419324397, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.678484419324397, + "min_quality": 0.30171746558961937, + "max_quality": 0.935996382956898 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..d381b22b202e929cf44a36129609b57563f1a954 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 1520.24 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3174 + + Auxiliary Metrics: + • spatial_uniformity: 0.841 + • edge_utilization: 0.604 + • density_variance: 0.519 + • packing_efficiency: 0.723 + • radius_distribution: 0.885 + • gap_analysis: 0.725 + • geometric_quality: 0.678 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3174 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.841 + • Area utilization efficiency: 0.723 + • Area coverage (1 - gap ratio): 0.725 + +📊 Other Metrics: + • Boundary and corner utilization: 0.604 + • Spatial density uniformity across grid: 0.519 + • Radius size diversity: 0.885 + • Delaunay triangulation quality: 0.678 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..038ef10d7ce19fbc022d908bc74c756f4db8b3dd --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3173759937693235, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0774, 0.0774)\n centers[2] = (0.1012, 0.3004)\n centers[3] = (0.0732, 0.5176)\n centers[4] = (0.0273, 0.7319)\n centers[5] = (0.0893, 0.8802)\n centers[6] = (0.2630, 0.1273)\n centers[7] = (0.2385, 0.3195)\n centers[8] = (0.2357, 0.4932)\n centers[9] = (0.1326, 0.6574)\n centers[10] = (0.2787, 0.9125)\n centers[11] = (0.4615, 0.0879)\n centers[12] = (0.4252, 0.2870)\n centers[13] = (0.3614, 0.6900)\n centers[14] = (0.4954, 0.8964)\n centers[15] = (0.6848, 0.1287)\n centers[16] = (0.6399, 0.3734)\n centers[17] = (0.6713, 0.6652)\n centers[18] = (0.7024, 0.9196)\n centers[19] = (0.9090, 0.0910)\n centers[20] = (0.8837, 0.3050)\n centers[21] = (0.9076, 0.5219)\n centers[22] = (0.9215, 0.7074)\n centers[23] = (0.8993, 0.8995)\n centers[24] = (0.1071, 0.4141)\n centers[25] = (0.3855, 0.4655)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8410684926450399, + "aux_edge_utilization": 0.6038461538461538, + "aux_density_variance": 0.5190019219217723, + "aux_packing_efficiency": 0.7234314343610836, + "aux_radius_distribution": 0.8854530804755598, + "aux_gap_analysis": 0.7252, + "aux_geometric_quality": 0.678484419324397 + }, + "private": { + "reported_sum_of_radii": 2.3173759937693235 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3174\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.841\n \u2022 Area utilization efficiency: 0.723\n \u2022 Area coverage (1 - gap ratio): 0.725\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.604\n \u2022 Spatial density uniformity across grid: 0.519\n \u2022 Radius size diversity: 0.885\n \u2022 Delaunay triangulation quality: 0.678\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_164/results/packing_viz.png", + "execution_time_mean": 1520.2429725308903, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3f8fcb0ac664c4ca4285562c9b4140e7a3563e3c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..8aa7ba9663b331504ae762db000e5697f829d4a3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/edit.diff @@ -0,0 +1,310 @@ +--- a/original.py ++++ b/original.py +@@ -1,283 +1,283 @@ + # EVOLVE-BLOCK-START + """ + Hybrid circle packing for n=26 circles, combining a systematic search for + initial configurations with a force-directed dynamic optimizer for refinement. + """ + + import numpy as np + import itertools + + + class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii +- to guide the optimization towards a better packing. +- """ +- def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015): ++ to guide the optimization towards a better packing. The central circle is ++ explicitly fixed to provide a stable anchor for the packing. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate ++ self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): +- progress_ratio = step / self.num_steps + # Linearly decay the learning rate +- learning_rate = self.initial_learning_rate * (1 - progress_ratio) ++ learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + +- # Adaptive parameters that decay over the optimization process +- decay_factor = 1 - progress_ratio +- buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Decays from 0.1 to 0.01 +- K_boundary = 5.0 + (15.0 - 5.0) * decay_factor # Decays from 15.0 to 5.0 +- K_center = 2.0 + (10.0 - 2.0) * decay_factor # Decays from 10.0 to 2.0 +- + # Adaptively determine iteration count for radii calculation +- radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles ++ buffer_factor = 0.05 # Use a fixed buffer for stability + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces ++ K_boundary = 12.0 # Use a strong, fixed boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + +- # 3. Add a restoring force pulling the central circle towards the geometric center +- center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] +- force_vectors[self.central_idx] += K_center * center_offset +- + # --- Update centers --- + self.centers += learning_rate * force_vectors ++ ++ # Fix the central circle to its position to provide a stable anchor ++ if self.central_fixed: ++ self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 +- sc_options = np.array([0.09, 0.1, 0.11]) +- ec_options = np.array([0.89, 0.9, 0.91]) +- central_weight_options = np.linspace(1.2, 2.2, 3) +- +- TOP_N_CANDIDATES = 20 ++ # Broader search space for grid boundaries and central weight ++ sc_options = np.array([0.08, 0.1, 0.12]) ++ ec_options = np.array([0.92, 0.9, 0.88]) ++ central_weight_options = np.linspace(1.5, 3.0, 4) ++ ++ TOP_N_CANDIDATES = 25 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) ++ # Use denser interstitial candidates for better initial placement ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, +- num_steps=2500, +- initial_learning_rate=0.015 ++ num_steps=3000, ++ initial_learning_rate=0.02, ++ central_fixed=True + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/main.py new file mode 100644 index 0000000000000000000000000000000000000000..f03bd6f0ef890f52e7c6339b89101adcc716dfc9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/main.py @@ -0,0 +1,283 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. The central circle is + explicitly fixed to provide a stable anchor for the packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Use a fixed buffer for stability + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 12.0 # Use a strong, fixed boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Fix the central circle to its position to provide a stable anchor + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + # Broader search space for grid boundaries and central weight + sc_options = np.array([0.08, 0.1, 0.12]) + ec_options = np.array([0.92, 0.9, 0.88]) + central_weight_options = np.linspace(1.5, 3.0, 4) + + TOP_N_CANDIDATES = 25 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + # Use denser interstitial candidates for better initial placement + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=3000, + initial_learning_rate=0.02, + central_fixed=True + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/original.py new file mode 100644 index 0000000000000000000000000000000000000000..1324ad426d82e71ffbbc12c97a7558b2d8e3b295 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/original.py @@ -0,0 +1,283 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive parameters that decay over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Decays from 0.1 to 0.01 + K_boundary = 5.0 + (15.0 - 5.0) * decay_factor # Decays from 15.0 to 5.0 + K_center = 2.0 + (10.0 - 2.0) * decay_factor # Decays from 10.0 to 2.0 + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Add a restoring force pulling the central circle towards the geometric center + center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * center_offset + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=2500, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..bb724de02aa515fea35cc45e7ed25014c57def6d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9138814432903769, + "spatial_uniformity_details": { + "cell_size_mean": 0.20199166295280913, + "cell_size_std": 0.0190344499220387, + "coefficient_of_variation": 0.09423383890973679 + }, + "edge_utilization": 0.8, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 13, + "corner_score": 1.0, + "edge_score": 0.5 + }, + "density_variance": 0.5704065800333373, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0005252319470300924, + "mean_density": 0.03043003548459474, + "cv": 0.7531354563643972 + }, + "packing_efficiency": 0.7333540063721833, + "packing_efficiency_details": { + "total_area": 0.7333540063721833, + "square_area": 1.0, + "efficiency": 0.7333540063721833, + "relative_to_estimated_best": 0.8730404837764087 + }, + "radius_distribution": 0.9194324210397706, + "radius_distribution_details": { + "mean": 0.08954190479331282, + "std": 0.030991475091097103, + "min": 0.0018942630185961983, + "max": 0.16072672645455063, + "range": 0.15883246343595445, + "small_count": 6, + "medium_count": 14, + "large_count": 6, + "diversity_score": 0.9194324210397706 + }, + "gap_analysis": 0.7448, + "gap_analysis_details": { + "covered_samples": 1862, + "total_samples": 2500, + "coverage": 0.7448, + "gap_ratio": 0.2552 + }, + "geometric_quality": 0.6820413589201332, + "geometric_quality_details": { + "num_triangles": 39, + "avg_triangle_quality": 0.6820413589201332, + "min_quality": 0.3085824322374703, + "max_quality": 0.9517126432426014 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..0594963b778d9c08a08f2ad358523355644a403a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 4216.40 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3281 + + Auxiliary Metrics: + • spatial_uniformity: 0.914 + • edge_utilization: 0.800 + • density_variance: 0.570 + • packing_efficiency: 0.733 + • radius_distribution: 0.919 + • gap_analysis: 0.745 + • geometric_quality: 0.682 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3281 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.914 + • Boundary and corner utilization: 0.800 + • Area utilization efficiency: 0.733 + • Area coverage (1 - gap ratio): 0.745 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.570 + • Radius size diversity: 0.919 + • Delaunay triangulation quality: 0.682 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..ed96766ef582d00ebc1f736f7baa342466cc4b2f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3280895246261335, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1002, 0.0955)\n centers[2] = (0.3001, 0.0989)\n centers[3] = (0.4699, 0.0847)\n centers[4] = (0.6310, 0.0858)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.0930, 0.2847)\n centers[7] = (0.2813, 0.2562)\n centers[8] = (0.4699, 0.2507)\n centers[9] = (0.9506, 0.2583)\n centers[10] = (0.0790, 0.4623)\n centers[11] = (0.2761, 0.4657)\n centers[12] = (0.8695, 0.4273)\n centers[13] = (0.9622, 0.5787)\n centers[14] = (0.0019, 0.7010)\n centers[15] = (0.1284, 0.6676)\n centers[16] = (0.3850, 0.6849)\n centers[17] = (0.6714, 0.6466)\n centers[18] = (0.9126, 0.7098)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.2995, 0.9017)\n centers[21] = (0.5067, 0.8937)\n centers[22] = (0.7089, 0.9047)\n centers[23] = (0.9021, 0.9021)\n centers[24] = (0.7467, 0.2315)\n centers[25] = (0.6148, 0.3676)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9138814432903769, + "aux_edge_utilization": 0.8, + "aux_density_variance": 0.5704065800333373, + "aux_packing_efficiency": 0.7333540063721833, + "aux_radius_distribution": 0.9194324210397706, + "aux_gap_analysis": 0.7448, + "aux_geometric_quality": 0.6820413589201332 + }, + "private": { + "reported_sum_of_radii": 2.3280895246261335 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3281\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.914\n \u2022 Boundary and corner utilization: 0.800\n \u2022 Area utilization efficiency: 0.733\n \u2022 Area coverage (1 - gap ratio): 0.745\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.570\n \u2022 Radius size diversity: 0.919\n \u2022 Delaunay triangulation quality: 0.682\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/results/packing_viz.png", + "execution_time_mean": 4216.404958290979, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..ace2d57c04ae3a28a5ce1e3b7435ff74e5892db8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_168/search_replace.txt @@ -0,0 +1,377 @@ + +robust_fixed_center_optimizer + + +I'm replacing the current `DynamicPackingOptimizer`, which uses decaying parameters and a soft restoring force for the central circle, with a more robust and historically better-performing version. + +The key changes are: +1. **Fixed Central Anchor:** I'm reintroducing the `central_fixed=True` behavior, which locks the central circle at `[0.5, 0.5]`. Previous high-scoring programs used this, and it provides a stable anchor that simplifies the optimization problem and prevents the entire packing from drifting. The soft restoring force in the current version proved less effective. +2. **Stable Force Parameters:** Instead of decaying parameters (`K_boundary`, `buffer_factor`), I'm using strong, fixed values (`K_boundary=12.0`, `buffer_factor=0.05`). This provides consistent forces throughout the optimization, avoiding potential instabilities from changing dynamics. +3. **Deeper Optimization:** The `__init__` signature is updated to use `num_steps=3000` and `initial_learning_rate=0.02` by default, based on parameters from previously successful runs. This allows for a more thorough exploration of the solution space for each candidate configuration. + +This new optimizer is designed to be more stable and effective at refining good initial layouts into high-density packings. + + +<<<<<<< SEARCH +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive parameters that decay over the optimization process + decay_factor = 1 - progress_ratio + buffer_factor = 0.01 + (0.1 - 0.01) * decay_factor # Decays from 0.1 to 0.01 + K_boundary = 5.0 + (15.0 - 5.0) * decay_factor # Decays from 15.0 to 5.0 + K_center = 2.0 + (10.0 - 2.0) * decay_factor # Decays from 10.0 to 2.0 + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # 3. Add a restoring force pulling the central circle towards the geometric center + center_offset = np.array([0.5, 0.5]) - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * center_offset + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii +======= +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. The central circle is + explicitly fixed to provide a stable anchor for the packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Use a fixed buffer for stability + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 12.0 # Use a strong, fixed boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Fix the central circle to its position to provide a stable anchor + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii +>>>>>>> REPLACE + + +expand_combinatorial_search + + +To feed better initial configurations into the new robust optimizer, I'm expanding the initial combinatorial search in `construct_packing`. + +The improvements are: +1. **Denser Interstitial Candidates:** I'm increasing `density_factor` from 1 to 2 when generating interstitial candidates. This quadruples the number of potential locations for the two crucial interstitial circles, significantly increasing the probability of finding more optimal starting positions for them. These circles are often key to filling gaps or forming the secondary large circles seen in good packings. +2. **Broader Search Parameters:** I'm widening the search space for the central circle weight (`w_central`) to `[1.5, 2.0, 2.5, 3.0]` and the grid boundary options (`sc_options`, `ec_options`). This allows the search to explore a more diverse set of initial topologies, including those with a more dominant central circle. +3. **Wider Funnel:** I'm increasing `TOP_N_CANDIDATES` to 25 to capture more promising candidates for the deep refinement stage. +4. **Optimizer Invocation:** I'm updating the call to `DynamicPackingOptimizer` to match the new, more powerful parameters (`num_steps=3000`, `lr=0.02`) and explicitly setting `central_fixed=True`. + +These changes create a more powerful Stage 1 search, which is critical for finding globally competitive packing structures. + + +<<<<<<< SEARCH +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=2500, + initial_learning_rate=0.015 + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +======= +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + # Broader search space for grid boundaries and central weight + sc_options = np.array([0.08, 0.1, 0.12]) + ec_options = np.array([0.92, 0.9, 0.88]) + central_weight_options = np.linspace(1.5, 3.0, 4) + + TOP_N_CANDIDATES = 25 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + # Use denser interstitial candidates for better initial placement + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=3000, + initial_learning_rate=0.02, + central_fixed=True + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ab8721f52608bb1fc4643f4b74bc9b0a423b914d Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..9ef1887f1838aaa668c66a0d8d2e21b2cde2cf29 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9089521235424773, + "spatial_uniformity_details": { + "cell_size_mean": 0.19241463296070918, + "cell_size_std": 0.019273780618056267, + "coefficient_of_variation": 0.10016795615447809 + }, + "edge_utilization": 0.15, + "edge_utilization_details": { + "corners_touched": 1, + "edges_touched": 0, + "corner_score": 0.25, + "edge_score": 0.0 + }, + "density_variance": 0.430980461443845, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00015702109892411402, + "mean_density": 0.009490942956645227, + "cv": 1.3202908007705492 + }, + "packing_efficiency": 0.4059372768768489, + "packing_efficiency_details": { + "total_area": 0.4059372768768489, + "square_area": 1.0, + "efficiency": 0.4059372768768489, + "relative_to_estimated_best": 0.4832586629486296 + }, + "radius_distribution": 0.9947372351472321, + "radius_distribution_details": { + "mean": 0.06569144013415244, + "std": 0.025581205857377314, + "min": 0.022404293688511857, + "max": 0.10710006643052564, + "range": 0.08469577274201379, + "small_count": 10, + "medium_count": 8, + "large_count": 8, + "diversity_score": 0.9947372351472321 + }, + "gap_analysis": 0.4072, + "gap_analysis_details": { + "covered_samples": 1018, + "total_samples": 2500, + "coverage": 0.4072, + "gap_ratio": 0.5928 + }, + "geometric_quality": 0.6561351361457485, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6561351361457485, + "min_quality": 0.30178582014172844, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..5493ece12f267f91680686650de21405a8e09ddc --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.7080 + + Auxiliary Metrics: + • spatial_uniformity: 0.909 + • edge_utilization: 0.150 + • density_variance: 0.431 + • packing_efficiency: 0.406 + • radius_distribution: 0.995 + • gap_analysis: 0.407 + • geometric_quality: 0.656 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.7080 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.909 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.150 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.431 + → Balance circle density across different regions + • Area utilization efficiency: 0.406 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.407 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.995 + • Delaunay triangulation quality: 0.656 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 1/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 59.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..673fe211cbc0ffe92bf475cb27aa7b5b929243da --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.7079774434879635, + "public": { + "centers_str": " centers[0] = (0.1250, 0.1250)\n centers[1] = (0.3750, 0.1250)\n centers[2] = (0.6250, 0.1250)\n centers[3] = (0.8750, 0.1250)\n centers[4] = (0.1250, 0.3750)\n centers[5] = (0.3750, 0.3750)\n centers[6] = (0.6250, 0.3750)\n centers[7] = (0.8750, 0.3750)\n centers[8] = (0.1250, 0.6250)\n centers[9] = (0.3750, 0.6250)\n centers[10] = (0.6250, 0.6250)\n centers[11] = (0.8750, 0.6250)\n centers[12] = (0.1250, 0.8750)\n centers[13] = (0.3750, 0.8750)\n centers[14] = (0.6250, 0.8750)\n centers[15] = (0.8750, 0.8750)\n centers[16] = (0.2500, 0.2500)\n centers[17] = (0.5000, 0.2500)\n centers[18] = (0.7500, 0.2500)\n centers[19] = (0.2500, 0.5000)\n centers[20] = (0.5000, 0.5000)\n centers[21] = (0.7500, 0.5000)\n centers[22] = (0.2500, 0.7500)\n centers[23] = (0.5000, 0.7500)\n centers[24] = (0.7500, 0.7500)\n centers[25] = (0.0500, 0.0500)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9089521235424773, + "aux_edge_utilization": 0.15, + "aux_density_variance": 0.430980461443845, + "aux_packing_efficiency": 0.4059372768768489, + "aux_radius_distribution": 0.9947372351472321, + "aux_gap_analysis": 0.4072, + "aux_geometric_quality": 0.6561351361457485 + }, + "private": { + "reported_sum_of_radii": 1.7079774434879635 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.7080\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.909\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.150\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.431\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.406\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.407\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.995\n \u2022 Delaunay triangulation quality: 0.656\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 1/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 59.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_17/results/packing_viz.png", + "execution_time_mean": 0.004088776186108589, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1cd67ebb14908fc7e5ec2c397914b74ad208faf6 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..1a9b6804110fe2ce9b92b50fb09a30ee37854216 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8658369858798514, + "spatial_uniformity_details": { + "cell_size_mean": 0.20072127666067108, + "cell_size_std": 0.031102126668379325, + "coefficient_of_variation": 0.1549518169217663 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5596481648226466, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0006878769088730477, + "mean_density": 0.03333271014831459, + "cv": 0.7868369144333773 + }, + "packing_efficiency": 0.7323694788709523, + "packing_efficiency_details": { + "total_area": 0.7323694788709523, + "square_area": 1.0, + "efficiency": 0.7323694788709523, + "relative_to_estimated_best": 0.8718684272273242 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.08838278036065142, + "std": 0.03398021652522869, + "min": 0.0008226958867362529, + "max": 0.16748932221352555, + "range": 0.1666666263267893, + "small_count": 10, + "medium_count": 10, + "large_count": 6, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.7312, + "gap_analysis_details": { + "covered_samples": 1828, + "total_samples": 2500, + "coverage": 0.7312, + "gap_ratio": 0.26880000000000004 + }, + "geometric_quality": 0.6733847134042996, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6733847134042996, + "min_quality": 0.32160840089543113, + "max_quality": 0.9755307924681633 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..05ee2dd3520ea6af64207c10e23126b6139b7b36 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 367.04 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2980 + + Auxiliary Metrics: + • spatial_uniformity: 0.866 + • edge_utilization: 0.785 + • density_variance: 0.560 + • packing_efficiency: 0.732 + • radius_distribution: 0.977 + • gap_analysis: 0.731 + • geometric_quality: 0.673 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2980 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.866 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.732 + • Area coverage (1 - gap ratio): 0.731 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.560 + • Radius size diversity: 0.977 + • Delaunay triangulation quality: 0.673 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..c0370aa4b1f36d677c96b91292a743c1ba2d183f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.297952289376937, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1067, 0.1028)\n centers[2] = (0.2681, 0.0737)\n centers[3] = (0.5212, 0.0912)\n centers[4] = (0.7135, 0.0657)\n centers[5] = (0.8928, 0.1027)\n centers[6] = (0.0888, 0.3009)\n centers[7] = (0.2589, 0.2295)\n centers[8] = (0.4242, 0.2820)\n centers[9] = (0.6627, 0.2903)\n centers[10] = (0.9287, 0.2843)\n centers[11] = (0.0649, 0.4880)\n centers[12] = (0.2621, 0.4532)\n centers[13] = (0.9048, 0.4594)\n centers[14] = (0.0008, 0.6752)\n centers[15] = (0.1333, 0.6887)\n centers[16] = (0.4030, 0.6758)\n centers[17] = (0.6909, 0.6289)\n centers[18] = (0.9233, 0.7088)\n centers[19] = (0.0876, 0.9124)\n centers[20] = (0.2882, 0.8889)\n centers[21] = (0.5026, 0.8995)\n centers[22] = (0.6992, 0.9065)\n centers[23] = (0.8975, 0.8975)\n centers[24] = (0.3934, 0.1364)\n centers[25] = (0.4444, 0.4089)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8658369858798514, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5596481648226466, + "aux_packing_efficiency": 0.7323694788709523, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.7312, + "aux_geometric_quality": 0.6733847134042996 + }, + "private": { + "reported_sum_of_radii": 2.297952289376937 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2980\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.866\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.732\n \u2022 Area coverage (1 - gap ratio): 0.731\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.560\n \u2022 Radius size diversity: 0.977\n \u2022 Delaunay triangulation quality: 0.673\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_170/results/packing_viz.png", + "execution_time_mean": 367.0408516768366, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c54f21a955a9c687f6ae40025393930cd8734b2c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..fd9712bc61f1f02f675f728e2cb077c5d8f67d6a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/edit.diff @@ -0,0 +1,493 @@ +--- a/original.py ++++ b/original.py +@@ -1,256 +1,361 @@ + # EVOLVE-BLOCK-START +-""" +-Constructor-based circle packing for n=26 circles using a two-stage hybrid +-optimization strategy. It combines a broad combinatorial search for initial +-topologies with a deep, force-directed refinement of the best candidates. +-""" +- + import numpy as np ++import random + from itertools import combinations + + + class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version uses a fixed central circle as a stable anchor for the packing structure. + """ +- def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): ++ def __init__(self, initial_centers, interstitial_indices, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) +- self.interstitial_idx = interstitial_idx +- self.central_idx = 0 ++ self.interstitial_indices = interstitial_indices # Expecting a list or single index ++ self.central_idx = 0 # Convention: central circle is always at index 0 + + # Initialize best configuration with max radii for the starting configuration +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Use a strong, constant boundary force for better edge utilization + K_boundary = 15.0 + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 50 == 0 or step == self.num_steps - 1: +- test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) ++ test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +-def _generate_grid_centers(grid_size, start_coord, end_coord): +- """Generates centers for a square grid of circles.""" +- coords = np.linspace(start_coord, end_coord, grid_size) +- return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) +- +- +-def _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2): +- """Generates potential interstitial points with higher density, avoiding coarse grid lines.""" +- if grid_size < 2: +- return np.array([]) +- num_intervals = (grid_size - 1) * density_factor +- step = (end_coord - start_coord) / num_intervals +- +- candidates = [] +- for i in range(num_intervals + 1): +- for j in range(num_intervals + 1): +- # Add point if it's NOT on a coarse grid line (unless it's a boundary) +- if (i % density_factor != 0 or j % density_factor != 0): +- candidates.append([start_coord + j * step, start_coord + i * step]) +- return np.array(candidates) +- +- +-def construct_packing(): +- """ +- Constructs an arrangement of 26 circles using a two-stage process: +- 1. A broad combinatorial search over `1+23+2` configurations, optimizing for +- grid spacing and central circle weight. +- 2. A deep dynamic refinement of the top N best configurations found. +- """ +- n_circles = 26 +- grid_size = 5 +- top_n_to_refine = 20 +- +- # --- STAGE 1: Coarse Combinatorial Search --- +- start_coord_search_space = np.linspace(0.08, 0.12, 4) +- w_central_search_space = np.linspace(1.5, 2.8, 4) +- top_n_configs = [] +- +- for w_central in w_central_search_space: +- for start_coord in start_coord_search_space: +- end_coord = 1.0 - start_coord +- +- all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) +- central_point_coords = np.array([[0.5, 0.5]]) +- central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] +- if not central_idx_in_grid_list.size: continue +- central_idx_in_grid = central_idx_in_grid_list[0] +- potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- +- interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2) +- if len(interstitial_candidates) < 2: continue +- +- num_interstitial_cand = len(interstitial_candidates) +- +- # Loop over removing 1 of 24 peripheral points +- for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): +- current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) +- +- # Loop over pairs of interstitial candidates +- for i, j in combinations(range(num_interstitial_cand), 2): +- interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) +- +- # Assemble config: 1 central, 23 peripheral, 2 interstitial +- current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) +- interstitial_indices = [n_circles - 2, n_circles - 1] +- +- # Fast evaluation with fewer iterations +- radii = compute_max_radii(current_centers, max_iterations=250, interstitial_idx=interstitial_indices, w_central=w_central) +- sum_r = np.sum(radii) +- +- if len(top_n_configs) < top_n_to_refine: +- top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) +- top_n_configs.sort(key=lambda x: x[0], reverse=True) +- elif sum_r > top_n_configs[-1][0]: +- top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) +- top_n_configs.sort(key=lambda x: x[0], reverse=True) +- +- # --- STAGE 2: Dynamic Refinement --- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None +- +- if not top_n_configs: +- # Robust fallback: generate a simple grid-based configuration +- centers = _generate_grid_centers(5, 0.1, 0.9) +- extra_point = np.array([[0.5, 0.3]]) +- centers = np.vstack([centers, extra_point]) +- radii = compute_max_radii(centers) +- return centers, radii +- +- for _, centers, interstitial_idx, w_central in top_n_configs: +- optimizer = DynamicPackingOptimizer(initial_centers=centers, +- interstitial_idx=interstitial_idx, +- w_central=w_central, +- num_circles=n_circles, +- central_fixed=True) # Ensure central circle is fixed +- +- optimized_centers, optimized_radii = optimizer.optimize() +- current_sum_radii = np.sum(optimized_radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = optimized_centers +- best_radii = optimized_radii +- +- return best_centers, best_radii +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- if interstitial_idx is not None: +- indices = np.atleast_1d(interstitial_idx) ++ if interstitial_indices is not None: ++ indices = np.atleast_1d(interstitial_indices) + for idx in indices: + if idx < n: +- other_centers = np.delete(centers, idx, axis=0) +- if len(other_centers) > 0: +- distances = np.linalg.norm(centers[idx] - other_centers, axis=1) ++ # Ensure we don't calculate distance to self ++ other_centers_mask = np.ones(n, dtype=bool) ++ other_centers_mask[idx] = False ++ temp_centers_for_dist = centers[other_centers_mask] ++ ++ if len(temp_centers_for_dist) > 0: ++ distances = np.linalg.norm(centers[idx] - temp_centers_for_dist, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 +- weighted_r_i = radii[i] / w_i +- weighted_r_j = radii[j] / w_j ++ ++ # Prevent division by zero if radius is tiny ++ weighted_r_i = radii[i] / w_i if w_i != 0 else 0 ++ weighted_r_j = radii[j] / w_j if w_j != 0 else 0 ++ + total_weighted = weighted_r_i + weighted_r_j +- if total_weighted > 1e-12: ++ ++ if total_weighted > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) ++ elif (radii[i] + radii[j]) > 1e-12: # Fallback if weighted radii sum is zero but actual sum is not ++ scale_factor = dist / (radii[i] + radii[j]) ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor ++ radii[radii < 0] = 0 # Ensure no negative radii + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) ++ ++ ++class GeneticAlgorithmPacker: ++ """ ++ Implements a Genetic Algorithm to find optimal circle center configurations. ++ It uses a hybrid approach by integrating the DynamicPackingOptimizer as ++ a local refinement step within the GA evolutionary cycle. ++ """ ++ def __init__(self, n_circles=26, population_size=70, generations=150, ++ mutation_rate=0.1, crossover_rate=0.85, local_opt_frequency=0.3, ++ local_opt_steps=200): ++ self.n_circles = n_circles ++ self.population_size = population_size ++ self.generations = generations ++ self.mutation_rate = mutation_rate ++ self.crossover_rate = crossover_rate ++ self.local_opt_frequency = local_opt_frequency ++ self.local_opt_steps = local_opt_steps ++ ++ # Fixed parameters for compute_max_radii and DynamicPackingOptimizer ++ self.w_central = 1.5 ++ # Assuming the last two circles in the array are potential interstitial circles ++ self.interstitial_indices = [n_circles - 2, n_circles - 1] ++ ++ self.population = [] ++ self.best_solution_centers = None ++ self.best_solution_radii = None ++ self.best_fitness = -1.0 ++ ++ def _initialize_population(self): ++ """Initializes the population with diverse configurations.""" ++ for _ in range(self.population_size): ++ centers = np.random.rand(self.n_circles, 2) ++ # Always fix the first circle (central) at [0.5, 0.5] for consistency and stability ++ centers[0] = np.array([0.5, 0.5]) ++ ++ # Apply a light local optimization to initial random population to ensure basic validity ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=centers, ++ interstitial_indices=self.interstitial_indices, ++ w_central=self.w_central, ++ num_circles=self.n_circles, ++ num_steps=50, # Very short initial optimization ++ initial_learning_rate=0.02, ++ central_fixed=True ++ ) ++ optimized_centers, _ = optimizer.optimize() # Radii not needed here ++ self.population.append(optimized_centers) ++ ++ def _evaluate_fitness(self, centers): ++ """Calculates the fitness (sum of radii) for a given center configuration.""" ++ radii = compute_max_radii(centers, max_iterations=500, tolerance=1e-6, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ return np.sum(radii) ++ ++ def _select_parents(self): ++ """Selects parents for the next generation using tournament selection.""" ++ parents = [] ++ tournament_size = 5 # Number of individuals to compete in each tournament ++ for _ in range(self.population_size): ++ contenders = random.sample(self.population, tournament_size) ++ best_contender = max(contenders, key=self._evaluate_fitness) ++ parents.append(best_contender) ++ return parents ++ ++ def _crossover(self, parent1, parent2): ++ """Performs uniform crossover between two parents.""" ++ offspring1 = np.copy(parent1) ++ offspring2 = np.copy(parent2) ++ ++ for i in range(self.n_circles): ++ if random.random() < 0.5: # 50% chance to swap for each circle's position ++ offspring1[i], offspring2[i] = offspring2[i], offspring1[i] ++ return offspring1, offspring2 ++ ++ def _mutate(self, individual): ++ """Applies random perturbations to circle centers.""" ++ mutated_individual = np.copy(individual) ++ for i in range(self.n_circles): ++ if random.random() < self.mutation_rate: ++ # Perturb x, y coordinates by a small, decreasing amount ++ # Ensures larger mutations early and smaller ones later for fine-tuning ++ perturb_amount = 0.05 * (1 - self.generations_done / self.generations) ++ mutated_individual[i, 0] += (random.random() - 0.5) * perturb_amount ++ mutated_individual[i, 1] += (random.random() - 0.5) * perturb_amount ++ ++ # Clip to stay within square bounds (0 to 1) ++ mutated_individual[i, 0] = np.clip(mutated_individual[i, 0], 0, 1) ++ mutated_individual[i, 1] = np.clip(mutated_individual[i, 1], 0, 1) ++ ++ # Ensure central circle remains fixed at [0.5, 0.5] after mutation ++ mutated_individual[0] = np.array([0.5, 0.5]) ++ return mutated_individual ++ ++ def _local_optimize_individual(self, centers, num_steps_local): ++ """Applies a short run of the DynamicPackingOptimizer for local refinement.""" ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=centers, ++ interstitial_indices=self.interstitial_indices, ++ w_central=self.w_central, ++ num_circles=self.n_circles, ++ num_steps=num_steps_local, ++ initial_learning_rate=0.015, ++ central_fixed=True ++ ) ++ optimized_centers, _ = optimizer.optimize() ++ return optimized_centers ++ ++ def run(self): ++ """Executes the Genetic Algorithm optimization.""" ++ self.generations_done = 0 # Track generations for adaptive mutation ++ ++ self._initialize_population() ++ ++ # Evaluate initial population and set initial best solution ++ for individual_centers in self.population: ++ fitness = self._evaluate_fitness(individual_centers) ++ if fitness > self.best_fitness: ++ self.best_fitness = fitness ++ self.best_solution_centers = np.copy(individual_centers) ++ # For initial best, run full local opt to get actual best radii ++ _, self.best_solution_radii = self._local_optimize_full(self.best_solution_centers) ++ ++ ++ for gen in range(self.generations): ++ self.generations_done = gen ++ new_population = [] ++ ++ # Elitism: Carry over the best individual directly ++ if self.best_solution_centers is not None: ++ new_population.append(self.best_solution_centers) ++ ++ parents = self._select_parents() ++ random.shuffle(parents) # Shuffle parents for random pairing ++ ++ # Generate offspring through crossover and mutation ++ # Ensure enough parents for pairing (population_size - len(new_population) handles elitism) ++ for i in range(0, min(self.population_size - len(new_population), len(parents) - 1), 2): ++ parent1 = parents[i] ++ parent2 = parents[i+1] ++ ++ # Crossover ++ if random.random() < self.crossover_rate: ++ offspring1, offspring2 = self._crossover(parent1, parent2) ++ else: # No crossover, just pass parents as offspring ++ offspring1, offspring2 = np.copy(parent1), np.copy(parent2) ++ ++ # Mutation ++ offspring1 = self._mutate(offspring1) ++ offspring2 = self._mutate(offspring2) ++ ++ # Hybrid Local Optimization (Lamarckian Evolution) for a subset ++ if random.random() < self.local_opt_frequency: ++ offspring1 = self._local_optimize_individual(offspring1, self.local_opt_steps) ++ if random.random() < self.local_opt_frequency: ++ offspring2 = self._local_optimize_individual(offspring2, self.local_opt_steps) ++ ++ new_population.append(offspring1) ++ new_population.append(offspring2) ++ ++ # Update population (trim to population_size, handling elitism) ++ self.population = new_population[:self.population_size] ++ ++ # Re-evaluate new population and update global best solution ++ for individual_centers in self.population: ++ fitness = self._evaluate_fitness(individual_centers) ++ if fitness > self.best_fitness: ++ self.best_fitness = fitness ++ self.best_solution_centers = np.copy(individual_centers) ++ # For current best, only store centers. Full radii calculation is done at the end. ++ ++ # print(f"Generation {gen+1}/{self.generations}: Best sum of radii = {self.best_fitness:.4f}") ++ ++ # Final, full-step local optimization on the best found individual ++ final_centers, final_radii = self._local_optimize_full(self.best_solution_centers) ++ return final_centers, final_radii ++ ++ def _local_optimize_full(self, centers): ++ """Runs a full optimization on a candidate solution.""" ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=centers, ++ interstitial_indices=self.interstitial_indices, ++ w_central=self.w_central, ++ num_circles=self.n_circles, ++ num_steps=3000, # Full steps for final refinement ++ initial_learning_rate=0.015, ++ central_fixed=True ++ ) ++ return optimizer.optimize() ++ ++ ++def construct_packing(): ++ """ ++ Constructs an arrangement of 26 circles using a Genetic Algorithm ++ with integrated force-directed local optimization. ++ """ ++ ga_packer = GeneticAlgorithmPacker( ++ n_circles=26, ++ population_size=70, # Increased population size for better exploration ++ generations=150, # Increased generations for more evolutionary steps ++ mutation_rate=0.1, # Balanced mutation rate for exploration ++ crossover_rate=0.85,# High crossover rate to combine good features ++ local_opt_frequency=0.3, # Apply local opt to a significant portion of offspring ++ local_opt_steps=200 # Sufficient steps for local refinement during evolution ++ ) ++ return ga_packer.run() + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/main.py new file mode 100644 index 0000000000000000000000000000000000000000..828fa6e50679272523f7bd4d685e2e89498fe27d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/main.py @@ -0,0 +1,361 @@ +# EVOLVE-BLOCK-START +import numpy as np +import random +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version uses a fixed central circle as a stable anchor for the packing structure. + """ + def __init__(self, initial_centers, interstitial_indices, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices # Expecting a list or single index + self.central_idx = 0 # Convention: central circle is always at index 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Use a strong, constant boundary force for better edge utilization + K_boundary = 15.0 + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices is not None: + indices = np.atleast_1d(interstitial_indices) + for idx in indices: + if idx < n: + # Ensure we don't calculate distance to self + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + temp_centers_for_dist = centers[other_centers_mask] + + if len(temp_centers_for_dist) > 0: + distances = np.linalg.norm(centers[idx] - temp_centers_for_dist, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + # Prevent division by zero if radius is tiny + weighted_r_i = radii[i] / w_i if w_i != 0 else 0 + weighted_r_j = radii[j] / w_j if w_j != 0 else 0 + + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + elif (radii[i] + radii[j]) > 1e-12: # Fallback if weighted radii sum is zero but actual sum is not + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 # Ensure no negative radii + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + +class GeneticAlgorithmPacker: + """ + Implements a Genetic Algorithm to find optimal circle center configurations. + It uses a hybrid approach by integrating the DynamicPackingOptimizer as + a local refinement step within the GA evolutionary cycle. + """ + def __init__(self, n_circles=26, population_size=70, generations=150, + mutation_rate=0.1, crossover_rate=0.85, local_opt_frequency=0.3, + local_opt_steps=200): + self.n_circles = n_circles + self.population_size = population_size + self.generations = generations + self.mutation_rate = mutation_rate + self.crossover_rate = crossover_rate + self.local_opt_frequency = local_opt_frequency + self.local_opt_steps = local_opt_steps + + # Fixed parameters for compute_max_radii and DynamicPackingOptimizer + self.w_central = 1.5 + # Assuming the last two circles in the array are potential interstitial circles + self.interstitial_indices = [n_circles - 2, n_circles - 1] + + self.population = [] + self.best_solution_centers = None + self.best_solution_radii = None + self.best_fitness = -1.0 + + def _initialize_population(self): + """Initializes the population with diverse configurations.""" + for _ in range(self.population_size): + centers = np.random.rand(self.n_circles, 2) + # Always fix the first circle (central) at [0.5, 0.5] for consistency and stability + centers[0] = np.array([0.5, 0.5]) + + # Apply a light local optimization to initial random population to ensure basic validity + optimizer = DynamicPackingOptimizer( + initial_centers=centers, + interstitial_indices=self.interstitial_indices, + w_central=self.w_central, + num_circles=self.n_circles, + num_steps=50, # Very short initial optimization + initial_learning_rate=0.02, + central_fixed=True + ) + optimized_centers, _ = optimizer.optimize() # Radii not needed here + self.population.append(optimized_centers) + + def _evaluate_fitness(self, centers): + """Calculates the fitness (sum of radii) for a given center configuration.""" + radii = compute_max_radii(centers, max_iterations=500, tolerance=1e-6, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + return np.sum(radii) + + def _select_parents(self): + """Selects parents for the next generation using tournament selection.""" + parents = [] + tournament_size = 5 # Number of individuals to compete in each tournament + for _ in range(self.population_size): + contenders = random.sample(self.population, tournament_size) + best_contender = max(contenders, key=self._evaluate_fitness) + parents.append(best_contender) + return parents + + def _crossover(self, parent1, parent2): + """Performs uniform crossover between two parents.""" + offspring1 = np.copy(parent1) + offspring2 = np.copy(parent2) + + for i in range(self.n_circles): + if random.random() < 0.5: # 50% chance to swap for each circle's position + offspring1[i], offspring2[i] = offspring2[i], offspring1[i] + return offspring1, offspring2 + + def _mutate(self, individual): + """Applies random perturbations to circle centers.""" + mutated_individual = np.copy(individual) + for i in range(self.n_circles): + if random.random() < self.mutation_rate: + # Perturb x, y coordinates by a small, decreasing amount + # Ensures larger mutations early and smaller ones later for fine-tuning + perturb_amount = 0.05 * (1 - self.generations_done / self.generations) + mutated_individual[i, 0] += (random.random() - 0.5) * perturb_amount + mutated_individual[i, 1] += (random.random() - 0.5) * perturb_amount + + # Clip to stay within square bounds (0 to 1) + mutated_individual[i, 0] = np.clip(mutated_individual[i, 0], 0, 1) + mutated_individual[i, 1] = np.clip(mutated_individual[i, 1], 0, 1) + + # Ensure central circle remains fixed at [0.5, 0.5] after mutation + mutated_individual[0] = np.array([0.5, 0.5]) + return mutated_individual + + def _local_optimize_individual(self, centers, num_steps_local): + """Applies a short run of the DynamicPackingOptimizer for local refinement.""" + optimizer = DynamicPackingOptimizer( + initial_centers=centers, + interstitial_indices=self.interstitial_indices, + w_central=self.w_central, + num_circles=self.n_circles, + num_steps=num_steps_local, + initial_learning_rate=0.015, + central_fixed=True + ) + optimized_centers, _ = optimizer.optimize() + return optimized_centers + + def run(self): + """Executes the Genetic Algorithm optimization.""" + self.generations_done = 0 # Track generations for adaptive mutation + + self._initialize_population() + + # Evaluate initial population and set initial best solution + for individual_centers in self.population: + fitness = self._evaluate_fitness(individual_centers) + if fitness > self.best_fitness: + self.best_fitness = fitness + self.best_solution_centers = np.copy(individual_centers) + # For initial best, run full local opt to get actual best radii + _, self.best_solution_radii = self._local_optimize_full(self.best_solution_centers) + + + for gen in range(self.generations): + self.generations_done = gen + new_population = [] + + # Elitism: Carry over the best individual directly + if self.best_solution_centers is not None: + new_population.append(self.best_solution_centers) + + parents = self._select_parents() + random.shuffle(parents) # Shuffle parents for random pairing + + # Generate offspring through crossover and mutation + # Ensure enough parents for pairing (population_size - len(new_population) handles elitism) + for i in range(0, min(self.population_size - len(new_population), len(parents) - 1), 2): + parent1 = parents[i] + parent2 = parents[i+1] + + # Crossover + if random.random() < self.crossover_rate: + offspring1, offspring2 = self._crossover(parent1, parent2) + else: # No crossover, just pass parents as offspring + offspring1, offspring2 = np.copy(parent1), np.copy(parent2) + + # Mutation + offspring1 = self._mutate(offspring1) + offspring2 = self._mutate(offspring2) + + # Hybrid Local Optimization (Lamarckian Evolution) for a subset + if random.random() < self.local_opt_frequency: + offspring1 = self._local_optimize_individual(offspring1, self.local_opt_steps) + if random.random() < self.local_opt_frequency: + offspring2 = self._local_optimize_individual(offspring2, self.local_opt_steps) + + new_population.append(offspring1) + new_population.append(offspring2) + + # Update population (trim to population_size, handling elitism) + self.population = new_population[:self.population_size] + + # Re-evaluate new population and update global best solution + for individual_centers in self.population: + fitness = self._evaluate_fitness(individual_centers) + if fitness > self.best_fitness: + self.best_fitness = fitness + self.best_solution_centers = np.copy(individual_centers) + # For current best, only store centers. Full radii calculation is done at the end. + + # print(f"Generation {gen+1}/{self.generations}: Best sum of radii = {self.best_fitness:.4f}") + + # Final, full-step local optimization on the best found individual + final_centers, final_radii = self._local_optimize_full(self.best_solution_centers) + return final_centers, final_radii + + def _local_optimize_full(self, centers): + """Runs a full optimization on a candidate solution.""" + optimizer = DynamicPackingOptimizer( + initial_centers=centers, + interstitial_indices=self.interstitial_indices, + w_central=self.w_central, + num_circles=self.n_circles, + num_steps=3000, # Full steps for final refinement + initial_learning_rate=0.015, + central_fixed=True + ) + return optimizer.optimize() + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a Genetic Algorithm + with integrated force-directed local optimization. + """ + ga_packer = GeneticAlgorithmPacker( + n_circles=26, + population_size=70, # Increased population size for better exploration + generations=150, # Increased generations for more evolutionary steps + mutation_rate=0.1, # Balanced mutation rate for exploration + crossover_rate=0.85,# High crossover rate to combine good features + local_opt_frequency=0.3, # Apply local opt to a significant portion of offspring + local_opt_steps=200 # Sufficient steps for local refinement during evolution + ) + return ga_packer.run() +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/original.py new file mode 100644 index 0000000000000000000000000000000000000000..ef6db6fc5273a767d5bf11eb400ff86dc18839b8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/original.py @@ -0,0 +1,256 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a two-stage hybrid +optimization strategy. It combines a broad combinatorial search for initial +topologies with a deep, force-directed refinement of the best candidates. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version uses a fixed central circle as a stable anchor for the packing structure. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Use a strong, constant boundary force for better edge utilization + K_boundary = 15.0 + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2): + """Generates potential interstitial points with higher density, avoiding coarse grid lines.""" + if grid_size < 2: + return np.array([]) + num_intervals = (grid_size - 1) * density_factor + step = (end_coord - start_coord) / num_intervals + + candidates = [] + for i in range(num_intervals + 1): + for j in range(num_intervals + 1): + # Add point if it's NOT on a coarse grid line (unless it's a boundary) + if (i % density_factor != 0 or j % density_factor != 0): + candidates.append([start_coord + j * step, start_coord + i * step]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search over `1+23+2` configurations, optimizing for + grid spacing and central circle weight. + 2. A deep dynamic refinement of the top N best configurations found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 20 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 4) + w_central_search_space = np.linspace(1.5, 2.8, 4) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] + if not central_idx_in_grid_list.size: continue + central_idx_in_grid = central_idx_in_grid_list[0] + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2) + if len(interstitial_candidates) < 2: continue + + num_interstitial_cand = len(interstitial_candidates) + + # Loop over removing 1 of 24 peripheral points + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Loop over pairs of interstitial candidates + for i, j in combinations(range(num_interstitial_cand), 2): + interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation with fewer iterations + radii = compute_max_radii(current_centers, max_iterations=250, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: + # Robust fallback: generate a simple grid-based configuration + centers = _generate_grid_centers(5, 0.1, 0.9) + extra_point = np.array([[0.5, 0.3]]) + centers = np.vstack([centers, extra_point]) + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + central_fixed=True) # Ensure central circle is fixed + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..2480bf0838f0b6eedf4a1e8fe4df95fdb931cea8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8595627733874482, + "spatial_uniformity_details": { + "cell_size_mean": 0.20535531188527914, + "cell_size_std": 0.03355139555207561, + "coefficient_of_variation": 0.16338216470113415 + }, + "edge_utilization": 0.8153846153846154, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 14, + "corner_score": 1.0, + "edge_score": 0.5384615384615384 + }, + "density_variance": 0.5591934753050197, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0009065905509206769, + "mean_density": 0.038196156487743084, + "cv": 0.7882898212546853 + }, + "packing_efficiency": 0.7705782447865611, + "packing_efficiency_details": { + "total_area": 0.7705782447865611, + "square_area": 1.0, + "efficiency": 0.7705782447865611, + "relative_to_estimated_best": 0.9173550533173347 + }, + "radius_distribution": 0.9986351900937254, + "radius_distribution_details": { + "mean": 0.08845470343712997, + "std": 0.04012124644787038, + "min": 0.02061569056693805, + "max": 0.16829950527982848, + "range": 0.14768381471289044, + "small_count": 9, + "medium_count": 8, + "large_count": 9, + "diversity_score": 0.9986351900937254 + }, + "gap_analysis": 0.7736, + "gap_analysis_details": { + "covered_samples": 1934, + "total_samples": 2500, + "coverage": 0.7736, + "gap_ratio": 0.22640000000000005 + }, + "geometric_quality": 0.6426087448467658, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6426087448467658, + "min_quality": 0.2715288878627691, + "max_quality": 0.9073496411539475 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..7e386ff08fdf00595d06e81c0c5bd8929fc18dc6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 2575.28 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2998 + + Auxiliary Metrics: + • spatial_uniformity: 0.860 + • edge_utilization: 0.815 + • density_variance: 0.559 + • packing_efficiency: 0.771 + • radius_distribution: 0.999 + • gap_analysis: 0.774 + • geometric_quality: 0.643 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2998 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.860 + • Boundary and corner utilization: 0.815 + • Area utilization efficiency: 0.771 + • Area coverage (1 - gap ratio): 0.774 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.559 + • Radius size diversity: 0.999 + • Delaunay triangulation quality: 0.643 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..555a5186b3c5768e01f470eaa795bde8a0bc7c0f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.299822289365379, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0420, 0.2619)\n centers[2] = (0.1520, 0.2079)\n centers[3] = (0.9794, 0.0206)\n centers[4] = (0.0407, 0.9595)\n centers[5] = (0.9207, 0.5521)\n centers[6] = (0.0377, 0.6708)\n centers[7] = (0.8393, 0.7284)\n centers[8] = (0.5283, 0.9463)\n centers[9] = (0.1058, 0.5460)\n centers[10] = (0.2616, 0.0320)\n centers[11] = (0.1881, 0.8116)\n centers[12] = (0.0763, 0.3675)\n centers[13] = (0.2606, 0.3695)\n centers[14] = (0.1725, 0.0612)\n centers[15] = (0.8794, 0.3476)\n centers[16] = (0.7240, 0.5276)\n centers[17] = (0.6538, 0.1173)\n centers[18] = (0.8828, 0.1121)\n centers[19] = (0.5749, 0.3396)\n centers[20] = (0.3934, 0.1487)\n centers[21] = (0.9133, 0.9137)\n centers[22] = (0.7253, 0.9041)\n centers[23] = (0.5264, 0.7315)\n centers[24] = (0.3110, 0.5721)\n centers[25] = (0.3942, 0.9285)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8595627733874482, + "aux_edge_utilization": 0.8153846153846154, + "aux_density_variance": 0.5591934753050197, + "aux_packing_efficiency": 0.7705782447865611, + "aux_radius_distribution": 0.9986351900937254, + "aux_gap_analysis": 0.7736, + "aux_geometric_quality": 0.6426087448467658 + }, + "private": { + "reported_sum_of_radii": 2.299822289365379 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2998\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.860\n \u2022 Boundary and corner utilization: 0.815\n \u2022 Area utilization efficiency: 0.771\n \u2022 Area coverage (1 - gap ratio): 0.774\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.559\n \u2022 Radius size diversity: 0.999\n \u2022 Delaunay triangulation quality: 0.643\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/results/packing_viz.png", + "execution_time_mean": 2575.2847009780817, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..d73bd96dcfbfa2be7135293eb6c961167dc6145d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_171/rewrite.txt @@ -0,0 +1,350 @@ +import numpy as np +import random +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version uses a fixed central circle as a stable anchor for the packing structure. + """ + def __init__(self, initial_centers, interstitial_indices, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices # Expecting a list or single index + self.central_idx = 0 # Convention: central circle is always at index 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Use a strong, constant boundary force for better edge utilization + K_boundary = 15.0 + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices is not None: + indices = np.atleast_1d(interstitial_indices) + for idx in indices: + if idx < n: + # Ensure we don't calculate distance to self + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + temp_centers_for_dist = centers[other_centers_mask] + + if len(temp_centers_for_dist) > 0: + distances = np.linalg.norm(centers[idx] - temp_centers_for_dist, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + # Prevent division by zero if radius is tiny + weighted_r_i = radii[i] / w_i if w_i != 0 else 0 + weighted_r_j = radii[j] / w_j if w_j != 0 else 0 + + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + elif (radii[i] + radii[j]) > 1e-12: # Fallback if weighted radii sum is zero but actual sum is not + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 # Ensure no negative radii + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + +class GeneticAlgorithmPacker: + """ + Implements a Genetic Algorithm to find optimal circle center configurations. + It uses a hybrid approach by integrating the DynamicPackingOptimizer as + a local refinement step within the GA evolutionary cycle. + """ + def __init__(self, n_circles=26, population_size=70, generations=150, + mutation_rate=0.1, crossover_rate=0.85, local_opt_frequency=0.3, + local_opt_steps=200): + self.n_circles = n_circles + self.population_size = population_size + self.generations = generations + self.mutation_rate = mutation_rate + self.crossover_rate = crossover_rate + self.local_opt_frequency = local_opt_frequency + self.local_opt_steps = local_opt_steps + + # Fixed parameters for compute_max_radii and DynamicPackingOptimizer + self.w_central = 1.5 + # Assuming the last two circles in the array are potential interstitial circles + self.interstitial_indices = [n_circles - 2, n_circles - 1] + + self.population = [] + self.best_solution_centers = None + self.best_solution_radii = None + self.best_fitness = -1.0 + + def _initialize_population(self): + """Initializes the population with diverse configurations.""" + for _ in range(self.population_size): + centers = np.random.rand(self.n_circles, 2) + # Always fix the first circle (central) at [0.5, 0.5] for consistency and stability + centers[0] = np.array([0.5, 0.5]) + + # Apply a light local optimization to initial random population to ensure basic validity + optimizer = DynamicPackingOptimizer( + initial_centers=centers, + interstitial_indices=self.interstitial_indices, + w_central=self.w_central, + num_circles=self.n_circles, + num_steps=50, # Very short initial optimization + initial_learning_rate=0.02, + central_fixed=True + ) + optimized_centers, _ = optimizer.optimize() # Radii not needed here + self.population.append(optimized_centers) + + def _evaluate_fitness(self, centers): + """Calculates the fitness (sum of radii) for a given center configuration.""" + radii = compute_max_radii(centers, max_iterations=500, tolerance=1e-6, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + return np.sum(radii) + + def _select_parents(self): + """Selects parents for the next generation using tournament selection.""" + parents = [] + tournament_size = 5 # Number of individuals to compete in each tournament + for _ in range(self.population_size): + contenders = random.sample(self.population, tournament_size) + best_contender = max(contenders, key=self._evaluate_fitness) + parents.append(best_contender) + return parents + + def _crossover(self, parent1, parent2): + """Performs uniform crossover between two parents.""" + offspring1 = np.copy(parent1) + offspring2 = np.copy(parent2) + + for i in range(self.n_circles): + if random.random() < 0.5: # 50% chance to swap for each circle's position + offspring1[i], offspring2[i] = offspring2[i], offspring1[i] + return offspring1, offspring2 + + def _mutate(self, individual): + """Applies random perturbations to circle centers.""" + mutated_individual = np.copy(individual) + for i in range(self.n_circles): + if random.random() < self.mutation_rate: + # Perturb x, y coordinates by a small, decreasing amount + # Ensures larger mutations early and smaller ones later for fine-tuning + perturb_amount = 0.05 * (1 - self.generations_done / self.generations) + mutated_individual[i, 0] += (random.random() - 0.5) * perturb_amount + mutated_individual[i, 1] += (random.random() - 0.5) * perturb_amount + + # Clip to stay within square bounds (0 to 1) + mutated_individual[i, 0] = np.clip(mutated_individual[i, 0], 0, 1) + mutated_individual[i, 1] = np.clip(mutated_individual[i, 1], 0, 1) + + # Ensure central circle remains fixed at [0.5, 0.5] after mutation + mutated_individual[0] = np.array([0.5, 0.5]) + return mutated_individual + + def _local_optimize_individual(self, centers, num_steps_local): + """Applies a short run of the DynamicPackingOptimizer for local refinement.""" + optimizer = DynamicPackingOptimizer( + initial_centers=centers, + interstitial_indices=self.interstitial_indices, + w_central=self.w_central, + num_circles=self.n_circles, + num_steps=num_steps_local, + initial_learning_rate=0.015, + central_fixed=True + ) + optimized_centers, _ = optimizer.optimize() + return optimized_centers + + def run(self): + """Executes the Genetic Algorithm optimization.""" + self.generations_done = 0 # Track generations for adaptive mutation + + self._initialize_population() + + # Evaluate initial population and set initial best solution + for individual_centers in self.population: + fitness = self._evaluate_fitness(individual_centers) + if fitness > self.best_fitness: + self.best_fitness = fitness + self.best_solution_centers = np.copy(individual_centers) + # For initial best, run full local opt to get actual best radii + _, self.best_solution_radii = self._local_optimize_full(self.best_solution_centers) + + + for gen in range(self.generations): + self.generations_done = gen + new_population = [] + + # Elitism: Carry over the best individual directly + if self.best_solution_centers is not None: + new_population.append(self.best_solution_centers) + + parents = self._select_parents() + random.shuffle(parents) # Shuffle parents for random pairing + + # Generate offspring through crossover and mutation + # Ensure enough parents for pairing (population_size - len(new_population) handles elitism) + for i in range(0, min(self.population_size - len(new_population), len(parents) - 1), 2): + parent1 = parents[i] + parent2 = parents[i+1] + + # Crossover + if random.random() < self.crossover_rate: + offspring1, offspring2 = self._crossover(parent1, parent2) + else: # No crossover, just pass parents as offspring + offspring1, offspring2 = np.copy(parent1), np.copy(parent2) + + # Mutation + offspring1 = self._mutate(offspring1) + offspring2 = self._mutate(offspring2) + + # Hybrid Local Optimization (Lamarckian Evolution) for a subset + if random.random() < self.local_opt_frequency: + offspring1 = self._local_optimize_individual(offspring1, self.local_opt_steps) + if random.random() < self.local_opt_frequency: + offspring2 = self._local_optimize_individual(offspring2, self.local_opt_steps) + + new_population.append(offspring1) + new_population.append(offspring2) + + # Update population (trim to population_size, handling elitism) + self.population = new_population[:self.population_size] + + # Re-evaluate new population and update global best solution + for individual_centers in self.population: + fitness = self._evaluate_fitness(individual_centers) + if fitness > self.best_fitness: + self.best_fitness = fitness + self.best_solution_centers = np.copy(individual_centers) + # For current best, only store centers. Full radii calculation is done at the end. + + # print(f"Generation {gen+1}/{self.generations}: Best sum of radii = {self.best_fitness:.4f}") + + # Final, full-step local optimization on the best found individual + final_centers, final_radii = self._local_optimize_full(self.best_solution_centers) + return final_centers, final_radii + + def _local_optimize_full(self, centers): + """Runs a full optimization on a candidate solution.""" + optimizer = DynamicPackingOptimizer( + initial_centers=centers, + interstitial_indices=self.interstitial_indices, + w_central=self.w_central, + num_circles=self.n_circles, + num_steps=3000, # Full steps for final refinement + initial_learning_rate=0.015, + central_fixed=True + ) + return optimizer.optimize() + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a Genetic Algorithm + with integrated force-directed local optimization. + """ + ga_packer = GeneticAlgorithmPacker( + n_circles=26, + population_size=70, # Increased population size for better exploration + generations=150, # Increased generations for more evolutionary steps + mutation_rate=0.1, # Balanced mutation rate for exploration + crossover_rate=0.85,# High crossover rate to combine good features + local_opt_frequency=0.3, # Apply local opt to a significant portion of offspring + local_opt_steps=200 # Sufficient steps for local refinement during evolution + ) + return ga_packer.run() \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a6d3f6a7a364b9cf5add3fcab65b50f4a9bed75f Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5d0c94ea506e0f1d3c64221424690d45cb5c087f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8820904745938811, + "spatial_uniformity_details": { + "cell_size_mean": 0.20441460920734494, + "cell_size_std": 0.02732421488478459, + "coefficient_of_variation": 0.13367055738857744 + }, + "edge_utilization": 0.8, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 13, + "corner_score": 1.0, + "edge_score": 0.5 + }, + "density_variance": 0.5605082713031411, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0006241378314085738, + "mean_density": 0.03186189191002393, + "cv": 0.7840949923452023 + }, + "packing_efficiency": 0.731009843503974, + "packing_efficiency_details": { + "total_area": 0.731009843503974, + "square_area": 1.0, + "efficiency": 0.731009843503974, + "relative_to_estimated_best": 0.8702498136952072 + }, + "radius_distribution": 0.9194324210397706, + "radius_distribution_details": { + "mean": 0.08798821178442019, + "std": 0.03475053920249134, + "min": 0.0012868151878789938, + "max": 0.17203424657340363, + "range": 0.17074743138552465, + "small_count": 6, + "medium_count": 14, + "large_count": 6, + "diversity_score": 0.9194324210397706 + }, + "gap_analysis": 0.7316, + "gap_analysis_details": { + "covered_samples": 1829, + "total_samples": 2500, + "coverage": 0.7316, + "gap_ratio": 0.26839999999999997 + }, + "geometric_quality": 0.6721591779218832, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6721591779218832, + "min_quality": 0.3233428570983498, + "max_quality": 0.9365096775440843 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..9f57c2e4fc2cc1822baa8876330f1797c1b89c8a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 3203.60 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2877 + + Auxiliary Metrics: + • spatial_uniformity: 0.882 + • edge_utilization: 0.800 + • density_variance: 0.561 + • packing_efficiency: 0.731 + • radius_distribution: 0.919 + • gap_analysis: 0.732 + • geometric_quality: 0.672 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2877 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.882 + • Boundary and corner utilization: 0.800 + • Area utilization efficiency: 0.731 + • Area coverage (1 - gap ratio): 0.732 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.561 + • Radius size diversity: 0.919 + • Delaunay triangulation quality: 0.672 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..e727c849ffde3fb49f381c71200172e7567546ea --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.287693506394925, + "public": { + "centers_str": " centers[0] = (0.4931, 0.4936)\n centers[1] = (0.0891, 0.0797)\n centers[2] = (0.2995, 0.1012)\n centers[3] = (0.4858, 0.0780)\n centers[4] = (0.6190, 0.0027)\n centers[5] = (0.9049, 0.0951)\n centers[6] = (0.1184, 0.2750)\n centers[7] = (0.3184, 0.2485)\n centers[8] = (0.6791, 0.1135)\n centers[9] = (0.9048, 0.2939)\n centers[10] = (0.0825, 0.4728)\n centers[11] = (0.2642, 0.4268)\n centers[12] = (0.6766, 0.3545)\n centers[13] = (0.8973, 0.5007)\n centers[14] = (0.0013, 0.7296)\n centers[15] = (0.1098, 0.6781)\n centers[16] = (0.3560, 0.6521)\n centers[17] = (0.6640, 0.6530)\n centers[18] = (0.9151, 0.7099)\n centers[19] = (0.0990, 0.9010)\n centers[20] = (0.2992, 0.9000)\n centers[21] = (0.5079, 0.8926)\n centers[22] = (0.7119, 0.9103)\n centers[23] = (0.9030, 0.9030)\n centers[24] = (0.4350, 0.3783)\n centers[25] = (0.4958, 0.2328)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8820904745938811, + "aux_edge_utilization": 0.8, + "aux_density_variance": 0.5605082713031411, + "aux_packing_efficiency": 0.731009843503974, + "aux_radius_distribution": 0.9194324210397706, + "aux_gap_analysis": 0.7316, + "aux_geometric_quality": 0.6721591779218832 + }, + "private": { + "reported_sum_of_radii": 2.287693506394925 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2877\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.882\n \u2022 Boundary and corner utilization: 0.800\n \u2022 Area utilization efficiency: 0.731\n \u2022 Area coverage (1 - gap ratio): 0.732\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.561\n \u2022 Radius size diversity: 0.919\n \u2022 Delaunay triangulation quality: 0.672\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_175/results/packing_viz.png", + "execution_time_mean": 3203.596247372683, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fb51213a93743571891104745b591ed1a94f752e Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..78471a4962014aa0d5939d886eb25814b09dfb24 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/edit.diff @@ -0,0 +1,371 @@ +--- a/original.py ++++ b/original.py +@@ -1,237 +1,174 @@ + # EVOLVE-BLOCK-START +-""" +-Hybrid circle packing for n=26 circles, combining a systematic combinatorial search +-for promising initial configurations with a force-directed dynamic optimizer for refinement. +-""" ++import numpy as np + +-import numpy as np +-import itertools ++def compute_max_radii_pso(centers, max_iterations=1000, tolerance=1e-7, w_central=1.5): ++ """ ++ Computes maximum radii for a given set of centers using iterative relaxation. ++ This version dynamically identifies the "central" circle (closest to [0.5, 0.5]) ++ and applies the weight `w_central` to it, making the search more flexible. ++ """ ++ n = centers.shape[0] ++ if n == 0: ++ return np.array([]) ++ ++ radii = np.zeros(n) + +- +-class DynamicPackingOptimizer: +- """ +- Optimizes circle packing using a force-directed approach. Starting from an +- initial configuration, it iteratively adjusts circle centers based on +- repulsion forces and boundaries, while repeatedly calculating maximum radii +- to guide the optimization towards a better packing. The central circle is +- kept fixed to provide a stable anchor. +- """ +- def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): +- self.n_circles = num_circles +- self.num_steps = num_steps +- self.initial_learning_rate = initial_learning_rate +- self.central_fixed = central_fixed +- +- self.centers = np.copy(initial_centers) +- self.interstitial_indices = interstitial_indices +- self.w_central = w_central +- self.central_idx = 0 # The central circle is at index 0 by convention +- +- # Initialize best configuration with max radii for the starting layout +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) +- self.best_sum_radii = np.sum(self.radii) +- self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(self.radii) +- +- def optimize(self): +- """Runs the force-directed optimization loop.""" +- for step in range(self.num_steps): +- # Linearly decay the learning rate +- learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) +- learning_rate = max(learning_rate, 1e-7) +- +- # Adaptively determine iteration count for radii calculation +- radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) +- +- # Periodically check for improvement with a full, accurate radius calculation +- if step % 50 == 0 or step == self.num_steps - 1: +- test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) +- current_sum_radii = np.sum(test_radii) +- if current_sum_radii > self.best_sum_radii: +- self.best_sum_radii = current_sum_radii +- self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(test_radii) +- +- # --- Calculate force vectors for center movement --- +- force_vectors = np.zeros_like(self.centers) +- +- # 1. Repulsion between circles +- buffer_factor = 0.05 # Apply force even before contact for smoother movement +- for i in range(self.n_circles): +- for j in range(i + 1, self.n_circles): +- dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) +- target_dist = current_radii[i] + current_radii[j] +- if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: +- overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) +- direction = (self.centers[i] - self.centers[j]) / dist_ij +- force_vectors[i] += direction * overlap_factor +- force_vectors[j] -= direction * overlap_factor +- +- # 2. Boundary repulsion forces +- K_boundary = 10.0 # Strong boundary force +- for i in range(self.n_circles): +- x, y = self.centers[i] +- r = current_radii[i] +- if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) +- if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) +- if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) +- if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) +- +- # --- Update centers --- +- self.centers += learning_rate * force_vectors +- +- if self.central_fixed: +- self.centers[self.central_idx] = np.array([0.5, 0.5]) +- +- # Clip centers to ensure they stay within radius distance of boundaries +- for i in range(self.n_circles): +- r = current_radii[i] +- self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) +- self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) +- +- return self.best_centers, self.best_radii +- +- +-def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): +- x_coords = np.linspace(sc_x, ec_x, grid_size) +- y_coords = np.linspace(sc_y, ec_y, grid_size) +- return np.array([[x, y] for y in y_coords for x in x_coords]) +- +- +-def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): +- if grid_size < 2: +- return np.array([]) +- step_x = (ec_x - sc_x) / (grid_size - 1) +- step_y = (ec_y - sc_y) / (grid_size - 1) +- candidates = [] +- for i in range(grid_size - 1): +- for j in range(grid_size - 1): +- candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) +- return np.array(candidates) +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): +- n = centers.shape[0] +- radii = np.zeros(n) ++ # Initialize radii based on distance to square borders + for i in range(n): + x, y = centers[i] +- radii[i] = min(x, y, 1 - x, 1 - y) ++ radii[i] = min(x, 1 - x, y, 1 - y) ++ ++ # Dynamically find the circle closest to the geometric center ++ center_point = np.array([0.5, 0.5]) ++ central_idx = np.argmin(np.linalg.norm(centers - center_point, axis=1)) + +- if interstitial_indices is not None: +- for idx in interstitial_indices: +- if idx < n: +- other_centers = np.delete(centers, idx, axis=0) +- if len(other_centers) > 0: +- distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) +- min_dist_to_neighbor = np.min(distances_to_others) +- radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) +- ++ # Iteratively adjust radii to resolve overlaps + for _ in range(max_iterations): + prev_radii = np.copy(radii) ++ + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist +- w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 ++ ++ w_i = w_central if i == central_idx else 1.0 ++ w_j = w_central if j == central_idx else 1.0 ++ ++ # Reduction is proportional to radius and inversely proportional to weight. ++ # This logic is adapted from successful previous implementations. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j ++ + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) ++ + radii[radii < 0] = 0 ++ + if np.allclose(radii, prev_radii, atol=tolerance): + break ++ + return np.maximum(radii, 0) ++ ++ ++class ParticleSwarmOptimizer: ++ """ ++ Solves the circle packing problem using Particle Swarm Optimization (PSO). ++ """ ++ def __init__(self, n_circles, n_particles, n_iterations, w_central): ++ self.n_circles = n_circles ++ self.dim = n_circles * 2 ++ self.n_particles = n_particles ++ self.n_iterations = n_iterations ++ self.w_central = w_central ++ ++ # PSO parameters with common effective values ++ self.w_max = 0.9 ++ self.w_min = 0.4 ++ self.c1 = 2.0 ++ self.c2 = 2.0 ++ ++ # Initialize swarm state ++ self.positions = np.random.rand(self.n_particles, self.dim) ++ self.velocities = np.random.uniform(-0.1, 0.1, (self.n_particles, self.dim)) ++ ++ self.pbest_positions = np.copy(self.positions) ++ self.pbest_scores = np.full(self.n_particles, -1.0) ++ ++ self.gbest_position = None ++ self.gbest_score = -1.0 ++ ++ def _evaluate_fitness(self, position_vector, max_iter): ++ """Calculates the sum of radii for a given position vector.""" ++ centers = position_vector.reshape(self.n_circles, 2) ++ radii = compute_max_radii_pso(centers, max_iterations=max_iter, w_central=self.w_central) ++ return np.sum(radii) ++ ++ def optimize(self): ++ """Runs the PSO main loop.""" ++ # Initial evaluation of the entire swarm ++ for i in range(self.n_particles): ++ score = self._evaluate_fitness(self.positions[i], max_iter=250) ++ self.pbest_scores[i] = score ++ if score > self.gbest_score: ++ self.gbest_score = score ++ self.gbest_position = np.copy(self.positions[i]) ++ ++ # Main optimization loop ++ for it in range(self.n_iterations): ++ # Adapt inertia weight linearly ++ w = self.w_max - (self.w_max - self.w_min) * (it / self.n_iterations) ++ ++ # Adaptively set max_iterations for fitness evaluation ++ eval_max_iter = 200 if it < self.n_iterations * 0.9 else 600 ++ ++ for i in range(self.n_particles): ++ # Update velocity ++ r1 = np.random.rand(self.dim) ++ r2 = np.random.rand(self.dim) ++ cognitive_velocity = self.c1 * r1 * (self.pbest_positions[i] - self.positions[i]) ++ social_velocity = self.c2 * r2 * (self.gbest_position - self.positions[i]) ++ self.velocities[i] = w * self.velocities[i] + cognitive_velocity + social_velocity ++ ++ # Update position ++ self.positions[i] += self.velocities[i] ++ ++ # Boundary handling: clip positions to stay within [0, 1] ++ np.clip(self.positions[i], 0.0, 1.0, out=self.positions[i]) ++ ++ # Evaluate new position ++ score = self._evaluate_fitness(self.positions[i], max_iter=eval_max_iter) ++ ++ # Update personal best ++ if score > self.pbest_scores[i]: ++ self.pbest_scores[i] = score ++ self.pbest_positions[i] = np.copy(self.positions[i]) ++ ++ # Update global best ++ if score > self.gbest_score: ++ self.gbest_score = score ++ self.gbest_position = np.copy(self.positions[i]) ++ ++ # Final high-precision calculation for the best found solution ++ final_centers = self.gbest_position.reshape(self.n_circles, 2) ++ final_radii = compute_max_radii_pso(final_centers, max_iterations=4000, w_central=self.w_central, tolerance=1e-8) ++ ++ return final_centers, final_radii + + + def construct_packing(): + """ +- Constructs an arrangement of 26 circles using a two-stage hybrid process: +- 1. A broad combinatorial search finds promising initial topologies. +- 2. A force-directed dynamic optimization refines the best candidates. ++ Constructs an arrangement of 26 circles using Particle Swarm Optimization (PSO). ++ This method explores the solution space using a population of candidate solutions ++ that evolve over time based on individual and collective best-found positions. + """ + n_circles = 26 +- grid_size = 5 + +- # Stage 1 Parameters +- sc_options = np.array([0.09, 0.1, 0.11]) +- ec_options = np.array([0.89, 0.9, 0.91]) +- central_weight_options = np.linspace(1.2, 2.2, 3) +- TOP_N_CANDIDATES = 15 +- top_candidates = [] ++ # PSO Hyperparameters - chosen for a balance of exploration and exploitation ++ n_particles = 60 # More particles for better coverage of the search space ++ n_iterations = 300 # More iterations for deeper search ++ w_central = 2.2 # A strong weight for the central circle, guided by prior results + +- num_fixed_central = 1 +- num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 +- num_interstitial_to_select = 2 +- interstitial_circle_indices = list(range(1 + num_peripheral_to_select, n_circles)) +- +- # STAGE 1: Coarse Combinatorial Search for promising initial configurations +- for w_central in central_weight_options: +- for sc_x in sc_options: +- for ec_x in ec_options: +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue +- for sc_y in sc_options: +- for ec_y in ec_options: +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue +- +- all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) +- +- central_point = np.array([0.5, 0.5]) +- peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) +- +- for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral = peripheral_grid_points[list(p_indices)] +- for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial = all_interstitial_candidates[list(i_indices)] +- current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) +- +- coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=interstitial_circle_indices, w_central=w_central) +- coarse_sum_radii = np.sum(coarse_radii) +- +- if len(top_candidates) < TOP_N_CANDIDATES: +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) +- elif coarse_sum_radii > top_candidates[-1][0]: +- top_candidates.pop() +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) +- +- # STAGE 2: Refine Top Candidates with Dynamic Optimizer +- if not top_candidates: +- return np.random.rand(n_circles, 2), np.zeros(n_circles) +- +- best_sum_radii = 0.0 +- best_centers = top_candidates[0][1] +- best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) +- best_sum_radii = np.sum(best_radii) +- +- for _, initial_centers, w_central in top_candidates: +- optimizer = DynamicPackingOptimizer( +- initial_centers=initial_centers, +- interstitial_indices=interstitial_circle_indices, +- w_central=w_central +- ) +- optimized_centers, optimized_radii = optimizer.optimize() +- current_sum_radii = np.sum(optimized_radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = optimized_centers +- best_radii = optimized_radii ++ # Create and run the optimizer ++ optimizer = ParticleSwarmOptimizer( ++ n_circles=n_circles, ++ n_particles=n_particles, ++ n_iterations=n_iterations, ++ w_central=w_central ++ ) ++ ++ best_centers, best_radii = optimizer.optimize() + + return best_centers, best_radii + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/main.py new file mode 100644 index 0000000000000000000000000000000000000000..6dde930dfa2864ee46a145e0bf1ce9fbf92f4958 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/main.py @@ -0,0 +1,174 @@ +# EVOLVE-BLOCK-START +import numpy as np + +def compute_max_radii_pso(centers, max_iterations=1000, tolerance=1e-7, w_central=1.5): + """ + Computes maximum radii for a given set of centers using iterative relaxation. + This version dynamically identifies the "central" circle (closest to [0.5, 0.5]) + and applies the weight `w_central` to it, making the search more flexible. + """ + n = centers.shape[0] + if n == 0: + return np.array([]) + + radii = np.zeros(n) + + # Initialize radii based on distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, 1 - x, y, 1 - y) + + # Dynamically find the circle closest to the geometric center + center_point = np.array([0.5, 0.5]) + central_idx = np.argmin(np.linalg.norm(centers - center_point, axis=1)) + + # Iteratively adjust radii to resolve overlaps + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == central_idx else 1.0 + w_j = w_central if j == central_idx else 1.0 + + # Reduction is proportional to radius and inversely proportional to weight. + # This logic is adapted from successful previous implementations. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + +class ParticleSwarmOptimizer: + """ + Solves the circle packing problem using Particle Swarm Optimization (PSO). + """ + def __init__(self, n_circles, n_particles, n_iterations, w_central): + self.n_circles = n_circles + self.dim = n_circles * 2 + self.n_particles = n_particles + self.n_iterations = n_iterations + self.w_central = w_central + + # PSO parameters with common effective values + self.w_max = 0.9 + self.w_min = 0.4 + self.c1 = 2.0 + self.c2 = 2.0 + + # Initialize swarm state + self.positions = np.random.rand(self.n_particles, self.dim) + self.velocities = np.random.uniform(-0.1, 0.1, (self.n_particles, self.dim)) + + self.pbest_positions = np.copy(self.positions) + self.pbest_scores = np.full(self.n_particles, -1.0) + + self.gbest_position = None + self.gbest_score = -1.0 + + def _evaluate_fitness(self, position_vector, max_iter): + """Calculates the sum of radii for a given position vector.""" + centers = position_vector.reshape(self.n_circles, 2) + radii = compute_max_radii_pso(centers, max_iterations=max_iter, w_central=self.w_central) + return np.sum(radii) + + def optimize(self): + """Runs the PSO main loop.""" + # Initial evaluation of the entire swarm + for i in range(self.n_particles): + score = self._evaluate_fitness(self.positions[i], max_iter=250) + self.pbest_scores[i] = score + if score > self.gbest_score: + self.gbest_score = score + self.gbest_position = np.copy(self.positions[i]) + + # Main optimization loop + for it in range(self.n_iterations): + # Adapt inertia weight linearly + w = self.w_max - (self.w_max - self.w_min) * (it / self.n_iterations) + + # Adaptively set max_iterations for fitness evaluation + eval_max_iter = 200 if it < self.n_iterations * 0.9 else 600 + + for i in range(self.n_particles): + # Update velocity + r1 = np.random.rand(self.dim) + r2 = np.random.rand(self.dim) + cognitive_velocity = self.c1 * r1 * (self.pbest_positions[i] - self.positions[i]) + social_velocity = self.c2 * r2 * (self.gbest_position - self.positions[i]) + self.velocities[i] = w * self.velocities[i] + cognitive_velocity + social_velocity + + # Update position + self.positions[i] += self.velocities[i] + + # Boundary handling: clip positions to stay within [0, 1] + np.clip(self.positions[i], 0.0, 1.0, out=self.positions[i]) + + # Evaluate new position + score = self._evaluate_fitness(self.positions[i], max_iter=eval_max_iter) + + # Update personal best + if score > self.pbest_scores[i]: + self.pbest_scores[i] = score + self.pbest_positions[i] = np.copy(self.positions[i]) + + # Update global best + if score > self.gbest_score: + self.gbest_score = score + self.gbest_position = np.copy(self.positions[i]) + + # Final high-precision calculation for the best found solution + final_centers = self.gbest_position.reshape(self.n_circles, 2) + final_radii = compute_max_radii_pso(final_centers, max_iterations=4000, w_central=self.w_central, tolerance=1e-8) + + return final_centers, final_radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using Particle Swarm Optimization (PSO). + This method explores the solution space using a population of candidate solutions + that evolve over time based on individual and collective best-found positions. + """ + n_circles = 26 + + # PSO Hyperparameters - chosen for a balance of exploration and exploitation + n_particles = 60 # More particles for better coverage of the search space + n_iterations = 300 # More iterations for deeper search + w_central = 2.2 # A strong weight for the central circle, guided by prior results + + # Create and run the optimizer + optimizer = ParticleSwarmOptimizer( + n_circles=n_circles, + n_particles=n_particles, + n_iterations=n_iterations, + w_central=w_central + ) + + best_centers, best_radii = optimizer.optimize() + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/original.py new file mode 100644 index 0000000000000000000000000000000000000000..863dda41ac616ad8aa577b60682725aab8bd55f5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/original.py @@ -0,0 +1,237 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic combinatorial search +for promising initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. The central circle is + kept fixed to provide a stable anchor. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Apply force even before contact for smoother movement + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 10.0 # Strong boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y): + if grid_size < 2: + return np.array([]) + step_x = (ec_x - sc_x) / (grid_size - 1) + step_y = (ec_y - sc_y) / (grid_size - 1) + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + n = centers.shape[0] + radii = np.zeros(n) + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices is not None: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return np.maximum(radii, 0) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage hybrid process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + + # Stage 1 Parameters + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + TOP_N_CANDIDATES = 15 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + interstitial_circle_indices = list(range(1 + num_peripheral_to_select, n_circles)) + + # STAGE 1: Coarse Combinatorial Search for promising initial configurations + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices)] + for i_indices in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial = all_interstitial_candidates[list(i_indices)] + current_centers = np.array([central_point] + list(selected_peripheral) + list(selected_interstitial)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, interstitial_indices=interstitial_circle_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = 0.0 + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2]) + best_sum_radii = np.sum(best_radii) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..da4742c5e81156f624ff787c13d093d2332f8b9e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.789065311078094, + "spatial_uniformity_details": { + "cell_size_mean": 0.18969982093127571, + "cell_size_std": 0.05071097710903476, + "coefficient_of_variation": 0.2673222177689038 + }, + "edge_utilization": 0.7423076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 19, + "corner_score": 0.75, + "edge_score": 0.7307692307692307 + }, + "density_variance": 0.527914972727363, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0032596470379374536, + "mean_density": 0.06384531506136222, + "cv": 0.8942444364358676 + }, + "packing_efficiency": 0.7349980063859984, + "packing_efficiency_details": { + "total_area": 0.7349980063859984, + "square_area": 1.0, + "efficiency": 0.7349980063859984, + "relative_to_estimated_best": 0.8749976266499981 + }, + "radius_distribution": 0.990349616966463, + "radius_distribution_details": { + "mean": 0.06951304767210108, + "std": 0.06454678477507061, + "min": 0.0, + "max": 0.22088165404559806, + "range": 0.22088165404559806, + "small_count": 9, + "medium_count": 10, + "large_count": 7, + "diversity_score": 0.990349616966463 + }, + "gap_analysis": 0.738, + "gap_analysis_details": { + "covered_samples": 1845, + "total_samples": 2500, + "coverage": 0.738, + "gap_ratio": 0.262 + }, + "geometric_quality": 0.5517791128695168, + "geometric_quality_details": { + "num_triangles": 39, + "avg_triangle_quality": 0.5517791128695168, + "min_quality": 0.09644519193378251, + "max_quality": 0.9042356401357066 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..68d43cddeb7b3fcb416ac166d091704d202412ca --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 43.41 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8073 + + Auxiliary Metrics: + • spatial_uniformity: 0.789 + • edge_utilization: 0.742 + • density_variance: 0.528 + • packing_efficiency: 0.735 + • radius_distribution: 0.990 + • gap_analysis: 0.738 + • geometric_quality: 0.552 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8073 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.789 + • Boundary and corner utilization: 0.742 + • Area utilization efficiency: 0.735 + • Area coverage (1 - gap ratio): 0.738 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.528 + • Radius size diversity: 0.990 + • Delaunay triangulation quality: 0.552 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..7aca0f7279d0bee0a12a013a88138432fa27648c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8073392394746282, + "public": { + "centers_str": " centers[0] = (0.9375, 0.9436)\n centers[1] = (0.3472, 0.3476)\n centers[2] = (0.7384, 0.1166)\n centers[3] = (0.5865, 0.4051)\n centers[4] = (0.0000, 0.1115)\n centers[5] = (0.9193, 0.1444)\n centers[6] = (0.8847, 0.0331)\n centers[7] = (0.7573, 0.0000)\n centers[8] = (0.0506, 0.2597)\n centers[9] = (0.0434, 0.0425)\n centers[10] = (0.8051, 0.7564)\n centers[11] = (0.8979, 0.4898)\n centers[12] = (0.1770, 0.4682)\n centers[13] = (0.9862, 1.0000)\n centers[14] = (1.0000, 0.1501)\n centers[15] = (0.2848, 0.0000)\n centers[16] = (1.0000, 0.9076)\n centers[17] = (0.5693, 0.0726)\n centers[18] = (1.0000, 0.6161)\n centers[19] = (0.2154, 0.9479)\n centers[20] = (0.0678, 0.8781)\n centers[21] = (0.1030, 0.7187)\n centers[22] = (0.4311, 0.8032)\n centers[23] = (0.3187, 0.2722)\n centers[24] = (0.3956, 0.1077)\n centers[25] = (0.1704, 0.1424)", + "num_circles": 26, + "aux_spatial_uniformity": 0.789065311078094, + "aux_edge_utilization": 0.7423076923076923, + "aux_density_variance": 0.527914972727363, + "aux_packing_efficiency": 0.7349980063859984, + "aux_radius_distribution": 0.990349616966463, + "aux_gap_analysis": 0.738, + "aux_geometric_quality": 0.5517791128695168 + }, + "private": { + "reported_sum_of_radii": 1.8073392394746282 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8073\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.789\n \u2022 Boundary and corner utilization: 0.742\n \u2022 Area utilization efficiency: 0.735\n \u2022 Area coverage (1 - gap ratio): 0.738\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.528\n \u2022 Radius size diversity: 0.990\n \u2022 Delaunay triangulation quality: 0.552\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/results/packing_viz.png", + "execution_time_mean": 43.408684647176415, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..0047b1d71a67bc64ac2e8f0756bce21b4431ebf7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_176/rewrite.txt @@ -0,0 +1,165 @@ +# EVOLVE-BLOCK-START +import numpy as np + +def compute_max_radii_pso(centers, max_iterations=1000, tolerance=1e-7, w_central=1.5): + """ + Computes maximum radii for a given set of centers using iterative relaxation. + This version dynamically identifies the "central" circle (closest to [0.5, 0.5]) + and applies the weight `w_central` to it, making the search more flexible. + """ + n = centers.shape[0] + if n == 0: + return np.array([]) + + radii = np.zeros(n) + + # Initialize radii based on distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, 1 - x, y, 1 - y) + + # Dynamically find the circle closest to the geometric center + center_point = np.array([0.5, 0.5]) + central_idx = np.argmin(np.linalg.norm(centers - center_point, axis=1)) + + # Iteratively adjust radii to resolve overlaps + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = w_central if i == central_idx else 1.0 + w_j = w_central if j == central_idx else 1.0 + + # Reduction is proportional to radius and inversely proportional to weight. + # This logic is adapted from successful previous implementations. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + + +class ParticleSwarmOptimizer: + """ + Solves the circle packing problem using Particle Swarm Optimization (PSO). + """ + def __init__(self, n_circles, n_particles, n_iterations, w_central): + self.n_circles = n_circles + self.dim = n_circles * 2 + self.n_particles = n_particles + self.n_iterations = n_iterations + self.w_central = w_central + + # PSO parameters with common effective values + self.w_max = 0.9 + self.w_min = 0.4 + self.c1 = 2.0 + self.c2 = 2.0 + + # Initialize swarm state + self.positions = np.random.rand(self.n_particles, self.dim) + self.velocities = np.random.uniform(-0.1, 0.1, (self.n_particles, self.dim)) + + self.pbest_positions = np.copy(self.positions) + self.pbest_scores = np.full(self.n_particles, -1.0) + + self.gbest_position = None + self.gbest_score = -1.0 + + def _evaluate_fitness(self, position_vector, max_iter): + """Calculates the sum of radii for a given position vector.""" + centers = position_vector.reshape(self.n_circles, 2) + radii = compute_max_radii_pso(centers, max_iterations=max_iter, w_central=self.w_central) + return np.sum(radii) + + def optimize(self): + """Runs the PSO main loop.""" + # Initial evaluation of the entire swarm + for i in range(self.n_particles): + score = self._evaluate_fitness(self.positions[i], max_iter=250) + self.pbest_scores[i] = score + if score > self.gbest_score: + self.gbest_score = score + self.gbest_position = np.copy(self.positions[i]) + + # Main optimization loop + for it in range(self.n_iterations): + # Adapt inertia weight linearly + w = self.w_max - (self.w_max - self.w_min) * (it / self.n_iterations) + + # Adaptively set max_iterations for fitness evaluation + eval_max_iter = 200 if it < self.n_iterations * 0.9 else 600 + + for i in range(self.n_particles): + # Update velocity + r1 = np.random.rand(self.dim) + r2 = np.random.rand(self.dim) + cognitive_velocity = self.c1 * r1 * (self.pbest_positions[i] - self.positions[i]) + social_velocity = self.c2 * r2 * (self.gbest_position - self.positions[i]) + self.velocities[i] = w * self.velocities[i] + cognitive_velocity + social_velocity + + # Update position + self.positions[i] += self.velocities[i] + + # Boundary handling: clip positions to stay within [0, 1] + np.clip(self.positions[i], 0.0, 1.0, out=self.positions[i]) + + # Evaluate new position + score = self._evaluate_fitness(self.positions[i], max_iter=eval_max_iter) + + # Update personal best + if score > self.pbest_scores[i]: + self.pbest_scores[i] = score + self.pbest_positions[i] = np.copy(self.positions[i]) + + # Update global best + if score > self.gbest_score: + self.gbest_score = score + self.gbest_position = np.copy(self.positions[i]) + + # Final high-precision calculation for the best found solution + final_centers = self.gbest_position.reshape(self.n_circles, 2) + final_radii = compute_max_radii_pso(final_centers, max_iterations=4000, w_central=self.w_central, tolerance=1e-8) + + return final_centers, final_radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using Particle Swarm Optimization (PSO). + This method explores the solution space using a population of candidate solutions + that evolve over time based on individual and collective best-found positions. + """ + n_circles = 26 + + # PSO Hyperparameters - chosen for a balance of exploration and exploitation + n_particles = 60 # More particles for better coverage of the search space + n_iterations = 300 # More iterations for deeper search + w_central = 2.2 # A strong weight for the central circle, guided by prior results + + # Create and run the optimizer + optimizer = ParticleSwarmOptimizer( + n_circles=n_circles, + n_particles=n_particles, + n_iterations=n_iterations, + w_central=w_central + ) + + best_centers, best_radii = optimizer.optimize() + + return best_centers, best_radii +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bbedef872d7e2edeedddb9f47d1e88fbfd0d2c72 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..7948c93b83b798f0dd95046120ebc140c9316db4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8789395196907688, + "spatial_uniformity_details": { + "cell_size_mean": 0.2027771361730147, + "cell_size_std": 0.027929450288607657, + "coefficient_of_variation": 0.13773471052004016 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5353249188100495, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0009639446724528397, + "mean_density": 0.035767955609808715, + "cv": 0.8680243808243723 + }, + "packing_efficiency": 0.7488846482584683, + "packing_efficiency_details": { + "total_area": 0.7488846482584683, + "square_area": 1.0, + "efficiency": 0.7488846482584683, + "relative_to_estimated_best": 0.8915293431648433 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.08986151166010882, + "std": 0.0330646301425792, + "min": 0.0019017702590188794, + "max": 0.17382130271421323, + "range": 0.17191953245519434, + "small_count": 6, + "medium_count": 15, + "large_count": 5, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.7476, + "gap_analysis_details": { + "covered_samples": 1869, + "total_samples": 2500, + "coverage": 0.7476, + "gap_ratio": 0.25239999999999996 + }, + "geometric_quality": 0.6866489206269525, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6866489206269525, + "min_quality": 0.3276974658744321, + "max_quality": 0.9340640407127343 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..c81739e4acf96a1e477723046cd0823d58ad6938 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 514.30 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3364 + + Auxiliary Metrics: + • spatial_uniformity: 0.879 + • edge_utilization: 0.785 + • density_variance: 0.535 + • packing_efficiency: 0.749 + • radius_distribution: 0.885 + • gap_analysis: 0.748 + • geometric_quality: 0.687 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3364 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.879 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.749 + • Area coverage (1 - gap ratio): 0.748 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.535 + • Radius size diversity: 0.885 + • Delaunay triangulation quality: 0.687 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..9167e2d54735f81c32c6d228532a843444c59236 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.336399303162829, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0968, 0.0821)\n centers[2] = (0.2526, 0.1025)\n centers[3] = (0.3925, 0.0914)\n centers[4] = (0.7347, 0.0603)\n centers[5] = (0.9021, 0.0984)\n centers[6] = (0.0961, 0.2753)\n centers[7] = (0.2872, 0.2587)\n centers[8] = (0.5589, 0.0899)\n centers[9] = (0.9453, 0.2535)\n centers[10] = (0.0736, 0.4569)\n centers[11] = (0.2478, 0.4705)\n centers[12] = (0.7116, 0.2974)\n centers[13] = (0.9032, 0.4838)\n centers[14] = (0.0019, 0.7295)\n centers[15] = (0.1269, 0.6688)\n centers[16] = (0.3843, 0.6812)\n centers[17] = (0.6893, 0.6525)\n centers[18] = (0.9258, 0.7298)\n centers[19] = (0.0966, 0.9040)\n centers[20] = (0.2998, 0.9002)\n centers[21] = (0.5158, 0.8925)\n centers[22] = (0.7165, 0.9134)\n centers[23] = (0.9073, 0.9056)\n centers[24] = (0.4013, 0.3867)\n centers[25] = (0.4589, 0.2355)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8789395196907688, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5353249188100495, + "aux_packing_efficiency": 0.7488846482584683, + "aux_radius_distribution": 0.8854530804755598, + "aux_gap_analysis": 0.7476, + "aux_geometric_quality": 0.6866489206269525 + }, + "private": { + "reported_sum_of_radii": 2.336399303162829 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3364\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.879\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.749\n \u2022 Area coverage (1 - gap ratio): 0.748\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.535\n \u2022 Radius size diversity: 0.885\n \u2022 Delaunay triangulation quality: 0.687\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_178/results/packing_viz.png", + "execution_time_mean": 514.2950752992183, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5bb36d0c901d3f0cef86aea47d9b827af106380a Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..e8e6885d2b4b31d1298db611ae4be8878f71c856 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/edit.diff @@ -0,0 +1,446 @@ +--- a/original.py ++++ b/original.py +@@ -1,258 +1,278 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" +- + import numpy as np + import itertools ++from collections import namedtuple ++ ++# Define a data structure for a packing configuration candidate ++PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) ++ ++class PackingUtilities: ++ """ ++ Utility functions for circle packing, including radius calculation and ++ initial center generation. ++ """ ++ @staticmethod ++ def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): ++ """ ++ Compute maximum radii using an iterative relaxation approach. Includes a ++ heuristic for special circles (e.g., interstitial) and weighted scaling ++ for the central one. ++ """ ++ n = centers.shape[0] ++ radii = np.zeros(n) ++ ++ # 1. Initialize radii based on distance to square borders. ++ for i in range(n): ++ x, y = centers[i] ++ radii[i] = min(x, y, 1 - x, 1 - y) ++ ++ # Heuristic: Adaptively cap the initial radius of special circles. ++ if special_radii_indices: ++ for idx in special_radii_indices: ++ if idx < n: # Ensure index is valid ++ other_centers_mask = np.ones(n, dtype=bool) ++ other_centers_mask[idx] = False ++ other_centers = centers[other_centers_mask] ++ ++ if len(other_centers) > 0: ++ distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) ++ min_dist_to_neighbor = np.min(distances_to_others) ++ radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) ++ ++ # 2. Iteratively adjust radii to resolve overlaps until convergence. ++ for _ in range(max_iterations): ++ prev_radii = np.copy(radii) ++ for i in range(n): ++ for j in range(i + 1, n): ++ dist = np.linalg.norm(centers[i] - centers[j]) ++ if radii[i] + radii[j] > dist: ++ overlap = radii[i] + radii[j] - dist ++ w_i = w_central if i == 0 else 1.0 ++ w_j = 1.0 ++ weighted_r_i = radii[i] / w_i ++ weighted_r_j = radii[j] / w_j ++ total_weighted_radii = weighted_r_i + weighted_r_j ++ if total_weighted_radii > 1e-12: ++ radii[i] -= overlap * (weighted_r_i / total_weighted_radii) ++ radii[j] -= overlap * (weighted_r_j / total_weighted_radii) ++ else: ++ scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor ++ radii[radii < 0] = 0 ++ if np.allclose(radii, prev_radii, atol=tolerance): ++ break ++ return radii ++ ++ @staticmethod ++ def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): ++ """Generates centers for a square grid of circles with asymmetric bounds.""" ++ x_coords = np.linspace(sc_x, ec_x, grid_size) ++ y_coords = np.linspace(sc_y, ec_y, grid_size) ++ return np.array([[x, y] for y in y_coords for x in x_coords]) ++ ++ @staticmethod ++ def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): ++ """Generates potential interstitial points with variable density.""" ++ if grid_size < 2: ++ return np.array([]) ++ num_interstitial_intervals_x = (grid_size - 1) * density_factor ++ num_interstitial_intervals_y = (grid_size - 1) * density_factor ++ step_x = (ec_x - sc_x) / num_interstitial_intervals_x ++ step_y = (ec_y - sc_y) / num_interstitial_intervals_y ++ candidates = [] ++ for i in range(num_interstitial_intervals_y): ++ for j in range(num_interstitial_intervals_x): ++ interstitial_x = sc_x + j * step_x + step_x / 2 ++ interstitial_y = sc_y + i * step_y + step_y / 2 ++ candidates.append([interstitial_x, interstitial_y]) ++ return np.array(candidates) + + + class DynamicPackingOptimizer: + """ +- Optimizes circle packing using a force-directed approach. This version incorporates +- a 'jiggle' mechanism and an adaptive buffer factor from successful prior variants +- to better escape local optima. +- """ +- def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2500, initial_learning_rate=0.015): +- self.n_circles = initial_centers.shape[0] ++ Refines packing using a force-directed approach with adaptive parameters, jiggle, ++ and a hard-fixed central anchor for stability. ++ """ ++ def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): ++ self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate +- self.use_central_restoring_force = True +- ++ self.central_fixed = central_fixed + self.centers = np.copy(initial_centers) +- self.interstitial_indices = interstitial_indices ++ self.special_radii_indices = special_radii_indices + self.w_central = w_central + self.central_idx = 0 +- +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ self.radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): +- """Runs the force-directed optimization loop with jiggle and adaptive forces.""" ++ """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): +- learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) ++ progress = step / self.num_steps ++ learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + +- radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: ++ jiggle_magnitude = 0.004 * (1 - progress) ++ jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude ++ if self.central_fixed: ++ jiggle_vec[self.central_idx] = 0.0 ++ self.centers += jiggle_vec ++ ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 ++ current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: +- test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + +- # Crossover Feature: Jiggle mechanism to escape local optima +- if step > 0 and step % 150 == 0 and step < self.num_steps * 0.8: +- jiggle_magnitude = 0.004 * (1 - step / self.num_steps) +- jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude +- if self.use_central_restoring_force: +- jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the central circle +- self.centers += jiggle_vec +- + force_vectors = np.zeros_like(self.centers) +- +- # Crossover Feature: Adaptive buffer factor +- progress = step / self.num_steps +- buffer_factor = 0.1 * (1 - progress) + 0.02 * progress ++ buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + +- K_boundary = 10.0 ++ K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + +- if self.use_central_restoring_force: +- K_center = 5.0 +- center_target = np.array([0.5, 0.5]) +- displacement = center_target - self.centers[self.central_idx] +- force_vectors[self.central_idx] += K_center * displacement +- + self.centers += learning_rate * force_vectors ++ if self.central_fixed: ++ self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) +- + return self.best_centers, self.best_radii + + +-def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): +- """Generates centers for a square grid of circles with asymmetric bounds.""" +- x_coords = np.linspace(sc_x, ec_x, grid_size) +- y_coords = np.linspace(sc_y, ec_y, grid_size) +- grid_centers = [] +- for y in y_coords: +- for x in x_coords: +- grid_centers.append([x, y]) +- return np.array(grid_centers) +- +- +-def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): +- """Generates potential interstitial points within the grid.""" +- if grid_size < 2: +- return np.array([]) +- num_intervals_x = (grid_size - 1) * density_factor +- num_intervals_y = (grid_size - 1) * density_factor +- step_x = (ec_x - sc_x) / num_intervals_x +- step_y = (ec_y - sc_y) / num_intervals_y +- candidates = [] +- for i in range(num_intervals_y): +- for j in range(num_intervals_x): +- interstitial_x = sc_x + j * step_x + step_x / 2 +- interstitial_y = sc_y + i * step_y + step_y / 2 +- candidates.append([interstitial_x, interstitial_y]) +- return np.array(candidates) +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): +- """ +- Compute maximum radii using iterative relaxation, with an adaptive heuristic +- for interstitial circles and weighted scaling for the central circle. +- """ +- n = centers.shape[0] +- radii = np.zeros(n) +- +- for i in range(n): +- x, y = centers[i] +- radii[i] = min(x, y, 1 - x, 1 - y) +- +- if interstitial_indices: +- for idx in interstitial_indices: +- if idx < n: +- other_centers_mask = np.ones(n, dtype=bool) +- other_centers_mask[idx] = False +- other_centers = centers[other_centers_mask] +- if len(other_centers) > 0: +- distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) +- min_dist_to_neighbor = np.min(distances_to_others) +- radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) +- +- for _ in range(max_iterations): +- prev_radii = np.copy(radii) +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.linalg.norm(centers[i] - centers[j]) +- if radii[i] + radii[j] > dist: +- overlap = radii[i] + radii[j] - dist +- w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 +- weighted_r_i = radii[i] / w_i +- weighted_r_j = radii[j] / w_j +- total_weighted_radii = weighted_r_i + weighted_r_j +- if total_weighted_radii > 1e-12: +- radii[i] -= overlap * (weighted_r_i / total_weighted_radii) +- radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- elif (radii[i] + radii[j]) > 1e-12: +- scale_factor = dist / (radii[i] + radii[j]) +- radii[i] *= scale_factor +- radii[j] *= scale_factor +- radii[radii < 0] = 0 +- if np.allclose(radii, prev_radii, atol=tolerance): +- break +- return radii ++class InitialConfigurationGenerator: ++ """Generates initial packing configurations for the combinatorial search.""" ++ def __init__(self, n_circles, grid_size, sc_options, ec_options, central_weight_options, num_peripheral_to_select, num_interstitial_to_select, interstitial_density_factor=1): ++ self.n_circles = n_circles ++ self.grid_size = grid_size ++ self.sc_options = sc_options ++ self.ec_options = ec_options ++ self.central_weight_options = central_weight_options ++ self.num_peripheral_to_select = num_peripheral_to_select ++ self.num_interstitial_to_select = num_interstitial_to_select ++ self.interstitial_density_factor = interstitial_density_factor ++ self.central_point = np.array([0.5, 0.5]) ++ self.num_fixed_central = 1 ++ ++ def generate_candidates(self): ++ """Yields PackingCandidate objects for coarse evaluation.""" ++ for w_central in self.central_weight_options: ++ for sc_x in self.sc_options: ++ for ec_x in self.ec_options: ++ if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue ++ for sc_y in self.sc_options: ++ for ec_y in self.ec_options: ++ if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue ++ all_grid_centers = PackingUtilities.generate_grid_centers(self.grid_size, sc_x, ec_x, sc_y, ec_y) ++ all_interstitial_points = PackingUtilities.generate_interstitial_candidates(self.grid_size, sc_x, ec_x, sc_y, ec_y, self.interstitial_density_factor) ++ peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, self.central_point)]) ++ if len(peripheral_grid_points) < self.num_peripheral_to_select or len(all_interstitial_points) < self.num_interstitial_to_select: continue ++ for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.num_peripheral_to_select): ++ selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] ++ for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), self.num_interstitial_to_select): ++ selected_interstitial_points = all_interstitial_points[list(i_indices_combo)] ++ current_centers = np.vstack([self.central_point, selected_peripheral_points, selected_interstitial_points]) ++ special_radii_indices = list(range(self.num_fixed_central + self.num_peripheral_to_select, self.n_circles)) ++ coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) ++ coarse_sum_radii = np.sum(coarse_radii) ++ yield PackingCandidate(coarse_sum_radii, current_centers, w_central, special_radii_indices) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 +- sc_options = np.array([0.09, 0.1, 0.11]) +- ec_options = np.array([0.89, 0.9, 0.91]) +- central_weight_options = np.linspace(1.2, 2.2, 3) +- +- TOP_N_CANDIDATES = 20 +- top_candidates = [] +- ++ sc_options = np.array([0.08, 0.1, 0.12]) ++ ec_options = np.array([0.88, 0.9, 0.92]) ++ central_weight_options = np.linspace(1.5, 3.0, 4) + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 +- interstitial_circle_indices_to_pass = list(range(num_fixed_central + num_peripheral_to_select, n_circles)) +- +- # STAGE 1: Coarse Combinatorial Search +- for w_central in central_weight_options: +- for sc_x in sc_options: +- for ec_x in ec_options: +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue +- for sc_y in sc_options: +- for ec_y in ec_options: +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue +- +- all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) +- +- central_point = np.array([0.5, 0.5]) +- peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) +- +- for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] +- +- for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] +- current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) +- +- coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) +- coarse_sum_radii = np.sum(coarse_radii) +- +- if len(top_candidates) < TOP_N_CANDIDATES: +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) +- elif coarse_sum_radii > top_candidates[-1][0]: +- top_candidates.pop() +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) ++ TOP_N_CANDIDATES = 25 ++ top_candidates = [] ++ ++ # STAGE 1: Coarse Combinatorial Search with enhanced interstitial density ++ config_generator = InitialConfigurationGenerator( ++ n_circles=n_circles, ++ grid_size=grid_size, ++ sc_options=sc_options, ++ ec_options=ec_options, ++ central_weight_options=central_weight_options, ++ num_peripheral_to_select=num_peripheral_to_select, ++ num_interstitial_to_select=num_interstitial_to_select, ++ interstitial_density_factor=2 # KEY CHANGE: Denser search for filler circles ++ ) ++ for candidate in config_generator.generate_candidates(): ++ if len(top_candidates) < TOP_N_CANDIDATES: ++ top_candidates.append(candidate) ++ top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) ++ elif candidate.sum_radii > top_candidates[-1].sum_radii: ++ top_candidates.pop() ++ top_candidates.append(candidate) ++ top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + +- best_sum_radii = top_candidates[0][0] +- best_centers = top_candidates[0][1] +- best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) +- +- for _, initial_centers, w_central in top_candidates: ++ best_overall_candidate = top_candidates[0] ++ best_radii = PackingUtilities.compute_max_radii(best_overall_candidate.centers, max_iterations=2000, special_radii_indices=best_overall_candidate.special_radii_indices, w_central=best_overall_candidate.w_central) ++ best_sum_radii = np.sum(best_radii) ++ best_centers = best_overall_candidate.centers ++ ++ for candidate in top_candidates: + optimizer = DynamicPackingOptimizer( +- initial_centers=initial_centers, +- interstitial_indices=interstitial_circle_indices_to_pass, +- w_central=w_central, +- num_steps=2500, # Increased steps +- initial_learning_rate=0.015, ++ initial_centers=candidate.centers, ++ special_radii_indices=candidate.special_radii_indices, ++ w_central=candidate.w_central, ++ num_circles=n_circles, ++ num_steps=3000, ++ initial_learning_rate=0.02, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) +- + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii +- ++ + return best_centers, best_radii + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/main.py new file mode 100644 index 0000000000000000000000000000000000000000..542bc5f9f009da3227ee079578a34a47a125538c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/main.py @@ -0,0 +1,278 @@ +# EVOLVE-BLOCK-START +import numpy as np +import itertools +from collections import namedtuple + +# Define a data structure for a packing configuration candidate +PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) + +class PackingUtilities: + """ + Utility functions for circle packing, including radius calculation and + initial center generation. + """ + @staticmethod + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for special circles (e.g., interstitial) and weighted scaling + for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of special circles. + if special_radii_indices: + for idx in special_radii_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + @staticmethod + def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + @staticmethod + def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points with variable density.""" + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +class DynamicPackingOptimizer: + """ + Refines packing using a force-directed approach with adaptive parameters, jiggle, + and a hard-fixed central anchor for stability. + """ + def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.centers = np.copy(initial_centers) + self.special_radii_indices = special_radii_indices + self.w_central = w_central + self.central_idx = 0 + self.radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + progress = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + + if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - progress) + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 + self.centers += jiggle_vec + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + return self.best_centers, self.best_radii + + +class InitialConfigurationGenerator: + """Generates initial packing configurations for the combinatorial search.""" + def __init__(self, n_circles, grid_size, sc_options, ec_options, central_weight_options, num_peripheral_to_select, num_interstitial_to_select, interstitial_density_factor=1): + self.n_circles = n_circles + self.grid_size = grid_size + self.sc_options = sc_options + self.ec_options = ec_options + self.central_weight_options = central_weight_options + self.num_peripheral_to_select = num_peripheral_to_select + self.num_interstitial_to_select = num_interstitial_to_select + self.interstitial_density_factor = interstitial_density_factor + self.central_point = np.array([0.5, 0.5]) + self.num_fixed_central = 1 + + def generate_candidates(self): + """Yields PackingCandidate objects for coarse evaluation.""" + for w_central in self.central_weight_options: + for sc_x in self.sc_options: + for ec_x in self.ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in self.sc_options: + for ec_y in self.ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + all_grid_centers = PackingUtilities.generate_grid_centers(self.grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_points = PackingUtilities.generate_interstitial_candidates(self.grid_size, sc_x, ec_x, sc_y, ec_y, self.interstitial_density_factor) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, self.central_point)]) + if len(peripheral_grid_points) < self.num_peripheral_to_select or len(all_interstitial_points) < self.num_interstitial_to_select: continue + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), self.num_interstitial_to_select): + selected_interstitial_points = all_interstitial_points[list(i_indices_combo)] + current_centers = np.vstack([self.central_point, selected_peripheral_points, selected_interstitial_points]) + special_radii_indices = list(range(self.num_fixed_central + self.num_peripheral_to_select, self.n_circles)) + coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + yield PackingCandidate(coarse_sum_radii, current_centers, w_central, special_radii_indices) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.08, 0.1, 0.12]) + ec_options = np.array([0.88, 0.9, 0.92]) + central_weight_options = np.linspace(1.5, 3.0, 4) + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + TOP_N_CANDIDATES = 25 + top_candidates = [] + + # STAGE 1: Coarse Combinatorial Search with enhanced interstitial density + config_generator = InitialConfigurationGenerator( + n_circles=n_circles, + grid_size=grid_size, + sc_options=sc_options, + ec_options=ec_options, + central_weight_options=central_weight_options, + num_peripheral_to_select=num_peripheral_to_select, + num_interstitial_to_select=num_interstitial_to_select, + interstitial_density_factor=2 # KEY CHANGE: Denser search for filler circles + ) + for candidate in config_generator.generate_candidates(): + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + elif candidate.sum_radii > top_candidates[-1].sum_radii: + top_candidates.pop() + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_overall_candidate = top_candidates[0] + best_radii = PackingUtilities.compute_max_radii(best_overall_candidate.centers, max_iterations=2000, special_radii_indices=best_overall_candidate.special_radii_indices, w_central=best_overall_candidate.w_central) + best_sum_radii = np.sum(best_radii) + best_centers = best_overall_candidate.centers + + for candidate in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=candidate.centers, + special_radii_indices=candidate.special_radii_indices, + w_central=candidate.w_central, + num_circles=n_circles, + num_steps=3000, + initial_learning_rate=0.02, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/original.py new file mode 100644 index 0000000000000000000000000000000000000000..2149e3d5a6c06b5f5537198c040dcb2b63b54a47 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/original.py @@ -0,0 +1,258 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. This version incorporates + a 'jiggle' mechanism and an adaptive buffer factor from successful prior variants + to better escape local optima. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.use_central_restoring_force = True + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 + + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop with jiggle and adaptive forces.""" + for step in range(self.num_steps): + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Crossover Feature: Jiggle mechanism to escape local optima + if step > 0 and step % 150 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - step / self.num_steps) + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.use_central_restoring_force: + jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the central circle + self.centers += jiggle_vec + + force_vectors = np.zeros_like(self.centers) + + # Crossover Feature: Adaptive buffer factor + progress = step / self.num_steps + buffer_factor = 0.1 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + if self.use_central_restoring_force: + K_center = 5.0 + center_target = np.array([0.5, 0.5]) + displacement = center_target - self.centers[self.central_idx] + force_vectors[self.central_idx] += K_center * displacement + + self.centers += learning_rate * force_vectors + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points within the grid.""" + if grid_size < 2: + return np.array([]) + num_intervals_x = (grid_size - 1) * density_factor + num_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_intervals_x + step_y = (ec_y - sc_y) / num_intervals_y + candidates = [] + for i in range(num_intervals_y): + for j in range(num_intervals_x): + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using iterative relaxation, with an adaptive heuristic + for interstitial circles and weighted scaling for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + interstitial_circle_indices_to_pass = list(range(num_fixed_central + num_peripheral_to_select, n_circles)) + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=2500, # Increased steps + initial_learning_rate=0.015, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..d78e72f503c3d23400bc775ba49edb0e50028624 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9145889029387467, + "spatial_uniformity_details": { + "cell_size_mean": 0.20319764158524956, + "cell_size_std": 0.018976103381202914, + "coefficient_of_variation": 0.09338741896693845 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.557462912773997, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0004678032693621249, + "mean_density": 0.02724569665809555, + "cv": 0.7938413069021751 + }, + "packing_efficiency": 0.7112542432445386, + "packing_efficiency_details": { + "total_area": 0.7112542432445386, + "square_area": 1.0, + "efficiency": 0.7112542432445386, + "relative_to_estimated_best": 0.846731241957784 + }, + "radius_distribution": 0.9194324210397706, + "radius_distribution_details": { + "mean": 0.08830440791042518, + "std": 0.03016612806815167, + "min": 0.005186733868043975, + "max": 0.1567897858790526, + "range": 0.15160305201100863, + "small_count": 6, + "medium_count": 14, + "large_count": 6, + "diversity_score": 0.9194324210397706 + }, + "gap_analysis": 0.7136, + "gap_analysis_details": { + "covered_samples": 1784, + "total_samples": 2500, + "coverage": 0.7136, + "gap_ratio": 0.2864 + }, + "geometric_quality": 0.6771334414145622, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6771334414145622, + "min_quality": 0.29728297564610423, + "max_quality": 0.9496519520503537 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..daa207b88858eb1e6312cf408e056d7b8c7723e6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 4305.92 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2959 + + Auxiliary Metrics: + • spatial_uniformity: 0.915 + • edge_utilization: 0.785 + • density_variance: 0.557 + • packing_efficiency: 0.711 + • radius_distribution: 0.919 + • gap_analysis: 0.714 + • geometric_quality: 0.677 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2959 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.915 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.711 + • Area coverage (1 - gap ratio): 0.714 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.557 + • Radius size diversity: 0.919 + • Delaunay triangulation quality: 0.677 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..e8a8cd9feaa955a5b3a9411333ea40fa499a99fd --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.295914605671055, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0986, 0.0929)\n centers[2] = (0.3004, 0.0898)\n centers[3] = (0.4710, 0.0841)\n centers[4] = (0.6295, 0.0838)\n centers[5] = (0.9026, 0.0974)\n centers[6] = (0.0883, 0.2791)\n centers[7] = (0.2793, 0.2485)\n centers[8] = (0.4704, 0.2550)\n centers[9] = (0.9535, 0.2877)\n centers[10] = (0.0778, 0.4525)\n centers[11] = (0.2854, 0.4589)\n centers[12] = (0.8478, 0.4218)\n centers[13] = (0.9505, 0.5700)\n centers[14] = (0.0052, 0.7132)\n centers[15] = (0.1327, 0.6589)\n centers[16] = (0.3916, 0.6817)\n centers[17] = (0.6740, 0.6464)\n centers[18] = (0.9140, 0.7129)\n centers[19] = (0.1027, 0.8973)\n centers[20] = (0.3050, 0.9029)\n centers[21] = (0.5114, 0.8944)\n centers[22] = (0.7138, 0.9041)\n centers[23] = (0.9049, 0.9049)\n centers[24] = (0.7466, 0.2248)\n centers[25] = (0.6160, 0.3728)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9145889029387467, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.557462912773997, + "aux_packing_efficiency": 0.7112542432445386, + "aux_radius_distribution": 0.9194324210397706, + "aux_gap_analysis": 0.7136, + "aux_geometric_quality": 0.6771334414145622 + }, + "private": { + "reported_sum_of_radii": 2.295914605671055 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2959\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.915\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.711\n \u2022 Area coverage (1 - gap ratio): 0.714\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.557\n \u2022 Radius size diversity: 0.919\n \u2022 Delaunay triangulation quality: 0.677\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/results/packing_viz.png", + "execution_time_mean": 4305.921257778071, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..2922ae7e07f495e711b5a6392d20a9b7162cef53 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_179/rewrite.txt @@ -0,0 +1,269 @@ +# EVOLVE-BLOCK-START +import numpy as np +import itertools +from collections import namedtuple + +# Define a data structure for a packing configuration candidate +PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) + +class PackingUtilities: + """ + Utility functions for circle packing, including radius calculation and + initial center generation. + """ + @staticmethod + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for special circles (e.g., interstitial) and weighted scaling + for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of special circles. + if special_radii_indices: + for idx in special_radii_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + @staticmethod + def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + @staticmethod + def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points with variable density.""" + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +class DynamicPackingOptimizer: + """ + Refines packing using a force-directed approach with adaptive parameters, jiggle, + and a hard-fixed central anchor for stability. + """ + def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.centers = np.copy(initial_centers) + self.special_radii_indices = special_radii_indices + self.w_central = w_central + self.central_idx = 0 + self.radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + progress = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + + if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - progress) + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 + self.centers += jiggle_vec + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + return self.best_centers, self.best_radii + + +class InitialConfigurationGenerator: + """Generates initial packing configurations for the combinatorial search.""" + def __init__(self, n_circles, grid_size, sc_options, ec_options, central_weight_options, num_peripheral_to_select, num_interstitial_to_select, interstitial_density_factor=1): + self.n_circles = n_circles + self.grid_size = grid_size + self.sc_options = sc_options + self.ec_options = ec_options + self.central_weight_options = central_weight_options + self.num_peripheral_to_select = num_peripheral_to_select + self.num_interstitial_to_select = num_interstitial_to_select + self.interstitial_density_factor = interstitial_density_factor + self.central_point = np.array([0.5, 0.5]) + self.num_fixed_central = 1 + + def generate_candidates(self): + """Yields PackingCandidate objects for coarse evaluation.""" + for w_central in self.central_weight_options: + for sc_x in self.sc_options: + for ec_x in self.ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in self.sc_options: + for ec_y in self.ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + all_grid_centers = PackingUtilities.generate_grid_centers(self.grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_points = PackingUtilities.generate_interstitial_candidates(self.grid_size, sc_x, ec_x, sc_y, ec_y, self.interstitial_density_factor) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, self.central_point)]) + if len(peripheral_grid_points) < self.num_peripheral_to_select or len(all_interstitial_points) < self.num_interstitial_to_select: continue + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), self.num_interstitial_to_select): + selected_interstitial_points = all_interstitial_points[list(i_indices_combo)] + current_centers = np.vstack([self.central_point, selected_peripheral_points, selected_interstitial_points]) + special_radii_indices = list(range(self.num_fixed_central + self.num_peripheral_to_select, self.n_circles)) + coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + yield PackingCandidate(coarse_sum_radii, current_centers, w_central, special_radii_indices) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.08, 0.1, 0.12]) + ec_options = np.array([0.88, 0.9, 0.92]) + central_weight_options = np.linspace(1.5, 3.0, 4) + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + TOP_N_CANDIDATES = 25 + top_candidates = [] + + # STAGE 1: Coarse Combinatorial Search with enhanced interstitial density + config_generator = InitialConfigurationGenerator( + n_circles=n_circles, + grid_size=grid_size, + sc_options=sc_options, + ec_options=ec_options, + central_weight_options=central_weight_options, + num_peripheral_to_select=num_peripheral_to_select, + num_interstitial_to_select=num_interstitial_to_select, + interstitial_density_factor=2 # KEY CHANGE: Denser search for filler circles + ) + for candidate in config_generator.generate_candidates(): + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + elif candidate.sum_radii > top_candidates[-1].sum_radii: + top_candidates.pop() + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_overall_candidate = top_candidates[0] + best_radii = PackingUtilities.compute_max_radii(best_overall_candidate.centers, max_iterations=2000, special_radii_indices=best_overall_candidate.special_radii_indices, w_central=best_overall_candidate.w_central) + best_sum_radii = np.sum(best_radii) + best_centers = best_overall_candidate.centers + + for candidate in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=candidate.centers, + special_radii_indices=candidate.special_radii_indices, + w_central=candidate.w_central, + num_circles=n_circles, + num_steps=3000, + initial_learning_rate=0.02, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6e84442a3f2cece0f3161579a2e17507d59bc9d7 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5b65f14d627aabc37b9169aadfed13b7e128c382 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9088218504930425, + "spatial_uniformity_details": { + "cell_size_mean": 0.19161005656758423, + "cell_size_std": 0.019223404968152943, + "coefficient_of_variation": 0.10032565728640058 + }, + "edge_utilization": 0.5423076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 6, + "corner_score": 0.75, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.49987209333985694, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00017192201396102775, + "mean_density": 0.013105195838157543, + "cv": 1.0005117575549716 + }, + "packing_efficiency": 0.4464314285996091, + "packing_efficiency_details": { + "total_area": 0.4464314285996091, + "square_area": 1.0, + "efficiency": 0.4464314285996091, + "relative_to_estimated_best": 0.531465986428106 + }, + "radius_distribution": 0.9246502903618902, + "radius_distribution_details": { + "mean": 0.07122556703517727, + "std": 0.019810079835065043, + "min": 0.03693980625181294, + "max": 0.09999999999999998, + "range": 0.06306019374818704, + "small_count": 11, + "medium_count": 4, + "large_count": 11, + "diversity_score": 0.9246502903618902 + }, + "gap_analysis": 0.4448, + "gap_analysis_details": { + "covered_samples": 1112, + "total_samples": 2500, + "coverage": 0.4448, + "gap_ratio": 0.5552 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..7196c6c509966546a9c302872f2190ec5e875073 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8519 + + Auxiliary Metrics: + • spatial_uniformity: 0.909 + • edge_utilization: 0.542 + • density_variance: 0.500 + • packing_efficiency: 0.446 + • radius_distribution: 0.925 + • gap_analysis: 0.445 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8519 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.909 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.500 + → Balance circle density across different regions + • Area utilization efficiency: 0.446 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.445 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.542 + • Radius size diversity: 0.925 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 55.5% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..3b2cab958439cdfb3cd3aea3311c92a1169004d6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.851864742914609, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.2000, 0.2000)\n centers[25] = (0.8000, 0.8000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9088218504930425, + "aux_edge_utilization": 0.5423076923076923, + "aux_density_variance": 0.49987209333985694, + "aux_packing_efficiency": 0.4464314285996091, + "aux_radius_distribution": 0.9246502903618902, + "aux_gap_analysis": 0.4448, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.851864742914609 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8519\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.909\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.500\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.446\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.445\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.542\n \u2022 Radius size diversity: 0.925\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 55.5% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_18/results/packing_viz.png", + "execution_time_mean": 0.0065704272128641605, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b546d5541dcec149f24e28d97b8b1121839f6dc6 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..1c0a1be407e8342a164561856271aea4c546d84a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/edit.diff @@ -0,0 +1,375 @@ +--- a/original.py ++++ b/original.py +@@ -1,281 +1,277 @@ + # EVOLVE-BLOCK-START + """ +-Hybrid circle packing for n=26 circles, combining a systematic search for +-initial configurations with a force-directed dynamic optimizer for refinement. ++Hybrid circle packing for n=26 circles, featuring a symmetry-guided search ++and an aggressive adaptive optimizer. + """ + + import numpy as np + import itertools + + + class DynamicPackingOptimizer: + """ +- Optimizes circle packing using a force-directed approach. +- """ +- def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2500, initial_learning_rate=0.015): ++ Optimizes circle packing using a force-directed approach with adaptive parameters. ++ """ ++ def __init__(self, initial_centers, interstitial_indices, w_central, w_interstitial, num_steps=3000, initial_learning_rate=0.02): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = True + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central ++ self.w_interstitial = w_interstitial + self.central_idx = 0 + +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): +- learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) ++ progress = step / self.num_steps ++ learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + +- radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + + if step % 50 == 0 or step == self.num_steps - 1: +- test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Jiggle mechanism to escape local optima, applied periodically. +- if step > 0 and step % 200 == 0 and step < self.num_steps * 0.8: +- jiggle_magnitude = 0.005 * (1 - step / self.num_steps) # Decaying magnitude ++ if step > 0 and step % 150 == 0 and step < self.num_steps * 0.9: ++ jiggle_magnitude = 0.007 * (1 - progress)**2 # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle + self.centers += jiggle_vec + + force_vectors = np.zeros_like(self.centers) + +- # Adaptive buffer factor: starts larger to separate circles, then shrinks for tight packing. +- progress = step / self.num_steps +- buffer_factor = 0.1 * (1 - progress) + 0.02 * progress ++ # Adaptive buffer factor: quadratic decay to spend more time in the tight-packing regime. ++ buffer_factor = 0.08 * (1 - progress)**2 + 0.01 + + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor +- +- K_boundary = 10.0 ++ ++ # Adaptive boundary force: increases over time for better edge utilization. ++ K_boundary = 8.0 + 12.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates centers for a square grid of circles with asymmetric bounds. +- """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): +- """ +- Generates potential interstitial points with asymmetric bounds and variable density. +- """ + if grid_size < 2: + return np.array([]) +- num_interstitial_intervals_x = int((grid_size - 1) * density_factor) +- num_interstitial_intervals_y = int((grid_size - 1) * density_factor) +- +- if num_interstitial_intervals_x == 0 or num_interstitial_intervals_y == 0: ++ num_intervals_x = int((grid_size - 1) * density_factor) ++ num_intervals_y = int((grid_size - 1) * density_factor) ++ if num_intervals_x == 0 or num_intervals_y == 0: + return np.array([]) +- +- step_x = (ec_x - sc_x) / num_interstitial_intervals_x +- step_y = (ec_y - sc_y) / num_interstitial_intervals_y ++ step_x = (ec_x - sc_x) / num_intervals_x ++ step_y = (ec_y - sc_y) / num_intervals_y + candidates = [] +- for i in range(num_interstitial_intervals_y): +- for j in range(num_interstitial_intervals_x): ++ for i in range(num_intervals_y): ++ for j in range(num_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: +- 1. A broad combinatorial search finds promising initial topologies. ++ 1. A symmetry-guided combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimizer refines the best candidates. + """ + n_circles = 26 + grid_size = 5 +- sc_options = np.array([0.09, 0.1, 0.11]) +- ec_options = np.array([0.89, 0.9, 0.91]) +- central_weight_options = np.linspace(1.2, 2.2, 3) +- +- TOP_N_CANDIDATES = 20 ++ # Tighter search space around the presumed optimal values ++ sc_options = np.array([0.095, 0.1, 0.105]) ++ ec_options = np.array([0.905, 0.9, 0.895]) ++ central_weight_options = np.linspace(1.5, 2.5, 3) ++ interstitial_weight_options = np.array([1.0, 1.3, 1.6]) ++ ++ TOP_N_CANDIDATES = 30 + top_candidates = [] +- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 +- num_interstitial_to_select = 2 +- +- interstitial_circle_indices_to_pass = [ +- num_fixed_central + num_peripheral_to_select, +- num_fixed_central + num_peripheral_to_select + 1 +- ] ++ interstitial_circle_indices = list(range(num_peripheral_to_select + num_fixed_central, n_circles)) + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: +- for sc_x in sc_options: +- for ec_x in ec_options: +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): +- continue ++ for w_interstitial in interstitial_weight_options: ++ for sc_x in sc_options: ++ ec_x = 1.0 - sc_x # Enforce symmetry + for sc_y in sc_options: +- for ec_y in ec_options: +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): +- continue +- +- all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1.5) +- +- central_point = np.array([0.5, 0.5]) +- peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) +- +- for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] +- +- for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] +- current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) +- +- coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) +- coarse_sum_radii = np.sum(coarse_radii) +- +- if len(top_candidates) < TOP_N_CANDIDATES: +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) +- elif coarse_sum_radii > top_candidates[-1][0]: +- top_candidates.pop() +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) ++ ec_y = 1.0 - sc_y # Enforce symmetry ++ ++ all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) ++ ++ central_point = np.array([0.5, 0.5]) ++ peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) ++ ++ # Heuristic: Select pairs of interstitial points that are approx. symmetric ++ symmetric_interstitial_combos = [] ++ processed_indices = set() ++ for i, p1 in enumerate(all_interstitial_candidates): ++ if i in processed_indices: continue ++ p_sym = 1.0 - p1 ++ distances = np.linalg.norm(all_interstitial_candidates - p_sym, axis=1) ++ j = np.argmin(distances) ++ if i != j and j not in processed_indices: ++ symmetric_interstitial_combos.append((i, j)) ++ processed_indices.add(i); processed_indices.add(j) ++ ++ # Iterate through excluding each peripheral point (24 options) ++ for i_to_exclude in range(len(peripheral_grid_points)): ++ selected_peripheral_points = np.delete(peripheral_grid_points, i_to_exclude, axis=0) ++ ++ for i_idx, j_idx in symmetric_interstitial_combos: ++ selected_interstitial_points = all_interstitial_candidates[[i_idx, j_idx]] ++ current_centers = np.vstack([central_point, selected_peripheral_points, selected_interstitial_points]) ++ ++ coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices, w_central=w_central, w_interstitial=w_interstitial) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ if len(top_candidates) < TOP_N_CANDIDATES: ++ top_candidates.append((coarse_sum_radii, current_centers, w_central, w_interstitial)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) ++ elif coarse_sum_radii > top_candidates[-1][0]: ++ top_candidates.pop() ++ top_candidates.append((coarse_sum_radii, current_centers, w_central, w_interstitial)) ++ top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: +- # Fallback if no valid configurations were found + return np.random.rand(n_circles, 2), np.zeros(n_circles) + +- # Initialize with the best result from the coarse search + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] +- best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) +- +- for _, initial_centers, w_central in top_candidates: ++ best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2], w_interstitial=top_candidates[0][3]) ++ ++ for _, initial_centers, w_central, w_interstitial in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, +- interstitial_indices=interstitial_circle_indices_to_pass, ++ interstitial_indices=interstitial_circle_indices, + w_central=w_central, +- num_steps=2500, +- initial_learning_rate=0.015, ++ w_interstitial=w_interstitial, ++ num_steps=3000, ++ initial_learning_rate=0.02, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.5): ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.5, w_interstitial=1.0): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: +- other_centers_mask = np.ones(n, dtype=bool) +- other_centers_mask[idx] = False ++ other_centers_mask = np.ones(n, dtype=bool); other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if other_centers.shape[0] > 0: +- distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) +- min_dist_to_neighbor = np.min(distances_to_others) ++ min_dist_to_neighbor = np.min(np.linalg.norm(centers[idx] - other_centers, axis=1)) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + +- # Weighted scaling: Central circle (index 0) shrinks less +- w_i = w_central if i == 0 else 1.0 ++ w_i = 1.0 ++ if i == 0: w_i = w_central ++ elif interstitial_indices and i in interstitial_indices: w_i = w_interstitial ++ + w_j = 1.0 ++ if interstitial_indices and j in interstitial_indices: w_j = w_interstitial + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/main.py new file mode 100644 index 0000000000000000000000000000000000000000..5a90140d0020c0c6af200dd4a17679fcb42b7226 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/main.py @@ -0,0 +1,277 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, featuring a symmetry-guided search +and an aggressive adaptive optimizer. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with adaptive parameters. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, w_interstitial, num_steps=3000, initial_learning_rate=0.02): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = True + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.w_interstitial = w_interstitial + self.central_idx = 0 + + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + progress = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Jiggle mechanism to escape local optima, applied periodically. + if step > 0 and step % 150 == 0 and step < self.num_steps * 0.9: + jiggle_magnitude = 0.007 * (1 - progress)**2 # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle + self.centers += jiggle_vec + + force_vectors = np.zeros_like(self.centers) + + # Adaptive buffer factor: quadratic decay to spend more time in the tight-packing regime. + buffer_factor = 0.08 * (1 - progress)**2 + 0.01 + + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Adaptive boundary force: increases over time for better edge utilization. + K_boundary = 8.0 + 12.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + if grid_size < 2: + return np.array([]) + num_intervals_x = int((grid_size - 1) * density_factor) + num_intervals_y = int((grid_size - 1) * density_factor) + if num_intervals_x == 0 or num_intervals_y == 0: + return np.array([]) + step_x = (ec_x - sc_x) / num_intervals_x + step_y = (ec_y - sc_y) / num_intervals_y + candidates = [] + for i in range(num_intervals_y): + for j in range(num_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A symmetry-guided combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimizer refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + # Tighter search space around the presumed optimal values + sc_options = np.array([0.095, 0.1, 0.105]) + ec_options = np.array([0.905, 0.9, 0.895]) + central_weight_options = np.linspace(1.5, 2.5, 3) + interstitial_weight_options = np.array([1.0, 1.3, 1.6]) + + TOP_N_CANDIDATES = 30 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + interstitial_circle_indices = list(range(num_peripheral_to_select + num_fixed_central, n_circles)) + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for w_interstitial in interstitial_weight_options: + for sc_x in sc_options: + ec_x = 1.0 - sc_x # Enforce symmetry + for sc_y in sc_options: + ec_y = 1.0 - sc_y # Enforce symmetry + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + # Heuristic: Select pairs of interstitial points that are approx. symmetric + symmetric_interstitial_combos = [] + processed_indices = set() + for i, p1 in enumerate(all_interstitial_candidates): + if i in processed_indices: continue + p_sym = 1.0 - p1 + distances = np.linalg.norm(all_interstitial_candidates - p_sym, axis=1) + j = np.argmin(distances) + if i != j and j not in processed_indices: + symmetric_interstitial_combos.append((i, j)) + processed_indices.add(i); processed_indices.add(j) + + # Iterate through excluding each peripheral point (24 options) + for i_to_exclude in range(len(peripheral_grid_points)): + selected_peripheral_points = np.delete(peripheral_grid_points, i_to_exclude, axis=0) + + for i_idx, j_idx in symmetric_interstitial_combos: + selected_interstitial_points = all_interstitial_candidates[[i_idx, j_idx]] + current_centers = np.vstack([central_point, selected_peripheral_points, selected_interstitial_points]) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices, w_central=w_central, w_interstitial=w_interstitial) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central, w_interstitial)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central, w_interstitial)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2], w_interstitial=top_candidates[0][3]) + + for _, initial_centers, w_central, w_interstitial in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central, + w_interstitial=w_interstitial, + num_steps=3000, + initial_learning_rate=0.02, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.5, w_interstitial=1.0): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers_mask = np.ones(n, dtype=bool); other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if other_centers.shape[0] > 0: + min_dist_to_neighbor = np.min(np.linalg.norm(centers[idx] - other_centers, axis=1)) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = 1.0 + if i == 0: w_i = w_central + elif interstitial_indices and i in interstitial_indices: w_i = w_interstitial + + w_j = 1.0 + if interstitial_indices and j in interstitial_indices: w_j = w_interstitial + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/original.py new file mode 100644 index 0000000000000000000000000000000000000000..7bfcf04df8bab3cfa1d770f56c478363ce162abf --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/original.py @@ -0,0 +1,281 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_steps=2500, initial_learning_rate=0.015): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = True + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 + + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 400 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Jiggle mechanism to escape local optima, applied periodically. + if step > 0 and step % 200 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.005 * (1 - step / self.num_steps) # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle + self.centers += jiggle_vec + + force_vectors = np.zeros_like(self.centers) + + # Adaptive buffer factor: starts larger to separate circles, then shrinks for tight packing. + progress = step / self.num_steps + buffer_factor = 0.1 * (1 - progress) + 0.02 * progress + + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = int((grid_size - 1) * density_factor) + num_interstitial_intervals_y = int((grid_size - 1) * density_factor) + + if num_interstitial_intervals_x == 0 or num_interstitial_intervals_y == 0: + return np.array([]) + + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimizer refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + sc_options = np.array([0.09, 0.1, 0.11]) + ec_options = np.array([0.89, 0.9, 0.91]) + central_weight_options = np.linspace(1.2, 2.2, 3) + + TOP_N_CANDIDATES = 20 + top_candidates = [] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1.5) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + # Fallback if no valid configurations were found + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + # Initialize with the best result from the coarse search + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=2500, + initial_learning_rate=0.015, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.5): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if other_centers.shape[0] > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..2f9b1ff7083b9bbf458ced3320e7cbd7bf8bc446 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.84022218501755, + "spatial_uniformity_details": { + "cell_size_mean": 0.19995348186377643, + "cell_size_std": 0.038023431373021485, + "coefficient_of_variation": 0.19016138568051824 + }, + "edge_utilization": 0.8, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 13, + "corner_score": 1.0, + "edge_score": 0.5 + }, + "density_variance": 0.5509764456758738, + "density_variance_details": { + "grid_size": 10, + "variance": 0.001190114040680941, + "mean_density": 0.0423309669504625, + "cv": 0.8149596191418245 + }, + "packing_efficiency": 0.7660621073865215, + "packing_efficiency_details": { + "total_area": 0.7660621073865215, + "square_area": 1.0, + "efficiency": 0.7660621073865215, + "relative_to_estimated_best": 0.9119786992696685 + }, + "radius_distribution": 0.8956403029078803, + "radius_distribution_details": { + "mean": 0.08794058930505136, + "std": 0.040559981120845016, + "min": 0.003071415326238256, + "max": 0.18255821231545127, + "range": 0.17948679698921302, + "small_count": 8, + "medium_count": 14, + "large_count": 4, + "diversity_score": 0.8956403029078803 + }, + "gap_analysis": 0.7708, + "gap_analysis_details": { + "covered_samples": 1927, + "total_samples": 2500, + "coverage": 0.7708, + "gap_ratio": 0.22919999999999996 + }, + "geometric_quality": 0.6131452871322554, + "geometric_quality_details": { + "num_triangles": 40, + "avg_triangle_quality": 0.6131452871322554, + "min_quality": 0.26971142583541774, + "max_quality": 0.9289510808596132 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..757dc141cf6232b4e5da8af91b549fa2991a9fc5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 471.36 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2865 + + Auxiliary Metrics: + • spatial_uniformity: 0.840 + • edge_utilization: 0.800 + • density_variance: 0.551 + • packing_efficiency: 0.766 + • radius_distribution: 0.896 + • gap_analysis: 0.771 + • geometric_quality: 0.613 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2865 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.840 + • Boundary and corner utilization: 0.800 + • Area utilization efficiency: 0.766 + • Area coverage (1 - gap ratio): 0.771 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.551 + • Radius size diversity: 0.896 + • Delaunay triangulation quality: 0.613 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..b288fb5e2e61a416be9c9f5207186bacc55b547e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2864553219313355, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0787, 0.0788)\n centers[2] = (0.2774, 0.0514)\n centers[3] = (0.5560, 0.0932)\n centers[4] = (0.6787, 0.0031)\n centers[5] = (0.9041, 0.0958)\n centers[6] = (0.0356, 0.1872)\n centers[7] = (0.4089, 0.0772)\n centers[8] = (0.4868, 0.2198)\n centers[9] = (0.7153, 0.0793)\n centers[10] = (0.9359, 0.2573)\n centers[11] = (0.0917, 0.5217)\n centers[12] = (0.2314, 0.2884)\n centers[13] = (0.7106, 0.3211)\n centers[14] = (0.9006, 0.5018)\n centers[15] = (0.0912, 0.7086)\n centers[16] = (0.3254, 0.6363)\n centers[17] = (0.6660, 0.6657)\n centers[18] = (0.9216, 0.7223)\n centers[19] = (0.0980, 0.9020)\n centers[20] = (0.3047, 0.8933)\n centers[21] = (0.5110, 0.9023)\n centers[22] = (0.7225, 0.9218)\n centers[23] = (0.9006, 0.9006)\n centers[24] = (0.4898, 0.3645)\n centers[25] = (0.4062, 0.4458)", + "num_circles": 26, + "aux_spatial_uniformity": 0.84022218501755, + "aux_edge_utilization": 0.8, + "aux_density_variance": 0.5509764456758738, + "aux_packing_efficiency": 0.7660621073865215, + "aux_radius_distribution": 0.8956403029078803, + "aux_gap_analysis": 0.7708, + "aux_geometric_quality": 0.6131452871322554 + }, + "private": { + "reported_sum_of_radii": 2.2864553219313355 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2865\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.840\n \u2022 Boundary and corner utilization: 0.800\n \u2022 Area utilization efficiency: 0.766\n \u2022 Area coverage (1 - gap ratio): 0.771\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.551\n \u2022 Radius size diversity: 0.896\n \u2022 Delaunay triangulation quality: 0.613\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/results/packing_viz.png", + "execution_time_mean": 471.361627351027, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..85cc7d70d55e58b8d7df0c19a95ed27a46998899 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_180/rewrite.txt @@ -0,0 +1,268 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, featuring a symmetry-guided search +and an aggressive adaptive optimizer. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with adaptive parameters. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, w_interstitial, num_steps=3000, initial_learning_rate=0.02): + self.n_circles = initial_centers.shape[0] + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = True + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.w_interstitial = w_interstitial + self.central_idx = 0 + + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + progress = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, w_interstitial=self.w_interstitial) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # Jiggle mechanism to escape local optima, applied periodically. + if step > 0 and step % 150 == 0 and step < self.num_steps * 0.9: + jiggle_magnitude = 0.007 * (1 - progress)**2 # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle + self.centers += jiggle_vec + + force_vectors = np.zeros_like(self.centers) + + # Adaptive buffer factor: quadratic decay to spend more time in the tight-packing regime. + buffer_factor = 0.08 * (1 - progress)**2 + 0.01 + + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Adaptive boundary force: increases over time for better edge utilization. + K_boundary = 8.0 + 12.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + if grid_size < 2: + return np.array([]) + num_intervals_x = int((grid_size - 1) * density_factor) + num_intervals_y = int((grid_size - 1) * density_factor) + if num_intervals_x == 0 or num_intervals_y == 0: + return np.array([]) + step_x = (ec_x - sc_x) / num_intervals_x + step_y = (ec_y - sc_y) / num_intervals_y + candidates = [] + for i in range(num_intervals_y): + for j in range(num_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A symmetry-guided combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimizer refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + # Tighter search space around the presumed optimal values + sc_options = np.array([0.095, 0.1, 0.105]) + ec_options = np.array([0.905, 0.9, 0.895]) + central_weight_options = np.linspace(1.5, 2.5, 3) + interstitial_weight_options = np.array([1.0, 1.3, 1.6]) + + TOP_N_CANDIDATES = 30 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + interstitial_circle_indices = list(range(num_peripheral_to_select + num_fixed_central, n_circles)) + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for w_interstitial in interstitial_weight_options: + for sc_x in sc_options: + ec_x = 1.0 - sc_x # Enforce symmetry + for sc_y in sc_options: + ec_y = 1.0 - sc_y # Enforce symmetry + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + # Heuristic: Select pairs of interstitial points that are approx. symmetric + symmetric_interstitial_combos = [] + processed_indices = set() + for i, p1 in enumerate(all_interstitial_candidates): + if i in processed_indices: continue + p_sym = 1.0 - p1 + distances = np.linalg.norm(all_interstitial_candidates - p_sym, axis=1) + j = np.argmin(distances) + if i != j and j not in processed_indices: + symmetric_interstitial_combos.append((i, j)) + processed_indices.add(i); processed_indices.add(j) + + # Iterate through excluding each peripheral point (24 options) + for i_to_exclude in range(len(peripheral_grid_points)): + selected_peripheral_points = np.delete(peripheral_grid_points, i_to_exclude, axis=0) + + for i_idx, j_idx in symmetric_interstitial_combos: + selected_interstitial_points = all_interstitial_candidates[[i_idx, j_idx]] + current_centers = np.vstack([central_point, selected_peripheral_points, selected_interstitial_points]) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices, w_central=w_central, w_interstitial=w_interstitial) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central, w_interstitial)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central, w_interstitial)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, interstitial_indices=interstitial_circle_indices, w_central=top_candidates[0][2], w_interstitial=top_candidates[0][3]) + + for _, initial_centers, w_central, w_interstitial in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices, + w_central=w_central, + w_interstitial=w_interstitial, + num_steps=3000, + initial_learning_rate=0.02, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_indices=None, w_central=1.5, w_interstitial=1.0): + """ + Computes maximum radii for a fixed set of centers using iterative relaxation. + Includes heuristics for central and interstitial circles. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers_mask = np.ones(n, dtype=bool); other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + if other_centers.shape[0] > 0: + min_dist_to_neighbor = np.min(np.linalg.norm(centers[idx] - other_centers, axis=1)) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + w_i = 1.0 + if i == 0: w_i = w_central + elif interstitial_indices and i in interstitial_indices: w_i = w_interstitial + + w_j = 1.0 + if interstitial_indices and j in interstitial_indices: w_j = w_interstitial + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..521c65ddeda1a45fcef311da6daff49fe81b0f0a Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..0d44a7caa94fd352712559826feae6484bda7515 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8765932322035792, + "spatial_uniformity_details": { + "cell_size_mean": 0.20531334525275463, + "cell_size_std": 0.02890400646013153, + "coefficient_of_variation": 0.140779968704756 + }, + "edge_utilization": 0.6653846153846154, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 14, + "corner_score": 0.75, + "edge_score": 0.5384615384615384 + }, + "density_variance": 0.5724769914961055, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0005670884877420775, + "mean_density": 0.03188775508731871, + "cv": 0.7467950936973209 + }, + "packing_efficiency": 0.7297728521427406, + "packing_efficiency_details": { + "total_area": 0.7297728521427406, + "square_area": 1.0, + "efficiency": 0.7297728521427406, + "relative_to_estimated_best": 0.8687772049318341 + }, + "radius_distribution": 0.9194324210397706, + "radius_distribution_details": { + "mean": 0.08848635782336768, + "std": 0.033234707277647844, + "min": 0.0016585519393684245, + "max": 0.16600498426668256, + "range": 0.16434643232731413, + "small_count": 6, + "medium_count": 14, + "large_count": 6, + "diversity_score": 0.9194324210397706 + }, + "gap_analysis": 0.7292, + "gap_analysis_details": { + "covered_samples": 1823, + "total_samples": 2500, + "coverage": 0.7292, + "gap_ratio": 0.27080000000000004 + }, + "geometric_quality": 0.6702662053067164, + "geometric_quality_details": { + "num_triangles": 43, + "avg_triangle_quality": 0.6702662053067164, + "min_quality": 0.23311040287437254, + "max_quality": 0.9887236216420157 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..7e4ca0033c7daf1d17e4c450906693eec28efb35 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 5169.46 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3006 + + Auxiliary Metrics: + • spatial_uniformity: 0.877 + • edge_utilization: 0.665 + • density_variance: 0.572 + • packing_efficiency: 0.730 + • radius_distribution: 0.919 + • gap_analysis: 0.729 + • geometric_quality: 0.670 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3006 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.877 + • Area utilization efficiency: 0.730 + • Area coverage (1 - gap ratio): 0.729 + +📊 Other Metrics: + • Boundary and corner utilization: 0.665 + • Spatial density uniformity across grid: 0.572 + • Radius size diversity: 0.919 + • Delaunay triangulation quality: 0.670 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..5a430aa85194e3cd8e571bb4a78fdbf2762daec3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.30064530340756, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1034, 0.0849)\n centers[2] = (0.2979, 0.1112)\n centers[3] = (0.4739, 0.0721)\n centers[4] = (0.5875, 0.0170)\n centers[5] = (0.9185, 0.0815)\n centers[6] = (0.1011, 0.2784)\n centers[7] = (0.3108, 0.2665)\n centers[8] = (0.6967, 0.1332)\n centers[9] = (0.8966, 0.2794)\n centers[10] = (0.0809, 0.4745)\n centers[11] = (0.2624, 0.4382)\n centers[12] = (0.6537, 0.3720)\n centers[13] = (0.8957, 0.4974)\n centers[14] = (0.0017, 0.6485)\n centers[15] = (0.1153, 0.6958)\n centers[16] = (0.3650, 0.6534)\n centers[17] = (0.6645, 0.6474)\n centers[18] = (0.9108, 0.7146)\n centers[19] = (0.0895, 0.9105)\n centers[20] = (0.2851, 0.8931)\n centers[21] = (0.5052, 0.8882)\n centers[22] = (0.7161, 0.9050)\n centers[23] = (0.9066, 0.9066)\n centers[24] = (0.4945, 0.2304)\n centers[25] = (0.4370, 0.3771)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8765932322035792, + "aux_edge_utilization": 0.6653846153846154, + "aux_density_variance": 0.5724769914961055, + "aux_packing_efficiency": 0.7297728521427406, + "aux_radius_distribution": 0.9194324210397706, + "aux_gap_analysis": 0.7292, + "aux_geometric_quality": 0.6702662053067164 + }, + "private": { + "reported_sum_of_radii": 2.30064530340756 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3006\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.877\n \u2022 Area utilization efficiency: 0.730\n \u2022 Area coverage (1 - gap ratio): 0.729\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.665\n \u2022 Spatial density uniformity across grid: 0.572\n \u2022 Radius size diversity: 0.919\n \u2022 Delaunay triangulation quality: 0.670\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_181/results/packing_viz.png", + "execution_time_mean": 5169.463965098374, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ebdcc14d04ae80596aa9b2ca49fffa9b0f5d786e Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..31b77c534e38daebf7eafab9d766f0c84c5edb55 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/edit.diff @@ -0,0 +1,437 @@ +--- a/original.py ++++ b/original.py +@@ -1,274 +1,358 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + import itertools + + + class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This class manages the iterative adjustments of circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + for the current center configuration. + """ +- def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): ++ def __init__(self, initial_centers, interstitial_indices, w_central, interstitial_cap_factor, num_circles=26, num_steps=2500, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.w_central = w_central ++ self.interstitial_cap_factor = interstitial_cap_factor # New parameter + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.central_idx = 0 # The central circle is always at index 0 in our setup + + # Initialize best configuration with max radii for the starting configuration +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, interstitial_cap_factor=self.interstitial_cap_factor) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + if learning_rate < 1e-7: + learning_rate = 1e-7 + +- radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) +- +- test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) +- current_sum_radii = np.sum(test_radii_for_sum) +- +- if current_sum_radii > self.best_sum_radii: +- self.best_sum_radii = current_sum_radii +- self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations ++ # Adaptive radii calculation iterations ++ radii_iter_count = 150 if step < self.num_steps * 0.9 else 500 # Increased iteration counts ++ current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central, interstitial_cap_factor=self.interstitial_cap_factor) ++ ++ # Periodically check for new best configuration with full radii calculation ++ # Changed check frequency to every 25 steps for more granular updates ++ if step % 25 == 0 or step == self.num_steps - 1: ++ test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, interstitial_cap_factor=self.interstitial_cap_factor) ++ current_sum_radii = np.sum(test_radii_for_sum) ++ ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = np.copy(self.centers) ++ self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + +- # Repulsion between circles +- buffer_factor = 0.05 ++ # Repulsion between circles with adaptive buffer factor ++ progress = step / self.num_steps ++ # Decays from 0.08 to 0.02 ++ buffer_factor = 0.08 * (1 - progress) + 0.02 * progress ++ + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + +- # Boundary repulsion forces +- K_boundary = 10.0 ++ # Boundary repulsion forces with adaptive K_boundary ++ # Increases from 8.0 to 15.0 ++ K_boundary = 8.0 * (1 - progress) + 15.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure the circles remain entirely within the unit square + for i in range(self.n_circles): + r = current_radii[i] # Use the radii from this iteration for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ +- Generates centers for a square grid of circles. ++ Generates centers for a square grid of circles. Assumes symmetric bounds. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +-def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): ++def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9, density_factor=1): + """ + Generates potential interstitial points within the grid. +- For a GxG grid, there are (G-1)x(G-1) interstitial points. ++ For a GxG grid, there are (G-1)x(G-1) interstitial points at density_factor=1. + """ + if grid_size < 2: + return np.array([]) + +- step_coord = (end_coord - start_coord) / (grid_size - 1) ++ # Adjusted to allow density_factor to affect how many interstitial points are generated ++ num_intervals = (grid_size - 1) * density_factor ++ step_coord = (end_coord - start_coord) / (grid_size - 1) # This is the step for the main grid. ++ ++ interstitial_step = step_coord / density_factor # Smaller step for interstitial candidates + + candidates = [] +- for i in range(grid_size - 1): +- for j in range(grid_size - 1): +- interstitial_x = start_coord + j * step_coord + step_coord / 2 +- interstitial_y = start_coord + i * step_coord + step_coord / 2 ++ for i in range(num_intervals): ++ for j in range(num_intervals): ++ interstitial_x = start_coord + j * interstitial_step + interstitial_step / 2 ++ interstitial_y = start_coord + i * interstitial_step + interstitial_step / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer, a proven strategy from high- + scoring previous iterations. + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + +- # Use a high-performing central weight from previous experiments. +- w_central = 2.0 +- +- # Search over grid boundary parameters. +- start_coord_search_space = np.linspace(0.08, 0.12, 5) +- +- for current_start_coord in start_coord_search_space: +- current_end_coord = 1.0 - current_start_coord +- +- # 1. Generate base centers for 25 circles (24 grid + 1 central). +- all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) +- central_point_coords = np.array([0.5, 0.5]) +- central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] +- +- # Assemble the base 25 centers (central at index 0, others follow) +- base_centers = np.zeros((n_circles - 1, 2)) +- base_centers[0] = central_point_coords +- other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- base_centers[1:] = other_grid_centers +- +- # 2. Generate interstitial candidates for the current grid. +- candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) +- +- # 3. For each candidate interstitial point, run the dynamic optimizer. +- for interstitial_point in candidate_interstitial_points: +- initial_centers = np.vstack([base_centers, interstitial_point]) +- interstitial_indices = [n_circles - 1] # The last circle added +- +- # Initialize and run the dynamic packing optimizer +- optimizer = DynamicPackingOptimizer( +- initial_centers=initial_centers, +- interstitial_indices=interstitial_indices, +- w_central=w_central, +- num_steps=2000, +- initial_learning_rate=0.015, +- central_fixed=True +- ) +- +- optimized_centers, optimized_radii = optimizer.optimize() +- current_sum_radii = np.sum(optimized_radii) +- +- # 4. Keep track of the best configuration found. +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = optimized_centers +- best_radii = optimized_radii ++ # Search parameters ++ w_central_options = np.linspace(1.8, 2.8, 4) # Finer and higher range for central weight ++ start_coord_options = np.linspace(0.085, 0.115, 4) # Finer and slightly wider range for grid bounds ++ interstitial_cap_factor_options = np.array([0.45, 0.5, 0.55]) # Tunable interstitial capping factor ++ density_factor_options = [1] # Keep density_factor=1 for coarse search to manage complexity ++ ++ TOP_N_CANDIDATES = 25 # Increased to capture more good candidates for refinement ++ ++ num_fixed_central = 1 ++ num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 peripheral circles ++ num_interstitial_to_select = 2 # 2 interstitial circles ++ interstitial_indices_to_pass = list(range(num_fixed_central + num_peripheral_to_select, n_circles)) ++ ++ top_candidates_for_refinement = [] # Stores (sum_radii, centers, w_central, interstitial_cap_factor) ++ ++ # STAGE 1: Coarse Combinatorial Search ++ for w_central in w_central_options: ++ for current_start_coord in start_coord_options: ++ current_end_coord = 1.0 - current_start_coord # Enforce symmetry ++ ++ # Generate base centers for 25 circles (24 grid + 1 central). ++ all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) ++ central_point_coords = np.array([0.5, 0.5]) ++ ++ central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0] ++ if not central_idx_in_grid_list.size: ++ continue # Should not happen for a symmetric grid with central_point_coords at 0.5,0.5 ++ ++ other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid_list[0], axis=0) # Remove central from grid ++ ++ for interstitial_cap_factor in interstitial_cap_factor_options: ++ for df in density_factor_options: # Iterate over density factors for interstitial candidates ++ candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord, density_factor=df) ++ ++ if len(other_grid_centers) < num_peripheral_to_select or \ ++ len(candidate_interstitial_points) < num_interstitial_to_select: ++ continue # Skip if not enough points to select from ++ ++ # Iterate through combinations of peripheral points ++ for p_indices_combo in itertools.combinations(range(len(other_grid_centers)), num_peripheral_to_select): ++ selected_peripheral_points = other_grid_centers[list(p_indices_combo)] ++ ++ # Iterate through combinations of interstitial points ++ for i_indices_combo in itertools.combinations(range(len(candidate_interstitial_points)), num_interstitial_to_select): ++ selected_interstitial_points = candidate_interstitial_points[list(i_indices_combo)] ++ ++ # Assemble initial centers: central, then peripheral, then interstitial ++ initial_centers = np.vstack([central_point_coords, selected_peripheral_points, selected_interstitial_points]) ++ ++ # Coarse evaluation for pruning ++ coarse_radii = compute_max_radii(initial_centers, max_iterations=50, tolerance=1e-6, interstitial_indices=interstitial_indices_to_pass, w_central=w_central, interstitial_cap_factor=interstitial_cap_factor) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ # Maintain a list of the top N candidates ++ if len(top_candidates_for_refinement) < TOP_N_CANDIDATES: ++ top_candidates_for_refinement.append((coarse_sum_radii, initial_centers, w_central, interstitial_cap_factor)) ++ top_candidates_for_refinement.sort(key=lambda x: x[0], reverse=True) ++ elif coarse_sum_radii > top_candidates_for_refinement[-1][0]: ++ top_candidates_for_refinement.pop() ++ top_candidates_for_refinement.append((coarse_sum_radii, initial_centers, w_central, interstitial_cap_factor)) ++ top_candidates_for_refinement.sort(key=lambda x: x[0], reverse=True) ++ ++ # STAGE 2: Refine Top Candidates with Dynamic Optimizer ++ if not top_candidates_for_refinement: ++ # Fallback if no valid configurations were found ++ return np.random.rand(n_circles, 2), np.zeros(n_circles) ++ ++ # Initialize with the best result from the coarse search ++ best_sum_radii = -1.0 # Reset for actual best sum ++ best_centers = None ++ best_radii = None ++ ++ for _, initial_centers, w_central, interstitial_cap_factor in top_candidates_for_refinement: ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=initial_centers, ++ interstitial_indices=interstitial_indices_to_pass, ++ w_central=w_central, ++ interstitial_cap_factor=interstitial_cap_factor, ++ num_circles=n_circles, ++ num_steps=2500, # Increased steps for better refinement ++ initial_learning_rate=0.015, ++ central_fixed=True ++ ) ++ ++ optimized_centers, optimized_radii = optimizer.optimize() ++ current_sum_radii = np.sum(optimized_radii) ++ ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = optimized_centers ++ best_radii = optimized_radii ++ ++ # STAGE 3: Final Ultra-Precision Refinement Stage ++ if best_centers is not None: ++ final_optimizer = DynamicPackingOptimizer( ++ initial_centers=best_centers, # Start from the best found so far ++ interstitial_indices=interstitial_indices_to_pass, ++ w_central=w_central_options[-1], # Use a strong central weight, e.g., the max from options ++ interstitial_cap_factor=interstitial_cap_factor_options[1], # Use 0.5 as a robust default ++ num_circles=n_circles, ++ num_steps=100, # Short, focused refinement ++ initial_learning_rate=1e-6, # Very low learning rate for precision ++ central_fixed=True ++ ) ++ # Manually set buffer and K_boundary for this ultra-precision stage ++ final_optimizer.optimize() # Run the final optimization ++ ++ # After optimization, re-calculate radii with full iterations for the absolute best sum ++ final_radii = compute_max_radii(final_optimizer.best_centers, max_iterations=2000, ++ interstitial_indices=final_optimizer.interstitial_indices, ++ w_central=final_optimizer.w_central, ++ interstitial_cap_factor=final_optimizer.interstitial_cap_factor) ++ ++ if np.sum(final_radii) > best_sum_radii: ++ best_sum_radii = np.sum(final_radii) ++ best_centers = final_optimizer.best_centers ++ best_radii = final_radii ++ + + return best_centers, best_radii + + +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5, interstitial_cap_factor=0.5): + """ + Compute maximum radii using an iterative relaxation approach. This version is + generalized to handle multiple interstitial circles and a configurable weight +- for the central circle. ++ for the central circle, and a tunable interstitial capping factor. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. + w_central: Weight factor for the central circle (index 0) during overlap resolution. ++ interstitial_cap_factor (float): Factor to cap interstitial initial radii (e.g., 0.5). + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radii of the interstitial circles. + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) +- # Cap the initial radius to half the distance to the nearest neighbor. +- radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) ++ # Cap the initial radius to a factor of the distance to the nearest neighbor. ++ radii[idx] = min(radii[idx], interstitial_cap_factor * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (index 0). + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + # The reduction for each circle is proportional to its radius/weight. + # A higher weight leads to a smaller proportional reduction. + reduction_prop_i = radii[i] / w_i + reduction_prop_j = radii[j] / w_j + total_prop = reduction_prop_i + reduction_prop_j + + if total_prop > 1e-12: + radii[i] -= overlap * (reduction_prop_i / total_prop) + radii[j] -= overlap * (reduction_prop_j / total_prop) + elif (radii[i] + radii[j]) > 1e-12: + # Fallback for tiny radii: simple proportional scaling. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii +- +- + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/main.py new file mode 100644 index 0000000000000000000000000000000000000000..7d7e70bee4488c901e37d80516d647ec73401fbe --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/main.py @@ -0,0 +1,358 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This class manages the iterative adjustments of circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + for the current center configuration. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, interstitial_cap_factor, num_circles=26, num_steps=2500, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.w_central = w_central + self.interstitial_cap_factor = interstitial_cap_factor # New parameter + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.central_idx = 0 # The central circle is always at index 0 in our setup + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, interstitial_cap_factor=self.interstitial_cap_factor) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + # Adaptive radii calculation iterations + radii_iter_count = 150 if step < self.num_steps * 0.9 else 500 # Increased iteration counts + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central, interstitial_cap_factor=self.interstitial_cap_factor) + + # Periodically check for new best configuration with full radii calculation + # Changed check frequency to every 25 steps for more granular updates + if step % 25 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central, interstitial_cap_factor=self.interstitial_cap_factor) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles with adaptive buffer factor + progress = step / self.num_steps + # Decays from 0.08 to 0.02 + buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces with adaptive K_boundary + # Increases from 8.0 to 15.0 + K_boundary = 8.0 * (1 - progress) + 15.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure the circles remain entirely within the unit square + for i in range(self.n_circles): + r = current_radii[i] # Use the radii from this iteration for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. Assumes symmetric bounds. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9, density_factor=1): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points at density_factor=1. + """ + if grid_size < 2: + return np.array([]) + + # Adjusted to allow density_factor to affect how many interstitial points are generated + num_intervals = (grid_size - 1) * density_factor + step_coord = (end_coord - start_coord) / (grid_size - 1) # This is the step for the main grid. + + interstitial_step = step_coord / density_factor # Smaller step for interstitial candidates + + candidates = [] + for i in range(num_intervals): + for j in range(num_intervals): + interstitial_x = start_coord + j * interstitial_step + interstitial_step / 2 + interstitial_y = start_coord + i * interstitial_step + interstitial_step / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer, a proven strategy from high- + scoring previous iterations. + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Search parameters + w_central_options = np.linspace(1.8, 2.8, 4) # Finer and higher range for central weight + start_coord_options = np.linspace(0.085, 0.115, 4) # Finer and slightly wider range for grid bounds + interstitial_cap_factor_options = np.array([0.45, 0.5, 0.55]) # Tunable interstitial capping factor + density_factor_options = [1] # Keep density_factor=1 for coarse search to manage complexity + + TOP_N_CANDIDATES = 25 # Increased to capture more good candidates for refinement + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 peripheral circles + num_interstitial_to_select = 2 # 2 interstitial circles + interstitial_indices_to_pass = list(range(num_fixed_central + num_peripheral_to_select, n_circles)) + + top_candidates_for_refinement = [] # Stores (sum_radii, centers, w_central, interstitial_cap_factor) + + # STAGE 1: Coarse Combinatorial Search + for w_central in w_central_options: + for current_start_coord in start_coord_options: + current_end_coord = 1.0 - current_start_coord # Enforce symmetry + + # Generate base centers for 25 circles (24 grid + 1 central). + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0] + if not central_idx_in_grid_list.size: + continue # Should not happen for a symmetric grid with central_point_coords at 0.5,0.5 + + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid_list[0], axis=0) # Remove central from grid + + for interstitial_cap_factor in interstitial_cap_factor_options: + for df in density_factor_options: # Iterate over density factors for interstitial candidates + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord, density_factor=df) + + if len(other_grid_centers) < num_peripheral_to_select or \ + len(candidate_interstitial_points) < num_interstitial_to_select: + continue # Skip if not enough points to select from + + # Iterate through combinations of peripheral points + for p_indices_combo in itertools.combinations(range(len(other_grid_centers)), num_peripheral_to_select): + selected_peripheral_points = other_grid_centers[list(p_indices_combo)] + + # Iterate through combinations of interstitial points + for i_indices_combo in itertools.combinations(range(len(candidate_interstitial_points)), num_interstitial_to_select): + selected_interstitial_points = candidate_interstitial_points[list(i_indices_combo)] + + # Assemble initial centers: central, then peripheral, then interstitial + initial_centers = np.vstack([central_point_coords, selected_peripheral_points, selected_interstitial_points]) + + # Coarse evaluation for pruning + coarse_radii = compute_max_radii(initial_centers, max_iterations=50, tolerance=1e-6, interstitial_indices=interstitial_indices_to_pass, w_central=w_central, interstitial_cap_factor=interstitial_cap_factor) + coarse_sum_radii = np.sum(coarse_radii) + + # Maintain a list of the top N candidates + if len(top_candidates_for_refinement) < TOP_N_CANDIDATES: + top_candidates_for_refinement.append((coarse_sum_radii, initial_centers, w_central, interstitial_cap_factor)) + top_candidates_for_refinement.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates_for_refinement[-1][0]: + top_candidates_for_refinement.pop() + top_candidates_for_refinement.append((coarse_sum_radii, initial_centers, w_central, interstitial_cap_factor)) + top_candidates_for_refinement.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates_for_refinement: + # Fallback if no valid configurations were found + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + # Initialize with the best result from the coarse search + best_sum_radii = -1.0 # Reset for actual best sum + best_centers = None + best_radii = None + + for _, initial_centers, w_central, interstitial_cap_factor in top_candidates_for_refinement: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_indices_to_pass, + w_central=w_central, + interstitial_cap_factor=interstitial_cap_factor, + num_circles=n_circles, + num_steps=2500, # Increased steps for better refinement + initial_learning_rate=0.015, + central_fixed=True + ) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + # STAGE 3: Final Ultra-Precision Refinement Stage + if best_centers is not None: + final_optimizer = DynamicPackingOptimizer( + initial_centers=best_centers, # Start from the best found so far + interstitial_indices=interstitial_indices_to_pass, + w_central=w_central_options[-1], # Use a strong central weight, e.g., the max from options + interstitial_cap_factor=interstitial_cap_factor_options[1], # Use 0.5 as a robust default + num_circles=n_circles, + num_steps=100, # Short, focused refinement + initial_learning_rate=1e-6, # Very low learning rate for precision + central_fixed=True + ) + # Manually set buffer and K_boundary for this ultra-precision stage + final_optimizer.optimize() # Run the final optimization + + # After optimization, re-calculate radii with full iterations for the absolute best sum + final_radii = compute_max_radii(final_optimizer.best_centers, max_iterations=2000, + interstitial_indices=final_optimizer.interstitial_indices, + w_central=final_optimizer.w_central, + interstitial_cap_factor=final_optimizer.interstitial_cap_factor) + + if np.sum(final_radii) > best_sum_radii: + best_sum_radii = np.sum(final_radii) + best_centers = final_optimizer.best_centers + best_radii = final_radii + + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5, interstitial_cap_factor=0.5): + """ + Compute maximum radii using an iterative relaxation approach. This version is + generalized to handle multiple interstitial circles and a configurable weight + for the central circle, and a tunable interstitial capping factor. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. + w_central: Weight factor for the central circle (index 0) during overlap resolution. + interstitial_cap_factor (float): Factor to cap interstitial initial radii (e.g., 0.5). + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radii of the interstitial circles. + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to a factor of the distance to the nearest neighbor. + radii[idx] = min(radii[idx], interstitial_cap_factor * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (index 0). + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + # The reduction for each circle is proportional to its radius/weight. + # A higher weight leads to a smaller proportional reduction. + reduction_prop_i = radii[i] / w_i + reduction_prop_j = radii[j] / w_j + total_prop = reduction_prop_i + reduction_prop_j + + if total_prop > 1e-12: + radii[i] -= overlap * (reduction_prop_i / total_prop) + radii[j] -= overlap * (reduction_prop_j / total_prop) + elif (radii[i] + radii[j]) > 1e-12: + # Fallback for tiny radii: simple proportional scaling. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/original.py new file mode 100644 index 0000000000000000000000000000000000000000..e27b79d58df0a274afcc94e187bdc5ab3a942969 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/original.py @@ -0,0 +1,274 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This class manages the iterative adjustments of circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + for the current center configuration. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=2000, initial_learning_rate=0.015, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.w_central = w_central + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.central_idx = 0 # The central circle is always at index 0 in our setup + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + if learning_rate < 1e-7: + learning_rate = 1e-7 + + radii_iter_count = 50 if step < self.num_steps * 0.9 else 200 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) # Store radii computed with full iterations + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + buffer_factor = 0.05 + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + K_boundary = 10.0 + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on calculated forces + self.centers += learning_rate * force_vectors + + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure the circles remain entirely within the unit square + for i in range(self.n_circles): + r = current_radii[i] # Use the radii from this iteration for clipping + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by performing a systematic search + for the optimal grid boundary parameter and the best position for an + interstitial circle. Each initial configuration is then refined using + a force-directed dynamic packing optimizer, a proven strategy from high- + scoring previous iterations. + """ + n_circles = 26 + grid_size = 5 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Use a high-performing central weight from previous experiments. + w_central = 2.0 + + # Search over grid boundary parameters. + start_coord_search_space = np.linspace(0.08, 0.12, 5) + + for current_start_coord in start_coord_search_space: + current_end_coord = 1.0 - current_start_coord + + # 1. Generate base centers for 25 circles (24 grid + 1 central). + all_grid_centers = _generate_grid_centers(grid_size, current_start_coord, current_end_coord) + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords, atol=1e-5), axis=1))[0][0] + + # Assemble the base 25 centers (central at index 0, others follow) + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the current grid. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, current_start_coord, current_end_coord) + + # 3. For each candidate interstitial point, run the dynamic optimizer. + for interstitial_point in candidate_interstitial_points: + initial_centers = np.vstack([base_centers, interstitial_point]) + interstitial_indices = [n_circles - 1] # The last circle added + + # Initialize and run the dynamic packing optimizer + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_indices, + w_central=w_central, + num_steps=2000, + initial_learning_rate=0.015, + central_fixed=True + ) + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + # 4. Keep track of the best configuration found. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. This version is + generalized to handle multiple interstitial circles and a configurable weight + for the central circle. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. + w_central: Weight factor for the central circle (index 0) during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radii of the interstitial circles. + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to half the distance to the nearest neighbor. + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (index 0). + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # j > i >= 0, so j is never the central circle. + + # The reduction for each circle is proportional to its radius/weight. + # A higher weight leads to a smaller proportional reduction. + reduction_prop_i = radii[i] / w_i + reduction_prop_j = radii[j] / w_j + total_prop = reduction_prop_i + reduction_prop_j + + if total_prop > 1e-12: + radii[i] -= overlap * (reduction_prop_i / total_prop) + radii[j] -= overlap * (reduction_prop_j / total_prop) + elif (radii[i] + radii[j]) > 1e-12: + # Fallback for tiny radii: simple proportional scaling. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..dbcafd8b7a3de7ae23eaf85d6e3abea67ea545b7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8356045369247933, + "spatial_uniformity_details": { + "cell_size_mean": 0.20020054608327856, + "cell_size_std": 0.039387126554851944, + "coefficient_of_variation": 0.19673835625667824 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5115915659690312, + "density_variance_details": { + "grid_size": 10, + "variance": 0.001091522362222415, + "mean_density": 0.03460640830309943, + "cv": 0.9546842960670194 + }, + "packing_efficiency": 0.7429571345782271, + "packing_efficiency_details": { + "total_area": 0.7429571345782271, + "square_area": 1.0, + "efficiency": 0.7429571345782271, + "relative_to_estimated_best": 0.8844727792597942 + }, + "radius_distribution": 0.8420887788299293, + "radius_distribution_details": { + "mean": 0.08946167006626914, + "std": 0.03305150424822709, + "min": 0.03442594831655563, + "max": 0.17554018818441963, + "range": 0.141114239867864, + "small_count": 6, + "medium_count": 16, + "large_count": 4, + "diversity_score": 0.8420887788299293 + }, + "gap_analysis": 0.75, + "gap_analysis_details": { + "covered_samples": 1875, + "total_samples": 2500, + "coverage": 0.75, + "gap_ratio": 0.25 + }, + "geometric_quality": 0.6378415301522463, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6378415301522463, + "min_quality": 0.2336378694805686, + "max_quality": 0.9252124941837536 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3ca1ff55b664082eb6113ce91e7bcb156a6c6974 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 554.61 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3260 + + Auxiliary Metrics: + • spatial_uniformity: 0.836 + • edge_utilization: 0.785 + • density_variance: 0.512 + • packing_efficiency: 0.743 + • radius_distribution: 0.842 + • gap_analysis: 0.750 + • geometric_quality: 0.638 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3260 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.836 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.743 + • Area coverage (1 - gap ratio): 0.750 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.512 + • Radius size diversity: 0.842 + • Delaunay triangulation quality: 0.638 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..f7aa6babea8dfbe25b3bd84cb8f6421530fb7c6a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3260034217229975, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0822, 0.0781)\n centers[2] = (0.2910, 0.0725)\n centers[3] = (0.4949, 0.0344)\n centers[4] = (0.7599, 0.0620)\n centers[5] = (0.9101, 0.0857)\n centers[6] = (0.1019, 0.2678)\n centers[7] = (0.2689, 0.2169)\n centers[8] = (0.4634, 0.1843)\n centers[9] = (0.6155, 0.0799)\n centers[10] = (0.9467, 0.2247)\n centers[11] = (0.0930, 0.4572)\n centers[12] = (0.2757, 0.4299)\n centers[13] = (0.7299, 0.3135)\n centers[14] = (0.9062, 0.5238)\n centers[15] = (0.1229, 0.6768)\n centers[16] = (0.3628, 0.6173)\n centers[17] = (0.6707, 0.6670)\n centers[18] = (0.9208, 0.7174)\n centers[19] = (0.0911, 0.9089)\n centers[20] = (0.3211, 0.8592)\n centers[21] = (0.5516, 0.9086)\n centers[22] = (0.7204, 0.9258)\n centers[23] = (0.8983, 0.8995)\n centers[24] = (0.3988, 0.0476)\n centers[25] = (0.4360, 0.3674)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8356045369247933, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5115915659690312, + "aux_packing_efficiency": 0.7429571345782271, + "aux_radius_distribution": 0.8420887788299293, + "aux_gap_analysis": 0.75, + "aux_geometric_quality": 0.6378415301522463 + }, + "private": { + "reported_sum_of_radii": 2.3260034217229975 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3260\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.836\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.743\n \u2022 Area coverage (1 - gap ratio): 0.750\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.512\n \u2022 Radius size diversity: 0.842\n \u2022 Delaunay triangulation quality: 0.638\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_182/results/packing_viz.png", + "execution_time_mean": 554.6090477798134, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ef337c25a3a0a1b5206bed2c79d601dfb3458ae7 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..aede7ce06492a7c14cff76f0f163c265d12725f5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8770397471708633, + "spatial_uniformity_details": { + "cell_size_mean": 0.19013269536519367, + "cell_size_std": 0.02665644800200266, + "coefficient_of_variation": 0.1401991793710368 + }, + "edge_utilization": 0.2153846153846154, + "edge_utilization_details": { + "corners_touched": 0, + "edges_touched": 14, + "corner_score": 0.0, + "edge_score": 0.5384615384615384 + }, + "density_variance": 0.48803557678962306, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0004823652386423434, + "mean_density": 0.020936287841876303, + "cv": 1.0490309468382648 + }, + "packing_efficiency": 0.6145838320444514, + "packing_efficiency_details": { + "total_area": 0.6145838320444514, + "square_area": 1.0, + "efficiency": 0.6145838320444514, + "relative_to_estimated_best": 0.7316474191005374 + }, + "radius_distribution": 0.9947372351472321, + "radius_distribution_details": { + "mean": 0.08020893351921242, + "std": 0.03302552113659854, + "min": 0.0064744952968822985, + "max": 0.14092460610080798, + "range": 0.1344501108039257, + "small_count": 8, + "medium_count": 10, + "large_count": 8, + "diversity_score": 0.9947372351472321 + }, + "gap_analysis": 0.6132, + "gap_analysis_details": { + "covered_samples": 1533, + "total_samples": 2500, + "coverage": 0.6132, + "gap_ratio": 0.38680000000000003 + }, + "geometric_quality": 0.6386884206498188, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6386884206498188, + "min_quality": 0.24804986046596295, + "max_quality": 0.9294786313258135 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..ef22e3b974b57f0b810002a056b8acc3444a9ffb --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 2218.99 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.0854 + + Auxiliary Metrics: + • spatial_uniformity: 0.877 + • edge_utilization: 0.215 + • density_variance: 0.488 + • packing_efficiency: 0.615 + • radius_distribution: 0.995 + • gap_analysis: 0.613 + • geometric_quality: 0.639 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.0854 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.877 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.215 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.488 + → Balance circle density across different regions + +📊 Other Metrics: + • Area utilization efficiency: 0.615 + • Radius size diversity: 0.995 + • Area coverage (1 - gap ratio): 0.613 + • Delaunay triangulation quality: 0.639 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 0/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 38.7% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..b42c5347456b5889b8a9699eef8d69c8bedb82a4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.085432271499523, + "public": { + "centers_str": " centers[0] = (0.9079, 0.6045)\n centers[1] = (0.8947, 0.9305)\n centers[2] = (0.3792, 0.3665)\n centers[3] = (0.7200, 0.0802)\n centers[4] = (0.7635, 0.4420)\n centers[5] = (0.2360, 0.7291)\n centers[6] = (0.7660, 0.9565)\n centers[7] = (0.6465, 0.8836)\n centers[8] = (0.3979, 0.0825)\n centers[9] = (0.4060, 0.8278)\n centers[10] = (0.6517, 0.6363)\n centers[11] = (0.5877, 0.2573)\n centers[12] = (0.2045, 0.2193)\n centers[13] = (0.8631, 0.2422)\n centers[14] = (0.4517, 0.4742)\n centers[15] = (0.1012, 0.8639)\n centers[16] = (0.2792, 0.4565)\n centers[17] = (0.0809, 0.1817)\n centers[18] = (0.2695, 0.9222)\n centers[19] = (0.3546, 0.6417)\n centers[20] = (0.9304, 0.4997)\n centers[21] = (0.8894, 0.0639)\n centers[22] = (0.9658, 0.1221)\n centers[23] = (0.8817, 0.7593)\n centers[24] = (0.1310, 0.6076)\n centers[25] = (0.1068, 0.3736)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8770397471708633, + "aux_edge_utilization": 0.2153846153846154, + "aux_density_variance": 0.48803557678962306, + "aux_packing_efficiency": 0.6145838320444514, + "aux_radius_distribution": 0.9947372351472321, + "aux_gap_analysis": 0.6132, + "aux_geometric_quality": 0.6386884206498188 + }, + "private": { + "reported_sum_of_radii": 2.085432271499523 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.0854\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.877\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.215\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.488\n \u2192 Balance circle density across different regions\n\n\ud83d\udcca Other Metrics:\n \u2022 Area utilization efficiency: 0.615\n \u2022 Radius size diversity: 0.995\n \u2022 Area coverage (1 - gap ratio): 0.613\n \u2022 Delaunay triangulation quality: 0.639\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 0/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 38.7% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_183/results/packing_viz.png", + "execution_time_mean": 2218.985624182038, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f5c57a65681ab4877cbae5d116a057bc17b124bf Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..1330d8f2827a4f7e70cb789477827c9548007829 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": false, + "error": "_generate_grid_centers() takes from 0 to 3 positional arguments but 5 were given" +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..e9523c4751e8c9b8fd3ccca7a2e9f844e71b0648 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/job_log.out @@ -0,0 +1,35 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results +Auxiliary Metrics: ENABLED +====================================================================== + +Evaluation error: _generate_grid_centers() takes from 0 to 3 positional arguments but 5 were given +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/metrics.json + +====================================================================== +❌ EVALUATION FAILED +Error: _generate_grid_centers() takes from 0 to 3 positional arguments but 5 were given +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 0.0000 + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..fec2021a6a036637c9d3049ae9778c77cef78421 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_186/results/metrics.json @@ -0,0 +1,9 @@ +{ + "combined_score": 0.0, + "execution_time_mean": 0.0, + "execution_time_std": 0.0, + "num_successful_runs": 0, + "num_valid_runs": 0, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..25bbea8ba683fb237954bde2705aff96c34f0b6c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5a21c069dd708e740fa6ada1ee914553d4cb1fc3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8853281289824732, + "spatial_uniformity_details": { + "cell_size_mean": 0.20281453109649042, + "cell_size_std": 0.026269493878816108, + "coefficient_of_variation": 0.12952471209665692 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.52314347598511, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0010222629086716333, + "mean_density": 0.03507634833114255, + "cv": 0.9115214963102445 + }, + "packing_efficiency": 0.7497930473399792, + "packing_efficiency_details": { + "total_area": 0.7497930473399792, + "square_area": 1.0, + "efficiency": 0.7497930473399792, + "relative_to_estimated_best": 0.8926107706428325 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.0894735133009285, + "std": 0.034263285136789966, + "min": 0.000735771951635661, + "max": 0.17754355011041256, + "range": 0.1768077781587769, + "small_count": 6, + "medium_count": 15, + "large_count": 5, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.7496, + "gap_analysis_details": { + "covered_samples": 1874, + "total_samples": 2500, + "coverage": 0.7496, + "gap_ratio": 0.25039999999999996 + }, + "geometric_quality": 0.6544173385611373, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6544173385611373, + "min_quality": 0.2670871010089212, + "max_quality": 0.9338594683417882 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..52902a23872eb7760b9c69947f819a11609ee109 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 534.23 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3263 + + Auxiliary Metrics: + • spatial_uniformity: 0.885 + • edge_utilization: 0.785 + • density_variance: 0.523 + • packing_efficiency: 0.750 + • radius_distribution: 0.885 + • gap_analysis: 0.750 + • geometric_quality: 0.654 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3263 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.885 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.750 + • Area coverage (1 - gap ratio): 0.750 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.523 + • Radius size diversity: 0.885 + • Delaunay triangulation quality: 0.654 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..5a7a1de8bfbd33e4edd630218c819bcc16d80f97 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.326311345824141, + "public": { + "centers_str": " centers[0] = (0.4950, 0.4954)\n centers[1] = (0.0985, 0.0855)\n centers[2] = (0.3034, 0.0874)\n centers[3] = (0.4343, 0.1062)\n centers[4] = (0.7519, 0.0650)\n centers[5] = (0.9128, 0.0872)\n centers[6] = (0.0952, 0.2755)\n centers[7] = (0.2939, 0.2457)\n centers[8] = (0.5934, 0.0825)\n centers[9] = (0.9545, 0.2207)\n centers[10] = (0.0774, 0.4582)\n centers[11] = (0.2485, 0.4891)\n centers[12] = (0.7427, 0.3120)\n centers[13] = (0.9074, 0.5364)\n centers[14] = (0.0007, 0.7166)\n centers[15] = (0.1252, 0.6766)\n centers[16] = (0.3781, 0.6777)\n centers[17] = (0.6721, 0.6556)\n centers[18] = (0.9160, 0.7242)\n centers[19] = (0.0949, 0.9051)\n centers[20] = (0.2943, 0.9003)\n centers[21] = (0.5103, 0.8896)\n centers[22] = (0.7193, 0.9109)\n centers[23] = (0.9080, 0.9080)\n centers[24] = (0.3870, 0.3959)\n centers[25] = (0.4822, 0.2738)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8853281289824732, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.52314347598511, + "aux_packing_efficiency": 0.7497930473399792, + "aux_radius_distribution": 0.8854530804755598, + "aux_gap_analysis": 0.7496, + "aux_geometric_quality": 0.6544173385611373 + }, + "private": { + "reported_sum_of_radii": 2.326311345824141 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3263\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.885\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.750\n \u2022 Area coverage (1 - gap ratio): 0.750\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.523\n \u2022 Radius size diversity: 0.885\n \u2022 Delaunay triangulation quality: 0.654\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_188/results/packing_viz.png", + "execution_time_mean": 534.2300817701034, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e364910bb6a024dbbd2ded398c1c3c54517af2fb Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f6fc381abd432c9db24e45252b7e619fb61603cc --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576736 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5261424497752974, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00020708924409982752, + "mean_density": 0.01597843653375721, + "cv": 0.9006259624690526 + }, + "packing_efficiency": 0.49240606516668184, + "packing_efficiency_details": { + "total_area": 0.49240606516668184, + "square_area": 1.0, + "efficiency": 0.49240606516668184, + "relative_to_estimated_best": 0.5861976966270022 + }, + "radius_distribution": 0.7543533534342522, + "radius_distribution_details": { + "mean": 0.07372908132592121, + "std": 0.024339193856461577, + "min": 0.03669894819221307, + "max": 0.10261558125579377, + "range": 0.0659166330635807, + "small_count": 12, + "medium_count": 1, + "large_count": 13, + "diversity_score": 0.7543533534342522 + }, + "gap_analysis": 0.496, + "gap_analysis_details": { + "covered_samples": 1240, + "total_samples": 2500, + "coverage": 0.496, + "gap_ratio": 0.504 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..268c2d8fe5c40a9f08fa421739c2902db53a14fa --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9170 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.526 + • packing_efficiency: 0.492 + • radius_distribution: 0.754 + • gap_analysis: 0.496 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9170 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.492 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.496 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.526 + • Radius size diversity: 0.754 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 50.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..0475757f478d212db09c72eb85d991544d1fdd47 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9169561144739513, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.5000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5261424497752974, + "aux_packing_efficiency": 0.49240606516668184, + "aux_radius_distribution": 0.7543533534342522, + "aux_gap_analysis": 0.496, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9169561144739513 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9170\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.492\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.496\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.526\n \u2022 Radius size diversity: 0.754\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 50.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_19/results/packing_viz.png", + "execution_time_mean": 0.006362331099808216, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4621670eacf698bd4ccc4812b0b357beac3e9fff Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..327fb6e52eb55d804870d9c26e99cf73a671c5f0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8804681751563488, + "spatial_uniformity_details": { + "cell_size_mean": 0.20270657167019365, + "cell_size_std": 0.02751932122335693, + "coefficient_of_variation": 0.13575939280533955 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.5577976708150423, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0007617865475655272, + "mean_density": 0.03481547363688676, + "cv": 0.792764746648764 + }, + "packing_efficiency": 0.75611967936404, + "packing_efficiency_details": { + "total_area": 0.75611967936404, + "square_area": 1.0, + "efficiency": 0.75611967936404, + "relative_to_estimated_best": 0.900142475433381 + }, + "radius_distribution": 0.9341661379115739, + "radius_distribution_details": { + "mean": 0.09054996655537094, + "std": 0.03252139033185766, + "min": 0.0021668311906022242, + "max": 0.16726074564317145, + "range": 0.1650939144525692, + "small_count": 8, + "medium_count": 13, + "large_count": 5, + "diversity_score": 0.9341661379115739 + }, + "gap_analysis": 0.7568, + "gap_analysis_details": { + "covered_samples": 1892, + "total_samples": 2500, + "coverage": 0.7568, + "gap_ratio": 0.24319999999999997 + }, + "geometric_quality": 0.666371996286751, + "geometric_quality_details": { + "num_triangles": 43, + "avg_triangle_quality": 0.666371996286751, + "min_quality": 0.2357507016856368, + "max_quality": 0.9287603573964867 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..9701798c59ba850a11833a1cc077bca8deb971d5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 924.30 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3543 + + Auxiliary Metrics: + • spatial_uniformity: 0.880 + • edge_utilization: 0.785 + • density_variance: 0.558 + • packing_efficiency: 0.756 + • radius_distribution: 0.934 + • gap_analysis: 0.757 + • geometric_quality: 0.666 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3543 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.880 + • Boundary and corner utilization: 0.785 + • Area utilization efficiency: 0.756 + • Area coverage (1 - gap ratio): 0.757 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.558 + • Radius size diversity: 0.934 + • Delaunay triangulation quality: 0.666 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..000b9c12e86b7c4c28a90e2cf6fcd041031410b3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3542991304396446, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0958, 0.0853)\n centers[2] = (0.2670, 0.1025)\n centers[3] = (0.4063, 0.0980)\n centers[4] = (0.7392, 0.0607)\n centers[5] = (0.9017, 0.0988)\n centers[6] = (0.1048, 0.2847)\n centers[7] = (0.3015, 0.2698)\n centers[8] = (0.5758, 0.0900)\n centers[9] = (0.9454, 0.2552)\n centers[10] = (0.0706, 0.4681)\n centers[11] = (0.2484, 0.4723)\n centers[12] = (0.7204, 0.3095)\n centers[13] = (0.9005, 0.5184)\n centers[14] = (0.0022, 0.7226)\n centers[15] = (0.1260, 0.6721)\n centers[16] = (0.3782, 0.6738)\n centers[17] = (0.6680, 0.6521)\n centers[18] = (0.9110, 0.7151)\n centers[19] = (0.0967, 0.9037)\n centers[20] = (0.2951, 0.8999)\n centers[21] = (0.5085, 0.8888)\n centers[22] = (0.7163, 0.9047)\n centers[23] = (0.9074, 0.9058)\n centers[24] = (0.4068, 0.3942)\n centers[25] = (0.4703, 0.2519)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8804681751563488, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.5577976708150423, + "aux_packing_efficiency": 0.75611967936404, + "aux_radius_distribution": 0.9341661379115739, + "aux_gap_analysis": 0.7568, + "aux_geometric_quality": 0.666371996286751 + }, + "private": { + "reported_sum_of_radii": 2.3542991304396446 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3543\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.880\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Area utilization efficiency: 0.756\n \u2022 Area coverage (1 - gap ratio): 0.757\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.558\n \u2022 Radius size diversity: 0.934\n \u2022 Delaunay triangulation quality: 0.666\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_191/results/packing_viz.png", + "execution_time_mean": 924.3037533126771, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2d220baa7b0dee77f9aea740eb4d1283f47631a4 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..98a44f4bbf41f35ed93444d8aa209e92f98d108e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8871105147261602, + "spatial_uniformity_details": { + "cell_size_mean": 0.20261784338365033, + "cell_size_std": 0.025784187854910053, + "coefficient_of_variation": 0.1272552668465297 + }, + "edge_utilization": 0.6653846153846154, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 14, + "corner_score": 0.75, + "edge_score": 0.5384615384615384 + }, + "density_variance": 0.5529676017521004, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0006969395731748848, + "mean_density": 0.0326556427841967, + "cv": 0.8084242129764193 + }, + "packing_efficiency": 0.7268838710208323, + "packing_efficiency_details": { + "total_area": 0.7268838710208323, + "square_area": 1.0, + "efficiency": 0.7268838710208323, + "relative_to_estimated_best": 0.865337941691467 + }, + "radius_distribution": 0.8854530804755598, + "radius_distribution_details": { + "mean": 0.08777140621990968, + "std": 0.034571558318131905, + "min": 0.0013478150299026772, + "max": 0.1743775063556535, + "range": 0.17302969132575083, + "small_count": 6, + "medium_count": 15, + "large_count": 5, + "diversity_score": 0.8854530804755598 + }, + "gap_analysis": 0.7296, + "gap_analysis_details": { + "covered_samples": 1824, + "total_samples": 2500, + "coverage": 0.7296, + "gap_ratio": 0.2704 + }, + "geometric_quality": 0.666050869254344, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.666050869254344, + "min_quality": 0.3021300012663646, + "max_quality": 0.9263833179388419 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..6fbdc3d9482a69f2b17aa5ba67d7f9bf0fa98af1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 4089.25 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2821 + + Auxiliary Metrics: + • spatial_uniformity: 0.887 + • edge_utilization: 0.665 + • density_variance: 0.553 + • packing_efficiency: 0.727 + • radius_distribution: 0.885 + • gap_analysis: 0.730 + • geometric_quality: 0.666 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2821 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.887 + • Area utilization efficiency: 0.727 + • Area coverage (1 - gap ratio): 0.730 + +📊 Other Metrics: + • Boundary and corner utilization: 0.665 + • Spatial density uniformity across grid: 0.553 + • Radius size diversity: 0.885 + • Delaunay triangulation quality: 0.666 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..7c3130730cc4710370773982a921ceb68263954e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.282056561717652, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0979, 0.0800)\n centers[2] = (0.2969, 0.0629)\n centers[3] = (0.4567, 0.0838)\n centers[4] = (0.7565, 0.0215)\n centers[5] = (0.8789, 0.0909)\n centers[6] = (0.0974, 0.2708)\n centers[7] = (0.2974, 0.2232)\n centers[8] = (0.4895, 0.2502)\n centers[9] = (0.6455, 0.1094)\n centers[10] = (0.9107, 0.2811)\n centers[11] = (0.0676, 0.5081)\n centers[12] = (0.6934, 0.3526)\n centers[13] = (0.8979, 0.4918)\n centers[14] = (0.0013, 0.6378)\n centers[15] = (0.1025, 0.6901)\n centers[16] = (0.3428, 0.6256)\n centers[17] = (0.6587, 0.6574)\n centers[18] = (0.9136, 0.7123)\n centers[19] = (0.0971, 0.9029)\n centers[20] = (0.3090, 0.8920)\n centers[21] = (0.5216, 0.9028)\n centers[22] = (0.7165, 0.9132)\n centers[23] = (0.9054, 0.9054)\n centers[24] = (0.2119, 0.4251)\n centers[25] = (0.3857, 0.3946)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8871105147261602, + "aux_edge_utilization": 0.6653846153846154, + "aux_density_variance": 0.5529676017521004, + "aux_packing_efficiency": 0.7268838710208323, + "aux_radius_distribution": 0.8854530804755598, + "aux_gap_analysis": 0.7296, + "aux_geometric_quality": 0.666050869254344 + }, + "private": { + "reported_sum_of_radii": 2.282056561717652 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2821\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.887\n \u2022 Area utilization efficiency: 0.727\n \u2022 Area coverage (1 - gap ratio): 0.730\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.665\n \u2022 Spatial density uniformity across grid: 0.553\n \u2022 Radius size diversity: 0.885\n \u2022 Delaunay triangulation quality: 0.666\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_192/results/packing_viz.png", + "execution_time_mean": 4089.2482894309796, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..131e8e10716f2eba9cf8ae9b8d82a95c3492b05a Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4671009ace2ddedd1bba512624e9bdafaacc8958 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8905419546435273, + "spatial_uniformity_details": { + "cell_size_mean": 0.20254667299072346, + "cell_size_std": 0.02489536053060392, + "coefficient_of_variation": 0.12291172222232648 + }, + "edge_utilization": 0.6653846153846154, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 14, + "corner_score": 0.75, + "edge_score": 0.5384615384615384 + }, + "density_variance": 0.4780080702803942, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0011447486230051274, + "mean_density": 0.030983215748060466, + "cv": 1.092014888814348 + }, + "packing_efficiency": 0.696231242482327, + "packing_efficiency_details": { + "total_area": 0.696231242482327, + "square_area": 1.0, + "efficiency": 0.696231242482327, + "relative_to_estimated_best": 0.8288467172408656 + }, + "radius_distribution": 0.9341661379115739, + "radius_distribution_details": { + "mean": 0.0855911076987998, + "std": 0.03461075139059035, + "min": 0.0, + "max": 0.1788796581435929, + "range": 0.1788796581435929, + "small_count": 8, + "medium_count": 13, + "large_count": 5, + "diversity_score": 0.9341661379115739 + }, + "gap_analysis": 0.6968, + "gap_analysis_details": { + "covered_samples": 1742, + "total_samples": 2500, + "coverage": 0.6968, + "gap_ratio": 0.3032 + }, + "geometric_quality": 0.6593067247757869, + "geometric_quality_details": { + "num_triangles": 38, + "avg_triangle_quality": 0.6593067247757869, + "min_quality": 0.28215452548297665, + "max_quality": 0.9606409366935275 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..1e23e41122337023b9dae9282b7538d7d0c5d12e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/job_log.out @@ -0,0 +1,73 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 472.03 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2254 + + Auxiliary Metrics: + • spatial_uniformity: 0.891 + • edge_utilization: 0.665 + • density_variance: 0.478 + • packing_efficiency: 0.696 + • radius_distribution: 0.934 + • gap_analysis: 0.697 + • geometric_quality: 0.659 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2254 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.891 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.478 + → Balance circle density across different regions + +📊 Other Metrics: + • Boundary and corner utilization: 0.665 + • Area utilization efficiency: 0.696 + • Radius size diversity: 0.934 + • Area coverage (1 - gap ratio): 0.697 + • Delaunay triangulation quality: 0.659 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..f8a287a2c296a8c8eccb1d6a950766c105fc0d8a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.225368800168795, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.3378, 0.4817)\n centers[2] = (0.1368, 0.0834)\n centers[3] = (0.3378, 0.9114)\n centers[4] = (0.2683, 0.6710)\n centers[5] = (0.9453, 0.6253)\n centers[6] = (0.0662, 0.2244)\n centers[7] = (0.4395, 0.7759)\n centers[8] = (0.3136, 0.0816)\n centers[9] = (0.3707, 0.2902)\n centers[10] = (0.6971, 0.6715)\n centers[11] = (0.7464, 0.0776)\n centers[12] = (0.9201, 0.0802)\n centers[13] = (0.6729, 0.3227)\n centers[14] = (0.9129, 0.4822)\n centers[15] = (0.0663, 0.5594)\n centers[16] = (0.5057, 0.1015)\n centers[17] = (0.2236, 0.4758)\n centers[18] = (0.1186, 0.8780)\n centers[19] = (0.9191, 0.2526)\n centers[20] = (0.7504, 0.9237)\n centers[21] = (0.0702, 0.3677)\n centers[22] = (0.9327, 0.7591)\n centers[23] = (0.5734, 0.9144)\n centers[24] = (0.9158, 0.9155)\n centers[25] = (0.0618, 0.6910)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8905419546435273, + "aux_edge_utilization": 0.6653846153846154, + "aux_density_variance": 0.4780080702803942, + "aux_packing_efficiency": 0.696231242482327, + "aux_radius_distribution": 0.9341661379115739, + "aux_gap_analysis": 0.6968, + "aux_geometric_quality": 0.6593067247757869 + }, + "private": { + "reported_sum_of_radii": 2.225368800168795 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2254\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.891\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.478\n \u2192 Balance circle density across different regions\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.665\n \u2022 Area utilization efficiency: 0.696\n \u2022 Radius size diversity: 0.934\n \u2022 Area coverage (1 - gap ratio): 0.697\n \u2022 Delaunay triangulation quality: 0.659\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_193/results/packing_viz.png", + "execution_time_mean": 472.03401891421527, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8da206459adb1f049bcc41bddbb2401dd83184a1 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..55ae8de2622f5a7efb70bef7af9f432bb8fa09db --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/edit.diff @@ -0,0 +1,269 @@ +--- a/original.py ++++ b/original.py +@@ -1,256 +1,264 @@ + # EVOLVE-BLOCK-START + """ + Constructor-based circle packing for n=26 circles using a two-stage hybrid + optimization strategy. It combines a broad combinatorial search for initial + topologies with a deep, force-directed refinement of the best candidates. + """ + + import numpy as np + from itertools import combinations + + + class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version uses a fixed central circle as a stable anchor for the packing structure. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + ++ # Jiggle mechanism to escape local optima: periodic jiggle with decaying magnitude ++ if step > 0 and step % 100 == 0 and step < self.num_steps * 0.85: # Jiggle for 85% of steps ++ jiggle_magnitude = 0.004 * (1 - progress_ratio) # Decaying magnitude ++ jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude ++ if self.central_fixed: ++ jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle ++ self.centers += jiggle_vec ++ + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) +- # Use a strong, constant boundary force for better edge utilization +- K_boundary = 15.0 ++ # Adaptive boundary force: increases over time for stricter boundary enforcement ++ K_boundary = 10.0 + 10.0 * progress_ratio # Increases from 10.0 to 20.0 + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + + def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + + def _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2): + """Generates potential interstitial points with higher density, avoiding coarse grid lines.""" + if grid_size < 2: + return np.array([]) + num_intervals = (grid_size - 1) * density_factor + step = (end_coord - start_coord) / num_intervals + + candidates = [] + for i in range(num_intervals + 1): + for j in range(num_intervals + 1): + # Add point if it's NOT on a coarse grid line (unless it's a boundary) + if (i % density_factor != 0 or j % density_factor != 0): + candidates.append([start_coord + j * step, start_coord + i * step]) + return np.array(candidates) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search over `1+23+2` configurations, optimizing for + grid spacing and central circle weight. + 2. A deep dynamic refinement of the top N best configurations found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 20 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 4) + w_central_search_space = np.linspace(1.5, 2.8, 4) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] + if not central_idx_in_grid_list.size: continue + central_idx_in_grid = central_idx_in_grid_list[0] + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2) + if len(interstitial_candidates) < 2: continue + + num_interstitial_cand = len(interstitial_candidates) + + # Loop over removing 1 of 24 peripheral points + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Loop over pairs of interstitial candidates + for i, j in combinations(range(num_interstitial_cand), 2): + interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation with fewer iterations + radii = compute_max_radii(current_centers, max_iterations=250, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: + # Robust fallback: generate a simple grid-based configuration + centers = _generate_grid_centers(5, 0.1, 0.9) + extra_point = np.array([[0.5, 0.3]]) + centers = np.vstack([centers, extra_point]) + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + central_fixed=True) # Ensure central circle is fixed + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/main.py new file mode 100644 index 0000000000000000000000000000000000000000..13ba19802adedab2cf9a4253012470aaadbf150b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/main.py @@ -0,0 +1,264 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a two-stage hybrid +optimization strategy. It combines a broad combinatorial search for initial +topologies with a deep, force-directed refinement of the best candidates. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version uses a fixed central circle as a stable anchor for the packing structure. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Jiggle mechanism to escape local optima: periodic jiggle with decaying magnitude + if step > 0 and step % 100 == 0 and step < self.num_steps * 0.85: # Jiggle for 85% of steps + jiggle_magnitude = 0.004 * (1 - progress_ratio) # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle + self.centers += jiggle_vec + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Adaptive boundary force: increases over time for stricter boundary enforcement + K_boundary = 10.0 + 10.0 * progress_ratio # Increases from 10.0 to 20.0 + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2): + """Generates potential interstitial points with higher density, avoiding coarse grid lines.""" + if grid_size < 2: + return np.array([]) + num_intervals = (grid_size - 1) * density_factor + step = (end_coord - start_coord) / num_intervals + + candidates = [] + for i in range(num_intervals + 1): + for j in range(num_intervals + 1): + # Add point if it's NOT on a coarse grid line (unless it's a boundary) + if (i % density_factor != 0 or j % density_factor != 0): + candidates.append([start_coord + j * step, start_coord + i * step]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search over `1+23+2` configurations, optimizing for + grid spacing and central circle weight. + 2. A deep dynamic refinement of the top N best configurations found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 20 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 4) + w_central_search_space = np.linspace(1.5, 2.8, 4) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] + if not central_idx_in_grid_list.size: continue + central_idx_in_grid = central_idx_in_grid_list[0] + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2) + if len(interstitial_candidates) < 2: continue + + num_interstitial_cand = len(interstitial_candidates) + + # Loop over removing 1 of 24 peripheral points + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Loop over pairs of interstitial candidates + for i, j in combinations(range(num_interstitial_cand), 2): + interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation with fewer iterations + radii = compute_max_radii(current_centers, max_iterations=250, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: + # Robust fallback: generate a simple grid-based configuration + centers = _generate_grid_centers(5, 0.1, 0.9) + extra_point = np.array([[0.5, 0.3]]) + centers = np.vstack([centers, extra_point]) + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + central_fixed=True) # Ensure central circle is fixed + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/original.py new file mode 100644 index 0000000000000000000000000000000000000000..277110942ea97e1578ceb6f5b5e5b2906ff9c058 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/original.py @@ -0,0 +1,256 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a two-stage hybrid +optimization strategy. It combines a broad combinatorial search for initial +topologies with a deep, force-directed refinement of the best candidates. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version uses a fixed central circle as a stable anchor for the packing structure. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Use a strong, constant boundary force for better edge utilization + K_boundary = 15.0 + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2): + """Generates potential interstitial points with higher density, avoiding coarse grid lines.""" + if grid_size < 2: + return np.array([]) + num_intervals = (grid_size - 1) * density_factor + step = (end_coord - start_coord) / num_intervals + + candidates = [] + for i in range(num_intervals + 1): + for j in range(num_intervals + 1): + # Add point if it's NOT on a coarse grid line (unless it's a boundary) + if (i % density_factor != 0 or j % density_factor != 0): + candidates.append([start_coord + j * step, start_coord + i * step]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search over `1+23+2` configurations, optimizing for + grid spacing and central circle weight. + 2. A deep dynamic refinement of the top N best configurations found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 20 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 4) + w_central_search_space = np.linspace(1.5, 2.8, 4) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] + if not central_idx_in_grid_list.size: continue + central_idx_in_grid = central_idx_in_grid_list[0] + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2) + if len(interstitial_candidates) < 2: continue + + num_interstitial_cand = len(interstitial_candidates) + + # Loop over removing 1 of 24 peripheral points + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Loop over pairs of interstitial candidates + for i, j in combinations(range(num_interstitial_cand), 2): + interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation with fewer iterations + radii = compute_max_radii(current_centers, max_iterations=250, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: + # Robust fallback: generate a simple grid-based configuration + centers = _generate_grid_centers(5, 0.1, 0.9) + extra_point = np.array([[0.5, 0.3]]) + centers = np.vstack([centers, extra_point]) + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + central_fixed=True) # Ensure central circle is fixed + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..45ac7e644a3eb0c2bc96bbf50089680237e3cd6b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8407975893694336, + "spatial_uniformity_details": { + "cell_size_mean": 0.20150572596202507, + "cell_size_std": 0.03815448318813333, + "coefficient_of_variation": 0.189346892335838 + }, + "edge_utilization": 0.6346153846153846, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 12, + "corner_score": 0.75, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.4864485760321387, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0010814787536270968, + "mean_density": 0.031150281858141962, + "cv": 1.055715751409522 + }, + "packing_efficiency": 0.7169522578533025, + "packing_efficiency_details": { + "total_area": 0.7169522578533025, + "square_area": 1.0, + "efficiency": 0.7169522578533025, + "relative_to_estimated_best": 0.8535145926825031 + }, + "radius_distribution": 0.9629470128958899, + "radius_distribution_details": { + "mean": 0.0883175721049784, + "std": 0.03126386430359091, + "min": 0.037825573673061774, + "max": 0.18676046665351673, + "range": 0.14893489298045495, + "small_count": 8, + "medium_count": 12, + "large_count": 6, + "diversity_score": 0.9629470128958899 + }, + "gap_analysis": 0.7208, + "gap_analysis_details": { + "covered_samples": 1802, + "total_samples": 2500, + "coverage": 0.7208, + "gap_ratio": 0.2792 + }, + "geometric_quality": 0.6764888190017028, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6764888190017028, + "min_quality": 0.32125655498665695, + "max_quality": 0.9248227757678957 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..0ec3f522e40a4421bbf03f1c1556358204bb998c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/job_log.out @@ -0,0 +1,73 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 1520.83 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2963 + + Auxiliary Metrics: + • spatial_uniformity: 0.841 + • edge_utilization: 0.635 + • density_variance: 0.486 + • packing_efficiency: 0.717 + • radius_distribution: 0.963 + • gap_analysis: 0.721 + • geometric_quality: 0.676 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2963 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.841 + • Area utilization efficiency: 0.717 + • Area coverage (1 - gap ratio): 0.721 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.486 + → Balance circle density across different regions + +📊 Other Metrics: + • Boundary and corner utilization: 0.635 + • Radius size diversity: 0.963 + • Delaunay triangulation quality: 0.676 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..789c2580dda2287b7113c217928324c7796c038f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.2962568747294383, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0754, 0.0754)\n centers[2] = (0.1012, 0.2974)\n centers[3] = (0.0489, 0.4961)\n centers[4] = (0.0382, 0.7639)\n centers[5] = (0.0871, 0.8889)\n centers[6] = (0.2602, 0.1243)\n centers[7] = (0.2388, 0.3086)\n centers[8] = (0.2326, 0.4798)\n centers[9] = (0.1131, 0.6387)\n centers[10] = (0.2696, 0.9165)\n centers[11] = (0.4557, 0.0886)\n centers[12] = (0.4255, 0.2906)\n centers[13] = (0.3515, 0.6909)\n centers[14] = (0.4934, 0.8992)\n centers[15] = (0.6846, 0.1270)\n centers[16] = (0.6388, 0.3690)\n centers[17] = (0.6793, 0.6737)\n centers[18] = (0.7180, 0.9292)\n centers[19] = (0.9101, 0.0899)\n centers[20] = (0.8843, 0.3032)\n centers[21] = (0.9093, 0.5175)\n centers[22] = (0.9309, 0.7183)\n centers[23] = (0.9034, 0.9040)\n centers[24] = (0.1067, 0.4077)\n centers[25] = (0.3818, 0.4659)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8407975893694336, + "aux_edge_utilization": 0.6346153846153846, + "aux_density_variance": 0.4864485760321387, + "aux_packing_efficiency": 0.7169522578533025, + "aux_radius_distribution": 0.9629470128958899, + "aux_gap_analysis": 0.7208, + "aux_geometric_quality": 0.6764888190017028 + }, + "private": { + "reported_sum_of_radii": 2.2962568747294383 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2963\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.841\n \u2022 Area utilization efficiency: 0.717\n \u2022 Area coverage (1 - gap ratio): 0.721\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.486\n \u2192 Balance circle density across different regions\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.635\n \u2022 Radius size diversity: 0.963\n \u2022 Delaunay triangulation quality: 0.676\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/results/packing_viz.png", + "execution_time_mean": 1520.8294488070533, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..d3e1c6c0f0d1dce9e2168ba3ac6058b3787bbf91 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_194/search_replace.txt @@ -0,0 +1,33 @@ + +Introduce a decaying jiggle mechanism in the optimization loop to help escape local minima and make the boundary repulsion force (`K_boundary`) adaptive, increasing it over time to further encourage circles to utilize the edges of the square. This targets both overall primary score improvement and the 'edge_utilization' metric. + + + +<<<<<<< SEARCH + learning_rate = max(learning_rate, 1e-7) + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Use a strong, constant boundary force for better edge utilization + K_boundary = 15.0 + + # Use more iterations for radius calculation as the packing gets tighter +======= + learning_rate = max(learning_rate, 1e-7) + + # Jiggle mechanism to escape local optima: periodic jiggle with decaying magnitude + if step > 0 and step % 100 == 0 and step < self.num_steps * 0.85: # Jiggle for 85% of steps + jiggle_magnitude = 0.004 * (1 - progress_ratio) # Decaying magnitude + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 # Do not jiggle the fixed central circle + self.centers += jiggle_vec + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Adaptive boundary force: increases over time for stricter boundary enforcement + K_boundary = 10.0 + 10.0 * progress_ratio # Increases from 10.0 to 20.0 + + # Use more iterations for radius calculation as the packing gets tighter +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4a83ff65806446ec28961c93e3dd3c9c3bed706d Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..f7533e2fc62abedbc865db7814366ca305ef90db --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/edit.diff @@ -0,0 +1,476 @@ +--- a/original.py ++++ b/original.py +@@ -1,256 +1,297 @@ + # EVOLVE-BLOCK-START +-""" +-Constructor-based circle packing for n=26 circles using a two-stage hybrid +-optimization strategy. It combines a broad combinatorial search for initial +-topologies with a deep, force-directed refinement of the best candidates. +-""" +- + import numpy as np +-from itertools import combinations ++import itertools ++from collections import namedtuple ++ ++# Define a data structure for a packing configuration candidate ++PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) ++ ++class PackingUtilities: ++ """ ++ Utility functions for circle packing, including radius calculation and ++ initial center generation. ++ """ ++ @staticmethod ++ def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): ++ """ ++ Compute maximum radii using an iterative relaxation approach. Includes a ++ heuristic for special circles (e.g., interstitial) and weighted scaling ++ for the central one. ++ """ ++ n = centers.shape[0] ++ radii = np.zeros(n) ++ ++ # 1. Initialize radii based on distance to square borders. ++ for i in range(n): ++ x, y = centers[i] ++ radii[i] = min(x, y, 1 - x, 1 - y) ++ ++ # Heuristic: Adaptively cap the initial radius of special circles. ++ if special_radii_indices: ++ for idx in special_radii_indices: ++ if idx < n: # Ensure index is valid ++ other_centers_mask = np.ones(n, dtype=bool) ++ other_centers_mask[idx] = False ++ other_centers = centers[other_centers_mask] ++ ++ if len(other_centers) > 0: ++ distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) ++ min_dist_to_neighbor = np.min(distances_to_others) ++ radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) ++ ++ # 2. Iteratively adjust radii to resolve overlaps until convergence. ++ for _ in range(max_iterations): ++ prev_radii = np.copy(radii) ++ ++ for i in range(n): ++ for j in range(i + 1, n): ++ dist = np.linalg.norm(centers[i] - centers[j]) ++ ++ if radii[i] + radii[j] > dist: ++ overlap = radii[i] + radii[j] - dist ++ ++ # Weighted proportional scaling to protect the central circle (at index 0). ++ w_i = w_central if i == 0 else 1.0 ++ w_j = 1.0 # Other circles have normal weight (j > i) ++ ++ weighted_r_i = radii[i] / w_i ++ weighted_r_j = radii[j] / w_j ++ total_weighted_radii = weighted_r_i + weighted_r_j ++ ++ if total_weighted_radii > 1e-12: # Avoid division by zero ++ radii[i] -= overlap * (weighted_r_i / total_weighted_radii) ++ radii[j] -= overlap * (weighted_r_j / total_weighted_radii) ++ else: ++ # Fallback scaling ++ scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor ++ ++ radii[radii < 0] = 0 # Ensure no radii become negative ++ ++ if np.allclose(radii, prev_radii, atol=tolerance): ++ break ++ ++ return radii ++ ++ @staticmethod ++ def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): ++ """Generates centers for a square grid of circles with asymmetric bounds.""" ++ x_coords = np.linspace(sc_x, ec_x, grid_size) ++ y_coords = np.linspace(sc_y, ec_y, grid_size) ++ return np.array([[x, y] for y in y_coords for x in x_coords]) ++ ++ @staticmethod ++ def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): ++ """Generates potential interstitial points within the grid with higher density.""" ++ if grid_size < 2: ++ return np.array([]) ++ num_interstitial_intervals_x = (grid_size - 1) * density_factor ++ num_interstitial_intervals_y = (grid_size - 1) * density_factor ++ step_x = (ec_x - sc_x) / num_interstitial_intervals_x ++ step_y = (ec_y - sc_y) / num_interstitial_intervals_y ++ candidates = [] ++ for i in range(num_interstitial_intervals_y): ++ for j in range(num_interstitial_intervals_x): ++ interstitial_x = sc_x + j * step_x + step_x / 2 ++ interstitial_y = sc_y + i * step_y + step_y / 2 ++ candidates.append([interstitial_x, interstitial_y]) ++ return np.array(candidates) + + + class DynamicPackingOptimizer: +- """ +- Optimizes circle packing using a force-directed approach with iterative radius maximization. +- This version uses a fixed central circle as a stable anchor for the packing structure. +- """ +- def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): ++ """Optimizes circle packing using a force-directed approach with adaptive parameters.""" ++ def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate ++ self.central_fixed = central_fixed ++ self.centers = np.copy(initial_centers) ++ self.special_radii_indices = special_radii_indices + self.w_central = w_central +- self.central_fixed = central_fixed +- +- self.centers = np.copy(initial_centers) +- self.interstitial_idx = interstitial_idx + self.central_idx = 0 +- +- # Initialize best configuration with max radii for the starting configuration +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) ++ self.radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): ++ """Runs the force-directed optimization loop with jiggle and adaptive forces.""" + for step in range(self.num_steps): +- progress_ratio = step / self.num_steps +- learning_rate = self.initial_learning_rate * (1 - progress_ratio) ++ progress = step / self.num_steps ++ learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + +- # Adaptive buffer that decreases for tighter packing in later stages +- buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) +- # Use a strong, constant boundary force for better edge utilization +- K_boundary = 15.0 +- +- # Use more iterations for radius calculation as the packing gets tighter ++ if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: ++ jiggle_magnitude = 0.004 * (1 - progress) ++ jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude ++ if self.central_fixed: ++ jiggle_vec[self.central_idx] = 0.0 ++ self.centers += jiggle_vec ++ + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) +- +- # Periodically check for improvement with a full-iteration radius calculation ++ current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) ++ + if step % 50 == 0 or step == self.num_steps - 1: +- test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) +- current_sum_radii = np.sum(test_radii_for_sum) +- ++ test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) ++ current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(test_radii_for_sum) +- +- # Calculate force vectors for center movement ++ self.best_radii = np.copy(test_radii) ++ + force_vectors = np.zeros_like(self.centers) +- +- # Repulsion between circles ++ buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + +- # Boundary repulsion forces ++ K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + +- # Update centers based on forces + self.centers += learning_rate * force_vectors +- +- # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + +- # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) +- + return self.best_centers, self.best_radii + + +-def _generate_grid_centers(grid_size, start_coord, end_coord): +- """Generates centers for a square grid of circles.""" +- coords = np.linspace(start_coord, end_coord, grid_size) +- return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) +- +- +-def _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2): +- """Generates potential interstitial points with higher density, avoiding coarse grid lines.""" +- if grid_size < 2: +- return np.array([]) +- num_intervals = (grid_size - 1) * density_factor +- step = (end_coord - start_coord) / num_intervals +- +- candidates = [] +- for i in range(num_intervals + 1): +- for j in range(num_intervals + 1): +- # Add point if it's NOT on a coarse grid line (unless it's a boundary) +- if (i % density_factor != 0 or j % density_factor != 0): +- candidates.append([start_coord + j * step, start_coord + i * step]) +- return np.array(candidates) ++class InitialConfigurationGenerator: ++ """Generates initial packing configurations for the combinatorial search.""" ++ def __init__(self, n_circles, grid_size, sc_options, ec_options, central_weight_options, ++ num_peripheral_to_select, num_interstitial_to_select, interstitial_density_factor=1): ++ self.n_circles = n_circles ++ self.grid_size = grid_size ++ self.sc_options = sc_options ++ self.ec_options = ec_options ++ self.central_weight_options = central_weight_options ++ self.num_peripheral_to_select = num_peripheral_to_select ++ self.num_interstitial_to_select = num_interstitial_to_select ++ self.interstitial_density_factor = interstitial_density_factor ++ self.central_point = np.array([0.5, 0.5]) ++ self.num_fixed_central = 1 ++ ++ def generate_candidates(self): ++ """Yields PackingCandidate objects for coarse evaluation.""" ++ for w_central in self.central_weight_options: ++ for sc_x in self.sc_options: ++ for ec_x in self.ec_options: ++ if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue ++ for sc_y in self.sc_options: ++ for ec_y in self.ec_options: ++ if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue ++ ++ all_grid_centers = PackingUtilities.generate_grid_centers(self.grid_size, sc_x, ec_x, sc_y, ec_y) ++ all_interstitial_points = PackingUtilities.generate_interstitial_candidates(self.grid_size, sc_x, ec_x, sc_y, ec_y, self.interstitial_density_factor) ++ peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, self.central_point)]) ++ ++ if len(peripheral_grid_points) < self.num_peripheral_to_select or \ ++ len(all_interstitial_points) < self.num_interstitial_to_select: ++ continue ++ ++ for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.num_peripheral_to_select): ++ selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] ++ for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), self.num_interstitial_to_select): ++ selected_interstitial_points = all_interstitial_points[list(i_indices_combo)] ++ current_centers = np.vstack([self.central_point, selected_peripheral_points, selected_interstitial_points]) ++ special_radii_indices = list(range(self.num_fixed_central + self.num_peripheral_to_select, self.n_circles)) ++ coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) ++ yield PackingCandidate(np.sum(coarse_radii), current_centers, w_central, special_radii_indices) + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: +- 1. A broad combinatorial search over `1+23+2` configurations, optimizing for +- grid spacing and central circle weight. +- 2. A deep dynamic refinement of the top N best configurations found. ++ 1. A broad combinatorial search finds promising initial topologies. ++ 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 +- top_n_to_refine = 20 +- +- # --- STAGE 1: Coarse Combinatorial Search --- +- start_coord_search_space = np.linspace(0.08, 0.12, 4) +- w_central_search_space = np.linspace(1.5, 2.8, 4) +- top_n_configs = [] +- +- for w_central in w_central_search_space: +- for start_coord in start_coord_search_space: +- end_coord = 1.0 - start_coord +- +- all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) +- central_point_coords = np.array([[0.5, 0.5]]) +- central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] +- if not central_idx_in_grid_list.size: continue +- central_idx_in_grid = central_idx_in_grid_list[0] +- potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- +- interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2) +- if len(interstitial_candidates) < 2: continue +- +- num_interstitial_cand = len(interstitial_candidates) +- +- # Loop over removing 1 of 24 peripheral points +- for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): +- current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) +- +- # Loop over pairs of interstitial candidates +- for i, j in combinations(range(num_interstitial_cand), 2): +- interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) +- +- # Assemble config: 1 central, 23 peripheral, 2 interstitial +- current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) +- interstitial_indices = [n_circles - 2, n_circles - 1] +- +- # Fast evaluation with fewer iterations +- radii = compute_max_radii(current_centers, max_iterations=250, interstitial_idx=interstitial_indices, w_central=w_central) +- sum_r = np.sum(radii) +- +- if len(top_n_configs) < top_n_to_refine: +- top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) +- top_n_configs.sort(key=lambda x: x[0], reverse=True) +- elif sum_r > top_n_configs[-1][0]: +- top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) +- top_n_configs.sort(key=lambda x: x[0], reverse=True) +- +- # --- STAGE 2: Dynamic Refinement --- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None +- +- if not top_n_configs: +- # Robust fallback: generate a simple grid-based configuration +- centers = _generate_grid_centers(5, 0.1, 0.9) +- extra_point = np.array([[0.5, 0.3]]) +- centers = np.vstack([centers, extra_point]) +- radii = compute_max_radii(centers) +- return centers, radii +- +- for _, centers, interstitial_idx, w_central in top_n_configs: +- optimizer = DynamicPackingOptimizer(initial_centers=centers, +- interstitial_idx=interstitial_idx, +- w_central=w_central, +- num_circles=n_circles, +- central_fixed=True) # Ensure central circle is fixed +- ++ ++ # Crossover: Expanded search space and more candidates ++ sc_options = np.linspace(0.07, 0.13, 6) ++ ec_options = np.linspace(0.87, 0.93, 6) ++ central_weight_options = np.linspace(1.5, 3.2, 5) ++ ++ num_fixed_central = 1 ++ num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 peripheral ++ num_interstitial_to_select = 2 ++ ++ TOP_N_CANDIDATES = 30 ++ top_candidates = [] ++ ++ # STAGE 1: Coarse Combinatorial Search ++ config_generator = InitialConfigurationGenerator( ++ n_circles=n_circles, ++ grid_size=grid_size, ++ sc_options=sc_options, ++ ec_options=ec_options, ++ central_weight_options=central_weight_options, ++ num_peripheral_to_select=num_peripheral_to_select, ++ num_interstitial_to_select=num_interstitial_to_select, ++ interstitial_density_factor=2 # Crossover: Denser interstitial search ++ ) ++ ++ for candidate in config_generator.generate_candidates(): ++ if len(top_candidates) < TOP_N_CANDIDATES: ++ top_candidates.append(candidate) ++ top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) ++ elif candidate.sum_radii > top_candidates[-1].sum_radii: ++ top_candidates.pop() ++ top_candidates.append(candidate) ++ top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) ++ ++ # STAGE 2: Refine Top Candidates with Dynamic Optimizer ++ if not top_candidates: ++ return np.random.rand(n_circles, 2), np.zeros(n_circles) ++ ++ best_candidate = top_candidates[0] ++ best_centers = best_candidate.centers ++ best_radii = PackingUtilities.compute_max_radii(best_centers, max_iterations=2000, special_radii_indices=best_candidate.special_radii_indices, w_central=best_candidate.w_central) ++ best_sum_radii = np.sum(best_radii) ++ ++ for candidate in top_candidates: ++ optimizer = DynamicPackingOptimizer( ++ initial_centers=candidate.centers, ++ special_radii_indices=candidate.special_radii_indices, ++ w_central=candidate.w_central, ++ num_circles=n_circles, ++ num_steps=3000, ++ initial_learning_rate=0.02, ++ central_fixed=True, ++ ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): +- """ +- Computes maximum radii using a generalized iterative relaxation approach. +- It supports capping initial radii for multiple interstitial circles and +- uses weighted relaxation for the central circle. +- """ +- n = centers.shape[0] +- radii = np.zeros(n) +- +- for i in range(n): +- x, y = centers[i] +- radii[i] = min(x, y, 1 - x, 1 - y) +- +- if interstitial_idx is not None: +- indices = np.atleast_1d(interstitial_idx) +- for idx in indices: +- if idx < n: +- other_centers = np.delete(centers, idx, axis=0) +- if len(other_centers) > 0: +- distances = np.linalg.norm(centers[idx] - other_centers, axis=1) +- radii[idx] = min(radii[idx], 0.5 * np.min(distances)) +- +- for _ in range(max_iterations): +- prev_radii = np.copy(radii) +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.linalg.norm(centers[i] - centers[j]) +- if radii[i] + radii[j] > dist: +- overlap = radii[i] + radii[j] - dist +- w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 +- weighted_r_i = radii[i] / w_i +- weighted_r_j = radii[j] / w_j +- total_weighted = weighted_r_i + weighted_r_j +- if total_weighted > 1e-12: +- radii[i] -= overlap * (weighted_r_i / total_weighted) +- radii[j] -= overlap * (weighted_r_j / total_weighted) +- if np.allclose(radii, prev_radii, atol=tolerance): +- break +- +- return np.maximum(radii, 0) + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/main.py new file mode 100644 index 0000000000000000000000000000000000000000..9e7d1843727923deecac88ce4d024a39b4d32945 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/main.py @@ -0,0 +1,297 @@ +# EVOLVE-BLOCK-START +import numpy as np +import itertools +from collections import namedtuple + +# Define a data structure for a packing configuration candidate +PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) + +class PackingUtilities: + """ + Utility functions for circle packing, including radius calculation and + initial center generation. + """ + @staticmethod + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for special circles (e.g., interstitial) and weighted scaling + for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of special circles. + if special_radii_indices: + for idx in special_radii_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # Other circles have normal weight (j > i) + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback scaling + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + radii[radii < 0] = 0 # Ensure no radii become negative + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + @staticmethod + def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + @staticmethod + def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points within the grid with higher density.""" + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +class DynamicPackingOptimizer: + """Optimizes circle packing using a force-directed approach with adaptive parameters.""" + def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.centers = np.copy(initial_centers) + self.special_radii_indices = special_radii_indices + self.w_central = w_central + self.central_idx = 0 + self.radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop with jiggle and adaptive forces.""" + for step in range(self.num_steps): + progress = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + + if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - progress) + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 + self.centers += jiggle_vec + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + return self.best_centers, self.best_radii + + +class InitialConfigurationGenerator: + """Generates initial packing configurations for the combinatorial search.""" + def __init__(self, n_circles, grid_size, sc_options, ec_options, central_weight_options, + num_peripheral_to_select, num_interstitial_to_select, interstitial_density_factor=1): + self.n_circles = n_circles + self.grid_size = grid_size + self.sc_options = sc_options + self.ec_options = ec_options + self.central_weight_options = central_weight_options + self.num_peripheral_to_select = num_peripheral_to_select + self.num_interstitial_to_select = num_interstitial_to_select + self.interstitial_density_factor = interstitial_density_factor + self.central_point = np.array([0.5, 0.5]) + self.num_fixed_central = 1 + + def generate_candidates(self): + """Yields PackingCandidate objects for coarse evaluation.""" + for w_central in self.central_weight_options: + for sc_x in self.sc_options: + for ec_x in self.ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in self.sc_options: + for ec_y in self.ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = PackingUtilities.generate_grid_centers(self.grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_points = PackingUtilities.generate_interstitial_candidates(self.grid_size, sc_x, ec_x, sc_y, ec_y, self.interstitial_density_factor) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, self.central_point)]) + + if len(peripheral_grid_points) < self.num_peripheral_to_select or \ + len(all_interstitial_points) < self.num_interstitial_to_select: + continue + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), self.num_interstitial_to_select): + selected_interstitial_points = all_interstitial_points[list(i_indices_combo)] + current_centers = np.vstack([self.central_point, selected_peripheral_points, selected_interstitial_points]) + special_radii_indices = list(range(self.num_fixed_central + self.num_peripheral_to_select, self.n_circles)) + coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) + yield PackingCandidate(np.sum(coarse_radii), current_centers, w_central, special_radii_indices) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + + # Crossover: Expanded search space and more candidates + sc_options = np.linspace(0.07, 0.13, 6) + ec_options = np.linspace(0.87, 0.93, 6) + central_weight_options = np.linspace(1.5, 3.2, 5) + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 peripheral + num_interstitial_to_select = 2 + + TOP_N_CANDIDATES = 30 + top_candidates = [] + + # STAGE 1: Coarse Combinatorial Search + config_generator = InitialConfigurationGenerator( + n_circles=n_circles, + grid_size=grid_size, + sc_options=sc_options, + ec_options=ec_options, + central_weight_options=central_weight_options, + num_peripheral_to_select=num_peripheral_to_select, + num_interstitial_to_select=num_interstitial_to_select, + interstitial_density_factor=2 # Crossover: Denser interstitial search + ) + + for candidate in config_generator.generate_candidates(): + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + elif candidate.sum_radii > top_candidates[-1].sum_radii: + top_candidates.pop() + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_candidate = top_candidates[0] + best_centers = best_candidate.centers + best_radii = PackingUtilities.compute_max_radii(best_centers, max_iterations=2000, special_radii_indices=best_candidate.special_radii_indices, w_central=best_candidate.w_central) + best_sum_radii = np.sum(best_radii) + + for candidate in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=candidate.centers, + special_radii_indices=candidate.special_radii_indices, + w_central=candidate.w_central, + num_circles=n_circles, + num_steps=3000, + initial_learning_rate=0.02, + central_fixed=True, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/original.py new file mode 100644 index 0000000000000000000000000000000000000000..ef6db6fc5273a767d5bf11eb400ff86dc18839b8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/original.py @@ -0,0 +1,256 @@ +# EVOLVE-BLOCK-START +""" +Constructor-based circle packing for n=26 circles using a two-stage hybrid +optimization strategy. It combines a broad combinatorial search for initial +topologies with a deep, force-directed refinement of the best candidates. +""" + +import numpy as np +from itertools import combinations + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach with iterative radius maximization. + This version uses a fixed central circle as a stable anchor for the packing structure. + """ + def __init__(self, initial_centers, interstitial_idx, w_central=1.5, num_circles=26, num_steps=3000, initial_learning_rate=0.018, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.w_central = w_central + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_idx = interstitial_idx + self.central_idx = 0 + + # Initialize best configuration with max radii for the starting configuration + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + for step in range(self.num_steps): + progress_ratio = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress_ratio) + learning_rate = max(learning_rate, 1e-7) + + # Adaptive buffer that decreases for tighter packing in later stages + buffer_factor = 0.02 + (0.1 - 0.02) * (1 - progress_ratio) + # Use a strong, constant boundary force for better edge utilization + K_boundary = 15.0 + + # Use more iterations for radius calculation as the packing gets tighter + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + + # Periodically check for improvement with a full-iteration radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii_for_sum = compute_max_radii(self.centers, max_iterations=2000, interstitial_idx=self.interstitial_idx, w_central=self.w_central) + current_sum_radii = np.sum(test_radii_for_sum) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii_for_sum) + + # Calculate force vectors for center movement + force_vectors = np.zeros_like(self.centers) + + # Repulsion between circles + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Boundary repulsion forces + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # Update centers based on forces + self.centers += learning_rate * force_vectors + + # Hard-fix the central circle to its anchor position + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within bounds (considering radii) + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """Generates centers for a square grid of circles.""" + coords = np.linspace(start_coord, end_coord, grid_size) + return np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2): + """Generates potential interstitial points with higher density, avoiding coarse grid lines.""" + if grid_size < 2: + return np.array([]) + num_intervals = (grid_size - 1) * density_factor + step = (end_coord - start_coord) / num_intervals + + candidates = [] + for i in range(num_intervals + 1): + for j in range(num_intervals + 1): + # Add point if it's NOT on a coarse grid line (unless it's a boundary) + if (i % density_factor != 0 or j % density_factor != 0): + candidates.append([start_coord + j * step, start_coord + i * step]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search over `1+23+2` configurations, optimizing for + grid spacing and central circle weight. + 2. A deep dynamic refinement of the top N best configurations found. + """ + n_circles = 26 + grid_size = 5 + top_n_to_refine = 20 + + # --- STAGE 1: Coarse Combinatorial Search --- + start_coord_search_space = np.linspace(0.08, 0.12, 4) + w_central_search_space = np.linspace(1.5, 2.8, 4) + top_n_configs = [] + + for w_central in w_central_search_space: + for start_coord in start_coord_search_space: + end_coord = 1.0 - start_coord + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + central_point_coords = np.array([[0.5, 0.5]]) + central_idx_in_grid_list = np.where(np.all(np.isclose(all_grid_centers, [0.5, 0.5]), axis=1))[0] + if not central_idx_in_grid_list.size: continue + central_idx_in_grid = central_idx_in_grid_list[0] + potential_peripheral_centers_24 = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + interstitial_candidates = _generate_interstitial_candidates(grid_size, start_coord, end_coord, density_factor=2) + if len(interstitial_candidates) < 2: continue + + num_interstitial_cand = len(interstitial_candidates) + + # Loop over removing 1 of 24 peripheral points + for peripheral_remove_idx in range(len(potential_peripheral_centers_24)): + current_peripheral_centers_23 = np.delete(potential_peripheral_centers_24, peripheral_remove_idx, axis=0) + + # Loop over pairs of interstitial candidates + for i, j in combinations(range(num_interstitial_cand), 2): + interstitial_points = np.array([interstitial_candidates[i], interstitial_candidates[j]]) + + # Assemble config: 1 central, 23 peripheral, 2 interstitial + current_centers = np.vstack([central_point_coords, current_peripheral_centers_23, interstitial_points]) + interstitial_indices = [n_circles - 2, n_circles - 1] + + # Fast evaluation with fewer iterations + radii = compute_max_radii(current_centers, max_iterations=250, interstitial_idx=interstitial_indices, w_central=w_central) + sum_r = np.sum(radii) + + if len(top_n_configs) < top_n_to_refine: + top_n_configs.append((sum_r, current_centers, interstitial_indices, w_central)) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + elif sum_r > top_n_configs[-1][0]: + top_n_configs[-1] = (sum_r, current_centers, interstitial_indices, w_central) + top_n_configs.sort(key=lambda x: x[0], reverse=True) + + # --- STAGE 2: Dynamic Refinement --- + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + if not top_n_configs: + # Robust fallback: generate a simple grid-based configuration + centers = _generate_grid_centers(5, 0.1, 0.9) + extra_point = np.array([[0.5, 0.3]]) + centers = np.vstack([centers, extra_point]) + radii = compute_max_radii(centers) + return centers, radii + + for _, centers, interstitial_idx, w_central in top_n_configs: + optimizer = DynamicPackingOptimizer(initial_centers=centers, + interstitial_idx=interstitial_idx, + w_central=w_central, + num_circles=n_circles, + central_fixed=True) # Ensure central circle is fixed + + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8, interstitial_idx=None, w_central=1.0): + """ + Computes maximum radii using a generalized iterative relaxation approach. + It supports capping initial radii for multiple interstitial circles and + uses weighted relaxation for the central circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + if interstitial_idx is not None: + indices = np.atleast_1d(interstitial_idx) + for idx in indices: + if idx < n: + other_centers = np.delete(centers, idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[idx] - other_centers, axis=1) + radii[idx] = min(radii[idx], 0.5 * np.min(distances)) + + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..b1668129a14c02e87851aa614cfa5869f8ee9f04 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/results/job_log.err @@ -0,0 +1,25 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] +Traceback (most recent call last): + File "/home/tengxiao/pj/ShinkaEvolve/examples/circle_packing/evaluate_with_auxiliary.py", line 290, in + main( + File "/home/tengxiao/pj/ShinkaEvolve/examples/circle_packing/evaluate_with_auxiliary.py", line 207, in main + metrics, correct, error_msg = run_shinka_eval( + ^^^^^^^^^^^^^^^^ + File "/home/tengxiao/pj/ShinkaEvolve/shinka/core/wrap_eval.py", line 119, in run_shinka_eval + run_result = experiment_fn(**kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^ + File "/home/tengxiao/pj/ShinkaEvolve/examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/main.py", line 294, in run_packing + centers, radii = construct_packing() + ^^^^^^^^^^^^^^^^^^^ + File "/home/tengxiao/pj/ShinkaEvolve/examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/main.py", line 251, in construct_packing + for candidate in config_generator.generate_candidates(): + File "/home/tengxiao/pj/ShinkaEvolve/examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/main.py", line 214, in generate_candidates + coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..19549484a4e437f4f0f0c759eb8b507303fda043 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/results/job_log.out @@ -0,0 +1,15 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/results +Auxiliary Metrics: ENABLED +====================================================================== + diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..8066fc3a6eefdbf570721addc5451d3864fbf963 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_195/rewrite.txt @@ -0,0 +1,288 @@ +# EVOLVE-BLOCK-START +import numpy as np +import itertools +from collections import namedtuple + +# Define a data structure for a packing configuration candidate +PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) + +class PackingUtilities: + """ + Utility functions for circle packing, including radius calculation and + initial center generation. + """ + @staticmethod + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for special circles (e.g., interstitial) and weighted scaling + for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of special circles. + if special_radii_indices: + for idx in special_radii_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # Other circles have normal weight (j > i) + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback scaling + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + radii[radii < 0] = 0 # Ensure no radii become negative + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + @staticmethod + def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + @staticmethod + def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points within the grid with higher density.""" + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +class DynamicPackingOptimizer: + """Optimizes circle packing using a force-directed approach with adaptive parameters.""" + def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.centers = np.copy(initial_centers) + self.special_radii_indices = special_radii_indices + self.w_central = w_central + self.central_idx = 0 + self.radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop with jiggle and adaptive forces.""" + for step in range(self.num_steps): + progress = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + + if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - progress) + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 + self.centers += jiggle_vec + + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + return self.best_centers, self.best_radii + + +class InitialConfigurationGenerator: + """Generates initial packing configurations for the combinatorial search.""" + def __init__(self, n_circles, grid_size, sc_options, ec_options, central_weight_options, + num_peripheral_to_select, num_interstitial_to_select, interstitial_density_factor=1): + self.n_circles = n_circles + self.grid_size = grid_size + self.sc_options = sc_options + self.ec_options = ec_options + self.central_weight_options = central_weight_options + self.num_peripheral_to_select = num_peripheral_to_select + self.num_interstitial_to_select = num_interstitial_to_select + self.interstitial_density_factor = interstitial_density_factor + self.central_point = np.array([0.5, 0.5]) + self.num_fixed_central = 1 + + def generate_candidates(self): + """Yields PackingCandidate objects for coarse evaluation.""" + for w_central in self.central_weight_options: + for sc_x in self.sc_options: + for ec_x in self.ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in self.sc_options: + for ec_y in self.ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = PackingUtilities.generate_grid_centers(self.grid_size, sc_x, ec_x, sc_y, ec_y) + all_interstitial_points = PackingUtilities.generate_interstitial_candidates(self.grid_size, sc_x, ec_x, sc_y, ec_y, self.interstitial_density_factor) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, self.central_point)]) + + if len(peripheral_grid_points) < self.num_peripheral_to_select or \ + len(all_interstitial_points) < self.num_interstitial_to_select: + continue + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), self.num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), self.num_interstitial_to_select): + selected_interstitial_points = all_interstitial_points[list(i_indices_combo)] + current_centers = np.vstack([self.central_point, selected_peripheral_points, selected_interstitial_points]) + special_radii_indices = list(range(self.num_fixed_central + self.num_peripheral_to_select, self.n_circles)) + coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) + yield PackingCandidate(np.sum(coarse_radii), current_centers, w_central, special_radii_indices) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + + # Crossover: Expanded search space and more candidates + sc_options = np.linspace(0.07, 0.13, 6) + ec_options = np.linspace(0.87, 0.93, 6) + central_weight_options = np.linspace(1.5, 3.2, 5) + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 peripheral + num_interstitial_to_select = 2 + + TOP_N_CANDIDATES = 30 + top_candidates = [] + + # STAGE 1: Coarse Combinatorial Search + config_generator = InitialConfigurationGenerator( + n_circles=n_circles, + grid_size=grid_size, + sc_options=sc_options, + ec_options=ec_options, + central_weight_options=central_weight_options, + num_peripheral_to_select=num_peripheral_to_select, + num_interstitial_to_select=num_interstitial_to_select, + interstitial_density_factor=2 # Crossover: Denser interstitial search + ) + + for candidate in config_generator.generate_candidates(): + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + elif candidate.sum_radii > top_candidates[-1].sum_radii: + top_candidates.pop() + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_candidate = top_candidates[0] + best_centers = best_candidate.centers + best_radii = PackingUtilities.compute_max_radii(best_centers, max_iterations=2000, special_radii_indices=best_candidate.special_radii_indices, w_central=best_candidate.w_central) + best_sum_radii = np.sum(best_radii) + + for candidate in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=candidate.centers, + special_radii_indices=candidate.special_radii_indices, + w_central=candidate.w_central, + num_circles=n_circles, + num_steps=3000, + initial_learning_rate=0.02, + central_fixed=True, + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e3858ff94ef79af9d1d646c60d561d073c8fa375 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..c8f98848d414409ec68a4f82cdda887dd4ffb5c0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/edit.diff @@ -0,0 +1,496 @@ +--- a/original.py ++++ b/original.py +@@ -1,283 +1,290 @@ + # EVOLVE-BLOCK-START +-""" +-Hybrid circle packing for n=26 circles, combining a systematic search for +-initial configurations with a force-directed dynamic optimizer for refinement. +-""" +- + import numpy as np + import itertools ++from collections import namedtuple ++ ++# Define a data structure for a packing configuration candidate ++# This improves readability and maintainability over using raw tuples. ++PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) ++ ++class PackingUtilities: ++ """ ++ A utility class to encapsulate static, stateless helper functions for circle packing. ++ This separates core geometric calculations from the main optimization and generation logic. ++ """ ++ @staticmethod ++ def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): ++ """ ++ Computes maximum radii using an iterative relaxation approach. Includes a ++ heuristic for special circles (e.g., interstitial) and weighted scaling ++ for the central one to prioritize its size. ++ """ ++ n = centers.shape[0] ++ radii = np.zeros(n) ++ ++ # 1. Initialize radii based on distance to square borders. ++ for i in range(n): ++ x, y = centers[i] ++ radii[i] = min(x, y, 1 - x, 1 - y) ++ ++ # Heuristic: Adaptively cap the initial radius of special circles. ++ if special_radii_indices: ++ for idx in special_radii_indices: ++ if idx < n: # Ensure index is valid ++ other_centers_mask = np.ones(n, dtype=bool) ++ other_centers_mask[idx] = False ++ other_centers = centers[other_centers_mask] ++ ++ if len(other_centers) > 0: ++ distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) ++ min_dist_to_neighbor = np.min(distances_to_others) ++ radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) ++ ++ # 2. Iteratively adjust radii to resolve overlaps until convergence. ++ for _ in range(max_iterations): ++ prev_radii = np.copy(radii) ++ ++ for i in range(n): ++ for j in range(i + 1, n): ++ dist = np.linalg.norm(centers[i] - centers[j]) ++ ++ if radii[i] + radii[j] > dist: ++ overlap = radii[i] + radii[j] - dist ++ ++ # Weighted proportional scaling to protect the central circle (at index 0). ++ w_i = w_central if i == 0 else 1.0 ++ w_j = 1.0 ++ ++ weighted_r_i = radii[i] / w_i ++ weighted_r_j = radii[j] / w_j ++ total_weighted_radii = weighted_r_i + weighted_r_j ++ ++ if total_weighted_radii > 1e-12: ++ radii[i] -= overlap * (weighted_r_i / total_weighted_radii) ++ radii[j] -= overlap * (weighted_r_j / total_weighted_radii) ++ ++ radii[radii < 0] = 0 # Ensure no radii become negative ++ ++ if np.allclose(radii, prev_radii, atol=tolerance): ++ break ++ ++ return radii ++ ++ @staticmethod ++ def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): ++ """Generates centers for a square grid of circles with asymmetric bounds.""" ++ x_coords = np.linspace(sc_x, ec_x, grid_size) ++ y_coords = np.linspace(sc_y, ec_y, grid_size) ++ return np.array([[x, y] for y in y_coords for x in x_coords]) ++ ++ @staticmethod ++ def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): ++ """Generates potential interstitial points within the grid with variable density.""" ++ if grid_size < 2: ++ return np.array([]) ++ ++ num_intervals_x = (grid_size - 1) * density_factor ++ num_intervals_y = (grid_size - 1) * density_factor ++ step_x = (ec_x - sc_x) / num_intervals_x ++ step_y = (ec_y - sc_y) / num_intervals_y ++ ++ candidates = [] ++ for i in range(num_intervals_y): ++ for j in range(num_intervals_x): ++ interstitial_x = sc_x + j * step_x + step_x / 2 ++ interstitial_y = sc_y + i * step_y + step_y / 2 ++ candidates.append([interstitial_x, interstitial_y]) ++ return np.array(candidates) + + + class DynamicPackingOptimizer: + """ +- Optimizes circle packing using a force-directed approach. Starting from an +- initial configuration, it iteratively adjusts circle centers based on +- repulsion forces and boundaries, while repeatedly calculating maximum radii +- to guide the optimization towards a better packing. The central circle is +- explicitly fixed to provide a stable anchor for the packing. +- """ +- def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): ++ Encapsulates the force-directed optimization logic. It includes adaptive ++ parameters and a 'jiggle' mechanism to escape local optima. ++ """ ++ def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed +- + self.centers = np.copy(initial_centers) +- self.interstitial_indices = interstitial_indices ++ self.special_radii_indices = special_radii_indices + self.w_central = w_central +- self.central_idx = 0 # The central circle is at index 0 by convention +- +- # Initialize best configuration with max radii for the starting layout +- self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) +- self.best_sum_radii = np.sum(self.radii) ++ self.central_idx = 0 ++ ++ initial_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) ++ self.best_sum_radii = np.sum(initial_radii) + self.best_centers = np.copy(self.centers) +- self.best_radii = np.copy(self.radii) ++ self.best_radii = np.copy(initial_radii) + + def optimize(self): +- """Runs the force-directed optimization loop.""" ++ """Runs the force-directed optimization loop with adaptive parameters.""" + for step in range(self.num_steps): +- # Linearly decay the learning rate +- learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) ++ progress = step / self.num_steps ++ learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + +- # Adaptively determine iteration count for radii calculation +- radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 +- current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) +- +- # Periodically check for improvement with a full, accurate radius calculation ++ # Jiggle mechanism to escape local optima, with decaying magnitude. ++ if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: ++ jiggle_magnitude = 0.004 * (1 - progress) ++ jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude ++ if self.central_fixed: ++ jiggle_vec[self.central_idx] = 0.0 ++ self.centers += jiggle_vec ++ ++ radii_iter_count = 100 if progress < 0.9 else 500 ++ current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) ++ + if step % 50 == 0 or step == self.num_steps - 1: +- test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) ++ test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + +- # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) +- +- # 1. Repulsion between circles +- buffer_factor = 0.05 # Use a fixed buffer for stability ++ # Adaptive buffer factor: starts larger, shrinks for tight packing. ++ buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] +- + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + +- # 2. Boundary repulsion forces +- K_boundary = 12.0 # Use a strong, fixed boundary force ++ # Adaptive boundary force: increases over time for stricter enforcement. ++ K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + +- # --- Update centers --- + self.centers += learning_rate * force_vectors +- +- # Fix the central circle to its position to provide a stable anchor + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + +- # Clip centers to ensure they stay within radius distance of boundaries +- for i in range(self.n_circles): +- r = current_radii[i] +- self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) +- self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) ++ # Vectorized clipping to ensure circles stay within bounds ++ self.centers = np.clip(self.centers, current_radii.reshape(-1, 1), 1.0 - current_radii.reshape(-1, 1)) + + return self.best_centers, self.best_radii + + +-def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): +- """ +- Generates centers for a square grid of circles with asymmetric bounds. +- """ +- x_coords = np.linspace(sc_x, ec_x, grid_size) +- y_coords = np.linspace(sc_y, ec_y, grid_size) +- grid_centers = [] +- for y in y_coords: +- for x in x_coords: +- grid_centers.append([x, y]) +- return np.array(grid_centers) +- +- +-def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): +- """ +- Generates potential interstitial points with asymmetric bounds and variable density. +- """ +- if grid_size < 2: +- return np.array([]) +- num_interstitial_intervals_x = (grid_size - 1) * density_factor +- num_interstitial_intervals_y = (grid_size - 1) * density_factor +- step_x = (ec_x - sc_x) / num_interstitial_intervals_x +- step_y = (ec_y - sc_y) / num_interstitial_intervals_y +- candidates = [] +- for i in range(num_interstitial_intervals_y): +- for j in range(num_interstitial_intervals_x): +- candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) +- return np.array(candidates) ++class InitialConfigurationGenerator: ++ """ ++ Encapsulates the logic for generating and coarsely evaluating initial ++ packing configurations via a combinatorial search. This makes the main ++ pipeline cleaner and separates generation from refinement. ++ """ ++ def __init__(self, params): ++ self.params = params ++ self.central_point = np.array([0.5, 0.5]) ++ ++ def generate_candidates(self): ++ """Yields PackingCandidate objects for coarse evaluation.""" ++ p = self.params ++ num_peripheral_to_select = p['n_circles'] - 1 - p['num_interstitial_to_select'] ++ ++ for w_central in p['central_weight_options']: ++ for sc in p['sc_options']: ++ ec = 1.0 - sc # Enforce symmetry for a more focused search ++ ++ all_grid_centers = PackingUtilities.generate_grid_centers(p['grid_size'], sc, ec, sc, ec) ++ all_interstitial_points = PackingUtilities.generate_interstitial_candidates(p['grid_size'], sc, ec, sc, ec, p['interstitial_density_factor']) ++ ++ peripheral_grid_points = np.array([pt for pt in all_grid_centers if not np.allclose(pt, self.central_point)]) ++ ++ if len(peripheral_grid_points) < num_peripheral_to_select or len(all_interstitial_points) < p['num_interstitial_to_select']: ++ continue ++ ++ for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): ++ selected_peripheral = peripheral_grid_points[list(p_indices_combo)] ++ ++ for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), p['num_interstitial_to_select']): ++ selected_interstitial = all_interstitial_points[list(i_indices_combo)] ++ current_centers = np.vstack([self.central_point, selected_peripheral, selected_interstitial]) ++ ++ special_radii_indices = list(range(1 + num_peripheral_to_select, p['n_circles'])) ++ ++ coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) ++ coarse_sum_radii = np.sum(coarse_radii) ++ ++ yield PackingCandidate(coarse_sum_radii, current_centers, w_central, special_radii_indices) + + + def construct_packing(): + """ +- Constructs an arrangement of 26 circles using a two-stage process: +- 1. A broad combinatorial search finds promising initial topologies. +- 2. A force-directed dynamic optimization refines the best candidates. +- """ +- n_circles = 26 +- grid_size = 5 +- # Broader search space for grid boundaries and central weight +- sc_options = np.array([0.08, 0.1, 0.12]) +- ec_options = np.array([0.92, 0.9, 0.88]) +- central_weight_options = np.linspace(1.5, 3.0, 4) +- +- TOP_N_CANDIDATES = 25 ++ Main orchestrator for the circle packing process. It follows a two-stage ++ pipeline: coarse search followed by fine-grained optimization. ++ The structure is modular, with responsibilities delegated to specialized classes. ++ """ ++ params = { ++ 'n_circles': 26, ++ 'grid_size': 5, ++ 'sc_options': np.linspace(0.07, 0.13, 5), ++ 'central_weight_options': np.linspace(1.5, 3.0, 4), ++ 'num_interstitial_to_select': 2, ++ 'interstitial_density_factor': 1, ++ 'top_n_candidates': 25, ++ 'optimizer_steps': 3000, ++ 'optimizer_lr': 0.02, ++ } ++ + top_candidates = [] +- +- num_fixed_central = 1 +- num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 +- num_interstitial_to_select = 2 +- +- interstitial_circle_indices_to_pass = [ +- num_fixed_central + num_peripheral_to_select, +- num_fixed_central + num_peripheral_to_select + 1 +- ] +- +- # STAGE 1: Coarse Combinatorial Search +- for w_central in central_weight_options: +- for sc_x in sc_options: +- for ec_x in ec_options: +- if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue +- for sc_y in sc_options: +- for ec_y in ec_options: +- if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue +- +- all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) +- # Use denser interstitial candidates for better initial placement +- all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) +- +- central_point = np.array([0.5, 0.5]) +- peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) +- +- for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): +- selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] +- +- for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): +- selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] +- current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) +- +- coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) +- coarse_sum_radii = np.sum(coarse_radii) +- +- if len(top_candidates) < TOP_N_CANDIDATES: +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) +- elif coarse_sum_radii > top_candidates[-1][0]: +- top_candidates.pop() +- top_candidates.append((coarse_sum_radii, current_centers, w_central)) +- top_candidates.sort(key=lambda x: x[0], reverse=True) +- +- # STAGE 2: Refine Top Candidates with Dynamic Optimizer ++ config_generator = InitialConfigurationGenerator(params) ++ ++ # STAGE 1: Coarse Combinatorial Search to find promising topologies ++ for candidate in config_generator.generate_candidates(): ++ if len(top_candidates) < params['top_n_candidates']: ++ top_candidates.append(candidate) ++ top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) ++ elif candidate.sum_radii > top_candidates[-1].sum_radii: ++ top_candidates.pop() ++ top_candidates.append(candidate) ++ top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) ++ + if not top_candidates: +- return np.random.rand(n_circles, 2), np.zeros(n_circles) +- +- best_sum_radii = top_candidates[0][0] +- best_centers = top_candidates[0][1] +- best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) +- +- for _, initial_centers, w_central in top_candidates: ++ # Fallback if the search yields no valid configurations ++ return np.random.rand(params['n_circles'], 2), np.zeros(params['n_circles']) ++ ++ # Initialize overall best with the top result from the coarse search ++ best_candidate = top_candidates[0] ++ best_centers = best_candidate.centers ++ best_radii = PackingUtilities.compute_max_radii(best_centers, max_iterations=2000, special_radii_indices=best_candidate.special_radii_indices, w_central=best_candidate.w_central) ++ best_sum_radii = np.sum(best_radii) ++ ++ # STAGE 2: Refine Top Candidates with the dynamic optimizer ++ for candidate in top_candidates: + optimizer = DynamicPackingOptimizer( +- initial_centers=initial_centers, +- interstitial_indices=interstitial_circle_indices_to_pass, +- w_central=w_central, +- num_steps=3000, +- initial_learning_rate=0.02, +- central_fixed=True ++ initial_centers=candidate.centers, ++ special_radii_indices=candidate.special_radii_indices, ++ w_central=candidate.w_central, ++ num_circles=params['n_circles'], ++ num_steps=params['optimizer_steps'], ++ initial_learning_rate=params['optimizer_lr'], + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): +- """ +- Compute maximum radii using an iterative relaxation approach. Includes a +- heuristic for interstitial circles and weighted scaling for the central one. +- """ +- n = centers.shape[0] +- radii = np.zeros(n) +- +- # 1. Initialize radii based on distance to square borders. +- for i in range(n): +- x, y = centers[i] +- radii[i] = min(x, y, 1 - x, 1 - y) +- +- # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). +- if interstitial_indices: +- for idx in interstitial_indices: +- if idx < n: # Ensure index is valid +- other_centers_mask = np.ones(n, dtype=bool) +- other_centers_mask[idx] = False +- other_centers = centers[other_centers_mask] +- +- if len(other_centers) > 0: +- distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) +- min_dist_to_neighbor = np.min(distances_to_others) +- radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) +- +- # 2. Iteratively adjust radii to resolve overlaps until convergence. +- for _ in range(max_iterations): +- prev_radii = np.copy(radii) +- +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.linalg.norm(centers[i] - centers[j]) +- if radii[i] + radii[j] > dist: +- overlap = radii[i] + radii[j] - dist +- +- # Weighted scaling: Central circle (index 0) shrinks less +- w_i = w_central if i == 0 else 1.0 +- w_j = 1.0 +- +- weighted_r_i = radii[i] / w_i +- weighted_r_j = radii[j] / w_j +- total_weighted_radii = weighted_r_i + weighted_r_j +- +- if total_weighted_radii > 1e-12: +- radii[i] -= overlap * (weighted_r_i / total_weighted_radii) +- radii[j] -= overlap * (weighted_r_j / total_weighted_radii) +- elif (radii[i] + radii[j]) > 1e-12: +- scale_factor = dist / (radii[i] + radii[j]) +- radii[i] *= scale_factor +- radii[j] *= scale_factor +- +- # Ensure no radii become negative +- radii[radii < 0] = 0 +- +- if np.allclose(radii, prev_radii, atol=tolerance): +- break +- +- return np.maximum(radii, 0) + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/main.py new file mode 100644 index 0000000000000000000000000000000000000000..5d23f5b383628e0609d50eb3e6fee3837be66e13 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/main.py @@ -0,0 +1,290 @@ +# EVOLVE-BLOCK-START +import numpy as np +import itertools +from collections import namedtuple + +# Define a data structure for a packing configuration candidate +# This improves readability and maintainability over using raw tuples. +PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) + +class PackingUtilities: + """ + A utility class to encapsulate static, stateless helper functions for circle packing. + This separates core geometric calculations from the main optimization and generation logic. + """ + @staticmethod + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): + """ + Computes maximum radii using an iterative relaxation approach. Includes a + heuristic for special circles (e.g., interstitial) and weighted scaling + for the central one to prioritize its size. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of special circles. + if special_radii_indices: + for idx in special_radii_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + + radii[radii < 0] = 0 # Ensure no radii become negative + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + @staticmethod + def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + @staticmethod + def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points within the grid with variable density.""" + if grid_size < 2: + return np.array([]) + + num_intervals_x = (grid_size - 1) * density_factor + num_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_intervals_x + step_y = (ec_y - sc_y) / num_intervals_y + + candidates = [] + for i in range(num_intervals_y): + for j in range(num_intervals_x): + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +class DynamicPackingOptimizer: + """ + Encapsulates the force-directed optimization logic. It includes adaptive + parameters and a 'jiggle' mechanism to escape local optima. + """ + def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.centers = np.copy(initial_centers) + self.special_radii_indices = special_radii_indices + self.w_central = w_central + self.central_idx = 0 + + initial_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(initial_radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(initial_radii) + + def optimize(self): + """Runs the force-directed optimization loop with adaptive parameters.""" + for step in range(self.num_steps): + progress = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + + # Jiggle mechanism to escape local optima, with decaying magnitude. + if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - progress) + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 + self.centers += jiggle_vec + + radii_iter_count = 100 if progress < 0.9 else 500 + current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + # Adaptive buffer factor: starts larger, shrinks for tight packing. + buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Adaptive boundary force: increases over time for stricter enforcement. + K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Vectorized clipping to ensure circles stay within bounds + self.centers = np.clip(self.centers, current_radii.reshape(-1, 1), 1.0 - current_radii.reshape(-1, 1)) + + return self.best_centers, self.best_radii + + +class InitialConfigurationGenerator: + """ + Encapsulates the logic for generating and coarsely evaluating initial + packing configurations via a combinatorial search. This makes the main + pipeline cleaner and separates generation from refinement. + """ + def __init__(self, params): + self.params = params + self.central_point = np.array([0.5, 0.5]) + + def generate_candidates(self): + """Yields PackingCandidate objects for coarse evaluation.""" + p = self.params + num_peripheral_to_select = p['n_circles'] - 1 - p['num_interstitial_to_select'] + + for w_central in p['central_weight_options']: + for sc in p['sc_options']: + ec = 1.0 - sc # Enforce symmetry for a more focused search + + all_grid_centers = PackingUtilities.generate_grid_centers(p['grid_size'], sc, ec, sc, ec) + all_interstitial_points = PackingUtilities.generate_interstitial_candidates(p['grid_size'], sc, ec, sc, ec, p['interstitial_density_factor']) + + peripheral_grid_points = np.array([pt for pt in all_grid_centers if not np.allclose(pt, self.central_point)]) + + if len(peripheral_grid_points) < num_peripheral_to_select or len(all_interstitial_points) < p['num_interstitial_to_select']: + continue + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), p['num_interstitial_to_select']): + selected_interstitial = all_interstitial_points[list(i_indices_combo)] + current_centers = np.vstack([self.central_point, selected_peripheral, selected_interstitial]) + + special_radii_indices = list(range(1 + num_peripheral_to_select, p['n_circles'])) + + coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + yield PackingCandidate(coarse_sum_radii, current_centers, w_central, special_radii_indices) + + +def construct_packing(): + """ + Main orchestrator for the circle packing process. It follows a two-stage + pipeline: coarse search followed by fine-grained optimization. + The structure is modular, with responsibilities delegated to specialized classes. + """ + params = { + 'n_circles': 26, + 'grid_size': 5, + 'sc_options': np.linspace(0.07, 0.13, 5), + 'central_weight_options': np.linspace(1.5, 3.0, 4), + 'num_interstitial_to_select': 2, + 'interstitial_density_factor': 1, + 'top_n_candidates': 25, + 'optimizer_steps': 3000, + 'optimizer_lr': 0.02, + } + + top_candidates = [] + config_generator = InitialConfigurationGenerator(params) + + # STAGE 1: Coarse Combinatorial Search to find promising topologies + for candidate in config_generator.generate_candidates(): + if len(top_candidates) < params['top_n_candidates']: + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + elif candidate.sum_radii > top_candidates[-1].sum_radii: + top_candidates.pop() + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + + if not top_candidates: + # Fallback if the search yields no valid configurations + return np.random.rand(params['n_circles'], 2), np.zeros(params['n_circles']) + + # Initialize overall best with the top result from the coarse search + best_candidate = top_candidates[0] + best_centers = best_candidate.centers + best_radii = PackingUtilities.compute_max_radii(best_centers, max_iterations=2000, special_radii_indices=best_candidate.special_radii_indices, w_central=best_candidate.w_central) + best_sum_radii = np.sum(best_radii) + + # STAGE 2: Refine Top Candidates with the dynamic optimizer + for candidate in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=candidate.centers, + special_radii_indices=candidate.special_radii_indices, + w_central=candidate.w_central, + num_circles=params['n_circles'], + num_steps=params['optimizer_steps'], + initial_learning_rate=params['optimizer_lr'], + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/original.py new file mode 100644 index 0000000000000000000000000000000000000000..f03bd6f0ef890f52e7c6339b89101adcc716dfc9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/original.py @@ -0,0 +1,283 @@ +# EVOLVE-BLOCK-START +""" +Hybrid circle packing for n=26 circles, combining a systematic search for +initial configurations with a force-directed dynamic optimizer for refinement. +""" + +import numpy as np +import itertools + + +class DynamicPackingOptimizer: + """ + Optimizes circle packing using a force-directed approach. Starting from an + initial configuration, it iteratively adjusts circle centers based on + repulsion forces and boundaries, while repeatedly calculating maximum radii + to guide the optimization towards a better packing. The central circle is + explicitly fixed to provide a stable anchor for the packing. + """ + def __init__(self, initial_centers, interstitial_indices, w_central, num_circles=26, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + + self.centers = np.copy(initial_centers) + self.interstitial_indices = interstitial_indices + self.w_central = w_central + self.central_idx = 0 # The central circle is at index 0 by convention + + # Initialize best configuration with max radii for the starting layout + self.radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(self.radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(self.radii) + + def optimize(self): + """Runs the force-directed optimization loop.""" + for step in range(self.num_steps): + # Linearly decay the learning rate + learning_rate = self.initial_learning_rate * (1 - step / self.num_steps) + learning_rate = max(learning_rate, 1e-7) + + # Adaptively determine iteration count for radii calculation + radii_iter_count = 100 if step < self.num_steps * 0.9 else 500 + current_radii = compute_max_radii(self.centers, max_iterations=radii_iter_count, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + + # Periodically check for improvement with a full, accurate radius calculation + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = compute_max_radii(self.centers, max_iterations=2000, interstitial_indices=self.interstitial_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + # --- Calculate force vectors for center movement --- + force_vectors = np.zeros_like(self.centers) + + # 1. Repulsion between circles + buffer_factor = 0.05 # Use a fixed buffer for stability + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # 2. Boundary repulsion forces + K_boundary = 12.0 # Use a strong, fixed boundary force + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + # --- Update centers --- + self.centers += learning_rate * force_vectors + + # Fix the central circle to its position to provide a stable anchor + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Clip centers to ensure they stay within radius distance of boundaries + for i in range(self.n_circles): + r = current_radii[i] + self.centers[i, 0] = np.clip(self.centers[i, 0], r, 1.0 - r) + self.centers[i, 1] = np.clip(self.centers[i, 1], r, 1.0 - r) + + return self.best_centers, self.best_radii + + +def _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """ + Generates centers for a square grid of circles with asymmetric bounds. + """ + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """ + Generates potential interstitial points with asymmetric bounds and variable density. + """ + if grid_size < 2: + return np.array([]) + num_interstitial_intervals_x = (grid_size - 1) * density_factor + num_interstitial_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_interstitial_intervals_x + step_y = (ec_y - sc_y) / num_interstitial_intervals_y + candidates = [] + for i in range(num_interstitial_intervals_y): + for j in range(num_interstitial_intervals_x): + candidates.append([sc_x + j * step_x + step_x / 2, sc_y + i * step_y + step_y / 2]) + return np.array(candidates) + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using a two-stage process: + 1. A broad combinatorial search finds promising initial topologies. + 2. A force-directed dynamic optimization refines the best candidates. + """ + n_circles = 26 + grid_size = 5 + # Broader search space for grid boundaries and central weight + sc_options = np.array([0.08, 0.1, 0.12]) + ec_options = np.array([0.92, 0.9, 0.88]) + central_weight_options = np.linspace(1.5, 3.0, 4) + + TOP_N_CANDIDATES = 25 + top_candidates = [] + + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 23 + num_interstitial_to_select = 2 + + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + # STAGE 1: Coarse Combinatorial Search + for w_central in central_weight_options: + for sc_x in sc_options: + for ec_x in ec_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): continue + for sc_y in sc_options: + for ec_y in ec_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): continue + + all_grid_centers = _generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y) + # Use denser interstitial candidates for better initial placement + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=2) + + central_point = np.array([0.5, 0.5]) + peripheral_grid_points = np.array([p for p in all_grid_centers if not np.allclose(p, central_point)]) + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + current_centers = np.array([central_point] + list(selected_peripheral_points) + list(selected_interstitial_points)) + + coarse_radii = compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + if len(top_candidates) < TOP_N_CANDIDATES: + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + elif coarse_sum_radii > top_candidates[-1][0]: + top_candidates.pop() + top_candidates.append((coarse_sum_radii, current_centers, w_central)) + top_candidates.sort(key=lambda x: x[0], reverse=True) + + # STAGE 2: Refine Top Candidates with Dynamic Optimizer + if not top_candidates: + return np.random.rand(n_circles, 2), np.zeros(n_circles) + + best_sum_radii = top_candidates[0][0] + best_centers = top_candidates[0][1] + best_radii = compute_max_radii(best_centers, max_iterations=2000, interstitial_indices=interstitial_circle_indices_to_pass, w_central=top_candidates[0][2]) + + for _, initial_centers, w_central in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=initial_centers, + interstitial_indices=interstitial_circle_indices_to_pass, + w_central=w_central, + num_steps=3000, + initial_learning_rate=0.02, + central_fixed=True + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: Central circle (index 0) shrinks less + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5b654f34024b6961be4684d6de41377b0ca0b6a4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8940577414909647, + "spatial_uniformity_details": { + "cell_size_mean": 0.20377571264784874, + "cell_size_std": 0.024146605226125346, + "coefficient_of_variation": 0.11849599146959121 + }, + "edge_utilization": 0.8, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 13, + "corner_score": 1.0, + "edge_score": 0.5 + }, + "density_variance": 0.5572671518247855, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0006620607782343729, + "mean_density": 0.03238699212568107, + "cv": 0.7944714608163688 + }, + "packing_efficiency": 0.735458776244092, + "packing_efficiency_details": { + "total_area": 0.735458776244092, + "square_area": 1.0, + "efficiency": 0.735458776244092, + "relative_to_estimated_best": 0.8755461621953476 + }, + "radius_distribution": 0.9476787438018165, + "radius_distribution_details": { + "mean": 0.08947562801035236, + "std": 0.03159278834158822, + "min": 0.0010498426172741453, + "max": 0.1708508768114969, + "range": 0.16980103419422277, + "small_count": 9, + "medium_count": 12, + "large_count": 5, + "diversity_score": 0.9476787438018165 + }, + "gap_analysis": 0.744, + "gap_analysis_details": { + "covered_samples": 1860, + "total_samples": 2500, + "coverage": 0.744, + "gap_ratio": 0.256 + }, + "geometric_quality": 0.6749627348833056, + "geometric_quality_details": { + "num_triangles": 41, + "avg_triangle_quality": 0.6749627348833056, + "min_quality": 0.33509764430481453, + "max_quality": 0.9381799406992899 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..9ed1c92cac661d97dcb483f5a9828ccc1f6b6b80 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 400.04 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.3264 + + Auxiliary Metrics: + • spatial_uniformity: 0.894 + • edge_utilization: 0.800 + • density_variance: 0.557 + • packing_efficiency: 0.735 + • radius_distribution: 0.948 + • gap_analysis: 0.744 + • geometric_quality: 0.675 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.3264 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.894 + • Boundary and corner utilization: 0.800 + • Area utilization efficiency: 0.735 + • Area coverage (1 - gap ratio): 0.744 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.557 + • Radius size diversity: 0.948 + • Delaunay triangulation quality: 0.675 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Overall packing quality is good! Continue optimizing primary score. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..599d458ab60b1358a5a912b288d4728b85fb248c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.3263663282691613, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0992, 0.0970)\n centers[2] = (0.2964, 0.0998)\n centers[3] = (0.4313, 0.0862)\n centers[4] = (0.7673, 0.0523)\n centers[5] = (0.9097, 0.0903)\n centers[6] = (0.0979, 0.2979)\n centers[7] = (0.2925, 0.2753)\n centers[8] = (0.6111, 0.1102)\n centers[9] = (0.9270, 0.2606)\n centers[10] = (0.0705, 0.4754)\n centers[11] = (0.2433, 0.4719)\n centers[12] = (0.7198, 0.3469)\n centers[13] = (0.9020, 0.5218)\n centers[14] = (0.0011, 0.6884)\n centers[15] = (0.1266, 0.6749)\n centers[16] = (0.3760, 0.6677)\n centers[17] = (0.6699, 0.6658)\n centers[18] = (0.9181, 0.7139)\n centers[19] = (0.0967, 0.9033)\n centers[20] = (0.3036, 0.8970)\n centers[21] = (0.5161, 0.8985)\n centers[22] = (0.7126, 0.9165)\n centers[23] = (0.9028, 0.9028)\n centers[24] = (0.3992, 0.4060)\n centers[25] = (0.4985, 0.3009)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8940577414909647, + "aux_edge_utilization": 0.8, + "aux_density_variance": 0.5572671518247855, + "aux_packing_efficiency": 0.735458776244092, + "aux_radius_distribution": 0.9476787438018165, + "aux_gap_analysis": 0.744, + "aux_geometric_quality": 0.6749627348833056 + }, + "private": { + "reported_sum_of_radii": 2.3263663282691613 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.3264\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.894\n \u2022 Boundary and corner utilization: 0.800\n \u2022 Area utilization efficiency: 0.735\n \u2022 Area coverage (1 - gap ratio): 0.744\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.557\n \u2022 Radius size diversity: 0.948\n \u2022 Delaunay triangulation quality: 0.675\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Overall packing quality is good! Continue optimizing primary score.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/results/packing_viz.png", + "execution_time_mean": 400.0440020910464, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..987a35e2b7d84d18b351f100c47e3ebc04dfb792 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_196/rewrite.txt @@ -0,0 +1,281 @@ +# EVOLVE-BLOCK-START +import numpy as np +import itertools +from collections import namedtuple + +# Define a data structure for a packing configuration candidate +# This improves readability and maintainability over using raw tuples. +PackingCandidate = namedtuple('PackingCandidate', ['sum_radii', 'centers', 'w_central', 'special_radii_indices']) + +class PackingUtilities: + """ + A utility class to encapsulate static, stateless helper functions for circle packing. + This separates core geometric calculations from the main optimization and generation logic. + """ + @staticmethod + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, special_radii_indices=None, w_central=1.5): + """ + Computes maximum radii using an iterative relaxation approach. Includes a + heuristic for special circles (e.g., interstitial) and weighted scaling + for the central one to prioritize its size. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of special circles. + if special_radii_indices: + for idx in special_radii_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + + radii[radii < 0] = 0 # Ensure no radii become negative + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + @staticmethod + def generate_grid_centers(grid_size, sc_x, ec_x, sc_y, ec_y): + """Generates centers for a square grid of circles with asymmetric bounds.""" + x_coords = np.linspace(sc_x, ec_x, grid_size) + y_coords = np.linspace(sc_y, ec_y, grid_size) + return np.array([[x, y] for y in y_coords for x in x_coords]) + + @staticmethod + def generate_interstitial_candidates(grid_size, sc_x, ec_x, sc_y, ec_y, density_factor=1): + """Generates potential interstitial points within the grid with variable density.""" + if grid_size < 2: + return np.array([]) + + num_intervals_x = (grid_size - 1) * density_factor + num_intervals_y = (grid_size - 1) * density_factor + step_x = (ec_x - sc_x) / num_intervals_x + step_y = (ec_y - sc_y) / num_intervals_y + + candidates = [] + for i in range(num_intervals_y): + for j in range(num_intervals_x): + interstitial_x = sc_x + j * step_x + step_x / 2 + interstitial_y = sc_y + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +class DynamicPackingOptimizer: + """ + Encapsulates the force-directed optimization logic. It includes adaptive + parameters and a 'jiggle' mechanism to escape local optima. + """ + def __init__(self, initial_centers, special_radii_indices, w_central, num_circles, num_steps=3000, initial_learning_rate=0.02, central_fixed=True): + self.n_circles = num_circles + self.num_steps = num_steps + self.initial_learning_rate = initial_learning_rate + self.central_fixed = central_fixed + self.centers = np.copy(initial_centers) + self.special_radii_indices = special_radii_indices + self.w_central = w_central + self.central_idx = 0 + + initial_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + self.best_sum_radii = np.sum(initial_radii) + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(initial_radii) + + def optimize(self): + """Runs the force-directed optimization loop with adaptive parameters.""" + for step in range(self.num_steps): + progress = step / self.num_steps + learning_rate = self.initial_learning_rate * (1 - progress) + learning_rate = max(learning_rate, 1e-7) + + # Jiggle mechanism to escape local optima, with decaying magnitude. + if step > 0 and step % 100 == 0 and step < self.num_steps * 0.8: + jiggle_magnitude = 0.004 * (1 - progress) + jiggle_vec = (np.random.rand(self.n_circles, 2) - 0.5) * jiggle_magnitude + if self.central_fixed: + jiggle_vec[self.central_idx] = 0.0 + self.centers += jiggle_vec + + radii_iter_count = 100 if progress < 0.9 else 500 + current_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=radii_iter_count, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + + if step % 50 == 0 or step == self.num_steps - 1: + test_radii = PackingUtilities.compute_max_radii(self.centers, max_iterations=2000, special_radii_indices=self.special_radii_indices, w_central=self.w_central) + current_sum_radii = np.sum(test_radii) + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = np.copy(self.centers) + self.best_radii = np.copy(test_radii) + + force_vectors = np.zeros_like(self.centers) + # Adaptive buffer factor: starts larger, shrinks for tight packing. + buffer_factor = 0.08 * (1 - progress) + 0.02 * progress + for i in range(self.n_circles): + for j in range(i + 1, self.n_circles): + dist_ij = np.linalg.norm(self.centers[i] - self.centers[j]) + target_dist = current_radii[i] + current_radii[j] + if dist_ij < target_dist * (1 + buffer_factor) and dist_ij > 1e-9: + overlap_factor = (target_dist * (1 + buffer_factor) - dist_ij) / (target_dist * (1 + buffer_factor)) + direction = (self.centers[i] - self.centers[j]) / dist_ij + force_vectors[i] += direction * overlap_factor + force_vectors[j] -= direction * overlap_factor + + # Adaptive boundary force: increases over time for stricter enforcement. + K_boundary = 10.0 + 5.0 * progress + for i in range(self.n_circles): + x, y = self.centers[i] + r = current_radii[i] + if x - r < 0: force_vectors[i, 0] += K_boundary * (r - x) + if x + r > 1: force_vectors[i, 0] -= K_boundary * (x + r - 1) + if y - r < 0: force_vectors[i, 1] += K_boundary * (r - y) + if y + r > 1: force_vectors[i, 1] -= K_boundary * (y + r - 1) + + self.centers += learning_rate * force_vectors + if self.central_fixed: + self.centers[self.central_idx] = np.array([0.5, 0.5]) + + # Vectorized clipping to ensure circles stay within bounds + self.centers = np.clip(self.centers, current_radii.reshape(-1, 1), 1.0 - current_radii.reshape(-1, 1)) + + return self.best_centers, self.best_radii + + +class InitialConfigurationGenerator: + """ + Encapsulates the logic for generating and coarsely evaluating initial + packing configurations via a combinatorial search. This makes the main + pipeline cleaner and separates generation from refinement. + """ + def __init__(self, params): + self.params = params + self.central_point = np.array([0.5, 0.5]) + + def generate_candidates(self): + """Yields PackingCandidate objects for coarse evaluation.""" + p = self.params + num_peripheral_to_select = p['n_circles'] - 1 - p['num_interstitial_to_select'] + + for w_central in p['central_weight_options']: + for sc in p['sc_options']: + ec = 1.0 - sc # Enforce symmetry for a more focused search + + all_grid_centers = PackingUtilities.generate_grid_centers(p['grid_size'], sc, ec, sc, ec) + all_interstitial_points = PackingUtilities.generate_interstitial_candidates(p['grid_size'], sc, ec, sc, ec, p['interstitial_density_factor']) + + peripheral_grid_points = np.array([pt for pt in all_grid_centers if not np.allclose(pt, self.central_point)]) + + if len(peripheral_grid_points) < num_peripheral_to_select or len(all_interstitial_points) < p['num_interstitial_to_select']: + continue + + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral = peripheral_grid_points[list(p_indices_combo)] + + for i_indices_combo in itertools.combinations(range(len(all_interstitial_points)), p['num_interstitial_to_select']): + selected_interstitial = all_interstitial_points[list(i_indices_combo)] + current_centers = np.vstack([self.central_point, selected_peripheral, selected_interstitial]) + + special_radii_indices = list(range(1 + num_peripheral_to_select, p['n_circles'])) + + coarse_radii = PackingUtilities.compute_max_radii(current_centers, max_iterations=150, tolerance=1e-6, special_radii_indices=special_radii_indices, w_central=w_central) + coarse_sum_radii = np.sum(coarse_radii) + + yield PackingCandidate(coarse_sum_radii, current_centers, w_central, special_radii_indices) + + +def construct_packing(): + """ + Main orchestrator for the circle packing process. It follows a two-stage + pipeline: coarse search followed by fine-grained optimization. + The structure is modular, with responsibilities delegated to specialized classes. + """ + params = { + 'n_circles': 26, + 'grid_size': 5, + 'sc_options': np.linspace(0.07, 0.13, 5), + 'central_weight_options': np.linspace(1.5, 3.0, 4), + 'num_interstitial_to_select': 2, + 'interstitial_density_factor': 1, + 'top_n_candidates': 25, + 'optimizer_steps': 3000, + 'optimizer_lr': 0.02, + } + + top_candidates = [] + config_generator = InitialConfigurationGenerator(params) + + # STAGE 1: Coarse Combinatorial Search to find promising topologies + for candidate in config_generator.generate_candidates(): + if len(top_candidates) < params['top_n_candidates']: + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + elif candidate.sum_radii > top_candidates[-1].sum_radii: + top_candidates.pop() + top_candidates.append(candidate) + top_candidates.sort(key=lambda x: x.sum_radii, reverse=True) + + if not top_candidates: + # Fallback if the search yields no valid configurations + return np.random.rand(params['n_circles'], 2), np.zeros(params['n_circles']) + + # Initialize overall best with the top result from the coarse search + best_candidate = top_candidates[0] + best_centers = best_candidate.centers + best_radii = PackingUtilities.compute_max_radii(best_centers, max_iterations=2000, special_radii_indices=best_candidate.special_radii_indices, w_central=best_candidate.w_central) + best_sum_radii = np.sum(best_radii) + + # STAGE 2: Refine Top Candidates with the dynamic optimizer + for candidate in top_candidates: + optimizer = DynamicPackingOptimizer( + initial_centers=candidate.centers, + special_radii_indices=candidate.special_radii_indices, + w_central=candidate.w_central, + num_circles=params['n_circles'], + num_steps=params['optimizer_steps'], + initial_learning_rate=params['optimizer_lr'], + ) + optimized_centers, optimized_radii = optimizer.optimize() + current_sum_radii = np.sum(optimized_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = optimized_centers + best_radii = optimized_radii + + return best_centers, best_radii +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9c121bc7ea87ef0ea2ccff15fdf5d160d80ec8ac Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..53bfd958baf96088bd59d2737b3ab0e2760dd7a9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/results/job_log.err @@ -0,0 +1,11 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] +Traceback (most recent call last): + File "/home/tengxiao/pj/ShinkaEvolve/examples/circle_packing/evaluate_with_auxiliary.py", line 290, in diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..2bdcd5f0f3921a51c40d5526fe95898ac0c80077 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/results/job_log.out @@ -0,0 +1,15 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_197/results +Auxiliary Metrics: ENABLED +====================================================================== + diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3a785c0eccd7d64abd1e352a3c13a9f5393fe6d1 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..44d306cb5410efda4b4690d6fd97e122e27df770 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9297033890465274, + "spatial_uniformity_details": { + "cell_size_mean": 0.18832913599185583, + "cell_size_std": 0.014239918053753785, + "coefficient_of_variation": 0.07561186909898908 + }, + "edge_utilization": 0.15384615384615385, + "edge_utilization_details": { + "corners_touched": 0, + "edges_touched": 10, + "corner_score": 0.0, + "edge_score": 0.38461538461538464 + }, + "density_variance": 0.4272997234166122, + "density_variance_details": { + "grid_size": 10, + "variance": 8.277189535757555e-05, + "mean_density": 0.006788074574701184, + "cv": 1.3402776674044596 + }, + "packing_efficiency": 0.38707511510762277, + "packing_efficiency_details": { + "total_area": 0.38707511510762277, + "square_area": 1.0, + "efficiency": 0.38707511510762277, + "relative_to_estimated_best": 0.4608037084614557 + }, + "radius_distribution": 0.9986351900937254, + "radius_distribution_details": { + "mean": 0.06679970749578815, + "std": 0.016632465790285943, + "min": 0.016189092250368, + "max": 0.09190779064291757, + "range": 0.07571869839254958, + "small_count": 8, + "medium_count": 9, + "large_count": 9, + "diversity_score": 0.9986351900937254 + }, + "gap_analysis": 0.3924, + "gap_analysis_details": { + "covered_samples": 981, + "total_samples": 2500, + "coverage": 0.3924, + "gap_ratio": 0.6075999999999999 + }, + "geometric_quality": 0.7253348847946604, + "geometric_quality_details": { + "num_triangles": 33, + "avg_triangle_quality": 0.7253348847946604, + "min_quality": 0.6091603136894099, + "max_quality": 0.7899102830845551 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..2cac682ee7e63f7bf4cd3c5aa59bce848f560465 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.7368 + + Auxiliary Metrics: + • spatial_uniformity: 0.930 + • edge_utilization: 0.154 + • density_variance: 0.427 + • packing_efficiency: 0.387 + • radius_distribution: 0.999 + • gap_analysis: 0.392 + • geometric_quality: 0.725 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.7368 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.930 + • Delaunay triangulation quality: 0.725 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.154 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.427 + → Balance circle density across different regions + • Area utilization efficiency: 0.387 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.392 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.999 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 0/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 60.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..7a43db1083f49763401d375bbc8ea03e036dc6d9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.7367923948904918, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.7500, 0.5000)\n centers[2] = (0.6768, 0.6768)\n centers[3] = (0.5000, 0.7500)\n centers[4] = (0.3232, 0.6768)\n centers[5] = (0.2500, 0.5000)\n centers[6] = (0.3232, 0.3232)\n centers[7] = (0.5000, 0.2500)\n centers[8] = (0.6768, 0.3232)\n centers[9] = (0.9500, 0.5000)\n centers[10] = (0.9196, 0.6626)\n centers[11] = (0.8326, 0.8032)\n centers[12] = (0.7006, 0.9028)\n centers[13] = (0.5415, 0.9481)\n centers[14] = (0.3769, 0.9328)\n centers[15] = (0.2288, 0.8591)\n centers[16] = (0.1174, 0.7369)\n centers[17] = (0.0577, 0.5827)\n centers[18] = (0.0577, 0.4173)\n centers[19] = (0.1174, 0.2631)\n centers[20] = (0.2288, 0.1409)\n centers[21] = (0.3769, 0.0672)\n centers[22] = (0.5415, 0.0519)\n centers[23] = (0.7006, 0.0972)\n centers[24] = (0.8326, 0.1968)\n centers[25] = (0.9196, 0.3374)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9297033890465274, + "aux_edge_utilization": 0.15384615384615385, + "aux_density_variance": 0.4272997234166122, + "aux_packing_efficiency": 0.38707511510762277, + "aux_radius_distribution": 0.9986351900937254, + "aux_gap_analysis": 0.3924, + "aux_geometric_quality": 0.7253348847946604 + }, + "private": { + "reported_sum_of_radii": 1.7367923948904918 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.7368\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.930\n \u2022 Delaunay triangulation quality: 0.725\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.154\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.427\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.387\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.392\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.999\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 0/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 60.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_2/results/packing_viz.png", + "execution_time_mean": 0.001954099629074335, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cb0c2fc6b2a35b5c5bcd8eb8570446f621221fb3 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..7a4f7d0cc5ac768294189037daaf4815ae25144e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/edit.diff @@ -0,0 +1,119 @@ +--- a/original.py ++++ b/original.py +@@ -1,103 +1,109 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + +- # Place 25 circles in a 5x5 grid ++ # This strategy improves central packing density by replacing the single ++ # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 +- # Centers at 0.1, 0.3, ..., 0.9. This spacing allows for 0.1 radius at boundaries. + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + ++ # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) ++ # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): ++ if i == 2 and j == 2: # Corresponds to (0.5, 0.5) ++ continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + +- # Place the 26th circle in an interstitial position in the bottom-left quadrant. +- # This point (0.2, 0.2) is equidistant from its four nearest grid neighbors: +- # (0.1, 0.1), (0.3, 0.1), (0.1, 0.3), (0.3, 0.3). +- # Its placement is critical for filling gaps in the grid. +- centers[k] = [0.2, 0.2] # k is now 25, so centers[25] ++ # 2. Add two circles to fill the newly created central void. ++ # Placing them at (0.5, 0.45) and (0.5, 0.55) maintains symmetry ++ # and provides a better packing arrangement for the neighbors. ++ centers[k] = [0.5, 0.45] ++ k += 1 ++ centers[k] = [0.5, 0.55] ++ # k is now 25, having placed the 26th circle at index 25. + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/main.py new file mode 100644 index 0000000000000000000000000000000000000000..8f9a8581bedb69bf0e0e13ea44e5d5923d88ea77 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/main.py @@ -0,0 +1,109 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Add two circles to fill the newly created central void. + # Placing them at (0.5, 0.45) and (0.5, 0.55) maintains symmetry + # and provides a better packing arrangement for the neighbors. + centers[k] = [0.5, 0.45] + k += 1 + centers[k] = [0.5, 0.55] + # k is now 25, having placed the 26th circle at index 25. + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/original.py new file mode 100644 index 0000000000000000000000000000000000000000..582a478512df470378922a92525693bf135c14f8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/original.py @@ -0,0 +1,103 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Place 25 circles in a 5x5 grid + grid_size = 5 + # Centers at 0.1, 0.3, ..., 0.9. This spacing allows for 0.1 radius at boundaries. + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + for i in range(grid_size): + for j in range(grid_size): + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # Place the 26th circle in an interstitial position in the bottom-left quadrant. + # This point (0.2, 0.2) is equidistant from its four nearest grid neighbors: + # (0.1, 0.1), (0.3, 0.1), (0.1, 0.3), (0.3, 0.3). + # Its placement is critical for filling gaps in the grid. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..823434662c907b79f1a9700c753ca9614446ed94 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9182195964918392, + "spatial_uniformity_details": { + "cell_size_mean": 0.19927796682641336, + "cell_size_std": 0.017748513189432033, + "coefficient_of_variation": 0.08906410168178938 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.501615329681591, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00020119103199206512, + "mean_density": 0.01427612702619934, + "cv": 0.9935594883728283 + }, + "packing_efficiency": 0.4550478435988809, + "packing_efficiency_details": { + "total_area": 0.4550478435988809, + "square_area": 1.0, + "efficiency": 0.4550478435988809, + "relative_to_estimated_best": 0.5417236233320011 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.0702443847615189, + "std": 0.025233611551709854, + "min": 0.02673411558743709, + "max": 0.10229083801541207, + "range": 0.07555672242797498, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.458, + "gap_analysis_details": { + "covered_samples": 1145, + "total_samples": 2500, + "coverage": 0.458, + "gap_ratio": 0.542 + }, + "geometric_quality": 0.6923736837830137, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.6923736837830137, + "min_quality": 0.48507125007266594, + "max_quality": 0.8000000000000004 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3448afc49fdf877a51a4566b72af153c318ac0fe --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8264 + + Auxiliary Metrics: + • spatial_uniformity: 0.918 + • edge_utilization: 0.558 + • density_variance: 0.502 + • packing_efficiency: 0.455 + • radius_distribution: 0.974 + • gap_analysis: 0.458 + • geometric_quality: 0.692 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8264 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.918 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.455 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.458 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.502 + • Radius size diversity: 0.974 + • Delaunay triangulation quality: 0.692 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 54.2% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..6efdc28fb9d17b751cf31527b938f6b9f6d9dad6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8263540037994912, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.4500)\n centers[25] = (0.5000, 0.5500)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9182195964918392, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.501615329681591, + "aux_packing_efficiency": 0.4550478435988809, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.458, + "aux_geometric_quality": 0.6923736837830137 + }, + "private": { + "reported_sum_of_radii": 1.8263540037994912 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8264\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.918\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.455\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.458\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.502\n \u2022 Radius size diversity: 0.974\n \u2022 Delaunay triangulation quality: 0.692\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 54.2% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/results/packing_viz.png", + "execution_time_mean": 0.004047560039907694, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..ec869ad3b6e10ca1af277eb8bb1b055ec970e954 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_20/search_replace.txt @@ -0,0 +1,57 @@ + +replace_center_with_two + + + +The current 5x5 grid with an extra circle at (0.2, 0.2) results in very poor packing efficiency in the center of the square, as seen in the visualization where central circles are tiny. The core of the problem is that the circle at (0.5, 0.5) is constrained by 8 close neighbors. + +To address this, I am proposing a structural change that is motivated by creating more space in this dense central region. The strategy is: +1. Remove the single most constrained circle from the 5x5 grid: the one at the center, `(0.5, 0.5)`. This leaves 24 grid circles. +2. Use the two remaining circles (to bring the total to 26) to fill the newly created central void. I will place them symmetrically at `(0.5, 0.45)` and `(0.5, 0.55)`. + +This replacement of one circle with two smaller, slightly separated ones should allow for a more efficient local packing arrangement for the 8 surrounding grid circles, hopefully increasing their radii more than the loss incurred by replacing the single central circle. This maintains D2 symmetry in the center of the packing and is a direct attempt to improve the `packing_efficiency` and reduce the `gap_analysis` wasted space metric. + + + +<<<<<<< SEARCH + # Place 25 circles in a 5x5 grid + grid_size = 5 + # Centers at 0.1, 0.3, ..., 0.9. This spacing allows for 0.1 radius at boundaries. + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + for i in range(grid_size): + for j in range(grid_size): + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # Place the 26th circle in an interstitial position in the bottom-left quadrant. + # This point (0.2, 0.2) is equidistant from its four nearest grid neighbors: + # (0.1, 0.1), (0.3, 0.1), (0.1, 0.3), (0.3, 0.3). + # Its placement is critical for filling gaps in the grid. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] +======= + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Add two circles to fill the newly created central void. + # Placing them at (0.5, 0.45) and (0.5, 0.55) maintains symmetry + # and provides a better packing arrangement for the neighbors. + centers[k] = [0.5, 0.45] + k += 1 + centers[k] = [0.5, 0.55] + # k is now 25, having placed the 26th circle at index 25. +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..165129a4994d6fec65870fc4b03272b74853524f Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..e84d429b774df3eca2ce8498b4d4106da8cbf807 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576736 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5066449119960582, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00021368445209140032, + "mean_density": 0.015011721785826064, + "cv": 0.9737689579477712 + }, + "packing_efficiency": 0.49072180720295644, + "packing_efficiency_details": { + "total_area": 0.49072180720295644, + "square_area": 1.0, + "efficiency": 0.49072180720295644, + "relative_to_estimated_best": 0.5841926276225672 + }, + "radius_distribution": 0.8828951237442825, + "radius_distribution_details": { + "mean": 0.07393827395853675, + "std": 0.023256947137045646, + "min": 0.03946019296101107, + "max": 0.10261558125579377, + "range": 0.0631553882947827, + "small_count": 11, + "medium_count": 3, + "large_count": 12, + "diversity_score": 0.8828951237442825 + }, + "gap_analysis": 0.4896, + "gap_analysis_details": { + "covered_samples": 1224, + "total_samples": 2500, + "coverage": 0.4896, + "gap_ratio": 0.5104 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..7efe653b9bcf399175f16805049356fefaf95a2b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9224 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.507 + • packing_efficiency: 0.491 + • radius_distribution: 0.883 + • gap_analysis: 0.490 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9224 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.491 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.490 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.507 + • Radius size diversity: 0.883 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 51.0% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..6d0ca3ea299604a280674228b37648aa8036a27a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9223951229219554, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.1000, 0.3000)\n centers[2] = (0.1000, 0.5000)\n centers[3] = (0.1000, 0.7000)\n centers[4] = (0.1000, 0.9000)\n centers[5] = (0.3000, 0.1000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.3000, 0.5000)\n centers[8] = (0.3000, 0.7000)\n centers[9] = (0.3000, 0.9000)\n centers[10] = (0.5000, 0.1000)\n centers[11] = (0.5000, 0.3000)\n centers[12] = (0.5000, 0.5000)\n centers[13] = (0.5000, 0.7000)\n centers[14] = (0.5000, 0.9000)\n centers[15] = (0.7000, 0.1000)\n centers[16] = (0.7000, 0.3000)\n centers[17] = (0.7000, 0.5000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.7000, 0.9000)\n centers[20] = (0.9000, 0.1000)\n centers[21] = (0.9000, 0.3000)\n centers[22] = (0.9000, 0.5000)\n centers[23] = (0.9000, 0.7000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5066449119960582, + "aux_packing_efficiency": 0.49072180720295644, + "aux_radius_distribution": 0.8828951237442825, + "aux_gap_analysis": 0.4896, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9223951229219554 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9224\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.491\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.490\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.507\n \u2022 Radius size diversity: 0.883\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 51.0% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_22/results/packing_viz.png", + "execution_time_mean": 0.0022128261625766754, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3f0ca4852383c0711e633955dadf38b8d30baaf1 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..eede3c1f121c5feb83e274bc71bd97a05b8974d5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/edit.diff @@ -0,0 +1,116 @@ +--- a/original.py ++++ b/original.py +@@ -1,109 +1,105 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This strategy is a crossover of two parent ideas: + 1. It uses the 5x5 grid structure common to both parents. + 2. It removes the central grid circle at (0.5, 0.5) to create more space. + 3. It then places two interstitial circles at (0.2, 0.2) and (0.8, 0.8), + which are the key placement ideas from the inspiration and current programs, respectively. + This creates a symmetric and more balanced packing. + 4. It uses an iterative method to compute radii, adopted from the better-performing parent. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Use the 5x5 grid from both parents as a base + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # Place 24 circles in a 5x5 grid, but skip the center point (0.5, 0.5) + # This makes space for two interstitial circles, creating a symmetric packing. + for i in range(grid_size): + for j in range(grid_size): +- if i == 2 and j == 2: # Corresponds to (0.5, 0.5) +- continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + +- # Place two interstitial circles, combining ideas from both parents. +- # This balances the packing by filling gaps in two opposite quadrants. +- centers[k] = [0.2, 0.2] # From the 'inspiration' parent +- k += 1 +- centers[k] = [0.8, 0.8] # From the 'current' parent +- k += 1 ++ # Place the 26th circle in an interstitial position. ++ # Restoring the full 5x5 grid, and placing the single 26th circle ++ # at (0.8, 0.2) to explore symmetrical interstitial points. ++ centers[k] = [0.8, 0.2] + + # Use the superior iterative radius calculation from the 'inspiration' parent + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check for convergence. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/original.py new file mode 100644 index 0000000000000000000000000000000000000000..300fa32403503ac8dbebd3ea212dd8433e747ded --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/original.py @@ -0,0 +1,109 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This strategy is a crossover of two parent ideas: + 1. It uses the 5x5 grid structure common to both parents. + 2. It removes the central grid circle at (0.5, 0.5) to create more space. + 3. It then places two interstitial circles at (0.2, 0.2) and (0.8, 0.8), + which are the key placement ideas from the inspiration and current programs, respectively. + This creates a symmetric and more balanced packing. + 4. It uses an iterative method to compute radii, adopted from the better-performing parent. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Use the 5x5 grid from both parents as a base + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # Place 24 circles in a 5x5 grid, but skip the center point (0.5, 0.5) + # This makes space for two interstitial circles, creating a symmetric packing. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # Place two interstitial circles, combining ideas from both parents. + # This balances the packing by filling gaps in two opposite quadrants. + centers[k] = [0.2, 0.2] # From the 'inspiration' parent + k += 1 + centers[k] = [0.8, 0.8] # From the 'current' parent + k += 1 + + # Use the superior iterative radius calculation from the 'inspiration' parent + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check for convergence. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..65af00462f08e0664cdcbdc05aebb04a5f64d98c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.016563043408265046, + "coefficient_of_variation": 0.0836816563257674 + }, + "edge_utilization": 0.3923076923076923, + "edge_utilization_details": { + "corners_touched": 2, + "edges_touched": 6, + "corner_score": 0.5, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.4847986803323693, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0002037114696221169, + "mean_density": 0.013430499678665341, + "cv": 1.0627118855076463 + }, + "packing_efficiency": 0.4619968878599568, + "packing_efficiency_details": { + "total_area": 0.4619968878599568, + "square_area": 1.0, + "efficiency": 0.4619968878599568, + "relative_to_estimated_best": 0.5499962950713772 + }, + "radius_distribution": 0.9903496169664631, + "radius_distribution_details": { + "mean": 0.07154464926714749, + "std": 0.023182900681512374, + "min": 0.032460624246911915, + "max": 0.10261558125579377, + "range": 0.07015495700888186, + "small_count": 7, + "medium_count": 9, + "large_count": 10, + "diversity_score": 0.9903496169664631 + }, + "gap_analysis": 0.4624, + "gap_analysis_details": { + "covered_samples": 1156, + "total_samples": 2500, + "coverage": 0.4624, + "gap_ratio": 0.5376000000000001 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..17afb54c4e7c3c60c03f85e9cc369abde82b3f15 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8602 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.392 + • density_variance: 0.485 + • packing_efficiency: 0.462 + • radius_distribution: 0.990 + • gap_analysis: 0.462 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8602 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.392 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.485 + → Balance circle density across different regions + • Area utilization efficiency: 0.462 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.462 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.990 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 2/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 53.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..3b7a263a1aab52e250507645b5aedb1abe617234 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8601608809458345, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.5000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.8000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.3923076923076923, + "aux_density_variance": 0.4847986803323693, + "aux_packing_efficiency": 0.4619968878599568, + "aux_radius_distribution": 0.9903496169664631, + "aux_gap_analysis": 0.4624, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.8601608809458345 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8602\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.392\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.485\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.462\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.462\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.990\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 2/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 53.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_24/results/packing_viz.png", + "execution_time_mean": 0.003912006039172411, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..487fca30274aed2b0e6c21cca3f15dbe9be96b43 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..367ce6a66d0c834a6c6d6104e4aa047515905fc3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5321553497859173, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00023008231524406688, + "mean_density": 0.017253545721657784, + "cv": 0.8791505157324713 + }, + "packing_efficiency": 0.5166642865652796, + "packing_efficiency_details": { + "total_area": 0.5166642865652796, + "square_area": 1.0, + "efficiency": 0.5166642865652796, + "relative_to_estimated_best": 0.6150765316253329 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07541299137659785, + "std": 0.0252634193391021, + "min": 0.03669894819221307, + "max": 0.12486579904517192, + "range": 0.08816685085295886, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5168, + "gap_analysis_details": { + "covered_samples": 1292, + "total_samples": 2500, + "coverage": 0.5168, + "gap_ratio": 0.48319999999999996 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3650abd9c2d5ba06a0843d573d573d303b044dd8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9607 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.532 + • packing_efficiency: 0.517 + • radius_distribution: 0.977 + • gap_analysis: 0.517 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9607 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.532 + • Area utilization efficiency: 0.517 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.517 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 48.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..c6423cc448919f7a28a83c30a8a26adef49281a0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.960737775791544, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5321553497859173, + "aux_packing_efficiency": 0.5166642865652796, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5168, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.960737775791544 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9607\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.532\n \u2022 Area utilization efficiency: 0.517\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.517\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 48.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_25/results/packing_viz.png", + "execution_time_mean": 0.004113738890737295, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9edd116c468cf967f99f032b0e57b207c1f7dc9 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..15c97c5521ade0334757ea6ff103405b7fc10258 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/edit.diff @@ -0,0 +1,135 @@ +--- a/original.py ++++ b/original.py +@@ -1,108 +1,113 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + ++ This strategy slightly shrinks the main 5x5 grid towards the center ++ to give more room to the circles near the boundary. The interstitial ++ circle's position is adjusted accordingly to maintain its relative ++ position within the modified grid. ++ + Returns: +- Tuple of (centers, radii, sum_of_radii) ++ Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle +- sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + +- # Place 25 circles in a 5x5 grid, then add a 26th interstitial circle. +- # This configuration previously yielded a higher sum of radii (1.9607). ++ # Key parameter: Shrinks the grid towards the center. A positive value ++ # gives more space for boundary circles at the expense of interior ones. ++ grid_margin = 0.015 + grid_size = 5 +- x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 +- y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 ++ ++ # Calculate the new start and end points for the grid ++ start_coord = 0.1 + grid_margin ++ end_coord = 0.9 - grid_margin + ++ x_coords = np.linspace(start_coord, end_coord, grid_size) ++ y_coords = np.linspace(start_coord, end_coord, grid_size) ++ ++ # Place 25 circles in the shrunken 5x5 grid + for i in range(grid_size): + for j in range(grid_size): +- # Skip the central (0.5, 0.5) position for now +- if i == 2 and j == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] +- continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + +- # Place the central (0.5, 0.5) circle as the 25th circle +- centers[k] = [0.5, 0.5] # k is now 24, so centers[24] +- k += 1 ++ # Place the 26th circle in the corresponding interstitial position. ++ # This position is the center of the bottom-left cell of the new grid. ++ spacing = (end_coord - start_coord) / (grid_size - 1) ++ interstitial_coord = start_coord + spacing / 2.0 ++ centers[k] = [interstitial_coord, interstitial_coord] + +- # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2). +- # This position at (0.2, 0.2) previously proved effective in filling gaps. +- centers[k] = [0.2, 0.2] # k is now 25, so centers[25] +- +- # Compute maximum valid radii for this configuration using an iterative method +- # to ensure overlaps are resolved more thoroughly and radii are maximized. ++ # Compute maximum valid radii for this configuration using the robust iterative method. + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. +- # If the sum of radii has not changed significantly from the previous iteration, ++ # If the radii have not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/main.py new file mode 100644 index 0000000000000000000000000000000000000000..19df5f4f299432a3b3b305ca1a003af5f79fe3c8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/main.py @@ -0,0 +1,113 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This strategy slightly shrinks the main 5x5 grid towards the center + to give more room to the circles near the boundary. The interstitial + circle's position is adjusted accordingly to maintain its relative + position within the modified grid. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Key parameter: Shrinks the grid towards the center. A positive value + # gives more space for boundary circles at the expense of interior ones. + grid_margin = 0.015 + grid_size = 5 + + # Calculate the new start and end points for the grid + start_coord = 0.1 + grid_margin + end_coord = 0.9 - grid_margin + + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + + # Place 25 circles in the shrunken 5x5 grid + for i in range(grid_size): + for j in range(grid_size): + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # Place the 26th circle in the corresponding interstitial position. + # This position is the center of the bottom-left cell of the new grid. + spacing = (end_coord - start_coord) / (grid_size - 1) + interstitial_coord = start_coord + spacing / 2.0 + centers[k] = [interstitial_coord, interstitial_coord] + + # Compute maximum valid radii for this configuration using the robust iterative method. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the radii have not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/original.py new file mode 100644 index 0000000000000000000000000000000000000000..5da00de1da494a7bba0d554e9f1533371762750a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/original.py @@ -0,0 +1,108 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Place 25 circles in a 5x5 grid, then add a 26th interstitial circle. + # This configuration previously yielded a higher sum of radii (1.9607). + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i in range(grid_size): + for j in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i == 2 and j == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + centers[k] = [0.5, 0.5] # k is now 24, so centers[24] + k += 1 + + # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2). + # This position at (0.2, 0.2) previously proved effective in filling gaps. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..3c0834bd3cb9e812af20716896d1966cded947f6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225662003, + "spatial_uniformity_details": { + "cell_size_mean": 0.1905068553835812, + "cell_size_std": 0.015941929280455115, + "coefficient_of_variation": 0.08368165630929526 + }, + "edge_utilization": 0.3153846153846154, + "edge_utilization_details": { + "corners_touched": 2, + "edges_touched": 1, + "corner_score": 0.5, + "edge_score": 0.038461538461538464 + }, + "density_variance": 0.5062653545003325, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00016292422523399977, + "mean_density": 0.013088124100868294, + "cv": 0.9752487329237994 + }, + "packing_efficiency": 0.4263936086566674, + "packing_efficiency_details": { + "total_area": 0.4263936086566674, + "square_area": 1.0, + "efficiency": 0.4263936086566674, + "relative_to_estimated_best": 0.507611438876985 + }, + "radius_distribution": 0.8175195284559525, + "radius_distribution_details": { + "mean": 0.06824019937302975, + "std": 0.02373771420590957, + "min": 0.029597618207041834, + "max": 0.1001788796114574, + "range": 0.07058126140441556, + "small_count": 10, + "medium_count": 2, + "large_count": 14, + "diversity_score": 0.8175195284559525 + }, + "gap_analysis": 0.426, + "gap_analysis_details": { + "covered_samples": 1065, + "total_samples": 2500, + "coverage": 0.426, + "gap_ratio": 0.5740000000000001 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865474, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..7380186b64f112741bc42b362fbb80a8de70bcc6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/job_log.out @@ -0,0 +1,76 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.7742 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.315 + • density_variance: 0.506 + • packing_efficiency: 0.426 + • radius_distribution: 0.818 + • gap_analysis: 0.426 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.7742 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.315 + → Consider placing larger circles near boundaries and corners + • Area utilization efficiency: 0.426 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.426 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.506 + • Radius size diversity: 0.818 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 2/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 57.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..c4b2554add7e208006d0e184c3e7056eaf2021f8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.7742451836987736, + "public": { + "centers_str": " centers[0] = (0.1150, 0.1150)\n centers[1] = (0.3075, 0.1150)\n centers[2] = (0.5000, 0.1150)\n centers[3] = (0.6925, 0.1150)\n centers[4] = (0.8850, 0.1150)\n centers[5] = (0.1150, 0.3075)\n centers[6] = (0.3075, 0.3075)\n centers[7] = (0.5000, 0.3075)\n centers[8] = (0.6925, 0.3075)\n centers[9] = (0.8850, 0.3075)\n centers[10] = (0.1150, 0.5000)\n centers[11] = (0.3075, 0.5000)\n centers[12] = (0.5000, 0.5000)\n centers[13] = (0.6925, 0.5000)\n centers[14] = (0.8850, 0.5000)\n centers[15] = (0.1150, 0.6925)\n centers[16] = (0.3075, 0.6925)\n centers[17] = (0.5000, 0.6925)\n centers[18] = (0.6925, 0.6925)\n centers[19] = (0.8850, 0.6925)\n centers[20] = (0.1150, 0.8850)\n centers[21] = (0.3075, 0.8850)\n centers[22] = (0.5000, 0.8850)\n centers[23] = (0.6925, 0.8850)\n centers[24] = (0.8850, 0.8850)\n centers[25] = (0.2112, 0.2112)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225662003, + "aux_edge_utilization": 0.3153846153846154, + "aux_density_variance": 0.5062653545003325, + "aux_packing_efficiency": 0.4263936086566674, + "aux_radius_distribution": 0.8175195284559525, + "aux_gap_analysis": 0.426, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.7742451836987736 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.7742\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.315\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Area utilization efficiency: 0.426\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.426\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.506\n \u2022 Radius size diversity: 0.818\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 2/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 57.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/results/packing_viz.png", + "execution_time_mean": 0.003983947914093733, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..2292fbd3b74f879bcead25e09c38df60310d5fd8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_28/rewrite.txt @@ -0,0 +1,104 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This strategy slightly shrinks the main 5x5 grid towards the center + to give more room to the circles near the boundary. The interstitial + circle's position is adjusted accordingly to maintain its relative + position within the modified grid. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Key parameter: Shrinks the grid towards the center. A positive value + # gives more space for boundary circles at the expense of interior ones. + grid_margin = 0.015 + grid_size = 5 + + # Calculate the new start and end points for the grid + start_coord = 0.1 + grid_margin + end_coord = 0.9 - grid_margin + + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + + # Place 25 circles in the shrunken 5x5 grid + for i in range(grid_size): + for j in range(grid_size): + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # Place the 26th circle in the corresponding interstitial position. + # This position is the center of the bottom-left cell of the new grid. + spacing = (end_coord - start_coord) / (grid_size - 1) + interstitial_coord = start_coord + spacing / 2.0 + centers[k] = [interstitial_coord, interstitial_coord] + + # Compute maximum valid radii for this configuration using the robust iterative method. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the radii have not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e8b92ec672611ed54fb138200c93b9a1c1975185 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..a5c76402b7a1f9bf1a242974afdbf5c4ee0a6537 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.016563043408265067, + "coefficient_of_variation": 0.08368165632576749 + }, + "edge_utilization": 0.5423076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 6, + "corner_score": 0.75, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.48643520680450775, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00021412397470896822, + "mean_density": 0.01385997266470011, + "cv": 1.0557722508804497 + }, + "packing_efficiency": 0.4623109346928606, + "packing_efficiency_details": { + "total_area": 0.4623109346928606, + "square_area": 1.0, + "efficiency": 0.4623109346928606, + "relative_to_estimated_best": 0.5503701603486436 + }, + "radius_distribution": 0.9986351900937254, + "radius_distribution_details": { + "mean": 0.07168735619122488, + "std": 0.022822170414996873, + "min": 0.03946019296101107, + "max": 0.12486579904517192, + "range": 0.08540560608416085, + "small_count": 9, + "medium_count": 8, + "large_count": 9, + "diversity_score": 0.9986351900937254 + }, + "gap_analysis": 0.4576, + "gap_analysis_details": { + "covered_samples": 1144, + "total_samples": 2500, + "coverage": 0.4576, + "gap_ratio": 0.5424 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..950aedc46a23d772e5a9cc8ae77c3dfca0dcd272 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8639 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.542 + • density_variance: 0.486 + • packing_efficiency: 0.462 + • radius_distribution: 0.999 + • gap_analysis: 0.458 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8639 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.486 + → Balance circle density across different regions + • Area utilization efficiency: 0.462 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.458 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.542 + • Radius size diversity: 0.999 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 54.2% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..abfca5f00d62d1697b40ff41fa96d5acc7fb3602 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8638712609718469, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.8000, 0.8000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5423076923076923, + "aux_density_variance": 0.48643520680450775, + "aux_packing_efficiency": 0.4623109346928606, + "aux_radius_distribution": 0.9986351900937254, + "aux_gap_analysis": 0.4576, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.8638712609718469 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8639\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.486\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.462\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.458\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.542\n \u2022 Radius size diversity: 0.999\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 54.2% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_29/results/packing_viz.png", + "execution_time_mean": 0.006654523778706789, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f48d1a256cad6deb4def1245e37c35660f01204b Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..fa0296a659fdd4b25ee0df5c2decb9e618d42977 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9065258161650044, + "spatial_uniformity_details": { + "cell_size_mean": 0.1886271822049501, + "cell_size_std": 0.019449828879410054, + "coefficient_of_variation": 0.10311254480366772 + }, + "edge_utilization": 0.015384615384615385, + "edge_utilization_details": { + "corners_touched": 0, + "edges_touched": 1, + "corner_score": 0.0, + "edge_score": 0.038461538461538464 + }, + "density_variance": 0.430980461443845, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00015702109892411402, + "mean_density": 0.009490942956645227, + "cv": 1.3202908007705492 + }, + "packing_efficiency": 0.4059372768768489, + "packing_efficiency_details": { + "total_area": 0.4059372768768489, + "square_area": 1.0, + "efficiency": 0.4059372768768489, + "relative_to_estimated_best": 0.4832586629486296 + }, + "radius_distribution": 0.9947372351472321, + "radius_distribution_details": { + "mean": 0.06569144013415244, + "std": 0.025581205857377314, + "min": 0.022404293688511857, + "max": 0.10710006643052564, + "range": 0.08469577274201379, + "small_count": 10, + "medium_count": 8, + "large_count": 8, + "diversity_score": 0.9947372351472321 + }, + "gap_analysis": 0.4056, + "gap_analysis_details": { + "covered_samples": 1014, + "total_samples": 2500, + "coverage": 0.4056, + "gap_ratio": 0.5944 + }, + "geometric_quality": 0.6915086619257171, + "geometric_quality_details": { + "num_triangles": 39, + "avg_triangle_quality": 0.6915086619257171, + "min_quality": 0.3811812499312437, + "max_quality": 0.7288689868556625 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..779b8c4254ff2b22df75a398284619a923c34b35 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.7080 + + Auxiliary Metrics: + • spatial_uniformity: 0.907 + • edge_utilization: 0.015 + • density_variance: 0.431 + • packing_efficiency: 0.406 + • radius_distribution: 0.995 + • gap_analysis: 0.406 + • geometric_quality: 0.692 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.7080 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.907 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.015 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.431 + → Balance circle density across different regions + • Area utilization efficiency: 0.406 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.406 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.995 + • Delaunay triangulation quality: 0.692 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 0/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 59.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..44c957a38f2a731cd6b7fe5d247ef1cdfad36007 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.7079774434879635, + "public": { + "centers_str": " centers[0] = (0.1250, 0.1250)\n centers[1] = (0.1250, 0.3750)\n centers[2] = (0.1250, 0.6250)\n centers[3] = (0.1250, 0.8750)\n centers[4] = (0.3750, 0.1250)\n centers[5] = (0.3750, 0.3750)\n centers[6] = (0.3750, 0.6250)\n centers[7] = (0.3750, 0.8750)\n centers[8] = (0.6250, 0.1250)\n centers[9] = (0.6250, 0.3750)\n centers[10] = (0.6250, 0.6250)\n centers[11] = (0.6250, 0.8750)\n centers[12] = (0.8750, 0.1250)\n centers[13] = (0.8750, 0.3750)\n centers[14] = (0.8750, 0.6250)\n centers[15] = (0.8750, 0.8750)\n centers[16] = (0.2500, 0.2500)\n centers[17] = (0.2500, 0.5000)\n centers[18] = (0.2500, 0.7500)\n centers[19] = (0.5000, 0.2500)\n centers[20] = (0.5000, 0.5000)\n centers[21] = (0.5000, 0.7500)\n centers[22] = (0.7500, 0.2500)\n centers[23] = (0.7500, 0.5000)\n centers[24] = (0.7500, 0.7500)\n centers[25] = (0.0500, 0.5000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9065258161650044, + "aux_edge_utilization": 0.015384615384615385, + "aux_density_variance": 0.430980461443845, + "aux_packing_efficiency": 0.4059372768768489, + "aux_radius_distribution": 0.9947372351472321, + "aux_gap_analysis": 0.4056, + "aux_geometric_quality": 0.6915086619257171 + }, + "private": { + "reported_sum_of_radii": 1.7079774434879635 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.7080\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.907\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.015\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.431\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.406\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.406\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.995\n \u2022 Delaunay triangulation quality: 0.692\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 0/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 59.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_3/results/packing_viz.png", + "execution_time_mean": 0.0019080070778727531, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fad1e17d9ac0c388b6fa2a9d360ad9df21315ba3 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f6374d9f5297ccf1a2dc218ba59b6a41a053a98d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576736 + }, + "edge_utilization": 0.5423076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 6, + "corner_score": 0.75, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.5111144984177896, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001908546402477123, + "mean_density": 0.014443165046568045, + "cv": 0.9565087726832413 + }, + "packing_efficiency": 0.4741083916241685, + "packing_efficiency_details": { + "total_area": 0.4741083916241685, + "square_area": 1.0, + "efficiency": 0.4741083916241685, + "relative_to_estimated_best": 0.564414751933534 + }, + "radius_distribution": 0.9118485864013031, + "radius_distribution_details": { + "mean": 0.07294542244363586, + "std": 0.021984686221039183, + "min": 0.0392615408950439, + "max": 0.10621358656167956, + "range": 0.06695204566663567, + "small_count": 9, + "medium_count": 4, + "large_count": 13, + "diversity_score": 0.9118485864013031 + }, + "gap_analysis": 0.4692, + "gap_analysis_details": { + "covered_samples": 1173, + "total_samples": 2500, + "coverage": 0.4692, + "gap_ratio": 0.5307999999999999 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..10d567d993b0c4ac0209aa5b2c763cee946f59f8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8966 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.542 + • density_variance: 0.511 + • packing_efficiency: 0.474 + • radius_distribution: 0.912 + • gap_analysis: 0.469 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8966 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.474 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.469 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.542 + • Spatial density uniformity across grid: 0.511 + • Radius size diversity: 0.912 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 53.1% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..e6e042b43950f8cc2d2a7dd91ef758d95ff0a834 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8965809835345322, + "public": { + "centers_str": " centers[0] = (0.1050, 0.1050)\n centers[1] = (0.1050, 0.3050)\n centers[2] = (0.1050, 0.5050)\n centers[3] = (0.1050, 0.7050)\n centers[4] = (0.1050, 0.9050)\n centers[5] = (0.3050, 0.1050)\n centers[6] = (0.3050, 0.3050)\n centers[7] = (0.3050, 0.5050)\n centers[8] = (0.3050, 0.7050)\n centers[9] = (0.3050, 0.9050)\n centers[10] = (0.5050, 0.1050)\n centers[11] = (0.5050, 0.3050)\n centers[12] = (0.5050, 0.5050)\n centers[13] = (0.5050, 0.7050)\n centers[14] = (0.5050, 0.9050)\n centers[15] = (0.7050, 0.1050)\n centers[16] = (0.7050, 0.3050)\n centers[17] = (0.7050, 0.5050)\n centers[18] = (0.7050, 0.7050)\n centers[19] = (0.7050, 0.9050)\n centers[20] = (0.9050, 0.1050)\n centers[21] = (0.9050, 0.3050)\n centers[22] = (0.9050, 0.5050)\n centers[23] = (0.9050, 0.7050)\n centers[24] = (0.9050, 0.9050)\n centers[25] = (0.2050, 0.2050)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5423076923076923, + "aux_density_variance": 0.5111144984177896, + "aux_packing_efficiency": 0.4741083916241685, + "aux_radius_distribution": 0.9118485864013031, + "aux_gap_analysis": 0.4692, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.8965809835345322 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8966\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.474\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.469\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.542\n \u2022 Spatial density uniformity across grid: 0.511\n \u2022 Radius size diversity: 0.912\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 53.1% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_31/results/packing_viz.png", + "execution_time_mean": 0.0022709816694259644, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5c8451bc5e0837d2413d4ba23fc1753a9700d453 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..367ce6a66d0c834a6c6d6104e4aa047515905fc3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5321553497859173, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00023008231524406688, + "mean_density": 0.017253545721657784, + "cv": 0.8791505157324713 + }, + "packing_efficiency": 0.5166642865652796, + "packing_efficiency_details": { + "total_area": 0.5166642865652796, + "square_area": 1.0, + "efficiency": 0.5166642865652796, + "relative_to_estimated_best": 0.6150765316253329 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07541299137659785, + "std": 0.0252634193391021, + "min": 0.03669894819221307, + "max": 0.12486579904517192, + "range": 0.08816685085295886, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5168, + "gap_analysis_details": { + "covered_samples": 1292, + "total_samples": 2500, + "coverage": 0.5168, + "gap_ratio": 0.48319999999999996 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..b5d7f041352b87ce50533197df64730f053699cd --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9607 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.532 + • packing_efficiency: 0.517 + • radius_distribution: 0.977 + • gap_analysis: 0.517 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9607 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.532 + • Area utilization efficiency: 0.517 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.517 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 48.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..6b3ca82223c8502b7d79251fddf172f674d3d2f4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.960737775791544, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5321553497859173, + "aux_packing_efficiency": 0.5166642865652796, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5168, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.960737775791544 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9607\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.532\n \u2022 Area utilization efficiency: 0.517\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.517\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 48.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_32/results/packing_viz.png", + "execution_time_mean": 0.006222827825695276, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d8ae06dccc4341aca8d5a2f989ca40e34b6bc968 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..b785e5f9986a226da7bf403a96dea8368dfecf3e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.016563043408265043, + "coefficient_of_variation": 0.08368165632576736 + }, + "edge_utilization": 0.2730769230769231, + "edge_utilization_details": { + "corners_touched": 1, + "edges_touched": 8, + "corner_score": 0.25, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.466023066790669, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00014790991517326432, + "mean_density": 0.01061410842926998, + "cv": 1.1458165298268077 + }, + "packing_efficiency": 0.42896603149766144, + "packing_efficiency_details": { + "total_area": 0.42896603149766144, + "square_area": 1.0, + "efficiency": 0.42896603149766144, + "relative_to_estimated_best": 0.5106738470210256 + }, + "radius_distribution": 0.9450467888248784, + "radius_distribution_details": { + "mean": 0.06947190969770095, + "std": 0.020624039837370513, + "min": 0.03, + "max": 0.10969124546941258, + "range": 0.07969124546941259, + "small_count": 7, + "medium_count": 6, + "large_count": 13, + "diversity_score": 0.9450467888248784 + }, + "gap_analysis": 0.4184, + "gap_analysis_details": { + "covered_samples": 1046, + "total_samples": 2500, + "coverage": 0.4184, + "gap_ratio": 0.5816 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865475 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..8a41949f6860a159770cb7c76acf93f71ca70ab7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8063 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.273 + • density_variance: 0.466 + • packing_efficiency: 0.429 + • radius_distribution: 0.945 + • gap_analysis: 0.418 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8063 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.273 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.466 + → Balance circle density across different regions + • Area utilization efficiency: 0.429 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.418 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.945 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 1/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 58.2% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..c8e43d5b68d0b1c94be80518313f8d541ce41c42 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8062696521402248, + "public": { + "centers_str": " centers[0] = (0.1150, 0.1150)\n centers[1] = (0.1150, 0.3150)\n centers[2] = (0.1150, 0.5150)\n centers[3] = (0.1150, 0.7150)\n centers[4] = (0.1150, 0.9150)\n centers[5] = (0.3150, 0.1150)\n centers[6] = (0.3150, 0.3150)\n centers[7] = (0.3150, 0.5150)\n centers[8] = (0.3150, 0.7150)\n centers[9] = (0.3150, 0.9150)\n centers[10] = (0.5150, 0.1150)\n centers[11] = (0.5150, 0.3150)\n centers[12] = (0.5150, 0.5150)\n centers[13] = (0.5150, 0.7150)\n centers[14] = (0.5150, 0.9150)\n centers[15] = (0.7150, 0.1150)\n centers[16] = (0.7150, 0.3150)\n centers[17] = (0.7150, 0.5150)\n centers[18] = (0.7150, 0.7150)\n centers[19] = (0.7150, 0.9150)\n centers[20] = (0.9150, 0.1150)\n centers[21] = (0.9150, 0.3150)\n centers[22] = (0.9150, 0.5150)\n centers[23] = (0.9150, 0.7150)\n centers[24] = (0.9150, 0.9150)\n centers[25] = (0.2150, 0.2150)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.2730769230769231, + "aux_density_variance": 0.466023066790669, + "aux_packing_efficiency": 0.42896603149766144, + "aux_radius_distribution": 0.9450467888248784, + "aux_gap_analysis": 0.4184, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.8062696521402248 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8063\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.273\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.466\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.429\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.418\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.945\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 1/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 58.2% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_33/results/packing_viz.png", + "execution_time_mean": 0.002275214996188879, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..13c2008920b22d0db1a611ef0be08f46a38a64a8 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..e677c38361e158fe45b1b27a88a7f9c89e5e06c4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/edit.diff @@ -0,0 +1,130 @@ +--- a/original.py ++++ b/original.py +@@ -1,110 +1,118 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + +- # This strategy improves central packing density by replacing the single +- # center circle of a 5x5 grid with two smaller, symmetrically placed circles. ++ # Define a small offset to expand the grid slightly, pushing circles closer to boundaries ++ # to potentially increase their radii and improve edge utilization. ++ grid_boundary_offset = 0.01 ++ + grid_size = 5 +- x_coords = np.linspace(0.1, 0.9, grid_size) +- y_coords = np.linspace(0.1, 0.9, grid_size) ++ x_coords = np.linspace(0.1 - grid_boundary_offset, 0.9 + grid_boundary_offset, grid_size) ++ y_coords = np.linspace(0.1 - grid_boundary_offset, 0.9 + grid_boundary_offset, grid_size) ++ ++ # Calculate grid spacing for adjusting interstitial points ++ grid_spacing = x_coords[1] - x_coords[0] + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): +- if i == 2 and j == 2: # Corresponds to (0.5, 0.5) ++ if i == 2 and j == 2: # Corresponds to the central (0.5, 0.5) grid position + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Place the central (0.5, 0.5) circle as the 25th circle. +- # This configuration proved more effective than splitting the central space. ++ # The original (0.5, 0.5) point remains fixed as a core anchor for the packing. + centers[k] = [0.5, 0.5] + k += 1 + +- # 3. Place the 26th circle in an interstitial position (0.2, 0.2). +- # This position has consistently been effective in filling gaps in the bottom-left quadrant. +- centers[k] = [0.2, 0.2] ++ # 3. Place the 26th circle in an interstitial position. ++ # This position is adjusted to be the center of the bottom-left grid cell ++ # relative to the new, expanded grid coordinates. ++ interstitial_x = x_coords[0] + grid_spacing / 2.0 ++ interstitial_y = y_coords[0] + grid_spacing / 2.0 ++ centers[k] = [interstitial_x, interstitial_y] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/main.py new file mode 100644 index 0000000000000000000000000000000000000000..a3d182b5e01e175c94031c09f02bd7b3f4598317 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/main.py @@ -0,0 +1,118 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Define a small offset to expand the grid slightly, pushing circles closer to boundaries + # to potentially increase their radii and improve edge utilization. + grid_boundary_offset = 0.01 + + grid_size = 5 + x_coords = np.linspace(0.1 - grid_boundary_offset, 0.9 + grid_boundary_offset, grid_size) + y_coords = np.linspace(0.1 - grid_boundary_offset, 0.9 + grid_boundary_offset, grid_size) + + # Calculate grid spacing for adjusting interstitial points + grid_spacing = x_coords[1] - x_coords[0] + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to the central (0.5, 0.5) grid position + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Place the central (0.5, 0.5) circle as the 25th circle. + # The original (0.5, 0.5) point remains fixed as a core anchor for the packing. + centers[k] = [0.5, 0.5] + k += 1 + + # 3. Place the 26th circle in an interstitial position. + # This position is adjusted to be the center of the bottom-left grid cell + # relative to the new, expanded grid coordinates. + interstitial_x = x_coords[0] + grid_spacing / 2.0 + interstitial_y = y_coords[0] + grid_spacing / 2.0 + centers[k] = [interstitial_x, interstitial_y] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/original.py new file mode 100644 index 0000000000000000000000000000000000000000..6cd5bcccdeead16697936db01ee7bf9da9dab106 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/original.py @@ -0,0 +1,110 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Place the central (0.5, 0.5) circle as the 25th circle. + # This configuration proved more effective than splitting the central space. + centers[k] = [0.5, 0.5] + k += 1 + + # 3. Place the 26th circle in an interstitial position (0.2, 0.2). + # This position has consistently been effective in filling gaps in the bottom-left quadrant. + centers[k] = [0.2, 0.2] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..3b342ace4a1bd9c9a9c1947782c0e0e3cd712212 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.922780222543393, + "spatial_uniformity_details": { + "cell_size_mean": 0.2028774304084891, + "cell_size_std": 0.01697711949347169, + "coefficient_of_variation": 0.08368165633607932 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5299038612411695, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0002078795914724976, + "mean_density": 0.016252355023625244, + "cv": 0.8871347675364091 + }, + "packing_efficiency": 0.4910409522712212, + "packing_efficiency_details": { + "total_area": 0.4910409522712212, + "square_area": 1.0, + "efficiency": 0.4910409522712212, + "relative_to_estimated_best": 0.5845725622276443 + }, + "radius_distribution": 0.9543725752531863, + "radius_distribution_details": { + "mean": 0.07385835352778268, + "std": 0.023592472395729345, + "min": 0.037745220350631596, + "max": 0.12743903708926796, + "range": 0.08969381673863636, + "small_count": 10, + "medium_count": 5, + "large_count": 11, + "diversity_score": 0.9543725752531863 + }, + "gap_analysis": 0.496, + "gap_analysis_details": { + "covered_samples": 1240, + "total_samples": 2500, + "coverage": 0.496, + "gap_ratio": 0.504 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865474, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..df5963763c6e494deeaa6949df219efbbb7ef4a2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9203 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.530 + • packing_efficiency: 0.491 + • radius_distribution: 0.954 + • gap_analysis: 0.496 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9203 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.491 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.496 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.530 + • Radius size diversity: 0.954 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 50.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..d1c7a685a0722754e0833ea2f2426957e42c8366 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9203171917223496, + "public": { + "centers_str": " centers[0] = (0.0900, 0.0900)\n centers[1] = (0.2950, 0.0900)\n centers[2] = (0.5000, 0.0900)\n centers[3] = (0.7050, 0.0900)\n centers[4] = (0.9100, 0.0900)\n centers[5] = (0.0900, 0.2950)\n centers[6] = (0.2950, 0.2950)\n centers[7] = (0.5000, 0.2950)\n centers[8] = (0.7050, 0.2950)\n centers[9] = (0.9100, 0.2950)\n centers[10] = (0.0900, 0.5000)\n centers[11] = (0.2950, 0.5000)\n centers[12] = (0.7050, 0.5000)\n centers[13] = (0.9100, 0.5000)\n centers[14] = (0.0900, 0.7050)\n centers[15] = (0.2950, 0.7050)\n centers[16] = (0.5000, 0.7050)\n centers[17] = (0.7050, 0.7050)\n centers[18] = (0.9100, 0.7050)\n centers[19] = (0.0900, 0.9100)\n centers[20] = (0.2950, 0.9100)\n centers[21] = (0.5000, 0.9100)\n centers[22] = (0.7050, 0.9100)\n centers[23] = (0.9100, 0.9100)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.1925, 0.1925)", + "num_circles": 26, + "aux_spatial_uniformity": 0.922780222543393, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5299038612411695, + "aux_packing_efficiency": 0.4910409522712212, + "aux_radius_distribution": 0.9543725752531863, + "aux_gap_analysis": 0.496, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9203171917223496 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9203\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.491\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.496\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.530\n \u2022 Radius size diversity: 0.954\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 50.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/results/packing_viz.png", + "execution_time_mean": 0.003962242044508457, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..f6b1b98d045f4bb5e144da4aa61596fdd5b57c91 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_35/search_replace.txt @@ -0,0 +1,69 @@ + +This edit implements the recommendation to "Optimize grid linspace bounds with small, independent perturbations". Instead of fixed bounds of 0.1 and 0.9 for the 5x5 grid, we introduce a small `grid_boundary_offset`. This offset expands the grid slightly outwards, pushing the boundary circles closer to the unit square's edges. This aims to improve `edge_utilization` and overall `packing_efficiency` by allowing boundary circles to potentially grow larger or distribute forces more effectively during the iterative relaxation. The interstitial circle's position is also dynamically adjusted to maintain its relative placement within the expanded grid, specifically at the center of the bottom-left grid cell. + +The `grid_boundary_offset` is set to 0.01. This means `x_coords` and `y_coords` will span from `0.1 - 0.01 = 0.09` to `0.9 + 0.01 = 0.91`. This small expansion is designed to give the circles near the boundaries more space to expand. The previous attempt to shrink the grid led to a lower score, suggesting that expanding outwards might be more beneficial. + + + +<<<<<<< SEARCH + k = 0 # current circle index + + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Place the central (0.5, 0.5) circle as the 25th circle. + # This configuration proved more effective than splitting the central space. + centers[k] = [0.5, 0.5] + k += 1 + + # 3. Place the 26th circle in an interstitial position (0.2, 0.2). + # This position has consistently been effective in filling gaps in the bottom-left quadrant. + centers[k] = [0.2, 0.2] +======= + k = 0 # current circle index + + # Define a small offset to expand the grid slightly, pushing circles closer to boundaries + # to potentially increase their radii and improve edge utilization. + grid_boundary_offset = 0.01 + + grid_size = 5 + x_coords = np.linspace(0.1 - grid_boundary_offset, 0.9 + grid_boundary_offset, grid_size) + y_coords = np.linspace(0.1 - grid_boundary_offset, 0.9 + grid_boundary_offset, grid_size) + + # Calculate grid spacing for adjusting interstitial points + grid_spacing = x_coords[1] - x_coords[0] + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to the central (0.5, 0.5) grid position + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Place the central (0.5, 0.5) circle as the 25th circle. + # The original (0.5, 0.5) point remains fixed as a core anchor for the packing. + centers[k] = [0.5, 0.5] + k += 1 + + # 3. Place the 26th circle in an interstitial position. + # This position is adjusted to be the center of the bottom-left grid cell + # relative to the new, expanded grid coordinates. + interstitial_x = x_coords[0] + grid_spacing / 2.0 + interstitial_y = y_coords[0] + grid_spacing / 2.0 + centers[k] = [interstitial_x, interstitial_y] +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..01f79699d5f530003b633befa4fba2c023af9ca7 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..19a3f25c3bfe64ceffab30ebe61135f3648b3c64 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/edit.diff @@ -0,0 +1,129 @@ +--- a/original.py ++++ b/original.py +@@ -1,98 +1,110 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Place 25 circles in a 5x5 grid + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + centers[k] = [0.5, 0.5] # k is now 24, so centers[24] + k += 1 + + # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2) + # The bottom-left grid circle is at (0.1, 0.1). Its neighbors are (0.3, 0.1), (0.1, 0.3). + # Placing at (0.2, 0.2) aims to fill a gap and was the previous best interstitial. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # No clipping needed, as all centers are already within [0.1, 0.9] or [0.2, 0.2] + # which ensures they are within the unit square and allows for larger initial radii. + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +-def compute_max_radii(centers): ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. ++ This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates ++ max_iterations: Maximum number of iterations for the relaxation process. ++ tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] +- radii = np.ones(n) ++ radii = np.zeros(n) # Initialize radii to zero, then expand + +- # First, limit by distance to square borders ++ # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] +- # Distance to borders + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Then, limit by distance to other circles +- # Each pair of circles with centers at distance d can have +- # sum of radii at most d to avoid overlap +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) ++ # 2. Iteratively adjust radii to resolve overlaps and maximize size ++ for iteration in range(max_iterations): ++ prev_radii = np.copy(radii) + +- # If current radii would cause overlap +- if radii[i] + radii[j] > dist: +- # Scale both radii proportionally +- scale = dist / (radii[i] + radii[j]) +- radii[i] *= scale +- radii[j] *= scale ++ # Iterate over all unique pairs of circles (i, j) where i < j ++ for i in range(n): ++ for j in range(i + 1, n): ++ dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) ++ ++ # Check for overlap: if the sum of current radii exceeds the distance ++ if radii[i] + radii[j] > dist: ++ # Apply proportional scaling to both radii to make them just touch. ++ # This ensures no overlap while maximizing their combined size relative ++ # to their current proportions. ++ scale_factor = dist / (radii[i] + radii[j]) ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor ++ ++ # After a full pass over all pairs, check for convergence. ++ # If the radii have not changed significantly from the previous iteration, ++ # the system has stabilized. ++ if np.allclose(radii, prev_radii, atol=tolerance): ++ break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/main.py new file mode 100644 index 0000000000000000000000000000000000000000..3c4e5bc8b893f62b7b69aa5f133f29bc84188855 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/main.py @@ -0,0 +1,110 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Place 25 circles in a 5x5 grid + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + centers[k] = [0.5, 0.5] # k is now 24, so centers[24] + k += 1 + + # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2) + # The bottom-left grid circle is at (0.1, 0.1). Its neighbors are (0.3, 0.1), (0.1, 0.3). + # Placing at (0.2, 0.2) aims to fill a gap and was the previous best interstitial. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # No clipping needed, as all centers are already within [0.1, 0.9] or [0.2, 0.2] + # which ensures they are within the unit square and allows for larger initial radii. + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) # Initialize radii to zero, then expand + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the radii have not changed significantly from the previous iteration, + # the system has stabilized. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/original.py new file mode 100644 index 0000000000000000000000000000000000000000..e1f8968ab1fff8a30d35fd54004bd009ee3171da --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/original.py @@ -0,0 +1,98 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Place 25 circles in a 5x5 grid + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + centers[k] = [0.5, 0.5] # k is now 24, so centers[24] + k += 1 + + # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2) + # The bottom-left grid circle is at (0.1, 0.1). Its neighbors are (0.3, 0.1), (0.1, 0.3). + # Placing at (0.2, 0.2) aims to fill a gap and was the previous best interstitial. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # No clipping needed, as all centers are already within [0.1, 0.9] or [0.2, 0.2] + # which ensures they are within the unit square and allows for larger initial radii. + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.ones(n) + + # First, limit by distance to square borders + for i in range(n): + x, y = centers[i] + # Distance to borders + radii[i] = min(x, y, 1 - x, 1 - y) + + # Then, limit by distance to other circles + # Each pair of circles with centers at distance d can have + # sum of radii at most d to avoid overlap + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # If current radii would cause overlap + if radii[i] + radii[j] > dist: + # Scale both radii proportionally + scale = dist / (radii[i] + radii[j]) + radii[i] *= scale + radii[j] *= scale + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..367ce6a66d0c834a6c6d6104e4aa047515905fc3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5321553497859173, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00023008231524406688, + "mean_density": 0.017253545721657784, + "cv": 0.8791505157324713 + }, + "packing_efficiency": 0.5166642865652796, + "packing_efficiency_details": { + "total_area": 0.5166642865652796, + "square_area": 1.0, + "efficiency": 0.5166642865652796, + "relative_to_estimated_best": 0.6150765316253329 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07541299137659785, + "std": 0.0252634193391021, + "min": 0.03669894819221307, + "max": 0.12486579904517192, + "range": 0.08816685085295886, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5168, + "gap_analysis_details": { + "covered_samples": 1292, + "total_samples": 2500, + "coverage": 0.5168, + "gap_ratio": 0.48319999999999996 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..4cfa90a9cf494b309da3a0b97710ce9ad622de79 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9607 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.532 + • packing_efficiency: 0.517 + • radius_distribution: 0.977 + • gap_analysis: 0.517 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9607 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.532 + • Area utilization efficiency: 0.517 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.517 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 48.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..c6f283fff49956d6cc56903afcf6ab7b19e3a9b9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.960737775791544, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5321553497859173, + "aux_packing_efficiency": 0.5166642865652796, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5168, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.960737775791544 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9607\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.532\n \u2022 Area utilization efficiency: 0.517\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.517\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 48.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/results/packing_viz.png", + "execution_time_mean": 0.0040444196201860905, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..528f93aa7ae484ade478f0a2266dc3f3fabe70f3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_36/search_replace.txt @@ -0,0 +1,91 @@ + +Reintroduce the iterative relaxation loop to `compute_max_radii`. The current implementation describes an iterative approach but lacks the actual loop, `max_iterations`, and `tolerance` parameters, and incorrectly initializes radii to 1. This change corrects these omissions, ensuring that the radii are truly maximized for the given center configuration by repeatedly resolving overlaps until convergence. This will lead to higher total radii and better packing efficiency, directly addressing the feedback regarding "unused space" and "increasing radii in sparse regions". + + + +<<<<<<< SEARCH +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.ones(n) + + # First, limit by distance to square borders + for i in range(n): + x, y = centers[i] + # Distance to borders + radii[i] = min(x, y, 1 - x, 1 - y) + + # Then, limit by distance to other circles + # Each pair of circles with centers at distance d can have + # sum of radii at most d to avoid overlap + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # If current radii would cause overlap + if radii[i] + radii[j] > dist: + # Scale both radii proportionally + scale = dist / (radii[i] + radii[j]) + radii[i] *= scale + radii[j] *= scale + + return radii +======= +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) # Initialize radii to zero, then expand + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the radii have not changed significantly from the previous iteration, + # the system has stabilized. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fda30c2a2b93565965a2ef16ad1c68f86bcf07e4 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..d3fcd4de962e58fa89299e0c4813f303aaf3944d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5321553497859173, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00023008231524406688, + "mean_density": 0.017253545721657784, + "cv": 0.8791505157324713 + }, + "packing_efficiency": 0.5166642865652796, + "packing_efficiency_details": { + "total_area": 0.5166642865652796, + "square_area": 1.0, + "efficiency": 0.5166642865652796, + "relative_to_estimated_best": 0.6150765316253329 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07541299137659783, + "std": 0.0252634193391021, + "min": 0.03669894819221307, + "max": 0.12486579904517191, + "range": 0.08816685085295883, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5168, + "gap_analysis_details": { + "covered_samples": 1292, + "total_samples": 2500, + "coverage": 0.5168, + "gap_ratio": 0.48319999999999996 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3dbe9ad7247b3b5b88f8a1d6c8dc4099fa330e0a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9607 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.532 + • packing_efficiency: 0.517 + • radius_distribution: 0.977 + • gap_analysis: 0.517 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9607 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.532 + • Area utilization efficiency: 0.517 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.517 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 48.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..646fa6b2cabac07d7c20b86b3f55c858a17a9c0a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9607377757915438, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5321553497859173, + "aux_packing_efficiency": 0.5166642865652796, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5168, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9607377757915438 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9607\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.532\n \u2022 Area utilization efficiency: 0.517\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.517\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 48.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_37/results/packing_viz.png", + "execution_time_mean": 0.0026049455627799034, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..da7dfad4afca60b1f155feb05e9065d3772614f8 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5b65f14d627aabc37b9169aadfed13b7e128c382 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9088218504930425, + "spatial_uniformity_details": { + "cell_size_mean": 0.19161005656758423, + "cell_size_std": 0.019223404968152943, + "coefficient_of_variation": 0.10032565728640058 + }, + "edge_utilization": 0.5423076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 6, + "corner_score": 0.75, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.49987209333985694, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00017192201396102775, + "mean_density": 0.013105195838157543, + "cv": 1.0005117575549716 + }, + "packing_efficiency": 0.4464314285996091, + "packing_efficiency_details": { + "total_area": 0.4464314285996091, + "square_area": 1.0, + "efficiency": 0.4464314285996091, + "relative_to_estimated_best": 0.531465986428106 + }, + "radius_distribution": 0.9246502903618902, + "radius_distribution_details": { + "mean": 0.07122556703517727, + "std": 0.019810079835065043, + "min": 0.03693980625181294, + "max": 0.09999999999999998, + "range": 0.06306019374818704, + "small_count": 11, + "medium_count": 4, + "large_count": 11, + "diversity_score": 0.9246502903618902 + }, + "gap_analysis": 0.4448, + "gap_analysis_details": { + "covered_samples": 1112, + "total_samples": 2500, + "coverage": 0.4448, + "gap_ratio": 0.5552 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..b0d2168d11a0c0aa416f163327375a82b98b1101 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8519 + + Auxiliary Metrics: + • spatial_uniformity: 0.909 + • edge_utilization: 0.542 + • density_variance: 0.500 + • packing_efficiency: 0.446 + • radius_distribution: 0.925 + • gap_analysis: 0.445 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8519 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.909 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.500 + → Balance circle density across different regions + • Area utilization efficiency: 0.446 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.445 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.542 + • Radius size diversity: 0.925 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 55.5% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..b7ba579f26de0f1819ce258bb94d3184effae92d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.851864742914609, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.2000, 0.2000)\n centers[25] = (0.8000, 0.8000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9088218504930425, + "aux_edge_utilization": 0.5423076923076923, + "aux_density_variance": 0.49987209333985694, + "aux_packing_efficiency": 0.4464314285996091, + "aux_radius_distribution": 0.9246502903618902, + "aux_gap_analysis": 0.4448, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.851864742914609 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8519\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.909\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.500\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.446\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.445\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.542\n \u2022 Radius size diversity: 0.925\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 55.5% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_38/results/packing_viz.png", + "execution_time_mean": 0.006490504834800959, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c161a36db72a2c360c1c955e6cad0c131bc1aec1 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..fa0296a659fdd4b25ee0df5c2decb9e618d42977 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9065258161650044, + "spatial_uniformity_details": { + "cell_size_mean": 0.1886271822049501, + "cell_size_std": 0.019449828879410054, + "coefficient_of_variation": 0.10311254480366772 + }, + "edge_utilization": 0.015384615384615385, + "edge_utilization_details": { + "corners_touched": 0, + "edges_touched": 1, + "corner_score": 0.0, + "edge_score": 0.038461538461538464 + }, + "density_variance": 0.430980461443845, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00015702109892411402, + "mean_density": 0.009490942956645227, + "cv": 1.3202908007705492 + }, + "packing_efficiency": 0.4059372768768489, + "packing_efficiency_details": { + "total_area": 0.4059372768768489, + "square_area": 1.0, + "efficiency": 0.4059372768768489, + "relative_to_estimated_best": 0.4832586629486296 + }, + "radius_distribution": 0.9947372351472321, + "radius_distribution_details": { + "mean": 0.06569144013415244, + "std": 0.025581205857377314, + "min": 0.022404293688511857, + "max": 0.10710006643052564, + "range": 0.08469577274201379, + "small_count": 10, + "medium_count": 8, + "large_count": 8, + "diversity_score": 0.9947372351472321 + }, + "gap_analysis": 0.4056, + "gap_analysis_details": { + "covered_samples": 1014, + "total_samples": 2500, + "coverage": 0.4056, + "gap_ratio": 0.5944 + }, + "geometric_quality": 0.6915086619257171, + "geometric_quality_details": { + "num_triangles": 39, + "avg_triangle_quality": 0.6915086619257171, + "min_quality": 0.3811812499312437, + "max_quality": 0.7288689868556625 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..5743a11dab037f14c22daa7bdffe146c4080933a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.7080 + + Auxiliary Metrics: + • spatial_uniformity: 0.907 + • edge_utilization: 0.015 + • density_variance: 0.431 + • packing_efficiency: 0.406 + • radius_distribution: 0.995 + • gap_analysis: 0.406 + • geometric_quality: 0.692 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.7080 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.907 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.015 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.431 + → Balance circle density across different regions + • Area utilization efficiency: 0.406 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.406 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.995 + • Delaunay triangulation quality: 0.692 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 0/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 59.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..24b67373292d777302e300dc5a753ededbbf4126 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.7079774434879635, + "public": { + "centers_str": " centers[0] = (0.1250, 0.1250)\n centers[1] = (0.1250, 0.3750)\n centers[2] = (0.1250, 0.6250)\n centers[3] = (0.1250, 0.8750)\n centers[4] = (0.3750, 0.1250)\n centers[5] = (0.3750, 0.3750)\n centers[6] = (0.3750, 0.6250)\n centers[7] = (0.3750, 0.8750)\n centers[8] = (0.6250, 0.1250)\n centers[9] = (0.6250, 0.3750)\n centers[10] = (0.6250, 0.6250)\n centers[11] = (0.6250, 0.8750)\n centers[12] = (0.8750, 0.1250)\n centers[13] = (0.8750, 0.3750)\n centers[14] = (0.8750, 0.6250)\n centers[15] = (0.8750, 0.8750)\n centers[16] = (0.2500, 0.2500)\n centers[17] = (0.2500, 0.5000)\n centers[18] = (0.2500, 0.7500)\n centers[19] = (0.5000, 0.2500)\n centers[20] = (0.5000, 0.5000)\n centers[21] = (0.5000, 0.7500)\n centers[22] = (0.7500, 0.2500)\n centers[23] = (0.7500, 0.5000)\n centers[24] = (0.7500, 0.7500)\n centers[25] = (0.0500, 0.5000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9065258161650044, + "aux_edge_utilization": 0.015384615384615385, + "aux_density_variance": 0.430980461443845, + "aux_packing_efficiency": 0.4059372768768489, + "aux_radius_distribution": 0.9947372351472321, + "aux_gap_analysis": 0.4056, + "aux_geometric_quality": 0.6915086619257171 + }, + "private": { + "reported_sum_of_radii": 1.7079774434879635 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.7080\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.907\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.015\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.431\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.406\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.406\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.995\n \u2022 Delaunay triangulation quality: 0.692\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 0/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 59.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_4/results/packing_viz.png", + "execution_time_mean": 0.0019766180776059628, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f81fec8c4f895f6e9fff176f7572ecb8e29df681 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..17585e2b99fe4c1b63706be0c0555039c23e74ad --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/edit.diff @@ -0,0 +1,121 @@ +--- a/original.py ++++ b/original.py +@@ -1,110 +1,113 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. ++ # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, ++ # it might get higher priority during the iterative radius adjustment, ++ # potentially leading to a larger final radius for this key circle. ++ centers[k] = [0.5, 0.5] ++ k += 1 ++ ++ # 2. Then place the remaining 24 circles from a 5x5 grid, skipping the true center ++ # as it has already been placed. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 +- +- # 2. Place the central (0.5, 0.5) circle as the 25th circle. +- # This configuration proved more effective than splitting the central space. +- centers[k] = [0.5, 0.5] +- k += 1 + + # 3. Place the 26th circle in an interstitial position (0.2, 0.2). + # This position has consistently been effective in filling gaps in the bottom-left quadrant. + centers[k] = [0.2, 0.2] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/main.py new file mode 100644 index 0000000000000000000000000000000000000000..d42bf77ab9887d3c96aee70cd5dec7963063e7e9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/main.py @@ -0,0 +1,113 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, + # it might get higher priority during the iterative radius adjustment, + # potentially leading to a larger final radius for this key circle. + centers[k] = [0.5, 0.5] + k += 1 + + # 2. Then place the remaining 24 circles from a 5x5 grid, skipping the true center + # as it has already been placed. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 3. Place the 26th circle in an interstitial position (0.2, 0.2). + # This position has consistently been effective in filling gaps in the bottom-left quadrant. + centers[k] = [0.2, 0.2] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/original.py new file mode 100644 index 0000000000000000000000000000000000000000..6cd5bcccdeead16697936db01ee7bf9da9dab106 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/original.py @@ -0,0 +1,110 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Place the central (0.5, 0.5) circle as the 25th circle. + # This configuration proved more effective than splitting the central space. + centers[k] = [0.5, 0.5] + k += 1 + + # 3. Place the 26th circle in an interstitial position (0.2, 0.2). + # This position has consistently been effective in filling gaps in the bottom-left quadrant. + centers[k] = [0.2, 0.2] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4adfedcd480df665cf51b1692c28b8a308dac0ed --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.016563043408265036, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5945770573984382, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00015713321944299457, + "mean_density": 0.01838373734927172, + "cv": 0.6818677874580005 + }, + "packing_efficiency": 0.5451034036877884, + "packing_efficiency_details": { + "total_area": 0.5451034036877884, + "square_area": 1.0, + "efficiency": 0.5451034036877884, + "relative_to_estimated_best": 0.6489326234378434 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07891138439474837, + "std": 0.021131120981011373, + "min": 0.009022455236442276, + "max": 0.101979732779552, + "range": 0.09295727754310971, + "small_count": 6, + "medium_count": 10, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5504, + "gap_analysis_details": { + "covered_samples": 1376, + "total_samples": 2500, + "coverage": 0.5504, + "gap_ratio": 0.4496 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..2114c3569e824a5f7e1b3d30292ba10427ad7be3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.0517 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.595 + • packing_efficiency: 0.545 + • radius_distribution: 0.977 + • gap_analysis: 0.550 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.0517 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.595 + • Area utilization efficiency: 0.545 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.550 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 45.0% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..1a2b64fcf13f3a0c25811fd82e2c0f43e0ffbfeb --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.051695994263458, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5945770573984382, + "aux_packing_efficiency": 0.5451034036877884, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5504, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.051695994263458 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.0517\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.595\n \u2022 Area utilization efficiency: 0.545\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.550\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 45.0% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/results/packing_viz.png", + "execution_time_mean": 0.005276530981063843, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..2d01e4165ebcba007c1b681b3768ff96cee299e6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_40/search_replace.txt @@ -0,0 +1,40 @@ + +prioritize_central_circle_fix + + + +The previous attempt to prioritize the central circle failed due to a mismatch in the `SEARCH` block. This is a corrected re-application of that strategy. + +The core idea remains: placing the central `(0.5, 0.5)` circle as the *first* element in the `centers` array (`centers[0]`). This gives it a "priority" during the iterative radius adjustment process in `compute_max_radii`. The proportional scaling algorithm often resolves overlaps by reducing the radii of circles involved. By having the central circle considered earlier and its radius established first, there's a chance it can better maintain its size against the pressure from surrounding circles. This could lead to a higher overall sum of radii, as the central circle often has the potential for a larger radius due to its central location. + + + +<<<<<<< SEARCH + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 2. Place the central (0.5, 0.5) circle as the 25th circle. + # This configuration proved more effective than splitting the central space. + centers[k] = [0.5, 0.5] + k += 1 +======= + # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, + # it might get higher priority during the iterative radius adjustment, + # potentially leading to a larger final radius for this key circle. + centers[k] = [0.5, 0.5] + k += 1 + + # 2. Then place the remaining 24 circles from a 5x5 grid, skipping the true center + # as it has already been placed. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6095654a6adb522d72cb98cfbc7156c5152603c5 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..ab421c4166b6678e37e3987d86b9ae11f56e5281 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/edit.diff @@ -0,0 +1,121 @@ +--- a/original.py ++++ b/original.py +@@ -1,110 +1,112 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + +- # Place 25 circles in a 5x5 grid ++ # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, ++ # it might get higher priority during the iterative radius adjustment, ++ # potentially leading to a larger final radius for this key circle. ++ centers[k] = [0.5, 0.5] ++ k += 1 ++ ++ # Place the remaining 24 circles from a 5x5 grid. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): +- # Skip the central (0.5, 0.5) position for now ++ # Skip the central (0.5, 0.5) position as it has already been placed + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 +- +- # Place the central (0.5, 0.5) circle as the 25th circle +- centers[k] = [0.5, 0.5] # k is now 24, so centers[24] +- k += 1 + + # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2) + # The bottom-left grid circle is at (0.1, 0.1). Its neighbors are (0.3, 0.1), (0.1, 0.3). + # Placing at (0.2, 0.2) aims to fill a gap and was the previous best interstitial. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # No clipping needed, as all centers are already within [0.1, 0.9] or [0.2, 0.2] + # which ensures they are within the unit square and allows for larger initial radii. + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) # Initialize radii to zero, then expand + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the radii have not changed significantly from the previous iteration, + # the system has stabilized. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/main.py new file mode 100644 index 0000000000000000000000000000000000000000..956ea58b6a1a4ccda52161a553a5d55a8dddf002 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/main.py @@ -0,0 +1,112 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, + # it might get higher priority during the iterative radius adjustment, + # potentially leading to a larger final radius for this key circle. + centers[k] = [0.5, 0.5] + k += 1 + + # Place the remaining 24 circles from a 5x5 grid. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position as it has already been placed + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2) + # The bottom-left grid circle is at (0.1, 0.1). Its neighbors are (0.3, 0.1), (0.1, 0.3). + # Placing at (0.2, 0.2) aims to fill a gap and was the previous best interstitial. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # No clipping needed, as all centers are already within [0.1, 0.9] or [0.2, 0.2] + # which ensures they are within the unit square and allows for larger initial radii. + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) # Initialize radii to zero, then expand + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the radii have not changed significantly from the previous iteration, + # the system has stabilized. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/original.py new file mode 100644 index 0000000000000000000000000000000000000000..3c4e5bc8b893f62b7b69aa5f133f29bc84188855 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/original.py @@ -0,0 +1,110 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Place 25 circles in a 5x5 grid + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + centers[k] = [0.5, 0.5] # k is now 24, so centers[24] + k += 1 + + # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2) + # The bottom-left grid circle is at (0.1, 0.1). Its neighbors are (0.3, 0.1), (0.1, 0.3). + # Placing at (0.2, 0.2) aims to fill a gap and was the previous best interstitial. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # No clipping needed, as all centers are already within [0.1, 0.9] or [0.2, 0.2] + # which ensures they are within the unit square and allows for larger initial radii. + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) # Initialize radii to zero, then expand + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the radii have not changed significantly from the previous iteration, + # the system has stabilized. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4adfedcd480df665cf51b1692c28b8a308dac0ed --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.016563043408265036, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5945770573984382, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00015713321944299457, + "mean_density": 0.01838373734927172, + "cv": 0.6818677874580005 + }, + "packing_efficiency": 0.5451034036877884, + "packing_efficiency_details": { + "total_area": 0.5451034036877884, + "square_area": 1.0, + "efficiency": 0.5451034036877884, + "relative_to_estimated_best": 0.6489326234378434 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07891138439474837, + "std": 0.021131120981011373, + "min": 0.009022455236442276, + "max": 0.101979732779552, + "range": 0.09295727754310971, + "small_count": 6, + "medium_count": 10, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5504, + "gap_analysis_details": { + "covered_samples": 1376, + "total_samples": 2500, + "coverage": 0.5504, + "gap_ratio": 0.4496 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..0249889e58a43ec14b13f2807b44cb0de3c08fa3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.0517 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.595 + • packing_efficiency: 0.545 + • radius_distribution: 0.977 + • gap_analysis: 0.550 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.0517 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.595 + • Area utilization efficiency: 0.545 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.550 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 45.0% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..f68b0f7b6b5e877088c9c89134df7c9467c15d41 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.051695994263458, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5945770573984382, + "aux_packing_efficiency": 0.5451034036877884, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5504, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.051695994263458 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.0517\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.595\n \u2022 Area utilization efficiency: 0.545\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.550\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 45.0% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/results/packing_viz.png", + "execution_time_mean": 0.0062116049230098724, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..812b13adbd04ac5c9041e17622994519b973a23f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_42/search_replace.txt @@ -0,0 +1,49 @@ + +reorder_center_circle + + + +The previous highest-scoring program (2.0517) explicitly placed the central (0.5, 0.5) circle at index `centers[0]`, before all other grid circles. The current program places the central circle at `centers[24]`. The auxiliary metrics feedback from the 2.0517 program highlighted that "placing it early in the array, it might get higher priority during the iterative radius adjustment, potentially leading to a larger final radius for this key circle." + +This change modifies the `construct_packing` function to place the central (0.5, 0.5) circle at index 0, followed by the remaining 24 grid circles, and then the interstitial (0.2, 0.2) circle. This reordering ensures the central circle's radius is established earlier in the `compute_max_radii` iteration, potentially leading to a larger overall sum of radii. This directly addresses the recommendation to "Experiment with the explicit ordering of central and interstitial circle definitions." + + + +<<<<<<< SEARCH + # Place 25 circles in a 5x5 grid + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + centers[k] = [0.5, 0.5] # k is now 24, so centers[24] + k += 1 +======= + # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, + # it might get higher priority during the iterative radius adjustment, + # potentially leading to a larger final radius for this key circle. + centers[k] = [0.5, 0.5] + k += 1 + + # Place the remaining 24 circles from a 5x5 grid. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position as it has already been placed + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..008a781162d5226f556b99a4f38700c713cb38af Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..aa2d17cc0a3cac31fa8104fb199981f17d931e7c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8900993170295558, + "spatial_uniformity_details": { + "cell_size_mean": 0.1939972141140709, + "cell_size_std": 0.02395286236883228, + "coefficient_of_variation": 0.12347013514986764 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.4929804499394205, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00016432230390095172, + "mean_density": 0.012463878712486737, + "cv": 1.0284780058172371 + }, + "packing_efficiency": 0.41228078374699056, + "packing_efficiency_details": { + "total_area": 0.41228078374699056, + "square_area": 1.0, + "efficiency": 0.41228078374699056, + "relative_to_estimated_best": 0.4908104568416555 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.06704711793813288, + "std": 0.0234969987700649, + "min": 0.023587410754030643, + "max": 0.09499999999999997, + "range": 0.07141258924596933, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.4096, + "gap_analysis_details": { + "covered_samples": 1024, + "total_samples": 2500, + "coverage": 0.4096, + "gap_ratio": 0.5904 + }, + "geometric_quality": 0.6667633084221363, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.6667633084221363, + "min_quality": 0.3317291072233185, + "max_quality": 0.7395649366522823 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..659a21bde79c940ced8497486daf5dd11bfbf1a1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.7432 + + Auxiliary Metrics: + • spatial_uniformity: 0.890 + • edge_utilization: 0.558 + • density_variance: 0.493 + • packing_efficiency: 0.412 + • radius_distribution: 0.977 + • gap_analysis: 0.410 + • geometric_quality: 0.667 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.7432 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.890 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.493 + → Balance circle density across different regions + • Area utilization efficiency: 0.412 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.410 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Radius size diversity: 0.977 + • Delaunay triangulation quality: 0.667 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 59.0% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..318f3bfcc28a9735a0ab5b164879d2a62a51e995 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.7432250663914548, + "public": { + "centers_str": " centers[0] = (0.0950, 0.0950)\n centers[1] = (0.2975, 0.0950)\n centers[2] = (0.5000, 0.0950)\n centers[3] = (0.7025, 0.0950)\n centers[4] = (0.9050, 0.0950)\n centers[5] = (0.0950, 0.2975)\n centers[6] = (0.2975, 0.2975)\n centers[7] = (0.5000, 0.2975)\n centers[8] = (0.7025, 0.2975)\n centers[9] = (0.9050, 0.2975)\n centers[10] = (0.0950, 0.5000)\n centers[11] = (0.2975, 0.5000)\n centers[12] = (0.7025, 0.5000)\n centers[13] = (0.9050, 0.5000)\n centers[14] = (0.0950, 0.7025)\n centers[15] = (0.2975, 0.7025)\n centers[16] = (0.5000, 0.7025)\n centers[17] = (0.7025, 0.7025)\n centers[18] = (0.9050, 0.7025)\n centers[19] = (0.0950, 0.9050)\n centers[20] = (0.2975, 0.9050)\n centers[21] = (0.5000, 0.9050)\n centers[22] = (0.7025, 0.9050)\n centers[23] = (0.9050, 0.9050)\n centers[24] = (0.2500, 0.2500)\n centers[25] = (0.7500, 0.7500)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8900993170295558, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.4929804499394205, + "aux_packing_efficiency": 0.41228078374699056, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.4096, + "aux_geometric_quality": 0.6667633084221363 + }, + "private": { + "reported_sum_of_radii": 1.7432250663914548 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.7432\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.890\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.493\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.412\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.410\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Radius size diversity: 0.977\n \u2022 Delaunay triangulation quality: 0.667\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 59.0% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_43/results/packing_viz.png", + "execution_time_mean": 0.0040350682102143764, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..da5342b900607cb44ff9054134d238cd9220762a Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4adfedcd480df665cf51b1692c28b8a308dac0ed --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.016563043408265036, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5945770573984382, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00015713321944299457, + "mean_density": 0.01838373734927172, + "cv": 0.6818677874580005 + }, + "packing_efficiency": 0.5451034036877884, + "packing_efficiency_details": { + "total_area": 0.5451034036877884, + "square_area": 1.0, + "efficiency": 0.5451034036877884, + "relative_to_estimated_best": 0.6489326234378434 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07891138439474837, + "std": 0.021131120981011373, + "min": 0.009022455236442276, + "max": 0.101979732779552, + "range": 0.09295727754310971, + "small_count": 6, + "medium_count": 10, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5504, + "gap_analysis_details": { + "covered_samples": 1376, + "total_samples": 2500, + "coverage": 0.5504, + "gap_ratio": 0.4496 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..e7cde701125e595b7e9bbcb064944c0e285557a7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.0517 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.595 + • packing_efficiency: 0.545 + • radius_distribution: 0.977 + • gap_analysis: 0.550 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.0517 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.595 + • Area utilization efficiency: 0.545 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.550 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 45.0% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..92bca43bb7c48a3a0d430cb8e8a77561623ce747 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.051695994263458, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5945770573984382, + "aux_packing_efficiency": 0.5451034036877884, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5504, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.051695994263458 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.0517\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.595\n \u2022 Area utilization efficiency: 0.545\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.550\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 45.0% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_45/results/packing_viz.png", + "execution_time_mean": 0.0063311997801065445, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a29d89e1127d6032dab1974b0954af447f89bc7f Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..d3fcd4de962e58fa89299e0c4813f303aaf3944d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5321553497859173, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00023008231524406688, + "mean_density": 0.017253545721657784, + "cv": 0.8791505157324713 + }, + "packing_efficiency": 0.5166642865652796, + "packing_efficiency_details": { + "total_area": 0.5166642865652796, + "square_area": 1.0, + "efficiency": 0.5166642865652796, + "relative_to_estimated_best": 0.6150765316253329 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07541299137659783, + "std": 0.0252634193391021, + "min": 0.03669894819221307, + "max": 0.12486579904517191, + "range": 0.08816685085295883, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5168, + "gap_analysis_details": { + "covered_samples": 1292, + "total_samples": 2500, + "coverage": 0.5168, + "gap_ratio": 0.48319999999999996 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..a3263164584a302e0d1b5f3d5994d1aea791a71e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.01 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9607 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.532 + • packing_efficiency: 0.517 + • radius_distribution: 0.977 + • gap_analysis: 0.517 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9607 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.532 + • Area utilization efficiency: 0.517 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.517 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 48.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..27b6054557885cd29fc004fb86010b810cb5cc8e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9607377757915438, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5321553497859173, + "aux_packing_efficiency": 0.5166642865652796, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5168, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9607377757915438 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9607\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.532\n \u2022 Area utilization efficiency: 0.517\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.517\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 48.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_46/results/packing_viz.png", + "execution_time_mean": 0.005079635884612799, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c04bae7307627b4f403cbf88328b711645fd2a6c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..6aa5e3b415c4d4f77146103584d7a477af589090 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9208384753892523, + "spatial_uniformity_details": { + "cell_size_mean": 0.20276132158617088, + "cell_size_std": 0.017430739328336532, + "coefficient_of_variation": 0.08596678649562813 + }, + "edge_utilization": 0.5884615384615384, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 9, + "corner_score": 0.75, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.5818217232972964, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00014115803541789402, + "mean_density": 0.016530319211928796, + "cv": 0.7187395381746944 + }, + "packing_efficiency": 0.5088896197164416, + "packing_efficiency_details": { + "total_area": 0.5088896197164416, + "square_area": 1.0, + "efficiency": 0.5088896197164416, + "relative_to_estimated_best": 0.6058209758529067 + }, + "radius_distribution": 0.9543725752531863, + "radius_distribution_details": { + "mean": 0.0765615584336515, + "std": 0.01919647299087856, + "min": 0.011554220048501781, + "max": 0.11193562888857453, + "range": 0.10038140884007275, + "small_count": 5, + "medium_count": 10, + "large_count": 11, + "diversity_score": 0.9543725752531863 + }, + "gap_analysis": 0.5192, + "gap_analysis_details": { + "covered_samples": 1298, + "total_samples": 2500, + "coverage": 0.5192, + "gap_ratio": 0.4808 + }, + "geometric_quality": 0.7041744789416251, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7041744789416251, + "min_quality": 0.6553672606119222, + "max_quality": 0.7089971635974943 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..cb32982411a5da6d2b104c7c927f5158d2123e31 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9906 + + Auxiliary Metrics: + • spatial_uniformity: 0.921 + • edge_utilization: 0.588 + • density_variance: 0.582 + • packing_efficiency: 0.509 + • radius_distribution: 0.954 + • gap_analysis: 0.519 + • geometric_quality: 0.704 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9906 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.921 + • Delaunay triangulation quality: 0.704 + +📊 Other Metrics: + • Boundary and corner utilization: 0.588 + • Spatial density uniformity across grid: 0.582 + • Area utilization efficiency: 0.509 + • Radius size diversity: 0.954 + • Area coverage (1 - gap ratio): 0.519 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 48.1% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..9c10e0702069bb8e9a2f5d041b1f61e8f0954f26 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.990600519274939, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0900, 0.0900)\n centers[2] = (0.2950, 0.0900)\n centers[3] = (0.5000, 0.0900)\n centers[4] = (0.7050, 0.0900)\n centers[5] = (0.9100, 0.0900)\n centers[6] = (0.0900, 0.2950)\n centers[7] = (0.2950, 0.2950)\n centers[8] = (0.5000, 0.2950)\n centers[9] = (0.7050, 0.2950)\n centers[10] = (0.9100, 0.2950)\n centers[11] = (0.0900, 0.5000)\n centers[12] = (0.2950, 0.5000)\n centers[13] = (0.7050, 0.5000)\n centers[14] = (0.9100, 0.5000)\n centers[15] = (0.0900, 0.7050)\n centers[16] = (0.2950, 0.7050)\n centers[17] = (0.5000, 0.7050)\n centers[18] = (0.7050, 0.7050)\n centers[19] = (0.9100, 0.7050)\n centers[20] = (0.0900, 0.9100)\n centers[21] = (0.2950, 0.9100)\n centers[22] = (0.5000, 0.9100)\n centers[23] = (0.7050, 0.9100)\n centers[24] = (0.9100, 0.9100)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9208384753892523, + "aux_edge_utilization": 0.5884615384615384, + "aux_density_variance": 0.5818217232972964, + "aux_packing_efficiency": 0.5088896197164416, + "aux_radius_distribution": 0.9543725752531863, + "aux_gap_analysis": 0.5192, + "aux_geometric_quality": 0.7041744789416251 + }, + "private": { + "reported_sum_of_radii": 1.990600519274939 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9906\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.921\n \u2022 Delaunay triangulation quality: 0.704\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.588\n \u2022 Spatial density uniformity across grid: 0.582\n \u2022 Area utilization efficiency: 0.509\n \u2022 Radius size diversity: 0.954\n \u2022 Area coverage (1 - gap ratio): 0.519\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 48.1% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_47/results/packing_viz.png", + "execution_time_mean": 0.004048914182931185, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b354259453ddbaa710143fb257d25414b18ef98c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..d71df3d8dd3f275ea8b7bcc1ee4d7a4e8edb8da7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9043200454039053, + "spatial_uniformity_details": { + "cell_size_mean": 0.1926721426249511, + "cell_size_std": 0.02038532933960765, + "coefficient_of_variation": 0.10580319996485338 + }, + "edge_utilization": 0.5269230769230768, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 5, + "corner_score": 0.75, + "edge_score": 0.19230769230769232 + }, + "density_variance": 0.4930547452390272, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00021472962652210743, + "mean_density": 0.01425213851495311, + "cv": 1.02817234730235 + }, + "packing_efficiency": 0.4629383855614497, + "packing_efficiency_details": { + "total_area": 0.4629383855614497, + "square_area": 1.0, + "efficiency": 0.4629383855614497, + "relative_to_estimated_best": 0.5511171256683924 + }, + "radius_distribution": 0.9986351900937254, + "radius_distribution_details": { + "mean": 0.07164407908835112, + "std": 0.023124361978148312, + "min": 0.03669894819221307, + "max": 0.1287732037068908, + "range": 0.09207425551467774, + "small_count": 9, + "medium_count": 9, + "large_count": 8, + "diversity_score": 0.9986351900937254 + }, + "gap_analysis": 0.4668, + "gap_analysis_details": { + "covered_samples": 1167, + "total_samples": 2500, + "coverage": 0.4668, + "gap_ratio": 0.5332 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..c9f31ddb2a29483e0a868d25326ccc07b00e720a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8627 + + Auxiliary Metrics: + • spatial_uniformity: 0.904 + • edge_utilization: 0.527 + • density_variance: 0.493 + • packing_efficiency: 0.463 + • radius_distribution: 0.999 + • gap_analysis: 0.467 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8627 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.904 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.493 + → Balance circle density across different regions + • Area utilization efficiency: 0.463 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.467 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.527 + • Radius size diversity: 0.999 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 53.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..9c90c428044f239a33d2cfe01ea0494f517ecd67 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.862746056297129, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.7000, 0.5000)\n centers[12] = (0.9000, 0.5000)\n centers[13] = (0.1000, 0.7000)\n centers[14] = (0.3000, 0.7000)\n centers[15] = (0.5000, 0.7000)\n centers[16] = (0.7000, 0.7000)\n centers[17] = (0.9000, 0.7000)\n centers[18] = (0.1000, 0.9000)\n centers[19] = (0.3000, 0.9000)\n centers[20] = (0.5000, 0.9000)\n centers[21] = (0.7000, 0.9000)\n centers[22] = (0.9000, 0.9000)\n centers[23] = (0.5000, 0.5000)\n centers[24] = (0.2000, 0.2000)\n centers[25] = (0.8000, 0.8000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9043200454039053, + "aux_edge_utilization": 0.5269230769230768, + "aux_density_variance": 0.4930547452390272, + "aux_packing_efficiency": 0.4629383855614497, + "aux_radius_distribution": 0.9986351900937254, + "aux_gap_analysis": 0.4668, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.862746056297129 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8627\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.904\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.493\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.463\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.467\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.527\n \u2022 Radius size diversity: 0.999\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 53.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_48/results/packing_viz.png", + "execution_time_mean": 0.004255295265465975, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3510b1dd67e283b546896ff147a380b5e2c09900 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..9d7162e81884a1cbb06aa53da686300c7e67058d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576736 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5261424497752976, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00020708924409982752, + "mean_density": 0.015978436533757218, + "cv": 0.9006259624690521 + }, + "packing_efficiency": 0.49240606516668184, + "packing_efficiency_details": { + "total_area": 0.49240606516668184, + "square_area": 1.0, + "efficiency": 0.49240606516668184, + "relative_to_estimated_best": 0.5861976966270022 + }, + "radius_distribution": 0.7543533534342522, + "radius_distribution_details": { + "mean": 0.07372908132592121, + "std": 0.024339193856461577, + "min": 0.03669894819221307, + "max": 0.10261558125579377, + "range": 0.0659166330635807, + "small_count": 12, + "medium_count": 1, + "large_count": 13, + "diversity_score": 0.7543533534342522 + }, + "gap_analysis": 0.496, + "gap_analysis_details": { + "covered_samples": 1240, + "total_samples": 2500, + "coverage": 0.496, + "gap_ratio": 0.504 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..99bd1b61438292c4c45c55ff90ce9a23b63eb72c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9170 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.526 + • packing_efficiency: 0.492 + • radius_distribution: 0.754 + • gap_analysis: 0.496 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9170 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.492 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.496 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.526 + • Radius size diversity: 0.754 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 50.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..0669403dfd0b58730dbd4f15b6cee85415ec127d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9169561144739513, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.1000, 0.3000)\n centers[2] = (0.1000, 0.5000)\n centers[3] = (0.1000, 0.7000)\n centers[4] = (0.1000, 0.9000)\n centers[5] = (0.3000, 0.1000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.3000, 0.5000)\n centers[8] = (0.3000, 0.7000)\n centers[9] = (0.3000, 0.9000)\n centers[10] = (0.5000, 0.1000)\n centers[11] = (0.5000, 0.3000)\n centers[12] = (0.5000, 0.5000)\n centers[13] = (0.5000, 0.7000)\n centers[14] = (0.5000, 0.9000)\n centers[15] = (0.7000, 0.1000)\n centers[16] = (0.7000, 0.3000)\n centers[17] = (0.7000, 0.5000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.7000, 0.9000)\n centers[20] = (0.9000, 0.1000)\n centers[21] = (0.9000, 0.3000)\n centers[22] = (0.9000, 0.5000)\n centers[23] = (0.9000, 0.7000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5261424497752976, + "aux_packing_efficiency": 0.49240606516668184, + "aux_radius_distribution": 0.7543533534342522, + "aux_gap_analysis": 0.496, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9169561144739513 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9170\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.492\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.496\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.526\n \u2022 Radius size diversity: 0.754\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 50.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_5/results/packing_viz.png", + "execution_time_mean": 0.004423549864441156, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1dfee73cd274319c9460421718181ae1bfac938d Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..7a7f2344444bf1e75e3333fdb0c2ed59857f127a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9042160599760599, + "spatial_uniformity_details": { + "cell_size_mean": 0.19254905698053887, + "cell_size_std": 0.02039679257827202, + "coefficient_of_variation": 0.10593036804331468 + }, + "edge_utilization": 0.3923076923076923, + "edge_utilization_details": { + "corners_touched": 2, + "edges_touched": 6, + "corner_score": 0.5, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.4859763005156244, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00020564336594797059, + "mean_density": 0.013557801388148615, + "cv": 1.0577135118296772 + }, + "packing_efficiency": 0.43984656594685256, + "packing_efficiency_details": { + "total_area": 0.43984656594685256, + "square_area": 1.0, + "efficiency": 0.43984656594685256, + "relative_to_estimated_best": 0.5236268642224435 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.06949918646559297, + "std": 0.023553499201909404, + "min": 0.03656021570306602, + "max": 0.12485078732635782, + "range": 0.08829057162329179, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.4384, + "gap_analysis_details": { + "covered_samples": 1096, + "total_samples": 2500, + "coverage": 0.4384, + "gap_ratio": 0.5616 + }, + "geometric_quality": 0.7069275507225639, + "geometric_quality_details": { + "num_triangles": 35, + "avg_triangle_quality": 0.7069275507225639, + "min_quality": 0.7066766407973692, + "max_quality": 0.7071069120159655 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..75a3118f9242ce41436db65845261b65a2199d23 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.36 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8070 + + Auxiliary Metrics: + • spatial_uniformity: 0.904 + • edge_utilization: 0.392 + • density_variance: 0.486 + • packing_efficiency: 0.440 + • radius_distribution: 0.977 + • gap_analysis: 0.438 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8070 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.904 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.392 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.486 + → Balance circle density across different regions + • Area utilization efficiency: 0.440 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.438 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.977 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 2/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 56.2% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..ae77d7065454cb811e4a5fca2870882914bbf8ce --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8069788481054174, + "public": { + "centers_str": " centers[0] = (0.1002, 0.1002)\n centers[1] = (0.3000, 0.1002)\n centers[2] = (0.5000, 0.1002)\n centers[3] = (0.7000, 0.1002)\n centers[4] = (0.8998, 0.1002)\n centers[5] = (0.1002, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.8998, 0.3000)\n centers[10] = (0.1002, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.8998, 0.5000)\n centers[14] = (0.1002, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.8998, 0.7000)\n centers[19] = (0.3000, 0.8998)\n centers[20] = (0.5000, 0.8998)\n centers[21] = (0.7000, 0.8998)\n centers[22] = (0.8998, 0.8998)\n centers[23] = (0.5000, 0.5000)\n centers[24] = (0.2000, 0.2000)\n centers[25] = (0.8000, 0.8000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9042160599760599, + "aux_edge_utilization": 0.3923076923076923, + "aux_density_variance": 0.4859763005156244, + "aux_packing_efficiency": 0.43984656594685256, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.4384, + "aux_geometric_quality": 0.7069275507225639 + }, + "private": { + "reported_sum_of_radii": 1.8069788481054174 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8070\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.904\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.392\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.486\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.440\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.438\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.977\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 2/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 56.2% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_51/results/packing_viz.png", + "execution_time_mean": 0.36316054593771696, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4016fe35145975ca258993488c0b9bd706855f7e Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..80599b74827aadaa83dff1766be341c805d3fe85 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/edit.diff @@ -0,0 +1,247 @@ +--- a/original.py ++++ b/original.py +@@ -1,113 +1,155 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" ++import numpy as np + +-import numpy as np ++class CirclePackingSolver: ++ """ ++ Encapsulates the logic for placing and sizing circles in a unit square. ++ This class provides a modular structure for defining initial center ++ configurations and applying an iterative relaxation algorithm to find ++ maximum non-overlapping radii. ++ """ ++ def __init__(self, n_circles): ++ """ ++ Initializes the solver with the target number of circles. ++ Args: ++ n_circles (int): The total number of circles to pack. ++ """ ++ self.n_circles = n_circles ++ self.centers = np.zeros((n_circles, 2)) ++ self.radii = np.zeros(n_circles) ++ ++ def _initialize_centers(self): ++ """ ++ Initializes the center points for the specified number of circles ++ based on a refined strategy. This strategy combines a modified 5x5 grid, ++ a central circle, and two interstitial circles to maximize the sum of radii. ++ """ ++ k = 0 # Current index for placing circles ++ ++ # Define grid parameters ++ grid_size = 5 ++ coords = np.linspace(0.1, 0.9, grid_size) # Evenly spaced coordinates for grid [0.1, 0.3, 0.5, 0.7, 0.9] ++ ++ # Strategy: ++ # 1. Start with a 5x5 grid (25 potential points). ++ # 2. Exclude the central grid point (0.5, 0.5) and one corner-adjacent grid point (0.1, 0.1). ++ # This leaves 23 grid points. ++ # 3. Add the central circle (0.5, 0.5) explicitly. ++ # 4. Add two interstitial circles at (0.2, 0.2) and (0.8, 0.8). ++ # Total circles: 23 (grid) + 1 (central) + 2 (interstitial) = 26. ++ ++ # Identify grid indices to exclude. Using (j_grid, i_grid) for (x, y) mapping. ++ # (2, 2) corresponds to (0.5, 0.5) ++ # (0, 0) corresponds to (0.1, 0.1) ++ excluded_grid_indices = {(2, 2), (0, 0)} ++ ++ # Place 23 circles from the modified 5x5 grid ++ for i_grid in range(grid_size): # Iterate over y-coordinates (rows) ++ for j_grid in range(grid_size): # Iterate over x-coordinates (columns) ++ if (j_grid, i_grid) not in excluded_grid_indices: ++ self.centers[k] = [coords[j_grid], coords[i_grid]] ++ k += 1 ++ ++ # Place the central circle explicitly. ++ # Its position in the array can influence the relaxation process. ++ self.centers[k] = [0.5, 0.5] ++ k += 1 ++ ++ # Place the two interstitial circles. ++ # These are chosen to fill significant gaps in the corners, ++ # addressing previous recommendations for better space utilization. ++ self.centers[k] = [0.2, 0.2] ++ k += 1 ++ self.centers[k] = [0.8, 0.8] ++ k += 1 ++ ++ # Ensure that exactly 'n_circles' have been placed. ++ assert k == self.n_circles, \ ++ f"Error: Expected {self.n_circles} circles, but {k} were placed during initialization." ++ ++ def _compute_max_radii(self, max_iterations=2000, tolerance=1e-8): ++ """ ++ Computes the maximum possible radii for each circle position such that ++ they do not overlap with each other and remain within the unit square. ++ This method employs an iterative relaxation approach for robust convergence. ++ ++ Args: ++ max_iterations (int): Maximum number of iterations for the relaxation. ++ tolerance (float): Convergence threshold for radii changes between iterations. ++ """ ++ n = self.n_circles ++ radii = np.zeros(n) ++ ++ # 1. Initialize radii based on the minimum distance to the square's borders. ++ # This ensures all circles are initially valid within the boundaries. ++ for i in range(n): ++ x, y = self.centers[i] ++ radii[i] = min(x, y, 1 - x, 1 - y) ++ ++ # 2. Iteratively adjust radii to resolve overlaps until convergence. ++ # In each iteration, pairs of overlapping circles are scaled down ++ # proportionally until they just touch, or until no overlaps exist. ++ for _ in range(max_iterations): ++ prev_radii = np.copy(radii) # Store radii from the previous iteration for convergence check ++ ++ # Iterate over all unique pairs of circles (i, j) ++ for i in range(n): ++ for j in range(i + 1, n): ++ # Calculate the Euclidean distance between the centers ++ dist = np.linalg.norm(self.centers[i] - self.centers[j]) ++ ++ # Check for overlap: if the sum of current radii exceeds the distance ++ if radii[i] + radii[j] > dist: ++ # Scale both radii proportionally so they just touch. ++ # This resolves the overlap while preserving their relative sizes. ++ # Handle potential division by zero if dist is extremely small (circles on top of each other) ++ scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor ++ ++ # Check for convergence: if the radii vector has not changed significantly, stop iterating. ++ if np.allclose(radii, prev_radii, atol=tolerance): ++ break ++ ++ self.radii = radii ++ ++ def solve(self): ++ """ ++ Orchestrates the entire circle packing process: initializes centers ++ and then computes their maximum non-overlapping radii. ++ ++ Returns: ++ Tuple[np.ndarray, np.ndarray]: ++ - centers: An array of shape (n_circles, 2) with (x, y) coordinates. ++ - radii: An array of shape (n_circles) with the radius of each circle. ++ """ ++ self._initialize_centers() ++ self._compute_max_radii() ++ return self.centers, self.radii + + + def construct_packing(): + """ +- Construct a specific arrangement of 26 circles in a unit square +- that attempts to maximize the sum of their radii. This version +- reinstates the high-performing strategy of a 5x5 grid with a specific +- center ordering and one interstitial circle, which previously yielded +- a primary score of 1.9607. ++ Constructs an arrangement of 26 circles in a unit square by delegating ++ to the CirclePackingSolver class. This function serves as the external ++ interface and adheres to the required input/output signature. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ +- n = 26 +- centers = np.zeros((n, 2)) +- k = 0 # current circle index +- +- # This placement strategy from prior successful experiments uses a specific +- # ordering to aid the relaxation process. +- # 1. Place 24 circles in a 5x5 grid, skipping the center. +- # 2. Place the central circle. +- # 3. Place the single interstitial circle. +- grid_size = 5 +- coords = np.linspace(0.1, 0.9, grid_size) # [0.1, 0.3, 0.5, 0.7, 0.9] +- +- # 1. Place 24 grid circles, explicitly skipping the center (0.5, 0.5). +- # Iterating 'i' for y-coordinates and 'j' for x-coordinates. +- for i in range(grid_size): # Iterate over y-indices +- for j in range(grid_size): # Iterate over x-indices +- if i == 2 and j == 2: # Skip the central position (0.5, 0.5) +- continue +- centers[k] = [coords[j], coords[i]] # Assign as [x, y] +- k += 1 +- +- # 2. Now add the central circle, which was skipped earlier. +- # This specific placement (at index 24) is crucial for the relaxation outcome. +- centers[k] = [0.5, 0.5] # k is now 24 +- k += 1 +- +- # 3. Finally, add the 26th interstitial circle into a known large gap. +- # This placement (at index 25) is also critical. +- centers[k] = [0.2, 0.2] # k is now 25 +- +- # Compute maximum valid radii for this specific configuration. +- radii = compute_max_radii(centers) ++ solver = CirclePackingSolver(n_circles=26) ++ centers, radii = solver.solve() + return centers, radii +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): +- """ +- Compute the maximum possible radii for each circle position +- such that they don't overlap and stay within the unit square. +- This function uses an iterative relaxation approach, with parameters +- tuned to prior successful runs. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates +- max_iterations: Maximum number of iterations for the relaxation process. +- tolerance: Minimum change in radii sum to consider for convergence. +- +- Returns: +- np.array of shape (n) with radius of each circle +- """ +- n = centers.shape[0] +- radii = np.zeros(n) +- +- # 1. Initialize radii based on the minimum distance to the square's borders. +- for i in range(n): +- x, y = centers[i] +- radii[i] = min(x, y, 1 - x, 1 - y) +- +- # 2. Iteratively adjust radii to resolve overlaps until convergence. +- # The number of iterations and tolerance are set to empirically +- # effective values from prior successful runs. +- for _ in range(max_iterations): +- prev_radii = np.copy(radii) +- +- # Iterate over all unique pairs of circles (i, j) to check for overlaps. +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.linalg.norm(centers[i] - centers[j]) +- +- # If the sum of radii exceeds the distance, they overlap. +- if radii[i] + radii[j] > dist: +- # Scale both radii proportionally so they just touch. This +- # preserves their size ratio while resolving the conflict. +- scale_factor = dist / (radii[i] + radii[j]) +- radii[i] *= scale_factor +- radii[j] *= scale_factor +- +- # After a full pass, check for convergence. If the radii vector has +- # not changed significantly, the system has stabilized. +- if np.allclose(radii, prev_radii, atol=tolerance): +- break +- +- return radii + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/main.py new file mode 100644 index 0000000000000000000000000000000000000000..c4e275cf3735ffa7fccf83810677d8af07f6ea6e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/main.py @@ -0,0 +1,155 @@ +# EVOLVE-BLOCK-START +import numpy as np + +class CirclePackingSolver: + """ + Encapsulates the logic for placing and sizing circles in a unit square. + This class provides a modular structure for defining initial center + configurations and applying an iterative relaxation algorithm to find + maximum non-overlapping radii. + """ + def __init__(self, n_circles): + """ + Initializes the solver with the target number of circles. + Args: + n_circles (int): The total number of circles to pack. + """ + self.n_circles = n_circles + self.centers = np.zeros((n_circles, 2)) + self.radii = np.zeros(n_circles) + + def _initialize_centers(self): + """ + Initializes the center points for the specified number of circles + based on a refined strategy. This strategy combines a modified 5x5 grid, + a central circle, and two interstitial circles to maximize the sum of radii. + """ + k = 0 # Current index for placing circles + + # Define grid parameters + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) # Evenly spaced coordinates for grid [0.1, 0.3, 0.5, 0.7, 0.9] + + # Strategy: + # 1. Start with a 5x5 grid (25 potential points). + # 2. Exclude the central grid point (0.5, 0.5) and one corner-adjacent grid point (0.1, 0.1). + # This leaves 23 grid points. + # 3. Add the central circle (0.5, 0.5) explicitly. + # 4. Add two interstitial circles at (0.2, 0.2) and (0.8, 0.8). + # Total circles: 23 (grid) + 1 (central) + 2 (interstitial) = 26. + + # Identify grid indices to exclude. Using (j_grid, i_grid) for (x, y) mapping. + # (2, 2) corresponds to (0.5, 0.5) + # (0, 0) corresponds to (0.1, 0.1) + excluded_grid_indices = {(2, 2), (0, 0)} + + # Place 23 circles from the modified 5x5 grid + for i_grid in range(grid_size): # Iterate over y-coordinates (rows) + for j_grid in range(grid_size): # Iterate over x-coordinates (columns) + if (j_grid, i_grid) not in excluded_grid_indices: + self.centers[k] = [coords[j_grid], coords[i_grid]] + k += 1 + + # Place the central circle explicitly. + # Its position in the array can influence the relaxation process. + self.centers[k] = [0.5, 0.5] + k += 1 + + # Place the two interstitial circles. + # These are chosen to fill significant gaps in the corners, + # addressing previous recommendations for better space utilization. + self.centers[k] = [0.2, 0.2] + k += 1 + self.centers[k] = [0.8, 0.8] + k += 1 + + # Ensure that exactly 'n_circles' have been placed. + assert k == self.n_circles, \ + f"Error: Expected {self.n_circles} circles, but {k} were placed during initialization." + + def _compute_max_radii(self, max_iterations=2000, tolerance=1e-8): + """ + Computes the maximum possible radii for each circle position such that + they do not overlap with each other and remain within the unit square. + This method employs an iterative relaxation approach for robust convergence. + + Args: + max_iterations (int): Maximum number of iterations for the relaxation. + tolerance (float): Convergence threshold for radii changes between iterations. + """ + n = self.n_circles + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + # This ensures all circles are initially valid within the boundaries. + for i in range(n): + x, y = self.centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + # In each iteration, pairs of overlapping circles are scaled down + # proportionally until they just touch, or until no overlaps exist. + for _ in range(max_iterations): + prev_radii = np.copy(radii) # Store radii from the previous iteration for convergence check + + # Iterate over all unique pairs of circles (i, j) + for i in range(n): + for j in range(i + 1, n): + # Calculate the Euclidean distance between the centers + dist = np.linalg.norm(self.centers[i] - self.centers[j]) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Scale both radii proportionally so they just touch. + # This resolves the overlap while preserving their relative sizes. + # Handle potential division by zero if dist is extremely small (circles on top of each other) + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check for convergence: if the radii vector has not changed significantly, stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + self.radii = radii + + def solve(self): + """ + Orchestrates the entire circle packing process: initializes centers + and then computes their maximum non-overlapping radii. + + Returns: + Tuple[np.ndarray, np.ndarray]: + - centers: An array of shape (n_circles, 2) with (x, y) coordinates. + - radii: An array of shape (n_circles) with the radius of each circle. + """ + self._initialize_centers() + self._compute_max_radii() + return self.centers, self.radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles in a unit square by delegating + to the CirclePackingSolver class. This function serves as the external + interface and adheres to the required input/output signature. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + solver = CirclePackingSolver(n_circles=26) + centers, radii = solver.solve() + return centers, radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/original.py new file mode 100644 index 0000000000000000000000000000000000000000..655de8ddf807fa3b288062c2c8753269f09a540c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/original.py @@ -0,0 +1,113 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. This version + reinstates the high-performing strategy of a 5x5 grid with a specific + center ordering and one interstitial circle, which previously yielded + a primary score of 1.9607. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # This placement strategy from prior successful experiments uses a specific + # ordering to aid the relaxation process. + # 1. Place 24 circles in a 5x5 grid, skipping the center. + # 2. Place the central circle. + # 3. Place the single interstitial circle. + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) # [0.1, 0.3, 0.5, 0.7, 0.9] + + # 1. Place 24 grid circles, explicitly skipping the center (0.5, 0.5). + # Iterating 'i' for y-coordinates and 'j' for x-coordinates. + for i in range(grid_size): # Iterate over y-indices + for j in range(grid_size): # Iterate over x-indices + if i == 2 and j == 2: # Skip the central position (0.5, 0.5) + continue + centers[k] = [coords[j], coords[i]] # Assign as [x, y] + k += 1 + + # 2. Now add the central circle, which was skipped earlier. + # This specific placement (at index 24) is crucial for the relaxation outcome. + centers[k] = [0.5, 0.5] # k is now 24 + k += 1 + + # 3. Finally, add the 26th interstitial circle into a known large gap. + # This placement (at index 25) is also critical. + centers[k] = [0.2, 0.2] # k is now 25 + + # Compute maximum valid radii for this specific configuration. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach, with parameters + tuned to prior successful runs. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + # The number of iterations and tolerance are set to empirically + # effective values from prior successful runs. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) to check for overlaps. + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If the sum of radii exceeds the distance, they overlap. + if radii[i] + radii[j] > dist: + # Scale both radii proportionally so they just touch. This + # preserves their size ratio while resolving the conflict. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass, check for convergence. If the radii vector has + # not changed significantly, the system has stabilized. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..fa80ac7578927e6378761d67637fd4c64033991a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9094396440175248, + "spatial_uniformity_details": { + "cell_size_mean": 0.19236106482095203, + "cell_size_std": 0.019154967250996698, + "coefficient_of_variation": 0.09957819254768514 + }, + "edge_utilization": 0.5423076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 6, + "corner_score": 0.75, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.5063932112191585, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00021329238850818416, + "mean_density": 0.014982848928144131, + "cv": 0.9747500121347735 + }, + "packing_efficiency": 0.465107507408804, + "packing_efficiency_details": { + "total_area": 0.465107507408804, + "square_area": 1.0, + "efficiency": 0.465107507408804, + "relative_to_estimated_best": 0.5536994135819095 + }, + "radius_distribution": 0.9903496169664631, + "radius_distribution_details": { + "mean": 0.07115601474557381, + "std": 0.025119467205767756, + "min": 0.02025745808026436, + "max": 0.12488417222450536, + "range": 0.104626714144241, + "small_count": 9, + "medium_count": 7, + "large_count": 10, + "diversity_score": 0.9903496169664631 + }, + "gap_analysis": 0.4624, + "gap_analysis_details": { + "covered_samples": 1156, + "total_samples": 2500, + "coverage": 0.4624, + "gap_ratio": 0.5376000000000001 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..05c84ae0393b77a78b700c1cc7e339f663708579 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8501 + + Auxiliary Metrics: + • spatial_uniformity: 0.909 + • edge_utilization: 0.542 + • density_variance: 0.506 + • packing_efficiency: 0.465 + • radius_distribution: 0.990 + • gap_analysis: 0.462 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8501 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.909 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.465 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.462 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.542 + • Spatial density uniformity across grid: 0.506 + • Radius size diversity: 0.990 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 53.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..ad91ff30eeba721d41ef3e922e5aa7091e7d8daa --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.8500563833849193, + "public": { + "centers_str": " centers[0] = (0.3000, 0.1000)\n centers[1] = (0.5000, 0.1000)\n centers[2] = (0.7000, 0.1000)\n centers[3] = (0.9000, 0.1000)\n centers[4] = (0.1000, 0.3000)\n centers[5] = (0.3000, 0.3000)\n centers[6] = (0.5000, 0.3000)\n centers[7] = (0.7000, 0.3000)\n centers[8] = (0.9000, 0.3000)\n centers[9] = (0.1000, 0.5000)\n centers[10] = (0.3000, 0.5000)\n centers[11] = (0.7000, 0.5000)\n centers[12] = (0.9000, 0.5000)\n centers[13] = (0.1000, 0.7000)\n centers[14] = (0.3000, 0.7000)\n centers[15] = (0.5000, 0.7000)\n centers[16] = (0.7000, 0.7000)\n centers[17] = (0.9000, 0.7000)\n centers[18] = (0.1000, 0.9000)\n centers[19] = (0.3000, 0.9000)\n centers[20] = (0.5000, 0.9000)\n centers[21] = (0.7000, 0.9000)\n centers[22] = (0.9000, 0.9000)\n centers[23] = (0.5000, 0.5000)\n centers[24] = (0.2000, 0.2000)\n centers[25] = (0.8000, 0.8000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9094396440175248, + "aux_edge_utilization": 0.5423076923076923, + "aux_density_variance": 0.5063932112191585, + "aux_packing_efficiency": 0.465107507408804, + "aux_radius_distribution": 0.9903496169664631, + "aux_gap_analysis": 0.4624, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.8500563833849193 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8501\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.909\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.465\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.462\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.542\n \u2022 Spatial density uniformity across grid: 0.506\n \u2022 Radius size diversity: 0.990\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 53.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/results/packing_viz.png", + "execution_time_mean": 0.002524078357964754, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..c4e275cf3735ffa7fccf83810677d8af07f6ea6e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_52/rewrite.txt @@ -0,0 +1,155 @@ +# EVOLVE-BLOCK-START +import numpy as np + +class CirclePackingSolver: + """ + Encapsulates the logic for placing and sizing circles in a unit square. + This class provides a modular structure for defining initial center + configurations and applying an iterative relaxation algorithm to find + maximum non-overlapping radii. + """ + def __init__(self, n_circles): + """ + Initializes the solver with the target number of circles. + Args: + n_circles (int): The total number of circles to pack. + """ + self.n_circles = n_circles + self.centers = np.zeros((n_circles, 2)) + self.radii = np.zeros(n_circles) + + def _initialize_centers(self): + """ + Initializes the center points for the specified number of circles + based on a refined strategy. This strategy combines a modified 5x5 grid, + a central circle, and two interstitial circles to maximize the sum of radii. + """ + k = 0 # Current index for placing circles + + # Define grid parameters + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) # Evenly spaced coordinates for grid [0.1, 0.3, 0.5, 0.7, 0.9] + + # Strategy: + # 1. Start with a 5x5 grid (25 potential points). + # 2. Exclude the central grid point (0.5, 0.5) and one corner-adjacent grid point (0.1, 0.1). + # This leaves 23 grid points. + # 3. Add the central circle (0.5, 0.5) explicitly. + # 4. Add two interstitial circles at (0.2, 0.2) and (0.8, 0.8). + # Total circles: 23 (grid) + 1 (central) + 2 (interstitial) = 26. + + # Identify grid indices to exclude. Using (j_grid, i_grid) for (x, y) mapping. + # (2, 2) corresponds to (0.5, 0.5) + # (0, 0) corresponds to (0.1, 0.1) + excluded_grid_indices = {(2, 2), (0, 0)} + + # Place 23 circles from the modified 5x5 grid + for i_grid in range(grid_size): # Iterate over y-coordinates (rows) + for j_grid in range(grid_size): # Iterate over x-coordinates (columns) + if (j_grid, i_grid) not in excluded_grid_indices: + self.centers[k] = [coords[j_grid], coords[i_grid]] + k += 1 + + # Place the central circle explicitly. + # Its position in the array can influence the relaxation process. + self.centers[k] = [0.5, 0.5] + k += 1 + + # Place the two interstitial circles. + # These are chosen to fill significant gaps in the corners, + # addressing previous recommendations for better space utilization. + self.centers[k] = [0.2, 0.2] + k += 1 + self.centers[k] = [0.8, 0.8] + k += 1 + + # Ensure that exactly 'n_circles' have been placed. + assert k == self.n_circles, \ + f"Error: Expected {self.n_circles} circles, but {k} were placed during initialization." + + def _compute_max_radii(self, max_iterations=2000, tolerance=1e-8): + """ + Computes the maximum possible radii for each circle position such that + they do not overlap with each other and remain within the unit square. + This method employs an iterative relaxation approach for robust convergence. + + Args: + max_iterations (int): Maximum number of iterations for the relaxation. + tolerance (float): Convergence threshold for radii changes between iterations. + """ + n = self.n_circles + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + # This ensures all circles are initially valid within the boundaries. + for i in range(n): + x, y = self.centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + # In each iteration, pairs of overlapping circles are scaled down + # proportionally until they just touch, or until no overlaps exist. + for _ in range(max_iterations): + prev_radii = np.copy(radii) # Store radii from the previous iteration for convergence check + + # Iterate over all unique pairs of circles (i, j) + for i in range(n): + for j in range(i + 1, n): + # Calculate the Euclidean distance between the centers + dist = np.linalg.norm(self.centers[i] - self.centers[j]) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Scale both radii proportionally so they just touch. + # This resolves the overlap while preserving their relative sizes. + # Handle potential division by zero if dist is extremely small (circles on top of each other) + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check for convergence: if the radii vector has not changed significantly, stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + self.radii = radii + + def solve(self): + """ + Orchestrates the entire circle packing process: initializes centers + and then computes their maximum non-overlapping radii. + + Returns: + Tuple[np.ndarray, np.ndarray]: + - centers: An array of shape (n_circles, 2) with (x, y) coordinates. + - radii: An array of shape (n_circles) with the radius of each circle. + """ + self._initialize_centers() + self._compute_max_radii() + return self.centers, self.radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles in a unit square by delegating + to the CirclePackingSolver class. This function serves as the external + interface and adheres to the required input/output signature. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + solver = CirclePackingSolver(n_circles=26) + centers, radii = solver.solve() + return centers, radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d3e396ba844285826515f483534b9a42d13a9bd6 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..c223191b2f4c7395f7d5804f6fbc3e56d2ad797c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/edit.diff @@ -0,0 +1,237 @@ +--- a/original.py ++++ b/original.py +@@ -1,193 +1,198 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + start_coord (float): The starting coordinate for linspace. + end_coord (float): The ending coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers. + For a GxG grid, there are (G-1)x(G-1) interstitial points, located at the center + of each square formed by four adjacent grid circles. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + start_coord (float): The starting coordinate of the grid. + end_coord (float): The ending coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + + def compute_max_radii(centers, max_sub_iterations=200, tolerance=1e-9, interstitial_idx=-1): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop and a heuristic for + the interstitial circle's initial radius. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_sub_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + interstitial_idx: The index of the interstitial circle, if any, to apply + a specific initial radius heuristic. Defaults to -1 (no specific heuristic). + + Returns: + np.array: An array of shape (n) with the radius of each circle. + """ + n = centers.shape[0] + radii = np.ones(n) + + # 1. Limit radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Apply heuristic for the interstitial circle's initial radius. + # This prevents the interstitial circle from being too large initially and + # forcing its neighbors to shrink too much, leading to better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + # A value of 0.05 has been found effective in previous iterations. + # This cap ensures the interstitial circle starts at a more realistic size. + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # 2. Iteratively limit by distance to other circles until radii converge. + for _ in range(max_sub_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If current radii would cause overlap (with a tolerance) + if radii[i] + radii[j] > dist + tolerance: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_radii_i = radii[i] + old_radii_j = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check if significant change occurred to determine convergence + if not changed and (abs(radii[i] - old_radii_i) > tolerance or \ + abs(radii[j] - old_radii_j) > tolerance): + changed = True + if not changed: + break # Radii have converged sufficiently + + return radii + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + +- This version uses a 5x5 main grid and systematically explores all +- possible interstitial positions between grid points to find the +- one that maximizes the total sum of radii for the 26th circle. ++ This version reverts to the successful "hollow grid" strategy. It uses a ++ 24-circle peripheral grid, a dedicated central circle, and then systematically ++ explores all possible interstitial positions for the 26th circle to find ++ the optimal placement. This combines a strong base configuration with a ++ systematic search for the final circle. + + Returns: +- Tuple of (centers, radii, sum_of_radii) ++ Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle +- sum_of_radii: Sum of all radii (this is not returned by the function itself, +- but the caller will calculate it from radii). + """ + n_circles = 26 + grid_size = 5 +- n_grid_circles = grid_size * grid_size + + # Define base grid parameters. +- # Using 0.1 and 0.9 as start/end coordinates for linspace has proven robust +- # for the 5x5 grid in previous iterations. + start_coord = 0.1 + end_coord = 0.9 + +- grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) ++ # 1. Generate all 25 points of a 5x5 grid. ++ all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + +- best_sum_radii = -1.0 # Initialize with a very low sum ++ # 2. Separate the central point from the 24 peripheral points. This relieves ++ # the extreme crowding of a full 5x5 grid. ++ center_coord_val = start_coord + (end_coord - start_coord) / (grid_size - 1) * (grid_size // 2) ++ center_point_coord = np.array([center_coord_val, center_coord_val]) ++ ++ peripheral_centers = [] ++ center_point = None ++ for center in all_grid_centers: ++ if np.allclose(center, center_point_coord): ++ center_point = center ++ else: ++ peripheral_centers.append(center) ++ peripheral_centers = np.array(peripheral_centers) ++ ++ # 3. Create the 25-circle base configuration. Placing the central circle first ++ # has proven to be a beneficial heuristic in the iterative relaxation process. ++ base_centers = np.vstack([center_point, peripheral_centers]) ++ ++ best_sum_radii = -1.0 + best_centers = None + best_radii = None + +- # This strategy is specifically for 26 circles: 25 on a grid + 1 interstitial. +- if n_grid_circles == n_circles - 1: +- candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) ++ # 4. Systematically explore candidate interstitial points for the 26th circle. ++ candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + +- # Systematically explore each candidate interstitial position. +- for interstitial_point in candidate_interstitial_points: +- # Combine the fixed grid centers with the current interstitial candidate +- current_centers = np.vstack([grid_centers, interstitial_point]) ++ for interstitial_point in candidate_interstitial_points: ++ # Combine the 25 base circles with the current interstitial candidate. ++ current_centers = np.vstack([base_centers, interstitial_point]) + +- # The interstitial circle is added as the last element, its index is n_grid_circles +- interstitial_idx = n_grid_circles ++ # The interstitial circle is added as the last element. ++ interstitial_idx = n_circles - 1 + +- current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) +- current_sum_radii = np.sum(current_radii) ++ current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) ++ current_sum_radii = np.sum(current_radii) + +- # Keep track of the configuration that yields the highest sum of radii +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii +- else: +- # Fallback for cases where the number of circles does not fit the 5x5 grid + 1 interstitial pattern. +- # This ensures the function is robust for general 'n', though its primary optimization +- # is for n=26 using the grid+interstitial strategy. +- # In this specific problem, n_circles is always 26, so this else block should not be hit. +- centers_for_radii = grid_centers[:n_circles] +- radii_for_radii = compute_max_radii(centers_for_radii) +- best_centers = centers_for_radii +- best_radii = radii_for_radii ++ # Keep track of the configuration that yields the highest sum of radii. ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = current_centers ++ best_radii = current_radii + + return best_centers, best_radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/main.py new file mode 100644 index 0000000000000000000000000000000000000000..85598e227b9898c90b6e27700a3550e55ba165f8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/main.py @@ -0,0 +1,198 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + start_coord (float): The starting coordinate for linspace. + end_coord (float): The ending coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers. + For a GxG grid, there are (G-1)x(G-1) interstitial points, located at the center + of each square formed by four adjacent grid circles. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + start_coord (float): The starting coordinate of the grid. + end_coord (float): The ending coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_sub_iterations=200, tolerance=1e-9, interstitial_idx=-1): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop and a heuristic for + the interstitial circle's initial radius. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_sub_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + interstitial_idx: The index of the interstitial circle, if any, to apply + a specific initial radius heuristic. Defaults to -1 (no specific heuristic). + + Returns: + np.array: An array of shape (n) with the radius of each circle. + """ + n = centers.shape[0] + radii = np.ones(n) + + # 1. Limit radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Apply heuristic for the interstitial circle's initial radius. + # This prevents the interstitial circle from being too large initially and + # forcing its neighbors to shrink too much, leading to better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + # A value of 0.05 has been found effective in previous iterations. + # This cap ensures the interstitial circle starts at a more realistic size. + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # 2. Iteratively limit by distance to other circles until radii converge. + for _ in range(max_sub_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If current radii would cause overlap (with a tolerance) + if radii[i] + radii[j] > dist + tolerance: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_radii_i = radii[i] + old_radii_j = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check if significant change occurred to determine convergence + if not changed and (abs(radii[i] - old_radii_i) > tolerance or \ + abs(radii[j] - old_radii_j) > tolerance): + changed = True + if not changed: + break # Radii have converged sufficiently + + return radii + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This version reverts to the successful "hollow grid" strategy. It uses a + 24-circle peripheral grid, a dedicated central circle, and then systematically + explores all possible interstitial positions for the 26th circle to find + the optimal placement. This combines a strong base configuration with a + systematic search for the final circle. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n_circles = 26 + grid_size = 5 + + # Define base grid parameters. + start_coord = 0.1 + end_coord = 0.9 + + # 1. Generate all 25 points of a 5x5 grid. + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + # 2. Separate the central point from the 24 peripheral points. This relieves + # the extreme crowding of a full 5x5 grid. + center_coord_val = start_coord + (end_coord - start_coord) / (grid_size - 1) * (grid_size // 2) + center_point_coord = np.array([center_coord_val, center_coord_val]) + + peripheral_centers = [] + center_point = None + for center in all_grid_centers: + if np.allclose(center, center_point_coord): + center_point = center + else: + peripheral_centers.append(center) + peripheral_centers = np.array(peripheral_centers) + + # 3. Create the 25-circle base configuration. Placing the central circle first + # has proven to be a beneficial heuristic in the iterative relaxation process. + base_centers = np.vstack([center_point, peripheral_centers]) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 4. Systematically explore candidate interstitial points for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + for interstitial_point in candidate_interstitial_points: + # Combine the 25 base circles with the current interstitial candidate. + current_centers = np.vstack([base_centers, interstitial_point]) + + # The interstitial circle is added as the last element. + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + # Keep track of the configuration that yields the highest sum of radii. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/original.py new file mode 100644 index 0000000000000000000000000000000000000000..c359fef83a19ac26918870369bbfad21de35bc4f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/original.py @@ -0,0 +1,193 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + start_coord (float): The starting coordinate for linspace. + end_coord (float): The ending coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers. + For a GxG grid, there are (G-1)x(G-1) interstitial points, located at the center + of each square formed by four adjacent grid circles. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + start_coord (float): The starting coordinate of the grid. + end_coord (float): The ending coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_sub_iterations=200, tolerance=1e-9, interstitial_idx=-1): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version includes an iterative refinement loop and a heuristic for + the interstitial circle's initial radius. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_sub_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + interstitial_idx: The index of the interstitial circle, if any, to apply + a specific initial radius heuristic. Defaults to -1 (no specific heuristic). + + Returns: + np.array: An array of shape (n) with the radius of each circle. + """ + n = centers.shape[0] + radii = np.ones(n) + + # 1. Limit radii by distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Apply heuristic for the interstitial circle's initial radius. + # This prevents the interstitial circle from being too large initially and + # forcing its neighbors to shrink too much, leading to better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + # A value of 0.05 has been found effective in previous iterations. + # This cap ensures the interstitial circle starts at a more realistic size. + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + + # 2. Iteratively limit by distance to other circles until radii converge. + for _ in range(max_sub_iterations): + changed = False + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If current radii would cause overlap (with a tolerance) + if radii[i] + radii[j] > dist + tolerance: + # Scale both radii proportionally to just touch + scale_factor = dist / (radii[i] + radii[j]) + + old_radii_i = radii[i] + old_radii_j = radii[j] + + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Check if significant change occurred to determine convergence + if not changed and (abs(radii[i] - old_radii_i) > tolerance or \ + abs(radii[j] - old_radii_j) > tolerance): + changed = True + if not changed: + break # Radii have converged sufficiently + + return radii + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This version uses a 5x5 main grid and systematically explores all + possible interstitial positions between grid points to find the + one that maximizes the total sum of radii for the 26th circle. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii (this is not returned by the function itself, + but the caller will calculate it from radii). + """ + n_circles = 26 + grid_size = 5 + n_grid_circles = grid_size * grid_size + + # Define base grid parameters. + # Using 0.1 and 0.9 as start/end coordinates for linspace has proven robust + # for the 5x5 grid in previous iterations. + start_coord = 0.1 + end_coord = 0.9 + + grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + best_sum_radii = -1.0 # Initialize with a very low sum + best_centers = None + best_radii = None + + # This strategy is specifically for 26 circles: 25 on a grid + 1 interstitial. + if n_grid_circles == n_circles - 1: + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # Systematically explore each candidate interstitial position. + for interstitial_point in candidate_interstitial_points: + # Combine the fixed grid centers with the current interstitial candidate + current_centers = np.vstack([grid_centers, interstitial_point]) + + # The interstitial circle is added as the last element, its index is n_grid_circles + interstitial_idx = n_grid_circles + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + # Keep track of the configuration that yields the highest sum of radii + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + else: + # Fallback for cases where the number of circles does not fit the 5x5 grid + 1 interstitial pattern. + # This ensures the function is robust for general 'n', though its primary optimization + # is for n=26 using the grid+interstitial strategy. + # In this specific problem, n_circles is always 26, so this else block should not be hit. + centers_for_radii = grid_centers[:n_circles] + radii_for_radii = compute_max_radii(centers_for_radii) + best_centers = centers_for_radii + best_radii = radii_for_radii + + return best_centers, best_radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..17fc68f59fe0e51035fd56cdb102a4e36cb5d093 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.01751952657876505, + "coefficient_of_variation": 0.08804167661183819 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6411589929968947, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001309434723906757, + "mean_density": 0.020445869141094194, + "cv": 0.5596755421394257 + }, + "packing_efficiency": 0.5720719944931837, + "packing_efficiency_details": { + "total_area": 0.5720719944931837, + "square_area": 1.0, + "efficiency": 0.5720719944931837, + "relative_to_estimated_best": 0.6810380886823616 + }, + "radius_distribution": 0.982944883585438, + "radius_distribution_details": { + "mean": 0.08110499592193551, + "std": 0.020631978544457516, + "min": 0.009022455236442272, + "max": 0.101979732779552, + "range": 0.09295727754310973, + "small_count": 7, + "medium_count": 8, + "large_count": 11, + "diversity_score": 0.982944883585438 + }, + "gap_analysis": 0.576, + "gap_analysis_details": { + "covered_samples": 1440, + "total_samples": 2500, + "coverage": 0.576, + "gap_ratio": 0.42400000000000004 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..789b37dca3887cb4c9d11db3269f1709beac3236 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.03 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1087 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.641 + • packing_efficiency: 0.572 + • radius_distribution: 0.983 + • gap_analysis: 0.576 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1087 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.641 + • Area utilization efficiency: 0.572 + • Radius size diversity: 0.983 + • Area coverage (1 - gap ratio): 0.576 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 42.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..9dd887b0d9cb736464f716bdd425483e672e0d4e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1087298939703234, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6411589929968947, + "aux_packing_efficiency": 0.5720719944931837, + "aux_radius_distribution": 0.982944883585438, + "aux_gap_analysis": 0.576, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1087298939703234 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1087\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.641\n \u2022 Area utilization efficiency: 0.572\n \u2022 Radius size diversity: 0.983\n \u2022 Area coverage (1 - gap ratio): 0.576\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 42.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/results/packing_viz.png", + "execution_time_mean": 0.032667221035808325, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..d35547caaca6e813a4c2507f1f2e00acbb1fc672 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_54/search_replace.txt @@ -0,0 +1,153 @@ + +revert_to_hollow_grid_strategy + + + +The current program scores poorly (1.92) because it uses a full 5x5 grid (25 circles) as a base, which is too constrained, especially at the center. The visualization confirms that central circles are tiny, leading to low area utilization and a low sum of radii. + +Previous successful versions (score ~2.05) used a "hollow grid" structure: 24 peripheral circles from a 5x5 grid, one circle placed at the center `(0.5, 0.5)`, and one interstitial circle. + +This edit reverts to this more effective `24 (peripheral) + 1 (central) + 1 (interstitial)` structure. I will modify `construct_packing` to: +1. Generate the 24 peripheral circles of a 5x5 grid by filtering out the center point. +2. Create a 25-circle base configuration by combining these 24 peripheral circles with the central circle at `(0.5, 0.5)`. The central circle is placed first in the array, as this ordering proved beneficial for the iterative solver in prior experiments. +3. Retain the current logic of systematically searching all 16 interstitial grid locations for the 26th circle to find the one that maximizes the sum of radii. + +This change combines the superior base configuration of previous high-scoring solutions with the systematic search for the best interstitial point from the current code, aiming to recover performance by relieving central congestion and creating a more balanced packing. + + + +<<<<<<< SEARCH +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This version uses a 5x5 main grid and systematically explores all + possible interstitial positions between grid points to find the + one that maximizes the total sum of radii for the 26th circle. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii (this is not returned by the function itself, + but the caller will calculate it from radii). + """ + n_circles = 26 + grid_size = 5 + n_grid_circles = grid_size * grid_size + + # Define base grid parameters. + # Using 0.1 and 0.9 as start/end coordinates for linspace has proven robust + # for the 5x5 grid in previous iterations. + start_coord = 0.1 + end_coord = 0.9 + + grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + best_sum_radii = -1.0 # Initialize with a very low sum + best_centers = None + best_radii = None + + # This strategy is specifically for 26 circles: 25 on a grid + 1 interstitial. + if n_grid_circles == n_circles - 1: + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + # Systematically explore each candidate interstitial position. + for interstitial_point in candidate_interstitial_points: + # Combine the fixed grid centers with the current interstitial candidate + current_centers = np.vstack([grid_centers, interstitial_point]) + + # The interstitial circle is added as the last element, its index is n_grid_circles + interstitial_idx = n_grid_circles + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + # Keep track of the configuration that yields the highest sum of radii + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + else: + # Fallback for cases where the number of circles does not fit the 5x5 grid + 1 interstitial pattern. + # This ensures the function is robust for general 'n', though its primary optimization + # is for n=26 using the grid+interstitial strategy. + # In this specific problem, n_circles is always 26, so this else block should not be hit. + centers_for_radii = grid_centers[:n_circles] + radii_for_radii = compute_max_radii(centers_for_radii) + best_centers = centers_for_radii + best_radii = radii_for_radii + + return best_centers, best_radii +======= +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This version reverts to the successful "hollow grid" strategy. It uses a + 24-circle peripheral grid, a dedicated central circle, and then systematically + explores all possible interstitial positions for the 26th circle to find + the optimal placement. This combines a strong base configuration with a + systematic search for the final circle. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n_circles = 26 + grid_size = 5 + + # Define base grid parameters. + start_coord = 0.1 + end_coord = 0.9 + + # 1. Generate all 25 points of a 5x5 grid. + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + # 2. Separate the central point from the 24 peripheral points. This relieves + # the extreme crowding of a full 5x5 grid. + center_coord_val = start_coord + (end_coord - start_coord) / (grid_size - 1) * (grid_size // 2) + center_point_coord = np.array([center_coord_val, center_coord_val]) + + peripheral_centers = [] + center_point = None + for center in all_grid_centers: + if np.allclose(center, center_point_coord): + center_point = center + else: + peripheral_centers.append(center) + peripheral_centers = np.array(peripheral_centers) + + # 3. Create the 25-circle base configuration. Placing the central circle first + # has proven to be a beneficial heuristic in the iterative relaxation process. + base_centers = np.vstack([center_point, peripheral_centers]) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 4. Systematically explore candidate interstitial points for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + for interstitial_point in candidate_interstitial_points: + # Combine the 25 base circles with the current interstitial candidate. + current_centers = np.vstack([base_centers, interstitial_point]) + + # The interstitial circle is added as the last element. + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + # Keep track of the configuration that yields the highest sum of radii. + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ec947dda39959f9b349b9ad2370a83486427de96 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..19f2373c8d84ab592579b7231d14b0557ddc6179 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.01751952657876505, + "coefficient_of_variation": 0.08804167661183819 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6411589929968947, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001309434723906757, + "mean_density": 0.020445869141094194, + "cv": 0.5596755421394257 + }, + "packing_efficiency": 0.5720719944931837, + "packing_efficiency_details": { + "total_area": 0.5720719944931837, + "square_area": 1.0, + "efficiency": 0.5720719944931837, + "relative_to_estimated_best": 0.6810380886823616 + }, + "radius_distribution": 0.982944883585438, + "radius_distribution_details": { + "mean": 0.08110499592193551, + "std": 0.020631978544457513, + "min": 0.009022455236442276, + "max": 0.101979732779552, + "range": 0.09295727754310971, + "small_count": 7, + "medium_count": 8, + "large_count": 11, + "diversity_score": 0.982944883585438 + }, + "gap_analysis": 0.576, + "gap_analysis_details": { + "covered_samples": 1440, + "total_samples": 2500, + "coverage": 0.576, + "gap_ratio": 0.42400000000000004 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..682824d990badd0187f31ff3bc2b118c740f8f25 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.06 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1087 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.641 + • packing_efficiency: 0.572 + • radius_distribution: 0.983 + • gap_analysis: 0.576 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1087 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.641 + • Area utilization efficiency: 0.572 + • Radius size diversity: 0.983 + • Area coverage (1 - gap ratio): 0.576 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 42.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..cd36467cf887f3395882974ed663735b59eb208c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1087298939703234, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6411589929968947, + "aux_packing_efficiency": 0.5720719944931837, + "aux_radius_distribution": 0.982944883585438, + "aux_gap_analysis": 0.576, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1087298939703234 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1087\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.641\n \u2022 Area utilization efficiency: 0.572\n \u2022 Radius size diversity: 0.983\n \u2022 Area coverage (1 - gap ratio): 0.576\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 42.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_55/results/packing_viz.png", + "execution_time_mean": 0.057807477191090584, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d1410e99740bff7054a0c320e29c2051d000114d Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..26f376922c36b23cbd08f8b3bc7deb8758c18c3d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/edit.diff @@ -0,0 +1,123 @@ +--- a/original.py ++++ b/original.py +@@ -1,113 +1,113 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + +- # This strategy improves central packing density by replacing the single +- # center circle of a 5x5 grid with two smaller, symmetrically placed circles. ++ # This strategy widens the grid to improve edge utilization and give more ++ # space to the central circle, which was previously too small. + grid_size = 5 +- x_coords = np.linspace(0.1, 0.9, grid_size) +- y_coords = np.linspace(0.1, 0.9, grid_size) ++ x_coords = np.linspace(0.05, 0.95, grid_size) ++ y_coords = np.linspace(0.05, 0.95, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, + # it might get higher priority during the iterative radius adjustment, + # potentially leading to a larger final radius for this key circle. + centers[k] = [0.5, 0.5] + k += 1 + + # 2. Then place the remaining 24 circles from a 5x5 grid, skipping the true center + # as it has already been placed. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + +- # 3. Place the 26th circle in an interstitial position (0.2, 0.2). +- # This position has consistently been effective in filling gaps in the bottom-left quadrant. +- centers[k] = [0.2, 0.2] ++ # 3. Place the 26th circle in an interstitial position relative to the new, wider grid. ++ # The new position (0.1625, 0.1625) is the center of the bottom-left grid cell. ++ centers[k] = [0.1625, 0.1625] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/main.py new file mode 100644 index 0000000000000000000000000000000000000000..5fc1da9e306f11a54465839bff78aa15dcc787e2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/main.py @@ -0,0 +1,113 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # This strategy widens the grid to improve edge utilization and give more + # space to the central circle, which was previously too small. + grid_size = 5 + x_coords = np.linspace(0.05, 0.95, grid_size) + y_coords = np.linspace(0.05, 0.95, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, + # it might get higher priority during the iterative radius adjustment, + # potentially leading to a larger final radius for this key circle. + centers[k] = [0.5, 0.5] + k += 1 + + # 2. Then place the remaining 24 circles from a 5x5 grid, skipping the true center + # as it has already been placed. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 3. Place the 26th circle in an interstitial position relative to the new, wider grid. + # The new position (0.1625, 0.1625) is the center of the bottom-left grid cell. + centers[k] = [0.1625, 0.1625] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/original.py new file mode 100644 index 0000000000000000000000000000000000000000..d42bf77ab9887d3c96aee70cd5dec7963063e7e9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/original.py @@ -0,0 +1,113 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + # 1. Place 24 circles from a 5x5 grid, skipping the center (0.5, 0.5) + # to relieve the most constrained region of the packing. + # 1. Place the central (0.5, 0.5) circle first. By placing it early in the array, + # it might get higher priority during the iterative radius adjustment, + # potentially leading to a larger final radius for this key circle. + centers[k] = [0.5, 0.5] + k += 1 + + # 2. Then place the remaining 24 circles from a 5x5 grid, skipping the true center + # as it has already been placed. + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Corresponds to (0.5, 0.5) + continue + centers[k] = [x_coords[j], y_coords[i]] + k += 1 + + # 3. Place the 26th circle in an interstitial position (0.2, 0.2). + # This position has consistently been effective in filling gaps in the bottom-left quadrant. + centers[k] = [0.2, 0.2] + + # Compute maximum valid radii for this configuration using an iterative method + # to ensure overlaps are resolved more thoroughly and radii are maximized. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + if radii[i] + radii[j] > dist: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the sum of radii has not changed significantly from the previous iteration, + # it means the system has stabilized, and we can stop iterating. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..35bc8a6c33b2c53dd0158a656319feeed160f6c4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225121725, + "spatial_uniformity_details": { + "cell_size_mean": 0.22267035044834166, + "cell_size_std": 0.01863342383429819, + "coefficient_of_variation": 0.08368165637274366 + }, + "edge_utilization": 0.7846153846153846, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 12, + "corner_score": 1.0, + "edge_score": 0.46153846153846156 + }, + "density_variance": 0.3796456288408499, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001717195333915359, + "mean_density": 0.00801951959445715, + "cv": 1.6340353319837826 + }, + "packing_efficiency": 0.35277938649311974, + "packing_efficiency_details": { + "total_area": 0.35277938649311974, + "square_area": 1.0, + "efficiency": 0.35277938649311974, + "relative_to_estimated_best": 0.41997546011085685 + }, + "radius_distribution": 0.9679654790068056, + "radius_distribution_details": { + "mean": 0.06139204510409094, + "std": 0.02345175334513004, + "min": 0.02535729578859452, + "max": 0.12351461317718972, + "range": 0.09815731738859519, + "small_count": 7, + "medium_count": 12, + "large_count": 7, + "diversity_score": 0.9679654790068056 + }, + "gap_analysis": 0.3568, + "gap_analysis_details": { + "covered_samples": 892, + "total_samples": 2500, + "coverage": 0.3568, + "gap_ratio": 0.6432 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865474, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..a1f7965d9e9affb318a4556d8bcd3f766907259c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/job_log.out @@ -0,0 +1,75 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.5962 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.785 + • density_variance: 0.380 + • packing_efficiency: 0.353 + • radius_distribution: 0.968 + • gap_analysis: 0.357 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.5962 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Boundary and corner utilization: 0.785 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Spatial density uniformity across grid: 0.380 + → Balance circle density across different regions + • Area utilization efficiency: 0.353 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.357 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.968 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 64.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..64a60e49122e19734c384bc6d7ababbe2140edb1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.5961931727063645, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0500, 0.0500)\n centers[2] = (0.2750, 0.0500)\n centers[3] = (0.5000, 0.0500)\n centers[4] = (0.7250, 0.0500)\n centers[5] = (0.9500, 0.0500)\n centers[6] = (0.0500, 0.2750)\n centers[7] = (0.2750, 0.2750)\n centers[8] = (0.5000, 0.2750)\n centers[9] = (0.7250, 0.2750)\n centers[10] = (0.9500, 0.2750)\n centers[11] = (0.0500, 0.5000)\n centers[12] = (0.2750, 0.5000)\n centers[13] = (0.7250, 0.5000)\n centers[14] = (0.9500, 0.5000)\n centers[15] = (0.0500, 0.7250)\n centers[16] = (0.2750, 0.7250)\n centers[17] = (0.5000, 0.7250)\n centers[18] = (0.7250, 0.7250)\n centers[19] = (0.9500, 0.7250)\n centers[20] = (0.0500, 0.9500)\n centers[21] = (0.2750, 0.9500)\n centers[22] = (0.5000, 0.9500)\n centers[23] = (0.7250, 0.9500)\n centers[24] = (0.9500, 0.9500)\n centers[25] = (0.1625, 0.1625)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225121725, + "aux_edge_utilization": 0.7846153846153846, + "aux_density_variance": 0.3796456288408499, + "aux_packing_efficiency": 0.35277938649311974, + "aux_radius_distribution": 0.9679654790068056, + "aux_gap_analysis": 0.3568, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.5961931727063645 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.5962\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Boundary and corner utilization: 0.785\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Spatial density uniformity across grid: 0.380\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.353\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.357\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.968\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 64.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/results/packing_viz.png", + "execution_time_mean": 0.003923471085727215, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..778f0e1d3267f87f8d33d7bf8aa4ca2e5b086644 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_56/search_replace.txt @@ -0,0 +1,50 @@ +My analysis of the current packing reveals two primary weaknesses, which are supported by the auxiliary metrics and the visualization: + +1. **Poor Grid Spacing:** The 5x5 grid is defined by `linspace(0.1, 0.9, 5)`. This leads to low `edge_utilization` (0.558) as the outermost circles are far from the boundary. More critically, it creates a very dense central region where the circle at `(0.5, 0.5)` is squeezed by eight neighbors, rendering it almost infinitesimally small as seen in the visualization. This is the main contributor to the high `unused space` (45%). + +2. **Suboptimal Interstitial Placement:** The 26th circle is hardcoded at `(0.2, 0.2)`. While this was effective for a previous grid, it's not necessarily optimal for the current one, and it certainly won't be for the improved grid I'm proposing. + +My proposed solution addresses both points in a cohesive manner: + +1. **Widen the Grid:** I will change the `linspace` range from `[0.1, 0.9]` to `[0.05, 0.95]`. This pushes the outer circles closer to the boundaries, which should improve `edge_utilization`. Crucially, it increases the step size between grid points from `0.2` to `0.225`. This increases the distance between the central circle and its neighbors, giving it more "breathing room" to expand and reduce the large central void. + +2. **Recenter the Interstitial Circle:** With the new grid, the four bottom-left grid points are `(0.05, 0.05)`, `(0.275, 0.05)`, `(0.05, 0.275)`, and `(0.275, 0.275)`. The geometric center of this cell is `(0.1625, 0.1625)`. I will move the 26th circle to this new, symmetrically optimal position. This ensures it is perfectly balanced with respect to its four closest neighbors, which is a more stable and efficient configuration than the arbitrary `(0.2, 0.2)`. + +These two changes work together to create a more balanced and efficient initial configuration, directly targeting the weaknesses identified by the metrics and visualization. + + +widen_grid_and_recenter_interstitial + + + +This edit addresses two key issues: poor grid spacing and suboptimal interstitial placement. + +First, the grid is widened from `linspace(0.1, 0.9, ...)` to `linspace(0.05, 0.95, ...)`. This pushes outer circles closer to the boundary to improve `edge_utilization` and, more importantly, increases the spacing between all grid points from 0.2 to 0.225. This gives the central circle at (0.5, 0.5) more room to expand, tackling the large unused central space seen in the visualization. + +Second, to complement the new grid geometry, the 26th "interstitial" circle is moved from the hardcoded `(0.2, 0.2)` to `(0.1625, 0.1625)`. This new position is the exact geometric center of the bottom-left cell of the widened grid, ensuring it is placed in the most stable and balanced location relative to its four nearest neighbors. + + + +<<<<<<< SEARCH + # This strategy improves central packing density by replacing the single + # center circle of a 5x5 grid with two smaller, symmetrically placed circles. + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) +======= + # This strategy widens the grid to improve edge utilization and give more + # space to the central circle, which was previously too small. + grid_size = 5 + x_coords = np.linspace(0.05, 0.95, grid_size) + y_coords = np.linspace(0.05, 0.95, grid_size) +>>>>>>> REPLACE +<<<<<<< SEARCH + # 3. Place the 26th circle in an interstitial position (0.2, 0.2). + # This position has consistently been effective in filling gaps in the bottom-left quadrant. + centers[k] = [0.2, 0.2] +======= + # 3. Place the 26th circle in an interstitial position relative to the new, wider grid. + # The new position (0.1625, 0.1625) is the center of the bottom-left grid cell. + centers[k] = [0.1625, 0.1625] +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f6202efc8a693e8a928f49ca4e75b77350ef4bb1 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..047b153cbc04dff852ea002f203023b1924ab132 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9088569714133816, + "spatial_uniformity_details": { + "cell_size_mean": 0.19566336459159553, + "cell_size_std": 0.01962173618554716, + "coefficient_of_variation": 0.10028313744997744 + }, + "edge_utilization": 0.3923076923076923, + "edge_utilization_details": { + "corners_touched": 2, + "edges_touched": 6, + "corner_score": 0.5, + "edge_score": 0.23076923076923078 + }, + "density_variance": 0.5329800247969909, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00018898046185922239, + "mean_density": 0.01568858957156087, + "cv": 0.8762429237022427 + }, + "packing_efficiency": 0.4720815888513603, + "packing_efficiency_details": { + "total_area": 0.4720815888513603, + "square_area": 1.0, + "efficiency": 0.4720815888513603, + "relative_to_estimated_best": 0.5620018914897147 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.07215936502916907, + "std": 0.02392851036863203, + "min": 0.03205646169944585, + "max": 0.1255076016247733, + "range": 0.09345113992532747, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.4748, + "gap_analysis_details": { + "covered_samples": 1187, + "total_samples": 2500, + "coverage": 0.4748, + "gap_ratio": 0.5252 + }, + "geometric_quality": 0.6436786972211647, + "geometric_quality_details": { + "num_triangles": 43, + "avg_triangle_quality": 0.6436786972211647, + "min_quality": 0.2728587624655322, + "max_quality": 0.8131447310562795 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..2065342e0e2aa402e060ecd983b4a89be45500c8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/job_log.out @@ -0,0 +1,76 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 19.78 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.8761 + + Auxiliary Metrics: + • spatial_uniformity: 0.909 + • edge_utilization: 0.392 + • density_variance: 0.533 + • packing_efficiency: 0.472 + • radius_distribution: 0.974 + • gap_analysis: 0.475 + • geometric_quality: 0.644 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.8761 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.909 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.392 + → Consider placing larger circles near boundaries and corners + • Area utilization efficiency: 0.472 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.475 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.533 + • Radius size diversity: 0.974 + • Delaunay triangulation quality: 0.644 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 2/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 52.5% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..5f48f8431a543cd7d6b7c8a1ad5a19b1cfe4e14b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.876143490758396, + "public": { + "centers_str": " centers[0] = (0.1021, 0.0957)\n centers[1] = (0.3096, 0.1129)\n centers[2] = (0.4977, 0.0977)\n centers[3] = (0.7158, 0.1077)\n centers[4] = (0.8953, 0.1054)\n centers[5] = (0.0954, 0.2953)\n centers[6] = (0.3073, 0.2849)\n centers[7] = (0.4828, 0.2944)\n centers[8] = (0.6899, 0.3031)\n centers[9] = (0.8909, 0.2859)\n centers[10] = (0.1147, 0.4977)\n centers[11] = (0.3007, 0.4858)\n centers[12] = (0.6946, 0.5011)\n centers[13] = (0.8885, 0.5038)\n centers[14] = (0.0940, 0.6971)\n centers[15] = (0.2940, 0.7185)\n centers[16] = (0.4999, 0.6894)\n centers[17] = (0.7082, 0.6878)\n centers[18] = (0.9021, 0.6804)\n centers[19] = (0.0867, 0.9020)\n centers[20] = (0.3074, 0.9017)\n centers[21] = (0.4988, 0.8970)\n centers[22] = (0.6852, 0.8928)\n centers[23] = (0.8954, 0.9106)\n centers[24] = (0.5034, 0.4824)\n centers[25] = (0.1981, 0.1975)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9088569714133816, + "aux_edge_utilization": 0.3923076923076923, + "aux_density_variance": 0.5329800247969909, + "aux_packing_efficiency": 0.4720815888513603, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.4748, + "aux_geometric_quality": 0.6436786972211647 + }, + "private": { + "reported_sum_of_radii": 1.876143490758396 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.8761\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.909\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.392\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Area utilization efficiency: 0.472\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.475\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.533\n \u2022 Radius size diversity: 0.974\n \u2022 Delaunay triangulation quality: 0.644\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 2/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 52.5% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_57/results/packing_viz.png", + "execution_time_mean": 19.778902889229357, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6aa3aeee1e76d89b98aa10253b782a03c97cbb38 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..d3fcd4de962e58fa89299e0c4813f303aaf3944d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5321553497859173, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00023008231524406688, + "mean_density": 0.017253545721657784, + "cv": 0.8791505157324713 + }, + "packing_efficiency": 0.5166642865652796, + "packing_efficiency_details": { + "total_area": 0.5166642865652796, + "square_area": 1.0, + "efficiency": 0.5166642865652796, + "relative_to_estimated_best": 0.6150765316253329 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07541299137659783, + "std": 0.0252634193391021, + "min": 0.03669894819221307, + "max": 0.12486579904517191, + "range": 0.08816685085295883, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5168, + "gap_analysis_details": { + "covered_samples": 1292, + "total_samples": 2500, + "coverage": 0.5168, + "gap_ratio": 0.48319999999999996 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..8ca89f3cca91eb0c4192b92646488897fe6fd44e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9607 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.532 + • packing_efficiency: 0.517 + • radius_distribution: 0.977 + • gap_analysis: 0.517 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9607 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.532 + • Area utilization efficiency: 0.517 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.517 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 48.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..cd2e7e0fa58a1e557aeb2767fa3c0775270b6c26 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9607377757915438, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5321553497859173, + "aux_packing_efficiency": 0.5166642865652796, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5168, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9607377757915438 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9607\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.532\n \u2022 Area utilization efficiency: 0.517\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.517\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 48.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_59/results/packing_viz.png", + "execution_time_mean": 0.002635116223245859, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d57b56a0d2c3f5067b6b032b311cb9841778cb74 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..9a8bbac8c69c5f8beef139c71fc672fbaeff7476 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8312342706180994, + "spatial_uniformity_details": { + "cell_size_mean": 0.1955468559544958, + "cell_size_std": 0.03970193374934353, + "coefficient_of_variation": 0.20303028321535366 + }, + "edge_utilization": 0.0, + "edge_utilization_details": { + "corners_touched": 0, + "edges_touched": 0, + "corner_score": 0.0, + "edge_score": 0.0 + }, + "density_variance": 0.4072944245113661, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001463859844670802, + "mean_density": 0.008314174762847354, + "cv": 1.4552263419753577 + }, + "packing_efficiency": 0.31099380668391413, + "packing_efficiency_details": { + "total_area": 0.31099380668391413, + "square_area": 1.0, + "efficiency": 0.31099380668391413, + "relative_to_estimated_best": 0.37023072224275494 + }, + "radius_distribution": 0.9947372351472321, + "radius_distribution_details": { + "mean": 0.05583776249154598, + "std": 0.026259177507624847, + "min": 0.015277712389274648, + "max": 0.11018344798400377, + "range": 0.09490573559472912, + "small_count": 10, + "medium_count": 8, + "large_count": 8, + "diversity_score": 0.9947372351472321 + }, + "gap_analysis": 0.3044, + "gap_analysis_details": { + "covered_samples": 761, + "total_samples": 2500, + "coverage": 0.3044, + "gap_ratio": 0.6956 + }, + "geometric_quality": 0.5996134514170103, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.5996134514170103, + "min_quality": 0.3535533905932739, + "max_quality": 0.7810249675906651 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3047dc4aac72cf30666c715012f969b704e5f8db --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 24.63 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.4518 + + Auxiliary Metrics: + • spatial_uniformity: 0.831 + • edge_utilization: 0.000 + • density_variance: 0.407 + • packing_efficiency: 0.311 + • radius_distribution: 0.995 + • gap_analysis: 0.304 + • geometric_quality: 0.600 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.4518 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.831 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.000 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.407 + → Balance circle density across different regions + • Area utilization efficiency: 0.311 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.304 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.995 + • Delaunay triangulation quality: 0.600 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 0/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 69.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..6c9bcd94d3a20fdad4d7e563cf714343cf05c182 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.4517818247801955, + "public": { + "centers_str": " centers[0] = (0.0800, 0.0800)\n centers[1] = (0.9200, 0.0800)\n centers[2] = (0.0800, 0.9200)\n centers[3] = (0.9200, 0.9200)\n centers[4] = (0.5000, 0.0800)\n centers[5] = (0.5000, 0.9200)\n centers[6] = (0.0800, 0.5000)\n centers[7] = (0.9200, 0.5000)\n centers[8] = (0.2000, 0.2000)\n centers[9] = (0.2000, 0.4000)\n centers[10] = (0.2000, 0.6000)\n centers[11] = (0.2000, 0.8000)\n centers[12] = (0.4000, 0.2000)\n centers[13] = (0.4000, 0.4000)\n centers[14] = (0.4000, 0.6000)\n centers[15] = (0.4000, 0.8000)\n centers[16] = (0.6000, 0.2000)\n centers[17] = (0.6000, 0.4000)\n centers[18] = (0.6000, 0.6000)\n centers[19] = (0.6091, 0.8000)\n centers[20] = (0.8000, 0.2160)\n centers[21] = (0.8000, 0.3932)\n centers[22] = (0.8000, 0.5907)\n centers[23] = (0.7909, 0.8000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2500, 0.7500)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8312342706180994, + "aux_edge_utilization": 0.0, + "aux_density_variance": 0.4072944245113661, + "aux_packing_efficiency": 0.31099380668391413, + "aux_radius_distribution": 0.9947372351472321, + "aux_gap_analysis": 0.3044, + "aux_geometric_quality": 0.5996134514170103 + }, + "private": { + "reported_sum_of_radii": 1.4517818247801955 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.4518\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.831\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.000\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.407\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.311\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.304\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.995\n \u2022 Delaunay triangulation quality: 0.600\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 0/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 69.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_6/results/packing_viz.png", + "execution_time_mean": 24.633170281071216, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fcf6c5f872b2da8b2ab88b019ca269d2639d07fe Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..c00fb602ebceb34202c374018e20e44011f605bb --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/edit.diff @@ -0,0 +1,169 @@ +--- a/original.py ++++ b/original.py +@@ -1,145 +1,162 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + + def construct_packing(): + """ + Construct an arrangement of 26 circles by first placing 25 circles + (one at the center, 24 on a grid) and then systematically searching for + the best position for the 26th circle from a set of interstitial candidates. + This approach restores a previously successful, more robust strategy. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + start_coord = 0.1 + end_coord = 0.9 + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + # 1. Prioritize the central (0.5, 0.5) circle by placing it first. + central_point_coords = np.array([0.5, 0.5]) + + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 3. Explore each candidate to find the one maximizing the sum of radii. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a +- heuristic to cap the initial radius of a designated "interstitial" circle. ++ heuristic for the interstitial circle and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + if radii[i] + radii[j] > dist: +- scale_factor = dist / (radii[i] + radii[j]) +- radii[i] *= scale_factor +- radii[j] *= scale_factor ++ overlap = radii[i] + radii[j] - dist ++ ++ # Weighted proportional scaling to protect the central circle (at index 0). ++ w_i = 1.5 if i == 0 else 1.0 ++ ++ # The reduction for each circle is proportional to radius/weight. ++ # A higher weight means a smaller share of the reduction. ++ weighted_r_i = radii[i] / w_i ++ weighted_r_j = radii[j] # w_j is always 1.0 since j > i >= 0 ++ ++ total_weighted_radii = weighted_r_i + weighted_r_j ++ ++ if total_weighted_radii > 1e-12: ++ radii[i] -= overlap * weighted_r_i / total_weighted_radii ++ radii[j] -= overlap * weighted_r_j / total_weighted_radii ++ elif (radii[i] + radii[j]) > 1e-12: ++ # Fallback for tiny radii ++ scale_factor = dist / (radii[i] + radii[j]) ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/main.py new file mode 100644 index 0000000000000000000000000000000000000000..47a24971fc0c816d7daa4ab04a3a131e9ce72add --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/main.py @@ -0,0 +1,162 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def construct_packing(): + """ + Construct an arrangement of 26 circles by first placing 25 circles + (one at the center, 24 on a grid) and then systematically searching for + the best position for the 26th circle from a set of interstitial candidates. + This approach restores a previously successful, more robust strategy. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + start_coord = 0.1 + end_coord = 0.9 + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + # 1. Prioritize the central (0.5, 0.5) circle by placing it first. + central_point_coords = np.array([0.5, 0.5]) + + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 3. Explore each candidate to find the one maximizing the sum of radii. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for the interstitial circle and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = 1.5 if i == 0 else 1.0 + + # The reduction for each circle is proportional to radius/weight. + # A higher weight means a smaller share of the reduction. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] # w_j is always 1.0 since j > i >= 0 + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * weighted_r_i / total_weighted_radii + radii[j] -= overlap * weighted_r_j / total_weighted_radii + elif (radii[i] + radii[j]) > 1e-12: + # Fallback for tiny radii + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/original.py new file mode 100644 index 0000000000000000000000000000000000000000..880f63ef27847b2068b43ac57e959654c5adb65a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/original.py @@ -0,0 +1,145 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def construct_packing(): + """ + Construct an arrangement of 26 circles by first placing 25 circles + (one at the center, 24 on a grid) and then systematically searching for + the best position for the 26th circle from a set of interstitial candidates. + This approach restores a previously successful, more robust strategy. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + start_coord = 0.1 + end_coord = 0.9 + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + # 1. Prioritize the central (0.5, 0.5) circle by placing it first. + central_point_coords = np.array([0.5, 0.5]) + + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 3. Explore each candidate to find the one maximizing the sum of radii. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic to cap the initial radius of a designated "interstitial" circle. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f6aad5d9dac77133113537034a44fa0319e4a6bf --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.01751952657876505, + "coefficient_of_variation": 0.08804167661183819 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6488704821597152, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013118746872674172, + "mean_density": 0.02116590456546931, + "cv": 0.5411396072010817 + }, + "packing_efficiency": 0.5929125243019656, + "packing_efficiency_details": { + "total_area": 0.5929125243019656, + "square_area": 1.0, + "efficiency": 0.5929125243019656, + "relative_to_estimated_best": 0.7058482432166258 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.08312687418930133, + "std": 0.018675272218096832, + "min": 0.021467933716788186, + "max": 0.10181958598981834, + "range": 0.08035165227303015, + "small_count": 6, + "medium_count": 10, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5936, + "gap_analysis_details": { + "covered_samples": 1484, + "total_samples": 2500, + "coverage": 0.5936, + "gap_ratio": 0.4064 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..2f83e6ad7d3928bd4b77f4792a1348fc9f92c2d2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.06 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1613 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.649 + • packing_efficiency: 0.593 + • radius_distribution: 0.977 + • gap_analysis: 0.594 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1613 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.649 + • Area utilization efficiency: 0.593 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.594 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 40.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..13fe19cb1901b85bc6ee4342386110b569ecfb3a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1612987289218344, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6488704821597152, + "aux_packing_efficiency": 0.5929125243019656, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5936, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1612987289218344 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1613\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.649\n \u2022 Area utilization efficiency: 0.593\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.594\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 40.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/results/packing_viz.png", + "execution_time_mean": 0.05554588185623288, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..252b96eed8ccddde5968d86b6137e050cf477a28 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_60/search_replace.txt @@ -0,0 +1,122 @@ + +weighted_central_circle_scaling + + +The current packing shows the central circle at (0.5, 0.5) is being squeezed into a very small radius, which is suboptimal and leads to a low sum of radii. This is a common issue in iterative relaxation methods where a highly constrained object is reduced excessively. + +To counteract this, I'm introducing a weighted proportional scaling mechanism within the `compute_max_radii` function. This change is inspired by the recommendation to "Implement a weighted proportional scaling in `compute_max_radii` for the central circle". + +Specifically, when an overlap occurs involving the central circle (at index 0), the amount of radius reduction is adjusted. By assigning the central circle a weight of 1.5 (and all others a weight of 1.0), its "share" of the corrective reduction is decreased. The reduction for each circle `k` becomes proportional to `radius[k]/weight[k]`. This gives the central circle more "resistance" to shrinking, allowing it to maintain a larger radius, which should create a more balanced packing and increase the total sum of radii. The rest of the packing logic, including the systematic search for the 26th circle, remains unchanged. + + +<<<<<<< SEARCH +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic to cap the initial radius of a designated "interstitial" circle. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii +======= +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for the interstitial circle and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + w_i = 1.5 if i == 0 else 1.0 + + # The reduction for each circle is proportional to radius/weight. + # A higher weight means a smaller share of the reduction. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] # w_j is always 1.0 since j > i >= 0 + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * weighted_r_i / total_weighted_radii + radii[j] -= overlap * weighted_r_j / total_weighted_radii + elif (radii[i] + radii[j]) > 1e-12: + # Fallback for tiny radii + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..78345f6092eb50c04cf5eab34a102e614b2f9440 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f398d177695ef7362b0a1aff1b8b9f399d1a5729 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9387420797799824, + "spatial_uniformity_details": { + "cell_size_mean": 0.19989521731533136, + "cell_size_std": 0.013044227588895911, + "coefficient_of_variation": 0.06525532575931287 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5337246614587045, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00024185516969970784, + "mean_density": 0.01780133148498907, + "cv": 0.873625245771733 + }, + "packing_efficiency": 0.5278463000262735, + "packing_efficiency_details": { + "total_area": 0.5278463000262735, + "square_area": 1.0, + "efficiency": 0.5278463000262735, + "relative_to_estimated_best": 0.6283884524122304 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.07600593566093787, + "std": 0.026179290872923745, + "min": 0.03505713748493466, + "max": 0.1251359964784234, + "range": 0.09007885899348875, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.5224, + "gap_analysis_details": { + "covered_samples": 1306, + "total_samples": 2500, + "coverage": 0.5224, + "gap_ratio": 0.4776 + }, + "geometric_quality": 0.6705887302733149, + "geometric_quality_details": { + "num_triangles": 38, + "avg_triangle_quality": 0.6705887302733149, + "min_quality": 0.34176801056734396, + "max_quality": 0.7094272836976588 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..10b7185b111c982c5c3d57bac9d37249eb2101ea --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9762 + + Auxiliary Metrics: + • spatial_uniformity: 0.939 + • edge_utilization: 0.558 + • density_variance: 0.534 + • packing_efficiency: 0.528 + • radius_distribution: 0.974 + • gap_analysis: 0.522 + • geometric_quality: 0.671 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9762 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.939 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.534 + • Area utilization efficiency: 0.528 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.522 + • Delaunay triangulation quality: 0.671 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 47.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..38bcc8343ebe2759ccdf1e901f86a8ff98c42887 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9761543271843847, + "public": { + "centers_str": " centers[0] = (0.0850, 0.0850)\n centers[1] = (0.3150, 0.0850)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.0850, 0.3150)\n centers[6] = (0.3150, 0.3150)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9387420797799824, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5337246614587045, + "aux_packing_efficiency": 0.5278463000262735, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.5224, + "aux_geometric_quality": 0.6705887302733149 + }, + "private": { + "reported_sum_of_radii": 1.9761543271843847 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9762\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.939\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.534\n \u2022 Area utilization efficiency: 0.528\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.522\n \u2022 Delaunay triangulation quality: 0.671\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 47.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_61/results/packing_viz.png", + "execution_time_mean": 0.004018187988549471, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3dc6a8ddd671144ed33635fd429ee06acbd7add7 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..cd69ad2d1e55094d8226b4c87d9d57c62f02dcf8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.878107621527078, + "spatial_uniformity_details": { + "cell_size_mean": 0.19736041730378753, + "cell_size_std": 0.027396107508580195, + "coefficient_of_variation": 0.13881257317974804 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.6666849664337118, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00012582646426985398, + "mean_density": 0.022436325759595865, + "cv": 0.4999588266543424 + }, + "packing_efficiency": 0.6001116106358111, + "packing_efficiency_details": { + "total_area": 0.6001116106358111, + "square_area": 1.0, + "efficiency": 0.6001116106358111, + "relative_to_estimated_best": 0.7144185840902513 + }, + "radius_distribution": 0.9679654790068056, + "radius_distribution_details": { + "mean": 0.0828524242025938, + "std": 0.021964857751072365, + "min": 0.010030287367310813, + "max": 0.10549922638915632, + "range": 0.0954689390218455, + "small_count": 7, + "medium_count": 7, + "large_count": 12, + "diversity_score": 0.9679654790068056 + }, + "gap_analysis": 0.6048, + "gap_analysis_details": { + "covered_samples": 1512, + "total_samples": 2500, + "coverage": 0.6048, + "gap_ratio": 0.3952 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..5254f89e82ea06bb9a19514caabb61479b6700d3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 6.08 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1542 + + Auxiliary Metrics: + • spatial_uniformity: 0.878 + • edge_utilization: 0.738 + • density_variance: 0.667 + • packing_efficiency: 0.600 + • radius_distribution: 0.968 + • gap_analysis: 0.605 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1542 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.878 + • Boundary and corner utilization: 0.738 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.667 + • Area utilization efficiency: 0.600 + • Radius size diversity: 0.968 + • Area coverage (1 - gap ratio): 0.605 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 39.5% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..2e6f4a1812aa92aa220341e9fc7e86b7a61e5d26 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1541630292674387, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4000, 0.2000)\n centers[25] = (0.6000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.878107621527078, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.6666849664337118, + "aux_packing_efficiency": 0.6001116106358111, + "aux_radius_distribution": 0.9679654790068056, + "aux_gap_analysis": 0.6048, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1541630292674387 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1542\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.878\n \u2022 Boundary and corner utilization: 0.738\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.667\n \u2022 Area utilization efficiency: 0.600\n \u2022 Radius size diversity: 0.968\n \u2022 Area coverage (1 - gap ratio): 0.605\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 39.5% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_62/results/packing_viz.png", + "execution_time_mean": 6.079398216214031, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..78914cb3ccf745ff6ebbe680a90de4c81a2291b0 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5b59a226e8e553ed745ece5656f1cab83d0d56b7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9387923301065, + "spatial_uniformity_details": { + "cell_size_mean": 0.19977317878057696, + "cell_size_std": 0.01302487296652416, + "coefficient_of_variation": 0.06519830630332946 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5337699166960007, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00024132063098558293, + "mean_density": 0.017784882579329447, + "cv": 0.8734663920176162 + }, + "packing_efficiency": 0.527354048715805, + "packing_efficiency_details": { + "total_area": 0.527354048715805, + "square_area": 1.0, + "efficiency": 0.527354048715805, + "relative_to_estimated_best": 0.627802438947387 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.07597301678386921, + "std": 0.02615973562336655, + "min": 0.03507303183543785, + "max": 0.12512056573892363, + "range": 0.09004753390348579, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.5224, + "gap_analysis_details": { + "covered_samples": 1306, + "total_samples": 2500, + "coverage": 0.5224, + "gap_ratio": 0.4776 + }, + "geometric_quality": 0.6704995924368976, + "geometric_quality_details": { + "num_triangles": 38, + "avg_triangle_quality": 0.6704995924368976, + "min_quality": 0.3415875772334372, + "max_quality": 0.7094269878244596 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..f60e3cfa7846164f071a724141e7d292e473972c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.24 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9753 + + Auxiliary Metrics: + • spatial_uniformity: 0.939 + • edge_utilization: 0.558 + • density_variance: 0.534 + • packing_efficiency: 0.527 + • radius_distribution: 0.974 + • gap_analysis: 0.522 + • geometric_quality: 0.670 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9753 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.939 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.534 + • Area utilization efficiency: 0.527 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.522 + • Delaunay triangulation quality: 0.670 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 47.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..ce91a154ce51a503e1eebbb0cbbe82052ea4fac1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9752984363805994, + "public": { + "centers_str": " centers[0] = (0.0853, 0.0853)\n centers[1] = (0.3150, 0.0853)\n centers[2] = (0.5000, 0.1002)\n centers[3] = (0.7000, 0.1002)\n centers[4] = (0.8998, 0.1002)\n centers[5] = (0.0853, 0.3150)\n centers[6] = (0.3150, 0.3150)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.8998, 0.3000)\n centers[10] = (0.1002, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.8998, 0.5000)\n centers[14] = (0.1002, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.8998, 0.7000)\n centers[19] = (0.1002, 0.8998)\n centers[20] = (0.3000, 0.8998)\n centers[21] = (0.5000, 0.8998)\n centers[22] = (0.7000, 0.8998)\n centers[23] = (0.8998, 0.8998)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9387923301065, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5337699166960007, + "aux_packing_efficiency": 0.527354048715805, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.5224, + "aux_geometric_quality": 0.6704995924368976 + }, + "private": { + "reported_sum_of_radii": 1.9752984363805994 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9753\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.939\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.534\n \u2022 Area utilization efficiency: 0.527\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.522\n \u2022 Delaunay triangulation quality: 0.670\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 47.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_65/results/packing_viz.png", + "execution_time_mean": 0.2351867421530187, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d96f6181df7e87a517a8e1de5889ec233d73eb72 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f6aad5d9dac77133113537034a44fa0319e4a6bf --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.01751952657876505, + "coefficient_of_variation": 0.08804167661183819 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6488704821597152, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013118746872674172, + "mean_density": 0.02116590456546931, + "cv": 0.5411396072010817 + }, + "packing_efficiency": 0.5929125243019656, + "packing_efficiency_details": { + "total_area": 0.5929125243019656, + "square_area": 1.0, + "efficiency": 0.5929125243019656, + "relative_to_estimated_best": 0.7058482432166258 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.08312687418930133, + "std": 0.018675272218096832, + "min": 0.021467933716788186, + "max": 0.10181958598981834, + "range": 0.08035165227303015, + "small_count": 6, + "medium_count": 10, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5936, + "gap_analysis_details": { + "covered_samples": 1484, + "total_samples": 2500, + "coverage": 0.5936, + "gap_ratio": 0.4064 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..08ed05e3da0f405b518999d3842f792e5a0b9a36 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.06 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1613 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.649 + • packing_efficiency: 0.593 + • radius_distribution: 0.977 + • gap_analysis: 0.594 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1613 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.649 + • Area utilization efficiency: 0.593 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.594 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 40.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..cec8b8ef767b774590f884dbe1a844f1e59c9a7f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1612987289218344, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6488704821597152, + "aux_packing_efficiency": 0.5929125243019656, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5936, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1612987289218344 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1613\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.649\n \u2022 Area utilization efficiency: 0.593\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.594\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 40.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_66/results/packing_viz.png", + "execution_time_mean": 0.05861745402216911, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2632fbb2d436d02dfcf2479d881f062dbe815c2b Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f6aad5d9dac77133113537034a44fa0319e4a6bf --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.01751952657876505, + "coefficient_of_variation": 0.08804167661183819 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6488704821597152, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013118746872674172, + "mean_density": 0.02116590456546931, + "cv": 0.5411396072010817 + }, + "packing_efficiency": 0.5929125243019656, + "packing_efficiency_details": { + "total_area": 0.5929125243019656, + "square_area": 1.0, + "efficiency": 0.5929125243019656, + "relative_to_estimated_best": 0.7058482432166258 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.08312687418930133, + "std": 0.018675272218096832, + "min": 0.021467933716788186, + "max": 0.10181958598981834, + "range": 0.08035165227303015, + "small_count": 6, + "medium_count": 10, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5936, + "gap_analysis_details": { + "covered_samples": 1484, + "total_samples": 2500, + "coverage": 0.5936, + "gap_ratio": 0.4064 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3ec086a9b9e1dade8820d32bc3b2916cb95169bb --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.27 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1613 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.649 + • packing_efficiency: 0.593 + • radius_distribution: 0.977 + • gap_analysis: 0.594 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1613 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.649 + • Area utilization efficiency: 0.593 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.594 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 40.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..abddd5b8515e6966e929c1da5880ea209670fb64 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1612987289218344, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6488704821597152, + "aux_packing_efficiency": 0.5929125243019656, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5936, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1612987289218344 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1613\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.649\n \u2022 Area utilization efficiency: 0.593\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.594\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 40.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_67/results/packing_viz.png", + "execution_time_mean": 0.2720412649214268, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f71ebd3faaa8a03f4ca559ce40353212fb5cbc92 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..e9af02b8e64523c783922301edce4929aa73b35e --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8267251269807389, + "spatial_uniformity_details": { + "cell_size_mean": 0.1757577673317246, + "cell_size_std": 0.03683740096427215, + "coefficient_of_variation": 0.20959187928891634 + }, + "edge_utilization": 0.44999999999999996, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 0, + "corner_score": 0.75, + "edge_score": 0.0 + }, + "density_variance": 0.48123662510254545, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001895462861449405, + "mean_density": 0.012771648906414343, + "cv": 1.0779798291264984 + }, + "packing_efficiency": 0.45415265858036247, + "packing_efficiency_details": { + "total_area": 0.45415265858036247, + "square_area": 1.0, + "efficiency": 0.45415265858036247, + "relative_to_estimated_best": 0.5406579268813839 + }, + "radius_distribution": 0.9341661379115739, + "radius_distribution_details": { + "mean": 0.06837925838839223, + "std": 0.029737624214098174, + "min": 0.010382771162307198, + "max": 0.10967985498234362, + "range": 0.09929708382003642, + "small_count": 8, + "medium_count": 5, + "large_count": 13, + "diversity_score": 0.9341661379115739 + }, + "gap_analysis": 0.4536, + "gap_analysis_details": { + "covered_samples": 1134, + "total_samples": 2500, + "coverage": 0.4536, + "gap_ratio": 0.5464 + }, + "geometric_quality": 0.6090736590811904, + "geometric_quality_details": { + "num_triangles": 46, + "avg_triangle_quality": 0.6090736590811904, + "min_quality": 0.16611521053709002, + "max_quality": 0.8065184687841297 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..d2dc1afd9acec9fd9ba9a6c9a6aa37669f7e235c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/job_log.out @@ -0,0 +1,77 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.83 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.7779 + + Auxiliary Metrics: + • spatial_uniformity: 0.827 + • edge_utilization: 0.450 + • density_variance: 0.481 + • packing_efficiency: 0.454 + • radius_distribution: 0.934 + • gap_analysis: 0.454 + • geometric_quality: 0.609 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.7779 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.827 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.450 + → Consider placing larger circles near boundaries and corners + • Spatial density uniformity across grid: 0.481 + → Balance circle density across different regions + • Area utilization efficiency: 0.454 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.454 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Radius size diversity: 0.934 + • Delaunay triangulation quality: 0.609 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 3/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 54.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..1734496b9a8d7a6c0501fe377839d1ab67f9806a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.777860718098198, + "public": { + "centers_str": " centers[0] = (0.2514, 0.2514)\n centers[1] = (0.2514, 0.5000)\n centers[2] = (0.2514, 0.7486)\n centers[3] = (0.5000, 0.2514)\n centers[4] = (0.5000, 0.5000)\n centers[5] = (0.5000, 0.7486)\n centers[6] = (0.7486, 0.2514)\n centers[7] = (0.7486, 0.5000)\n centers[8] = (0.7486, 0.7486)\n centers[9] = (0.0932, 0.0932)\n centers[10] = (0.0932, 0.9068)\n centers[11] = (0.9068, 0.0932)\n centers[12] = (0.9068, 0.9068)\n centers[13] = (0.6259, 0.6259)\n centers[14] = (0.3741, 0.6259)\n centers[15] = (0.6259, 0.3741)\n centers[16] = (0.3741, 0.3741)\n centers[17] = (0.1748, 0.6259)\n centers[18] = (0.6259, 0.1748)\n centers[19] = (0.6259, 0.8252)\n centers[20] = (0.8252, 0.6259)\n centers[21] = (0.1748, 0.3741)\n centers[22] = (0.3741, 0.1748)\n centers[23] = (0.3741, 0.8252)\n centers[24] = (0.8252, 0.3741)\n centers[25] = (0.2240, 0.8726)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8267251269807389, + "aux_edge_utilization": 0.44999999999999996, + "aux_density_variance": 0.48123662510254545, + "aux_packing_efficiency": 0.45415265858036247, + "aux_radius_distribution": 0.9341661379115739, + "aux_gap_analysis": 0.4536, + "aux_geometric_quality": 0.6090736590811904 + }, + "private": { + "reported_sum_of_radii": 1.777860718098198 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.7779\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.827\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.450\n \u2192 Consider placing larger circles near boundaries and corners\n \u2022 Spatial density uniformity across grid: 0.481\n \u2192 Balance circle density across different regions\n \u2022 Area utilization efficiency: 0.454\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.454\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Radius size diversity: 0.934\n \u2022 Delaunay triangulation quality: 0.609\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 3/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 54.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_68/results/packing_viz.png", + "execution_time_mean": 0.8343792031519115, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..15710f4aedcce9b35d1d3e2d8266bf90d62ed42c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..a933243ad88849d61945dcabf72efea43366324a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.01751952657876506, + "coefficient_of_variation": 0.08804167661183825 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6467714070842768, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001313641757888452, + "mean_density": 0.02098618092743579, + "cv": 0.5461413245030731 + }, + "packing_efficiency": 0.5931843168812923, + "packing_efficiency_details": { + "total_area": 0.5931843168812923, + "square_area": 1.0, + "efficiency": 0.5931843168812923, + "relative_to_estimated_best": 0.7061718058110622 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08330120623009306, + "std": 0.017974412848432136, + "min": 0.021467933716788186, + "max": 0.10181958598981834, + "range": 0.08035165227303015, + "small_count": 6, + "medium_count": 9, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.6, + "gap_analysis_details": { + "covered_samples": 1500, + "total_samples": 2500, + "coverage": 0.6, + "gap_ratio": 0.4 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865471, + "max_quality": 0.7071067811865479 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..8ef52e4c519fae7338d24cfd6bb2f36727845534 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.22 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1658 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.647 + • packing_efficiency: 0.593 + • radius_distribution: 0.974 + • gap_analysis: 0.600 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1658 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.647 + • Area utilization efficiency: 0.593 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.600 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 40.0% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..d8714fa5e3240d7dab1a692a69a978c40336dafc --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1658313619824194, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.6000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6467714070842768, + "aux_packing_efficiency": 0.5931843168812923, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.6, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1658313619824194 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1658\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.647\n \u2022 Area utilization efficiency: 0.593\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.600\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 40.0% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_69/results/packing_viz.png", + "execution_time_mean": 0.21660362603142858, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..686a9810d34e955138b84f98add535642a7f15a1 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f6fc381abd432c9db24e45252b7e619fb61603cc --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.1979292003985259, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576736 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5261424497752974, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00020708924409982752, + "mean_density": 0.01597843653375721, + "cv": 0.9006259624690526 + }, + "packing_efficiency": 0.49240606516668184, + "packing_efficiency_details": { + "total_area": 0.49240606516668184, + "square_area": 1.0, + "efficiency": 0.49240606516668184, + "relative_to_estimated_best": 0.5861976966270022 + }, + "radius_distribution": 0.7543533534342522, + "radius_distribution_details": { + "mean": 0.07372908132592121, + "std": 0.024339193856461577, + "min": 0.03669894819221307, + "max": 0.10261558125579377, + "range": 0.0659166330635807, + "small_count": 12, + "medium_count": 1, + "large_count": 13, + "diversity_score": 0.7543533534342522 + }, + "gap_analysis": 0.496, + "gap_analysis_details": { + "covered_samples": 1240, + "total_samples": 2500, + "coverage": 0.496, + "gap_ratio": 0.504 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3c570f509422388df541f38b3b4d652f8a277773 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9170 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.526 + • packing_efficiency: 0.492 + • radius_distribution: 0.754 + • gap_analysis: 0.496 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9170 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +⚠️ Areas for Improvement: + • Area utilization efficiency: 0.492 + → Consider optimizing this aspect + • Area coverage (1 - gap ratio): 0.496 + → Identify and fill empty regions with additional circles or larger radii + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.526 + • Radius size diversity: 0.754 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 50.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..bff5bdcc3e8959e4aca21afa64d4b2976af635e5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9169561144739513, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.5000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5261424497752974, + "aux_packing_efficiency": 0.49240606516668184, + "aux_radius_distribution": 0.7543533534342522, + "aux_gap_analysis": 0.496, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9169561144739513 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9170\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Area utilization efficiency: 0.492\n \u2192 Consider optimizing this aspect\n \u2022 Area coverage (1 - gap ratio): 0.496\n \u2192 Identify and fill empty regions with additional circles or larger radii\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.526\n \u2022 Radius size diversity: 0.754\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 50.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_7/results/packing_viz.png", + "execution_time_mean": 0.0020519751124083996, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1f1a448b4b6ba58ce2695eda36cf91801703209c Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..f6b5492a159daba4cf489b5437435cb646f50ef7 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/edit.diff @@ -0,0 +1,215 @@ +--- a/original.py ++++ b/original.py +@@ -1,164 +1,175 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + + def construct_packing(): + """ +- Construct an arrangement of 26 circles by first placing 25 circles +- (one at the center, 24 on a grid) and then systematically searching for +- the best position for the 26th circle from a set of interstitial candidates. +- This approach restores a previously successful, more robust strategy. ++ Construct an arrangement of 26 circles by systematically searching for ++ optimal grid parameters and the best position for an interstitial circle. ++ This method combines grid parameter optimization with the proven strategy of ++ placing a central circle, a peripheral grid, and one interstitial circle. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 +- start_coord = 0.1 +- end_coord = 0.9 + +- all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) +- +- # 1. Prioritize the central (0.5, 0.5) circle by placing it first. +- # Calculate central point robustly, rather than hardcoding 0.5,0.5 +- center_coord_val = start_coord + (end_coord - start_coord) / (grid_size - 1) * (grid_size // 2) +- central_point_coords = np.array([center_coord_val, center_coord_val]) +- +- central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] +- +- base_centers = np.zeros((n_circles - 1, 2)) +- base_centers[0] = central_point_coords +- other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- base_centers[1:] = other_grid_centers +- +- # 2. Generate interstitial candidates for the 26th circle. +- candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) ++ # Define search space for grid boundary coordinates. ++ # We ensure the grid center stays at (0.5, 0.5). ++ start_coord_options = np.linspace(0.08, 0.12, 5) ++ end_coord_options = np.linspace(0.88, 0.92, 5) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + +- # 3. Explore each candidate to find the one maximizing the sum of radii. +- for interstitial_point in candidate_interstitial_points: +- current_centers = np.vstack([base_centers, interstitial_point]) +- interstitial_idx = n_circles - 1 # The interstitial circle is always the last one added ++ for sc in start_coord_options: ++ for ec in end_coord_options: ++ if ec <= sc or not np.isclose((sc + ec) / 2.0, 0.5): ++ continue + +- current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) +- current_sum_radii = np.sum(current_radii) ++ all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii ++ # 1. Prioritize the central (0.5, 0.5) circle. ++ # This point is guaranteed to be in the grid due to the check above. ++ central_point_coords = np.array([0.5, 0.5]) ++ central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] ++ ++ base_centers = np.zeros((n_circles - 1, 2)) ++ base_centers[0] = central_point_coords ++ other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) ++ base_centers[1:] = other_grid_centers ++ ++ # 2. Generate interstitial candidates for the 26th circle. ++ candidate_interstitial_points = _generate_interstitial_candidates(grid_size, sc, ec) ++ ++ # 3. Explore each candidate to find the one maximizing the sum of radii for the current grid config. ++ for interstitial_point in candidate_interstitial_points: ++ current_centers = np.vstack([base_centers, interstitial_point]) ++ interstitial_idx = n_circles - 1 ++ ++ current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) ++ current_sum_radii = np.sum(current_radii) ++ ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = current_centers ++ best_radii = current_radii + + return best_centers, best_radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for the interstitial circle and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Cap the initial radius of the interstitial circle. +- # This prevents it from growing too large initially and sub-optimally +- # squeezing its neighbors, allowing for a better overall packing. ++ # Heuristic: Adaptively cap the initial radius of the interstitial circle. ++ # This prevents it from growing too large initially by considering its ++ # proximity to other circles, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: +- radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) ++ other_centers = np.delete(centers, interstitial_idx, axis=0) ++ if len(other_centers) > 0: ++ distances_to_others = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) ++ min_dist_to_neighbor = np.min(distances_to_others) ++ # Cap the initial radius to half the distance to the nearest neighbor. ++ radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): +- dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) ++ dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = 1.5 if i == 0 else 1.0 + + # The reduction for each circle is proportional to radius/weight. + # A higher weight means a smaller share of the reduction. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] # w_j is always 1.0 since j > i >= 0. + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero if both radii are tiny + radii[i] -= overlap * weighted_r_i / total_weighted_radii + radii[j] -= overlap * weighted_r_j / total_weighted_radii + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling for extremely small radii sum + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/main.py new file mode 100644 index 0000000000000000000000000000000000000000..99ead4ffc72a503eaa5d161c7c632f587eda3fa9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/main.py @@ -0,0 +1,175 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def construct_packing(): + """ + Construct an arrangement of 26 circles by systematically searching for + optimal grid parameters and the best position for an interstitial circle. + This method combines grid parameter optimization with the proven strategy of + placing a central circle, a peripheral grid, and one interstitial circle. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + # Define search space for grid boundary coordinates. + # We ensure the grid center stays at (0.5, 0.5). + start_coord_options = np.linspace(0.08, 0.12, 5) + end_coord_options = np.linspace(0.88, 0.92, 5) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + for sc in start_coord_options: + for ec in end_coord_options: + if ec <= sc or not np.isclose((sc + ec) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + + # 1. Prioritize the central (0.5, 0.5) circle. + # This point is guaranteed to be in the grid due to the check above. + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, sc, ec) + + # 3. Explore each candidate to find the one maximizing the sum of radii for the current grid config. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for the interstitial circle and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially by considering its + # proximity to other circles, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + other_centers = np.delete(centers, interstitial_idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to half the distance to the nearest neighbor. + radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = 1.5 if i == 0 else 1.0 + + # The reduction for each circle is proportional to radius/weight. + # A higher weight means a smaller share of the reduction. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] # w_j is always 1.0 since j > i >= 0. + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero if both radii are tiny + radii[i] -= overlap * weighted_r_i / total_weighted_radii + radii[j] -= overlap * weighted_r_j / total_weighted_radii + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling for extremely small radii sum + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/original.py new file mode 100644 index 0000000000000000000000000000000000000000..03c6fa627ede745476246ba87cc8e00dbf5e703d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/original.py @@ -0,0 +1,164 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def construct_packing(): + """ + Construct an arrangement of 26 circles by first placing 25 circles + (one at the center, 24 on a grid) and then systematically searching for + the best position for the 26th circle from a set of interstitial candidates. + This approach restores a previously successful, more robust strategy. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + start_coord = 0.1 + end_coord = 0.9 + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + # 1. Prioritize the central (0.5, 0.5) circle by placing it first. + # Calculate central point robustly, rather than hardcoding 0.5,0.5 + center_coord_val = start_coord + (end_coord - start_coord) / (grid_size - 1) * (grid_size // 2) + central_point_coords = np.array([center_coord_val, center_coord_val]) + + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 3. Explore each candidate to find the one maximizing the sum of radii. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 # The interstitial circle is always the last one added + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for the interstitial circle and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = 1.5 if i == 0 else 1.0 + + # The reduction for each circle is proportional to radius/weight. + # A higher weight means a smaller share of the reduction. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] # w_j is always 1.0 since j > i >= 0. + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero if both radii are tiny + radii[i] -= overlap * weighted_r_i / total_weighted_radii + radii[j] -= overlap * weighted_r_j / total_weighted_radii + elif (radii[i] + radii[j]) > 1e-12: # Fallback to simple scaling for extremely small radii sum + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..a933243ad88849d61945dcabf72efea43366324a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.01751952657876506, + "coefficient_of_variation": 0.08804167661183825 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6467714070842768, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001313641757888452, + "mean_density": 0.02098618092743579, + "cv": 0.5461413245030731 + }, + "packing_efficiency": 0.5931843168812923, + "packing_efficiency_details": { + "total_area": 0.5931843168812923, + "square_area": 1.0, + "efficiency": 0.5931843168812923, + "relative_to_estimated_best": 0.7061718058110622 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08330120623009306, + "std": 0.017974412848432136, + "min": 0.021467933716788186, + "max": 0.10181958598981834, + "range": 0.08035165227303015, + "small_count": 6, + "medium_count": 9, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.6, + "gap_analysis_details": { + "covered_samples": 1500, + "total_samples": 2500, + "coverage": 0.6, + "gap_ratio": 0.4 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865471, + "max_quality": 0.7071067811865479 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..bc633fa73f20776770cd388e9470456b7bcb0fdf --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.26 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1658 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.647 + • packing_efficiency: 0.593 + • radius_distribution: 0.974 + • gap_analysis: 0.600 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1658 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.647 + • Area utilization efficiency: 0.593 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.600 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 40.0% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..b6165c5ca110653ebd1703e8243d49e6f47e25d1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1658313619824194, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.6000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6467714070842768, + "aux_packing_efficiency": 0.5931843168812923, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.6, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1658313619824194 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1658\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.647\n \u2022 Area utilization efficiency: 0.593\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.600\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 40.0% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/results/packing_viz.png", + "execution_time_mean": 0.26067564776167274, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..eec0b328e048d8c9a735593a09eea9440b6262c1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_71/search_replace.txt @@ -0,0 +1,172 @@ +Here are the edits I propose to improve the circle packing algorithm. + +I will introduce two main improvements. First, I will re-implement a systematic search for the optimal grid spacing parameters, a strategy that has proven effective in past iterations. This will allow the underlying 5x5 grid to expand or contract to find a better overall fit within the unit square. + +Second, I will replace the fixed, hardcoded cap on the interstitial circle's initial radius with an adaptive heuristic. This new approach calculates the cap based on the circle's local environment—specifically, half the distance to its nearest neighbor. This makes the algorithm more flexible and intelligent, allowing the interstitial circle to better adapt to the varying geometries produced by the grid parameter search. + +Finally, a minor code-quality improvement will be made to enhance readability by using `np.linalg.norm` for distance calculations. + + +reintroduce_grid_parameter_search + + + +The current implementation uses a fixed grid with `start_coord=0.1` and `end_coord=0.9`. Previous successful versions showed that optimizing these grid parameters leads to better results. This change reintroduces a systematic search over a range of `start_coord` and `end_coord` values, while ensuring the grid remains centered at (0.5, 0.5). This allows the packing to adapt the grid spacing, which should improve edge utilization and overall density, directly addressing the feedback about unused space. By finding a better-spaced grid, we create a superior foundation for placing the 26 circles. + + + +<<<<<<< SEARCH +def construct_packing(): + """ + Construct an arrangement of 26 circles by first placing 25 circles + (one at the center, 24 on a grid) and then systematically searching for + the best position for the 26th circle from a set of interstitial candidates. + This approach restores a previously successful, more robust strategy. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + start_coord = 0.1 + end_coord = 0.9 + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + # 1. Prioritize the central (0.5, 0.5) circle by placing it first. + # Calculate central point robustly, rather than hardcoding 0.5,0.5 + center_coord_val = start_coord + (end_coord - start_coord) / (grid_size - 1) * (grid_size // 2) + central_point_coords = np.array([center_coord_val, center_coord_val]) + + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 3. Explore each candidate to find the one maximizing the sum of radii. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 # The interstitial circle is always the last one added + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii +======= +def construct_packing(): + """ + Construct an arrangement of 26 circles by systematically searching for + optimal grid parameters and the best position for an interstitial circle. + This method combines grid parameter optimization with the proven strategy of + placing a central circle, a peripheral grid, and one interstitial circle. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + + # Define search space for grid boundary coordinates. + # We ensure the grid center stays at (0.5, 0.5). + start_coord_options = np.linspace(0.08, 0.12, 5) + end_coord_options = np.linspace(0.88, 0.92, 5) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + for sc in start_coord_options: + for ec in end_coord_options: + if ec <= sc or not np.isclose((sc + ec) / 2.0, 0.5): + continue + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + + # 1. Prioritize the central (0.5, 0.5) circle. + # This point is guaranteed to be in the grid due to the check above. + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, sc, ec) + + # 3. Explore each candidate to find the one maximizing the sum of radii for the current grid config. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii +>>>>>>> REPLACE + + + +adaptive_interstitial_radius_cap + + + +The current heuristic for the interstitial circle uses a hardcoded initial radius cap of 0.05. This is inflexible and can unnecessarily constrain the circle. I am replacing this with an adaptive heuristic that caps the initial radius at half the distance to its nearest neighbor. This approach, inspired by previous successful versions, allows the interstitial circle's initial size to be determined by its local environment, leading to a more balanced and efficient packing, especially when the grid parameters are being optimized. + + + +<<<<<<< SEARCH + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) +======= + # Heuristic: Adaptively cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially by considering its + # proximity to other circles, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + other_centers = np.delete(centers, interstitial_idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + # Cap the initial radius to half the distance to the nearest neighbor. + radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * min_dist_to_neighbor) +>>>>>>> REPLACE + + + +use_linalg_norm_for_distance + + + +This is a minor code quality improvement. I am replacing `np.sqrt(np.sum((centers[i] - centers[j]) ** 2))` with the more direct and readable `np.linalg.norm(centers[i] - centers[j])` for calculating the Euclidean distance between two circle centers. This improves code clarity without changing the logic. + + + +<<<<<<< SEARCH + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) +======= + dist = np.linalg.norm(centers[i] - centers[j]) +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cc6b9f244d051610ac7c96d43572a0f285cf655e Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..f236eddbdd89a282662ce111b271ed7ec5a094d3 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/edit.diff @@ -0,0 +1,184 @@ +--- a/original.py ++++ b/original.py +@@ -1,167 +1,150 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles with center relaxation""" + + import numpy as np + + + def construct_packing(): + """ + Constructs an arrangement of 26 circles by first placing them on a + grid and then optimizing their center positions using a physics-based + relaxation before computing the final radii. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 + + # 1. Initial Placement: Start with the proven 5x5 grid + interstitial circle. + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: + continue + centers[k] = [coords[j], coords[i]] + k += 1 + centers[k] = [0.5, 0.5] + k += 1 + centers[k] = [0.2, 0.2] + + # 2. Apply a targeted perturbation to relax local tension around the interstitial circle. + # This specific adjustment was found to be effective in previous high-scoring versions. + perturbation_delta = 0.015 + + # Indices of the four neighbors of (0.2, 0.2) based on the grid creation order + idx_01_01 = 0 # Corresponds to initial center (0.1, 0.1) + idx_03_01 = 1 # Corresponds to initial center (0.3, 0.1) + idx_01_03 = 5 # Corresponds to initial center (0.1, 0.3) + idx_03_03 = 6 # Corresponds to initial center (0.3, 0.3) + + # Move circles away from the interstitial (0.2, 0.2) to relieve tension + centers[idx_01_01] -= perturbation_delta # Move (0.1, 0.1) towards (0,0) + centers[idx_03_01] += [perturbation_delta, -perturbation_delta] # Move (0.3, 0.1) away from (0.2,0.2) + centers[idx_01_03] += [-perturbation_delta, perturbation_delta] # Move (0.1, 0.3) away from (0.2,0.2) + centers[idx_03_03] += perturbation_delta # Move (0.3, 0.3) away from (0.2,0.2) + + # 3. Center Relaxation: Optimize center positions using a physics simulation. + # This allows circles to shift out of the rigid grid to find a better packing. + relaxation_steps = 100 + learning_rate = 0.002 + wall_repulsion = 1e-5 + + for _ in range(relaxation_steps): +- # A. Estimate radii for current centers (more robust estimation for force calculation) +- # Initialize with a reasonable radius given the typical grid spacing (0.2 for centers, so max r=0.1 if touching) +- radii = np.full(n, 0.08) +- +- # Apply border constraint initially +- for i in range(n): +- x, y = centers[i] +- radii[i] = min(radii[i], x, y, 1 - x, 1 - y) +- +- # Perform a few iterative scaling steps to resolve overlaps for more accurate force estimation. +- # This is a trade-off between simulation speed and the accuracy of force calculations. +- num_force_estimate_iterations = 5 +- for _ in range(num_force_estimate_iterations): +- prev_radii_estimate = np.copy(radii) +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.linalg.norm(centers[i] - centers[j]) +- if radii[i] + radii[j] > dist and dist > 1e-9: # Avoid division by zero for coincident centers +- scale_factor = dist / (radii[i] + radii[j]) +- radii[i] *= scale_factor +- radii[j] *= scale_factor +- # Check for early convergence of radius estimation within the relaxation step +- if np.allclose(radii, prev_radii_estimate, atol=1e-5): +- break +- + forces = np.zeros_like(centers) + +- # B. Calculate inter-circle repulsion forces for overlaps ++ # B. Calculate inter-circle repulsion forces based on a target diameter. ++ # This new force model avoids the complex and potentially inaccurate on-the-fly ++ # radius estimation. The force simply pushes centers apart if they are closer ++ # than a defined 'soft' diameter, making the relaxation more stable and predictable. ++ target_diameter = 0.185 # A key hyperparameter, set slightly below grid spacing (0.2). ++ + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) +- overlap = (radii[i] + radii[j]) - dist ++ ++ # Apply a repulsive spring-like force if circles are closer than the target diameter. ++ overlap = target_diameter - dist + if overlap > 0: +- # Spring-like force proportional to the overlap distance +- direction = vec / (dist + 1e-9) +- forces[i] += direction * overlap +- forces[j] -= direction * overlap ++ direction = vec / (dist + 1e-9) # Normalize vector, avoid division by zero ++ # Force is proportional to the 'overlap' with the target diameter sphere. ++ force_magnitude = overlap ++ forces[i] += direction * force_magnitude ++ forces[j] -= direction * force_magnitude + + # C. Calculate wall repulsion forces + for i in range(n): + x, y = centers[i] + # Force strength increases quadratically as circles approach a wall + forces[i][0] += wall_repulsion / (x**2 + 1e-9) + forces[i][0] -= wall_repulsion / ((1 - x)**2 + 1e-9) + forces[i][1] += wall_repulsion / (y**2 + 1e-9) + forces[i][1] -= wall_repulsion / ((1 - y)**2 + 1e-9) + + # D. Update center positions + centers += forces * learning_rate + + # E. Enforce boundaries to prevent circles from escaping + centers = np.clip(centers, 0.001, 0.999) + + # 3. Final Radii Computation: Use the optimized centers to find the max radii. + radii = compute_max_radii(centers) + return centers, radii + + + def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/main.py new file mode 100644 index 0000000000000000000000000000000000000000..a7aa9a96fc8ae08a895ef3af942b198273ea41e5 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/main.py @@ -0,0 +1,150 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles with center relaxation""" + +import numpy as np + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by first placing them on a + grid and then optimizing their center positions using a physics-based + relaxation before computing the final radii. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 + + # 1. Initial Placement: Start with the proven 5x5 grid + interstitial circle. + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: + continue + centers[k] = [coords[j], coords[i]] + k += 1 + centers[k] = [0.5, 0.5] + k += 1 + centers[k] = [0.2, 0.2] + + # 2. Apply a targeted perturbation to relax local tension around the interstitial circle. + # This specific adjustment was found to be effective in previous high-scoring versions. + perturbation_delta = 0.015 + + # Indices of the four neighbors of (0.2, 0.2) based on the grid creation order + idx_01_01 = 0 # Corresponds to initial center (0.1, 0.1) + idx_03_01 = 1 # Corresponds to initial center (0.3, 0.1) + idx_01_03 = 5 # Corresponds to initial center (0.1, 0.3) + idx_03_03 = 6 # Corresponds to initial center (0.3, 0.3) + + # Move circles away from the interstitial (0.2, 0.2) to relieve tension + centers[idx_01_01] -= perturbation_delta # Move (0.1, 0.1) towards (0,0) + centers[idx_03_01] += [perturbation_delta, -perturbation_delta] # Move (0.3, 0.1) away from (0.2,0.2) + centers[idx_01_03] += [-perturbation_delta, perturbation_delta] # Move (0.1, 0.3) away from (0.2,0.2) + centers[idx_03_03] += perturbation_delta # Move (0.3, 0.3) away from (0.2,0.2) + + # 3. Center Relaxation: Optimize center positions using a physics simulation. + # This allows circles to shift out of the rigid grid to find a better packing. + relaxation_steps = 100 + learning_rate = 0.002 + wall_repulsion = 1e-5 + + for _ in range(relaxation_steps): + forces = np.zeros_like(centers) + + # B. Calculate inter-circle repulsion forces based on a target diameter. + # This new force model avoids the complex and potentially inaccurate on-the-fly + # radius estimation. The force simply pushes centers apart if they are closer + # than a defined 'soft' diameter, making the relaxation more stable and predictable. + target_diameter = 0.185 # A key hyperparameter, set slightly below grid spacing (0.2). + + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + + # Apply a repulsive spring-like force if circles are closer than the target diameter. + overlap = target_diameter - dist + if overlap > 0: + direction = vec / (dist + 1e-9) # Normalize vector, avoid division by zero + # Force is proportional to the 'overlap' with the target diameter sphere. + force_magnitude = overlap + forces[i] += direction * force_magnitude + forces[j] -= direction * force_magnitude + + # C. Calculate wall repulsion forces + for i in range(n): + x, y = centers[i] + # Force strength increases quadratically as circles approach a wall + forces[i][0] += wall_repulsion / (x**2 + 1e-9) + forces[i][0] -= wall_repulsion / ((1 - x)**2 + 1e-9) + forces[i][1] += wall_repulsion / (y**2 + 1e-9) + forces[i][1] -= wall_repulsion / ((1 - y)**2 + 1e-9) + + # D. Update center positions + centers += forces * learning_rate + + # E. Enforce boundaries to prevent circles from escaping + centers = np.clip(centers, 0.001, 0.999) + + # 3. Final Radii Computation: Use the optimized centers to find the max radii. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/original.py new file mode 100644 index 0000000000000000000000000000000000000000..53fc0286c74cf3b852d9aa488220ba4475ca7a0c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/original.py @@ -0,0 +1,167 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles with center relaxation""" + +import numpy as np + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by first placing them on a + grid and then optimizing their center positions using a physics-based + relaxation before computing the final radii. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 + + # 1. Initial Placement: Start with the proven 5x5 grid + interstitial circle. + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: + continue + centers[k] = [coords[j], coords[i]] + k += 1 + centers[k] = [0.5, 0.5] + k += 1 + centers[k] = [0.2, 0.2] + + # 2. Apply a targeted perturbation to relax local tension around the interstitial circle. + # This specific adjustment was found to be effective in previous high-scoring versions. + perturbation_delta = 0.015 + + # Indices of the four neighbors of (0.2, 0.2) based on the grid creation order + idx_01_01 = 0 # Corresponds to initial center (0.1, 0.1) + idx_03_01 = 1 # Corresponds to initial center (0.3, 0.1) + idx_01_03 = 5 # Corresponds to initial center (0.1, 0.3) + idx_03_03 = 6 # Corresponds to initial center (0.3, 0.3) + + # Move circles away from the interstitial (0.2, 0.2) to relieve tension + centers[idx_01_01] -= perturbation_delta # Move (0.1, 0.1) towards (0,0) + centers[idx_03_01] += [perturbation_delta, -perturbation_delta] # Move (0.3, 0.1) away from (0.2,0.2) + centers[idx_01_03] += [-perturbation_delta, perturbation_delta] # Move (0.1, 0.3) away from (0.2,0.2) + centers[idx_03_03] += perturbation_delta # Move (0.3, 0.3) away from (0.2,0.2) + + # 3. Center Relaxation: Optimize center positions using a physics simulation. + # This allows circles to shift out of the rigid grid to find a better packing. + relaxation_steps = 100 + learning_rate = 0.002 + wall_repulsion = 1e-5 + + for _ in range(relaxation_steps): + # A. Estimate radii for current centers (more robust estimation for force calculation) + # Initialize with a reasonable radius given the typical grid spacing (0.2 for centers, so max r=0.1 if touching) + radii = np.full(n, 0.08) + + # Apply border constraint initially + for i in range(n): + x, y = centers[i] + radii[i] = min(radii[i], x, y, 1 - x, 1 - y) + + # Perform a few iterative scaling steps to resolve overlaps for more accurate force estimation. + # This is a trade-off between simulation speed and the accuracy of force calculations. + num_force_estimate_iterations = 5 + for _ in range(num_force_estimate_iterations): + prev_radii_estimate = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist and dist > 1e-9: # Avoid division by zero for coincident centers + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + # Check for early convergence of radius estimation within the relaxation step + if np.allclose(radii, prev_radii_estimate, atol=1e-5): + break + + forces = np.zeros_like(centers) + + # B. Calculate inter-circle repulsion forces for overlaps + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + overlap = (radii[i] + radii[j]) - dist + if overlap > 0: + # Spring-like force proportional to the overlap distance + direction = vec / (dist + 1e-9) + forces[i] += direction * overlap + forces[j] -= direction * overlap + + # C. Calculate wall repulsion forces + for i in range(n): + x, y = centers[i] + # Force strength increases quadratically as circles approach a wall + forces[i][0] += wall_repulsion / (x**2 + 1e-9) + forces[i][0] -= wall_repulsion / ((1 - x)**2 + 1e-9) + forces[i][1] += wall_repulsion / (y**2 + 1e-9) + forces[i][1] -= wall_repulsion / ((1 - y)**2 + 1e-9) + + # D. Update center positions + centers += forces * learning_rate + + # E. Enforce boundaries to prevent circles from escaping + centers = np.clip(centers, 0.001, 0.999) + + # 3. Final Radii Computation: Use the optimized centers to find the max radii. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..0fd05d6e0c0e0e253d8da24c718121c911b4ce7a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9402040146143483, + "spatial_uniformity_details": { + "cell_size_mean": 0.20016413200673033, + "cell_size_std": 0.012730228105770746, + "coefficient_of_variation": 0.06359894709679433 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5325657759481888, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00024664295114713223, + "mean_density": 0.017893161304440172, + "cv": 0.8777023330490656 + }, + "packing_efficiency": 0.5297897141800274, + "packing_efficiency_details": { + "total_area": 0.5297897141800274, + "square_area": 1.0, + "efficiency": 0.5297897141800274, + "relative_to_estimated_best": 0.6307020406905088 + }, + "radius_distribution": 0.9903496169664631, + "radius_distribution_details": { + "mean": 0.07605953296518754, + "std": 0.02647635897219937, + "min": 0.03419124093187968, + "max": 0.12517715365154145, + "range": 0.09098591271966176, + "small_count": 9, + "medium_count": 7, + "large_count": 10, + "diversity_score": 0.9903496169664631 + }, + "gap_analysis": 0.532, + "gap_analysis_details": { + "covered_samples": 1330, + "total_samples": 2500, + "coverage": 0.532, + "gap_ratio": 0.46799999999999997 + }, + "geometric_quality": 0.6695895487774548, + "geometric_quality_details": { + "num_triangles": 38, + "avg_triangle_quality": 0.6695895487774548, + "min_quality": 0.34314631573807947, + "max_quality": 0.7110213844630737 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..5c7345b7ffe9130004a26b31820449cd086d9c67 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.11 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9775 + + Auxiliary Metrics: + • spatial_uniformity: 0.940 + • edge_utilization: 0.558 + • density_variance: 0.533 + • packing_efficiency: 0.530 + • radius_distribution: 0.990 + • gap_analysis: 0.532 + • geometric_quality: 0.670 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9775 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.940 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.533 + • Area utilization efficiency: 0.530 + • Radius size diversity: 0.990 + • Area coverage (1 - gap ratio): 0.532 + • Delaunay triangulation quality: 0.670 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 46.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..19f77587bab32c4bd9de53d5f4d5fd2b66be9f34 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.977547857094876, + "public": { + "centers_str": " centers[0] = (0.0824, 0.0824)\n centers[1] = (0.3178, 0.0824)\n centers[2] = (0.5001, 0.1002)\n centers[3] = (0.7000, 0.1002)\n centers[4] = (0.8998, 0.1002)\n centers[5] = (0.0824, 0.3178)\n centers[6] = (0.3178, 0.3178)\n centers[7] = (0.5001, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.8998, 0.3000)\n centers[10] = (0.1002, 0.5001)\n centers[11] = (0.3000, 0.5001)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.8998, 0.5000)\n centers[14] = (0.1002, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.8998, 0.7000)\n centers[19] = (0.1002, 0.8998)\n centers[20] = (0.3000, 0.8998)\n centers[21] = (0.5000, 0.8998)\n centers[22] = (0.7000, 0.8998)\n centers[23] = (0.8998, 0.8998)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2001, 0.2001)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9402040146143483, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5325657759481888, + "aux_packing_efficiency": 0.5297897141800274, + "aux_radius_distribution": 0.9903496169664631, + "aux_gap_analysis": 0.532, + "aux_geometric_quality": 0.6695895487774548 + }, + "private": { + "reported_sum_of_radii": 1.977547857094876 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9775\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.940\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.533\n \u2022 Area utilization efficiency: 0.530\n \u2022 Radius size diversity: 0.990\n \u2022 Area coverage (1 - gap ratio): 0.532\n \u2022 Delaunay triangulation quality: 0.670\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 46.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/results/packing_viz.png", + "execution_time_mean": 0.1100989282131195, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..a803d44f1c730c097bb867a2404938aa4bfc5299 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_72/search_replace.txt @@ -0,0 +1,72 @@ + +simplified_physics_relaxation + + + +The current physics-based center relaxation is complex and ineffective, likely due to a flawed force model that depends on an unstable on-the-fly radius estimation. This change replaces the problematic force calculation with a much simpler and more robust model. The new model uses a radius-independent repulsive force that activates when two circle centers are closer than a fixed `target_diameter`. This is a standard technique in particle simulations. By removing the dependency on inaccurate radius estimates, the relaxation process becomes more stable and predictable, guiding the centers towards a better packing configuration. The initial configuration, including the manual perturbation, is retained as a good starting point for this improved relaxation process. I've chosen `target_diameter = 0.185`, a value slightly less than the grid spacing, to gently push apart only the most compressed circles. + + + +<<<<<<< SEARCH + # A. Estimate radii for current centers (more robust estimation for force calculation) + # Initialize with a reasonable radius given the typical grid spacing (0.2 for centers, so max r=0.1 if touching) + radii = np.full(n, 0.08) + + # Apply border constraint initially + for i in range(n): + x, y = centers[i] + radii[i] = min(radii[i], x, y, 1 - x, 1 - y) + + # Perform a few iterative scaling steps to resolve overlaps for more accurate force estimation. + # This is a trade-off between simulation speed and the accuracy of force calculations. + num_force_estimate_iterations = 5 + for _ in range(num_force_estimate_iterations): + prev_radii_estimate = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist and dist > 1e-9: # Avoid division by zero for coincident centers + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + # Check for early convergence of radius estimation within the relaxation step + if np.allclose(radii, prev_radii_estimate, atol=1e-5): + break + + forces = np.zeros_like(centers) + + # B. Calculate inter-circle repulsion forces for overlaps + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + overlap = (radii[i] + radii[j]) - dist + if overlap > 0: + # Spring-like force proportional to the overlap distance + direction = vec / (dist + 1e-9) + forces[i] += direction * overlap + forces[j] -= direction * overlap +======= + forces = np.zeros_like(centers) + + # B. Calculate inter-circle repulsion forces based on a target diameter. + # This new force model avoids the complex and potentially inaccurate on-the-fly + # radius estimation. The force simply pushes centers apart if they are closer + # than a defined 'soft' diameter, making the relaxation more stable and predictable. + target_diameter = 0.185 # A key hyperparameter, set slightly below grid spacing (0.2). + + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + + # Apply a repulsive spring-like force if circles are closer than the target diameter. + overlap = target_diameter - dist + if overlap > 0: + direction = vec / (dist + 1e-9) # Normalize vector, avoid division by zero + # Force is proportional to the 'overlap' with the target diameter sphere. + force_magnitude = overlap + forces[i] += direction * force_magnitude + forces[j] -= direction * force_magnitude +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..87583701e01c68d0a9c60d2e353cf0578b5b9586 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..c08c0d5f781a64a718868f2f653dfc3871a24c95 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/edit.diff @@ -0,0 +1,250 @@ +--- a/original.py ++++ b/original.py +@@ -1,98 +1,200 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" ++"""Physics-based iterative circle packing for n=26 circles""" + + import numpy as np + ++def compute_radii_for_force_estimation(centers, initial_estimate_r=0.08, num_iterations=15, tolerance=1e-6): ++ """ ++ A simplified and faster radius computation for use within the physics simulation loop. ++ It takes an initial radius estimate and performs a few iterations of overlap resolution, ++ but not to full convergence. This provides a 'good enough' radius for force calculations. ++ """ ++ n = centers.shape[0] ++ radii = np.full(n, initial_estimate_r, dtype=float) ++ ++ # Limit by border ++ for i in range(n): ++ x, y = centers[i] ++ radii[i] = min(radii[i], x, y, 1 - x, 1 - y) ++ ++ # Limited iterations to resolve major overlaps ++ for _ in range(num_iterations): ++ prev_radii = np.copy(radii) ++ for i in range(n): ++ for j in range(i + 1, n): ++ vec = centers[i] - centers[j] ++ dist = np.linalg.norm(vec) ++ if dist < 1e-9: # Avoid division by zero for nearly coincident centers ++ radii[i] *= 0.95 # Shrink them slightly ++ radii[j] *= 0.95 ++ continue ++ ++ if radii[i] + radii[j] > dist: ++ scale_factor = dist / (radii[i] + radii[j]) ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor ++ if np.allclose(radii, prev_radii, atol=tolerance): ++ break ++ return radii ++ + + def construct_packing(): + """ +- Construct a specific arrangement of 26 circles in a unit square +- that attempts to maximize the sum of their radii. ++ Constructs an arrangement of 26 circles by initially placing them on a ++ grid and then optimizing their center positions using a physics-based ++ relaxation before computing the final radii. This approach allows circles ++ to dynamically adjust positions to find better packing configurations. + + Returns: +- Tuple of (centers, radii, sum_of_radii) ++ Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle +- sum_of_radii: Sum of all radii + """ + n = 26 +- centers = np.zeros((n, 2)) +- k = 0 # current circle index +- +- # Place 25 circles in a 5x5 grid ++ ++ # 1. Initial Placement: Start with the proven 5x5 grid + interstitial circle. ++ # This provides a good initial guess that is already somewhat distributed. ++ initial_centers = np.zeros((n, 2)) ++ k = 0 + grid_size = 5 +- x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 +- y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 ++ x_coords = np.linspace(0.1, 0.9, grid_size) ++ y_coords = np.linspace(0.1, 0.9, grid_size) + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now +- if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] ++ if i_grid == 2 and j_grid == 2: + continue +- centers[k] = [x_coords[j_grid], y_coords[i_grid]] ++ initial_centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle +- centers[k] = [0.5, 0.5] # k is now 24, so centers[24] ++ initial_centers[k] = [0.5, 0.5] + k += 1 + +- # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2) +- # The bottom-left grid circle is at (0.1, 0.1). Its neighbors are (0.3, 0.1), (0.1, 0.3). +- # Placing at (0.2, 0.2) aims to fill a gap and was the previous best interstitial. +- centers[k] = [0.2, 0.2] # k is now 25, so centers[25] +- +- # No clipping needed, as all centers are already within [0.1, 0.9] or [0.2, 0.2] +- # which ensures they are within the unit square and allows for larger initial radii. +- +- # Compute maximum valid radii for this configuration +- radii = compute_max_radii(centers) +- return centers, radii +- +- +-def compute_max_radii(centers): ++ # Place the 26th circle in the interstitial position (0.2, 0.2) ++ initial_centers[k] = [0.2, 0.2] ++ ++ # Initialize current centers with the structured layout ++ centers = np.copy(initial_centers) ++ ++ # 2. Physics-based Center Relaxation ++ # This is the core 'different algorithm approach' where centers move iteratively. ++ relaxation_steps = 1500 # Increased iterations for better convergence ++ learning_rate = 0.0008 # Small learning rate for stability and fine-tuning ++ repulsion_strength = 0.8 # Factor for inter-circle repulsion ++ wall_repulsion_strength = 0.001 # Factor for wall repulsion, adjusted for effectiveness ++ ++ for step in range(relaxation_steps): ++ # A. Estimate radii for current centers for force calculation ++ # Using a quick estimate instead of full `compute_max_radii` for performance ++ estimated_radii = compute_radii_for_force_estimation(centers, num_iterations=15) # More iterations for better estimate ++ ++ forces = np.zeros_like(centers) ++ ++ # B. Calculate inter-circle repulsion forces ++ for i in range(n): ++ for j in range(i + 1, n): ++ vec = centers[i] - centers[j] ++ dist = np.linalg.norm(vec) ++ ++ # If circles overlap or are very close, apply repulsive force ++ min_dist_for_contact = estimated_radii[i] + estimated_radii[j] ++ if dist < min_dist_for_contact: ++ # Calculate overlap distance ++ overlap = min_dist_for_contact - dist ++ ++ # Ensure dist is not zero for normalization ++ direction = vec / (dist + 1e-12) if dist > 1e-12 else np.array([0., 0.]) ++ ++ # Force proportional to overlap ++ force_magnitude = repulsion_strength * overlap ++ forces[i] += direction * force_magnitude ++ forces[j] -= direction * force_magnitude ++ ++ # C. Calculate wall repulsion forces ++ for i in range(n): ++ x, y = centers[i] ++ r = estimated_radii[i] # Use estimated radius to determine proximity to wall ++ ++ # Repulsion from left wall (x=0) ++ if x < r: ++ forces[i][0] += wall_repulsion_strength * ((r - x)**2 + 1e-9) / (x + 1e-12) # Stronger repulsion closer to wall ++ # Repulsion from right wall (x=1) ++ if x > 1 - r: ++ forces[i][0] -= wall_repulsion_strength * ((r - (1-x))**2 + 1e-9) / ((1-x) + 1e-12) ++ # Repulsion from bottom wall (y=0) ++ if y < r: ++ forces[i][1] += wall_repulsion_strength * ((r - y)**2 + 1e-9) / (y + 1e-12) ++ # Repulsion from top wall (y=1) ++ if y > 1 - r: ++ forces[i][1] -= wall_repulsion_strength * ((r - (1-y))**2 + 1e-9) / ((1-y) + 1e-12) ++ ++ # D. Update center positions ++ centers += forces * learning_rate ++ ++ # E. Enforce boundaries (hard clamp) to prevent circles from escaping ++ # Small margin to prevent radii calculation issues at exactly 0 or 1. ++ centers = np.clip(centers, 0.001, 0.999) ++ ++ # 3. Final Radii Computation: Use the optimized centers to find the max radii. ++ final_radii = compute_max_radii(centers) ++ return centers, final_radii ++ ++ ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. ++ This function uses an iterative relaxation approach for robust convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates ++ max_iterations: Maximum number of iterations for the relaxation process. ++ tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] +- radii = np.ones(n) +- +- # First, limit by distance to square borders ++ radii = np.zeros(n) ++ ++ # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] +- # Distance to borders + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Then, limit by distance to other circles +- # Each pair of circles with centers at distance d can have +- # sum of radii at most d to avoid overlap +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) +- +- # If current radii would cause overlap +- if radii[i] + radii[j] > dist: +- # Scale both radii proportionally +- scale = dist / (radii[i] + radii[j]) +- radii[i] *= scale +- radii[j] *= scale ++ # 2. Iteratively adjust radii to resolve overlaps until convergence. ++ for _ in range(max_iterations): ++ prev_radii = np.copy(radii) ++ ++ for i in range(n): ++ for j in range(i + 1, n): ++ vec = centers[i] - centers[j] ++ dist = np.linalg.norm(vec) ++ ++ # Only scale if dist is not zero to avoid division by zero ++ if dist < 1e-9: # Centers are too close, shrink radii to avoid issues ++ radii[i] *= 0.95 ++ radii[j] *= 0.95 ++ continue ++ ++ if radii[i] + radii[j] > dist: ++ scale_factor = dist / (radii[i] + radii[j]) ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor ++ ++ if np.allclose(radii, prev_radii, atol=tolerance): ++ break + + return radii +- +- + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/main.py new file mode 100644 index 0000000000000000000000000000000000000000..50b70559d48db3179496c3da447d6e4491f96ed1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/main.py @@ -0,0 +1,200 @@ +# EVOLVE-BLOCK-START +"""Physics-based iterative circle packing for n=26 circles""" + +import numpy as np + +def compute_radii_for_force_estimation(centers, initial_estimate_r=0.08, num_iterations=15, tolerance=1e-6): + """ + A simplified and faster radius computation for use within the physics simulation loop. + It takes an initial radius estimate and performs a few iterations of overlap resolution, + but not to full convergence. This provides a 'good enough' radius for force calculations. + """ + n = centers.shape[0] + radii = np.full(n, initial_estimate_r, dtype=float) + + # Limit by border + for i in range(n): + x, y = centers[i] + radii[i] = min(radii[i], x, y, 1 - x, 1 - y) + + # Limited iterations to resolve major overlaps + for _ in range(num_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + if dist < 1e-9: # Avoid division by zero for nearly coincident centers + radii[i] *= 0.95 # Shrink them slightly + radii[j] *= 0.95 + continue + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by initially placing them on a + grid and then optimizing their center positions using a physics-based + relaxation before computing the final radii. This approach allows circles + to dynamically adjust positions to find better packing configurations. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + + # 1. Initial Placement: Start with the proven 5x5 grid + interstitial circle. + # This provides a good initial guess that is already somewhat distributed. + initial_centers = np.zeros((n, 2)) + k = 0 + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i_grid == 2 and j_grid == 2: + continue + initial_centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + initial_centers[k] = [0.5, 0.5] + k += 1 + + # Place the 26th circle in the interstitial position (0.2, 0.2) + initial_centers[k] = [0.2, 0.2] + + # Initialize current centers with the structured layout + centers = np.copy(initial_centers) + + # 2. Physics-based Center Relaxation + # This is the core 'different algorithm approach' where centers move iteratively. + relaxation_steps = 1500 # Increased iterations for better convergence + learning_rate = 0.0008 # Small learning rate for stability and fine-tuning + repulsion_strength = 0.8 # Factor for inter-circle repulsion + wall_repulsion_strength = 0.001 # Factor for wall repulsion, adjusted for effectiveness + + for step in range(relaxation_steps): + # A. Estimate radii for current centers for force calculation + # Using a quick estimate instead of full `compute_max_radii` for performance + estimated_radii = compute_radii_for_force_estimation(centers, num_iterations=15) # More iterations for better estimate + + forces = np.zeros_like(centers) + + # B. Calculate inter-circle repulsion forces + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + + # If circles overlap or are very close, apply repulsive force + min_dist_for_contact = estimated_radii[i] + estimated_radii[j] + if dist < min_dist_for_contact: + # Calculate overlap distance + overlap = min_dist_for_contact - dist + + # Ensure dist is not zero for normalization + direction = vec / (dist + 1e-12) if dist > 1e-12 else np.array([0., 0.]) + + # Force proportional to overlap + force_magnitude = repulsion_strength * overlap + forces[i] += direction * force_magnitude + forces[j] -= direction * force_magnitude + + # C. Calculate wall repulsion forces + for i in range(n): + x, y = centers[i] + r = estimated_radii[i] # Use estimated radius to determine proximity to wall + + # Repulsion from left wall (x=0) + if x < r: + forces[i][0] += wall_repulsion_strength * ((r - x)**2 + 1e-9) / (x + 1e-12) # Stronger repulsion closer to wall + # Repulsion from right wall (x=1) + if x > 1 - r: + forces[i][0] -= wall_repulsion_strength * ((r - (1-x))**2 + 1e-9) / ((1-x) + 1e-12) + # Repulsion from bottom wall (y=0) + if y < r: + forces[i][1] += wall_repulsion_strength * ((r - y)**2 + 1e-9) / (y + 1e-12) + # Repulsion from top wall (y=1) + if y > 1 - r: + forces[i][1] -= wall_repulsion_strength * ((r - (1-y))**2 + 1e-9) / ((1-y) + 1e-12) + + # D. Update center positions + centers += forces * learning_rate + + # E. Enforce boundaries (hard clamp) to prevent circles from escaping + # Small margin to prevent radii calculation issues at exactly 0 or 1. + centers = np.clip(centers, 0.001, 0.999) + + # 3. Final Radii Computation: Use the optimized centers to find the max radii. + final_radii = compute_max_radii(centers) + return centers, final_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for robust convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + + # Only scale if dist is not zero to avoid division by zero + if dist < 1e-9: # Centers are too close, shrink radii to avoid issues + radii[i] *= 0.95 + radii[j] *= 0.95 + continue + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/original.py new file mode 100644 index 0000000000000000000000000000000000000000..e1f8968ab1fff8a30d35fd54004bd009ee3171da --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/original.py @@ -0,0 +1,98 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 # current circle index + + # Place 25 circles in a 5x5 grid + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + y_coords = np.linspace(0.1, 0.9, grid_size) # Centers at 0.1, 0.3, ..., 0.9 + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i_grid == 2 and j_grid == 2: # (0.5, 0.5) is x_coords[2], y_coords[2] + continue + centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + centers[k] = [0.5, 0.5] # k is now 24, so centers[24] + k += 1 + + # Place the 26th circle in the center of the bottom-left grid cell (0.0-0.2, 0.0-0.2) + # The bottom-left grid circle is at (0.1, 0.1). Its neighbors are (0.3, 0.1), (0.1, 0.3). + # Placing at (0.2, 0.2) aims to fill a gap and was the previous best interstitial. + centers[k] = [0.2, 0.2] # k is now 25, so centers[25] + + # No clipping needed, as all centers are already within [0.1, 0.9] or [0.2, 0.2] + # which ensures they are within the unit square and allows for larger initial radii. + + # Compute maximum valid radii for this configuration + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.ones(n) + + # First, limit by distance to square borders + for i in range(n): + x, y = centers[i] + # Distance to borders + radii[i] = min(x, y, 1 - x, 1 - y) + + # Then, limit by distance to other circles + # Each pair of circles with centers at distance d can have + # sum of radii at most d to avoid overlap + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # If current radii would cause overlap + if radii[i] + radii[j] > dist: + # Scale both radii proportionally + scale = dist / (radii[i] + radii[j]) + radii[i] *= scale + radii[j] *= scale + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..d3fcd4de962e58fa89299e0c4813f303aaf3944d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9227802225521738, + "spatial_uniformity_details": { + "cell_size_mean": 0.19792920039852596, + "cell_size_std": 0.01656304340826504, + "coefficient_of_variation": 0.08368165632576735 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5321553497859173, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00023008231524406688, + "mean_density": 0.017253545721657784, + "cv": 0.8791505157324713 + }, + "packing_efficiency": 0.5166642865652796, + "packing_efficiency_details": { + "total_area": 0.5166642865652796, + "square_area": 1.0, + "efficiency": 0.5166642865652796, + "relative_to_estimated_best": 0.6150765316253329 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07541299137659783, + "std": 0.0252634193391021, + "min": 0.03669894819221307, + "max": 0.12486579904517191, + "range": 0.08816685085295883, + "small_count": 10, + "medium_count": 6, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5168, + "gap_analysis_details": { + "covered_samples": 1292, + "total_samples": 2500, + "coverage": 0.5168, + "gap_ratio": 0.48319999999999996 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..1acb09ef5f52ac223c875dc8f04e0323bcee2b21 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 4.71 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9607 + + Auxiliary Metrics: + • spatial_uniformity: 0.923 + • edge_utilization: 0.558 + • density_variance: 0.532 + • packing_efficiency: 0.517 + • radius_distribution: 0.977 + • gap_analysis: 0.517 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9607 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.923 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.532 + • Area utilization efficiency: 0.517 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.517 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 48.3% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..8a1cbd4e2a7731e0bafd089f561add3e4bac1be2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9607377757915438, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9227802225521738, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5321553497859173, + "aux_packing_efficiency": 0.5166642865652796, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5168, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9607377757915438 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9607\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.923\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.532\n \u2022 Area utilization efficiency: 0.517\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.517\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 48.3% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/results/packing_viz.png", + "execution_time_mean": 4.710599910933524, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..15d102fbb901acda888505a83f793a4914a2531d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_73/rewrite.txt @@ -0,0 +1,190 @@ +# EVOLVE-BLOCK-START +"""Physics-based iterative circle packing for n=26 circles""" + +import numpy as np + +def compute_radii_for_force_estimation(centers, initial_estimate_r=0.08, num_iterations=15, tolerance=1e-6): + """ + A simplified and faster radius computation for use within the physics simulation loop. + It takes an initial radius estimate and performs a few iterations of overlap resolution, + but not to full convergence. This provides a 'good enough' radius for force calculations. + """ + n = centers.shape[0] + radii = np.full(n, initial_estimate_r, dtype=float) + + # Limit by border + for i in range(n): + x, y = centers[i] + radii[i] = min(radii[i], x, y, 1 - x, 1 - y) + + # Limited iterations to resolve major overlaps + for _ in range(num_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + if dist < 1e-9: # Avoid division by zero for nearly coincident centers + radii[i] *= 0.95 # Shrink them slightly + radii[j] *= 0.95 + continue + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles by initially placing them on a + grid and then optimizing their center positions using a physics-based + relaxation before computing the final radii. This approach allows circles + to dynamically adjust positions to find better packing configurations. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n = 26 + + # 1. Initial Placement: Start with the proven 5x5 grid + interstitial circle. + # This provides a good initial guess that is already somewhat distributed. + initial_centers = np.zeros((n, 2)) + k = 0 + grid_size = 5 + x_coords = np.linspace(0.1, 0.9, grid_size) + y_coords = np.linspace(0.1, 0.9, grid_size) + + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position for now + if i_grid == 2 and j_grid == 2: + continue + initial_centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # Place the central (0.5, 0.5) circle as the 25th circle + initial_centers[k] = [0.5, 0.5] + k += 1 + + # Place the 26th circle in the interstitial position (0.2, 0.2) + initial_centers[k] = [0.2, 0.2] + + # Initialize current centers with the structured layout + centers = np.copy(initial_centers) + + # 2. Physics-based Center Relaxation + # This is the core 'different algorithm approach' where centers move iteratively. + relaxation_steps = 1500 # Increased iterations for better convergence + learning_rate = 0.0008 # Small learning rate for stability and fine-tuning + repulsion_strength = 0.8 # Factor for inter-circle repulsion + wall_repulsion_strength = 0.001 # Factor for wall repulsion, adjusted for effectiveness + + for step in range(relaxation_steps): + # A. Estimate radii for current centers for force calculation + # Using a quick estimate instead of full `compute_max_radii` for performance + estimated_radii = compute_radii_for_force_estimation(centers, num_iterations=15) # More iterations for better estimate + + forces = np.zeros_like(centers) + + # B. Calculate inter-circle repulsion forces + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + + # If circles overlap or are very close, apply repulsive force + min_dist_for_contact = estimated_radii[i] + estimated_radii[j] + if dist < min_dist_for_contact: + # Calculate overlap distance + overlap = min_dist_for_contact - dist + + # Ensure dist is not zero for normalization + direction = vec / (dist + 1e-12) if dist > 1e-12 else np.array([0., 0.]) + + # Force proportional to overlap + force_magnitude = repulsion_strength * overlap + forces[i] += direction * force_magnitude + forces[j] -= direction * force_magnitude + + # C. Calculate wall repulsion forces + for i in range(n): + x, y = centers[i] + r = estimated_radii[i] # Use estimated radius to determine proximity to wall + + # Repulsion from left wall (x=0) + if x < r: + forces[i][0] += wall_repulsion_strength * ((r - x)**2 + 1e-9) / (x + 1e-12) # Stronger repulsion closer to wall + # Repulsion from right wall (x=1) + if x > 1 - r: + forces[i][0] -= wall_repulsion_strength * ((r - (1-x))**2 + 1e-9) / ((1-x) + 1e-12) + # Repulsion from bottom wall (y=0) + if y < r: + forces[i][1] += wall_repulsion_strength * ((r - y)**2 + 1e-9) / (y + 1e-12) + # Repulsion from top wall (y=1) + if y > 1 - r: + forces[i][1] -= wall_repulsion_strength * ((r - (1-y))**2 + 1e-9) / ((1-y) + 1e-12) + + # D. Update center positions + centers += forces * learning_rate + + # E. Enforce boundaries (hard clamp) to prevent circles from escaping + # Small margin to prevent radii calculation issues at exactly 0 or 1. + centers = np.clip(centers, 0.001, 0.999) + + # 3. Final Radii Computation: Use the optimized centers to find the max radii. + final_radii = compute_max_radii(centers) + return centers, final_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for robust convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + vec = centers[i] - centers[j] + dist = np.linalg.norm(vec) + + # Only scale if dist is not zero to avoid division by zero + if dist < 1e-9: # Centers are too close, shrink radii to avoid issues + radii[i] *= 0.95 + radii[j] *= 0.95 + continue + + if radii[i] + radii[j] > dist: + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7ead12720bafb160f48b94f0409b0947980ef6fc Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..4189e32fe22d22846c67053bad36295b8ebd129f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8917204765935548, + "spatial_uniformity_details": { + "cell_size_mean": 0.19479631473968492, + "cell_size_std": 0.023653659171537042, + "coefficient_of_variation": 0.12142765165613548 + }, + "edge_utilization": 0.573076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 8, + "corner_score": 0.75, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.5603557031828542, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00018239881520514523, + "mean_density": 0.017213664491964206, + "cv": 0.7845807481211304 + }, + "packing_efficiency": 0.5400466045214022, + "packing_efficiency_details": { + "total_area": 0.5400466045214022, + "square_area": 1.0, + "efficiency": 0.5400466045214022, + "relative_to_estimated_best": 0.6429126244302408 + }, + "radius_distribution": 0.9770455777282848, + "radius_distribution_details": { + "mean": 0.07805456206097353, + "std": 0.022783928290793554, + "min": 0.0010948105449070772, + "max": 0.10197987945051748, + "range": 0.1008850689056104, + "small_count": 6, + "medium_count": 10, + "large_count": 10, + "diversity_score": 0.9770455777282848 + }, + "gap_analysis": 0.5376, + "gap_analysis_details": { + "covered_samples": 1344, + "total_samples": 2500, + "coverage": 0.5376, + "gap_ratio": 0.46240000000000003 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 35, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865471, + "max_quality": 0.7071067811865479 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..a686bb40c127f22172ed7e371ebf1761677106ac --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.45 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.0294 + + Auxiliary Metrics: + • spatial_uniformity: 0.892 + • edge_utilization: 0.573 + • density_variance: 0.560 + • packing_efficiency: 0.540 + • radius_distribution: 0.977 + • gap_analysis: 0.538 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.0294 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.892 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.573 + • Spatial density uniformity across grid: 0.560 + • Area utilization efficiency: 0.540 + • Radius size diversity: 0.977 + • Area coverage (1 - gap ratio): 0.538 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 46.2% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..d952d097d17b85227bff36be5420c7c657b89814 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.0294186135853116, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4000, 0.4000)\n centers[25] = (0.6000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8917204765935548, + "aux_edge_utilization": 0.573076923076923, + "aux_density_variance": 0.5603557031828542, + "aux_packing_efficiency": 0.5400466045214022, + "aux_radius_distribution": 0.9770455777282848, + "aux_gap_analysis": 0.5376, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.0294186135853116 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.0294\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.892\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.573\n \u2022 Spatial density uniformity across grid: 0.560\n \u2022 Area utilization efficiency: 0.540\n \u2022 Radius size diversity: 0.977\n \u2022 Area coverage (1 - gap ratio): 0.538\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 46.2% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_74/results/packing_viz.png", + "execution_time_mean": 0.44567334093153477, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fa3b1df054e811fe33c5921beb8f0b4f46e45495 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..0207782d5167e979b30e90d54a4595b2464016a4 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/edit.diff @@ -0,0 +1,183 @@ +--- a/original.py ++++ b/original.py +@@ -1,124 +1,149 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np + + + def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This approach builds upon the high-performing 5x5 grid with one + interstitial circle. It introduces a manual "relaxation" step by + perturbing the centers of the circles in the high-tension area + around the interstitial circle to allow for a better overall packing. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 +- centers = np.zeros((n, 2)) ++ best_sum_radii = -1.0 ++ best_centers = None ++ best_radii = None ++ ++ # 1. Create the base configuration of 25 centers: ++ # 24 circles from a 5x5 grid (excluding the center) ++ # 1 central circle at (0.5, 0.5) ++ base_24_grid_centers = np.zeros((24, 2)) + k = 0 +- +- # 1. Create the base configuration of 26 centers as in the previous +- # high-scoring solution. + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + + for i in range(grid_size): + for j in range(grid_size): +- # Skip the central grid point (i=2, j=2 corresponds to 0.5, 0.5) +- if i == 2 and j == 2: ++ if i == 2 and j == 2: # Skip the central grid point (i=2, j=2 corresponds to 0.5, 0.5) + continue +- centers[k] = [coords[j], coords[i]] ++ base_24_grid_centers[k] = [coords[j], coords[i]] + k += 1 + +- centers[k] = [0.5, 0.5] # k=24, central circle +- k += 1 +- centers[k] = [0.2, 0.2] # k=25, interstitial circle ++ # The 25th circle is the central (0.5, 0.5) ++ base_central_circle = np.array([[0.5, 0.5]]) + +- # 2. Apply a targeted perturbation to relax local tension. +- # The interstitial circle at (0.2, 0.2) compresses its four neighbors. +- # We move these four neighbors slightly away from it. +- perturbation_delta = 0.015 # The distance to shift the centers. ++ # Combine the grid circles and the central circle ++ base_25_centers = np.vstack((base_24_grid_centers, base_central_circle)) + +- # Find the indices of the four neighbors based on their creation order. +- # This relies on the specific loop structure above. +- idx_01_01 = 0 # Corresponds to initial center (0.1, 0.1) +- idx_03_01 = 1 # Corresponds to initial center (0.3, 0.1) +- idx_01_03 = 5 # Corresponds to initial center (0.1, 0.3) +- idx_03_03 = 6 # Corresponds to initial center (0.3, 0.3) ++ # Define candidate positions for the 26th (interstitial) circle ++ interstitial_x_candidates = np.linspace(0.2, 0.8, 4) # [0.2, 0.4, 0.6, 0.8] ++ interstitial_y_candidates = np.linspace(0.2, 0.8, 4) # [0.2, 0.4, 0.6, 0.8] + +- # Move (0.1, 0.1) towards the corner (0,0) +- centers[idx_01_01] -= perturbation_delta +- # Move (0.3, 0.1) away from the interstitial circle +- centers[idx_03_01] += [perturbation_delta, -perturbation_delta] +- # Move (0.1, 0.3) away from the interstitial circle +- centers[idx_01_03] += [-perturbation_delta, perturbation_delta] +- # Move (0.3, 0.3) away from the interstitial circle +- centers[idx_03_03] += perturbation_delta ++ perturbation_delta = 0.015 + +- # 3. Compute maximum valid radii for this improved configuration. +- radii = compute_max_radii(centers) +- return centers, radii ++ # These indices refer to the base_24_grid_centers, which are the first 24 in current_centers ++ idx_01_01 = 0 # Corresponds to (0.1, 0.1) ++ idx_03_01 = 1 # Corresponds to (0.3, 0.1) ++ idx_01_03 = 5 # Corresponds to (0.1, 0.3) ++ idx_03_03 = 6 # Corresponds to (0.3, 0.3) ++ ++ for int_x in interstitial_x_candidates: ++ for int_y in interstitial_y_candidates: ++ current_interstitial_point = np.array([int_x, int_y]) ++ ++ # Combine all 26 centers ++ current_centers = np.vstack((base_25_centers, current_interstitial_point)) ++ ++ # 2. Apply a targeted perturbation to relax local tension. ++ # This specific perturbation is only applied if the interstitial point is (0.2, 0.2) ++ # as it was designed for that configuration. ++ if np.allclose(current_interstitial_point, [0.2, 0.2]): ++ temp_centers_to_perturb = np.copy(current_centers) ++ temp_centers_to_perturb[idx_01_01] -= perturbation_delta ++ temp_centers_to_perturb[idx_03_01] += [perturbation_delta, -perturbation_delta] ++ temp_centers_to_perturb[idx_01_03] += [-perturbation_delta, perturbation_delta] ++ temp_centers_to_perturb[idx_03_03] += perturbation_delta ++ current_centers = temp_centers_to_perturb ++ ++ # Ensure all centers are within bounds after perturbation, before radius calculation. ++ # This prevents issues if a perturbation pushes a center slightly outside [0,1]. ++ current_centers = np.clip(current_centers, 0.001, 0.999) ++ ++ # 3. Compute maximum valid radii for this configuration. ++ radii = compute_max_radii(current_centers) ++ current_sum_radii = np.sum(radii) ++ ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = current_centers ++ best_radii = radii ++ ++ return best_centers, best_radii + + + def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version uses the robust iterative relaxation method. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + max_iterations = 2000 + tolerance = 1e-8 + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles to check for overlaps. + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If the sum of radii exceeds the distance, they overlap. + if radii[i] + radii[j] > dist: + # Scale both radii proportionally so they just touch. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass, check for convergence using np.allclose. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/main.py new file mode 100644 index 0000000000000000000000000000000000000000..e4e2d1f2bd1b058f67eba81d60e91e87bb335d1a --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/main.py @@ -0,0 +1,149 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This approach builds upon the high-performing 5x5 grid with one + interstitial circle. It introduces a manual "relaxation" step by + perturbing the centers of the circles in the high-tension area + around the interstitial circle to allow for a better overall packing. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 1. Create the base configuration of 25 centers: + # 24 circles from a 5x5 grid (excluding the center) + # 1 central circle at (0.5, 0.5) + base_24_grid_centers = np.zeros((24, 2)) + k = 0 + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Skip the central grid point (i=2, j=2 corresponds to 0.5, 0.5) + continue + base_24_grid_centers[k] = [coords[j], coords[i]] + k += 1 + + # The 25th circle is the central (0.5, 0.5) + base_central_circle = np.array([[0.5, 0.5]]) + + # Combine the grid circles and the central circle + base_25_centers = np.vstack((base_24_grid_centers, base_central_circle)) + + # Define candidate positions for the 26th (interstitial) circle + interstitial_x_candidates = np.linspace(0.2, 0.8, 4) # [0.2, 0.4, 0.6, 0.8] + interstitial_y_candidates = np.linspace(0.2, 0.8, 4) # [0.2, 0.4, 0.6, 0.8] + + perturbation_delta = 0.015 + + # These indices refer to the base_24_grid_centers, which are the first 24 in current_centers + idx_01_01 = 0 # Corresponds to (0.1, 0.1) + idx_03_01 = 1 # Corresponds to (0.3, 0.1) + idx_01_03 = 5 # Corresponds to (0.1, 0.3) + idx_03_03 = 6 # Corresponds to (0.3, 0.3) + + for int_x in interstitial_x_candidates: + for int_y in interstitial_y_candidates: + current_interstitial_point = np.array([int_x, int_y]) + + # Combine all 26 centers + current_centers = np.vstack((base_25_centers, current_interstitial_point)) + + # 2. Apply a targeted perturbation to relax local tension. + # This specific perturbation is only applied if the interstitial point is (0.2, 0.2) + # as it was designed for that configuration. + if np.allclose(current_interstitial_point, [0.2, 0.2]): + temp_centers_to_perturb = np.copy(current_centers) + temp_centers_to_perturb[idx_01_01] -= perturbation_delta + temp_centers_to_perturb[idx_03_01] += [perturbation_delta, -perturbation_delta] + temp_centers_to_perturb[idx_01_03] += [-perturbation_delta, perturbation_delta] + temp_centers_to_perturb[idx_03_03] += perturbation_delta + current_centers = temp_centers_to_perturb + + # Ensure all centers are within bounds after perturbation, before radius calculation. + # This prevents issues if a perturbation pushes a center slightly outside [0,1]. + current_centers = np.clip(current_centers, 0.001, 0.999) + + # 3. Compute maximum valid radii for this configuration. + radii = compute_max_radii(current_centers) + current_sum_radii = np.sum(radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = radii + + return best_centers, best_radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version uses the robust iterative relaxation method. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + max_iterations = 2000 + tolerance = 1e-8 + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles to check for overlaps. + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If the sum of radii exceeds the distance, they overlap. + if radii[i] + radii[j] > dist: + # Scale both radii proportionally so they just touch. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass, check for convergence using np.allclose. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/original.py new file mode 100644 index 0000000000000000000000000000000000000000..90c977791ad83391299cc353654423e969175dea --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/original.py @@ -0,0 +1,124 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This approach builds upon the high-performing 5x5 grid with one + interstitial circle. It introduces a manual "relaxation" step by + perturbing the centers of the circles in the high-tension area + around the interstitial circle to allow for a better overall packing. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + n = 26 + centers = np.zeros((n, 2)) + k = 0 + + # 1. Create the base configuration of 26 centers as in the previous + # high-scoring solution. + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + + for i in range(grid_size): + for j in range(grid_size): + # Skip the central grid point (i=2, j=2 corresponds to 0.5, 0.5) + if i == 2 and j == 2: + continue + centers[k] = [coords[j], coords[i]] + k += 1 + + centers[k] = [0.5, 0.5] # k=24, central circle + k += 1 + centers[k] = [0.2, 0.2] # k=25, interstitial circle + + # 2. Apply a targeted perturbation to relax local tension. + # The interstitial circle at (0.2, 0.2) compresses its four neighbors. + # We move these four neighbors slightly away from it. + perturbation_delta = 0.015 # The distance to shift the centers. + + # Find the indices of the four neighbors based on their creation order. + # This relies on the specific loop structure above. + idx_01_01 = 0 # Corresponds to initial center (0.1, 0.1) + idx_03_01 = 1 # Corresponds to initial center (0.3, 0.1) + idx_01_03 = 5 # Corresponds to initial center (0.1, 0.3) + idx_03_03 = 6 # Corresponds to initial center (0.3, 0.3) + + # Move (0.1, 0.1) towards the corner (0,0) + centers[idx_01_01] -= perturbation_delta + # Move (0.3, 0.1) away from the interstitial circle + centers[idx_03_01] += [perturbation_delta, -perturbation_delta] + # Move (0.1, 0.3) away from the interstitial circle + centers[idx_01_03] += [-perturbation_delta, perturbation_delta] + # Move (0.3, 0.3) away from the interstitial circle + centers[idx_03_03] += perturbation_delta + + # 3. Compute maximum valid radii for this improved configuration. + radii = compute_max_radii(centers) + return centers, radii + + +def compute_max_radii(centers): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This version uses the robust iterative relaxation method. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on the minimum distance to the square's borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + max_iterations = 2000 + tolerance = 1e-8 + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles to check for overlaps. + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + # If the sum of radii exceeds the distance, they overlap. + if radii[i] + radii[j] > dist: + # Scale both radii proportionally so they just touch. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass, check for convergence using np.allclose. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5d58a07687f8d14f45125e193a23beb106605a81 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.01751952657876505, + "coefficient_of_variation": 0.08804167661183819 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5330758306132531, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0002365403295272031, + "mean_density": 0.0175588153348603, + "cv": 0.8759057202979824 + }, + "packing_efficiency": 0.5339779957454304, + "packing_efficiency_details": { + "total_area": 0.5339779957454304, + "square_area": 1.0, + "efficiency": 0.5339779957454304, + "relative_to_estimated_best": 0.6356880901731314 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.07668559197677258, + "std": 0.025625103836823312, + "min": 0.023971101151201015, + "max": 0.12486579904517191, + "range": 0.10089469789397089, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.5328, + "gap_analysis_details": { + "covered_samples": 1332, + "total_samples": 2500, + "coverage": 0.5328, + "gap_ratio": 0.46719999999999995 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865477 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..914a6649d3b555e8641bfe0ae90f0eef105a82f2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.04 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9938 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.558 + • density_variance: 0.533 + • packing_efficiency: 0.534 + • radius_distribution: 0.974 + • gap_analysis: 0.533 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9938 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.533 + • Area utilization efficiency: 0.534 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.533 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 46.7% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..c2d15bdfbf424f552300ed40a81fb1820d6651ba --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9938253913960868, + "public": { + "centers_str": " centers[0] = (0.1000, 0.1000)\n centers[1] = (0.3000, 0.1000)\n centers[2] = (0.5000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.4000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5330758306132531, + "aux_packing_efficiency": 0.5339779957454304, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.5328, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 1.9938253913960868 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9938\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.533\n \u2022 Area utilization efficiency: 0.534\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.533\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 46.7% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/results/packing_viz.png", + "execution_time_mean": 0.03598682302981615, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..02576489f716823096c1ef2798b075b1d060c8c9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_75/search_replace.txt @@ -0,0 +1,126 @@ + +Systematic search for interstitial circle position + +The previous version relies on a hardcoded interstitial circle at (0.2, 0.2). This edit introduces a systematic search for the optimal position of this 26th interstitial circle. Instead of fixing it, we now iterate through a grid of 16 potential interstitial locations within the 5x5 grid cells (e.g., (0.2,0.2), (0.2,0.4), ..., (0.8,0.8)). For each candidate position, we construct the full set of 26 circles and compute their maximum radii. The configuration yielding the highest sum of radii is chosen as the best packing. The specific perturbation logic that was effective for the (0.2, 0.2) interstitial is preserved and applied only when that particular candidate position is being evaluated. This approach addresses the "Detected 47.8% unused space" recommendation by exploring more possibilities for filling gaps with the additional circle. It is a direct implementation of "Systematic exploration of candidate interstitial positions" (Recommendation 3), expanded to a grid search. + + + +<<<<<<< SEARCH + n = 26 + centers = np.zeros((n, 2)) + k = 0 + + # 1. Create the base configuration of 26 centers as in the previous + # high-scoring solution. + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + + for i in range(grid_size): + for j in range(grid_size): + # Skip the central grid point (i=2, j=2 corresponds to 0.5, 0.5) + if i == 2 and j == 2: + continue + centers[k] = [coords[j], coords[i]] + k += 1 + + centers[k] = [0.5, 0.5] # k=24, central circle + k += 1 + centers[k] = [0.2, 0.2] # k=25, interstitial circle + + # 2. Apply a targeted perturbation to relax local tension. + # The interstitial circle at (0.2, 0.2) compresses its four neighbors. + # We move these four neighbors slightly away from it. + perturbation_delta = 0.015 # The distance to shift the centers. + + # Find the indices of the four neighbors based on their creation order. + # This relies on the specific loop structure above. + idx_01_01 = 0 # Corresponds to initial center (0.1, 0.1) + idx_03_01 = 1 # Corresponds to initial center (0.3, 0.1) + idx_01_03 = 5 # Corresponds to initial center (0.1, 0.3) + idx_03_03 = 6 # Corresponds to initial center (0.3, 0.3) + + # Move (0.1, 0.1) towards the corner (0,0) + centers[idx_01_01] -= perturbation_delta + # Move (0.3, 0.1) away from the interstitial circle + centers[idx_03_01] += [perturbation_delta, -perturbation_delta] + # Move (0.1, 0.3) away from the interstitial circle + centers[idx_01_03] += [-perturbation_delta, perturbation_delta] + # Move (0.3, 0.3) away from the interstitial circle + centers[idx_03_03] += perturbation_delta + + # 3. Compute maximum valid radii for this improved configuration. + radii = compute_max_radii(centers) + return centers, radii +======= + n = 26 + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 1. Create the base configuration of 25 centers: + # 24 circles from a 5x5 grid (excluding the center) + # 1 central circle at (0.5, 0.5) + base_24_grid_centers = np.zeros((24, 2)) + k = 0 + grid_size = 5 + coords = np.linspace(0.1, 0.9, grid_size) + + for i in range(grid_size): + for j in range(grid_size): + if i == 2 and j == 2: # Skip the central grid point (i=2, j=2 corresponds to 0.5, 0.5) + continue + base_24_grid_centers[k] = [coords[j], coords[i]] + k += 1 + + # The 25th circle is the central (0.5, 0.5) + base_central_circle = np.array([[0.5, 0.5]]) + + # Combine the grid circles and the central circle + base_25_centers = np.vstack((base_24_grid_centers, base_central_circle)) + + # Define candidate positions for the 26th (interstitial) circle + interstitial_x_candidates = np.linspace(0.2, 0.8, 4) # [0.2, 0.4, 0.6, 0.8] + interstitial_y_candidates = np.linspace(0.2, 0.8, 4) # [0.2, 0.4, 0.6, 0.8] + + perturbation_delta = 0.015 + + # These indices refer to the base_24_grid_centers, which are the first 24 in current_centers + idx_01_01 = 0 # Corresponds to (0.1, 0.1) + idx_03_01 = 1 # Corresponds to (0.3, 0.1) + idx_01_03 = 5 # Corresponds to (0.1, 0.3) + idx_03_03 = 6 # Corresponds to (0.3, 0.3) + + for int_x in interstitial_x_candidates: + for int_y in interstitial_y_candidates: + current_interstitial_point = np.array([int_x, int_y]) + + # Combine all 26 centers + current_centers = np.vstack((base_25_centers, current_interstitial_point)) + + # 2. Apply a targeted perturbation to relax local tension. + # This specific perturbation is only applied if the interstitial point is (0.2, 0.2) + # as it was designed for that configuration. + if np.allclose(current_interstitial_point, [0.2, 0.2]): + temp_centers_to_perturb = np.copy(current_centers) + temp_centers_to_perturb[idx_01_01] -= perturbation_delta + temp_centers_to_perturb[idx_03_01] += [perturbation_delta, -perturbation_delta] + temp_centers_to_perturb[idx_01_03] += [-perturbation_delta, perturbation_delta] + temp_centers_to_perturb[idx_03_03] += perturbation_delta + current_centers = temp_centers_to_perturb + + # Ensure all centers are within bounds after perturbation, before radius calculation. + # This prevents issues if a perturbation pushes a center slightly outside [0,1]. + current_centers = np.clip(current_centers, 0.001, 0.999) + + # 3. Compute maximum valid radii for this configuration. + radii = compute_max_radii(current_centers) + current_sum_radii = np.sum(radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = radii + + return best_centers, best_radii +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b4ceedd74debde32d32788ceb90f92f8cdea0fe3 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..a5df0984bcb211412b9690ea6952b6fd5fc771af --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9387798580462884, + "spatial_uniformity_details": { + "cell_size_mean": 0.19980363367049334, + "cell_size_std": 0.013029686110704769, + "coefficient_of_variation": 0.06521245788242395 + }, + "edge_utilization": 0.5576923076923077, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 7, + "corner_score": 0.75, + "edge_score": 0.2692307692307692 + }, + "density_variance": 0.5337590746617289, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00024145287362607956, + "mean_density": 0.017788979904745733, + "cv": 0.873504446989969 + }, + "packing_efficiency": 0.527476741499729, + "packing_efficiency_details": { + "total_area": 0.527476741499729, + "square_area": 1.0, + "efficiency": 0.527476741499729, + "relative_to_estimated_best": 0.6279485017853917 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.07598123928368375, + "std": 0.026164564080201267, + "min": 0.03506907627494472, + "max": 0.12512441672359573, + "range": 0.09005534044865102, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.5224, + "gap_analysis_details": { + "covered_samples": 1306, + "total_samples": 2500, + "coverage": 0.5224, + "gap_ratio": 0.4776 + }, + "geometric_quality": 0.6705218465938836, + "geometric_quality_details": { + "num_triangles": 38, + "avg_triangle_quality": 0.6705218465938836, + "min_quality": 0.34163261903956604, + "max_quality": 0.7094270617819698 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..1f757b63ba912bb1a8de261c108e9aacb86d3ba0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.47 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9755 + + Auxiliary Metrics: + • spatial_uniformity: 0.939 + • edge_utilization: 0.558 + • density_variance: 0.534 + • packing_efficiency: 0.527 + • radius_distribution: 0.974 + • gap_analysis: 0.522 + • geometric_quality: 0.671 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9755 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.939 + +📊 Other Metrics: + • Boundary and corner utilization: 0.558 + • Spatial density uniformity across grid: 0.534 + • Area utilization efficiency: 0.527 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.522 + • Delaunay triangulation quality: 0.671 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 47.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..885c98ab216d3e2dcdccb7222764dfcfd5345d11 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9755122213757774, + "public": { + "centers_str": " centers[0] = (0.0852, 0.0852)\n centers[1] = (0.3150, 0.0852)\n centers[2] = (0.5000, 0.1001)\n centers[3] = (0.7000, 0.1001)\n centers[4] = (0.8999, 0.1001)\n centers[5] = (0.0852, 0.3150)\n centers[6] = (0.3150, 0.3150)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.8999, 0.3000)\n centers[10] = (0.1001, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.8999, 0.5000)\n centers[14] = (0.1001, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.8999, 0.7000)\n centers[19] = (0.1001, 0.8999)\n centers[20] = (0.3000, 0.8999)\n centers[21] = (0.5000, 0.8999)\n centers[22] = (0.7000, 0.8999)\n centers[23] = (0.8999, 0.8999)\n centers[24] = (0.5000, 0.5000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9387798580462884, + "aux_edge_utilization": 0.5576923076923077, + "aux_density_variance": 0.5337590746617289, + "aux_packing_efficiency": 0.527476741499729, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.5224, + "aux_geometric_quality": 0.6705218465938836 + }, + "private": { + "reported_sum_of_radii": 1.9755122213757774 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9755\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.939\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.558\n \u2022 Spatial density uniformity across grid: 0.534\n \u2022 Area utilization efficiency: 0.527\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.522\n \u2022 Delaunay triangulation quality: 0.671\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 47.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_76/results/packing_viz.png", + "execution_time_mean": 0.4677794282324612, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1af90a76497d6ddfcd0fd4dff8d461e70b4ff72d Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..9745145d0773b2b605a0027eff538b11301e379c --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9387420797799824, + "spatial_uniformity_details": { + "cell_size_mean": 0.19989521731533133, + "cell_size_std": 0.013044227588895911, + "coefficient_of_variation": 0.06525532575931288 + }, + "edge_utilization": 0.573076923076923, + "edge_utilization_details": { + "corners_touched": 3, + "edges_touched": 8, + "corner_score": 0.75, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.5909221939736454, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00016044798947514118, + "mean_density": 0.01829748920167389, + "cv": 0.6922701672034322 + }, + "packing_efficiency": 0.547547346224708, + "packing_efficiency_details": { + "total_area": 0.547547346224708, + "square_area": 1.0, + "efficiency": 0.547547346224708, + "relative_to_estimated_best": 0.6518420788389382 + }, + "radius_distribution": 0.9947372351472321, + "radius_distribution_details": { + "mean": 0.07912281967258991, + "std": 0.021048294322044588, + "min": 0.008690259640489735, + "max": 0.10199880854307497, + "range": 0.09330854890258523, + "small_count": 8, + "medium_count": 8, + "large_count": 10, + "diversity_score": 0.9947372351472321 + }, + "gap_analysis": 0.5532, + "gap_analysis_details": { + "covered_samples": 1383, + "total_samples": 2500, + "coverage": 0.5532, + "gap_ratio": 0.4468 + }, + "geometric_quality": 0.6705887302733149, + "geometric_quality_details": { + "num_triangles": 38, + "avg_triangle_quality": 0.6705887302733149, + "min_quality": 0.34176801056734396, + "max_quality": 0.7094272836976588 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3e607e8b8adaaf33a65ee3d1bcc7bf7badd1164f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.00 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.0572 + + Auxiliary Metrics: + • spatial_uniformity: 0.939 + • edge_utilization: 0.573 + • density_variance: 0.591 + • packing_efficiency: 0.548 + • radius_distribution: 0.995 + • gap_analysis: 0.553 + • geometric_quality: 0.671 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.0572 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.939 + +📊 Other Metrics: + • Boundary and corner utilization: 0.573 + • Spatial density uniformity across grid: 0.591 + • Area utilization efficiency: 0.548 + • Radius size diversity: 0.995 + • Area coverage (1 - gap ratio): 0.553 + • Delaunay triangulation quality: 0.671 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 44.7% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..b6c0a23f4c637a668a85cde09bf3d3dd2e98efc8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.0571933114873375, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.0850, 0.0850)\n centers[2] = (0.3150, 0.0850)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.0850, 0.3150)\n centers[7] = (0.3150, 0.3150)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.2000, 0.2000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9387420797799824, + "aux_edge_utilization": 0.573076923076923, + "aux_density_variance": 0.5909221939736454, + "aux_packing_efficiency": 0.547547346224708, + "aux_radius_distribution": 0.9947372351472321, + "aux_gap_analysis": 0.5532, + "aux_geometric_quality": 0.6705887302733149 + }, + "private": { + "reported_sum_of_radii": 2.0571933114873375 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.0572\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.939\n\n\ud83d\udcca Other Metrics:\n \u2022 Boundary and corner utilization: 0.573\n \u2022 Spatial density uniformity across grid: 0.591\n \u2022 Area utilization efficiency: 0.548\n \u2022 Radius size diversity: 0.995\n \u2022 Area coverage (1 - gap ratio): 0.553\n \u2022 Delaunay triangulation quality: 0.671\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 44.7% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_80/results/packing_viz.png", + "execution_time_mean": 0.0028174398466944695, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ace0bdef12b3ea62d0d5431320d8055f62508a3a Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..2dafdf09fada5f8d196ea17f7beddc81d270f04b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/edit.diff @@ -0,0 +1,314 @@ +--- a/original.py ++++ b/original.py +@@ -1,163 +1,172 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" ++""" ++Object-oriented circle packing optimizer for n=26 circles. ++This version refactors the procedural code into a class-based framework ++to improve structure, modularity, and extensibility. ++""" + + import numpy as np + ++class PackingOptimizer: ++ """ ++ An object-oriented framework for finding optimal circle packings. ++ Encapsulates the search state, configuration generation, and evaluation logic. ++ """ ++ def __init__(self, n_circles=26, grid_size=5): ++ """Initializes the optimizer with problem parameters.""" ++ self.n_circles = n_circles ++ self.grid_size = grid_size ++ self.best_sum_radii = -1.0 ++ self.best_centers = None ++ self.best_radii = None + +-def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): +- """ +- Generates centers for a square grid of circles. +- """ +- x_coords = np.linspace(start_coord, end_coord, grid_size) +- y_coords = np.linspace(start_coord, end_coord, grid_size) +- grid_centers = [] +- for y in y_coords: +- for x in x_coords: +- grid_centers.append([x, y]) +- return np.array(grid_centers) ++ def optimize(self): ++ """ ++ Runs the main optimization loop, searching through generated configurations ++ to find the one that maximizes the sum of radii. + ++ Returns: ++ Tuple of (centers, radii) for the best found packing. ++ """ ++ # Iterate through all candidate configurations yielded by the generator ++ for centers, params in self._generate_configurations(): ++ radii = self._relax_radii(centers, params) ++ current_sum_radii = np.sum(radii) + +-def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): +- """ +- Generates potential interstitial points within the grid. +- For a GxG grid, there are (G-1)x(G-1) interstitial points. +- """ +- if grid_size < 2: +- return np.array([]) ++ if current_sum_radii > self.best_sum_radii: ++ self.best_sum_radii = current_sum_radii ++ self.best_centers = centers ++ self.best_radii = radii + +- step_coord = (end_coord - start_coord) / (grid_size - 1) ++ return self.best_centers, self.best_radii + +- candidates = [] +- for i in range(grid_size - 1): +- for j in range(grid_size - 1): +- interstitial_x = start_coord + j * step_coord + step_coord / 2 +- interstitial_y = start_coord + i * step_coord + step_coord / 2 +- candidates.append([interstitial_x, interstitial_y]) +- return np.array(candidates) ++ def _generate_configurations(self): ++ """ ++ A generator that yields candidate circle configurations to be evaluated. ++ It explores a hyperparameter space including asymmetrical grid boundaries ++ and the central circle's relaxation weight. ++ """ ++ # Define search space for hyperparameters (Recommendations #2 and #4) ++ start_coord_options = np.linspace(0.08, 0.12, 3) # e.g., [0.08, 0.10, 0.12] ++ end_coord_options = np.linspace(0.88, 0.92, 3) # e.g., [0.88, 0.90, 0.92] ++ central_weight_options = np.linspace(1.25, 1.75, 3) # e.g., [1.25, 1.5, 1.75] + ++ # Explore asymmetric grid configurations ++ for sc_x in start_coord_options: ++ for ec_x in end_coord_options: ++ if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): ++ continue ++ for sc_y in start_coord_options: ++ for ec_y in end_coord_options: ++ if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): ++ continue ++ ++ grid_params = {'sc_x': sc_x, 'ec_x': ec_x, 'sc_y': sc_y, 'ec_y': ec_y} ++ ++ base_centers = self._generate_base_layout(grid_params) ++ interstitial_candidates = self._generate_interstitial_candidates(grid_params) ++ ++ # Test each interstitial candidate for the current grid ++ for interstitial_point in interstitial_candidates: ++ current_centers = np.vstack([base_centers, interstitial_point]) ++ ++ # Test each central weight for the current geometry ++ for w_central in central_weight_options: ++ params = { ++ 'interstitial_idx': self.n_circles - 1, ++ 'w_central': w_central ++ } ++ yield current_centers, params ++ ++ def _generate_base_layout(self, grid_params): ++ """Generates the 25 base circles (1 central, 24 peripheral).""" ++ x_coords = np.linspace(grid_params['sc_x'], grid_params['ec_x'], self.grid_size) ++ y_coords = np.linspace(grid_params['sc_y'], grid_params['ec_y'], self.grid_size) ++ all_grid_centers = np.array([[x, y] for y in y_coords for x in x_coords]) ++ ++ central_point_coords = np.array([0.5, 0.5]) ++ central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] ++ ++ base_centers = np.zeros((self.n_circles - 1, 2)) ++ base_centers[0] = central_point_coords # Central circle at index 0 ++ other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) ++ base_centers[1:] = other_grid_centers ++ return base_centers ++ ++ def _generate_interstitial_candidates(self, grid_params): ++ """Generates interstitial candidates for an asymmetric grid.""" ++ step_x = (grid_params['ec_x'] - grid_params['sc_x']) / (self.grid_size - 1) ++ step_y = (grid_params['ec_y'] - grid_params['sc_y']) / (self.grid_size - 1) ++ ++ candidates = [] ++ for i in range(self.grid_size - 1): ++ for j in range(self.grid_size - 1): ++ interstitial_x = grid_params['sc_x'] + j * step_x + step_x / 2 ++ interstitial_y = grid_params['sc_y'] + i * step_y + step_y / 2 ++ candidates.append([interstitial_x, interstitial_y]) ++ return np.array(candidates) ++ ++ def _relax_radii(self, centers, params, max_iterations=2000, tolerance=1e-7): ++ """ ++ Computes maximum radii for a given set of centers using iterative relaxation. ++ This is the core evaluation function. ++ """ ++ n = centers.shape[0] ++ radii = np.zeros(n) ++ interstitial_idx = params.get('interstitial_idx', -1) ++ w_central = params.get('w_central', 1.5) ++ ++ # 1. Initialize radii based on boundary distances. ++ for i in range(n): ++ x, y = centers[i] ++ radii[i] = min(x, y, 1 - x, 1 - y) ++ ++ # 2. Adaptive heuristic for interstitial circle's initial radius. ++ if interstitial_idx != -1: ++ other_centers = np.delete(centers, interstitial_idx, axis=0) ++ if len(other_centers) > 0: ++ distances = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) ++ radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * np.min(distances)) ++ ++ # 3. Iteratively relax radii to resolve overlaps. ++ for _ in range(max_iterations): ++ prev_radii = np.copy(radii) ++ for i in range(n): ++ for j in range(i + 1, n): ++ dist = np.linalg.norm(centers[i] - centers[j]) ++ if radii[i] + radii[j] > dist: ++ overlap = radii[i] + radii[j] - dist ++ w_i = w_central if i == 0 else 1.0 ++ w_j = w_central if j == 0 else 1.0 ++ ++ weighted_r_i = radii[i] / w_i ++ weighted_r_j = radii[j] / w_j ++ total_weighted = weighted_r_i + weighted_r_j ++ ++ if total_weighted > 1e-12: ++ radii[i] -= overlap * (weighted_r_i / total_weighted) ++ radii[j] -= overlap * (weighted_r_j / total_weighted) ++ ++ radii[radii < 0] = 0 ++ if np.allclose(radii, prev_radii, atol=tolerance): ++ break ++ return radii + + def construct_packing(): + """ +- Reinstates a robust strategy from prior successful runs. This function +- constructs an arrangement of 26 circles by first placing 25 circles +- (one at the center, 24 on a peripheral grid) and then systematically +- searching for the best position for the 26th circle from a set of +- interstitial candidates. +- +- Returns: +- Tuple of (centers, radii) ++ Constructs the circle packing by creating and running the optimizer. ++ This function serves as the main entry point, adhering to the expected API. + """ +- n_circles = 26 +- grid_size = 5 +- start_coord = 0.1 +- end_coord = 0.9 +- +- all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) +- +- # 1. Prioritize the central (0.5, 0.5) circle by placing it first. +- central_point_coords = np.array([0.5, 0.5]) +- central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] +- +- base_centers = np.zeros((n_circles - 1, 2)) +- base_centers[0] = central_point_coords +- other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- base_centers[1:] = other_grid_centers +- +- # 2. Generate interstitial candidates for the 26th circle. +- candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) +- +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None +- +- # 3. Explore each candidate to find the one maximizing the sum of radii. +- for interstitial_point in candidate_interstitial_points: +- current_centers = np.vstack([base_centers, interstitial_point]) +- interstitial_idx = n_circles - 1 +- +- current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) +- current_sum_radii = np.sum(current_radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii +- +- return best_centers, best_radii +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): +- """ +- Compute maximum radii using an iterative relaxation approach. Includes a +- heuristic to cap the initial radius of the interstitial circle and applies +- weighted scaling to protect the central circle (at index 0). +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates. +- max_iterations: Maximum iterations for the relaxation process. +- tolerance: Convergence tolerance. +- interstitial_idx: Index of the interstitial circle to apply the heuristic. +- +- Returns: +- np.array: Array of radii for each circle. +- """ +- n = centers.shape[0] +- radii = np.zeros(n) +- +- # 1. Initialize radii based on distance to square borders. +- for i in range(n): +- x, y = centers[i] +- radii[i] = min(x, y, 1 - x, 1 - y) +- +- # Heuristic: Cap the initial radius of the interstitial circle. +- # This prevents it from growing too large initially and sub-optimally +- # squeezing its neighbors, allowing for a better overall packing. +- if interstitial_idx != -1 and interstitial_idx < n: +- radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) +- +- # 2. Iteratively adjust radii to resolve overlaps until convergence. +- for _ in range(max_iterations): +- prev_radii = np.copy(radii) +- +- for i in range(n): +- for j in range(i + 1, n): +- dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) +- +- if radii[i] + radii[j] > dist: +- overlap = radii[i] + radii[j] - dist +- +- # Weighted proportional scaling to protect the central circle (at index 0). +- # A higher weight means the circle's radius is reduced less. +- w_i = 1.5 if i == 0 else 1.0 +- w_j = 1.5 if j == 0 else 1.0 # j is always > i, so this is just for clarity +- +- # The reduction for each circle is proportional to its radius and inversely proportional to its weight. +- weighted_r_i = radii[i] / w_i +- weighted_r_j = radii[j] / w_j +- +- total_weighted_radii = weighted_r_i + weighted_r_j +- +- if total_weighted_radii > 1e-12: +- radii[i] -= overlap * weighted_r_i / total_weighted_radii +- radii[j] -= overlap * weighted_r_j / total_weighted_radii +- elif (radii[i] + radii[j]) > 1e-12: # Fallback for tiny radii +- scale_factor = dist / (radii[i] + radii[j]) +- radii[i] *= scale_factor +- radii[j] *= scale_factor +- +- if np.allclose(radii, prev_radii, atol=tolerance): +- break +- +- return radii +- +- ++ optimizer = PackingOptimizer(n_circles=26) ++ centers, radii = optimizer.optimize() ++ return centers, radii + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/main.py new file mode 100644 index 0000000000000000000000000000000000000000..20aca29a76e4ad7b12e0c02fa088097fdadb4d43 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/main.py @@ -0,0 +1,172 @@ +# EVOLVE-BLOCK-START +""" +Object-oriented circle packing optimizer for n=26 circles. +This version refactors the procedural code into a class-based framework +to improve structure, modularity, and extensibility. +""" + +import numpy as np + +class PackingOptimizer: + """ + An object-oriented framework for finding optimal circle packings. + Encapsulates the search state, configuration generation, and evaluation logic. + """ + def __init__(self, n_circles=26, grid_size=5): + """Initializes the optimizer with problem parameters.""" + self.n_circles = n_circles + self.grid_size = grid_size + self.best_sum_radii = -1.0 + self.best_centers = None + self.best_radii = None + + def optimize(self): + """ + Runs the main optimization loop, searching through generated configurations + to find the one that maximizes the sum of radii. + + Returns: + Tuple of (centers, radii) for the best found packing. + """ + # Iterate through all candidate configurations yielded by the generator + for centers, params in self._generate_configurations(): + radii = self._relax_radii(centers, params) + current_sum_radii = np.sum(radii) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = centers + self.best_radii = radii + + return self.best_centers, self.best_radii + + def _generate_configurations(self): + """ + A generator that yields candidate circle configurations to be evaluated. + It explores a hyperparameter space including asymmetrical grid boundaries + and the central circle's relaxation weight. + """ + # Define search space for hyperparameters (Recommendations #2 and #4) + start_coord_options = np.linspace(0.08, 0.12, 3) # e.g., [0.08, 0.10, 0.12] + end_coord_options = np.linspace(0.88, 0.92, 3) # e.g., [0.88, 0.90, 0.92] + central_weight_options = np.linspace(1.25, 1.75, 3) # e.g., [1.25, 1.5, 1.75] + + # Explore asymmetric grid configurations + for sc_x in start_coord_options: + for ec_x in end_coord_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + for sc_y in start_coord_options: + for ec_y in end_coord_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + grid_params = {'sc_x': sc_x, 'ec_x': ec_x, 'sc_y': sc_y, 'ec_y': ec_y} + + base_centers = self._generate_base_layout(grid_params) + interstitial_candidates = self._generate_interstitial_candidates(grid_params) + + # Test each interstitial candidate for the current grid + for interstitial_point in interstitial_candidates: + current_centers = np.vstack([base_centers, interstitial_point]) + + # Test each central weight for the current geometry + for w_central in central_weight_options: + params = { + 'interstitial_idx': self.n_circles - 1, + 'w_central': w_central + } + yield current_centers, params + + def _generate_base_layout(self, grid_params): + """Generates the 25 base circles (1 central, 24 peripheral).""" + x_coords = np.linspace(grid_params['sc_x'], grid_params['ec_x'], self.grid_size) + y_coords = np.linspace(grid_params['sc_y'], grid_params['ec_y'], self.grid_size) + all_grid_centers = np.array([[x, y] for y in y_coords for x in x_coords]) + + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((self.n_circles - 1, 2)) + base_centers[0] = central_point_coords # Central circle at index 0 + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + return base_centers + + def _generate_interstitial_candidates(self, grid_params): + """Generates interstitial candidates for an asymmetric grid.""" + step_x = (grid_params['ec_x'] - grid_params['sc_x']) / (self.grid_size - 1) + step_y = (grid_params['ec_y'] - grid_params['sc_y']) / (self.grid_size - 1) + + candidates = [] + for i in range(self.grid_size - 1): + for j in range(self.grid_size - 1): + interstitial_x = grid_params['sc_x'] + j * step_x + step_x / 2 + interstitial_y = grid_params['sc_y'] + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + def _relax_radii(self, centers, params, max_iterations=2000, tolerance=1e-7): + """ + Computes maximum radii for a given set of centers using iterative relaxation. + This is the core evaluation function. + """ + n = centers.shape[0] + radii = np.zeros(n) + interstitial_idx = params.get('interstitial_idx', -1) + w_central = params.get('w_central', 1.5) + + # 1. Initialize radii based on boundary distances. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Adaptive heuristic for interstitial circle's initial radius. + if interstitial_idx != -1: + other_centers = np.delete(centers, interstitial_idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) + radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * np.min(distances)) + + # 3. Iteratively relax radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = w_central if j == 0 else 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + +def construct_packing(): + """ + Constructs the circle packing by creating and running the optimizer. + This function serves as the main entry point, adhering to the expected API. + """ + optimizer = PackingOptimizer(n_circles=26) + centers, radii = optimizer.optimize() + return centers, radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/original.py new file mode 100644 index 0000000000000000000000000000000000000000..bdfdd6b38dfffad39156931cbb03e1ce571d0f1f --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/original.py @@ -0,0 +1,163 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_grid_centers(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates centers for a square grid of circles. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size=5, start_coord=0.1, end_coord=0.9): + """ + Generates potential interstitial points within the grid. + For a GxG grid, there are (G-1)x(G-1) interstitial points. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + for i in range(grid_size - 1): + for j in range(grid_size - 1): + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def construct_packing(): + """ + Reinstates a robust strategy from prior successful runs. This function + constructs an arrangement of 26 circles by first placing 25 circles + (one at the center, 24 on a peripheral grid) and then systematically + searching for the best position for the 26th circle from a set of + interstitial candidates. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + grid_size = 5 + start_coord = 0.1 + end_coord = 0.9 + + all_grid_centers = _generate_grid_centers(grid_size, start_coord, end_coord) + + # 1. Prioritize the central (0.5, 0.5) circle by placing it first. + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, start_coord, end_coord) + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # 3. Explore each candidate to find the one maximizing the sum of radii. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic to cap the initial radius of the interstitial circle and applies + weighted scaling to protect the central circle (at index 0). + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Cap the initial radius of the interstitial circle. + # This prevents it from growing too large initially and sub-optimally + # squeezing its neighbors, allowing for a better overall packing. + if interstitial_idx != -1 and interstitial_idx < n: + radii[interstitial_idx] = min(radii[interstitial_idx], 0.05) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # A higher weight means the circle's radius is reduced less. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.5 if j == 0 else 1.0 # j is always > i, so this is just for clarity + + # The reduction for each circle is proportional to its radius and inversely proportional to its weight. + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: + radii[i] -= overlap * weighted_r_i / total_weighted_radii + radii[j] -= overlap * weighted_r_j / total_weighted_radii + elif (radii[i] + radii[j]) > 1e-12: # Fallback for tiny radii + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..09ef32b0623faa4a0b899716ffd4a8852e6805f2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.017519526578765064, + "coefficient_of_variation": 0.08804167661183826 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6452435671070412, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001320151649216326, + "mean_density": 0.020898027415687245, + "cv": 0.5498023552307764 + }, + "packing_efficiency": 0.5927853551691786, + "packing_efficiency_details": { + "total_area": 0.5927853551691786, + "square_area": 1.0, + "efficiency": 0.5927853551691786, + "relative_to_estimated_best": 0.7056968513918793 + }, + "radius_distribution": 0.982944883585438, + "radius_distribution_details": { + "mean": 0.08344677668148125, + "std": 0.017144141109075504, + "min": 0.02780907365919041, + "max": 0.10186995664981877, + "range": 0.07406088299062835, + "small_count": 8, + "medium_count": 7, + "large_count": 11, + "diversity_score": 0.982944883585438 + }, + "gap_analysis": 0.5984, + "gap_analysis_details": { + "covered_samples": 1496, + "total_samples": 2500, + "coverage": 0.5984, + "gap_ratio": 0.40159999999999996 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..b81b8303a882e20fcfdc2eb534c78937130057f9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 1.04 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1696 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.645 + • packing_efficiency: 0.593 + • radius_distribution: 0.983 + • gap_analysis: 0.598 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1696 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.645 + • Area utilization efficiency: 0.593 + • Radius size diversity: 0.983 + • Area coverage (1 - gap ratio): 0.598 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 40.2% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..4c16d7905caf9f1f1b897f654134bdc8c3f04514 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1696161937185123, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6452435671070412, + "aux_packing_efficiency": 0.5927853551691786, + "aux_radius_distribution": 0.982944883585438, + "aux_gap_analysis": 0.5984, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.1696161937185123 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1696\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.645\n \u2022 Area utilization efficiency: 0.593\n \u2022 Radius size diversity: 0.983\n \u2022 Area coverage (1 - gap ratio): 0.598\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 40.2% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/results/packing_viz.png", + "execution_time_mean": 1.040869229938835, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..591a02c5ee9d3885e98ae4163023a65d1301d660 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_82/rewrite.txt @@ -0,0 +1,163 @@ +# EVOLVE-BLOCK-START +""" +Object-oriented circle packing optimizer for n=26 circles. +This version refactors the procedural code into a class-based framework +to improve structure, modularity, and extensibility. +""" + +import numpy as np + +class PackingOptimizer: + """ + An object-oriented framework for finding optimal circle packings. + Encapsulates the search state, configuration generation, and evaluation logic. + """ + def __init__(self, n_circles=26, grid_size=5): + """Initializes the optimizer with problem parameters.""" + self.n_circles = n_circles + self.grid_size = grid_size + self.best_sum_radii = -1.0 + self.best_centers = None + self.best_radii = None + + def optimize(self): + """ + Runs the main optimization loop, searching through generated configurations + to find the one that maximizes the sum of radii. + + Returns: + Tuple of (centers, radii) for the best found packing. + """ + # Iterate through all candidate configurations yielded by the generator + for centers, params in self._generate_configurations(): + radii = self._relax_radii(centers, params) + current_sum_radii = np.sum(radii) + + if current_sum_radii > self.best_sum_radii: + self.best_sum_radii = current_sum_radii + self.best_centers = centers + self.best_radii = radii + + return self.best_centers, self.best_radii + + def _generate_configurations(self): + """ + A generator that yields candidate circle configurations to be evaluated. + It explores a hyperparameter space including asymmetrical grid boundaries + and the central circle's relaxation weight. + """ + # Define search space for hyperparameters (Recommendations #2 and #4) + start_coord_options = np.linspace(0.08, 0.12, 3) # e.g., [0.08, 0.10, 0.12] + end_coord_options = np.linspace(0.88, 0.92, 3) # e.g., [0.88, 0.90, 0.92] + central_weight_options = np.linspace(1.25, 1.75, 3) # e.g., [1.25, 1.5, 1.75] + + # Explore asymmetric grid configurations + for sc_x in start_coord_options: + for ec_x in end_coord_options: + if ec_x <= sc_x or not np.isclose((sc_x + ec_x) / 2.0, 0.5): + continue + for sc_y in start_coord_options: + for ec_y in end_coord_options: + if ec_y <= sc_y or not np.isclose((sc_y + ec_y) / 2.0, 0.5): + continue + + grid_params = {'sc_x': sc_x, 'ec_x': ec_x, 'sc_y': sc_y, 'ec_y': ec_y} + + base_centers = self._generate_base_layout(grid_params) + interstitial_candidates = self._generate_interstitial_candidates(grid_params) + + # Test each interstitial candidate for the current grid + for interstitial_point in interstitial_candidates: + current_centers = np.vstack([base_centers, interstitial_point]) + + # Test each central weight for the current geometry + for w_central in central_weight_options: + params = { + 'interstitial_idx': self.n_circles - 1, + 'w_central': w_central + } + yield current_centers, params + + def _generate_base_layout(self, grid_params): + """Generates the 25 base circles (1 central, 24 peripheral).""" + x_coords = np.linspace(grid_params['sc_x'], grid_params['ec_x'], self.grid_size) + y_coords = np.linspace(grid_params['sc_y'], grid_params['ec_y'], self.grid_size) + all_grid_centers = np.array([[x, y] for y in y_coords for x in x_coords]) + + central_point_coords = np.array([0.5, 0.5]) + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + + base_centers = np.zeros((self.n_circles - 1, 2)) + base_centers[0] = central_point_coords # Central circle at index 0 + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + return base_centers + + def _generate_interstitial_candidates(self, grid_params): + """Generates interstitial candidates for an asymmetric grid.""" + step_x = (grid_params['ec_x'] - grid_params['sc_x']) / (self.grid_size - 1) + step_y = (grid_params['ec_y'] - grid_params['sc_y']) / (self.grid_size - 1) + + candidates = [] + for i in range(self.grid_size - 1): + for j in range(self.grid_size - 1): + interstitial_x = grid_params['sc_x'] + j * step_x + step_x / 2 + interstitial_y = grid_params['sc_y'] + i * step_y + step_y / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + def _relax_radii(self, centers, params, max_iterations=2000, tolerance=1e-7): + """ + Computes maximum radii for a given set of centers using iterative relaxation. + This is the core evaluation function. + """ + n = centers.shape[0] + radii = np.zeros(n) + interstitial_idx = params.get('interstitial_idx', -1) + w_central = params.get('w_central', 1.5) + + # 1. Initialize radii based on boundary distances. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Adaptive heuristic for interstitial circle's initial radius. + if interstitial_idx != -1: + other_centers = np.delete(centers, interstitial_idx, axis=0) + if len(other_centers) > 0: + distances = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) + radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * np.min(distances)) + + # 3. Iteratively relax radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + w_i = w_central if i == 0 else 1.0 + w_j = w_central if j == 0 else 1.0 + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + total_weighted = weighted_r_i + weighted_r_j + + if total_weighted > 1e-12: + radii[i] -= overlap * (weighted_r_i / total_weighted) + radii[j] -= overlap * (weighted_r_j / total_weighted) + + radii[radii < 0] = 0 + if np.allclose(radii, prev_radii, atol=tolerance): + break + return radii + +def construct_packing(): + """ + Constructs the circle packing by creating and running the optimizer. + This function serves as the main entry point, adhering to the expected API. + """ + optimizer = PackingOptimizer(n_circles=26) + centers, radii = optimizer.optimize() + return centers, radii +# EVOLVE-BLOCK-END \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..f90fdcf6a80d6ce6a2dfbc9f2eb02fa971d70a01 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9190824409539164, + "spatial_uniformity_details": { + "cell_size_mean": 0.19899128645589284, + "cell_size_std": 0.017519526578765064, + "coefficient_of_variation": 0.08804167661183826 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6653173552577553, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00011640972508199662, + "mean_density": 0.021448171409387297, + "cv": 0.5030421077961856 + }, + "packing_efficiency": 0.5934508890040798, + "packing_efficiency_details": { + "total_area": 0.5934508890040798, + "square_area": 1.0, + "efficiency": 0.5934508890040798, + "relative_to_estimated_best": 0.7064891535762855 + }, + "radius_distribution": 0.9903496169664631, + "radius_distribution_details": { + "mean": 0.08363012016372973, + "std": 0.016475346349763585, + "min": 0.034061396543213454, + "max": 0.1020139199022079, + "range": 0.06795252335899445, + "small_count": 9, + "medium_count": 7, + "large_count": 10, + "diversity_score": 0.9903496169664631 + }, + "gap_analysis": 0.6032, + "gap_analysis_details": { + "covered_samples": 1508, + "total_samples": 2500, + "coverage": 0.6032, + "gap_ratio": 0.39680000000000004 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865472, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..ab2f3f7b98ccb2cefbf312eb515ed6cc1ff67bd6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.56 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1744 + + Auxiliary Metrics: + • spatial_uniformity: 0.919 + • edge_utilization: 0.723 + • density_variance: 0.665 + • packing_efficiency: 0.593 + • radius_distribution: 0.990 + • gap_analysis: 0.603 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1744 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.919 + • Boundary and corner utilization: 0.723 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.665 + • Area utilization efficiency: 0.593 + • Radius size diversity: 0.990 + • Area coverage (1 - gap ratio): 0.603 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 39.7% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..fee8913138891eff5d90ffd9ba2c65d1051b86be --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.174383124256973, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.4000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9190824409539164, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6653173552577553, + "aux_packing_efficiency": 0.5934508890040798, + "aux_radius_distribution": 0.9903496169664631, + "aux_gap_analysis": 0.6032, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.174383124256973 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1744\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.919\n \u2022 Boundary and corner utilization: 0.723\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.665\n \u2022 Area utilization efficiency: 0.593\n \u2022 Radius size diversity: 0.990\n \u2022 Area coverage (1 - gap ratio): 0.603\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 39.7% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_84/results/packing_viz.png", + "execution_time_mean": 0.5624174340628088, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..49867bf2d8bb8553e263a550e9422573e6d27769 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..6997d4f83a36a59833485f1d1e6bdfb181d0c763 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8927317071681885, + "spatial_uniformity_details": { + "cell_size_mean": 0.19554732299305277, + "cell_size_std": 0.02349645189493874, + "coefficient_of_variation": 0.12015736863662475 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.589808771298676, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0001729138285627158, + "mean_density": 0.01890774331574993, + "cv": 0.6954647822516109 + }, + "packing_efficiency": 0.5848020115431085, + "packing_efficiency_details": { + "total_area": 0.5848020115431085, + "square_area": 1.0, + "efficiency": 0.5848020115431085, + "relative_to_estimated_best": 0.696192870884653 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08294789545624646, + "std": 0.01670913425714809, + "min": 0.03460014600033095, + "max": 0.10203786155614666, + "range": 0.06743771555581571, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.582, + "gap_analysis_details": { + "covered_samples": 1455, + "total_samples": 2500, + "coverage": 0.582, + "gap_ratio": 0.41800000000000004 + }, + "geometric_quality": 0.6895797361499798, + "geometric_quality_details": { + "num_triangles": 35, + "avg_triangle_quality": 0.6895797361499798, + "min_quality": 0.35355339059327373, + "max_quality": 0.7071067811865476 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..5c8469da077a20c998df4d88b4342db8c5d7973b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 3.31 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1566 + + Auxiliary Metrics: + • spatial_uniformity: 0.893 + • edge_utilization: 0.723 + • density_variance: 0.590 + • packing_efficiency: 0.585 + • radius_distribution: 0.974 + • gap_analysis: 0.582 + • geometric_quality: 0.690 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1566 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.893 + • Boundary and corner utilization: 0.723 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.590 + • Area utilization efficiency: 0.585 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.582 + • Delaunay triangulation quality: 0.690 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 41.8% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..123aa8fde76ffe3487999f201396aebdc3f92f28 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1566452818624082, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.7000, 0.1000)\n centers[4] = (0.9000, 0.1000)\n centers[5] = (0.1000, 0.3000)\n centers[6] = (0.3000, 0.3000)\n centers[7] = (0.5000, 0.3000)\n centers[8] = (0.7000, 0.3000)\n centers[9] = (0.9000, 0.3000)\n centers[10] = (0.1000, 0.5000)\n centers[11] = (0.3000, 0.5000)\n centers[12] = (0.7000, 0.5000)\n centers[13] = (0.9000, 0.5000)\n centers[14] = (0.1000, 0.7000)\n centers[15] = (0.3000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4000, 0.2000)\n centers[25] = (0.4000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8927317071681885, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.589808771298676, + "aux_packing_efficiency": 0.5848020115431085, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.582, + "aux_geometric_quality": 0.6895797361499798 + }, + "private": { + "reported_sum_of_radii": 2.1566452818624082 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1566\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.893\n \u2022 Boundary and corner utilization: 0.723\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.590\n \u2022 Area utilization efficiency: 0.585\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.582\n \u2022 Delaunay triangulation quality: 0.690\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 41.8% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_87/results/packing_viz.png", + "execution_time_mean": 3.312341393902898, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d0f02d1b390afe9eb5aa9fc97983f9be274634cc Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..7f4469edc396d7b2ab9f40e3aa6c07262a1f3404 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/edit.diff @@ -0,0 +1,361 @@ +--- a/original.py ++++ b/original.py +@@ -1,168 +1,220 @@ + # EVOLVE-BLOCK-START +-"""Constructor-based circle packing for n=26 circles""" ++""" ++Iterative Force-Directed Optimization for Circle Packing (n=26) ++This approach dynamically adjusts circle centers based on repulsive forces ++(from other circles and boundaries) and attractive forces (to keep circles ++somewhat cohesive or towards optimal positions), combined with an ++iterative radius relaxation method. ++""" + + import numpy as np + + +-def construct_packing(): +- """ +- Construct a specific arrangement of 26 circles in a unit square +- that attempts to maximize the sum of their radii. ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): ++ """ ++ Computes maximum radii for a given set of fixed circle centers, ++ including a heuristic for the central circle (at index 0). ++ Circles must not overlap and must stay within the unit square boundaries. ++ ++ Args: ++ centers: np.array of shape (n, 2) with (x, y) coordinates. ++ max_iterations: Maximum iterations for the relaxation process. ++ tolerance: Convergence tolerance. + + Returns: +- Tuple of (centers, radii, sum_of_radii) +- centers: np.array of shape (26, 2) with (x, y) coordinates +- radii: np.array of shape (26) with radius of each circle +- sum_of_radii: Sum of all radii +- """ +-def _generate_interstitial_candidates(): +- """ +- Generates a fixed set of candidate points for interstitial circles based on a 5x5 grid. +- These are the midpoints between grid lines of a standard 0.1 to 0.9 grid. +- """ +- interstitial_values = np.linspace(0.2, 0.8, 4) # [0.2, 0.4, 0.6, 0.8] +- +- candidates = [] +- for y_val in interstitial_values: +- for x_val in interstitial_values: +- candidates.append([x_val, y_val]) +- return candidates +- +-def construct_packing(): +- """ +- Construct a specific arrangement of 26 circles in a unit square +- that attempts to maximize the sum of their radii. +- +- Returns: +- Tuple of (centers, radii, sum_of_radii) +- centers: np.array of shape (26, 2) with (x, y) coordinates +- radii: np.array of shape (26) with radius of each circle +- sum_of_radii: Sum of all radii +- """ +- best_sum_radii = -1.0 +- best_centers = None +- best_radii = None +- n = 26 +- +- # Generate candidate interstitial points (fixed grid for now for performance) +- interstitial_candidates = _generate_interstitial_candidates() # 16 candidates +- +- # Fixed grid parameters based on previous high-scoring results +- scx, ecx = 0.1, 0.9 +- scy, ecy = 0.1, 0.9 +- +- # Iterating through unique pairs of interstitial candidates +- for i1, p1 in enumerate(interstitial_candidates): +- for i2, p2 in enumerate(interstitial_candidates): +- if i2 <= i1: # Ensure unique pairs (no duplicates or reversed order) +- continue +- +- current_centers = np.zeros((n, 2)) +- k = 0 +- +- # 1. Place the central (0.5, 0.5) circle first. +- current_centers[k] = [0.5, 0.5] +- k += 1 +- +- # Generate grid coordinates for the 5x5 grid +- grid_size = 5 +- x_coords = np.linspace(scx, ecx, grid_size) +- y_coords = np.linspace(scy, ecy, grid_size) +- +- # 2. Place 23 circles from a 5x5 grid: +- # - Excluding the central point (0.5,0.5) as it's already placed. +- # - Excluding the (0.1, 0.1) position to make space for the two interstitials. +- for i_grid in range(grid_size): +- for j_grid in range(grid_size): +- # Skip the central (0.5, 0.5) position (index 0) +- # Skip the (0.1, 0.1) position (first grid circle) +- is_central_grid_pos = (abs(x_coords[j_grid] - 0.5) < 1e-6 and abs(y_coords[i_grid] - 0.5) < 1e-6) +- is_bottom_left_grid_pos = (abs(x_coords[j_grid] - 0.1) < 1e-6 and abs(y_coords[i_grid] - 0.1) < 1e-6) +- +- if is_central_grid_pos or is_bottom_left_grid_pos: +- continue +- +- current_centers[k] = [x_coords[j_grid], y_coords[i_grid]] +- k += 1 +- +- # At this point, k should be 1 (for central) + 23 (for grid) = 24. +- # So current_centers[24] and current_centers[25] are the next available slots. +- # 3. Place the two interstitial circles +- current_centers[24] = p1 +- current_centers[25] = p2 +- +- # Ensure all centers are within bounds +- current_centers = np.clip(current_centers, 0.001, 0.999) +- +- # Compute radii for the current configuration +- radii = compute_max_radii(current_centers) +- current_sum_radii = np.sum(radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = radii +- +- return best_centers, best_radii +- +- +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): +- """ +- Compute the maximum possible radii for each circle position +- such that they don't overlap and stay within the unit square. +- This function uses an iterative relaxation approach for better convergence. +- +- Args: +- centers: np.array of shape (n, 2) with (x, y) coordinates +- max_iterations: Maximum number of iterations for the relaxation process. +- tolerance: Minimum change in radii sum to consider for convergence. +- +- Returns: +- np.array of shape (n) with radius of each circle ++ np.array: Array of radii for each circle. + """ + n = centers.shape[0] +- radii = np.zeros(n) # Initialize radii to zero, then expand +- +- # 1. Initialize radii based on minimum distance to square borders ++ radii = np.zeros(n) ++ ++ # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # 2. Iteratively adjust radii to resolve overlaps and maximize size +- for iteration in range(max_iterations): ++ # 2. Iteratively adjust radii to resolve overlaps. ++ for _ in range(max_iterations): + prev_radii = np.copy(radii) + +- # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): +- dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) +- +- # Check for overlap: if the sum of current radii exceeds the distance +- # Also ensure dist is not zero to prevent division errors, though highly unlikely with distinct centers. +- if radii[i] + radii[j] > dist and dist > 1e-9: +- # Apply proportional scaling to both radii to make them just touch. +- # This ensures no overlap while maximizing their combined size relative +- # to their current proportions. +- scale_factor = dist / (radii[i] + radii[j]) +- radii[i] *= scale_factor +- radii[j] *= scale_factor +- +- # After a full pass over all pairs, check for convergence. +- # If the radii have not changed significantly from the previous iteration, +- # the system has stabilized. ++ dist = np.linalg.norm(centers[i] - centers[j]) ++ ++ if radii[i] + radii[j] > dist: ++ overlap = radii[i] + radii[j] - dist ++ ++ # Weighted scaling: The central circle (index 0) is more ++ # resistant to shrinking, allowing it to grow larger. ++ # This heuristic was noted as a strength in previous programs. ++ w_i = 1.5 if i == 0 else 1.0 ++ w_j = 1.0 # j is always > i >= 0. ++ ++ weighted_r_i = radii[i] / w_i ++ weighted_r_j = radii[j] / w_j ++ ++ total_weighted_radii = weighted_r_i + weighted_r_j ++ if total_weighted_radii > 1e-12: # Avoid division by zero ++ radii[i] -= overlap * (weighted_r_i / total_weighted_radii) ++ radii[j] -= overlap * (weighted_r_j / total_weighted_radii) ++ elif (radii[i] + radii[j]) > 1e-12: # Fallback for extremely small radii sum ++ scale_factor = dist / (radii[i] + radii[j]) ++ radii[i] *= scale_factor ++ radii[j] *= scale_factor ++ + if np.allclose(radii, prev_radii, atol=tolerance): + break + +- return radii +- +- ++ return np.maximum(radii, 0) # Ensure radii are non-negative ++ ++ ++def construct_packing(): ++ """ ++ Constructs an arrangement of 26 circles using an iterative force-directed ++ approach to optimize center positions, combined with a radius relaxation ++ method. ++ ++ Returns: ++ Tuple of (centers, radii) ++ """ ++ n_circles = 26 ++ ++ # --- Initialization: Start with a reasonably good, slightly perturbed configuration --- ++ # This combines elements from previous successful strategies for a strong baseline: ++ # 1. A 5x5 grid (25 circles) ++ # 2. One central circle explicitly placed at (0.5, 0.5) ++ # 3. One additional circle placed in an interstitial position. ++ ++ # Base grid centers (5x5) ++ grid_size = 5 ++ start_coord, end_coord = 0.1, 0.9 # Typical range for 5x5 grid ++ coords = np.linspace(start_coord, end_coord, grid_size) ++ all_grid_centers = np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) ++ ++ # Central point (0.5, 0.5) to be placed at index 0 ++ central_point_coords = np.array([0.5, 0.5]) ++ ++ # Identify and remove the central point from the grid, then stack it first ++ central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] ++ other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) ++ ++ # Initial 25 centers: central (index 0) + 24 other grid circles ++ initial_centers_25 = np.vstack([central_point_coords, other_grid_centers]) ++ ++ # Add the 26th circle at a good candidate interstitial point from prior experimentation. ++ # This point will then be dynamically adjusted by the force-directed system. ++ initial_interstitial = np.array([0.2, 0.4]) ++ centers = np.vstack([initial_centers_25, initial_interstitial]) ++ ++ # Apply a small random perturbation to all centers to escape initial perfect symmetry ++ # and give the force-directed system a starting "jiggle". ++ centers += (np.random.rand(n_circles, 2) - 0.5) * 0.01 ++ centers = np.clip(centers, 0.01, 0.99) # Ensure centers are slightly within bounds ++ ++ best_sum_radii = -1.0 ++ best_centers = np.copy(centers) ++ best_radii = None ++ ++ # --- Force-Directed Iteration Parameters --- ++ N_outer_iterations = 1500 # Number of iterations for center adjustments ++ learning_rate_initial = 0.005 # Initial step size for center movement ++ damping_factor = 0.998 # Damping for learning rate over iterations ++ k_overlap = 1.8 # Strength of force for direct overlaps (stronger to resolve quickly) ++ k_general_rep = 0.7 # Strength of general repulsion from nearby circles (fills gaps) ++ k_boundary = 1.2 # Strength of repulsion from walls (to maximize edge utilization) ++ max_jiggle_initial = 0.003 # Initial strength of random perturbation (explores new states) ++ ++ learning_rate = learning_rate_initial ++ ++ for iteration in range(N_outer_iterations): ++ # 1. Calculate radii for current center positions ++ # Use fewer max_iterations for radii calculation during the exploration phase for speed. ++ current_radii = compute_max_radii(centers, max_iterations=75) ++ current_sum_radii = np.sum(current_radii) ++ ++ # Update best configuration found so far ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = np.copy(centers) ++ best_radii = np.copy(current_radii) ++ ++ # 2. Calculate forces acting on each circle center ++ forces = np.zeros_like(centers) ++ ++ # Jiggle strength decreases over time (simulated annealing-like schedule) ++ jiggle_strength = max_jiggle_initial * (1 - iteration / N_outer_iterations)**2 # Quadratic decay ++ ++ for i in range(n_circles): ++ c_i = centers[i] ++ r_i = current_radii[i] ++ ++ # Repulsion from other circles ++ for j in range(n_circles): ++ if i == j: ++ continue ++ ++ c_j = centers[j] ++ r_j = current_radii[j] ++ ++ vec_ij = c_i - c_j ++ dist_ij = np.linalg.norm(vec_ij) ++ ++ if dist_ij < 1e-9: # Handle co-located centers (highly unlikely after initialization) ++ forces[i] += k_overlap * 0.1 * (np.random.rand(2) - 0.5) # Random push if co-located ++ continue ++ ++ unit_vec_ij = vec_ij / dist_ij ++ min_sep = r_i + r_j ++ ++ # Overlap repulsion: Strong force to push circles apart if they overlap ++ if dist_ij < min_sep: ++ overlap_amount = min_sep - dist_ij ++ forces[i] += k_overlap * overlap_amount * unit_vec_ij ++ ++ # General repulsion: Weaker force to spread circles that are close but not overlapping. ++ # This helps fill gaps and avoid clumping, improving spatial uniformity. ++ buffer_factor = 1.4 # Repel if within 1.4 times the sum of radii ++ if dist_ij < min_sep * buffer_factor: ++ # Force increases as distance decreases from buffer_factor*min_sep down to min_sep ++ rep_strength = (min_sep * buffer_factor - dist_ij) / (min_sep * (buffer_factor - 1) + 1e-9) ++ forces[i] += k_general_rep * rep_strength * unit_vec_ij ++ ++ # Repulsion from boundaries: Circles should not extend beyond the unit square ++ # Forces are proportional to the penetration depth past the allowed radius. ++ # Using current radius `r_i` for boundary interaction. ++ if c_i[0] < r_i: ++ forces[i][0] += k_boundary * (r_i - c_i[0]) # Push right ++ if c_i[0] > 1 - r_i: ++ forces[i][0] -= k_boundary * (c_i[0] - (1 - r_i)) # Push left ++ ++ if c_i[1] < r_i: ++ forces[i][1] += k_boundary * (r_i - c_i[1]) # Push up ++ if c_i[1] > 1 - r_i: ++ forces[i][1] -= k_boundary * (c_i[1] - (1 - r_i)) # Push down ++ ++ # Add random "jiggle" for exploration (simulated annealing component) ++ forces[i] += (np.random.rand(2) - 0.5) * jiggle_strength ++ ++ # 3. Update center positions based on calculated forces ++ centers += learning_rate * forces ++ ++ # Ensure centers remain strictly within the unit square after movement ++ centers = np.clip(centers, 0, 1) ++ ++ # 4. Decay learning rate to gradually reduce movement as iterations progress ++ learning_rate *= damping_factor ++ ++ # After force-directed optimization, perform a final, high-precision radii calculation ++ # on the best center configuration found, using more iterations for convergence. ++ final_radii = compute_max_radii(best_centers, max_iterations=2000) ++ ++ return best_centers, final_radii + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/main.py new file mode 100644 index 0000000000000000000000000000000000000000..f3f119605dd220b8f8e0f5385f2757bd5b9075ac --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/main.py @@ -0,0 +1,220 @@ +# EVOLVE-BLOCK-START +""" +Iterative Force-Directed Optimization for Circle Packing (n=26) +This approach dynamically adjusts circle centers based on repulsive forces +(from other circles and boundaries) and attractive forces (to keep circles +somewhat cohesive or towards optimal positions), combined with an +iterative radius relaxation method. +""" + +import numpy as np + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Computes maximum radii for a given set of fixed circle centers, + including a heuristic for the central circle (at index 0). + Circles must not overlap and must stay within the unit square boundaries. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + # This heuristic was noted as a strength in previous programs. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # j is always > i >= 0. + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback for extremely small radii sum + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) # Ensure radii are non-negative + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using an iterative force-directed + approach to optimize center positions, combined with a radius relaxation + method. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + + # --- Initialization: Start with a reasonably good, slightly perturbed configuration --- + # This combines elements from previous successful strategies for a strong baseline: + # 1. A 5x5 grid (25 circles) + # 2. One central circle explicitly placed at (0.5, 0.5) + # 3. One additional circle placed in an interstitial position. + + # Base grid centers (5x5) + grid_size = 5 + start_coord, end_coord = 0.1, 0.9 # Typical range for 5x5 grid + coords = np.linspace(start_coord, end_coord, grid_size) + all_grid_centers = np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + # Central point (0.5, 0.5) to be placed at index 0 + central_point_coords = np.array([0.5, 0.5]) + + # Identify and remove the central point from the grid, then stack it first + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # Initial 25 centers: central (index 0) + 24 other grid circles + initial_centers_25 = np.vstack([central_point_coords, other_grid_centers]) + + # Add the 26th circle at a good candidate interstitial point from prior experimentation. + # This point will then be dynamically adjusted by the force-directed system. + initial_interstitial = np.array([0.2, 0.4]) + centers = np.vstack([initial_centers_25, initial_interstitial]) + + # Apply a small random perturbation to all centers to escape initial perfect symmetry + # and give the force-directed system a starting "jiggle". + centers += (np.random.rand(n_circles, 2) - 0.5) * 0.01 + centers = np.clip(centers, 0.01, 0.99) # Ensure centers are slightly within bounds + + best_sum_radii = -1.0 + best_centers = np.copy(centers) + best_radii = None + + # --- Force-Directed Iteration Parameters --- + N_outer_iterations = 1500 # Number of iterations for center adjustments + learning_rate_initial = 0.005 # Initial step size for center movement + damping_factor = 0.998 # Damping for learning rate over iterations + k_overlap = 1.8 # Strength of force for direct overlaps (stronger to resolve quickly) + k_general_rep = 0.7 # Strength of general repulsion from nearby circles (fills gaps) + k_boundary = 1.2 # Strength of repulsion from walls (to maximize edge utilization) + max_jiggle_initial = 0.003 # Initial strength of random perturbation (explores new states) + + learning_rate = learning_rate_initial + + for iteration in range(N_outer_iterations): + # 1. Calculate radii for current center positions + # Use fewer max_iterations for radii calculation during the exploration phase for speed. + current_radii = compute_max_radii(centers, max_iterations=75) + current_sum_radii = np.sum(current_radii) + + # Update best configuration found so far + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = np.copy(centers) + best_radii = np.copy(current_radii) + + # 2. Calculate forces acting on each circle center + forces = np.zeros_like(centers) + + # Jiggle strength decreases over time (simulated annealing-like schedule) + jiggle_strength = max_jiggle_initial * (1 - iteration / N_outer_iterations)**2 # Quadratic decay + + for i in range(n_circles): + c_i = centers[i] + r_i = current_radii[i] + + # Repulsion from other circles + for j in range(n_circles): + if i == j: + continue + + c_j = centers[j] + r_j = current_radii[j] + + vec_ij = c_i - c_j + dist_ij = np.linalg.norm(vec_ij) + + if dist_ij < 1e-9: # Handle co-located centers (highly unlikely after initialization) + forces[i] += k_overlap * 0.1 * (np.random.rand(2) - 0.5) # Random push if co-located + continue + + unit_vec_ij = vec_ij / dist_ij + min_sep = r_i + r_j + + # Overlap repulsion: Strong force to push circles apart if they overlap + if dist_ij < min_sep: + overlap_amount = min_sep - dist_ij + forces[i] += k_overlap * overlap_amount * unit_vec_ij + + # General repulsion: Weaker force to spread circles that are close but not overlapping. + # This helps fill gaps and avoid clumping, improving spatial uniformity. + buffer_factor = 1.4 # Repel if within 1.4 times the sum of radii + if dist_ij < min_sep * buffer_factor: + # Force increases as distance decreases from buffer_factor*min_sep down to min_sep + rep_strength = (min_sep * buffer_factor - dist_ij) / (min_sep * (buffer_factor - 1) + 1e-9) + forces[i] += k_general_rep * rep_strength * unit_vec_ij + + # Repulsion from boundaries: Circles should not extend beyond the unit square + # Forces are proportional to the penetration depth past the allowed radius. + # Using current radius `r_i` for boundary interaction. + if c_i[0] < r_i: + forces[i][0] += k_boundary * (r_i - c_i[0]) # Push right + if c_i[0] > 1 - r_i: + forces[i][0] -= k_boundary * (c_i[0] - (1 - r_i)) # Push left + + if c_i[1] < r_i: + forces[i][1] += k_boundary * (r_i - c_i[1]) # Push up + if c_i[1] > 1 - r_i: + forces[i][1] -= k_boundary * (c_i[1] - (1 - r_i)) # Push down + + # Add random "jiggle" for exploration (simulated annealing component) + forces[i] += (np.random.rand(2) - 0.5) * jiggle_strength + + # 3. Update center positions based on calculated forces + centers += learning_rate * forces + + # Ensure centers remain strictly within the unit square after movement + centers = np.clip(centers, 0, 1) + + # 4. Decay learning rate to gradually reduce movement as iterations progress + learning_rate *= damping_factor + + # After force-directed optimization, perform a final, high-precision radii calculation + # on the best center configuration found, using more iterations for convergence. + final_radii = compute_max_radii(best_centers, max_iterations=2000) + + return best_centers, final_radii +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/original.py new file mode 100644 index 0000000000000000000000000000000000000000..406231d9fbf28d8b76e6bf16d4930ea5370a30d8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/original.py @@ -0,0 +1,168 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ +def _generate_interstitial_candidates(): + """ + Generates a fixed set of candidate points for interstitial circles based on a 5x5 grid. + These are the midpoints between grid lines of a standard 0.1 to 0.9 grid. + """ + interstitial_values = np.linspace(0.2, 0.8, 4) # [0.2, 0.4, 0.6, 0.8] + + candidates = [] + for y_val in interstitial_values: + for x_val in interstitial_values: + candidates.append([x_val, y_val]) + return candidates + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + Returns: + Tuple of (centers, radii, sum_of_radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + sum_of_radii: Sum of all radii + """ + best_sum_radii = -1.0 + best_centers = None + best_radii = None + n = 26 + + # Generate candidate interstitial points (fixed grid for now for performance) + interstitial_candidates = _generate_interstitial_candidates() # 16 candidates + + # Fixed grid parameters based on previous high-scoring results + scx, ecx = 0.1, 0.9 + scy, ecy = 0.1, 0.9 + + # Iterating through unique pairs of interstitial candidates + for i1, p1 in enumerate(interstitial_candidates): + for i2, p2 in enumerate(interstitial_candidates): + if i2 <= i1: # Ensure unique pairs (no duplicates or reversed order) + continue + + current_centers = np.zeros((n, 2)) + k = 0 + + # 1. Place the central (0.5, 0.5) circle first. + current_centers[k] = [0.5, 0.5] + k += 1 + + # Generate grid coordinates for the 5x5 grid + grid_size = 5 + x_coords = np.linspace(scx, ecx, grid_size) + y_coords = np.linspace(scy, ecy, grid_size) + + # 2. Place 23 circles from a 5x5 grid: + # - Excluding the central point (0.5,0.5) as it's already placed. + # - Excluding the (0.1, 0.1) position to make space for the two interstitials. + for i_grid in range(grid_size): + for j_grid in range(grid_size): + # Skip the central (0.5, 0.5) position (index 0) + # Skip the (0.1, 0.1) position (first grid circle) + is_central_grid_pos = (abs(x_coords[j_grid] - 0.5) < 1e-6 and abs(y_coords[i_grid] - 0.5) < 1e-6) + is_bottom_left_grid_pos = (abs(x_coords[j_grid] - 0.1) < 1e-6 and abs(y_coords[i_grid] - 0.1) < 1e-6) + + if is_central_grid_pos or is_bottom_left_grid_pos: + continue + + current_centers[k] = [x_coords[j_grid], y_coords[i_grid]] + k += 1 + + # At this point, k should be 1 (for central) + 23 (for grid) = 24. + # So current_centers[24] and current_centers[25] are the next available slots. + # 3. Place the two interstitial circles + current_centers[24] = p1 + current_centers[25] = p2 + + # Ensure all centers are within bounds + current_centers = np.clip(current_centers, 0.001, 0.999) + + # Compute radii for the current configuration + radii = compute_max_radii(current_centers) + current_sum_radii = np.sum(radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = radii + + return best_centers, best_radii + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7): + """ + Compute the maximum possible radii for each circle position + such that they don't overlap and stay within the unit square. + This function uses an iterative relaxation approach for better convergence. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates + max_iterations: Maximum number of iterations for the relaxation process. + tolerance: Minimum change in radii sum to consider for convergence. + + Returns: + np.array of shape (n) with radius of each circle + """ + n = centers.shape[0] + radii = np.zeros(n) # Initialize radii to zero, then expand + + # 1. Initialize radii based on minimum distance to square borders + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps and maximize size + for iteration in range(max_iterations): + prev_radii = np.copy(radii) + + # Iterate over all unique pairs of circles (i, j) where i < j + for i in range(n): + for j in range(i + 1, n): + dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2)) + + # Check for overlap: if the sum of current radii exceeds the distance + # Also ensure dist is not zero to prevent division errors, though highly unlikely with distinct centers. + if radii[i] + radii[j] > dist and dist > 1e-9: + # Apply proportional scaling to both radii to make them just touch. + # This ensures no overlap while maximizing their combined size relative + # to their current proportions. + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + # After a full pass over all pairs, check for convergence. + # If the radii have not changed significantly from the previous iteration, + # the system has stabilized. + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..a89582032345bcbd7610572eb3314e6791fdd4e1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9168347929637846, + "spatial_uniformity_details": { + "cell_size_mean": 0.19957341293907233, + "cell_size_std": 0.018103113468800117, + "coefficient_of_variation": 0.09070904341159794 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.6379763555802505, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00012851800593618624, + "mean_density": 0.019977889877016507, + "cv": 0.5674562093927177 + }, + "packing_efficiency": 0.564529304671956, + "packing_efficiency_details": { + "total_area": 0.564529304671956, + "square_area": 1.0, + "efficiency": 0.564529304671956, + "relative_to_estimated_best": 0.6720586960380428 + }, + "radius_distribution": 0.9341661379115739, + "radius_distribution_details": { + "mean": 0.08081485996627605, + "std": 0.019501654113232226, + "min": 0.020491569556032343, + "max": 0.10089476217862214, + "range": 0.0804031926225898, + "small_count": 5, + "medium_count": 8, + "large_count": 13, + "diversity_score": 0.9341661379115739 + }, + "gap_analysis": 0.5656, + "gap_analysis_details": { + "covered_samples": 1414, + "total_samples": 2500, + "coverage": 0.5656, + "gap_ratio": 0.4344 + }, + "geometric_quality": 0.6557430353534466, + "geometric_quality_details": { + "num_triangles": 42, + "avg_triangle_quality": 0.6557430353534466, + "min_quality": 0.33095545268948423, + "max_quality": 0.7224657999438245 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..1f5148865f5fb25b4674903e2856302887b548f2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 6.13 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1012 + + Auxiliary Metrics: + • spatial_uniformity: 0.917 + • edge_utilization: 0.738 + • density_variance: 0.638 + • packing_efficiency: 0.565 + • radius_distribution: 0.934 + • gap_analysis: 0.566 + • geometric_quality: 0.656 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1012 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.917 + • Boundary and corner utilization: 0.738 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.638 + • Area utilization efficiency: 0.565 + • Radius size diversity: 0.934 + • Area coverage (1 - gap ratio): 0.566 + • Delaunay triangulation quality: 0.656 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 43.4% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..97390ea2da08a0655798cdb51307412d02a3b773 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.101186359123177, + "public": { + "centers_str": " centers[0] = (0.5037, 0.4981)\n centers[1] = (0.0977, 0.0980)\n centers[2] = (0.0987, 0.2999)\n centers[3] = (0.0956, 0.5021)\n centers[4] = (0.0974, 0.7012)\n centers[5] = (0.0976, 0.8972)\n centers[6] = (0.2986, 0.0937)\n centers[7] = (0.2986, 0.3008)\n centers[8] = (0.3060, 0.5045)\n centers[9] = (0.2979, 0.7018)\n centers[10] = (0.2983, 0.9037)\n centers[11] = (0.4989, 0.0966)\n centers[12] = (0.4960, 0.3029)\n centers[13] = (0.4999, 0.6986)\n centers[14] = (0.5014, 0.9015)\n centers[15] = (0.7029, 0.1023)\n centers[16] = (0.6984, 0.3046)\n centers[17] = (0.6980, 0.5012)\n centers[18] = (0.6974, 0.6996)\n centers[19] = (0.6977, 0.8985)\n centers[20] = (0.9040, 0.1008)\n centers[21] = (0.9038, 0.2974)\n centers[22] = (0.9068, 0.4988)\n centers[23] = (0.8985, 0.6992)\n centers[24] = (0.9016, 0.9053)\n centers[25] = (0.1936, 0.3970)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9168347929637846, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.6379763555802505, + "aux_packing_efficiency": 0.564529304671956, + "aux_radius_distribution": 0.9341661379115739, + "aux_gap_analysis": 0.5656, + "aux_geometric_quality": 0.6557430353534466 + }, + "private": { + "reported_sum_of_radii": 2.101186359123177 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1012\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.917\n \u2022 Boundary and corner utilization: 0.738\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.638\n \u2022 Area utilization efficiency: 0.565\n \u2022 Radius size diversity: 0.934\n \u2022 Area coverage (1 - gap ratio): 0.566\n \u2022 Delaunay triangulation quality: 0.656\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 43.4% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/results/packing_viz.png", + "execution_time_mean": 6.128936703782529, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/rewrite.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/rewrite.txt new file mode 100644 index 0000000000000000000000000000000000000000..390ec01f19929aa94866cc046f7d6c13840b7324 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_89/rewrite.txt @@ -0,0 +1,210 @@ +# EVOLVE-BLOCK-START +""" +Iterative Force-Directed Optimization for Circle Packing (n=26) +This approach dynamically adjusts circle centers based on repulsive forces +(from other circles and boundaries) and attractive forces (to keep circles +somewhat cohesive or towards optimal positions), combined with an +iterative radius relaxation method. +""" + +import numpy as np + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-8): + """ + Computes maximum radii for a given set of fixed circle centers, + including a heuristic for the central circle (at index 0). + Circles must not overlap and must stay within the unit square boundaries. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # 2. Iteratively adjust radii to resolve overlaps. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted scaling: The central circle (index 0) is more + # resistant to shrinking, allowing it to grow larger. + # This heuristic was noted as a strength in previous programs. + w_i = 1.5 if i == 0 else 1.0 + w_j = 1.0 # j is always > i >= 0. + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + elif (radii[i] + radii[j]) > 1e-12: # Fallback for extremely small radii sum + scale_factor = dist / (radii[i] + radii[j]) + radii[i] *= scale_factor + radii[j] *= scale_factor + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return np.maximum(radii, 0) # Ensure radii are non-negative + + +def construct_packing(): + """ + Constructs an arrangement of 26 circles using an iterative force-directed + approach to optimize center positions, combined with a radius relaxation + method. + + Returns: + Tuple of (centers, radii) + """ + n_circles = 26 + + # --- Initialization: Start with a reasonably good, slightly perturbed configuration --- + # This combines elements from previous successful strategies for a strong baseline: + # 1. A 5x5 grid (25 circles) + # 2. One central circle explicitly placed at (0.5, 0.5) + # 3. One additional circle placed in an interstitial position. + + # Base grid centers (5x5) + grid_size = 5 + start_coord, end_coord = 0.1, 0.9 # Typical range for 5x5 grid + coords = np.linspace(start_coord, end_coord, grid_size) + all_grid_centers = np.array(np.meshgrid(coords, coords)).T.reshape(-1, 2) + + # Central point (0.5, 0.5) to be placed at index 0 + central_point_coords = np.array([0.5, 0.5]) + + # Identify and remove the central point from the grid, then stack it first + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0][0] + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + + # Initial 25 centers: central (index 0) + 24 other grid circles + initial_centers_25 = np.vstack([central_point_coords, other_grid_centers]) + + # Add the 26th circle at a good candidate interstitial point from prior experimentation. + # This point will then be dynamically adjusted by the force-directed system. + initial_interstitial = np.array([0.2, 0.4]) + centers = np.vstack([initial_centers_25, initial_interstitial]) + + # Apply a small random perturbation to all centers to escape initial perfect symmetry + # and give the force-directed system a starting "jiggle". + centers += (np.random.rand(n_circles, 2) - 0.5) * 0.01 + centers = np.clip(centers, 0.01, 0.99) # Ensure centers are slightly within bounds + + best_sum_radii = -1.0 + best_centers = np.copy(centers) + best_radii = None + + # --- Force-Directed Iteration Parameters --- + N_outer_iterations = 1500 # Number of iterations for center adjustments + learning_rate_initial = 0.005 # Initial step size for center movement + damping_factor = 0.998 # Damping for learning rate over iterations + k_overlap = 1.8 # Strength of force for direct overlaps (stronger to resolve quickly) + k_general_rep = 0.7 # Strength of general repulsion from nearby circles (fills gaps) + k_boundary = 1.2 # Strength of repulsion from walls (to maximize edge utilization) + max_jiggle_initial = 0.003 # Initial strength of random perturbation (explores new states) + + learning_rate = learning_rate_initial + + for iteration in range(N_outer_iterations): + # 1. Calculate radii for current center positions + # Use fewer max_iterations for radii calculation during the exploration phase for speed. + current_radii = compute_max_radii(centers, max_iterations=75) + current_sum_radii = np.sum(current_radii) + + # Update best configuration found so far + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = np.copy(centers) + best_radii = np.copy(current_radii) + + # 2. Calculate forces acting on each circle center + forces = np.zeros_like(centers) + + # Jiggle strength decreases over time (simulated annealing-like schedule) + jiggle_strength = max_jiggle_initial * (1 - iteration / N_outer_iterations)**2 # Quadratic decay + + for i in range(n_circles): + c_i = centers[i] + r_i = current_radii[i] + + # Repulsion from other circles + for j in range(n_circles): + if i == j: + continue + + c_j = centers[j] + r_j = current_radii[j] + + vec_ij = c_i - c_j + dist_ij = np.linalg.norm(vec_ij) + + if dist_ij < 1e-9: # Handle co-located centers (highly unlikely after initialization) + forces[i] += k_overlap * 0.1 * (np.random.rand(2) - 0.5) # Random push if co-located + continue + + unit_vec_ij = vec_ij / dist_ij + min_sep = r_i + r_j + + # Overlap repulsion: Strong force to push circles apart if they overlap + if dist_ij < min_sep: + overlap_amount = min_sep - dist_ij + forces[i] += k_overlap * overlap_amount * unit_vec_ij + + # General repulsion: Weaker force to spread circles that are close but not overlapping. + # This helps fill gaps and avoid clumping, improving spatial uniformity. + buffer_factor = 1.4 # Repel if within 1.4 times the sum of radii + if dist_ij < min_sep * buffer_factor: + # Force increases as distance decreases from buffer_factor*min_sep down to min_sep + rep_strength = (min_sep * buffer_factor - dist_ij) / (min_sep * (buffer_factor - 1) + 1e-9) + forces[i] += k_general_rep * rep_strength * unit_vec_ij + + # Repulsion from boundaries: Circles should not extend beyond the unit square + # Forces are proportional to the penetration depth past the allowed radius. + # Using current radius `r_i` for boundary interaction. + if c_i[0] < r_i: + forces[i][0] += k_boundary * (r_i - c_i[0]) # Push right + if c_i[0] > 1 - r_i: + forces[i][0] -= k_boundary * (c_i[0] - (1 - r_i)) # Push left + + if c_i[1] < r_i: + forces[i][1] += k_boundary * (r_i - c_i[1]) # Push up + if c_i[1] > 1 - r_i: + forces[i][1] -= k_boundary * (c_i[1] - (1 - r_i)) # Push down + + # Add random "jiggle" for exploration (simulated annealing component) + forces[i] += (np.random.rand(2) - 0.5) * jiggle_strength + + # 3. Update center positions based on calculated forces + centers += learning_rate * forces + + # Ensure centers remain strictly within the unit square after movement + centers = np.clip(centers, 0, 1) + + # 4. Decay learning rate to gradually reduce movement as iterations progress + learning_rate *= damping_factor + + # After force-directed optimization, perform a final, high-precision radii calculation + # on the best center configuration found, using more iterations for convergence. + final_radii = compute_max_radii(best_centers, max_iterations=2000) + + return best_centers, final_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0856f001e5bc8ecae0b2296485a66266ac1a6428 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/edit.diff b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/edit.diff new file mode 100644 index 0000000000000000000000000000000000000000..0af0534fe619dba1d8d58a74732ad38f2326df48 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/edit.diff @@ -0,0 +1,325 @@ +--- a/original.py ++++ b/original.py +@@ -1,225 +1,240 @@ + # EVOLVE-BLOCK-START + """Constructor-based circle packing for n=26 circles""" + + import numpy as np ++import itertools + + + def _generate_grid_centers(grid_size, start_coord, end_coord): + """ + Generates centers for a square grid of circles. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + start_coord (float): The starting coordinate for linspace. + end_coord (float): The ending coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + + def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers. + For a GxG grid, there are (G-1)x(G-1) interstitial points, located at the center + of each square formed by four adjacent grid circles. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + start_coord (float): The starting coordinate of the grid. + end_coord (float): The ending coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +-def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): ++def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a +- heuristic for the interstitial circle and weighted scaling for the central one. ++ heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. +- interstitial_idx: Index of the interstitial circle to apply the heuristic. ++ interstitial_indices: A list of indices for interstitial circles to apply ++ an adaptive initial radius heuristic. Defaults to None. ++ w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + +- # Heuristic: Adaptively cap the initial radius of the interstitial circle. +- # Instead of a fixed cap, this prevents it from growing too large initially +- # by considering its proximity to other circles, allowing for a better +- # overall packing, especially in sparse regions. +- if interstitial_idx != -1 and interstitial_idx < n: +- # Calculate distances from the interstitial point to all other centers +- other_centers = np.delete(centers, interstitial_idx, axis=0) +- if len(other_centers) > 0: +- distances_to_others = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) +- min_dist_to_neighbor = np.min(distances_to_others) +- +- # Set the initial radius to be at most half the minimum distance to a neighbor. +- # This value is then capped by its boundary distance already in radii[interstitial_idx]. +- radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * min_dist_to_neighbor) ++ # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). ++ # This prevents them from growing too large initially and sub-optimally ++ # squeezing their neighbors, allowing for a better overall packing. ++ if interstitial_indices: ++ for idx in interstitial_indices: ++ if idx < n: # Ensure index is valid ++ other_centers_mask = np.ones(n, dtype=bool) ++ other_centers_mask[idx] = False ++ other_centers = centers[other_centers_mask] ++ ++ if len(other_centers) > 0: ++ distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) ++ min_dist_to_neighbor = np.min(distances_to_others) ++ radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). ++ # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. +- # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. +- w_i = 1.5 if i == 0 else 1.0 # Central circle (index 0) is protected +- w_j = 1.0 # Other circles have normal weight ++ w_i = w_central if i == 0 else 1.0 ++ w_j = 1.0 # Other circles have normal weight (j is always > i, so j is never the first circle if i=0) + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + + def construct_packing(): + """ +- Construct an arrangement of 26 circles by first placing 25 circles +- (one at the center, 24 on a grid) and then systematically searching for +- the best position for the 26th circle from a set of interstitial candidates. +- This version also systematically optimizes the grid boundary parameters (start_coord, end_coord) +- to improve edge utilization and overall packing density. ++ Construct a specific arrangement of 26 circles in a unit square ++ that attempts to maximize the sum of their radii. ++ ++ This version implements a combinatorial search for peripheral and interstitial circles, ++ while also optimizing grid boundary parameters and the central circle's weight. ++ It places: ++ - 1 fixed central circle. ++ - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). ++ - 2 interstitial circles, chosen from the 16 available interstitial candidate positions. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n_circles = 26 +- grid_size = 5 # For a 5x5 grid, total 25 points +- +- # Ranges for optimizing grid boundaries (Recommendation 2: Systematically optimize `np.linspace` parameters) +- # These ranges are chosen to ensure the central grid point remains at (0.5, 0.5) +- # given grid_size=5, as (start_coord + end_coord) / 2 = 0.5 for current options. ++ grid_size = 5 ++ ++ # Ranges for optimizing grid boundaries + start_coord_options = np.linspace(0.08, 0.12, 5) # e.g., 0.08, 0.09, 0.10, 0.11, 0.12 + end_coord_options = np.linspace(0.88, 0.92, 5) # e.g., 0.88, 0.89, 0.90, 0.91, 0.92 ++ ++ # Range for optimizing central circle weight ++ central_weight_options = np.linspace(1.2, 2.0, 3) # e.g., [1.2, 1.6, 2.0] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + +- for sc in start_coord_options: +- for ec in end_coord_options: +- # Ensure end_coord is strictly greater than start_coord for valid linspace +- if ec <= sc: +- continue +- +- # Ensure the midpoint of the grid aligns with 0.5 for the central point heuristic. +- # For grid_size=5, the midpoint coordinate is `sc + (ec - sc) / 2`. +- if not np.isclose(sc + (ec - sc) / 2, 0.5): +- continue # Skip combinations where grid's central point will not be at (0.5,0.5) +- +- all_grid_centers = _generate_grid_centers(grid_size, sc, ec) +- +- # 1. Prioritize the central (0.5, 0.5) circle. +- # Due to the (sc + ec) / 2 = 0.5 constraint and odd grid_size, (0.5, 0.5) +- # will always be exactly at the center of `all_grid_centers`. +- central_point_coords = np.array([0.5, 0.5]) +- +- # Find the index of the central point within the generated grid centers +- central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0] +- +- # This check adds robustness, though it should always find one with the current options. +- if central_idx_in_grid.size == 0: +- continue +- +- central_idx_in_grid = central_idx_in_grid[0] +- +- +- base_centers = np.zeros((n_circles - 1, 2)) +- base_centers[0] = central_point_coords # The central circle is always at index 0 +- +- # The remaining 24 grid centers (excluding the central one) fill the rest of base_centers +- other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) +- base_centers[1:] = other_grid_centers +- +- +- # 2. Generate interstitial candidates for the 26th circle. +- candidate_interstitial_points = _generate_interstitial_candidates(grid_size, sc, ec) +- +- # 3. Explore each candidate interstitial position to find the one maximizing the sum of radii. +- for interstitial_point in candidate_interstitial_points: +- current_centers = np.vstack([base_centers, interstitial_point]) +- # The interstitial circle is always the last one added, so its index is n_circles - 1 +- interstitial_idx = n_circles - 1 +- +- current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) +- current_sum_radii = np.sum(current_radii) +- +- if current_sum_radii > best_sum_radii: +- best_sum_radii = current_sum_radii +- best_centers = current_centers +- best_radii = current_radii ++ # Define the number of circles to select for each category ++ num_fixed_central = 1 ++ num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 ++ num_interstitial_to_select = 2 ++ ++ # The interstitial circles will always be the last two circles in the `current_centers` array. ++ # Their 0-indexed positions will be after the central (index 0) and the 23 peripheral circles. ++ # So, indices are 1 (for central) + 23 (for peripheral) = 24 and 25. ++ interstitial_circle_indices_to_pass = [ ++ num_fixed_central + num_peripheral_to_select, ++ num_fixed_central + num_peripheral_to_select + 1 ++ ] ++ ++ for w_central in central_weight_options: ++ for sc in start_coord_options: ++ for ec in end_coord_options: ++ # Ensure end_coord is strictly greater than start_coord for valid linspace ++ if ec <= sc: ++ continue ++ ++ # Ensure the midpoint of the grid aligns with 0.5 for the central point heuristic. ++ # For grid_size=5, the midpoint coordinate is `sc + (ec - sc) / 2`. ++ if not np.isclose(sc + (ec - sc) / 2, 0.5): ++ continue # Skip combinations where grid's central point will not be at (0.5,0.5) ++ ++ all_grid_centers = _generate_grid_centers(grid_size, sc, ec) ++ all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec) ++ ++ # Identify the central point (0.5, 0.5) and the 24 peripheral grid points. ++ center_coord_val = sc + (ec - sc) / (grid_size - 1) * (grid_size // 2) ++ central_point = np.array([center_coord_val, center_coord_val]) ++ ++ peripheral_grid_points = [] ++ for center in all_grid_centers: ++ if not np.allclose(center, central_point): ++ peripheral_grid_points.append(center) ++ peripheral_grid_points = np.array(peripheral_grid_points) # These are the 24 peripheral points ++ ++ # Iterate through all combinations of 23 peripheral points from the 24 available ++ for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): ++ selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] ++ ++ # Iterate through all combinations of 2 interstitial points from the 16 available candidates ++ for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): ++ selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] ++ ++ # Construct the full set of 26 centers for the current combination ++ current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) ++ current_centers = np.array(current_centers_list) ++ ++ # Compute radii for this specific configuration ++ current_radii = compute_max_radii(current_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) ++ current_sum_radii = np.sum(current_radii) ++ ++ # Keep track of the configuration that yields the highest sum of radii ++ if current_sum_radii > best_sum_radii: ++ best_sum_radii = current_sum_radii ++ best_centers = current_centers ++ best_radii = current_radii + + return best_centers, best_radii + + # EVOLVE-BLOCK-END + + + # This part remains fixed (not evolved) + def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/main.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/main.py new file mode 100644 index 0000000000000000000000000000000000000000..de4f4c923ff0c81dda8107dc10af7e4669161ef6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/main.py @@ -0,0 +1,240 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np +import itertools + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """ + Generates centers for a square grid of circles. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + start_coord (float): The starting coordinate for linspace. + end_coord (float): The ending coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers. + For a GxG grid, there are (G-1)x(G-1) interstitial points, located at the center + of each square formed by four adjacent grid circles. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + start_coord (float): The starting coordinate of the grid. + end_coord (float): The ending coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + # This prevents them from growing too large initially and sub-optimally + # squeezing their neighbors, allowing for a better overall packing. + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # Other circles have normal weight (j is always > i, so j is never the first circle if i=0) + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This version implements a combinatorial search for peripheral and interstitial circles, + while also optimizing grid boundary parameters and the central circle's weight. + It places: + - 1 fixed central circle. + - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). + - 2 interstitial circles, chosen from the 16 available interstitial candidate positions. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n_circles = 26 + grid_size = 5 + + # Ranges for optimizing grid boundaries + start_coord_options = np.linspace(0.08, 0.12, 5) # e.g., 0.08, 0.09, 0.10, 0.11, 0.12 + end_coord_options = np.linspace(0.88, 0.92, 5) # e.g., 0.88, 0.89, 0.90, 0.91, 0.92 + + # Range for optimizing central circle weight + central_weight_options = np.linspace(1.2, 2.0, 3) # e.g., [1.2, 1.6, 2.0] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Define the number of circles to select for each category + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 + + # The interstitial circles will always be the last two circles in the `current_centers` array. + # Their 0-indexed positions will be after the central (index 0) and the 23 peripheral circles. + # So, indices are 1 (for central) + 23 (for peripheral) = 24 and 25. + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + for w_central in central_weight_options: + for sc in start_coord_options: + for ec in end_coord_options: + # Ensure end_coord is strictly greater than start_coord for valid linspace + if ec <= sc: + continue + + # Ensure the midpoint of the grid aligns with 0.5 for the central point heuristic. + # For grid_size=5, the midpoint coordinate is `sc + (ec - sc) / 2`. + if not np.isclose(sc + (ec - sc) / 2, 0.5): + continue # Skip combinations where grid's central point will not be at (0.5,0.5) + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec) + + # Identify the central point (0.5, 0.5) and the 24 peripheral grid points. + center_coord_val = sc + (ec - sc) / (grid_size - 1) * (grid_size // 2) + central_point = np.array([center_coord_val, center_coord_val]) + + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) # These are the 24 peripheral points + + # Iterate through all combinations of 23 peripheral points from the 24 available + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + # Iterate through all combinations of 2 interstitial points from the 16 available candidates + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Construct the full set of 26 centers for the current combination + current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) + current_centers = np.array(current_centers_list) + + # Compute radii for this specific configuration + current_radii = compute_max_radii(current_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + current_sum_radii = np.sum(current_radii) + + # Keep track of the configuration that yields the highest sum of radii + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/original.py b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/original.py new file mode 100644 index 0000000000000000000000000000000000000000..073496d6b4cd36f671e51e820eb49c9507e58a41 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/original.py @@ -0,0 +1,225 @@ +# EVOLVE-BLOCK-START +"""Constructor-based circle packing for n=26 circles""" + +import numpy as np + + +def _generate_grid_centers(grid_size, start_coord, end_coord): + """ + Generates centers for a square grid of circles. + + Args: + grid_size (int): The number of circles along one dimension of the square grid. + start_coord (float): The starting coordinate for linspace. + end_coord (float): The ending coordinate for linspace. + + Returns: + np.array: An array of (x, y) coordinates for the grid centers. + """ + x_coords = np.linspace(start_coord, end_coord, grid_size) + y_coords = np.linspace(start_coord, end_coord, grid_size) + grid_centers = [] + for y in y_coords: + for x in x_coords: + grid_centers.append([x, y]) + return np.array(grid_centers) + + +def _generate_interstitial_candidates(grid_size, start_coord, end_coord): + """ + Generates potential interstitial points within the grid formed by _generate_grid_centers. + For a GxG grid, there are (G-1)x(G-1) interstitial points, located at the center + of each square formed by four adjacent grid circles. + + Args: + grid_size (int): The number of circles along one dimension of the base grid. + start_coord (float): The starting coordinate of the grid. + end_coord (float): The ending coordinate of the grid. + + Returns: + np.array: An array of (x, y) coordinates for the candidate interstitial centers. + """ + if grid_size < 2: + return np.array([]) + + step_coord = (end_coord - start_coord) / (grid_size - 1) + + candidates = [] + # Interstitial points are halfway between grid points + for i in range(grid_size - 1): # y-indices + for j in range(grid_size - 1): # x-indices + interstitial_x = start_coord + j * step_coord + step_coord / 2 + interstitial_y = start_coord + i * step_coord + step_coord / 2 + candidates.append([interstitial_x, interstitial_y]) + return np.array(candidates) + + +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for the interstitial circle and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle. + # Instead of a fixed cap, this prevents it from growing too large initially + # by considering its proximity to other circles, allowing for a better + # overall packing, especially in sparse regions. + if interstitial_idx != -1 and interstitial_idx < n: + # Calculate distances from the interstitial point to all other centers + other_centers = np.delete(centers, interstitial_idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + + # Set the initial radius to be at most half the minimum distance to a neighbor. + # This value is then capped by its boundary distance already in radii[interstitial_idx]. + radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + w_i = 1.5 if i == 0 else 1.0 # Central circle (index 0) is protected + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii + + +def construct_packing(): + """ + Construct an arrangement of 26 circles by first placing 25 circles + (one at the center, 24 on a grid) and then systematically searching for + the best position for the 26th circle from a set of interstitial candidates. + This version also systematically optimizes the grid boundary parameters (start_coord, end_coord) + to improve edge utilization and overall packing density. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n_circles = 26 + grid_size = 5 # For a 5x5 grid, total 25 points + + # Ranges for optimizing grid boundaries (Recommendation 2: Systematically optimize `np.linspace` parameters) + # These ranges are chosen to ensure the central grid point remains at (0.5, 0.5) + # given grid_size=5, as (start_coord + end_coord) / 2 = 0.5 for current options. + start_coord_options = np.linspace(0.08, 0.12, 5) # e.g., 0.08, 0.09, 0.10, 0.11, 0.12 + end_coord_options = np.linspace(0.88, 0.92, 5) # e.g., 0.88, 0.89, 0.90, 0.91, 0.92 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + for sc in start_coord_options: + for ec in end_coord_options: + # Ensure end_coord is strictly greater than start_coord for valid linspace + if ec <= sc: + continue + + # Ensure the midpoint of the grid aligns with 0.5 for the central point heuristic. + # For grid_size=5, the midpoint coordinate is `sc + (ec - sc) / 2`. + if not np.isclose(sc + (ec - sc) / 2, 0.5): + continue # Skip combinations where grid's central point will not be at (0.5,0.5) + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + + # 1. Prioritize the central (0.5, 0.5) circle. + # Due to the (sc + ec) / 2 = 0.5 constraint and odd grid_size, (0.5, 0.5) + # will always be exactly at the center of `all_grid_centers`. + central_point_coords = np.array([0.5, 0.5]) + + # Find the index of the central point within the generated grid centers + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0] + + # This check adds robustness, though it should always find one with the current options. + if central_idx_in_grid.size == 0: + continue + + central_idx_in_grid = central_idx_in_grid[0] + + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords # The central circle is always at index 0 + + # The remaining 24 grid centers (excluding the central one) fill the rest of base_centers + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, sc, ec) + + # 3. Explore each candidate interstitial position to find the one maximizing the sum of radii. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + # The interstitial circle is always the last one added, so its index is n_circles - 1 + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii + +# EVOLVE-BLOCK-END + + +# This part remains fixed (not evolved) +def run_packing(): + """Run the circle packing constructor for n=26""" + centers, radii = construct_packing() + # Calculate the sum of radii + sum_radii = np.sum(radii) + return centers, radii, sum_radii \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5c327313348259d4bd43d75faea831eb4ba556c9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8802248193193365, + "spatial_uniformity_details": { + "cell_size_mean": 0.19736041730378753, + "cell_size_std": 0.02685550241565221, + "coefficient_of_variation": 0.13607339630946064 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.662240135647969, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013350998874884403, + "mean_density": 0.022655013063977415, + "cv": 0.5100262671659876 + }, + "packing_efficiency": 0.6216487529561742, + "packing_efficiency_details": { + "total_area": 0.6216487529561742, + "square_area": 1.0, + "efficiency": 0.6216487529561742, + "relative_to_estimated_best": 0.7400580392335407 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08544772261069246, + "std": 0.017588018229831755, + "min": 0.03763886318562511, + "max": 0.1110746929211277, + "range": 0.0734358297355026, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.6336, + "gap_analysis_details": { + "covered_samples": 1584, + "total_samples": 2500, + "coverage": 0.6336, + "gap_ratio": 0.36639999999999995 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865471, + "max_quality": 0.7071067811865479 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..a5d588149d6e697a8e752f7bc43d47b49cbd17a0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 100.10 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2216 + + Auxiliary Metrics: + • spatial_uniformity: 0.880 + • edge_utilization: 0.738 + • density_variance: 0.662 + • packing_efficiency: 0.622 + • radius_distribution: 0.974 + • gap_analysis: 0.634 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2216 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.880 + • Boundary and corner utilization: 0.738 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.662 + • Area utilization efficiency: 0.622 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.634 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 36.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..e92a3b56ada601706d291b8c2ebf9d49e908b8a0 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.221640787878004, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4000, 0.2000)\n centers[25] = (0.6000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8802248193193365, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.662240135647969, + "aux_packing_efficiency": 0.6216487529561742, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.6336, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.221640787878004 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2216\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.880\n \u2022 Boundary and corner utilization: 0.738\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.662\n \u2022 Area utilization efficiency: 0.622\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.634\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 36.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/results/packing_viz.png", + "execution_time_mean": 100.10314619587734, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/search_replace.txt b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/search_replace.txt new file mode 100644 index 0000000000000000000000000000000000000000..ead9d09eb89751b34e43313efcbc79139a133af6 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_93/search_replace.txt @@ -0,0 +1,361 @@ +revert_to_combinatorial_search_with_hp_tuning +Reverts the core packing strategy to a previously higher-performing combinatorial search (1 central, 23 peripheral, 2 interstitial) and re-introduces hyperparameter tuning for central weight and grid boundaries. This addresses the "40% unused space" by leveraging a more flexible center selection strategy. + + +<<<<<<< SEARCH +import numpy as np +======= +import numpy as np +import itertools +>>>>>>> REPLACE + + + +refactor_compute_max_radii_for_multiple_interstitials_and_w_central + + +Refactors the `compute_max_radii` function to correctly handle a list of `interstitial_indices` for its initial radius heuristic and to accept a `w_central` parameter for the central circle's overlap resolution weight. This generalizes the function for more flexible packing strategies, particularly when multiple interstitial circles are used and when the central circle's importance needs tuning. + + +<<<<<<< SEARCH +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_idx=-1): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for the interstitial circle and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_idx: Index of the interstitial circle to apply the heuristic. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle. + # Instead of a fixed cap, this prevents it from growing too large initially + # by considering its proximity to other circles, allowing for a better + # overall packing, especially in sparse regions. + if interstitial_idx != -1 and interstitial_idx < n: + # Calculate distances from the interstitial point to all other centers + other_centers = np.delete(centers, interstitial_idx, axis=0) + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[interstitial_idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + + # Set the initial radius to be at most half the minimum distance to a neighbor. + # This value is then capped by its boundary distance already in radii[interstitial_idx]. + radii[interstitial_idx] = min(radii[interstitial_idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + w_i = 1.5 if i == 0 else 1.0 # Central circle (index 0) is protected + w_j = 1.0 # Other circles have normal weight + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii +======= +def compute_max_radii(centers, max_iterations=2000, tolerance=1e-7, interstitial_indices=None, w_central=1.5): + """ + Compute maximum radii using an iterative relaxation approach. Includes a + heuristic for interstitial circles and weighted scaling for the central one. + + Args: + centers: np.array of shape (n, 2) with (x, y) coordinates. + max_iterations: Maximum iterations for the relaxation process. + tolerance: Convergence tolerance. + interstitial_indices: A list of indices for interstitial circles to apply + an adaptive initial radius heuristic. Defaults to None. + w_central (float): Weight factor for the central circle during overlap resolution. + + Returns: + np.array: Array of radii for each circle. + """ + n = centers.shape[0] + radii = np.zeros(n) + + # 1. Initialize radii based on distance to square borders. + for i in range(n): + x, y = centers[i] + radii[i] = min(x, y, 1 - x, 1 - y) + + # Heuristic: Adaptively cap the initial radius of the interstitial circle(s). + # This prevents them from growing too large initially and sub-optimally + # squeezing their neighbors, allowing for a better overall packing. + if interstitial_indices: + for idx in interstitial_indices: + if idx < n: # Ensure index is valid + other_centers_mask = np.ones(n, dtype=bool) + other_centers_mask[idx] = False + other_centers = centers[other_centers_mask] + + if len(other_centers) > 0: + distances_to_others = np.linalg.norm(centers[idx] - other_centers, axis=1) + min_dist_to_neighbor = np.min(distances_to_others) + radii[idx] = min(radii[idx], 0.5 * min_dist_to_neighbor) + + # 2. Iteratively adjust radii to resolve overlaps until convergence. + for _ in range(max_iterations): + prev_radii = np.copy(radii) + + for i in range(n): + for j in range(i + 1, n): + dist = np.linalg.norm(centers[i] - centers[j]) + + if radii[i] + radii[j] > dist: + overlap = radii[i] + radii[j] - dist + + # Weighted proportional scaling to protect the central circle (at index 0). + # A higher weight (w_i > 1) means that circle 'i' shrinks less proportionally. + # Index 0 is guaranteed to be the central circle due to how construct_packing builds base_centers. + w_i = w_central if i == 0 else 1.0 + w_j = 1.0 # Other circles have normal weight (j is always > i, so j is never the first circle if i=0) + + weighted_r_i = radii[i] / w_i + weighted_r_j = radii[j] / w_j + + total_weighted_radii = weighted_r_i + weighted_r_j + + if total_weighted_radii > 1e-12: # Avoid division by zero + radii[i] -= overlap * (weighted_r_i / total_weighted_radii) + radii[j] -= overlap * (weighted_r_j / total_weighted_radii) + else: + # Fallback for extremely tiny radii sums (should be rare) + # Just scale down proportionally to prevent infinite loop or negative radii + scale_factor = dist / (radii[i] + radii[j]) if (radii[i] + radii[j]) > 1e-12 else 0 + radii[i] *= scale_factor + radii[j] *= scale_factor + + # Ensure no radii become negative + radii[radii < 0] = 0 + + if np.allclose(radii, prev_radii, atol=tolerance): + break + + return radii +>>>>>>> REPLACE + + + +revert_construct_packing_to_combinatorial_search + + +Reverts the `construct_packing` function to a previously successful combinatorial search strategy. Instead of fixing 24 grid points and adding one interstitial, it now selects 23 peripheral circles from the 24 non-central grid points and 2 interstitial circles from the 16 candidates. This greatly expands the search space and improves packing flexibility, aiming to increase the sum of radii. It also adds a hyperparameter search for the central circle's weight (`w_central`). + + +<<<<<<< SEARCH +def construct_packing(): + """ + Construct an arrangement of 26 circles by first placing 25 circles + (one at the center, 24 on a grid) and then systematically searching for + the best position for the 26th circle from a set of interstitial candidates. + This version also systematically optimizes the grid boundary parameters (start_coord, end_coord) + to improve edge utilization and overall packing density. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n_circles = 26 + grid_size = 5 # For a 5x5 grid, total 25 points + + # Ranges for optimizing grid boundaries (Recommendation 2: Systematically optimize `np.linspace` parameters) + # These ranges are chosen to ensure the central grid point remains at (0.5, 0.5) + # given grid_size=5, as (start_coord + end_coord) / 2 = 0.5 for current options. + start_coord_options = np.linspace(0.08, 0.12, 5) # e.g., 0.08, 0.09, 0.10, 0.11, 0.12 + end_coord_options = np.linspace(0.88, 0.92, 5) # e.g., 0.88, 0.89, 0.90, 0.91, 0.92 + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + for sc in start_coord_options: + for ec in end_coord_options: + # Ensure end_coord is strictly greater than start_coord for valid linspace + if ec <= sc: + continue + + # Ensure the midpoint of the grid aligns with 0.5 for the central point heuristic. + # For grid_size=5, the midpoint coordinate is `sc + (ec - sc) / 2`. + if not np.isclose(sc + (ec - sc) / 2, 0.5): + continue # Skip combinations where grid's central point will not be at (0.5,0.5) + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + + # 1. Prioritize the central (0.5, 0.5) circle. + # Due to the (sc + ec) / 2 = 0.5 constraint and odd grid_size, (0.5, 0.5) + # will always be exactly at the center of `all_grid_centers`. + central_point_coords = np.array([0.5, 0.5]) + + # Find the index of the central point within the generated grid centers + central_idx_in_grid = np.where(np.all(np.isclose(all_grid_centers, central_point_coords), axis=1))[0] + + # This check adds robustness, though it should always find one with the current options. + if central_idx_in_grid.size == 0: + continue + + central_idx_in_grid = central_idx_in_grid[0] + + + base_centers = np.zeros((n_circles - 1, 2)) + base_centers[0] = central_point_coords # The central circle is always at index 0 + + # The remaining 24 grid centers (excluding the central one) fill the rest of base_centers + other_grid_centers = np.delete(all_grid_centers, central_idx_in_grid, axis=0) + base_centers[1:] = other_grid_centers + + + # 2. Generate interstitial candidates for the 26th circle. + candidate_interstitial_points = _generate_interstitial_candidates(grid_size, sc, ec) + + # 3. Explore each candidate interstitial position to find the one maximizing the sum of radii. + for interstitial_point in candidate_interstitial_points: + current_centers = np.vstack([base_centers, interstitial_point]) + # The interstitial circle is always the last one added, so its index is n_circles - 1 + interstitial_idx = n_circles - 1 + + current_radii = compute_max_radii(current_centers, interstitial_idx=interstitial_idx) + current_sum_radii = np.sum(current_radii) + + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii +======= +def construct_packing(): + """ + Construct a specific arrangement of 26 circles in a unit square + that attempts to maximize the sum of their radii. + + This version implements a combinatorial search for peripheral and interstitial circles, + while also optimizing grid boundary parameters and the central circle's weight. + It places: + - 1 fixed central circle. + - 23 peripheral circles, chosen from the 24 available grid points (excluding the center). + - 2 interstitial circles, chosen from the 16 available interstitial candidate positions. + + Returns: + Tuple of (centers, radii) + centers: np.array of shape (26, 2) with (x, y) coordinates + radii: np.array of shape (26) with radius of each circle + """ + n_circles = 26 + grid_size = 5 + + # Ranges for optimizing grid boundaries + start_coord_options = np.linspace(0.08, 0.12, 5) # e.g., 0.08, 0.09, 0.10, 0.11, 0.12 + end_coord_options = np.linspace(0.88, 0.92, 5) # e.g., 0.88, 0.89, 0.90, 0.91, 0.92 + + # Range for optimizing central circle weight + central_weight_options = np.linspace(1.2, 2.0, 3) # e.g., [1.2, 1.6, 2.0] + + best_sum_radii = -1.0 + best_centers = None + best_radii = None + + # Define the number of circles to select for each category + num_fixed_central = 1 + num_peripheral_to_select = n_circles - num_fixed_central - 2 # 26 - 1 - 2 = 23 + num_interstitial_to_select = 2 + + # The interstitial circles will always be the last two circles in the `current_centers` array. + # Their 0-indexed positions will be after the central (index 0) and the 23 peripheral circles. + # So, indices are 1 (for central) + 23 (for peripheral) = 24 and 25. + interstitial_circle_indices_to_pass = [ + num_fixed_central + num_peripheral_to_select, + num_fixed_central + num_peripheral_to_select + 1 + ] + + for w_central in central_weight_options: + for sc in start_coord_options: + for ec in end_coord_options: + # Ensure end_coord is strictly greater than start_coord for valid linspace + if ec <= sc: + continue + + # Ensure the midpoint of the grid aligns with 0.5 for the central point heuristic. + # For grid_size=5, the midpoint coordinate is `sc + (ec - sc) / 2`. + if not np.isclose(sc + (ec - sc) / 2, 0.5): + continue # Skip combinations where grid's central point will not be at (0.5,0.5) + + all_grid_centers = _generate_grid_centers(grid_size, sc, ec) + all_interstitial_candidates = _generate_interstitial_candidates(grid_size, sc, ec) + + # Identify the central point (0.5, 0.5) and the 24 peripheral grid points. + center_coord_val = sc + (ec - sc) / (grid_size - 1) * (grid_size // 2) + central_point = np.array([center_coord_val, center_coord_val]) + + peripheral_grid_points = [] + for center in all_grid_centers: + if not np.allclose(center, central_point): + peripheral_grid_points.append(center) + peripheral_grid_points = np.array(peripheral_grid_points) # These are the 24 peripheral points + + # Iterate through all combinations of 23 peripheral points from the 24 available + for p_indices_combo in itertools.combinations(range(len(peripheral_grid_points)), num_peripheral_to_select): + selected_peripheral_points = peripheral_grid_points[list(p_indices_combo)] + + # Iterate through all combinations of 2 interstitial points from the 16 available candidates + for i_indices_combo in itertools.combinations(range(len(all_interstitial_candidates)), num_interstitial_to_select): + selected_interstitial_points = all_interstitial_candidates[list(i_indices_combo)] + + # Construct the full set of 26 centers for the current combination + current_centers_list = [central_point] + list(selected_peripheral_points) + list(selected_interstitial_points) + current_centers = np.array(current_centers_list) + + # Compute radii for this specific configuration + current_radii = compute_max_radii(current_centers, interstitial_indices=interstitial_circle_indices_to_pass, w_central=w_central) + current_sum_radii = np.sum(current_radii) + + # Keep track of the configuration that yields the highest sum of radii + if current_sum_radii > best_sum_radii: + best_sum_radii = current_sum_radii + best_centers = current_centers + best_radii = current_radii + + return best_centers, best_radii +>>>>>>> REPLACE + \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..371644f32d529f184e8479e78638899c20f49d56 Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..ed77ffed06399b0dbd74c8bc31d22df58987ca18 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.9262086329869444, + "spatial_uniformity_details": { + "cell_size_mean": 0.19918567919627053, + "cell_size_std": 0.015869193082024863, + "coefficient_of_variation": 0.07967035113361523 + }, + "edge_utilization": 0.7230769230769231, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 8, + "corner_score": 1.0, + "edge_score": 0.3076923076923077 + }, + "density_variance": 0.6507510260642492, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013170432818898175, + "mean_density": 0.021383546041597864, + "cv": 0.5366860134635718 + }, + "packing_efficiency": 0.5976921448748342, + "packing_efficiency_details": { + "total_area": 0.5976921448748342, + "square_area": 1.0, + "efficiency": 0.5976921448748342, + "relative_to_estimated_best": 0.711538267708136 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08344656629652222, + "std": 0.0188156578764126, + "min": 0.021087230548853864, + "max": 0.10168799482571135, + "range": 0.08060076427685749, + "small_count": 6, + "medium_count": 9, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.5936, + "gap_analysis_details": { + "covered_samples": 1484, + "total_samples": 2500, + "coverage": 0.5936, + "gap_ratio": 0.4064 + }, + "geometric_quality": 0.6967135021967906, + "geometric_quality_details": { + "num_triangles": 35, + "avg_triangle_quality": 0.6967135021967906, + "min_quality": 0.4912522368342203, + "max_quality": 0.7075815525423831 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..8694a838db514335badf5847a10c71cc2e5558e9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.17 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.1696 + + Auxiliary Metrics: + • spatial_uniformity: 0.926 + • edge_utilization: 0.723 + • density_variance: 0.651 + • packing_efficiency: 0.598 + • radius_distribution: 0.974 + • gap_analysis: 0.594 + • geometric_quality: 0.697 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.1696 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.926 + • Boundary and corner utilization: 0.723 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.651 + • Area utilization efficiency: 0.598 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.594 + • Delaunay triangulation quality: 0.697 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 40.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..f6ae3eddf5d54f2d7475eb9426f9a67e9832bf7b --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.1696107237095776, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.6929, 0.2929)\n centers[10] = (0.9071, 0.2929)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.6929, 0.5071)\n centers[14] = (0.9071, 0.5071)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.3000, 0.7000)\n centers[17] = (0.5000, 0.7000)\n centers[18] = (0.7000, 0.7000)\n centers[19] = (0.9000, 0.7000)\n centers[20] = (0.1000, 0.9000)\n centers[21] = (0.3000, 0.9000)\n centers[22] = (0.5000, 0.9000)\n centers[23] = (0.7000, 0.9000)\n centers[24] = (0.9000, 0.9000)\n centers[25] = (0.8000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.9262086329869444, + "aux_edge_utilization": 0.7230769230769231, + "aux_density_variance": 0.6507510260642492, + "aux_packing_efficiency": 0.5976921448748342, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.5936, + "aux_geometric_quality": 0.6967135021967906 + }, + "private": { + "reported_sum_of_radii": 2.1696107237095776 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.1696\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.926\n \u2022 Boundary and corner utilization: 0.723\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.651\n \u2022 Area utilization efficiency: 0.598\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.594\n \u2022 Delaunay triangulation quality: 0.697\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 40.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_94/results/packing_viz.png", + "execution_time_mean": 0.17329419264569879, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..aa23fbba0c3ac5cefb7bcc8266a3809b77e4d69e Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..65c722c90b5bc3686466902c81e27ffacf25d2e8 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8629755280155726, + "spatial_uniformity_details": { + "cell_size_mean": 0.1949476486133398, + "cell_size_std": 0.03095406287394859, + "coefficient_of_variation": 0.1587814109856828 + }, + "edge_utilization": 0.46923076923076923, + "edge_utilization_details": { + "corners_touched": 2, + "edges_touched": 11, + "corner_score": 0.5, + "edge_score": 0.4230769230769231 + }, + "density_variance": 0.5562203560468365, + "density_variance_details": { + "grid_size": 10, + "variance": 0.0002042364904962519, + "mean_density": 0.017912085214360884, + "cv": 0.7978486208365142 + }, + "packing_efficiency": 0.5343111195704735, + "packing_efficiency_details": { + "total_area": 0.5343111195704735, + "square_area": 1.0, + "efficiency": 0.5343111195704735, + "relative_to_estimated_best": 0.6360846661553257 + }, + "radius_distribution": 0.982944883585438, + "radius_distribution_details": { + "mean": 0.0761241394817508, + "std": 0.027322512378459497, + "min": 0.0, + "max": 0.1075300877260175, + "range": 0.1075300877260175, + "small_count": 7, + "medium_count": 8, + "large_count": 11, + "diversity_score": 0.982944883585438 + }, + "gap_analysis": 0.5344, + "gap_analysis_details": { + "covered_samples": 1336, + "total_samples": 2500, + "coverage": 0.5344, + "gap_ratio": 0.4656 + }, + "geometric_quality": 0.666133979284106, + "geometric_quality_details": { + "num_triangles": 45, + "avg_triangle_quality": 0.666133979284106, + "min_quality": 0.3779702107444966, + "max_quality": 0.8637205911880631 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..c7c0938b22b796b4baf000e17c819980ad30c6d1 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/job_log.out @@ -0,0 +1,74 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 0.82 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 1.9792 + + Auxiliary Metrics: + • spatial_uniformity: 0.863 + • edge_utilization: 0.469 + • density_variance: 0.556 + • packing_efficiency: 0.534 + • radius_distribution: 0.983 + • gap_analysis: 0.534 + • geometric_quality: 0.666 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 1.9792 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.863 + +⚠️ Areas for Improvement: + • Boundary and corner utilization: 0.469 + → Consider placing larger circles near boundaries and corners + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.556 + • Area utilization efficiency: 0.534 + • Radius size diversity: 0.983 + • Area coverage (1 - gap ratio): 0.534 + • Delaunay triangulation quality: 0.666 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Only 2/4 corners are utilized. Place larger circles at unused corners. + 2. Detected 46.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..e1803ea3882595a1f72034d1468da7a8d6507704 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 1.9792276265255206, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.7500, 0.5000)\n centers[2] = (0.6768, 0.6768)\n centers[3] = (0.5000, 0.7500)\n centers[4] = (0.3232, 0.6768)\n centers[5] = (0.2500, 0.5000)\n centers[6] = (0.3232, 0.3232)\n centers[7] = (0.5000, 0.2500)\n centers[8] = (0.6768, 0.3232)\n centers[9] = (0.8864, 0.6035)\n centers[10] = (0.7828, 0.7828)\n centers[11] = (0.6035, 0.8864)\n centers[12] = (0.3965, 0.8864)\n centers[13] = (0.2172, 0.7828)\n centers[14] = (0.1136, 0.6035)\n centers[15] = (0.1136, 0.3965)\n centers[16] = (0.2172, 0.2172)\n centers[17] = (0.3965, 0.1136)\n centers[18] = (0.6035, 0.1136)\n centers[19] = (0.7828, 0.2172)\n centers[20] = (0.8864, 0.3965)\n centers[21] = (0.0892, 0.9124)\n centers[22] = (0.0914, 0.0843)\n centers[23] = (0.9119, 0.1093)\n centers[24] = (0.7663, 0.0728)\n centers[25] = (0.8969, 0.9222)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8629755280155726, + "aux_edge_utilization": 0.46923076923076923, + "aux_density_variance": 0.5562203560468365, + "aux_packing_efficiency": 0.5343111195704735, + "aux_radius_distribution": 0.982944883585438, + "aux_gap_analysis": 0.5344, + "aux_geometric_quality": 0.666133979284106 + }, + "private": { + "reported_sum_of_radii": 1.9792276265255206 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 1.9792\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.863\n\n\u26a0\ufe0f Areas for Improvement:\n \u2022 Boundary and corner utilization: 0.469\n \u2192 Consider placing larger circles near boundaries and corners\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.556\n \u2022 Area utilization efficiency: 0.534\n \u2022 Radius size diversity: 0.983\n \u2022 Area coverage (1 - gap ratio): 0.534\n \u2022 Delaunay triangulation quality: 0.666\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Only 2/4 corners are utilized. Place larger circles at unused corners.\n 2. Detected 46.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_95/results/packing_viz.png", + "execution_time_mean": 0.8244949602521956, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/__pycache__/main.cpython-311.pyc b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..902b3dfb2acd5d4dd09af9a2f42cbc8b6bc0a23f Binary files /dev/null and b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/__pycache__/main.cpython-311.pyc differ diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/auxiliary_analysis.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/auxiliary_analysis.json new file mode 100644 index 0000000000000000000000000000000000000000..5c327313348259d4bd43d75faea831eb4ba556c9 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/auxiliary_analysis.json @@ -0,0 +1,55 @@ +{ + "spatial_uniformity": 0.8802248193193365, + "spatial_uniformity_details": { + "cell_size_mean": 0.19736041730378753, + "cell_size_std": 0.02685550241565221, + "coefficient_of_variation": 0.13607339630946064 + }, + "edge_utilization": 0.7384615384615385, + "edge_utilization_details": { + "corners_touched": 4, + "edges_touched": 9, + "corner_score": 1.0, + "edge_score": 0.34615384615384615 + }, + "density_variance": 0.662240135647969, + "density_variance_details": { + "grid_size": 10, + "variance": 0.00013350998874884403, + "mean_density": 0.022655013063977415, + "cv": 0.5100262671659876 + }, + "packing_efficiency": 0.6216487529561742, + "packing_efficiency_details": { + "total_area": 0.6216487529561742, + "square_area": 1.0, + "efficiency": 0.6216487529561742, + "relative_to_estimated_best": 0.7400580392335407 + }, + "radius_distribution": 0.9735387992937531, + "radius_distribution_details": { + "mean": 0.08544772261069246, + "std": 0.017588018229831755, + "min": 0.03763886318562511, + "max": 0.1110746929211277, + "range": 0.0734358297355026, + "small_count": 9, + "medium_count": 6, + "large_count": 11, + "diversity_score": 0.9735387992937531 + }, + "gap_analysis": 0.6336, + "gap_analysis_details": { + "covered_samples": 1584, + "total_samples": 2500, + "coverage": 0.6336, + "gap_ratio": 0.36639999999999995 + }, + "geometric_quality": 0.7071067811865474, + "geometric_quality_details": { + "num_triangles": 34, + "avg_triangle_quality": 0.7071067811865474, + "min_quality": 0.7071067811865471, + "max_quality": 0.7071067811865479 + } +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/correct.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/correct.json new file mode 100644 index 0000000000000000000000000000000000000000..3253af2e0d1b8942bcb0602218b9caf2145945ab --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/correct.json @@ -0,0 +1,4 @@ +{ + "correct": true, + "error": null +} \ No newline at end of file diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/job_log.err b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/job_log.err new file mode 100644 index 0000000000000000000000000000000000000000..345388018093ce84dec98ead3e182d85d46d64b2 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/job_log.err @@ -0,0 +1,9 @@ +/home/tengxiao/pj/ShinkaEvolve/.venv/lib/python3.11/site-packages/instructor/providers/gemini/client.py:5: FutureWarning: + +All support for the `google.generativeai` package has ended. It will no longer be receiving +updates or bug fixes. Please switch to the `google.genai` package as soon as possible. +See README for more details: + +https://github.com/google-gemini/deprecated-generative-ai-python/blob/main/README.md + + import google.generativeai as genai # type: ignore[import-not-found] diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/job_log.out b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/job_log.out new file mode 100644 index 0000000000000000000000000000000000000000..3c3c90b9e99122392830a5ff27b0709909ea6b7d --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/job_log.out @@ -0,0 +1,70 @@ +[MetricRegistry] Registered metric: spatial_uniformity +[MetricRegistry] Registered metric: edge_utilization +[MetricRegistry] Registered metric: density_variance +[MetricRegistry] Registered metric: packing_efficiency +[MetricRegistry] Registered metric: radius_distribution +[MetricRegistry] Registered metric: gap_analysis +[MetricRegistry] Registered metric: geometric_quality +====================================================================== +ENHANCED EVALUATION WITH AUXILIARY METRICS +====================================================================== +Program: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/main.py +Results: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results +Auxiliary Metrics: ENABLED +====================================================================== + +Run 1/1 completed in 39.86 seconds +[AuxiliaryEval] Detailed analysis saved to: examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/auxiliary_analysis.json +Detailed packing data saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/extra.npz +Visualization saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/packing_viz.png +Correctness and error status saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/correct.json +Metrics saved to examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/metrics.json + +====================================================================== +✅ EVALUATION COMPLETED SUCCESSFULLY +====================================================================== + +📊 METRICS SUMMARY: +---------------------------------------------------------------------- + Primary Score (sum of radii): 2.2216 + + Auxiliary Metrics: + • spatial_uniformity: 0.880 + • edge_utilization: 0.738 + • density_variance: 0.662 + • packing_efficiency: 0.622 + • radius_distribution: 0.974 + • gap_analysis: 0.634 + • geometric_quality: 0.707 + +============================================================ +AUXILIARY EVALUATION FEEDBACK +============================================================ +Primary Score (sum of radii): 2.2216 + +Auxiliary Metrics: +------------------------------------------------------------ + +✅ Strengths: + • Spatial distribution uniformity (Voronoi analysis): 0.880 + • Boundary and corner utilization: 0.738 + • Delaunay triangulation quality: 0.707 + +📊 Other Metrics: + • Spatial density uniformity across grid: 0.662 + • Area utilization efficiency: 0.622 + • Radius size diversity: 0.974 + • Area coverage (1 - gap ratio): 0.634 + +------------------------------------------------------------ +💡 Actionable Recommendations: + 1. Detected 36.6% unused space. Consider increasing radii in sparse regions. +============================================================ + +====================================================================== +📁 OUTPUT FILES: + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/metrics.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/correct.json + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/extra.npz + • examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/auxiliary_analysis.json +====================================================================== diff --git a/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/metrics.json b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..33c3ef1c307e2a8ec356ec7bee6ba31f6e5ff496 --- /dev/null +++ b/examples_deprecated/circle_packing/results__debug/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/metrics.json @@ -0,0 +1,24 @@ +{ + "combined_score": 2.221640787878004, + "public": { + "centers_str": " centers[0] = (0.5000, 0.5000)\n centers[1] = (0.1000, 0.1000)\n centers[2] = (0.3000, 0.1000)\n centers[3] = (0.5000, 0.1000)\n centers[4] = (0.7000, 0.1000)\n centers[5] = (0.9000, 0.1000)\n centers[6] = (0.1000, 0.3000)\n centers[7] = (0.3000, 0.3000)\n centers[8] = (0.5000, 0.3000)\n centers[9] = (0.7000, 0.3000)\n centers[10] = (0.9000, 0.3000)\n centers[11] = (0.1000, 0.5000)\n centers[12] = (0.3000, 0.5000)\n centers[13] = (0.7000, 0.5000)\n centers[14] = (0.9000, 0.5000)\n centers[15] = (0.1000, 0.7000)\n centers[16] = (0.5000, 0.7000)\n centers[17] = (0.7000, 0.7000)\n centers[18] = (0.9000, 0.7000)\n centers[19] = (0.1000, 0.9000)\n centers[20] = (0.3000, 0.9000)\n centers[21] = (0.5000, 0.9000)\n centers[22] = (0.7000, 0.9000)\n centers[23] = (0.9000, 0.9000)\n centers[24] = (0.4000, 0.2000)\n centers[25] = (0.6000, 0.4000)", + "num_circles": 26, + "aux_spatial_uniformity": 0.8802248193193365, + "aux_edge_utilization": 0.7384615384615385, + "aux_density_variance": 0.662240135647969, + "aux_packing_efficiency": 0.6216487529561742, + "aux_radius_distribution": 0.9735387992937531, + "aux_gap_analysis": 0.6336, + "aux_geometric_quality": 0.7071067811865474 + }, + "private": { + "reported_sum_of_radii": 2.221640787878004 + }, + "text_feedback": "============================================================\nAUXILIARY EVALUATION FEEDBACK\n============================================================\nPrimary Score (sum of radii): 2.2216\n\nAuxiliary Metrics:\n------------------------------------------------------------\n\n\u2705 Strengths:\n \u2022 Spatial distribution uniformity (Voronoi analysis): 0.880\n \u2022 Boundary and corner utilization: 0.738\n \u2022 Delaunay triangulation quality: 0.707\n\n\ud83d\udcca Other Metrics:\n \u2022 Spatial density uniformity across grid: 0.662\n \u2022 Area utilization efficiency: 0.622\n \u2022 Radius size diversity: 0.974\n \u2022 Area coverage (1 - gap ratio): 0.634\n\n------------------------------------------------------------\n\ud83d\udca1 Actionable Recommendations:\n 1. Detected 36.6% unused space. Consider increasing radii in sparse regions.\n============================================================", + "visualization_path": "examples/circle_packing/results/results_circle_packing_NO_vision_WITH_aux_20260118_072141/gen_99/results/packing_viz.png", + "execution_time_mean": 39.85848567681387, + "execution_time_std": 0.0, + "num_valid_runs": 1, + "num_invalid_runs": 0, + "all_validation_errors": [] +} \ No newline at end of file