UNPKG

agentjs-core

Version:

A comprehensive agent-based modeling framework with built-in p5.js visualization

140 lines 4.29 kB
/** * SocialInfluence - Social influence propagation system */ import { EventEmitter } from 'eventemitter3'; import type { Agent } from '../agents/Agent'; import type { AgentId, PropertyValue } from '../../types/core'; import { NetworkManager, ConnectionType } from './NetworkManager'; /** Influence propagation configuration */ export interface InfluenceConfig { readonly propagationRate: number; readonly resistanceFactor: number; readonly connectionTypeWeights: { [ConnectionType.SUPPORTIVE]: number; [ConnectionType.EXPLOITATIVE]: number; [ConnectionType.ECONOMIC]: number; }; readonly minInfluenceThreshold: number; readonly maxInfluenceDistance: number; } /** Influence event data */ export interface InfluenceEvent { readonly source: AgentId; readonly target: AgentId; readonly property: string; readonly oldValue: PropertyValue; readonly newValue: PropertyValue; readonly influenceStrength: number; readonly connectionType: ConnectionType; } /** Property influence rule */ export interface InfluenceRule { readonly property: string; readonly influenceType: 'average' | 'majority' | 'strongest' | 'custom'; readonly customFunction?: (current: PropertyValue, influences: Array<{ value: PropertyValue; weight: number; }>) => PropertyValue; readonly resistance?: number; } /** * SocialInfluence - Manages property propagation through social networks * * Features: * - Property value propagation through connections * - Different influence patterns based on connection type * - Configurable resistance to change * - Multiple influence aggregation methods * - Cascade detection and limits * * Educational Context: Models how ideas, behaviors, and * resources spread through social networks, enabling * simulation of opinion dynamics, resource distribution, * and social contagion phenomena. */ export declare class SocialInfluence extends EventEmitter { /** Reference to network manager */ private readonly network; /** Influence configuration */ private config; /** Registered influence rules by property */ private readonly influenceRules; /** Track current influence cascade to prevent infinite loops */ private currentCascade; /** Influence statistics */ private stats; constructor(network: NetworkManager, config?: Partial<InfluenceConfig>); /** * Register an influence rule for a property */ registerInfluenceRule(rule: InfluenceRule): void; /** * Remove influence rule */ removeInfluenceRule(property: string): boolean; /** * Propagate influence from one agent to its network */ propagateInfluence(source: Agent, property: string, agents: Map<AgentId, Agent>): number; /** * Propagate all registered properties through network */ propagateAll(agents: Map<AgentId, Agent>): void; /** * Calculate aggregate influence on an agent */ calculateAggregateInfluence(target: Agent, property: string, agents: Map<AgentId, Agent>): PropertyValue | null; /** * Influence a single agent */ private influenceAgent; /** * Calculate influence weight based on connection */ private calculateInfluenceWeight; /** * Calculate time-based influence factor */ private calculateTimeFactor; /** * Calculate influenced value based on rule type */ private calculateInfluencedValue; /** * Aggregate multiple influences */ private aggregateInfluences; /** * Average influence aggregation */ private averageInfluence; /** * Majority vote influence */ private majorityInfluence; /** * Strongest influence wins */ private strongestInfluence; /** * Check if property should cascade */ private shouldCascade; /** * Get influence statistics */ getStats(): typeof this.stats; /** * Reset statistics */ resetStats(): void; /** * Get current configuration */ getConfig(): InfluenceConfig; /** * Update configuration */ updateConfig(newConfig: Partial<InfluenceConfig>): void; } //# sourceMappingURL=SocialInfluence.d.ts.map