agentjs-core
Version:
A comprehensive agent-based modeling framework with built-in p5.js visualization
180 lines • 4.68 kB
TypeScript
import type { Agent } from '../core/agents/Agent';
import type { NetworkManager } from '../core/network/NetworkManager';
import type { Environment } from '../core/environment/Environment';
import type { AgentManager } from '../core/AgentManager';
import { EventEmitter } from 'eventemitter3';
/**
* Advanced network metrics
*/
export interface NetworkMetrics {
clustering: number;
avgPathLength: number;
diameter: number;
density: number;
components: number;
largestComponentSize: number;
degreeDistribution: Map<number, number>;
centralityScores: Map<string, number>;
modularity: number;
assortativity: number;
}
/**
* Advanced spatial metrics
*/
export interface SpatialMetrics {
dispersion: number;
clustering: number;
nearestNeighborIndex: number;
ripleyK: number[];
moranI: number;
giniCoefficient: number;
quadratCounts: number[][];
hotspots: Array<{
x: number;
y: number;
intensity: number;
}>;
convexHullArea: number;
spatialAutocorrelation: number;
}
/**
* Time window configuration
*/
export interface TimeWindowConfig {
windowSize: number;
overlapSize: number;
updateInterval: number;
}
/**
* Enhanced metrics collector with advanced network and spatial analysis
*/
export declare class EnhancedMetrics extends EventEmitter {
private timeSeriesBuffer;
private windowConfig;
private circularBuffers;
private bufferSize;
constructor(windowConfig?: TimeWindowConfig, bufferSize?: number);
/**
* Calculate comprehensive network metrics
*/
calculateNetworkMetrics(networkManager: NetworkManager, agentManager: AgentManager): NetworkMetrics;
/**
* Calculate comprehensive spatial metrics
*/
calculateSpatialMetrics(agents: Agent[], environment: Environment): SpatialMetrics;
/**
* Add time-series data point with circular buffer management
*/
addTimeSeriesPoint(metric: string, value: number, step: number): void;
/**
* Get moving statistics for a metric
*/
getMovingStatistics(metric: string, windowSize?: number): {
mean: number;
std: number;
min: number;
max: number;
trend: number;
} | null;
/**
* Calculate network clustering coefficient
*/
private calculateClusteringCoefficient;
/**
* Find connected components using DFS
*/
private findConnectedComponents;
/**
* Depth-first search helper
*/
private dfs;
/**
* Calculate betweenness centrality
*/
private calculateBetweennessCentrality;
/**
* Breadth-first search for distances
*/
private bfs;
/**
* Calculate path metrics
*/
private calculatePathMetrics;
/**
* Calculate modularity (simplified)
*/
private calculateModularity;
/**
* Calculate assortativity coefficient
*/
private calculateAssortativity;
/**
* Calculate spatial dispersion
*/
private calculateDispersion;
/**
* Calculate spatial clustering using nearest neighbor distances
*/
private calculateSpatialClustering;
/**
* Calculate nearest neighbor index
*/
private calculateNearestNeighborIndex;
/**
* Calculate mean nearest neighbor distance
*/
private calculateMeanNearestNeighborDistance;
/**
* Calculate Ripley's K function
*/
private calculateRipleyK;
/**
* Calculate Moran's I for spatial autocorrelation
*/
private calculateMoranI;
/**
* Calculate spatial Gini coefficient
*/
private calculateSpatialGini;
/**
* Calculate quadrat counts
*/
private calculateQuadratCounts;
/**
* Detect spatial hotspots
*/
private detectHotspots;
/**
* Calculate convex hull area
*/
private calculateConvexHullArea;
/**
* Convex hull using Graham scan
*/
private convexHull;
/**
* Cross product for convex hull
*/
private cross;
/**
* Calculate spatial autocorrelation
*/
private calculateSpatialAutocorrelation;
/**
* Calculate Moran's I for a specific property
*/
private calculatePropertyMoranI;
/**
* Calculate trend from time series data
*/
private calculateTrend;
/**
* Get empty spatial metrics
*/
private getEmptySpatialMetrics;
}
/**
* Factory function for creating enhanced metrics collector
*/
export declare function createEnhancedMetrics(windowConfig?: TimeWindowConfig, bufferSize?: number): EnhancedMetrics;
//# sourceMappingURL=EnhancedMetrics.d.ts.map