/** * MaxDiff (Best-Worst Scaling) utility module. * * Provides balanced incomplete block design (BIBD) generation for MaxDiff trials, * utility score computation, and top-N filtering with tie handling. */ export interface MaxDiffTrial { trialIndex: number; itemValues: string[]; } export interface MaxDiffTrialAnswer { trialIndex: number; itemValues: string[]; bestValue: string; worstValue: string; } /** * Generate a balanced incomplete block design for MaxDiff trials. * * Guarantees: * - Every item appears in at least one trial (Req 5.1) * - Each item appears approximately equally — difference of at most 1 (Req 14.1) * - Pair co-appearances bounded by ceil(T*K*(K-1) / (S*(S-1))) + 1 (Req 14.2) * - At least ceil(3*S/K) trials for statistical adequacy (Req 5.5) * * @param itemValues Array of surviving item value strings (S items, 3 ≤ S ≤ 7) * @param itemsPerTrial Number of items per trial (K, 3 ≤ K ≤ 5) * @returns Array of MaxDiffTrial objects */ export declare function generateMaxDiffDesign(itemValues: string[], itemsPerTrial: number): MaxDiffTrial[]; /** * Compute utility scores from completed MaxDiff trial answers. * * Formula: (best_count - worst_count) / total_appearances * Normalized to 0–100 scale. * * @param trials Array of completed trial answers * @returns Map of item value → utility score (0–100) */ export declare function computeUtilityScores(trials: MaxDiffTrialAnswer[]): Map; /** * Filter to retain the top N items by descending utility score. * If items are tied at the boundary, all tied items are included * (potentially exceeding N). * * @param utilities Map of item value → utility score * @param topN Number of top items to retain * @returns Array of item values that made the cut */ export declare function filterTopN(utilities: Map, topN: number): string[];