| | |
| | |
| | |
| | |
| | export type LearningAlgorithm = 'q-learning' | 'sarsa' | 'double-q' | 'actor-critic' | 'ppo' | 'decision-transformer' | 'monte-carlo' | 'td-lambda' | 'dqn'; |
| | export type TaskType = 'agent-routing' | 'error-avoidance' | 'confidence-scoring' | 'trajectory-learning' | 'context-ranking' | 'memory-recall'; |
| | export interface LearningConfig { |
| | algorithm: LearningAlgorithm; |
| | learningRate: number; |
| | discountFactor: number; |
| | epsilon: number; |
| | lambda?: number; |
| | clipRange?: number; |
| | entropyCoef?: number; |
| | sequenceLength?: number; |
| | } |
| | export interface Experience { |
| | state: string; |
| | action: string; |
| | reward: number; |
| | nextState: string; |
| | done: boolean; |
| | timestamp?: number; |
| | } |
| | export interface LearningTrajectory { |
| | experiences: Experience[]; |
| | totalReward: number; |
| | completed: boolean; |
| | } |
| | export interface AlgorithmStats { |
| | algorithm: LearningAlgorithm; |
| | updates: number; |
| | avgReward: number; |
| | convergenceScore: number; |
| | lastUpdate: number; |
| | } |
| | export declare class LearningEngine { |
| | private configs; |
| | private qTables; |
| | private qTables2; |
| | private eligibilityTraces; |
| | private actorWeights; |
| | private criticValues; |
| | private trajectories; |
| | private stats; |
| | private rewardHistory; |
| | constructor(); |
| | |
| | |
| | |
| | configure(task: TaskType, config: Partial<LearningConfig>): void; |
| | |
| | |
| | |
| | getConfig(task: TaskType): LearningConfig; |
| | |
| | |
| | |
| | update(task: TaskType, experience: Experience): number; |
| | |
| | |
| | |
| | getBestAction(task: TaskType, state: string, actions: string[]): { |
| | action: string; |
| | confidence: number; |
| | }; |
| | |
| | |
| | |
| | getActionProbabilities(state: string, actions: string[]): Map<string, number>; |
| | |
| | |
| | |
| | private qLearningUpdate; |
| | |
| | |
| | |
| | |
| | private sarsaUpdate; |
| | |
| | |
| | |
| | |
| | private doubleQUpdate; |
| | |
| | |
| | |
| | private actorCriticUpdate; |
| | |
| | |
| | |
| | private ppoUpdate; |
| | |
| | |
| | |
| | private tdLambdaUpdate; |
| | |
| | |
| | |
| | private monteCarloUpdate; |
| | |
| | |
| | |
| | private decisionTransformerUpdate; |
| | |
| | |
| | |
| | |
| | private dqnUpdate; |
| | private getQTable; |
| | private getQTable2; |
| | private getEligibilityTraces; |
| | private softmaxConfidence; |
| | private addToCurrentTrajectory; |
| | private sampleFromReplay; |
| | private updateStats; |
| | |
| | |
| | |
| | getStats(): Map<LearningAlgorithm, AlgorithmStats>; |
| | |
| | |
| | |
| | getStatsSummary(): { |
| | bestAlgorithm: LearningAlgorithm; |
| | totalUpdates: number; |
| | avgReward: number; |
| | algorithms: AlgorithmStats[]; |
| | }; |
| | |
| | |
| | |
| | export(): { |
| | qTables: Record<string, Record<string, number>>; |
| | qTables2: Record<string, Record<string, number>>; |
| | criticValues: Record<string, number>; |
| | trajectories: LearningTrajectory[]; |
| | stats: Record<string, AlgorithmStats>; |
| | configs: Record<string, LearningConfig>; |
| | rewardHistory: number[]; |
| | }; |
| | |
| | |
| | |
| | import(data: ReturnType<LearningEngine['export']>): void; |
| | |
| | |
| | |
| | clear(): void; |
| | |
| | |
| | |
| | static getAlgorithms(): { |
| | algorithm: LearningAlgorithm; |
| | description: string; |
| | bestFor: string; |
| | }[]; |
| | } |
| | export default LearningEngine; |
| | |