agentjs-core
Version:
A comprehensive agent-based modeling framework with built-in p5.js visualization
90 lines • 2.71 kB
TypeScript
import { EventEmitter } from 'eventemitter3';
import type { Agent } from '../core/agents/Agent';
import type { Simulation } from '../core/Simulation';
export interface DataPoint {
timestamp: number;
step: number;
value: number;
metadata?: Record<string, any>;
}
export interface AgentMetrics {
agentId: string;
agentType: string;
properties: Record<string, number>;
position: {
x: number;
y: number;
};
connections: number;
timestamp: number;
}
export interface SimulationMetrics {
timestamp: number;
step: number;
totalAgents: number;
averageAutonomy: number;
averageResources: number;
totalConnections: number;
networkDensity: number;
populationByType: Record<string, number>;
spatialDistribution: {
centerOfMass: {
x: number;
y: number;
};
spread: number;
};
}
export interface DataCollectorConfig {
collectInterval: number;
maxDataPoints: number;
enableAgentTracking: boolean;
enableNetworkMetrics: boolean;
enableSpatialMetrics: boolean;
customMetrics: string[];
}
export declare class DataCollector extends EventEmitter {
private simulation;
private config;
private isCollecting;
private lastCollectionTime;
private _cachedAgents?;
private timeSeriesData;
private agentHistory;
private simulationHistory;
private customData;
constructor(simulation?: Simulation, config?: Partial<DataCollectorConfig>);
private initializeDataSeries;
private setupEventListeners;
private shouldCollectData;
private collectData;
private collectSimulationMetrics;
private calculateSpatialDistribution;
private collectAgentMetrics;
private extractNumericProperties;
private getAgentConnectionCount;
private collectCustomMetrics;
private calculateCustomMetric;
private updateTimeSeries;
private trackAgentCreation;
private trackAgentDestruction;
private cleanupOldData;
startCollection(agents?: Agent[]): void;
stopCollection(): void;
getCachedAgents(): Agent[] | undefined;
reset(): void;
getTimeSeries(seriesName: string): DataPoint[];
getAgentHistory(agentId: string): AgentMetrics[];
getSimulationHistory(): SimulationMetrics[];
getCurrentMetrics(): SimulationMetrics | null;
getAvailableTimeSeries(): string[];
addCustomMetric(name: string, calculator: () => number): void;
getDataSummary(): {
timeSeriesCount: number;
totalDataPoints: number;
trackedAgents: number;
collectionActive: boolean;
lastCollection: number;
};
}
//# sourceMappingURL=DataCollector.d.ts.map