import os,time,json,resource for key in ['OMP_NUM_THREADS','OPENBLAS_NUM_THREADS','MKL_NUM_THREADS']:os.environ[key]='1' start=time.process_time() from common1133 import read,ROOT,RED_SHA,BASIS_SHA import numpy as np from scipy.sparse import csc_matrix from scipy.sparse.linalg import splu C,B,F,e,b=read();n=len(B) M=csc_matrix(([v for i,j,v in e],([i for i,j,v in e],[j for i,j,v in e])),shape=(n,n),dtype=float) # SciPy documents Pr*A*Pc=L*U with original-index -> permuted-index mappings. lu=splu(M,permc_spec='COLAMD');pr=[int(x) for x in lu.perm_r];pc=[int(x) for x in lu.perm_c] assert sorted(pr)==sorted(pc)==list(range(n));pb=[0]*n for i,v in enumerate(b):pb[pr[i]]=v text=f'{n} {len(e)}\n'+''.join(f'{pr[i]} {pc[j]} {v}\n' for i,j,v in e)+' '.join(map(str,pb))+'\n' (ROOT/'permuted1133.txt').write_text(text) (ROOT/'ordering1133.json').write_text(json.dumps({'row':pr,'column':pc,'source':RED_SHA},sort_keys=True,separators=(',',':'))+'\n') receipt={'cpu_seconds':time.process_time()-start,'maxrss_bytes':resource.getrusage(resource.RUSAGE_SELF).ru_maxrss, 'scope':'saved-format/bound preflight and one floating ordering heuristic only; no LP, determinant or floating solution estimate'} (ROOT/'prepare-receipt1133.json').write_text(json.dumps(receipt,sort_keys=True)+'\n') print('PREPARE1133 PREFLIGHT_PASS ORDERING_READY')