Class: Pool

Pool()

Pool for managing a collection of agents. Agents may belong to multiple pools.

Constructor

new Pool()

Source:

Classes

Pool

Methods

distribute(field, good, aggregateArray)

distribute an aggregate setting of buyer Values or seller Costs to a pool of sellers, by giving each agent a successive value from the array without replacement
Parameters:
Name Type Description
field string "values" or "costs"
good good name of good for agents inventories.
aggregateArray Array.<number> list of numeric values or costs reflecting the aggregate pool values or costs
Source:
Throws:
when field is invalid or aggregateArray is wrong type
Type
Error

endPeriod()

calls .endPeriod for all agents in the Pool
Source:

endTime() → {number}

finds latest period.endTime of all agent in Pool
Source:
Returns:
max of agents period.endTime
Type
number

initPeriod(param)

calls .initPeriod for all agents in the Pool
Parameters:
Name Type Description
param Object | number passed to each agent's .initPeriod()
Source:

next() → {Object}

finds agent from Pool with lowest wakeTime
Source:
Returns:
Type
Object

push(agent)

Add an agent to the Pool
Parameters:
Name Type Description
agent Object to add to pool. Should be instanceof Agent, including subclasses.
Source:

runAsPromise(untilTime, batch) → {Promise.<Object, Error>}

Repeatedly wake agents in Pool, until simulation time "untilTime" is reached. For a synchronous equivalent, see syncRun(untilTime, limitCalls)
Parameters:
Name Type Description
untilTime number Stop time for this run
batch number Batch size of number of agents to wake up synchronously before surrendering to event loop
Source:
Returns:
returns promise resolving to pool, with caught errors passed to reject handler.
Type
Promise.<Object, Error>

syncRun(untilTime, limitCallsopt)

Repeatedly wake agents in Pool, until simulation time "untilTime" or "limitCalls" agent wake calls are reached. This method runs synchronously. It returns only when finished.
Parameters:
Name Type Attributes Description
untilTime number Stop time for this run
limitCalls number <optional>
Stop run once this number of agent wake up calls have been executed.
Source:

trade(tradeSpec)

adjusts Pool agents inventories, via agent.transfer(), in response to one or more trades
Parameters:
Name Type Description
tradeSpec Object Object providing specifics of trades.
Properties
Name Type Description
bs string 'b' for buy trade, 's' for sell trade. In a buy trade, buyQ, buyId are single element arrays. In a sell trade, sellQ, sellId are single element arrays,
goods string the name of the goods, as stored in agent inventory object
money string the name of money used for payment, as stored in agent inventory object
prices Array.<number> the price of each trade
buyId Array.<number> the agent id of a buyer in a trade
buyQ Array.<number> the number bought by the corresponding agent in .buyId
sellId Array.<number> the agent id of a seller in a trade
tradeSPec.sellQ Array.<number> the number bought by he corresponding agent in .sellId
Source:
Throws:
when accounting identities do not balance or trade invalid
Type
Error

wake()

wakes agent in Pool with lowest wakeTime
Source: