nx_flavor_pairing_test.nx source
↩ module page · 53 lines · 2348 B
1// nx_flavor_pairing_test.nx -- smoke for nx_flavor_pairing (T4).
2//
3// Proves shared-compound pairing + the MEASURED EXCEED (scores any pair,
4// not just hand-listed ones):
5// - shared-compound counts are correct (1-3)
6// - flavor-network principle: a fruity pair (shared esters) out-scores a
7// fruit+allium pair (no shared compounds) (4)
8// - identical sets score 1000; affinity bounded (5-7)
9// - a NOVEL ingredient gets a real computed affinity, and a non-sharing
10// novel ingredient scores 0 (8-10) -- generalisation the table lacks
11// Exit code = failed assertion number; 0 = all pass.
12
13import "nx_syscalls.nx"
14import "nx_flavor_pairing.nx"
15
16func main() -> i64 {
17 let straw: *NxCompoundSet = nx_compounds_strawberry()
18 let pine: *NxCompoundSet = nx_compounds_pineapple()
19 let garlic:*NxCompoundSet = nx_compounds_garlic()
20 let beef: *NxCompoundSet = nx_compounds_roastbeef()
21
22 // --- shared-compound counts ---
23 if nx_pairing_shared(straw, pine) != 3 { return 1 } // share esters 3,4,5
24 if nx_pairing_shared(straw, garlic) != 0 { return 2 } // share nothing
25 if nx_pairing_shared(garlic, beef) != 1 { return 3 } // share compound 10
26
27 // --- flavor-network principle: more shared compounds -> better pair ---
28 if nx_pairing_affinity_milli(straw, pine) <= nx_pairing_affinity_milli(straw, garlic) { return 4 }
29
30 // --- identical sets score 1000; affinity bounded to [0,1000] ---
31 if nx_pairing_affinity_milli(straw, straw) != 1000 { return 5 }
32 if nx_pairing_affinity_milli(straw, pine) <= 0 { return 6 }
33 if nx_pairing_affinity_milli(straw, pine) > 1000 { return 7 }
34
35 // --- MEASURED EXCEED: a NOVEL ingredient (in no table) sharing 3
36 // compounds with strawberry gets a real affinity computed from
37 // structure; a non-sharing novel ingredient scores 0 ---
38 let novel_fruity: *NxCompoundSet = nx_compoundset_new(3)
39 let nf: *i64 = novel_fruity.ids
40 nf[0] = 0
41 nf[1] = 1
42 nf[2] = 2
43 if nx_pairing_shared(novel_fruity, straw) != 3 { return 8 }
44 if nx_pairing_affinity_milli(novel_fruity, straw) <= 0 { return 9 }
45
46 let novel_offbeat: *NxCompoundSet = nx_compoundset_new(2)
47 let no: *i64 = novel_offbeat.ids
48 no[0] = 20
49 no[1] = 21
50 if nx_pairing_affinity_milli(novel_offbeat, straw) != 0 { return 10 }
51
52 return 0
53}