ppef 1.0.0 → 1.0.1
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 +172 -0
- package/dist/__tests__/framework-pipeline.integration.test.d.ts +7 -0
- package/dist/__tests__/framework-pipeline.integration.test.d.ts.map +1 -0
- package/dist/__tests__/framework-pipeline.integration.test.js +413 -0
- package/dist/__tests__/framework-pipeline.integration.test.js.map +1 -0
- package/dist/__tests__/registry-executor.integration.test.d.ts +5 -0
- package/dist/__tests__/registry-executor.integration.test.d.ts.map +1 -0
- package/dist/__tests__/registry-executor.integration.test.js +349 -0
- package/dist/__tests__/registry-executor.integration.test.js.map +1 -0
- package/dist/__tests__/test-helpers.d.ts +94 -0
- package/dist/__tests__/test-helpers.d.ts.map +1 -0
- package/dist/__tests__/test-helpers.js +271 -0
- package/dist/__tests__/test-helpers.js.map +1 -0
- package/dist/aggregation/aggregators.d.ts +54 -0
- package/dist/aggregation/aggregators.d.ts.map +1 -0
- package/dist/aggregation/aggregators.js +228 -0
- package/dist/aggregation/aggregators.js.map +1 -0
- package/dist/aggregation/index.d.ts +8 -0
- package/dist/aggregation/index.d.ts.map +1 -0
- package/dist/aggregation/index.js +8 -0
- package/dist/aggregation/index.js.map +1 -0
- package/dist/aggregation/pipeline.d.ts +38 -0
- package/dist/aggregation/pipeline.d.ts.map +1 -0
- package/dist/aggregation/pipeline.js +198 -0
- package/dist/aggregation/pipeline.js.map +1 -0
- package/dist/claims/evaluator.d.ts +33 -0
- package/dist/claims/evaluator.d.ts.map +1 -0
- package/dist/claims/evaluator.js +174 -0
- package/dist/claims/evaluator.js.map +1 -0
- package/dist/claims/index.d.ts +7 -0
- package/dist/claims/index.d.ts.map +1 -0
- package/dist/claims/index.js +7 -0
- package/dist/claims/index.js.map +1 -0
- package/dist/collector/index.d.ts +8 -0
- package/dist/collector/index.d.ts.map +1 -0
- package/dist/collector/index.js +8 -0
- package/dist/collector/index.js.map +1 -0
- package/dist/collector/result-collector.d.ts +159 -0
- package/dist/collector/result-collector.d.ts.map +1 -0
- package/dist/collector/result-collector.js +213 -0
- package/dist/collector/result-collector.js.map +1 -0
- package/dist/collector/schema.d.ts +34 -0
- package/dist/collector/schema.d.ts.map +1 -0
- package/dist/collector/schema.js +145 -0
- package/dist/collector/schema.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-hash-bug.diagnostic.test.d.ts +10 -0
- package/dist/executor/__tests__/checkpoint-hash-bug.diagnostic.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-hash-bug.diagnostic.test.js +122 -0
- package/dist/executor/__tests__/checkpoint-hash-bug.diagnostic.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-manager.integration.test.d.ts +7 -0
- package/dist/executor/__tests__/checkpoint-manager.integration.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-manager.integration.test.js +330 -0
- package/dist/executor/__tests__/checkpoint-manager.integration.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-manager.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/checkpoint-manager.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-manager.unit.test.js +449 -0
- package/dist/executor/__tests__/checkpoint-manager.unit.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.diagnostic.test.d.ts +11 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.diagnostic.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.diagnostic.test.js +224 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.diagnostic.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.unit.test.d.ts +8 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.unit.test.js +164 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.unit.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-storage.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/checkpoint-storage.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-storage.unit.test.js +386 -0
- package/dist/executor/__tests__/checkpoint-storage.unit.test.js.map +1 -0
- package/dist/executor/__tests__/executor.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/executor.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/executor.unit.test.js +134 -0
- package/dist/executor/__tests__/executor.unit.test.js.map +1 -0
- package/dist/executor/__tests__/parallel-checkpoint-merge.integration.test.d.ts +12 -0
- package/dist/executor/__tests__/parallel-checkpoint-merge.integration.test.d.ts.map +1 -0
- package/dist/executor/__tests__/parallel-checkpoint-merge.integration.test.js +196 -0
- package/dist/executor/__tests__/parallel-checkpoint-merge.integration.test.js.map +1 -0
- package/dist/executor/__tests__/parallel-executor.integration.test.d.ts +7 -0
- package/dist/executor/__tests__/parallel-executor.integration.test.d.ts.map +1 -0
- package/dist/executor/__tests__/parallel-executor.integration.test.js +249 -0
- package/dist/executor/__tests__/parallel-executor.integration.test.js.map +1 -0
- package/dist/executor/__tests__/parallel-executor.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/parallel-executor.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/parallel-executor.unit.test.js +203 -0
- package/dist/executor/__tests__/parallel-executor.unit.test.js.map +1 -0
- package/dist/executor/checkpoint-manager.d.ts +231 -0
- package/dist/executor/checkpoint-manager.d.ts.map +1 -0
- package/dist/executor/checkpoint-manager.js +395 -0
- package/dist/executor/checkpoint-manager.js.map +1 -0
- package/dist/executor/checkpoint-storage.d.ts +230 -0
- package/dist/executor/checkpoint-storage.d.ts.map +1 -0
- package/dist/executor/checkpoint-storage.js +370 -0
- package/dist/executor/checkpoint-storage.js.map +1 -0
- package/dist/executor/checkpoint-types.d.ts +48 -0
- package/dist/executor/checkpoint-types.d.ts.map +1 -0
- package/dist/executor/checkpoint-types.js +8 -0
- package/dist/executor/checkpoint-types.js.map +1 -0
- package/dist/executor/executor.d.ts +164 -0
- package/dist/executor/executor.d.ts.map +1 -0
- package/dist/executor/executor.js +408 -0
- package/dist/executor/executor.js.map +1 -0
- package/dist/executor/index.d.ts +11 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +11 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/executor/memory-monitor.d.ts +115 -0
- package/dist/executor/memory-monitor.d.ts.map +1 -0
- package/dist/executor/memory-monitor.js +168 -0
- package/dist/executor/memory-monitor.js.map +1 -0
- package/dist/executor/parallel-executor.d.ts +53 -0
- package/dist/executor/parallel-executor.d.ts.map +1 -0
- package/dist/executor/parallel-executor.js +194 -0
- package/dist/executor/parallel-executor.js.map +1 -0
- package/dist/executor/run-id.d.ts +71 -0
- package/dist/executor/run-id.d.ts.map +1 -0
- package/dist/executor/run-id.js +67 -0
- package/dist/executor/run-id.js.map +1 -0
- package/dist/executor/worker-entry.d.ts +8 -0
- package/dist/executor/worker-entry.d.ts.map +1 -0
- package/dist/executor/worker-entry.js +67 -0
- package/dist/executor/worker-entry.js.map +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/case-registry.d.ts +113 -0
- package/dist/registry/case-registry.d.ts.map +1 -0
- package/dist/registry/case-registry.js +160 -0
- package/dist/registry/case-registry.js.map +1 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +8 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/sut-registry.d.ts +96 -0
- package/dist/registry/sut-registry.d.ts.map +1 -0
- package/dist/registry/sut-registry.js +126 -0
- package/dist/registry/sut-registry.js.map +1 -0
- package/dist/renderers/index.d.ts +10 -0
- package/dist/renderers/index.d.ts.map +1 -0
- package/dist/renderers/index.js +9 -0
- package/dist/renderers/index.js.map +1 -0
- package/dist/renderers/latex-renderer.d.ts +84 -0
- package/dist/renderers/latex-renderer.d.ts.map +1 -0
- package/dist/renderers/latex-renderer.js +208 -0
- package/dist/renderers/latex-renderer.js.map +1 -0
- package/dist/renderers/types.d.ts +106 -0
- package/dist/renderers/types.d.ts.map +1 -0
- package/dist/renderers/types.js +23 -0
- package/dist/renderers/types.js.map +1 -0
- package/dist/robustness/analyzer.d.ts +61 -0
- package/dist/robustness/analyzer.d.ts.map +1 -0
- package/dist/robustness/analyzer.js +191 -0
- package/dist/robustness/analyzer.js.map +1 -0
- package/dist/robustness/index.d.ts +8 -0
- package/dist/robustness/index.d.ts.map +1 -0
- package/dist/robustness/index.js +8 -0
- package/dist/robustness/index.js.map +1 -0
- package/dist/robustness/perturbations.d.ts +46 -0
- package/dist/robustness/perturbations.d.ts.map +1 -0
- package/dist/robustness/perturbations.js +184 -0
- package/dist/robustness/perturbations.js.map +1 -0
- package/dist/statistical/index.d.ts +8 -0
- package/dist/statistical/index.d.ts.map +1 -0
- package/dist/statistical/index.js +8 -0
- package/dist/statistical/index.js.map +1 -0
- package/dist/statistical/mann-whitney-u.d.ts +62 -0
- package/dist/statistical/mann-whitney-u.d.ts.map +1 -0
- package/dist/statistical/mann-whitney-u.js +127 -0
- package/dist/statistical/mann-whitney-u.js.map +1 -0
- package/dist/types/aggregate.d.ts +124 -0
- package/dist/types/aggregate.d.ts.map +1 -0
- package/dist/types/aggregate.js +9 -0
- package/dist/types/aggregate.js.map +1 -0
- package/dist/types/case.d.ts +105 -0
- package/dist/types/case.d.ts.map +1 -0
- package/dist/types/case.js +10 -0
- package/dist/types/case.js.map +1 -0
- package/dist/types/claims.d.ts +122 -0
- package/dist/types/claims.d.ts.map +1 -0
- package/dist/types/claims.js +14 -0
- package/dist/types/claims.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/perturbation.d.ts +105 -0
- package/dist/types/perturbation.d.ts.map +1 -0
- package/dist/types/perturbation.js +9 -0
- package/dist/types/perturbation.js.map +1 -0
- package/dist/types/result.d.ts +150 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +12 -0
- package/dist/types/result.js.map +1 -0
- package/dist/types/sut.d.ts +128 -0
- package/dist/types/sut.d.ts.map +1 -0
- package/dist/types/sut.js +12 -0
- package/dist/types/sut.js.map +1 -0
- package/package.json +283 -7
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Robustness Analyzer
|
|
3
|
+
*
|
|
4
|
+
* Analyzes algorithm robustness under perturbations.
|
|
5
|
+
* Computes variance, stability, and degradation metrics.
|
|
6
|
+
*/
|
|
7
|
+
import { computeSummaryStats } from "../aggregation/aggregators.js";
|
|
8
|
+
/**
|
|
9
|
+
* Analyze robustness of a SUT under perturbation.
|
|
10
|
+
*
|
|
11
|
+
* @param baseResults - Results without perturbation
|
|
12
|
+
* @param perturbedResults - Results with perturbation, keyed by perturbation name
|
|
13
|
+
* @param metric - Metric to analyze
|
|
14
|
+
* @returns Robustness metrics
|
|
15
|
+
*/
|
|
16
|
+
export const analyzeRobustnessForMetric = (baseResults, perturbedResults, metric) => {
|
|
17
|
+
// Extract metric values
|
|
18
|
+
const baseValues = baseResults
|
|
19
|
+
.map((r) => r.metrics.numeric[metric])
|
|
20
|
+
.filter((v) => !Number.isNaN(v));
|
|
21
|
+
const perturbedValues = perturbedResults
|
|
22
|
+
.map((r) => r.metrics.numeric[metric])
|
|
23
|
+
.filter((v) => !Number.isNaN(v));
|
|
24
|
+
if (baseValues.length === 0 || perturbedValues.length === 0) {
|
|
25
|
+
return {
|
|
26
|
+
varianceUnderPerturbation: Number.NaN,
|
|
27
|
+
stdUnderPerturbation: Number.NaN,
|
|
28
|
+
coefficientOfVariation: Number.NaN,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Compute statistics for perturbed results
|
|
32
|
+
// Note: baseStats could be used for relative comparison in future
|
|
33
|
+
const perturbedStats = computeSummaryStats(perturbedValues);
|
|
34
|
+
// Variance under perturbation
|
|
35
|
+
const varianceUnderPerturbation = perturbedStats.std === undefined ? Number.NaN : perturbedStats.std ** 2;
|
|
36
|
+
// Standard deviation
|
|
37
|
+
const stdUnderPerturbation = perturbedStats.std ?? Number.NaN;
|
|
38
|
+
// Coefficient of variation (relative variance)
|
|
39
|
+
const coefficientOfVariation = perturbedStats.mean !== 0 && perturbedStats.std !== undefined
|
|
40
|
+
? perturbedStats.std / Math.abs(perturbedStats.mean)
|
|
41
|
+
: Number.NaN;
|
|
42
|
+
return {
|
|
43
|
+
varianceUnderPerturbation,
|
|
44
|
+
stdUnderPerturbation,
|
|
45
|
+
coefficientOfVariation,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Analyze robustness across multiple perturbation levels.
|
|
50
|
+
*
|
|
51
|
+
* @param results - All results including perturbed ones
|
|
52
|
+
* @param metric - Metric to analyze
|
|
53
|
+
* @param intensityLevels - Perturbation intensity levels
|
|
54
|
+
* @returns Robustness metrics with degradation curve
|
|
55
|
+
*/
|
|
56
|
+
export const analyzeRobustnessWithCurve = (results, metric, intensityLevels) => {
|
|
57
|
+
// Group results by perturbation intensity
|
|
58
|
+
const byIntensity = new Map();
|
|
59
|
+
// Base results (no perturbation)
|
|
60
|
+
const baseResults = results.filter((r) => r.run.config?.perturbationIntensity === undefined);
|
|
61
|
+
byIntensity.set(0, baseResults);
|
|
62
|
+
// Perturbed results
|
|
63
|
+
for (const level of intensityLevels) {
|
|
64
|
+
const levelResults = results.filter((r) => r.run.config?.perturbationIntensity === level);
|
|
65
|
+
if (levelResults.length > 0) {
|
|
66
|
+
byIntensity.set(level, levelResults);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Build degradation curve
|
|
70
|
+
const degradationCurve = [];
|
|
71
|
+
for (const [level, levelResults] of byIntensity) {
|
|
72
|
+
const values = levelResults
|
|
73
|
+
.map((r) => r.metrics.numeric[metric])
|
|
74
|
+
.filter((v) => !Number.isNaN(v));
|
|
75
|
+
if (values.length > 0) {
|
|
76
|
+
const stats = computeSummaryStats(values);
|
|
77
|
+
degradationCurve.push({
|
|
78
|
+
perturbationLevel: level,
|
|
79
|
+
metricValue: stats.mean,
|
|
80
|
+
stdDev: stats.std,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Sort by level
|
|
85
|
+
degradationCurve.sort((a, b) => a.perturbationLevel - b.perturbationLevel);
|
|
86
|
+
// Find breakpoint (significant degradation)
|
|
87
|
+
let breakpoint;
|
|
88
|
+
if (degradationCurve.length >= 2) {
|
|
89
|
+
const baseValue = degradationCurve[0].metricValue;
|
|
90
|
+
for (let index = 1; index < degradationCurve.length; index++) {
|
|
91
|
+
const relativeChange = Math.abs((degradationCurve[index].metricValue - baseValue) / baseValue);
|
|
92
|
+
if (relativeChange > 0.1) {
|
|
93
|
+
// 10% degradation threshold
|
|
94
|
+
breakpoint = degradationCurve[index].perturbationLevel;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Compute overall variance from all perturbed results
|
|
100
|
+
const allPerturbedValues = results
|
|
101
|
+
.filter((r) => r.run.config?.perturbationIntensity !== undefined)
|
|
102
|
+
.map((r) => r.metrics.numeric[metric])
|
|
103
|
+
.filter((v) => !Number.isNaN(v));
|
|
104
|
+
const overallStats = computeSummaryStats(allPerturbedValues);
|
|
105
|
+
return {
|
|
106
|
+
varianceUnderPerturbation: overallStats.std === undefined ? Number.NaN : overallStats.std ** 2,
|
|
107
|
+
stdUnderPerturbation: overallStats.std ?? Number.NaN,
|
|
108
|
+
coefficientOfVariation: overallStats.mean !== 0 && overallStats.std !== undefined
|
|
109
|
+
? overallStats.std / Math.abs(overallStats.mean)
|
|
110
|
+
: Number.NaN,
|
|
111
|
+
degradationCurve,
|
|
112
|
+
breakpoint,
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Compare robustness between two SUTs.
|
|
117
|
+
*
|
|
118
|
+
* @param sutAResults - Results for SUT A (including perturbed)
|
|
119
|
+
* @param sutBResults - Results for SUT B (including perturbed)
|
|
120
|
+
* @param metric - Metric to compare
|
|
121
|
+
* @returns Object with comparison metrics
|
|
122
|
+
*/
|
|
123
|
+
export const compareRobustness = (sutAResults, sutBResults, metric) => {
|
|
124
|
+
const sutAPerturbed = sutAResults.filter((r) => r.run.config?.perturbationIntensity !== undefined);
|
|
125
|
+
const sutBPerturbed = sutBResults.filter((r) => r.run.config?.perturbationIntensity !== undefined);
|
|
126
|
+
const sutABase = sutAResults.filter((r) => r.run.config?.perturbationIntensity === undefined);
|
|
127
|
+
const sutBBase = sutBResults.filter((r) => r.run.config?.perturbationIntensity === undefined);
|
|
128
|
+
const sutARobustness = analyzeRobustnessForMetric(sutABase, sutAPerturbed, metric);
|
|
129
|
+
const sutBRobustness = analyzeRobustnessForMetric(sutBBase, sutBPerturbed, metric);
|
|
130
|
+
const relativeRobustness = sutBRobustness.varianceUnderPerturbation === 0
|
|
131
|
+
? Infinity
|
|
132
|
+
: sutARobustness.varianceUnderPerturbation / sutBRobustness.varianceUnderPerturbation;
|
|
133
|
+
return {
|
|
134
|
+
sutAVariance: sutARobustness.varianceUnderPerturbation,
|
|
135
|
+
sutBVariance: sutBRobustness.varianceUnderPerturbation,
|
|
136
|
+
relativeRobustness,
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Create a full robustness analysis output.
|
|
141
|
+
*
|
|
142
|
+
* @param results - All evaluation results (base and perturbed)
|
|
143
|
+
* @param options - Analysis options
|
|
144
|
+
* @returns Complete robustness analysis output
|
|
145
|
+
*/
|
|
146
|
+
export const createRobustnessAnalysis = (results, options) => {
|
|
147
|
+
const analysisResults = [];
|
|
148
|
+
// Group results by SUT
|
|
149
|
+
const bySut = new Map();
|
|
150
|
+
for (const result of results) {
|
|
151
|
+
const existing = bySut.get(result.run.sut) ?? [];
|
|
152
|
+
existing.push(result);
|
|
153
|
+
bySut.set(result.run.sut, existing);
|
|
154
|
+
}
|
|
155
|
+
// Analyze each SUT for each metric and perturbation
|
|
156
|
+
for (const [sut, sutResults] of bySut) {
|
|
157
|
+
for (const metric of options.metrics) {
|
|
158
|
+
for (const perturbation of options.perturbations) {
|
|
159
|
+
// Filter to this perturbation
|
|
160
|
+
const baseResults = sutResults.filter((r) => !r.run.config?.perturbation);
|
|
161
|
+
const perturbedResults = sutResults.filter((r) => r.run.config?.perturbation === perturbation);
|
|
162
|
+
const robustness = analyzeRobustnessForMetric(baseResults, perturbedResults, metric);
|
|
163
|
+
// Get baseline value
|
|
164
|
+
const baseValues = baseResults.map((r) => r.metrics.numeric[metric]);
|
|
165
|
+
const baselineValue = baseValues.length > 0
|
|
166
|
+
? baseValues.reduce((a, b) => a + b, 0) / baseValues.length
|
|
167
|
+
: Number.NaN;
|
|
168
|
+
analysisResults.push({
|
|
169
|
+
sut,
|
|
170
|
+
perturbation,
|
|
171
|
+
metric,
|
|
172
|
+
robustness,
|
|
173
|
+
baselineValue,
|
|
174
|
+
runCount: perturbedResults.length,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
version: "1.0.0",
|
|
181
|
+
timestamp: new Date().toISOString(),
|
|
182
|
+
results: analysisResults,
|
|
183
|
+
config: {
|
|
184
|
+
perturbations: options.perturbations,
|
|
185
|
+
metrics: options.metrics,
|
|
186
|
+
intensityLevels: options.intensityLevels,
|
|
187
|
+
runsPerLevel: options.runsPerLevel ?? 1,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../../src/robustness/analyzer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mB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AO;QACN,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE;YACP,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,CAAC;SACvC;KACD,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Robustness Module
|
|
3
|
+
*
|
|
4
|
+
* Re-exports perturbations and robustness analysis.
|
|
5
|
+
*/
|
|
6
|
+
export { analyzeRobustnessForMetric, analyzeRobustnessWithCurve, compareRobustness, createRobustnessAnalysis, type RobustnessAnalysisOptions, } from "./analyzer.js";
|
|
7
|
+
export { createPerturbation, edgeRemovalPerturbation, getPerturbation, nodeRemovalPerturbation, PERTURBATIONS, seedShiftPerturbation, weightNoisePerturbation, } from "./perturbations.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/robustness/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,yBAAyB,GAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Robustness Module
|
|
3
|
+
*
|
|
4
|
+
* Re-exports perturbations and robustness analysis.
|
|
5
|
+
*/
|
|
6
|
+
export { analyzeRobustnessForMetric, analyzeRobustnessWithCurve, compareRobustness, createRobustnessAnalysis, } from "./analyzer.js";
|
|
7
|
+
export { createPerturbation, edgeRemovalPerturbation, getPerturbation, nodeRemovalPerturbation, PERTURBATIONS, seedShiftPerturbation, weightNoisePerturbation, } from "./perturbations.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/robustness/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,GAExB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perturbation Implementations
|
|
3
|
+
*
|
|
4
|
+
* Concrete perturbations for robustness analysis.
|
|
5
|
+
* Each perturbation modifies evaluation cases in controlled ways.
|
|
6
|
+
*/
|
|
7
|
+
import type { Perturbation, PerturbationConfig } from "../types/perturbation.js";
|
|
8
|
+
/**
|
|
9
|
+
* Edge removal perturbation.
|
|
10
|
+
* Randomly removes a fraction of edges from the graph.
|
|
11
|
+
*/
|
|
12
|
+
export declare const edgeRemovalPerturbation: Perturbation;
|
|
13
|
+
/**
|
|
14
|
+
* Seed shift perturbation.
|
|
15
|
+
* Shifts seed nodes to their neighbors.
|
|
16
|
+
*/
|
|
17
|
+
export declare const seedShiftPerturbation: Perturbation;
|
|
18
|
+
/**
|
|
19
|
+
* Node removal perturbation.
|
|
20
|
+
* Randomly removes non-seed nodes from the graph.
|
|
21
|
+
*/
|
|
22
|
+
export declare const nodeRemovalPerturbation: Perturbation;
|
|
23
|
+
/**
|
|
24
|
+
* Weight noise perturbation.
|
|
25
|
+
* Adds Gaussian noise to edge weights.
|
|
26
|
+
*/
|
|
27
|
+
export declare const weightNoisePerturbation: Perturbation;
|
|
28
|
+
/**
|
|
29
|
+
* All built-in perturbations.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PERTURBATIONS: Perturbation[];
|
|
32
|
+
/**
|
|
33
|
+
* Get a perturbation by ID.
|
|
34
|
+
*
|
|
35
|
+
* @param id - Perturbation identifier
|
|
36
|
+
* @returns Perturbation or undefined
|
|
37
|
+
*/
|
|
38
|
+
export declare const getPerturbation: (id: string) => Perturbation | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Create a perturbation with custom intensity.
|
|
41
|
+
*
|
|
42
|
+
* @param config - Perturbation configuration
|
|
43
|
+
* @returns Perturbation with configured intensity
|
|
44
|
+
*/
|
|
45
|
+
export declare const createPerturbation: (config: PerturbationConfig) => Perturbation;
|
|
46
|
+
//# sourceMappingURL=perturbations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perturbations.d.ts","sourceRoot":"","sources":["../../src/robustness/perturbations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,YAgDrC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,YA4BnC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,YA+BrC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,YA+BrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,YAAY,EAKvC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,KAAG,YAAY,GAAG,SACrB,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,kBAAkB,KAAG,YAU/D,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perturbation Implementations
|
|
3
|
+
*
|
|
4
|
+
* Concrete perturbations for robustness analysis.
|
|
5
|
+
* Each perturbation modifies evaluation cases in controlled ways.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
/**
|
|
9
|
+
* Edge removal perturbation.
|
|
10
|
+
* Randomly removes a fraction of edges from the graph.
|
|
11
|
+
*/
|
|
12
|
+
export const edgeRemovalPerturbation = {
|
|
13
|
+
id: "edge-removal",
|
|
14
|
+
name: "Edge Removal",
|
|
15
|
+
description: "Randomly remove a fraction of edges",
|
|
16
|
+
type: "structural",
|
|
17
|
+
intensity: 0.1, // Default: remove 10% of edges
|
|
18
|
+
apply(evaluationCase, seed = 42) {
|
|
19
|
+
const intensity = this.intensity ?? 0.1;
|
|
20
|
+
// Note: rng would be used when actually perturbing the graph at load time
|
|
21
|
+
// const rng = new SeededRandom(seed);
|
|
22
|
+
// Create perturbed case ID
|
|
23
|
+
const perturbedId = createHash("sha256")
|
|
24
|
+
.update(`${evaluationCase.caseId}-edge-removal-${intensity}-${seed}`)
|
|
25
|
+
.digest("hex")
|
|
26
|
+
.slice(0, 16);
|
|
27
|
+
// Mark artefacts as perturbed (actual perturbation happens at load time)
|
|
28
|
+
const perturbedArtefacts = (evaluationCase.inputs.artefacts ?? []).map((a) => ({
|
|
29
|
+
...a,
|
|
30
|
+
metadata: {
|
|
31
|
+
...a.metadata,
|
|
32
|
+
perturbation: "edge-removal",
|
|
33
|
+
perturbationIntensity: intensity,
|
|
34
|
+
perturbationSeed: seed,
|
|
35
|
+
},
|
|
36
|
+
}));
|
|
37
|
+
return {
|
|
38
|
+
...evaluationCase,
|
|
39
|
+
caseId: perturbedId,
|
|
40
|
+
name: `${evaluationCase.name ?? "Case"} (${Math.round(intensity * 100)}% edges removed)`,
|
|
41
|
+
inputs: {
|
|
42
|
+
...evaluationCase.inputs,
|
|
43
|
+
summary: {
|
|
44
|
+
...evaluationCase.inputs.summary,
|
|
45
|
+
perturbation: "edge-removal",
|
|
46
|
+
perturbationIntensity: intensity,
|
|
47
|
+
perturbationSeed: seed,
|
|
48
|
+
},
|
|
49
|
+
artefacts: perturbedArtefacts,
|
|
50
|
+
},
|
|
51
|
+
tags: [...(evaluationCase.tags ?? []), "perturbed", "edge-removal"],
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Seed shift perturbation.
|
|
57
|
+
* Shifts seed nodes to their neighbors.
|
|
58
|
+
*/
|
|
59
|
+
export const seedShiftPerturbation = {
|
|
60
|
+
id: "seed-shift",
|
|
61
|
+
name: "Seed Shift",
|
|
62
|
+
description: "Shift seed nodes to random neighbors",
|
|
63
|
+
type: "seed",
|
|
64
|
+
intensity: 1, // Default: shift all seeds
|
|
65
|
+
apply: (evaluationCase, seed = 42) => {
|
|
66
|
+
const perturbedId = createHash("sha256")
|
|
67
|
+
.update(`${evaluationCase.caseId}-seed-shift-${seed}`)
|
|
68
|
+
.digest("hex")
|
|
69
|
+
.slice(0, 16);
|
|
70
|
+
return {
|
|
71
|
+
...evaluationCase,
|
|
72
|
+
caseId: perturbedId,
|
|
73
|
+
name: `${evaluationCase.name ?? "Case"} (seeds shifted)`,
|
|
74
|
+
inputs: {
|
|
75
|
+
...evaluationCase.inputs,
|
|
76
|
+
summary: {
|
|
77
|
+
...evaluationCase.inputs.summary,
|
|
78
|
+
perturbation: "seed-shift",
|
|
79
|
+
perturbationSeed: seed,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
tags: [...(evaluationCase.tags ?? []), "perturbed", "seed-shift"],
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Node removal perturbation.
|
|
88
|
+
* Randomly removes non-seed nodes from the graph.
|
|
89
|
+
*/
|
|
90
|
+
export const nodeRemovalPerturbation = {
|
|
91
|
+
id: "node-removal",
|
|
92
|
+
name: "Node Removal",
|
|
93
|
+
description: "Randomly remove non-seed nodes",
|
|
94
|
+
type: "structural",
|
|
95
|
+
intensity: 0.05, // Default: remove 5% of nodes
|
|
96
|
+
apply(evaluationCase, seed = 42) {
|
|
97
|
+
const intensity = this.intensity ?? 0.05;
|
|
98
|
+
const perturbedId = createHash("sha256")
|
|
99
|
+
.update(`${evaluationCase.caseId}-node-removal-${intensity}-${seed}`)
|
|
100
|
+
.digest("hex")
|
|
101
|
+
.slice(0, 16);
|
|
102
|
+
return {
|
|
103
|
+
...evaluationCase,
|
|
104
|
+
caseId: perturbedId,
|
|
105
|
+
name: `${evaluationCase.name ?? "Case"} (${Math.round(intensity * 100)}% nodes removed)`,
|
|
106
|
+
inputs: {
|
|
107
|
+
...evaluationCase.inputs,
|
|
108
|
+
summary: {
|
|
109
|
+
...evaluationCase.inputs.summary,
|
|
110
|
+
perturbation: "node-removal",
|
|
111
|
+
perturbationIntensity: intensity,
|
|
112
|
+
perturbationSeed: seed,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
tags: [...(evaluationCase.tags ?? []), "perturbed", "node-removal"],
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Weight noise perturbation.
|
|
121
|
+
* Adds Gaussian noise to edge weights.
|
|
122
|
+
*/
|
|
123
|
+
export const weightNoisePerturbation = {
|
|
124
|
+
id: "weight-noise",
|
|
125
|
+
name: "Weight Noise",
|
|
126
|
+
description: "Add Gaussian noise to edge weights",
|
|
127
|
+
type: "noise",
|
|
128
|
+
intensity: 0.1, // Default: 10% noise (std dev as fraction of weight)
|
|
129
|
+
apply(evaluationCase, seed = 42) {
|
|
130
|
+
const intensity = this.intensity ?? 0.1;
|
|
131
|
+
const perturbedId = createHash("sha256")
|
|
132
|
+
.update(`${evaluationCase.caseId}-weight-noise-${intensity}-${seed}`)
|
|
133
|
+
.digest("hex")
|
|
134
|
+
.slice(0, 16);
|
|
135
|
+
return {
|
|
136
|
+
...evaluationCase,
|
|
137
|
+
caseId: perturbedId,
|
|
138
|
+
name: `${evaluationCase.name ?? "Case"} (${Math.round(intensity * 100)}% weight noise)`,
|
|
139
|
+
inputs: {
|
|
140
|
+
...evaluationCase.inputs,
|
|
141
|
+
summary: {
|
|
142
|
+
...evaluationCase.inputs.summary,
|
|
143
|
+
perturbation: "weight-noise",
|
|
144
|
+
perturbationIntensity: intensity,
|
|
145
|
+
perturbationSeed: seed,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
tags: [...(evaluationCase.tags ?? []), "perturbed", "weight-noise"],
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* All built-in perturbations.
|
|
154
|
+
*/
|
|
155
|
+
export const PERTURBATIONS = [
|
|
156
|
+
edgeRemovalPerturbation,
|
|
157
|
+
seedShiftPerturbation,
|
|
158
|
+
nodeRemovalPerturbation,
|
|
159
|
+
weightNoisePerturbation,
|
|
160
|
+
];
|
|
161
|
+
/**
|
|
162
|
+
* Get a perturbation by ID.
|
|
163
|
+
*
|
|
164
|
+
* @param id - Perturbation identifier
|
|
165
|
+
* @returns Perturbation or undefined
|
|
166
|
+
*/
|
|
167
|
+
export const getPerturbation = (id) => PERTURBATIONS.find((p) => p.id === id);
|
|
168
|
+
/**
|
|
169
|
+
* Create a perturbation with custom intensity.
|
|
170
|
+
*
|
|
171
|
+
* @param config - Perturbation configuration
|
|
172
|
+
* @returns Perturbation with configured intensity
|
|
173
|
+
*/
|
|
174
|
+
export const createPerturbation = (config) => {
|
|
175
|
+
const basePerturbation = getPerturbation(config.type);
|
|
176
|
+
if (!basePerturbation) {
|
|
177
|
+
throw new Error(`Unknown perturbation type: ${config.type}`);
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
...basePerturbation,
|
|
181
|
+
intensity: config.intensity,
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingUR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e,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACN,GAAG,gBAAgB;QACnB,SAAS,EAAE,MAAM,CAAC,SAAS;KAC3B,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Statistical Test Utilities
|
|
3
|
+
*
|
|
4
|
+
* Collection of statistical functions for hypothesis testing,
|
|
5
|
+
* effect size calculation, and confidence intervals.
|
|
6
|
+
*/
|
|
7
|
+
export { mannWhitneyUTest, normalCDF, cohensD, confidenceInterval } from "./mann-whitney-u.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/statistical/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Statistical Test Utilities
|
|
3
|
+
*
|
|
4
|
+
* Collection of statistical functions for hypothesis testing,
|
|
5
|
+
* effect size calculation, and confidence intervals.
|
|
6
|
+
*/
|
|
7
|
+
export { mannWhitneyUTest, normalCDF, cohensD, confidenceInterval } from "./mann-whitney-u.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/statistical/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mann-Whitney U Test
|
|
3
|
+
*
|
|
4
|
+
* Statistical test for comparing two independent samples.
|
|
5
|
+
* Tests whether two populations have the same distribution.
|
|
6
|
+
*
|
|
7
|
+
* H0: Both populations have the same distribution
|
|
8
|
+
* H1: Populations have different distributions
|
|
9
|
+
*
|
|
10
|
+
* Returns p-value (smaller = more significant difference)
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Standard normal cumulative distribution function.
|
|
14
|
+
* Uses the Abramowitz and Stegun approximation.
|
|
15
|
+
*
|
|
16
|
+
* @param z - Z-score
|
|
17
|
+
* @returns Cumulative probability from -infinity to z
|
|
18
|
+
*/
|
|
19
|
+
export declare const normalCDF: (z: number) => number;
|
|
20
|
+
/**
|
|
21
|
+
* Mann-Whitney U test for comparing two independent samples.
|
|
22
|
+
*
|
|
23
|
+
* Non-parametric test that does not assume normal distribution.
|
|
24
|
+
* Tests whether two populations have the same distribution.
|
|
25
|
+
*
|
|
26
|
+
* @param sampleA - First sample array
|
|
27
|
+
* @param sampleB - Second sample array
|
|
28
|
+
* @returns Object containing U statistic, p-value, and significance flag
|
|
29
|
+
*/
|
|
30
|
+
export declare const mannWhitneyUTest: (sampleA: number[], sampleB: number[]) => {
|
|
31
|
+
u: number;
|
|
32
|
+
pValue: number;
|
|
33
|
+
significant: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Calculate Cohen's d effect size.
|
|
37
|
+
*
|
|
38
|
+
* Measures the standardized difference between two means.
|
|
39
|
+
*
|
|
40
|
+
* Interpretation:
|
|
41
|
+
* - 0.2: Small effect
|
|
42
|
+
* - 0.5: Medium effect
|
|
43
|
+
* - 0.8: Large effect
|
|
44
|
+
*
|
|
45
|
+
* @param sampleA - First sample array
|
|
46
|
+
* @param sampleB - Second sample array
|
|
47
|
+
* @returns Cohen's d effect size
|
|
48
|
+
*/
|
|
49
|
+
export declare const cohensD: (sampleA: number[], sampleB: number[]) => number;
|
|
50
|
+
/**
|
|
51
|
+
* Calculate confidence interval for a mean.
|
|
52
|
+
*
|
|
53
|
+
* Uses t-distribution approximation (1.96 for 95% CI with large samples).
|
|
54
|
+
*
|
|
55
|
+
* @param values - Sample values
|
|
56
|
+
* @returns Object with lower and upper bounds
|
|
57
|
+
*/
|
|
58
|
+
export declare const confidenceInterval: (values: number[]) => {
|
|
59
|
+
lower: number;
|
|
60
|
+
upper: number;
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=mann-whitney-u.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mann-whitney-u.d.ts","sourceRoot":"","sources":["../../src/statistical/mann-whitney-u.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,KAAG,MAarC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAC5B,SAAS,MAAM,EAAE,EACjB,SAAS,MAAM,EAAE,KACf;IACF,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;CAgDrB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,EAAE,KAAG,MAa9D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAYnF,CAAC"}
|