Enriched default_atomic_factory with Kronecker, mirror, upscale, stack, symmetry transforms
Browse files
itt_solver/experiment_driver.py
CHANGED
|
@@ -63,9 +63,6 @@ def run_single(task, atomic_library, params, out_dir):
|
|
| 63 |
with open(os.path.join(out_dir, base + "_logs.json"), "w") as f:
|
| 64 |
json.dump(logs, f, default=str)
|
| 65 |
|
| 66 |
-
# IMPORTANT: do not call run_and_log_wandb here to avoid recursion.
|
| 67 |
-
# If you want W&B logging, call itt_solver.wandb_runner.run_and_log_wandb(...) externally.
|
| 68 |
-
|
| 69 |
return result
|
| 70 |
|
| 71 |
def sweep(tasks, atomic_library_factory, grid, out_dir="experiments", max_runs=None):
|
|
@@ -96,20 +93,64 @@ def sweep(tasks, atomic_library_factory, grid, out_dir="experiments", max_runs=N
|
|
| 96 |
runs += 1
|
| 97 |
return
|
| 98 |
|
| 99 |
-
|
| 100 |
def default_atomic_factory(params, task):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
import itt_solver.transforms as tr
|
| 102 |
-
from itt_solver.solver_core import tile_transform
|
| 103 |
|
| 104 |
# Capture target_shape by value to avoid late-binding closure bug
|
| 105 |
target_h, target_w = task['target_shape'][0], task['target_shape'][1]
|
| 106 |
|
| 107 |
libs = []
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
libs.append(tr.FillEnclosedHarmonic())
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
if params.get('use_symmetry', True):
|
| 113 |
libs.append(tr.Rotate(1))
|
|
|
|
|
|
|
| 114 |
libs.append(tr.Reflect('h'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
return libs
|
|
|
|
| 63 |
with open(os.path.join(out_dir, base + "_logs.json"), "w") as f:
|
| 64 |
json.dump(logs, f, default=str)
|
| 65 |
|
|
|
|
|
|
|
|
|
|
| 66 |
return result
|
| 67 |
|
| 68 |
def sweep(tasks, atomic_library_factory, grid, out_dir="experiments", max_runs=None):
|
|
|
|
| 93 |
runs += 1
|
| 94 |
return
|
| 95 |
|
| 96 |
+
|
| 97 |
def default_atomic_factory(params, task):
|
| 98 |
+
"""Build the default atomic library for a task.
|
| 99 |
+
|
| 100 |
+
Includes the original transforms plus the new Kronecker / mirror / upscale
|
| 101 |
+
family so the beam can express a much wider range of ARC patterns.
|
| 102 |
+
"""
|
| 103 |
import itt_solver.transforms as tr
|
| 104 |
+
from itt_solver.solver_core import tile_transform
|
| 105 |
|
| 106 |
# Capture target_shape by value to avoid late-binding closure bug
|
| 107 |
target_h, target_w = task['target_shape'][0], task['target_shape'][1]
|
| 108 |
|
| 109 |
libs = []
|
| 110 |
+
|
| 111 |
+
# --- core tiling ---
|
| 112 |
+
libs.append(tr.Transform(
|
| 113 |
+
lambda p, _h=target_h, _w=target_w: tile_transform(p, (_h, _w)),
|
| 114 |
+
"tile_to_target"))
|
| 115 |
+
libs.append(tr.tile_to_target_shifted(shift=(1, 1), tile_factor=3))
|
| 116 |
libs.append(tr.FillEnclosedHarmonic())
|
| 117 |
+
|
| 118 |
+
# --- Kronecker / self-similar (covers 007bbfb7 family) ---
|
| 119 |
+
libs.append(tr.KroneckerSelfSimilar())
|
| 120 |
+
libs.append(tr.KroneckerSelfSimilarInv())
|
| 121 |
+
|
| 122 |
+
# --- mirror / kaleidoscope ---
|
| 123 |
+
libs.append(tr.MirrorTileH())
|
| 124 |
+
libs.append(tr.MirrorTileV())
|
| 125 |
+
libs.append(tr.MirrorTile4Way())
|
| 126 |
+
|
| 127 |
+
# --- upscale (2x and 3x) ---
|
| 128 |
+
libs.append(tr.Upscale(2))
|
| 129 |
+
libs.append(tr.Upscale(3))
|
| 130 |
+
|
| 131 |
+
# --- stacking ---
|
| 132 |
+
libs.append(tr.StackH(3))
|
| 133 |
+
libs.append(tr.StackV(3))
|
| 134 |
+
|
| 135 |
+
# --- structural ---
|
| 136 |
+
libs.append(tr.Transpose())
|
| 137 |
+
libs.append(tr.CropToContent())
|
| 138 |
+
|
| 139 |
+
# --- symmetry (optional) ---
|
| 140 |
if params.get('use_symmetry', True):
|
| 141 |
libs.append(tr.Rotate(1))
|
| 142 |
+
libs.append(tr.Rotate(2))
|
| 143 |
+
libs.append(tr.Rotate(3))
|
| 144 |
libs.append(tr.Reflect('h'))
|
| 145 |
+
libs.append(tr.Reflect('v'))
|
| 146 |
+
|
| 147 |
+
# --- gravity (optional) ---
|
| 148 |
+
if params.get('use_gravity', False):
|
| 149 |
+
libs.append(tr.GravityDown())
|
| 150 |
+
libs.append(tr.GravityUp())
|
| 151 |
+
|
| 152 |
+
# --- color ops (optional, for multi-color tasks) ---
|
| 153 |
+
if params.get('use_color_ops', False):
|
| 154 |
+
libs.append(tr.InvertColors())
|
| 155 |
+
|
| 156 |
return libs
|