code wiki / (root) / nx_ice_stabiliser_gate.nx

nx_ice_stabiliser_gate.nx source

↩ module page · 192 lines · 9000 B

1// nx_ice_stabiliser_gate.nx -- gate for the hydrocolloid term. 2// 3// T0 ★LBG is INERT without milk protein and works with it (310 permil) 4// T1 the protein-conditional flag separates LBG from xanthan 5// T2 ⚠GUAR -- the gum the reference product uses -- has NO measured 6// protein-conditional data in either direction 7// T3 gelatin's illegible cell reads UNKNOWN, never a substituted guess 8// T4 the CONTROL ITSELF MOVES with protein (4.02 -> 4.59), so retardation 9// must be taken against the matching control 10// T5 saturation at 0.3% w/w: dose past it is wasted, and measured as such 11// T6 recommended stabiliser FALLS as fat rises (35 -> 25 -> 15 per 10k) 12// T7 carrageenan minimum is dosed off PROTEIN: 13 per 100k at 41 permil 13// T8 carrageenan window is bounded BOTH sides: under-dose and gelling 14// T9 incompatibility xanthan > guar > LBG; guar demands a secondary 15// T10 ★★THE TRAP: Flores means show a 258 permil apparent gain and the 16// study found NO significant difference -- both are returned 17// T11 ★the refusals: model result does not transfer; gum swap unsupported 18// T12 mechanism is ice adsorption, not viscosity; storage, not freezing 19// T13 unknown gums and impossible doses REFUSE 20// 21// license_tier: ORIGINAL expect_exit: 0 22import "nx_syscalls.nx" 23import "nx_ice_stabiliser.nx" 24 25func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 26func gn(v: i64) -> i64 { 27 let b: *u8=sys_mmap(28); var m: i64=v; if m<0 {sys_write(1,"-" as *u8,1); m=0-m} 28 let t: *u8=sys_mmap(28); var k: i64=0; if m==0 {t[0]=48 as u8;k=1} while m>0 {t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} 29 var i: i64=0; while i<k {b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 30} 31func gck(pass: i64, name: *u8, fails: *i64) -> i64 { 32 if pass==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8); fails[0]=fails[0]+1 } 33 gw(name); gw("\n" as *u8); return 0 34} 35 36// B&J Vanilla protein load, permil of product: 6 g in a 143 g serving. 37const GT_BJ_PROTEIN_PERMIL: i64 = 41 38 39func t0() -> i64 { 40 // without protein LBG does not retard at all -- 4.05 against a 4.02 control 41 if stab_retardation_permil(STAB_LBG, 0) > 0 { return 0 } 42 if stab_lbg_inert_without_protein() != 1 { return 0 } 43 // with protein it retards by 310 permil 44 if stab_retardation_permil(STAB_LBG, 1) != 310 { return 0 } 45 return 1 46} 47 48func t1() -> i64 { 49 if stab_is_protein_conditional(STAB_LBG) != 1 { return 0 } 50 // xanthan retards WITHOUT protein, so it is not protein-conditional 51 if stab_is_protein_conditional(STAB_XANTHAN) != 0 { return 0 } 52 if stab_retardation_permil(STAB_XANTHAN, 0) != 299 { return 0 } 53 return 1 54} 55 56// The dataset does not cover guar. Substituting a neighbouring gum would 57// have produced a confident number about the competitor's actual formula. 58func t2() -> i64 { 59 if stab_rate_is_measured(STAB_GUAR, 0) != 0 { return 0 } 60 if stab_rate_is_measured(STAB_GUAR, 1) != 0 { return 0 } 61 if stab_rate_no_protein_q2(STAB_GUAR) != STAB_UNKNOWN { return 0 } 62 if stab_retardation_permil(STAB_GUAR, 1) != STAB_UNKNOWN { return 0 } 63 return 1 64} 65 66func t3() -> i64 { 67 // legible cell present 68 if stab_rate_no_protein_q2(STAB_GELATIN) != 365 { return 0 } 69 // illegible cell refuses 70 if stab_rate_with_protein_q2(STAB_GELATIN) != STAB_UNKNOWN { return 0 } 71 if stab_rate_is_measured(STAB_GELATIN, 1) != 0 { return 0 } 72 return 1 73} 74 75// ★Adding milk solids makes the UNSTABILISED system ripen FASTER (4.02 -> 76// 4.59). A model that compared every gum against one fixed control would 77// mis-attribute that shift to the gum. 78func t4() -> i64 { 79 if stab_rate_q2(STAB_NONE, 0) != 402 { return 0 } 80 if stab_rate_q2(STAB_NONE, 1) != 459 { return 0 } 81 if stab_rate_q2(STAB_NONE, 1) <= stab_rate_q2(STAB_NONE, 0) { return 0 } 82 return 1 83} 84 85func t5() -> i64 { 86 if stab_effective_dose_q4(50) != STAB_SATURATION_Q4 { return 0 } 87 if stab_wasted_dose_q4(50) != 20 { return 0 } 88 if stab_effective_dose_q4(20) != 20 { return 0 } 89 if stab_wasted_dose_q4(20) != 0 { return 0 } 90 // exactly at saturation nothing is wasted -- the boundary, both sides 91 if stab_wasted_dose_q4(30) != 0 { return 0 } 92 if stab_wasted_dose_q4(31) != 1 { return 0 } 93 return 1 94} 95 96func t6() -> i64 { 97 if stab_recommended_total_q4(100) != 35 { return 0 } 98 if stab_recommended_total_q4(146) != 25 { return 0 } 99 if stab_recommended_total_q4(160) != 15 { return 0 } 100 if stab_recommended_total_q4(100) <= stab_recommended_total_q4(160) { return 0 } 101 return 1 102} 103 104// The ratio-243 rule lands at 0.013%, and industry practice is 0.015-0.02% -- 105// just above the theoretical minimum, which is the agreement worth having. 106func t7() -> i64 { 107 if stab_casein_permil(GT_BJ_PROTEIN_PERMIL) != 32 { return 0 } 108 if stab_min_carrageenan_q5(GT_BJ_PROTEIN_PERMIL) != 13 { return 0 } 109 return 1 110} 111 112func t8() -> i64 { 113 // 0.02% clears the ratio and stays below the gelling threshold 114 if stab_carrageenan_dose_ok_q4(2, GT_BJ_PROTEIN_PERMIL) != 1 { return 0 } 115 // 0.01% is below the protein-derived minimum -> whey-off 116 if stab_carrageenan_dose_ok_q4(1, GT_BJ_PROTEIN_PERMIL) != 0 { return 0 } 117 // 0.06% is past the failure threshold -> gels 118 if stab_carrageenan_dose_ok_q4(6, GT_BJ_PROTEIN_PERMIL) != 0 { return 0 } 119 return 1 120} 121 122func t9() -> i64 { 123 if stab_incompatibility_rank(STAB_XANTHAN) <= stab_incompatibility_rank(STAB_GUAR) { return 0 } 124 if stab_incompatibility_rank(STAB_GUAR) <= stab_incompatibility_rank(STAB_LBG) { return 0 } 125 if stab_needs_secondary_colloid(STAB_GUAR) != 1 { return 0 } 126 if stab_needs_secondary_colloid(STAB_CARRAGEENAN) != 0 { return 0 } 127 return 1 128} 129 130// ★★The whole point of the organ. A reader taking the means alone would 131// price a 25.8% smoothness lever. The study reported no significant 132// difference, and the organ returns both so the trap cannot be walked into. 133func t10() -> i64 { 134 if stab_flores_x50_q2(STAB_FLORES_HARSH, STAB_NONE) != 2076 { return 0 } 135 if stab_flores_x50_q2(STAB_FLORES_HARSH, STAB_GUAR) != 1541 { return 0 } 136 if stab_flores_apparent_gain_permil(STAB_FLORES_HARSH, STAB_GUAR) != 258 { return 0 } 137 if stab_flores_difference_is_significant() != 0 { return 0 } 138 // and the apparent gain is genuinely large -- this is not a small number 139 // being dismissed, it is a large one that failed significance 140 if stab_flores_apparent_gain_permil(STAB_FLORES_HARSH, STAB_GUAR) < 200 { return 0 } 141 return 1 142} 143 144func t11() -> i64 { 145 if stab_model_result_transfers_to_product() != 0 { return 0 } 146 if stab_gum_swap_is_a_supported_lever(STAB_GUAR) != 0 { return 0 } 147 if stab_gum_swap_is_a_supported_lever(STAB_LBG) != 0 { return 0 } 148 return 1 149} 150 151func t12() -> i64 { 152 if stab_mechanism_is_ice_adsorption() != 1 { return 0 } 153 if stab_viscosity_explains_retardation() != 0 { return 0 } 154 if stab_acts_on_storage_not_freezing() != 1 { return 0 } 155 if stab_improves_initial_crystal_size() != 0 { return 0 } 156 return 1 157} 158 159func t13() -> i64 { 160 if stab_rate_no_protein_q2(99) != STAB_INVALID { return 0 } 161 if stab_incompatibility_rank(99) != STAB_INVALID { return 0 } 162 if stab_effective_dose_q4(0 - 1) != STAB_INVALID { return 0 } 163 if stab_min_carrageenan_q5(0) != STAB_INVALID { return 0 } 164 if stab_flores_x50_q2(STAB_FLORES_MILD, STAB_ALGINATE) != STAB_UNKNOWN { return 0 } 165 return 1 166} 167 168func main() -> i64 { 169 let fails: *i64 = sys_mmap(16) as *i64 170 fails[0] = 0 171 gw("=== nx_ice_stabiliser -- the hydrocolloid term, honestly bounded ===\n" as *u8) 172 173 gck(t0(), "T0 LBG inert without protein, 310 permil with it" as *u8, fails) 174 gck(t1(), "T1 protein-conditional flag separates LBG from xanthan" as *u8, fails) 175 gck(t2(), "T2 GUAR (the reference's gum) has NO measured data" as *u8, fails) 176 gck(t3(), "T3 illegible gelatin cell reads UNKNOWN, not a guess" as *u8, fails) 177 gck(t4(), "T4 the control itself moves 4.02 -> 4.59 with protein" as *u8, fails) 178 gck(t5(), "T5 0.3% saturation, waste measured, boundary both sides" as *u8, fails) 179 gck(t6(), "T6 recommended stabiliser falls as fat rises" as *u8, fails) 180 gck(t7(), "T7 carrageenan minimum dosed off protein = 13 per 100k" as *u8, fails) 181 gck(t8(), "T8 carrageenan window bounded BOTH sides" as *u8, fails) 182 gck(t9(), "T9 xanthan > guar > LBG; guar demands a secondary" as *u8, fails) 183 gck(t10(), "T10 258 permil apparent gain, NOT significant -- both" as *u8, fails) 184 gck(t11(), "T11 model result does not transfer; gum swap unsupported" as *u8, fails) 185 gck(t12(), "T12 ice adsorption not viscosity; storage not freezing" as *u8, fails) 186 gck(t13(), "T13 unknown gums and impossible doses REFUSE" as *u8, fails) 187 188 gw("pass=" as *u8); gn(14 - fails[0]); gw("/14\n" as *u8) 189 if fails[0] == 0 { gw("verdict=GREEN\n" as *u8) } else { gw("verdict=RED\n" as *u8) } 190 sys_exit(fails[0]) 191 return 0 192}