code wiki / _hdl_build / nx_supplychain_case.nx

nx_supplychain_case.nx source

↩ module page · 35 lines · 2050 B

1// nx_supplychain_case.nx -- LIB: the Nishi-analyst DOMESTIC SUPPLY-CHAIN SECURITY + GOOD-JOBS business case. Adds the 2// geopolitical + labor dimensions to the supply-chain twin so the analyst/business-case builder can present a domestic 3// plan to city/state/federal government. Per component: country of ORIGIN (0 domestic, 1 allied, 2 adversary), ENERGY 4// risk (0-100), SINGLE-SOURCE flag, value. Computes value-weighted supply-chain RISK and DOMESTIC content, and the 5// reshoring case: jobs at a LIVING WAGE with European-exceeding benefits (healthcare, PTO) and home affordability. 6// never-brick #26: pure arithmetic, deterministic. license_tier: ORIGINAL 7import "nx_syscalls.nx" 8 9// domestic content in permil (by value; origin == 0 is domestic). 10func sc_domestic_permil(origin: *i64, value: *i64, n: i64) -> i64 { 11 var dom: i64=0; var tot: i64=0; var i: i64=0 12 while i<n { tot=tot+value[i]; if origin[i]==0 { dom=dom+value[i] } i=i+1 } 13 if tot<=0 { return 0 } 14 return dom*1000/tot 15} 16 17// value-weighted supply-chain risk: per part risk = origin_factor (dom 0 / allied 10 / adversary 30) 18// + single_source*20 + energy_risk/10. 19func sc_weighted_risk(origin: *i64, energy_risk: *i64, single_source: *i64, value: *i64, n: i64) -> i64 { 20 var num: i64=0; var tot: i64=0; var i: i64=0 21 while i<n { 22 var of: i64=0 23 if origin[i]==1 { of=10 } 24 if origin[i]==2 { of=30 } 25 let pr: i64 = of + single_source[i]*20 + energy_risk[i]/10 26 num = num + value[i]*pr; tot = tot + value[i]; i=i+1 27 } 28 if tot<=0 { return 0 } 29 return num/tot 30} 31 32func sc_payroll(jobs: i64, annual_wage: i64) -> i64 { return jobs*annual_wage } 33func sc_benefits(payroll: i64, pct: i64) -> i64 { return payroll*pct/100 } 34// home affordability = median_home / annual_wage (income multiple; lower is more affordable; <=4 = strong middle class). 35func sc_home_afford(median_home: i64, annual_wage: i64) -> i64 { if annual_wage<=0 { return 0-1 } return median_home/annual_wage }