/* Offline research candidate, 2026-10-31. NOT certified 16 kHz hard realtime. * Include AFTER g10_0deg_118_physicalnp_core.h. * Repair only a high-voltage-error 118 path by one- and two-adjacent-state * substitutions. Uses the exact same 639 K/Q pool, O-state current model, * NP predicted-voltage and 20-A current constraints, 1us minimum dwell, * per-device <=2 rise/fall switching budget and frozen carrier endpoints. * Does not relax any constraint and never worsens a valid existing path. */ #ifndef G10_119_LEGAL_REPAIR_H #define G10_119_LEGAL_REPAIR_H static int g10_119_evaluations=0; static int g10_119_improvements=0; static int g10_119_evaluate(const double x[16],int cycle,const uint16_t path[12],int n, const double b[8],double Bbefore,double dur[12],double *e,double *B,double *npdev){ int prev=(cycle+G10_NCYCLE-1)%G10_NCYCLE; const uint16_t prevcode=G10_codes[prev][G10_nseg[prev]-1]; if(!g10_116_budget(prevcode,path,n))return 0; g10_119_evaluations++; return g10_117_eval_path(x,path,n,b,Bbefore,dur,e,B,npdev); } static int g10_119_repair(const double x[16],int cycle,int n,double dur[12],double *err){ if(n<4||n>12||!isfinite(*err)||*err<=10.)return 0; const double vp=x[6],vn=x[7],delta=vp-vn; double l[4],r[4],b[8]={1,0,0,0,0,0,0,0}; if(!g10_fourleg_ref(x,vp,vn,l)||!g10_fourleg_ref(x+3,vp,vn,r))return 0; for(int j=0;j<3;j++){b[j+1]=l[j]-l[3];b[j+4]=r[j]-r[3];} b[7]=G10_CNP*G10_KNP*delta; const double Bbefore=-delta+(1./16000.)*G10_KNP*delta; uint16_t path[12]={0},best[12]={0}; double dcheck[12],bc=0,np=0,ec=0,bestD[12],bestB=0,bestNp=0; for(int k=0;k0.05;pass++){ int selected=-1;uint16_t selectedCode=0;double candidateE=bestE-1.e-6; for(int pos=1;pos0.05;pass++){ int selected=-1;uint16_t code1=0,code2=0;double candidateE=bestE-1.e-6; for(int pos=1;pos=*err-1.e-6)return 0; for(int k=0;k0 && *errv>10.)g10_119_repair(inputs,cycle,n,durations_us,errv); return n; } #endif