Classes
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 |
Throws:
-
when field is invalid or aggregateArray is wrong type
- Type
- Error
endPeriod()
calls .endPeriod for all agents in the Pool
endTime() → {number}
finds latest period.endTime of all agent in Pool
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() |
next() → {Object}
finds agent from Pool with lowest wakeTime
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. |
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 |
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. |
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
|
||||||||||||||||||||||||
tradeSPec.sellQ |
Array.<number> | the number bought by he corresponding agent in .sellId |
Throws:
-
when accounting identities do not balance or trade invalid
- Type
- Error
wake()
wakes agent in Pool with lowest wakeTime