Implement EMBA Specialization Solver web app
Full React+TypeScript app with LP-based optimization engine, drag-and-drop specialization ranking (with touch/arrow support), course selection UI, results dashboard with decision tree, and two optimization modes (maximize-count, priority-order).
This commit is contained in:
36
app/src/workers/decisionTree.worker.ts
Normal file
36
app/src/workers/decisionTree.worker.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { analyzeDecisionTree } from '../solver/decisionTree';
|
||||
import type { OptimizationMode } from '../data/types';
|
||||
import type { SetAnalysis } from '../solver/decisionTree';
|
||||
|
||||
export interface WorkerRequest {
|
||||
pinnedCourseIds: string[];
|
||||
openSetIds: string[];
|
||||
ranking: string[];
|
||||
mode: OptimizationMode;
|
||||
}
|
||||
|
||||
export interface WorkerResponse {
|
||||
type: 'setComplete' | 'allComplete';
|
||||
analysis?: SetAnalysis;
|
||||
analyses?: SetAnalysis[];
|
||||
}
|
||||
|
||||
self.onmessage = (e: MessageEvent<WorkerRequest>) => {
|
||||
const { pinnedCourseIds, openSetIds, ranking, mode } = e.data;
|
||||
|
||||
const analyses = analyzeDecisionTree(
|
||||
pinnedCourseIds,
|
||||
openSetIds,
|
||||
ranking,
|
||||
mode,
|
||||
(analysis) => {
|
||||
// Progressive update: send each set's results as they complete
|
||||
const response: WorkerResponse = { type: 'setComplete', analysis };
|
||||
self.postMessage(response);
|
||||
},
|
||||
);
|
||||
|
||||
// Final result with sorted analyses
|
||||
const response: WorkerResponse = { type: 'allComplete', analyses };
|
||||
self.postMessage(response);
|
||||
};
|
||||
Reference in New Issue
Block a user