universal-physics-tensor 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -34
- package/data/applied-cases.json +1892 -0
- package/data/applied-cases.schema.json +194 -0
- package/data/atlas/atlas.json +21 -21
- package/data/atlas/atlas.jsonld +1 -1
- package/data/atlas/diffusion.json +5 -5
- package/data/atlas/oscillators.json +7 -7
- package/data/atlas/waves.json +11 -11
- package/data/bridge-catalog.json +20 -4
- package/data/units.json +6 -25
- package/dist/atlas/benchmark/stats.d.ts.map +1 -1
- package/dist/atlas/benchmark/stats.js +6 -20
- package/dist/atlas/benchmark/stats.js.map +1 -1
- package/dist/atlas/physjs-entries.generated.d.ts +13 -4
- package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
- package/dist/atlas/physjs-entries.generated.js +15 -4
- package/dist/atlas/physjs-entries.generated.js.map +1 -1
- package/dist/atlas/physjs-reviewed.js +2 -2
- package/dist/atlas/physjs-reviewed.js.map +1 -1
- package/dist/cases/catalog-checks.d.ts +10 -0
- package/dist/cases/catalog-checks.d.ts.map +1 -0
- package/dist/cases/catalog-checks.js +241 -0
- package/dist/cases/catalog-checks.js.map +1 -0
- package/dist/cases/catalog.d.ts +83 -0
- package/dist/cases/catalog.d.ts.map +1 -0
- package/dist/cases/catalog.js +118 -0
- package/dist/cases/catalog.js.map +1 -0
- package/dist/cases/engine.d.ts +13 -0
- package/dist/cases/engine.d.ts.map +1 -0
- package/dist/cases/engine.js +179 -0
- package/dist/cases/engine.js.map +1 -0
- package/dist/cases/index.d.ts.map +1 -1
- package/dist/cases/index.js +5 -7
- package/dist/cases/index.js.map +1 -1
- package/dist/cases/methods.d.ts +215 -0
- package/dist/cases/methods.d.ts.map +1 -0
- package/dist/cases/methods.js +743 -0
- package/dist/cases/methods.js.map +1 -0
- package/dist/cases/types.d.ts +12 -0
- package/dist/cases/types.d.ts.map +1 -1
- package/dist/cases/types.js.map +1 -1
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/command.d.ts +3 -0
- package/dist/cli/command.d.ts.map +1 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/commands/_discovery-opts.d.ts +1 -0
- package/dist/cli/commands/_discovery-opts.d.ts.map +1 -1
- package/dist/cli/commands/_discovery-opts.js +1 -0
- package/dist/cli/commands/_discovery-opts.js.map +1 -1
- package/dist/cli/commands/discover.d.ts.map +1 -1
- package/dist/cli/commands/discover.js +116 -71
- package/dist/cli/commands/discover.js.map +1 -1
- package/dist/cli/commands/evaluate.js +2 -2
- package/dist/cli/commands/evaluate.js.map +1 -1
- package/dist/cli/commands/explain.d.ts.map +1 -1
- package/dist/cli/commands/explain.js +22 -2
- package/dist/cli/commands/explain.js.map +1 -1
- package/dist/cli/commands/ground.d.ts.map +1 -1
- package/dist/cli/commands/ground.js +6 -1
- package/dist/cli/commands/ground.js.map +1 -1
- package/dist/cli/commands/map.d.ts.map +1 -1
- package/dist/cli/commands/map.js +9 -6
- package/dist/cli/commands/map.js.map +1 -1
- package/dist/cli/determination.d.ts +1 -0
- package/dist/cli/determination.d.ts.map +1 -1
- package/dist/cli/determination.js.map +1 -1
- package/dist/cli/flag-help.d.ts +1 -0
- package/dist/cli/flag-help.d.ts.map +1 -1
- package/dist/cli/flag-help.js +1 -0
- package/dist/cli/flag-help.js.map +1 -1
- package/dist/cli/graphs.d.ts +2 -0
- package/dist/cli/graphs.d.ts.map +1 -1
- package/dist/cli/graphs.js +1 -0
- package/dist/cli/graphs.js.map +1 -1
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +1 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output.d.ts +8 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +8 -0
- package/dist/cli/output.js.map +1 -1
- package/dist/cli/statuses.d.ts.map +1 -1
- package/dist/cli/statuses.js +12 -2
- package/dist/cli/statuses.js.map +1 -1
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.d.ts.map +1 -1
- package/dist/cli/version.js +1 -0
- package/dist/cli/version.js.map +1 -1
- package/dist/cli-api.d.ts +2 -0
- package/dist/cli-api.d.ts.map +1 -1
- package/dist/cli-api.js +2 -0
- package/dist/cli-api.js.map +1 -1
- package/dist/composition/canonical-graph.d.ts +2 -2
- package/dist/composition/canonical-graph.js +2 -2
- package/dist/composition/canonical-graph.js.map +1 -1
- package/dist/composition/consequence.d.ts +15 -5
- package/dist/composition/consequence.d.ts.map +1 -1
- package/dist/composition/consequence.js +6 -4
- package/dist/composition/consequence.js.map +1 -1
- package/dist/composition/discovery.d.ts +78 -14
- package/dist/composition/discovery.d.ts.map +1 -1
- package/dist/composition/discovery.js +73 -23
- package/dist/composition/discovery.js.map +1 -1
- package/dist/composition/expr-eval.d.ts +1 -1
- package/dist/composition/expr-eval.d.ts.map +1 -1
- package/dist/composition/expr-eval.js +4 -4
- package/dist/composition/expr-eval.js.map +1 -1
- package/dist/composition/expr-simplify.d.ts +10 -14
- package/dist/composition/expr-simplify.d.ts.map +1 -1
- package/dist/composition/expr-simplify.js +49 -52
- package/dist/composition/expr-simplify.js.map +1 -1
- package/dist/composition/grounding.d.ts.map +1 -1
- package/dist/composition/grounding.js +19 -7
- package/dist/composition/grounding.js.map +1 -1
- package/dist/composition/mathts-quiet.d.ts +4 -6
- package/dist/composition/mathts-quiet.d.ts.map +1 -1
- package/dist/composition/mathts-quiet.js +4 -14
- package/dist/composition/mathts-quiet.js.map +1 -1
- package/dist/composition/own-equation-magnitude.d.ts +95 -0
- package/dist/composition/own-equation-magnitude.d.ts.map +1 -0
- package/dist/composition/own-equation-magnitude.js +270 -0
- package/dist/composition/own-equation-magnitude.js.map +1 -0
- package/dist/composition/probe/backend-protocol.d.ts +3 -0
- package/dist/composition/probe/backend-protocol.d.ts.map +1 -1
- package/dist/composition/probe/backend-protocol.js.map +1 -1
- package/dist/composition/probe/candidate-store.d.ts +1 -0
- package/dist/composition/probe/candidate-store.d.ts.map +1 -1
- package/dist/composition/probe/candidate-store.js +1 -0
- package/dist/composition/probe/candidate-store.js.map +1 -1
- package/dist/composition/probe/corpus.d.ts +4 -2
- package/dist/composition/probe/corpus.d.ts.map +1 -1
- package/dist/composition/probe/corpus.js +3 -3
- package/dist/composition/probe/corpus.js.map +1 -1
- package/dist/composition/probe/dataset.d.ts +1 -0
- package/dist/composition/probe/dataset.d.ts.map +1 -1
- package/dist/composition/probe/dataset.js.map +1 -1
- package/dist/composition/probe/experiment-design.d.ts +2 -0
- package/dist/composition/probe/experiment-design.d.ts.map +1 -1
- package/dist/composition/probe/experiment-design.js.map +1 -1
- package/dist/composition/probe/falsify.d.ts +2 -0
- package/dist/composition/probe/falsify.d.ts.map +1 -1
- package/dist/composition/probe/falsify.js.map +1 -1
- package/dist/composition/probe/fit.d.ts +1 -0
- package/dist/composition/probe/fit.d.ts.map +1 -1
- package/dist/composition/probe/fit.js.map +1 -1
- package/dist/composition/probe/generator.d.ts +3 -0
- package/dist/composition/probe/generator.d.ts.map +1 -1
- package/dist/composition/probe/generator.js +5 -6
- package/dist/composition/probe/generator.js.map +1 -1
- package/dist/composition/probe/limits.d.ts +1 -0
- package/dist/composition/probe/limits.d.ts.map +1 -1
- package/dist/composition/probe/limits.js.map +1 -1
- package/dist/composition/probe/pipeline.d.ts +5 -0
- package/dist/composition/probe/pipeline.d.ts.map +1 -1
- package/dist/composition/probe/pipeline.js +64 -21
- package/dist/composition/probe/pipeline.js.map +1 -1
- package/dist/composition/probe/power-law.d.ts.map +1 -1
- package/dist/composition/probe/power-law.js +3 -7
- package/dist/composition/probe/power-law.js.map +1 -1
- package/dist/composition/probe/problem.d.ts +1 -0
- package/dist/composition/probe/problem.d.ts.map +1 -1
- package/dist/composition/probe/problem.js.map +1 -1
- package/dist/composition/probe/residual.d.ts +1 -0
- package/dist/composition/probe/residual.d.ts.map +1 -1
- package/dist/composition/probe/residual.js +1 -0
- package/dist/composition/probe/residual.js.map +1 -1
- package/dist/composition/probe/run-manifest.d.ts +1 -0
- package/dist/composition/probe/run-manifest.d.ts.map +1 -1
- package/dist/composition/probe/run-manifest.js.map +1 -1
- package/dist/composition/probe/scalar-search.d.ts +50 -0
- package/dist/composition/probe/scalar-search.d.ts.map +1 -0
- package/dist/composition/probe/scalar-search.js +169 -0
- package/dist/composition/probe/scalar-search.js.map +1 -0
- package/dist/composition/probe/scoring.d.ts +1 -0
- package/dist/composition/probe/scoring.d.ts.map +1 -1
- package/dist/composition/probe/scoring.js.map +1 -1
- package/dist/composition/probe/study.d.ts +2 -2
- package/dist/composition/probe/study.d.ts.map +1 -1
- package/dist/composition/probe/study.js +6 -10
- package/dist/composition/probe/study.js.map +1 -1
- package/dist/composition/probe/t-tail.d.ts +3 -4
- package/dist/composition/probe/t-tail.d.ts.map +1 -1
- package/dist/composition/probe/t-tail.js +7 -10
- package/dist/composition/probe/t-tail.js.map +1 -1
- package/dist/composition/proposed-bridges.d.ts +11 -2
- package/dist/composition/proposed-bridges.d.ts.map +1 -1
- package/dist/composition/proposed-bridges.js +7 -5
- package/dist/composition/proposed-bridges.js.map +1 -1
- package/dist/composition/rational-exponent.d.ts +2 -2
- package/dist/composition/rational-exponent.d.ts.map +1 -1
- package/dist/composition/rational-exponent.js +4 -4
- package/dist/composition/rational-exponent.js.map +1 -1
- package/dist/composition/representative-values.d.ts.map +1 -1
- package/dist/composition/representative-values.js +6 -0
- package/dist/composition/representative-values.js.map +1 -1
- package/dist/composition/retrodiction.d.ts +15 -0
- package/dist/composition/retrodiction.d.ts.map +1 -1
- package/dist/composition/retrodiction.js +10 -3
- package/dist/composition/retrodiction.js.map +1 -1
- package/dist/composition/user-equation.d.ts +1 -0
- package/dist/composition/user-equation.d.ts.map +1 -1
- package/dist/composition/user-equation.js +1 -0
- package/dist/composition/user-equation.js.map +1 -1
- package/dist/core/constants.d.ts +12 -11
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +24 -21
- package/dist/core/constants.js.map +1 -1
- package/dist/diff/bridge-ast-gradient.d.ts +27 -23
- package/dist/diff/bridge-ast-gradient.d.ts.map +1 -1
- package/dist/diff/bridge-ast-gradient.js +75 -173
- package/dist/diff/bridge-ast-gradient.js.map +1 -1
- package/dist/dimensional/ast-types.d.ts +15 -0
- package/dist/dimensional/ast-types.d.ts.map +1 -1
- package/dist/dimensional/ast-types.js.map +1 -1
- package/dist/dimensional/curvature-composite.d.ts +1 -1
- package/dist/dimensional/curvature-composite.js.map +1 -1
- package/dist/dimensional/exact-scale.d.ts +41 -11
- package/dist/dimensional/exact-scale.d.ts.map +1 -1
- package/dist/dimensional/exact-scale.js +115 -123
- package/dist/dimensional/exact-scale.js.map +1 -1
- package/dist/dimensional/mathts-unit-delegation.d.ts +29 -0
- package/dist/dimensional/mathts-unit-delegation.d.ts.map +1 -0
- package/dist/dimensional/mathts-unit-delegation.js +187 -0
- package/dist/dimensional/mathts-unit-delegation.js.map +1 -0
- package/dist/dimensional/mathts-unit-wrapper.d.ts +33 -0
- package/dist/dimensional/mathts-unit-wrapper.d.ts.map +1 -0
- package/dist/dimensional/mathts-unit-wrapper.js +190 -0
- package/dist/dimensional/mathts-unit-wrapper.js.map +1 -0
- package/dist/dimensional/scalar-lowering.d.ts +21 -0
- package/dist/dimensional/scalar-lowering.d.ts.map +1 -0
- package/dist/dimensional/scalar-lowering.js +45 -0
- package/dist/dimensional/scalar-lowering.js.map +1 -0
- package/dist/dimensional/unit-data.d.ts +5 -1
- package/dist/dimensional/unit-data.d.ts.map +1 -1
- package/dist/dimensional/unit-data.js +28 -4
- package/dist/dimensional/unit-data.js.map +1 -1
- package/dist/dimensional/units.d.ts +2 -0
- package/dist/dimensional/units.d.ts.map +1 -1
- package/dist/dimensional/units.js +59 -3
- package/dist/dimensional/units.js.map +1 -1
- package/dist/dimensional/validator.d.ts +2 -0
- package/dist/dimensional/validator.d.ts.map +1 -1
- package/dist/dimensional/validator.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/numerical/connection-lowering-helpers.d.ts +3 -1
- package/dist/numerical/connection-lowering-helpers.d.ts.map +1 -1
- package/dist/numerical/connection-lowering-helpers.js +11 -15
- package/dist/numerical/connection-lowering-helpers.js.map +1 -1
- package/dist/numerical/pderiv.d.ts.map +1 -1
- package/dist/numerical/pderiv.js +2 -6
- package/dist/numerical/pderiv.js.map +1 -1
- package/dist/numerical/quadrature.js +3 -3
- package/dist/numerical/quadrature.js.map +1 -1
- package/dist/numerical/statistics.js +1 -1
- package/dist/numerical/statistics.js.map +1 -1
- package/dist/numerical/strides.d.ts +3 -2
- package/dist/numerical/strides.d.ts.map +1 -1
- package/dist/numerical/strides.js +3 -10
- package/dist/numerical/strides.js.map +1 -1
- package/package.json +9 -12
- package/dist/cases/brownian-sphere.d.ts +0 -68
- package/dist/cases/brownian-sphere.d.ts.map +0 -1
- package/dist/cases/brownian-sphere.js +0 -355
- package/dist/cases/brownian-sphere.js.map +0 -1
- package/dist/cases/damped-resonator.d.ts +0 -23
- package/dist/cases/damped-resonator.d.ts.map +0 -1
- package/dist/cases/damped-resonator.js +0 -221
- package/dist/cases/damped-resonator.js.map +0 -1
- package/dist/cases/kepler-rv.d.ts +0 -13
- package/dist/cases/kepler-rv.d.ts.map +0 -1
- package/dist/cases/kepler-rv.js +0 -173
- package/dist/cases/kepler-rv.js.map +0 -1
- package/dist/cases/lumped-cooling.d.ts +0 -51
- package/dist/cases/lumped-cooling.d.ts.map +0 -1
- package/dist/cases/lumped-cooling.js +0 -259
- package/dist/cases/lumped-cooling.js.map +0 -1
- package/dist/cases/resistor-noise.d.ts +0 -14
- package/dist/cases/resistor-noise.d.ts.map +0 -1
- package/dist/cases/resistor-noise.js +0 -215
- package/dist/cases/resistor-noise.js.map +0 -1
- package/dist/cases/skin-depth.d.ts +0 -17
- package/dist/cases/skin-depth.d.ts.map +0 -1
- package/dist/cases/skin-depth.js +0 -170
- package/dist/cases/skin-depth.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"problem.js","sourceRoot":"","sources":["../../../src/composition/probe/problem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAUzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAExE,gGAAgG;AAChG,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,CACL,CAAC,KAAK,qBAAqB;QAC3B,CAAC,KAAK,eAAe;QACrB,CAAC,KAAK,mBAAmB;QACzB,CAAC,KAAK,mBAAmB;QACzB,CAAC,KAAK,qBAAqB;QAC3B,CAAC,KAAK,kBAAkB;QACxB,CAAC,KAAK,yBAAyB;QAC/B,CAAC,KAAK,oBAAoB;QAC1B,CAAC,KAAK,kBAAkB;QACxB,CAAC,KAAK,OAAO,CACd,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAC7B,EAAU,EACV,OAAe,EACf,IAAI,GAAoB,yBAAyB;IAEjD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,UAAU,CAAC,mDAAmD,EAAE,IAAI,CAAC,CAAC;IAClF,CAAC;IACD,IAAI,IAAI,KAAK,eAAe,IAAI,IAAI,KAAK,mBAAmB,EAAE,CAAC;QAC7D,MAAM,IAAI,UAAU,CAAC,oBAAoB,IAAI,6CAA6C,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO;QACL,EAAE;QACF,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Q,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAClE,MAAM,IAAI,gBAAgB,CAAC,GAAG,IAAI,gCAAgC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,iBAAiB,CAAC,GAAG,kBAAkB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACzI,CAAC;YACD,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAC9B,OAAO,GAA0B,CAAC;QACpC,CAAC;QACD;YACE,MAAM,IAAI,gBAAgB,CAAC,GAAG,IAAI,cAAc,IAAI,6CAA6C,YAAY,GAAG,CAAC,CAAC;IACtH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,GAAG,GAAY,YAAY,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1E,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,YAAY,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QAChE,OAAO,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,IAAI,gBAAgB,CAAC,GAAG,IAAI,iCAAiC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["/**\n * Search-problem construction and JSON loading for Product B.\n *\n * @internal\n */\n\nimport { readJsonFile } from '../../core/data-file.js';\nimport { isPlainObject } from '../../core/json-schema.js';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { parseDimensionSpec } from '../../dimensional/dimension-spec.js';\nimport type { ExprNode } from '../../dimensional/ast-types.js';\nimport type {\n DimensionalVariableRef,\n DiscrepancyDefinition,\n FrontierGap,\n FrontierGapKind,\n ProbeDataset,\n SearchProblem,\n} from './types.js';\nimport { problemFromResidualGap } from './frontier.js';\nimport { asDatasetSafe, loadSplitDatasetsFromJson } from './dataset.js';\n\n/** Return whether a string names a supported frontier-gap kind for probe problems. @internal */\nexport function isGapKind(s: string): s is FrontierGapKind {\n return (\n s === 'prediction-residual' ||\n s === 'relation-link' ||\n s === 'regime-transition' ||\n s === 'parameter-tension' ||\n s === 'assumption-conflict' ||\n s === 'missing-operator' ||\n s === 'unexplained-observation' ||\n s === 'model-disagreement' ||\n s === 'causal-mechanism' ||\n s === 'other'\n );\n}\n\n/** Residual / unexplained-observation gap template. @internal */\nexport function makeResidualGap(\n id: string,\n summary: string,\n kind: FrontierGapKind = 'unexplained-observation',\n): FrontierGap {\n if (!id.startsWith('fg-')) {\n throw new RangeError(`makeResidualGap: id must start with 'fg-' (got '${id}')`);\n }\n if (kind === 'relation-link' || kind === 'regime-transition') {\n throw new RangeError(`makeResidualGap: ${kind} is Product A — use upt discover, not probe`);\n }\n return {\n id,\n kind,\n participants: [],\n observations: [],\n regimes: [],\n assumptions: [],\n constraints: [],\n evidence: { summary, sourceIds: [] },\n identifiability: {\n kind: 'parametric',\n parametric: { status: 'unknown', reasons: ['not yet assessed'] },\n },\n searchability: { searchable: true, reasons: ['residual gap'] },\n status: 'identified',\n };\n}\n\n/**\n * A JSON file that is not a search-problem file, or not an expression file: a field it must carry\n * is missing or holds a value of another kind. The message names the field; it never reports what\n * a JavaScript engine said on reading it. @internal\n */\nexport class ProblemFileError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ProblemFileError';\n }\n}\n\n/** The `DiscrepancyKind` union as a runtime set, for a file's `discrepancy.kind`. */\nconst DISCREPANCY_KINDS: ReadonlySet<string> = new Set([\n 'additive', 'relative', 'log-ratio', 'standardized', 'likelihood',\n 'vector', 'tensor', 'distributional', 'operator', 'custom',\n]);\n\n/** What a JSON value is, in the words a file author would use. */\nfunction kindOf(v: unknown): string {\n if (v === null) return 'null';\n if (Array.isArray(v)) return 'a list';\n if (typeof v === 'string') return 'text';\n if (typeof v === 'number') return 'a number';\n if (typeof v === 'boolean') return 'true or false';\n return typeof v === 'object' ? 'an object' : typeof v;\n}\n\n/** A `{\"name\", \"dim\"}` variable, read from `raw` and located by `where` in any refusal. */\nfunction varFromJson(raw: unknown, where: string): DimensionalVariableRef {\n if (!isPlainObject(raw)) {\n throw new ProblemFileError(`${where} must be {\"name\": text, \"dim\": text} (found ${kindOf(raw)})`);\n }\n const { name, dim } = raw;\n if (typeof name !== 'string' || name === '') {\n throw new ProblemFileError(`${where} needs a \"name\" (text)${name === undefined ? '' : `, found ${kindOf(name)}`}`);\n }\n if (typeof dim !== 'string' || dim === '') {\n throw new ProblemFileError(`${where} needs a \"dim\" (text)${dim === undefined ? '' : `, found ${kindOf(dim)}`}`);\n }\n return { name, dim: parseDimensionSpec(dim) };\n}\n\nexport interface ProblemFile {\n readonly gap?: {\n readonly id?: string;\n readonly kind?: string;\n readonly summary?: string;\n };\n readonly target: { readonly name: string; readonly dim: string };\n readonly governing: readonly { readonly name: string; readonly dim: string }[];\n readonly exploratory?: unknown;\n readonly holdout?: unknown;\n readonly observationsPath?: string;\n readonly baseline?: ExprNode;\n readonly discrepancy?: DiscrepancyDefinition;\n readonly assumptions?: readonly string[];\n readonly limits?: SearchProblem['limits'];\n readonly claimedRegimes?: Readonly<Record<string, string>>;\n readonly observationalBoundIds?: readonly string[];\n}\n\n/** Load a SearchProblem from a JSON file (optionally with inline datasets). @internal */\nexport function loadSearchProblemFromJson(path: string): SearchProblem {\n const raw = readJsonFile(path) as ProblemFile;\n return searchProblemFromFile(raw, path);\n}\n\n/**\n * The observations file a problem file names, resolved against the problem file's directory\n * (the working directory for an inline problem), or null when it names none. @internal\n */\nexport function resolveObservationsPath(raw: Pick<ProblemFile, 'observationsPath'>, source = 'inline'): string | null {\n if (!raw.observationsPath) return null;\n return isAbsolute(raw.observationsPath)\n ? raw.observationsPath\n : resolve(source === 'inline' ? process.cwd() : dirname(source), raw.observationsPath);\n}\n\n/** Build a SearchProblem from an already-parsed problem file. @internal */\nexport function searchProblemFromFile(raw: ProblemFile, source = 'inline'): SearchProblem {\n // `ProblemFile` is what a well-formed file holds; a file read from disk is any JSON value, so\n // each field is checked here before it is read, and a refusal names the field.\n const file: unknown = raw;\n if (!isPlainObject(file)) {\n throw new ProblemFileError(`the top level must be a JSON object with \"target\" and \"governing\" (found ${kindOf(file)})`);\n }\n if (file.target === undefined) throw new ProblemFileError('it has no \"target\" ({\"name\": text, \"dim\": text})');\n if (file.governing === undefined) throw new ProblemFileError('it has no \"governing\" list ([{\"name\": text, \"dim\": text}, ...])');\n if (!Array.isArray(file.governing)) {\n throw new ProblemFileError(`\"governing\" must be a list of {\"name\": text, \"dim\": text} (found ${kindOf(file.governing)})`);\n }\n if (file.gap !== undefined && !isPlainObject(file.gap)) {\n throw new ProblemFileError(`\"gap\" must be an object (found ${kindOf(file.gap)})`);\n }\n for (const field of ['id', 'kind', 'summary'] as const) {\n const v: unknown = raw.gap?.[field];\n if (v !== undefined && typeof v !== 'string') {\n throw new ProblemFileError(`gap.${field} must be text (found ${kindOf(v)})`);\n }\n }\n const kindRaw = raw.gap?.kind ?? 'unexplained-observation';\n if (!isGapKind(kindRaw)) {\n throw new ProblemFileError(`unknown gap kind '${kindRaw}' in gap.kind (see \\`upt help probe\\`, PROBLEM FILE)`);\n }\n if (kindRaw === 'relation-link' || kindRaw === 'regime-transition') {\n throw new ProblemFileError(`gap.kind '${kindRaw}' is a Product A gap: use \\`upt discover\\`, not probe`);\n }\n const gapId = raw.gap?.id ?? 'fg-inline';\n if (!gapId.startsWith('fg-')) {\n throw new ProblemFileError(`gap.id '${gapId}' must start with \"fg-\"`);\n }\n const gap = makeResidualGap(gapId, raw.gap?.summary ?? `search problem from ${source}`, kindRaw);\n const target = varFromJson(raw.target, '\"target\"');\n const governing = raw.governing.map((g, i) => varFromJson(g, `governing[${i}]`));\n let exploratory: ProbeDataset | undefined;\n let holdout: ProbeDataset | undefined;\n if (file.observationsPath !== undefined && typeof file.observationsPath !== 'string') {\n throw new ProblemFileError(`\"observationsPath\" must be text (found ${kindOf(file.observationsPath)})`);\n }\n const observationsPath = resolveObservationsPath(raw, source);\n if (observationsPath !== null) {\n const split = loadSplitDatasetsFromJson(observationsPath);\n exploratory = split.exploratory;\n holdout = split.holdout;\n }\n if (raw.exploratory) {\n exploratory = asDatasetSafe(raw.exploratory, `${source}#exploratory`, 'exploratory-fit');\n }\n if (raw.holdout) {\n holdout = asDatasetSafe(raw.holdout, `${source}#holdout`, 'validation-holdout');\n }\n const problem = problemFromResidualGap(gap, target, governing, exploratory, holdout);\n // The secondary fields. Each was once passed through unread, so `limits: 5` or\n // `assumptions: \"x\"` reached `runProbeSearch` and threw a raw TypeError there.\n return {\n ...problem,\n baseline: file.baseline === undefined ? undefined : assertExprNode(file.baseline, '\"baseline\"'),\n discrepancy: file.discrepancy === undefined ? problem.discrepancy : discrepancyFromJson(file.discrepancy),\n assumptions: file.assumptions === undefined ? gap.assumptions : textList(file.assumptions, 'assumptions'),\n limits: file.limits === undefined ? undefined : limitsFromJson(file.limits),\n claimedRegimes: file.claimedRegimes === undefined ? undefined : textRecord(file.claimedRegimes, 'claimedRegimes'),\n observationalBoundIds:\n file.observationalBoundIds === undefined ? undefined : textList(file.observationalBoundIds, 'observationalBoundIds'),\n };\n}\n\n/** A list of text, located by its field name. */\nfunction textList(raw: unknown, field: string): readonly string[] {\n const label = field.includes('.') ? field : `\"${field}\"`;\n if (!Array.isArray(raw)) throw new ProblemFileError(`${label} must be a list of text (found ${kindOf(raw)})`);\n return raw.map((v, i) => {\n if (typeof v !== 'string') throw new ProblemFileError(`${field}[${i}] must be text (found ${kindOf(v)})`);\n return v;\n });\n}\n\n/** A `{name: text}` object, located by its field name. */\nfunction textRecord(raw: unknown, field: string): Readonly<Record<string, string>> {\n if (!isPlainObject(raw)) throw new ProblemFileError(`\"${field}\" must be {name: text} (found ${kindOf(raw)})`);\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(raw)) {\n if (typeof v !== 'string') throw new ProblemFileError(`${field}.${k} must be text (found ${kindOf(v)})`);\n out[k] = v;\n }\n return out;\n}\n\nfunction discrepancyFromJson(raw: unknown): DiscrepancyDefinition {\n if (!isPlainObject(raw)) throw new ProblemFileError(`\"discrepancy\" must be {\"kind\": text, \"observableIds\": [text]} (found ${kindOf(raw)})`);\n if (typeof raw.kind !== 'string' || !DISCREPANCY_KINDS.has(raw.kind)) {\n throw new ProblemFileError(\n `discrepancy.kind '${String(raw.kind)}' is not a discrepancy kind (${[...DISCREPANCY_KINDS].join(', ')})`,\n );\n }\n const observableIds = textList(raw.observableIds, 'discrepancy.observableIds');\n for (const key of ['covarianceRef', 'implementationRef'] as const) {\n if (raw[key] !== undefined && typeof raw[key] !== 'string') {\n throw new ProblemFileError(`discrepancy.${key} must be text (found ${kindOf(raw[key])})`);\n }\n }\n return {\n kind: raw.kind as DiscrepancyDefinition['kind'],\n observableIds,\n ...(typeof raw.covarianceRef === 'string' ? { covarianceRef: raw.covarianceRef } : {}),\n ...(typeof raw.implementationRef === 'string' ? { implementationRef: raw.implementationRef } : {}),\n };\n}\n\nfunction limitsFromJson(raw: unknown): NonNullable<SearchProblem['limits']> {\n const shape = '{\"id\": text, \"regime\": {name: text}}';\n if (!Array.isArray(raw)) throw new ProblemFileError(`\"limits\" must be a list of ${shape} (found ${kindOf(raw)})`);\n return raw.map((l, i) => {\n if (!isPlainObject(l)) throw new ProblemFileError(`limits[${i}] must be ${shape} (found ${kindOf(l)})`);\n if (typeof l.id !== 'string' || l.id === '') throw new ProblemFileError(`limits[${i}].id must be text`);\n if (!isPlainObject(l.regime)) throw new ProblemFileError(`limits[${i}].regime must be {name: text} (found ${kindOf(l.regime)})`);\n const regime = textRecord(l.regime, `limits[${i}].regime`);\n if (l.description !== undefined && typeof l.description !== 'string') {\n throw new ProblemFileError(`limits[${i}].description must be text (found ${kindOf(l.description)})`);\n }\n return { id: l.id, regime, ...(typeof l.description === 'string' ? { description: l.description } : {}) };\n });\n}\n\n/** The scalar operators an `op` node may carry. */\nconst SCALAR_OPS: ReadonlySet<string> = new Set(['+', '-', '*', '/', '^']);\n/** The `TranscendentalFn` union as a runtime set. */\nconst TRANSCENDENTAL_FNS: ReadonlySet<string> = new Set(['exp', 'ln', 'log2', 'log10', 'sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh']);\n/** A decimal literal, as the validator reads a numeric-literal symbol. */\nconst DECIMAL_LITERAL = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?$/;\nconst DIM_KEYS = ['L', 'M', 'T', 'I', 'Theta', 'N', 'J'] as const;\nconst SCALAR_KINDS = 'symbol, op, integral, derivative, dirac-delta, variational-derivative, transcendental, abs';\n\n/** `raw[field]` as a child node, or a refusal that names the field. */\nfunction child(raw: Record<string, unknown>, field: string, path: string, what: string): ExprNode {\n if (raw[field] === undefined) throw new ProblemFileError(`${path} ${what} node needs ${field === 'args' ? '' : 'an '}\"${field}\" node`);\n return assertExprNode(raw[field], `${path}#${field}`);\n}\n\n/**\n * Check that a JSON value has the shape of a scalar `ExprNode`, recursively:\n * a kind per node, the children each kind owns, a finite literal where a\n * symbol's name is a decimal literal, and the seven dimension exponents on a\n * symbol. A tensor kind is refused here: the probe evaluates scalars.\n * Refusals are {@link ProblemFileError}, located by `path`.\n */\nfunction assertExprNode(raw: unknown, path: string): ExprNode {\n if (!isPlainObject(raw) || !('kind' in raw)) {\n throw new ProblemFileError(`${path} is not an ExprNode JSON object (found ${kindOf(raw)})`);\n }\n const kind = raw.kind;\n if (typeof kind !== 'string' || kind.length === 0) {\n throw new ProblemFileError(`${path} has invalid kind (found ${kindOf(kind)})`);\n }\n switch (kind) {\n case 'symbol': {\n if (typeof raw.name !== 'string' || raw.name.length === 0) {\n throw new ProblemFileError(`${path} symbol node missing name (needs \"name\": text)`);\n }\n if (!isPlainObject(raw.dim)) throw new ProblemFileError(`${path} symbol node missing dim`);\n for (const k of DIM_KEYS) {\n if (!(k in raw.dim)) throw new ProblemFileError(`${path} symbol node dim needs the exponents ${DIM_KEYS.join(', ')}`);\n if (typeof raw.dim[k] !== 'number' || !Number.isFinite(raw.dim[k])) {\n throw new ProblemFileError(`${path} symbol node dim.${k} must be a finite number (found ${kindOf(raw.dim[k])})`);\n }\n }\n if (DECIMAL_LITERAL.test(raw.name) && !Number.isFinite(Number(raw.name))) {\n throw new ProblemFileError(`${path} literal '${raw.name}' is not a finite number`);\n }\n return raw as unknown as ExprNode;\n }\n case 'op': {\n if (typeof raw.op !== 'string' || !Array.isArray(raw.args)) {\n throw new ProblemFileError(`${path} op node needs \"op\" and an \"args\" list (op node missing op/args)`);\n }\n if (!SCALAR_OPS.has(raw.op)) throw new ProblemFileError(`${path} op node has op '${raw.op}', not one of + - * / ^`);\n raw.args.forEach((a, i) => assertExprNode(a, `${path}#args[${i}]`));\n return raw as unknown as ExprNode;\n }\n case 'integral': {\n child(raw, 'over', path, 'integral');\n child(raw, 'integrand', path, 'integral');\n for (const bound of ['lower', 'upper']) if (raw[bound] !== undefined) assertExprNode(raw[bound], `${path}#${bound}`);\n return raw as unknown as ExprNode;\n }\n case 'derivative':\n child(raw, 'of', path, 'derivative');\n child(raw, 'wrt', path, 'derivative');\n return raw as unknown as ExprNode;\n case 'dirac-delta':\n case 'abs':\n child(raw, 'arg', path, kind);\n return raw as unknown as ExprNode;\n case 'variational-derivative':\n for (const f of ['functional', 'field', 'over']) child(raw, f, path, kind);\n return raw as unknown as ExprNode;\n case 'transcendental': {\n if (typeof raw.fn !== 'string' || !TRANSCENDENTAL_FNS.has(raw.fn)) {\n throw new ProblemFileError(`${path} transcendental node has fn '${String(raw.fn)}', not one of ${[...TRANSCENDENTAL_FNS].join(', ')}`);\n }\n child(raw, 'arg', path, kind);\n return raw as unknown as ExprNode;\n }\n default:\n throw new ProblemFileError(`${path} has kind '${kind}', which is not a scalar expression node (${SCALAR_KINDS})`);\n }\n}\n\n/**\n * Load an ExprNode from a JSON file (`{expression}` wrapper or bare node). The node shape is\n * checked recursively; a file that is not an expression raises {@link ProblemFileError}. @internal\n */\nexport function parseExprJson(path: string): ExprNode {\n const raw: unknown = readJsonFile(path);\n if (isPlainObject(raw) && 'kind' in raw) return assertExprNode(raw, path);\n if (isPlainObject(raw) && 'expression' in raw && raw.expression) {\n return assertExprNode(raw.expression, path);\n }\n throw new ProblemFileError(`${path} is not an ExprNode JSON object`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"problem.js","sourceRoot":"","sources":["../../../src/composition/probe/problem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAUzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAExE,gGAAgG;AAChG,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,CACL,CAAC,KAAK,qBAAqB;QAC3B,CAAC,KAAK,eAAe;QACrB,CAAC,KAAK,mBAAmB;QACzB,CAAC,KAAK,mBAAmB;QACzB,CAAC,KAAK,qBAAqB;QAC3B,CAAC,KAAK,kBAAkB;QACxB,CAAC,KAAK,yBAAyB;QAC/B,CAAC,KAAK,oBAAoB;QAC1B,CAAC,KAAK,kBAAkB;QACxB,CAAC,KAAK,OAAO,CACd,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAC7B,EAAU,EACV,OAAe,EACf,IAAI,GAAoB,yBAAyB;IAEjD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAA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search-problem construction and JSON loading for Product B.\n *\n * @internal\n */\n\nimport { readJsonFile } from '../../core/data-file.js';\nimport { isPlainObject } from '../../core/json-schema.js';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { parseDimensionSpec } from '../../dimensional/dimension-spec.js';\nimport type { ExprNode } from '../../dimensional/ast-types.js';\nimport type {\n DimensionalVariableRef,\n DiscrepancyDefinition,\n FrontierGap,\n FrontierGapKind,\n ProbeDataset,\n SearchProblem,\n} from './types.js';\nimport { problemFromResidualGap } from './frontier.js';\nimport { asDatasetSafe, loadSplitDatasetsFromJson } from './dataset.js';\n\n/** Return whether a string names a supported frontier-gap kind for probe problems. @internal */\nexport function isGapKind(s: string): s is FrontierGapKind {\n return (\n s === 'prediction-residual' ||\n s === 'relation-link' ||\n s === 'regime-transition' ||\n s === 'parameter-tension' ||\n s === 'assumption-conflict' ||\n s === 'missing-operator' ||\n s === 'unexplained-observation' ||\n s === 'model-disagreement' ||\n s === 'causal-mechanism' ||\n s === 'other'\n );\n}\n\n/** Residual / unexplained-observation gap template. @internal */\nexport function makeResidualGap(\n id: string,\n summary: string,\n kind: FrontierGapKind = 'unexplained-observation',\n): FrontierGap {\n if (!id.startsWith('fg-')) {\n throw new RangeError(`makeResidualGap: id must start with 'fg-' (got '${id}')`);\n }\n if (kind === 'relation-link' || kind === 'regime-transition') {\n throw new RangeError(`makeResidualGap: ${kind} is Product A — use upt discover, not probe`);\n }\n return {\n id,\n kind,\n participants: [],\n observations: [],\n regimes: [],\n assumptions: [],\n constraints: [],\n evidence: { summary, sourceIds: [] },\n identifiability: {\n kind: 'parametric',\n parametric: { status: 'unknown', reasons: ['not yet assessed'] },\n },\n searchability: { searchable: true, reasons: ['residual gap'] },\n status: 'identified',\n };\n}\n\n/**\n * A JSON file that is not a search-problem file, or not an expression file: a field it must carry\n * is missing or holds a value of another kind. The message names the field; it never reports what\n * a JavaScript engine said on reading it. @internal\n */\nexport class ProblemFileError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ProblemFileError';\n }\n}\n\n/** The `DiscrepancyKind` union as a runtime set, for a file's `discrepancy.kind`. */\nconst DISCREPANCY_KINDS: ReadonlySet<string> = new Set([\n 'additive', 'relative', 'log-ratio', 'standardized', 'likelihood',\n 'vector', 'tensor', 'distributional', 'operator', 'custom',\n]);\n\n/** What a JSON value is, in the words a file author would use. */\nfunction kindOf(v: unknown): string {\n if (v === null) return 'null';\n if (Array.isArray(v)) return 'a list';\n if (typeof v === 'string') return 'text';\n if (typeof v === 'number') return 'a number';\n if (typeof v === 'boolean') return 'true or false';\n return typeof v === 'object' ? 'an object' : typeof v;\n}\n\n/** A `{\"name\", \"dim\"}` variable, read from `raw` and located by `where` in any refusal. */\nfunction varFromJson(raw: unknown, where: string): DimensionalVariableRef {\n if (!isPlainObject(raw)) {\n throw new ProblemFileError(`${where} must be {\"name\": text, \"dim\": text} (found ${kindOf(raw)})`);\n }\n const { name, dim } = raw;\n if (typeof name !== 'string' || name === '') {\n throw new ProblemFileError(`${where} needs a \"name\" (text)${name === undefined ? '' : `, found ${kindOf(name)}`}`);\n }\n if (typeof dim !== 'string' || dim === '') {\n throw new ProblemFileError(`${where} needs a \"dim\" (text)${dim === undefined ? '' : `, found ${kindOf(dim)}`}`);\n }\n return { name, dim: parseDimensionSpec(dim) };\n}\n\n/** The JSON shape of a probe problem file, as read before validation. */\nexport interface ProblemFile {\n readonly gap?: {\n readonly id?: string;\n readonly kind?: string;\n readonly summary?: string;\n };\n readonly target: { readonly name: string; readonly dim: string };\n readonly governing: readonly { readonly name: string; readonly dim: string }[];\n readonly exploratory?: unknown;\n readonly holdout?: unknown;\n readonly observationsPath?: string;\n readonly baseline?: ExprNode;\n readonly discrepancy?: DiscrepancyDefinition;\n readonly assumptions?: readonly string[];\n readonly limits?: SearchProblem['limits'];\n readonly claimedRegimes?: Readonly<Record<string, string>>;\n readonly observationalBoundIds?: readonly string[];\n}\n\n/** Load a SearchProblem from a JSON file (optionally with inline datasets). @internal */\nexport function loadSearchProblemFromJson(path: string): SearchProblem {\n const raw = readJsonFile(path) as ProblemFile;\n return searchProblemFromFile(raw, path);\n}\n\n/**\n * The observations file a problem file names, resolved against the problem file's directory\n * (the working directory for an inline problem), or null when it names none. @internal\n */\nexport function resolveObservationsPath(raw: Pick<ProblemFile, 'observationsPath'>, source = 'inline'): string | null {\n if (!raw.observationsPath) return null;\n return isAbsolute(raw.observationsPath)\n ? raw.observationsPath\n : resolve(source === 'inline' ? process.cwd() : dirname(source), raw.observationsPath);\n}\n\n/** Build a SearchProblem from an already-parsed problem file. @internal */\nexport function searchProblemFromFile(raw: ProblemFile, source = 'inline'): SearchProblem {\n // `ProblemFile` is what a well-formed file holds; a file read from disk is any JSON value, so\n // each field is checked here before it is read, and a refusal names the field.\n const file: unknown = raw;\n if (!isPlainObject(file)) {\n throw new ProblemFileError(`the top level must be a JSON object with \"target\" and \"governing\" (found ${kindOf(file)})`);\n }\n if (file.target === undefined) throw new ProblemFileError('it has no \"target\" ({\"name\": text, \"dim\": text})');\n if (file.governing === undefined) throw new ProblemFileError('it has no \"governing\" list ([{\"name\": text, \"dim\": text}, ...])');\n if (!Array.isArray(file.governing)) {\n throw new ProblemFileError(`\"governing\" must be a list of {\"name\": text, \"dim\": text} (found ${kindOf(file.governing)})`);\n }\n if (file.gap !== undefined && !isPlainObject(file.gap)) {\n throw new ProblemFileError(`\"gap\" must be an object (found ${kindOf(file.gap)})`);\n }\n for (const field of ['id', 'kind', 'summary'] as const) {\n const v: unknown = raw.gap?.[field];\n if (v !== undefined && typeof v !== 'string') {\n throw new ProblemFileError(`gap.${field} must be text (found ${kindOf(v)})`);\n }\n }\n const kindRaw = raw.gap?.kind ?? 'unexplained-observation';\n if (!isGapKind(kindRaw)) {\n throw new ProblemFileError(`unknown gap kind '${kindRaw}' in gap.kind (see \\`upt help probe\\`, PROBLEM FILE)`);\n }\n if (kindRaw === 'relation-link' || kindRaw === 'regime-transition') {\n throw new ProblemFileError(`gap.kind '${kindRaw}' is a Product A gap: use \\`upt discover\\`, not probe`);\n }\n const gapId = raw.gap?.id ?? 'fg-inline';\n if (!gapId.startsWith('fg-')) {\n throw new ProblemFileError(`gap.id '${gapId}' must start with \"fg-\"`);\n }\n const gap = makeResidualGap(gapId, raw.gap?.summary ?? `search problem from ${source}`, kindRaw);\n const target = varFromJson(raw.target, '\"target\"');\n const governing = raw.governing.map((g, i) => varFromJson(g, `governing[${i}]`));\n let exploratory: ProbeDataset | undefined;\n let holdout: ProbeDataset | undefined;\n if (file.observationsPath !== undefined && typeof file.observationsPath !== 'string') {\n throw new ProblemFileError(`\"observationsPath\" must be text (found ${kindOf(file.observationsPath)})`);\n }\n const observationsPath = resolveObservationsPath(raw, source);\n if (observationsPath !== null) {\n const split = loadSplitDatasetsFromJson(observationsPath);\n exploratory = split.exploratory;\n holdout = split.holdout;\n }\n if (raw.exploratory) {\n exploratory = asDatasetSafe(raw.exploratory, `${source}#exploratory`, 'exploratory-fit');\n }\n if (raw.holdout) {\n holdout = asDatasetSafe(raw.holdout, `${source}#holdout`, 'validation-holdout');\n }\n const problem = problemFromResidualGap(gap, target, governing, exploratory, holdout);\n // The secondary fields. Each was once passed through unread, so `limits: 5` or\n // `assumptions: \"x\"` reached `runProbeSearch` and threw a raw TypeError there.\n return {\n ...problem,\n baseline: file.baseline === undefined ? undefined : assertExprNode(file.baseline, '\"baseline\"'),\n discrepancy: file.discrepancy === undefined ? problem.discrepancy : discrepancyFromJson(file.discrepancy),\n assumptions: file.assumptions === undefined ? gap.assumptions : textList(file.assumptions, 'assumptions'),\n limits: file.limits === undefined ? undefined : limitsFromJson(file.limits),\n claimedRegimes: file.claimedRegimes === undefined ? undefined : textRecord(file.claimedRegimes, 'claimedRegimes'),\n observationalBoundIds:\n file.observationalBoundIds === undefined ? undefined : textList(file.observationalBoundIds, 'observationalBoundIds'),\n };\n}\n\n/** A list of text, located by its field name. */\nfunction textList(raw: unknown, field: string): readonly string[] {\n const label = field.includes('.') ? field : `\"${field}\"`;\n if (!Array.isArray(raw)) throw new ProblemFileError(`${label} must be a list of text (found ${kindOf(raw)})`);\n return raw.map((v, i) => {\n if (typeof v !== 'string') throw new ProblemFileError(`${field}[${i}] must be text (found ${kindOf(v)})`);\n return v;\n });\n}\n\n/** A `{name: text}` object, located by its field name. */\nfunction textRecord(raw: unknown, field: string): Readonly<Record<string, string>> {\n if (!isPlainObject(raw)) throw new ProblemFileError(`\"${field}\" must be {name: text} (found ${kindOf(raw)})`);\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(raw)) {\n if (typeof v !== 'string') throw new ProblemFileError(`${field}.${k} must be text (found ${kindOf(v)})`);\n out[k] = v;\n }\n return out;\n}\n\nfunction discrepancyFromJson(raw: unknown): DiscrepancyDefinition {\n if (!isPlainObject(raw)) throw new ProblemFileError(`\"discrepancy\" must be {\"kind\": text, \"observableIds\": [text]} (found ${kindOf(raw)})`);\n if (typeof raw.kind !== 'string' || !DISCREPANCY_KINDS.has(raw.kind)) {\n throw new ProblemFileError(\n `discrepancy.kind '${String(raw.kind)}' is not a discrepancy kind (${[...DISCREPANCY_KINDS].join(', ')})`,\n );\n }\n const observableIds = textList(raw.observableIds, 'discrepancy.observableIds');\n for (const key of ['covarianceRef', 'implementationRef'] as const) {\n if (raw[key] !== undefined && typeof raw[key] !== 'string') {\n throw new ProblemFileError(`discrepancy.${key} must be text (found ${kindOf(raw[key])})`);\n }\n }\n return {\n kind: raw.kind as DiscrepancyDefinition['kind'],\n observableIds,\n ...(typeof raw.covarianceRef === 'string' ? { covarianceRef: raw.covarianceRef } : {}),\n ...(typeof raw.implementationRef === 'string' ? { implementationRef: raw.implementationRef } : {}),\n };\n}\n\nfunction limitsFromJson(raw: unknown): NonNullable<SearchProblem['limits']> {\n const shape = '{\"id\": text, \"regime\": {name: text}}';\n if (!Array.isArray(raw)) throw new ProblemFileError(`\"limits\" must be a list of ${shape} (found ${kindOf(raw)})`);\n return raw.map((l, i) => {\n if (!isPlainObject(l)) throw new ProblemFileError(`limits[${i}] must be ${shape} (found ${kindOf(l)})`);\n if (typeof l.id !== 'string' || l.id === '') throw new ProblemFileError(`limits[${i}].id must be text`);\n if (!isPlainObject(l.regime)) throw new ProblemFileError(`limits[${i}].regime must be {name: text} (found ${kindOf(l.regime)})`);\n const regime = textRecord(l.regime, `limits[${i}].regime`);\n if (l.description !== undefined && typeof l.description !== 'string') {\n throw new ProblemFileError(`limits[${i}].description must be text (found ${kindOf(l.description)})`);\n }\n return { id: l.id, regime, ...(typeof l.description === 'string' ? { description: l.description } : {}) };\n });\n}\n\n/** The scalar operators an `op` node may carry. */\nconst SCALAR_OPS: ReadonlySet<string> = new Set(['+', '-', '*', '/', '^']);\n/** The `TranscendentalFn` union as a runtime set. */\nconst TRANSCENDENTAL_FNS: ReadonlySet<string> = new Set(['exp', 'ln', 'log2', 'log10', 'sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh']);\n/** A decimal literal, as the validator reads a numeric-literal symbol. */\nconst DECIMAL_LITERAL = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?$/;\nconst DIM_KEYS = ['L', 'M', 'T', 'I', 'Theta', 'N', 'J'] as const;\nconst SCALAR_KINDS = 'symbol, op, integral, derivative, dirac-delta, variational-derivative, transcendental, abs';\n\n/** `raw[field]` as a child node, or a refusal that names the field. */\nfunction child(raw: Record<string, unknown>, field: string, path: string, what: string): ExprNode {\n if (raw[field] === undefined) throw new ProblemFileError(`${path} ${what} node needs ${field === 'args' ? '' : 'an '}\"${field}\" node`);\n return assertExprNode(raw[field], `${path}#${field}`);\n}\n\n/**\n * Check that a JSON value has the shape of a scalar `ExprNode`, recursively:\n * a kind per node, the children each kind owns, a finite literal where a\n * symbol's name is a decimal literal, and the seven dimension exponents on a\n * symbol. A tensor kind is refused here: the probe evaluates scalars.\n * Refusals are {@link ProblemFileError}, located by `path`.\n */\nfunction assertExprNode(raw: unknown, path: string): ExprNode {\n if (!isPlainObject(raw) || !('kind' in raw)) {\n throw new ProblemFileError(`${path} is not an ExprNode JSON object (found ${kindOf(raw)})`);\n }\n const kind = raw.kind;\n if (typeof kind !== 'string' || kind.length === 0) {\n throw new ProblemFileError(`${path} has invalid kind (found ${kindOf(kind)})`);\n }\n switch (kind) {\n case 'symbol': {\n if (typeof raw.name !== 'string' || raw.name.length === 0) {\n throw new ProblemFileError(`${path} symbol node missing name (needs \"name\": text)`);\n }\n if (!isPlainObject(raw.dim)) throw new ProblemFileError(`${path} symbol node missing dim`);\n for (const k of DIM_KEYS) {\n if (!(k in raw.dim)) throw new ProblemFileError(`${path} symbol node dim needs the exponents ${DIM_KEYS.join(', ')}`);\n if (typeof raw.dim[k] !== 'number' || !Number.isFinite(raw.dim[k])) {\n throw new ProblemFileError(`${path} symbol node dim.${k} must be a finite number (found ${kindOf(raw.dim[k])})`);\n }\n }\n if (DECIMAL_LITERAL.test(raw.name) && !Number.isFinite(Number(raw.name))) {\n throw new ProblemFileError(`${path} literal '${raw.name}' is not a finite number`);\n }\n return raw as unknown as ExprNode;\n }\n case 'op': {\n if (typeof raw.op !== 'string' || !Array.isArray(raw.args)) {\n throw new ProblemFileError(`${path} op node needs \"op\" and an \"args\" list (op node missing op/args)`);\n }\n if (!SCALAR_OPS.has(raw.op)) throw new ProblemFileError(`${path} op node has op '${raw.op}', not one of + - * / ^`);\n raw.args.forEach((a, i) => assertExprNode(a, `${path}#args[${i}]`));\n return raw as unknown as ExprNode;\n }\n case 'integral': {\n child(raw, 'over', path, 'integral');\n child(raw, 'integrand', path, 'integral');\n for (const bound of ['lower', 'upper']) if (raw[bound] !== undefined) assertExprNode(raw[bound], `${path}#${bound}`);\n return raw as unknown as ExprNode;\n }\n case 'derivative':\n child(raw, 'of', path, 'derivative');\n child(raw, 'wrt', path, 'derivative');\n return raw as unknown as ExprNode;\n case 'dirac-delta':\n case 'abs':\n child(raw, 'arg', path, kind);\n return raw as unknown as ExprNode;\n case 'variational-derivative':\n for (const f of ['functional', 'field', 'over']) child(raw, f, path, kind);\n return raw as unknown as ExprNode;\n case 'transcendental': {\n if (typeof raw.fn !== 'string' || !TRANSCENDENTAL_FNS.has(raw.fn)) {\n throw new ProblemFileError(`${path} transcendental node has fn '${String(raw.fn)}', not one of ${[...TRANSCENDENTAL_FNS].join(', ')}`);\n }\n child(raw, 'arg', path, kind);\n return raw as unknown as ExprNode;\n }\n default:\n throw new ProblemFileError(`${path} has kind '${kind}', which is not a scalar expression node (${SCALAR_KINDS})`);\n }\n}\n\n/**\n * Load an ExprNode from a JSON file (`{expression}` wrapper or bare node). The node shape is\n * checked recursively; a file that is not an expression raises {@link ProblemFileError}. @internal\n */\nexport function parseExprJson(path: string): ExprNode {\n const raw: unknown = readJsonFile(path);\n if (isPlainObject(raw) && 'kind' in raw) return assertExprNode(raw, path);\n if (isPlainObject(raw) && 'expression' in raw && raw.expression) {\n return assertExprNode(raw.expression, path);\n }\n throw new ProblemFileError(`${path} is not an ExprNode JSON object`);\n}\n"]}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @module composition/probe/residual
|
|
6
6
|
*/
|
|
7
7
|
import type { DiscrepancyDefinition, DiscrepancyKind } from './types.js';
|
|
8
|
+
/** The error that residual evaluation throws, for example on a non-finite value. */
|
|
8
9
|
export declare class ResidualError extends Error {
|
|
9
10
|
constructor(message: string);
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"residual.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/residual.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEzE,qBAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,eAAe,EACrB,KAAK,SAAI,GACR,MAAM,CAyCR;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAClB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,GAAG,EAAE,qBAAqB,EAC1B,KAAK,SAAI,GACR,MAAM,CAMR"}
|
|
1
|
+
{"version":3,"file":"residual.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/residual.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEzE,oFAAoF;AACpF,qBAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,eAAe,EACrB,KAAK,SAAI,GACR,MAAM,CAyCR;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAClB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,GAAG,EAAE,qBAAqB,EAC1B,KAAK,SAAI,GACR,MAAM,CAMR"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @module composition/probe/residual
|
|
6
6
|
*/
|
|
7
7
|
import { norm2 } from '@danielsimonjr/mathts-core';
|
|
8
|
+
/** The error that residual evaluation throws, for example on a non-finite value. */
|
|
8
9
|
export class ResidualError extends Error {
|
|
9
10
|
constructor(message) {
|
|
10
11
|
super(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"residual.js","sourceRoot":"","sources":["../../../src/composition/probe/residual.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnD,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CA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CAAC,CAAC;AACxD,CAAC","sourcesContent":["/**\n * Explicit residual / discrepancy evaluation. Does not replace\n * `residualInSigma` on the confrontation spine.\n *\n * @module composition/probe/residual\n */\n\nimport { norm2 } from '@danielsimonjr/mathts-core';\nimport type { DiscrepancyDefinition, DiscrepancyKind } from './types.js';\n\nexport class ResidualError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ResidualError';\n }\n}\n\n/**\n * Scalar discrepancy. Covariance-standardized with a non-diagonal Σ is\n * unsupported and throws rather than silently using diagonal σ.\n *\n * @internal\n */\nexport function scalarDiscrepancy(\n observed: number,\n predicted: number,\n kind: DiscrepancyKind,\n scale = 1,\n): number {\n if (!Number.isFinite(observed) || !Number.isFinite(predicted)) {\n throw new ResidualError('scalarDiscrepancy: observed and predicted must be finite');\n }\n switch (kind) {\n case 'additive':\n return observed - predicted;\n case 'relative': {\n const s = scale !== 0 && Number.isFinite(scale) ? scale : Math.abs(predicted) || 1;\n return (observed - predicted) / s;\n }\n case 'log-ratio': {\n if (!(observed > 0 && predicted > 0)) {\n throw new ResidualError('log-ratio residual requires positive observed and predicted');\n }\n return Math.log(observed / predicted);\n }\n case 'standardized': {\n if (!(scale > 0 && Number.isFinite(scale))) {\n throw new ResidualError('standardized residual requires positive finite sigma');\n }\n return (observed - predicted) / scale;\n }\n case 'likelihood': {\n if (!(scale > 0)) throw new ResidualError('likelihood residual requires positive sigma');\n const z = (observed - predicted) / scale;\n return 0.5 * z * z + Math.log(scale * Math.sqrt(2 * Math.PI));\n }\n case 'vector':\n case 'tensor':\n case 'distributional':\n case 'operator':\n case 'custom':\n throw new ResidualError(\n `${kind} discrepancy is not implemented on the scalar path — abstain`,\n );\n default: {\n const _never: never = kind;\n return _never;\n }\n }\n}\n\n/**\n * RMSE of a discrepancy over paired samples: core `norm2` of the discrepancies\n * (the scaled, overflow-safe 2-norm) over √n. Empty or unequal-length samples\n * are refused, as before; a non-finite sample still throws from\n * {@link scalarDiscrepancy}. @internal\n */\nexport function rmse(\n observed: readonly number[],\n predicted: readonly number[],\n def: DiscrepancyDefinition,\n scale = 1,\n): number {\n if (observed.length !== predicted.length || observed.length === 0) {\n throw new ResidualError('rmse: nonempty equal-length samples required');\n }\n const residuals = observed.map((o, i) => scalarDiscrepancy(o, predicted[i]!, def.kind, scale));\n return norm2(residuals) / Math.sqrt(residuals.length);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"residual.js","sourceRoot":"","sources":["../../../src/composition/probe/residual.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnD,oFAAoF;AACpF,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,SAAiB,EACjB,IAAqB,EACrB,KAAK,GAAG,CAAC;IAET,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,aAAa,CAAC,0DAA0D,CAAC,CAAC;IACtF,CAAC;IACD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU;YACb,OAAO,QAAQ,GAAG,SAAS,CAAC;QAC9B,KAAK,UAAU,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,KAAK,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACnF,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,KAAK,WAAW,EAAE,CAAC;YACjB,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EAC1B,KAAK,GAAG,CAAC;IAET,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,aAAa,CAAC,8CAA8C,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAE,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC/F,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/**\n * Explicit residual / discrepancy evaluation. Does not replace\n * `residualInSigma` on the confrontation spine.\n *\n * @module composition/probe/residual\n */\n\nimport { norm2 } from '@danielsimonjr/mathts-core';\nimport type { DiscrepancyDefinition, DiscrepancyKind } from './types.js';\n\n/** The error that residual evaluation throws, for example on a non-finite value. */\nexport class ResidualError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ResidualError';\n }\n}\n\n/**\n * Scalar discrepancy. Covariance-standardized with a non-diagonal Σ is\n * unsupported and throws rather than silently using diagonal σ.\n *\n * @internal\n */\nexport function scalarDiscrepancy(\n observed: number,\n predicted: number,\n kind: DiscrepancyKind,\n scale = 1,\n): number {\n if (!Number.isFinite(observed) || !Number.isFinite(predicted)) {\n throw new ResidualError('scalarDiscrepancy: observed and predicted must be finite');\n }\n switch (kind) {\n case 'additive':\n return observed - predicted;\n case 'relative': {\n const s = scale !== 0 && Number.isFinite(scale) ? scale : Math.abs(predicted) || 1;\n return (observed - predicted) / s;\n }\n case 'log-ratio': {\n if (!(observed > 0 && predicted > 0)) {\n throw new ResidualError('log-ratio residual requires positive observed and predicted');\n }\n return Math.log(observed / predicted);\n }\n case 'standardized': {\n if (!(scale > 0 && Number.isFinite(scale))) {\n throw new ResidualError('standardized residual requires positive finite sigma');\n }\n return (observed - predicted) / scale;\n }\n case 'likelihood': {\n if (!(scale > 0)) throw new ResidualError('likelihood residual requires positive sigma');\n const z = (observed - predicted) / scale;\n return 0.5 * z * z + Math.log(scale * Math.sqrt(2 * Math.PI));\n }\n case 'vector':\n case 'tensor':\n case 'distributional':\n case 'operator':\n case 'custom':\n throw new ResidualError(\n `${kind} discrepancy is not implemented on the scalar path — abstain`,\n );\n default: {\n const _never: never = kind;\n return _never;\n }\n }\n}\n\n/**\n * RMSE of a discrepancy over paired samples: core `norm2` of the discrepancies\n * (the scaled, overflow-safe 2-norm) over √n. Empty or unequal-length samples\n * are refused, as before; a non-finite sample still throws from\n * {@link scalarDiscrepancy}. @internal\n */\nexport function rmse(\n observed: readonly number[],\n predicted: readonly number[],\n def: DiscrepancyDefinition,\n scale = 1,\n): number {\n if (observed.length !== predicted.length || observed.length === 0) {\n throw new ResidualError('rmse: nonempty equal-length samples required');\n }\n const residuals = observed.map((o, i) => scalarDiscrepancy(o, predicted[i]!, def.kind, scale));\n return norm2(residuals) / Math.sqrt(residuals.length);\n}\n"]}
|
|
@@ -10,6 +10,7 @@ import type { DiscoveryBackendDescriptor, DiscoveryRunManifest, SearchBudget, Se
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export { captureEnvironment } from '../canonical-json.js';
|
|
13
|
+
/** The inputs from which openManifest builds one discovery run manifest. */
|
|
13
14
|
export interface ManifestDraft {
|
|
14
15
|
readonly runId: string;
|
|
15
16
|
readonly repositoryCommit: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-manifest.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/run-manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAIpB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,CAAC;IACvB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAC;IACpE,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,oBAAoB,CA0BvE;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,UAAU,EAAE,gBAAgB,EAC5B,WAAW,SAA2B,GACrC,oBAAoB,CAEtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-manifest.js","sourceRoot":"","sources":["../../../src/composition/probe/run-manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEzE;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-manifest.js","sourceRoot":"","sources":["../../../src/composition/probe/run-manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAE,mBAAmB,EAAE,qBA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IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAEtC,OAAO,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Discovery-run manifest construction (schema v0).\n *\n * @module composition/probe/run-manifest\n */\n\nimport type {\n DiscoveryBackendDescriptor,\n DiscoveryRunManifest,\n SearchBudget,\n SearchStopReason,\n} from './types.js';\nimport { DEFAULT_HOLDOUT_TOL, DEFAULT_SEARCH_BUDGET, SCHEMA_VERSION } from './types.js';\nimport { captureEnvironment, hashCanonical } from '../canonical-json.js';\n\n/**\n * Capture host environment.\n *\n * @internal\n */\nexport { captureEnvironment } from '../canonical-json.js';\n\n/** The inputs from which openManifest builds one discovery run manifest. */\nexport interface ManifestDraft {\n readonly runId: string;\n readonly repositoryCommit: string;\n readonly problem: unknown;\n readonly datasetHashes?: readonly string[];\n readonly backendDescriptors?: readonly DiscoveryBackendDescriptor[];\n readonly randomSeeds?: Readonly<Record<string, string | number>>;\n readonly tolerances?: Readonly<Record<string, number>>;\n readonly searchBudget?: SearchBudget;\n readonly startedAt?: string;\n}\n\n/** Open a run manifest (completedAt / stopReason filled at close). @internal */\nexport function openManifest(draft: ManifestDraft): DiscoveryRunManifest {\n if (!draft.runId.startsWith('dr-')) {\n throw new RangeError(`openManifest: runId must start with 'dr-' (got '${draft.runId}')`);\n }\n return {\n schemaVersion: SCHEMA_VERSION,\n runId: draft.runId,\n repositoryCommit: draft.repositoryCommit,\n problemHash: hashCanonical(draft.problem),\n datasetHashes: draft.datasetHashes ?? [],\n backendDescriptors: draft.backendDescriptors ?? [\n {\n protocolVersion: '0',\n backendId: 'native',\n backendVersion: SCHEMA_VERSION,\n capabilities: ['grammar-enumerator'],\n deterministic: 'yes',\n },\n ],\n randomSeeds: draft.randomSeeds ?? {},\n tolerances: draft.tolerances ?? { holdoutRmse: DEFAULT_HOLDOUT_TOL },\n environment: captureEnvironment(),\n searchBudget: draft.searchBudget ?? DEFAULT_SEARCH_BUDGET,\n startedAt: draft.startedAt ?? new Date().toISOString(),\n nondeterminism: [],\n };\n}\n\n/** Close a manifest with stop reason and completion time. @internal */\nexport function closeManifest(\n open: DiscoveryRunManifest,\n stopReason: SearchStopReason,\n completedAt = new Date().toISOString(),\n): DiscoveryRunManifest {\n return { ...open, stopReason, completedAt };\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MathTS scalar-search trees as UPT probe candidates (plan task P5).
|
|
3
|
+
*
|
|
4
|
+
* `scalarNodeToExpr` converts a MathTS `ScalarNode` to a UPT `ExprNode`.
|
|
5
|
+
* `dimensionToRational` converts a UPT `Dimension` to the MathTS
|
|
6
|
+
* `SiDimensionVector` that the search's `dimensions` filter reads.
|
|
7
|
+
*
|
|
8
|
+
* @module composition/probe/scalar-search
|
|
9
|
+
*/
|
|
10
|
+
import { type ScalarNode, type ScalarOperator } from '@danielsimonjr/mathts-expression';
|
|
11
|
+
import type { SiDimensionVector } from '@danielsimonjr/mathts-core';
|
|
12
|
+
import type { ExprNode } from '../../dimensional/validator.js';
|
|
13
|
+
import type { Dimension } from '../../dimensional/types.js';
|
|
14
|
+
import type { RawCandidate } from './generator.js';
|
|
15
|
+
import type { SearchProblem } from './types.js';
|
|
16
|
+
/** A MathTS `ScalarNode` as a UPT `ExprNode`; a symbol takes its governing variable's dimension. @throws Error on an unknown symbol or a function with no UPT form. @internal */
|
|
17
|
+
export declare function scalarNodeToExpr(node: ScalarNode, variables: ReadonlyMap<string, Dimension>): ExprNode;
|
|
18
|
+
/** A UPT `Dimension` as a MathTS `SiDimensionVector`, by key in BIPM order `[L, M, T, I, Θ, N, J]`. @throws RangeError on an exponent that does not rationalize. @internal */
|
|
19
|
+
export declare function dimensionToRational(dim: Dimension): SiDimensionVector;
|
|
20
|
+
/** The scalar-search grammar lists a function with no UPT form: a caller error, not an abstention. @internal */
|
|
21
|
+
export declare class UnsupportedScalarFunctionError extends Error {
|
|
22
|
+
constructor(name: string);
|
|
23
|
+
}
|
|
24
|
+
/** Options of the opt-in MathTS scalar search (plan task P5). @internal */
|
|
25
|
+
export interface ProbeScalarSearchOptions {
|
|
26
|
+
/** Seed of the MathTS random stream. */
|
|
27
|
+
readonly seed: number;
|
|
28
|
+
/** Cap on tree evaluations. */
|
|
29
|
+
readonly maxEvaluations: number;
|
|
30
|
+
/** Binary operators of the grammar. */
|
|
31
|
+
readonly binary: readonly ScalarOperator[];
|
|
32
|
+
/** Unary functions of the grammar, by MathTS input name. Default none. */
|
|
33
|
+
readonly unary?: readonly string[];
|
|
34
|
+
/** Largest tree size. Default 7. */
|
|
35
|
+
readonly maxSize?: number;
|
|
36
|
+
}
|
|
37
|
+
/** The `originNote` and the backend id of a scalar-search candidate. @internal */
|
|
38
|
+
export declare const SCALAR_SEARCH_ORIGIN = "mathts-scalar-search";
|
|
39
|
+
/**
|
|
40
|
+
* Runs MathTS `runScalarSearch` over the exploratory rows, structure only (no fitted
|
|
41
|
+
* parameters), and converts each front tree to a raw probe candidate. A front tree with no
|
|
42
|
+
* UPT form is skipped and counted in the note.
|
|
43
|
+
* @throws Error when the grammar lists a function with no UPT form.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export declare function scalarSearchCandidates(problem: SearchProblem, opts: ProbeScalarSearchOptions, budgetMs: number): Promise<{
|
|
47
|
+
readonly raws: readonly RawCandidate[];
|
|
48
|
+
readonly note?: string;
|
|
49
|
+
}>;
|
|
50
|
+
//# sourceMappingURL=scalar-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalar-search.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/scalar-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAY,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG9E,OAAO,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-0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MathTS scalar-search trees as UPT probe candidates (plan task P5).
|
|
3
|
+
*
|
|
4
|
+
* `scalarNodeToExpr` converts a MathTS `ScalarNode` to a UPT `ExprNode`.
|
|
5
|
+
* `dimensionToRational` converts a UPT `Dimension` to the MathTS
|
|
6
|
+
* `SiDimensionVector` that the search's `dimensions` filter reads.
|
|
7
|
+
*
|
|
8
|
+
* @module composition/probe/scalar-search
|
|
9
|
+
*/
|
|
10
|
+
import { SCALAR_FUNCTION_LOWERING, } from '@danielsimonjr/mathts-expression';
|
|
11
|
+
import { runScalarSearch } from '@danielsimonjr/mathts-functions';
|
|
12
|
+
import { rationalize } from '../rational-exponent.js';
|
|
13
|
+
const ZERO_DIMENSION = { L: 0, M: 0, T: 0, I: 0, Theta: 0, N: 0, J: 0 };
|
|
14
|
+
const UPT_TRANSCENDENTAL_NAMES = new Set([
|
|
15
|
+
'exp', 'ln', 'log2', 'log10', 'sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh',
|
|
16
|
+
]);
|
|
17
|
+
function isTranscendentalFn(name) {
|
|
18
|
+
return UPT_TRANSCENDENTAL_NAMES.has(name);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The inverse of MathTS `SCALAR_FUNCTION_LOWERING`, restricted to the UPT
|
|
22
|
+
* transcendental names. The table is not one-to-one (`log` and `log10` both
|
|
23
|
+
* lower to `log10`), so an input name equal to its lowered name wins.
|
|
24
|
+
*/
|
|
25
|
+
const TRANSCENDENTAL_BY_LOWERED = (() => {
|
|
26
|
+
const inverse = new Map();
|
|
27
|
+
for (const [inputName, loweredName] of Object.entries(SCALAR_FUNCTION_LOWERING)) {
|
|
28
|
+
if (!isTranscendentalFn(inputName))
|
|
29
|
+
continue;
|
|
30
|
+
if (!inverse.has(loweredName) || inputName === loweredName)
|
|
31
|
+
inverse.set(loweredName, inputName);
|
|
32
|
+
}
|
|
33
|
+
return inverse;
|
|
34
|
+
})();
|
|
35
|
+
function literal(name) {
|
|
36
|
+
return { kind: 'symbol', name, dim: ZERO_DIMENSION };
|
|
37
|
+
}
|
|
38
|
+
/** A MathTS `ScalarNode` as a UPT `ExprNode`; a symbol takes its governing variable's dimension. @throws Error on an unknown symbol or a function with no UPT form. @internal */
|
|
39
|
+
export function scalarNodeToExpr(node, variables) {
|
|
40
|
+
switch (node.kind) {
|
|
41
|
+
case 'number':
|
|
42
|
+
return literal(String(node.value));
|
|
43
|
+
case 'symbol': {
|
|
44
|
+
const dim = variables.get(node.name);
|
|
45
|
+
if (dim === undefined)
|
|
46
|
+
throw new Error(`scalar search: unknown symbol '${node.name}'`);
|
|
47
|
+
return { kind: 'symbol', name: node.name, dim };
|
|
48
|
+
}
|
|
49
|
+
case 'op':
|
|
50
|
+
return { kind: 'op', op: node.op, args: node.args.map((a) => scalarNodeToExpr(a, variables)) };
|
|
51
|
+
case 'call': {
|
|
52
|
+
const arg = scalarNodeToExpr(node.arg, variables);
|
|
53
|
+
if (node.fn === 'abs')
|
|
54
|
+
return { kind: 'abs', arg };
|
|
55
|
+
if (node.fn === 'sqrt')
|
|
56
|
+
return { kind: 'op', op: '^', args: [arg, literal('0.5')] };
|
|
57
|
+
const fn = TRANSCENDENTAL_BY_LOWERED.get(node.fn);
|
|
58
|
+
if (fn === undefined)
|
|
59
|
+
throw new Error(`scalar search: function '${node.fn}' has no UPT form`);
|
|
60
|
+
return { kind: 'transcendental', fn, arg };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function rationalAxis(axis, value) {
|
|
65
|
+
const f = rationalize(value);
|
|
66
|
+
if (f === undefined)
|
|
67
|
+
throw new RangeError(`scalar search: dimension ${axis} = ${value} is not rational`);
|
|
68
|
+
return f;
|
|
69
|
+
}
|
|
70
|
+
/** A UPT `Dimension` as a MathTS `SiDimensionVector`, by key in BIPM order `[L, M, T, I, Θ, N, J]`. @throws RangeError on an exponent that does not rationalize. @internal */
|
|
71
|
+
export function dimensionToRational(dim) {
|
|
72
|
+
return [
|
|
73
|
+
rationalAxis('L', dim.L),
|
|
74
|
+
rationalAxis('M', dim.M),
|
|
75
|
+
rationalAxis('T', dim.T),
|
|
76
|
+
rationalAxis('I', dim.I),
|
|
77
|
+
rationalAxis('Theta', dim.Theta),
|
|
78
|
+
rationalAxis('N', dim.N),
|
|
79
|
+
rationalAxis('J', dim.J),
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
/** The scalar-search grammar lists a function with no UPT form: a caller error, not an abstention. @internal */
|
|
83
|
+
export class UnsupportedScalarFunctionError extends Error {
|
|
84
|
+
constructor(name) {
|
|
85
|
+
super(`scalar search: function '${name}' has no UPT form`);
|
|
86
|
+
this.name = 'UnsupportedScalarFunctionError';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** The `originNote` and the backend id of a scalar-search candidate. @internal */
|
|
90
|
+
export const SCALAR_SEARCH_ORIGIN = 'mathts-scalar-search';
|
|
91
|
+
/** MathTS input names whose lowered form has a UPT form, read from the same table the converter reads. */
|
|
92
|
+
const UNARY_WITH_UPT_FORM = new Set(Object.entries(SCALAR_FUNCTION_LOWERING)
|
|
93
|
+
.filter(([, lowered]) => TRANSCENDENTAL_BY_LOWERED.has(lowered) || lowered === 'abs' || lowered === 'sqrt')
|
|
94
|
+
.map(([input]) => input));
|
|
95
|
+
function isLoweringKey(name) {
|
|
96
|
+
return Object.prototype.hasOwnProperty.call(SCALAR_FUNCTION_LOWERING, name);
|
|
97
|
+
}
|
|
98
|
+
function loweredName(name) {
|
|
99
|
+
if (!isLoweringKey(name))
|
|
100
|
+
throw new Error(`scalar search: unknown function '${name}'`);
|
|
101
|
+
return SCALAR_FUNCTION_LOWERING[name];
|
|
102
|
+
}
|
|
103
|
+
function column(rows, name) {
|
|
104
|
+
return Float64Array.from(rows, (row) => {
|
|
105
|
+
const v = row[name];
|
|
106
|
+
if (v === undefined)
|
|
107
|
+
throw new RangeError(`scalar search: a row has no '${name}'`);
|
|
108
|
+
return v;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Runs MathTS `runScalarSearch` over the exploratory rows, structure only (no fitted
|
|
113
|
+
* parameters), and converts each front tree to a raw probe candidate. A front tree with no
|
|
114
|
+
* UPT form is skipped and counted in the note.
|
|
115
|
+
* @throws Error when the grammar lists a function with no UPT form.
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
export async function scalarSearchCandidates(problem, opts, budgetMs) {
|
|
119
|
+
const unary = opts.unary ?? [];
|
|
120
|
+
for (const name of unary) {
|
|
121
|
+
if (!UNARY_WITH_UPT_FORM.has(name))
|
|
122
|
+
throw new UnsupportedScalarFunctionError(name);
|
|
123
|
+
}
|
|
124
|
+
const data = problem.exploratory;
|
|
125
|
+
if (data === undefined || data.rows.length === 0) {
|
|
126
|
+
return { raws: [], note: 'scalar search did not run: no exploratory data' };
|
|
127
|
+
}
|
|
128
|
+
const rows = data.rows;
|
|
129
|
+
const names = problem.governing.map((g) => g.name);
|
|
130
|
+
const columns = {};
|
|
131
|
+
for (const name of names)
|
|
132
|
+
columns[name] = column(rows, name);
|
|
133
|
+
const symbols = {};
|
|
134
|
+
for (const g of problem.governing)
|
|
135
|
+
symbols[g.name] = dimensionToRational(g.dim);
|
|
136
|
+
const grammar = {
|
|
137
|
+
variables: names,
|
|
138
|
+
parameters: [],
|
|
139
|
+
binary: opts.binary,
|
|
140
|
+
unary: unary.map(loweredName),
|
|
141
|
+
maxSize: opts.maxSize ?? 7,
|
|
142
|
+
};
|
|
143
|
+
const result = await runScalarSearch({ variables: names, columns, observed: column(rows, data.observable), parameters: [] }, {
|
|
144
|
+
seed: opts.seed,
|
|
145
|
+
grammar,
|
|
146
|
+
maxEvaluations: opts.maxEvaluations,
|
|
147
|
+
signal: AbortSignal.timeout(Math.max(1, Math.floor(budgetMs))),
|
|
148
|
+
dimensions: { symbols, target: dimensionToRational(problem.target.dim) },
|
|
149
|
+
});
|
|
150
|
+
const variables = new Map(problem.governing.map((g) => [g.name, g.dim]));
|
|
151
|
+
const raws = [];
|
|
152
|
+
let skipped = 0;
|
|
153
|
+
for (const entry of result.front) {
|
|
154
|
+
try {
|
|
155
|
+
raws.push({ expression: scalarNodeToExpr(entry.item, variables), monomial: null, originNote: SCALAR_SEARCH_ORIGIN });
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
skipped += 1;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const notes = [];
|
|
162
|
+
if (result.stopReason !== 'max-evaluations') {
|
|
163
|
+
notes.push(`scalar search stopped: ${result.stopReason} after ${result.evaluations} evaluation(s)`);
|
|
164
|
+
}
|
|
165
|
+
if (skipped > 0)
|
|
166
|
+
notes.push(`scalar search: ${skipped} front tree(s) had no UPT form`);
|
|
167
|
+
return notes.length > 0 ? { raws, note: notes.join('; ') } : { raws };
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=scalar-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalar-search.js","sourceRoot":"","sources":["../../../src/composition/probe/scalar-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,wBAAwB,GAIzB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAIlE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,MAAM,cAAc,GAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAEnF,MAAM,wBAAwB,GAAwB,IAAI,GAAG,CAAC;IAC5D,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAA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AmB,EAAE,CAAC;IAChC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,CAAC;QACvH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IACD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,MAAM,CAAC,UAAU,KAAK,iBAAiB,EAAE,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,0BAA0B,MAAM,CAAC,UAAU,UAAU,MAAM,CAAC,WAAW,gBAAgB,CAAC,CAAC;IACtG,CAAC;IACD,IAAI,OAAO,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,OAAO,gCAAgC,CAAC,CAAC;IACvF,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;AACxE,CAAC","sourcesContent":["/**\n * MathTS scalar-search trees as UPT probe candidates (plan task P5).\n *\n * `scalarNodeToExpr` converts a MathTS `ScalarNode` to a UPT `ExprNode`.\n * `dimensionToRational` converts a UPT `Dimension` to the MathTS\n * `SiDimensionVector` that the search's `dimensions` filter reads.\n *\n * @module composition/probe/scalar-search\n */\n\nimport {\n SCALAR_FUNCTION_LOWERING,\n type ScalarGrammar,\n type ScalarNode,\n type ScalarOperator,\n} from '@danielsimonjr/mathts-expression';\nimport type { Fraction, SiDimensionVector } from '@danielsimonjr/mathts-core';\nimport { runScalarSearch } from '@danielsimonjr/mathts-functions';\n\nimport type { ExprNode } from '../../dimensional/validator.js';\nimport type { Dimension } from '../../dimensional/types.js';\nimport { rationalize } from '../rational-exponent.js';\nimport type { RawCandidate } from './generator.js';\nimport type { SearchProblem } from './types.js';\n\ntype TranscendentalFn = Extract<ExprNode, { kind: 'transcendental' }>['fn'];\n\nconst ZERO_DIMENSION: Dimension = { L: 0, M: 0, T: 0, I: 0, Theta: 0, N: 0, J: 0 };\n\nconst UPT_TRANSCENDENTAL_NAMES: ReadonlySet<string> = new Set([\n 'exp', 'ln', 'log2', 'log10', 'sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh',\n]);\n\nfunction isTranscendentalFn(name: string): name is TranscendentalFn {\n return UPT_TRANSCENDENTAL_NAMES.has(name);\n}\n\n/**\n * The inverse of MathTS `SCALAR_FUNCTION_LOWERING`, restricted to the UPT\n * transcendental names. The table is not one-to-one (`log` and `log10` both\n * lower to `log10`), so an input name equal to its lowered name wins.\n */\nconst TRANSCENDENTAL_BY_LOWERED: ReadonlyMap<string, TranscendentalFn> = (() => {\n const inverse = new Map<string, TranscendentalFn>();\n for (const [inputName, loweredName] of Object.entries(SCALAR_FUNCTION_LOWERING)) {\n if (!isTranscendentalFn(inputName)) continue;\n if (!inverse.has(loweredName) || inputName === loweredName) inverse.set(loweredName, inputName);\n }\n return inverse;\n})();\n\nfunction literal(name: string): ExprNode {\n return { kind: 'symbol', name, dim: ZERO_DIMENSION };\n}\n\n/** A MathTS `ScalarNode` as a UPT `ExprNode`; a symbol takes its governing variable's dimension. @throws Error on an unknown symbol or a function with no UPT form. @internal */\nexport function scalarNodeToExpr(\n node: ScalarNode,\n variables: ReadonlyMap<string, Dimension>,\n): ExprNode {\n switch (node.kind) {\n case 'number':\n return literal(String(node.value));\n case 'symbol': {\n const dim = variables.get(node.name);\n if (dim === undefined) throw new Error(`scalar search: unknown symbol '${node.name}'`);\n return { kind: 'symbol', name: node.name, dim };\n }\n case 'op':\n return { kind: 'op', op: node.op, args: node.args.map((a) => scalarNodeToExpr(a, variables)) };\n case 'call': {\n const arg = scalarNodeToExpr(node.arg, variables);\n if (node.fn === 'abs') return { kind: 'abs', arg };\n if (node.fn === 'sqrt') return { kind: 'op', op: '^', args: [arg, literal('0.5')] };\n const fn = TRANSCENDENTAL_BY_LOWERED.get(node.fn);\n if (fn === undefined) throw new Error(`scalar search: function '${node.fn}' has no UPT form`);\n return { kind: 'transcendental', fn, arg };\n }\n }\n}\n\nfunction rationalAxis(axis: string, value: number): Fraction {\n const f = rationalize(value);\n if (f === undefined) throw new RangeError(`scalar search: dimension ${axis} = ${value} is not rational`);\n return f;\n}\n\n/** A UPT `Dimension` as a MathTS `SiDimensionVector`, by key in BIPM order `[L, M, T, I, Θ, N, J]`. @throws RangeError on an exponent that does not rationalize. @internal */\nexport function dimensionToRational(dim: Dimension): SiDimensionVector {\n return [\n rationalAxis('L', dim.L),\n rationalAxis('M', dim.M),\n rationalAxis('T', dim.T),\n rationalAxis('I', dim.I),\n rationalAxis('Theta', dim.Theta),\n rationalAxis('N', dim.N),\n rationalAxis('J', dim.J),\n ];\n}\n\n/** The scalar-search grammar lists a function with no UPT form: a caller error, not an abstention. @internal */\nexport class UnsupportedScalarFunctionError extends Error {\n constructor(name: string) {\n super(`scalar search: function '${name}' has no UPT form`);\n this.name = 'UnsupportedScalarFunctionError';\n }\n}\n\n/** Options of the opt-in MathTS scalar search (plan task P5). @internal */\nexport interface ProbeScalarSearchOptions {\n /** Seed of the MathTS random stream. */\n readonly seed: number;\n /** Cap on tree evaluations. */\n readonly maxEvaluations: number;\n /** Binary operators of the grammar. */\n readonly binary: readonly ScalarOperator[];\n /** Unary functions of the grammar, by MathTS input name. Default none. */\n readonly unary?: readonly string[];\n /** Largest tree size. Default 7. */\n readonly maxSize?: number;\n}\n\n/** The `originNote` and the backend id of a scalar-search candidate. @internal */\nexport const SCALAR_SEARCH_ORIGIN = 'mathts-scalar-search';\n\n/** MathTS input names whose lowered form has a UPT form, read from the same table the converter reads. */\nconst UNARY_WITH_UPT_FORM: ReadonlySet<string> = new Set(\n Object.entries(SCALAR_FUNCTION_LOWERING)\n .filter(([, lowered]) => TRANSCENDENTAL_BY_LOWERED.has(lowered) || lowered === 'abs' || lowered === 'sqrt')\n .map(([input]) => input),\n);\n\ntype LoweredFn = (typeof SCALAR_FUNCTION_LOWERING)[keyof typeof SCALAR_FUNCTION_LOWERING];\n\nfunction isLoweringKey(name: string): name is keyof typeof SCALAR_FUNCTION_LOWERING {\n return Object.prototype.hasOwnProperty.call(SCALAR_FUNCTION_LOWERING, name);\n}\n\nfunction loweredName(name: string): LoweredFn {\n if (!isLoweringKey(name)) throw new Error(`scalar search: unknown function '${name}'`);\n return SCALAR_FUNCTION_LOWERING[name];\n}\n\nfunction column(rows: readonly Readonly<Record<string, number>>[], name: string): Float64Array {\n return Float64Array.from(rows, (row) => {\n const v = row[name];\n if (v === undefined) throw new RangeError(`scalar search: a row has no '${name}'`);\n return v;\n });\n}\n\n/**\n * Runs MathTS `runScalarSearch` over the exploratory rows, structure only (no fitted\n * parameters), and converts each front tree to a raw probe candidate. A front tree with no\n * UPT form is skipped and counted in the note.\n * @throws Error when the grammar lists a function with no UPT form.\n * @internal\n */\nexport async function scalarSearchCandidates(\n problem: SearchProblem,\n opts: ProbeScalarSearchOptions,\n budgetMs: number,\n): Promise<{ readonly raws: readonly RawCandidate[]; readonly note?: string }> {\n const unary = opts.unary ?? [];\n for (const name of unary) {\n if (!UNARY_WITH_UPT_FORM.has(name)) throw new UnsupportedScalarFunctionError(name);\n }\n const data = problem.exploratory;\n if (data === undefined || data.rows.length === 0) {\n return { raws: [], note: 'scalar search did not run: no exploratory data' };\n }\n const rows = data.rows;\n\n const names = problem.governing.map((g) => g.name);\n const columns: Record<string, Float64Array> = {};\n for (const name of names) columns[name] = column(rows, name);\n const symbols: Record<string, SiDimensionVector> = {};\n for (const g of problem.governing) symbols[g.name] = dimensionToRational(g.dim);\n const grammar: ScalarGrammar = {\n variables: names,\n parameters: [],\n binary: opts.binary,\n unary: unary.map(loweredName),\n maxSize: opts.maxSize ?? 7,\n };\n\n const result = await runScalarSearch(\n { variables: names, columns, observed: column(rows, data.observable), parameters: [] },\n {\n seed: opts.seed,\n grammar,\n maxEvaluations: opts.maxEvaluations,\n signal: AbortSignal.timeout(Math.max(1, Math.floor(budgetMs))),\n dimensions: { symbols, target: dimensionToRational(problem.target.dim) },\n },\n );\n\n const variables = new Map(problem.governing.map((g) => [g.name, g.dim]));\n const raws: RawCandidate[] = [];\n let skipped = 0;\n for (const entry of result.front) {\n try {\n raws.push({ expression: scalarNodeToExpr(entry.item, variables), monomial: null, originNote: SCALAR_SEARCH_ORIGIN });\n } catch {\n skipped += 1;\n }\n }\n const notes: string[] = [];\n if (result.stopReason !== 'max-evaluations') {\n notes.push(`scalar search stopped: ${result.stopReason} after ${result.evaluations} evaluation(s)`);\n }\n if (skipped > 0) notes.push(`scalar search: ${skipped} front tree(s) had no UPT form`);\n return notes.length > 0 ? { raws, note: notes.join('; ') } : { raws };\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import type { ProbeCandidateRecord, ScoreVector } from './types.js';
|
|
|
7
7
|
import type { FalsifyResult } from './falsify.js';
|
|
8
8
|
/** Build a score vector. @internal */
|
|
9
9
|
export declare function scoreCandidate(record: ProbeCandidateRecord, empirical?: number, corpusDistance?: number, falsification?: FalsifyResult): ScoreVector;
|
|
10
|
+
/** One probe candidate with its scores and whether it is on the Pareto front. */
|
|
10
11
|
export interface RankedCandidate {
|
|
11
12
|
readonly record: ProbeCandidateRecord;
|
|
12
13
|
readonly scores: ScoreVector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/scoring.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,C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CAAC,GAAG,KAAK;YAAE,OAAO,KAAK,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;YAAE,MAAM,GAAG,IAAI,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AASD,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CACxB,KAAuE;IAEvE,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACZ,GAAG,EAAE;QACL,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CACjB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAClF;KACF,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AACnG,CAAC","sourcesContent":["/**\n * Pareto scoring for probe candidates. Does not touch `VettedCandidate.score`.\n *\n * @module composition/probe/scoring\n */\n\nimport type { ProbeCandidateRecord, ScoreVector } from './types.js';\nimport type { FalsifyResult } from './falsify.js';\n\nfunction clamp01(x: number): number {\n if (!Number.isFinite(x)) return 0;\n return Math.min(1, Math.max(0, x));\n}\n\n/**\n * Robustness is what the falsification batteries recorded: the fraction of\n * the batteries that ran and passed (an `inconclusive` battery did not pass).\n * It is not read from the status label: a survivor awaiting expert review\n * was once scored 1 by its label alone, while two of the five listed\n * batteries could never fail (9.0.0 audit §4 Low). Without a falsification\n * record only the holdout stage is known: 0.7 past the holdout, 0.2 before.\n */\nfunction robustnessOf(record: ProbeCandidateRecord, falsification: FalsifyResult | undefined): number {\n if (falsification !== undefined && falsification.records.length > 0) {\n const passed = falsification.records.filter((r) => r.outcome === 'pass').length;\n return passed / falsification.records.length;\n }\n return record.status === 'heldout-supported' ||\n record.status === 'falsification-survivor' ||\n record.status === 'expert-review-required'\n ? 0.7\n : 0.2;\n}\n\n/** Build a score vector. @internal */\nexport function scoreCandidate(\n record: ProbeCandidateRecord,\n empirical = 0,\n corpusDistance = 1,\n falsification?: FalsifyResult,\n): ScoreVector {\n const parsimony = clamp01(1 / (1 + record.complexity.astNodes / 8));\n const validity = record.fingerprint.dimensionalSignature === 'invalid' ? 0 : 1;\n const robustness = robustnessOf(record, falsification);\n return {\n validity,\n empirical: clamp01(empirical),\n parsimony,\n corpusDistance: clamp01(corpusDistance),\n robustness,\n };\n}\n\nfunction dominates(a: ScoreVector, b: ScoreVector): boolean {\n const keys: (keyof ScoreVector)[] = [\n 'validity',\n 'empirical',\n 'parsimony',\n 'corpusDistance',\n 'robustness',\n ];\n let better = false;\n for (const k of keys) {\n if (a[k] < b[k] - 1e-12) return false;\n if (a[k] > b[k] + 1e-12) better = true;\n }\n return better;\n}\n\n/** One probe candidate with its scores and whether it is on the Pareto front. */\nexport interface RankedCandidate {\n readonly record: ProbeCandidateRecord;\n readonly scores: ScoreVector;\n readonly pareto: boolean;\n}\n\n/** Pareto front (non-dominated) plus the rest, stable by id. @internal */\nexport function rankPareto(\n items: readonly { record: ProbeCandidateRecord; scores: ScoreVector }[],\n): RankedCandidate[] {\n return items\n .map((it) => ({\n ...it,\n pareto: !items.some(\n (other) => other.record.id !== it.record.id && dominates(other.scores, it.scores),\n ),\n }))\n .sort((a, b) => Number(b.pareto) - Number(a.pareto) || a.record.id.localeCompare(b.record.id));\n}\n"]}
|
|
@@ -187,8 +187,8 @@ export declare function studyCsvToRaw(text: string, source?: string): Record<str
|
|
|
187
187
|
/** P(χ²_ν ≥ chi2): the probability of a χ² at least this large if the model and σ are right. @internal */
|
|
188
188
|
export declare function chiSquareSurvival(chi2: number, dof: number): number;
|
|
189
189
|
/**
|
|
190
|
-
* P(χ²_ν ≤ chi2),
|
|
191
|
-
*
|
|
190
|
+
* P(χ²_ν ≤ chi2), MathTS `chiSquaredCDF`. It is direct in the lower tail, where
|
|
191
|
+
* 1 − Q would round a small probability away. @internal
|
|
192
192
|
*/
|
|
193
193
|
export declare function chiSquareCdf(chi2: number, dof: number): number;
|
|
194
194
|
/** P(F_{d1,d2} ≥ f): the probability of an F ratio at least this large if the extra terms explain nothing. @internal */
|