agentjs-core
Version:
A comprehensive agent-based modeling framework with built-in p5.js visualization
124 lines • 3.64 kB
TypeScript
/**
* SequentialScheduler - Sequential activation order scheduler
*/
import { Scheduler } from './Scheduler';
import type { Agent } from '../agents/Agent';
/** Sequential scheduling modes */
export type SequentialMode = 'creation' | 'id' | 'custom';
/** Custom ordering function type */
export type AgentOrderingFunction = (a: Agent, b: Agent) => number;
/**
* SequentialScheduler - Activates agents in deterministic order
*
* Features:
* - Multiple ordering modes (creation time, ID, custom)
* - Consistent activation order for reproducible simulations
* - Custom sorting functions for specialized ordering
* - Reverse order support
* - Performance optimized sorting
*
* Educational Context: Simulates structured environments
* where community members follow predictable patterns,
* such as hierarchical organizations or systematic processes.
*/
export declare class SequentialScheduler extends Scheduler {
/** Scheduling mode */
private mode;
/** Custom ordering function */
private orderingFunction;
/** Whether to reverse the order */
private reversed;
/** Cached agent creation order */
private creationOrderCache;
constructor(mode?: SequentialMode, orderingFunction?: AgentOrderingFunction, reversed?: boolean);
/**
* Get agent activation order (implementing abstract method)
*/
protected getActivationOrder(): ReadonlyArray<Agent>;
/**
* Get scheduler type (implementing abstract method)
*/
protected getSchedulerType(): string;
/**
* Schedule agents in sequential order
*/
schedule(agents: ReadonlyArray<Agent>): ReadonlyArray<Agent>;
/**
* Set scheduling mode
*/
setMode(mode: SequentialMode, orderingFunction?: AgentOrderingFunction): void;
/**
* Get current mode
*/
getMode(): SequentialMode;
/**
* Set reverse order
*/
setReversed(reversed: boolean): void;
/**
* Check if order is reversed
*/
isReversed(): boolean;
/**
* Set custom ordering function
*/
setOrderingFunction(fn: AgentOrderingFunction): void;
/**
* Get scheduler type
*/
getType(): string;
/**
* Get scheduler configuration
*/
getConfiguration(): Record<string, any>;
/**
* Cache agent creation order
*/
cacheCreationOrder(agents: ReadonlyArray<Agent>): void;
/**
* Clear creation order cache
*/
clearCreationOrderCache(): void;
/**
* Sort agents based on current mode
*/
private sortAgents;
/**
* Compare agents by creation order
*/
private compareByCreationOrder;
/**
* Compare agents by ID (lexicographic)
*/
private compareById;
/**
* Create common ordering functions
*/
static createOrderingFunctions(): {
/**
* Order by energy level (highest first)
*/
byEnergyDesc: (a: Agent, b: Agent) => number;
/**
* Order by energy level (lowest first)
*/
byEnergyAsc: (a: Agent, b: Agent) => number;
/**
* Order by distance from origin
*/
byDistanceFromOrigin: (a: Agent, b: Agent) => number;
/**
* Order by agent type (if agents have type property)
*/
byType: (a: Agent, b: Agent) => number;
/**
* Order by creation time
*/
byCreationTime: (a: Agent, b: Agent) => number;
/**
* Random ordering (for sequential scheduler with random element)
*/
byRandom: () => number;
};
}
//# sourceMappingURL=SequentialScheduler.d.ts.map