PureOne's picture
Add Nhais-DQ II certified autonomous RSI research release
248ea7d verified
Raw History Blame Contribute Delete
1.46 kB
#!/usr/bin/env python3
"""Supplement: reuse the installed generator rather than rebuild it per query.
This deployment regime was specified AFTER the primary experiment. New seeds
are used for its assessment. It does not replace or conceal the cold-start result.
"""
from collections import deque
from engine import Guard
import time
def search_installed(generators, guard: Guard | None, expansions=6000, wall_budget=None):
start=time.perf_counter();ident=tuple(range(len(generators[0])))
best={ident:()};products=0;popped=0
if guard is None:
todo=deque([(ident,())])
while todo and popped<expansions:
if wall_budget is not None and time.perf_counter()-start>=wall_budget:break
sig,w=todo.popleft();popped+=1
for a,g in enumerate(generators):
value=tuple(g[x] for x in sig);products+=1
if value not in best:
child=w+(a,);best[value]=child;todo.append((value,child))
else:
todo=deque([(ident,(),0)])
while todo and popped<expansions:
if wall_budget is not None and time.perf_counter()-start>=wall_budget:break
sig,w,state=todo.popleft();popped+=1
for a,g in enumerate(generators):
ns=guard.next[state][a]
if guard.bad[ns]:continue
value=tuple(g[x] for x in sig);products+=1
if value not in best:
child=w+(a,);best[value]=child;todo.append((value,child,ns))
return {'known_semantics':len(best),'products':products,'popped':popped,
'wall_seconds':time.perf_counter()-start,'best':best}