MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / main

Function main

scripts/rubi/triage-ch6.ts:32–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30}
31
32function main() {
33 const argv = process.argv;
34 let rubiRules = '/tmp/rubi-all/corpus';
35 let chapter = '6 Hyperbolic functions';
36 let sample = 100;
37 let seed = 42;
38 let show = 0;
39 let grep: string | null = null;
40 const suite = path.join(
41 os.homedir(),
42 'dev/rubi/MathematicaSyntaxTestSuite-master'
43 );
44 for (let i = 2; i < argv.length; i++) {
45 switch (argv[i]) {
46 case '--rubi': rubiRules = argv[++i]; break;
47 case '--chapter': chapter = argv[++i]; break;
48 case '--sample': sample = parseInt(argv[++i]); break;
49 case '--seed': seed = parseInt(argv[++i]); break;
50 case '--show': show = parseInt(argv[++i]); break;
51 case '--grep': grep = argv[++i]; break;
52 }
53 }
54
55 const { problems } = loadTests(suite, chapter);
56 let slice = problems;
57 if (sample > 0) {
58 const rand = mulberry32(seed);
59 slice = [...problems]
60 .map((p) => ({ p, k: rand() }))
61 .sort((a, b) => a.k - b.k)
62 .slice(0, sample)
63 .map((x) => x.p)
64 .sort((a, b) =>
65 a.file === b.file ? a.index - b.index : a.file < b.file ? -1 : 1
66 );
67 }
68 if (grep) slice = slice.filter((p) => p.source.includes(grep!));
69
70 const ce = new ComputeEngine();
71 const { rules } = compileSection(ce, rubiRules);
72 console.log(`compiled ${rules.length} rules; ${slice.length} problems\n`);
73
74 const unimpl = new Map<string, number>();
75 const condFail = new Map<string, number>();
76 const ruleFail = new Map<string, number>();
77 let solved = 0;
78 let noAttempt = 0; // no rule's skeleton even matched (dispatch/reduction gap)
79 const noAttemptEx: string[] = [];
80 const unsolvedEx: { src: string; firings: number; tail: string }[] = [];
81
82 for (const p of slice) {
83 const driver = new RubiDriver(ce, rules, {
84 timeLimitMs: 15_000,
85 trace: true,
86 });
87 // reset trace per problem
88 driver.stats.trace.length = 0;
89 let result: any = null;

Callers 1

triage-ch6.tsFile · 0.70

Calls 13

intMethod · 0.95
exprMethod · 0.95
loadTestsFunction · 0.90
compileSectionFunction · 0.90
topFunction · 0.85
mulberry32Function · 0.70
mapMethod · 0.65
sliceMethod · 0.65
logMethod · 0.65
hasMethod · 0.65
valuesMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected