E
- agent typepublic abstract class AgentList<E extends Agent>
extends java.lang.Object
implements java.lang.Iterable<E>, java.io.Serializable, com.anylogic.engine.internal.Child
AgentArrayList
,
Serialized FormModifier and Type | Method and Description |
---|---|
abstract void |
_add(E agent)
This method should not be called by user
Call add_EONAME() method of class containing embedded object
with name EONAME or agent. |
abstract boolean |
_remove(Agent agent)
This method should not be called by user
Call remove_EONAME() method of class containing embedded
object with name EONAME or agent. |
double |
average(java.lang.String fieldName)
Returns the average of (numeric) field values for all agents in
this collection
|
double |
average(java.lang.String fieldName,
java.lang.String triggerFieldName)
Returns the average of (numeric) field values for all agents in
this collection which have
true value of a boolean field
with name triggerFieldName (if specified) |
void |
callCreate(E agent,
int index)
This method is internal and shouldn't be called by user.
|
void |
callCreate(E agent,
int index,
TableInput tableInput)
This method is internal and shouldn't be called by user.
|
void |
callSetupParameters(E agent,
int index)
This method is internal and shouldn't be called by user.
|
void |
callSetupParameters(E agent,
int index,
TableInput tableInput)
This method is internal and shouldn't be called by user.
|
abstract boolean |
contains(java.lang.Object agent)
Returns
true if this agent population contains the
specified element. |
int |
count(java.lang.String triggerFieldName)
Returns the number of agents in this collection which have
true value of a boolean field with name
triggerFieldName |
void |
fillFromTable(TableInput tableInput)
Creates agents from the given table using the parameters mapping configured in AnyLogic, adds to this population
and starts agents.
|
void |
fillFromTable(TableInput tableInput,
java.util.function.BiConsumer<TableInput,E> agentSetupCode,
boolean callCreate,
boolean startAgents)
Creates agents from the given table, sets their parameters and adds to this population.
|
void |
fillFromTable(TableInput tableInput,
java.util.function.BiConsumer<TableInput,E> agentSetupCode,
java.util.function.Function<TableInput,java.lang.Integer> numberOfAgents,
boolean callCreate,
boolean startAgents)
Creates agents from the given table, sets their parameters and adds to this population.
|
java.util.List<E> |
findAll(java.util.function.Predicate<E> condition)
Returns new list with agents from this population
which meet the given condition.
|
E |
findFirst(java.util.function.Predicate<E> condition)
Returns the first agent from this population which meets
the given condition.
|
abstract E |
get(int index)
Returns the agent element at the specified position in this
agent population.
|
Agent |
getEnvironment()
Returns the environment where this agent population belongs to.
|
Agent |
getOwner()
Returns the owner agent that encapsulates this population.
|
double |
getPresentationScaleOnOwnerSpace()
Returns the scale of the agent presentation animation
on its space or
1.0 if space isn't defined
or agent list is empty |
<T> T |
getValueFromTable(java.lang.String columnLabel,
java.lang.Class<T> returnType) |
E |
instantiateAgent(int index)
This method is internal and shouldn't be called by user.
|
abstract boolean |
isEmpty()
Returns
true if this agent population contains no
elements. |
boolean |
isPresentationEnabled()
This method is internal and shouldn't be called by user.
|
abstract java.util.Iterator<E> |
iterator()
Returns an iterator over the agent population.
|
double |
max(java.lang.String fieldName)
Returns the maximum of (numeric) field values for all agents in
this collection
|
double |
max(java.lang.String fieldName,
java.lang.String triggerFieldName)
Returns the maximum of (numeric) field values for all agents in
this collection which have
true value of a boolean field
with name triggerFieldName (if specified) |
double |
min(java.util.Collection<? extends Agent> agents,
java.lang.String fieldName,
java.lang.String triggerFieldName)
Deprecated.
will be removed in the next (7.1+) release,
please use
min(String, String) instead |
double |
min(java.lang.String fieldName)
Returns the minimum of (numeric) field values for all agents in
this collection
|
double |
min(java.lang.String fieldName,
java.lang.String triggerFieldName)
Returns the minimum of (numeric) field values for all agents in
this collection which have
true value of a boolean field
with name triggerFieldName (if specified) |
void |
onChange()
Calls onChange() for all the agents in this
list.
|
E |
random()
Randomly returns one agent from this population
(uses uniform distribution from the Engine) This method runs in linear time This method returns null if the population
is empty |
E |
random(java.util.Random r)
Randomly returns one agent from this population
(ses the specified random number generator to choose the element) This method runs in linear time This method returns null if the population
is empty |
E |
randomExcept(Agent agent)
Randomly returns one agent from this population
except the given agent
(uses uniform distribution from the Engine) This method runs in linear time This method returns null if the population
is empty or contains the only given agent |
E |
randomExcept(java.util.Set<? extends Agent> agents)
Randomly returns one agent from this population
except the given agents
(uses uniform distribution from the Engine) This method runs in linear time multiplied by the complexity of 'contains' check of the given set This method returns null if the population
is empty or all the agents are contained in the given agents set. |
void |
restoreOwner(java.lang.Object owner)
Deprecated.
|
void |
setEnvironment(Agent environment) |
abstract int |
size()
Returns the number of elements in this agent population.
|
java.util.stream.Stream<E> |
stream()
Returns a sequential Stream with this agent population as its source.
|
double |
sum(java.lang.String fieldName)
Returns the sum of (numeric) field values for all agents in this
collection
|
double |
sum(java.lang.String fieldName,
java.lang.String triggerFieldName)
Returns the sum of (numeric) field values for all agents in this
collection which have
true value of a boolean field with
name triggerFieldName (if specified) |
public AgentList(Agent owner)
public Agent getOwner()
@AnyLogicInternalCodegenAPI public abstract void _add(E agent)
add_EONAME()
method of class containing embedded object
with name EONAME or agent.goToPopulation( population )
@AnyLogicInternalCodegenAPI public abstract boolean _remove(Agent agent)
remove_EONAME()
method of class containing embedded
object with name EONAME or agent.goToPopulation( null )
@AnyLogicInternalCodegenAPI public void setEnvironment(Agent environment)
public Agent getEnvironment()
public abstract int size()
Integer.MAX_VALUE
elements, returns Integer.MAX_VALUE
.public abstract boolean isEmpty()
true
if this agent population contains no
elements.true
if this agent population contains no
elementspublic abstract boolean contains(java.lang.Object agent)
true
if this agent population contains the
specified element. More formally, returns true
if and only if
this collection contains at least one element e
such that
(o==null ? e==null : o.equals(e))
.agent
- element whose presence in this agent population is to
be testedtrue
if this agent population contains the
specified elementpublic final E random()
null
if the population
is emptypublic E random(java.util.Random r)
null
if the population
is emptyr
- the random number generator.public E randomExcept(Agent agent)
null
if the population
is empty or contains the only given agent
agent
- agent not to be chosenagent
public E randomExcept(java.util.Set<? extends Agent> agents)
null
if the population
is empty or all the agents are contained in the given agents
set.agents
- agent not to be chosenpublic java.util.List<E> findAll(java.util.function.Predicate<E> condition)
for (Person person : people.findAll( p -> p.age > 20 )) { traceln( person ); } Person person = randomFrom( people.findAll( p -> p.income < 5000 ) );
condition
- the condition to testtrue
value of the given conditionpublic E findFirst(java.util.function.Predicate<E> condition)
Person person = people.findFirst( p -> p.age > 20 );
condition
- the condition to testtrue
value of the given condition, or null
if there is no such agent or the population is empty.public void onChange()
Agent.onChange()
Agent.onChange()
@AnyLogicLegacyAPI public double sum(java.lang.String fieldName, java.lang.String triggerFieldName)
true
value of a boolean field with
name triggerFieldName
(if specified)fieldName
- the name of the field (case-sensitive) to be summed uptriggerFieldName
- the name of the field (case-sensitive) to be checked for
true
when performing additionnull
- in this case all the agents are takenpublic double sum(java.lang.String fieldName)
fieldName
- the name of the field (case-sensitive) to be summed up@AnyLogicLegacyAPI public double average(java.lang.String fieldName, java.lang.String triggerFieldName)
true
value of a boolean field
with name triggerFieldName
(if specified)fieldName
- the name of the field (case-sensitive) to be takentriggerFieldName
- the name of the field (case-sensitive) to be checked for
true
when performing calculationnull
- in this case all the agents are taken0
if there is no suitable agentspublic double average(java.lang.String fieldName)
fieldName
- the name of the field (case-sensitive) to be taken0
if there is no agents@Deprecated public double min(java.util.Collection<? extends Agent> agents, java.lang.String fieldName, java.lang.String triggerFieldName)
min(String, String)
instead@AnyLogicLegacyAPI public double min(java.lang.String fieldName, java.lang.String triggerFieldName)
true
value of a boolean field
with name triggerFieldName
(if specified)fieldName
- the name of the field (case-sensitive) to be takentriggerFieldName
- the name of the field (case-sensitive) to be checked for
true
when performing minimum searchnull
- in this case all the agents are takenpublic double min(java.lang.String fieldName)
fieldName
- the name of the field (case-sensitive) to be taken@AnyLogicLegacyAPI public double max(java.lang.String fieldName, java.lang.String triggerFieldName)
true
value of a boolean field
with name triggerFieldName
(if specified)fieldName
- the name of the field (case-sensitive) to be takentriggerFieldName
- the name of the field (case-sensitive) to be checked for
true
when performing maximum searchnull
- in this case all the agents are takenpublic double max(java.lang.String fieldName)
fieldName
- the name of the field (case-sensitive) to be takenpublic int count(java.lang.String triggerFieldName)
true
value of a boolean field with name
triggerFieldName
triggerFieldName
- the name of the field (case-sensitive) to be checked for
true
when performing calculationnull
- in this case
agents.size()
is returned (i.e. all
the agents are taken)true
value
of a boolean field with name triggerFieldName
@AnyLogicInternalCodegenAPI @Deprecated public final void restoreOwner(java.lang.Object owner)
restoreOwner
in interface com.anylogic.engine.internal.Child
owner
- owner of this object, usually
Agent
,
Experiment
or
ShapeGroup
public abstract java.util.Iterator<E> iterator()
public java.util.stream.Stream<E> stream()
public abstract E get(int index)
index
- index of the element to returnjava.lang.IndexOutOfBoundsException
- if the index is out of range (
index < 0 || index >= size()
)@AnyLogicInternalCodegenAPI public E instantiateAgent(int index)
index
- index of agent in the population@AnyLogicInternalCodegenAPI public void callSetupParameters(E agent, int index)
agent
- the agentindex
- index of agent in the population@AnyLogicInternalCodegenAPI public void callCreate(E agent, int index)
Agent.create()
and performs some other population-related initializations
(if required)agent
- the agentindex
- index of agent in the population@AnyLogicInternalCodegenAPI public void callSetupParameters(E agent, int index, TableInput tableInput)
agent
- the agentindex
- index of agent in the populationtableInput
- TableInput
, if agent is loaded from database, or null
otherwise@AnyLogicInternalCodegenAPI public void callCreate(E agent, int index, TableInput tableInput)
Agent.create()
and performs some other population-related initializations
(if required)agent
- the agentindex
- index of agent in the populationtableInput
- TableInput
, if agent is loaded from database, or null
otherwise@AnyLogicInternalAPI public void fillFromTable(TableInput tableInput)
tableInput
- table input (contains information about table source and columns-to-parameters mapping)@AnyLogicInternalAPI public void fillFromTable(TableInput tableInput, java.util.function.BiConsumer<TableInput,E> agentSetupCode, boolean callCreate, boolean startAgents)
tableInput
- table input (contains information about table source and columns-to-parameters mapping)agentSetupCode
- code to set agent parameters from tablecallCreate
- true
to call Agent.create()
for newly added agents (this will
create internal structure of agent)startAgents
- true
to call Agent.start()
for newly added agents (this will
schedule events, start statecharts etc.) - callCreate
argument is ignored in this case
and assumed to be true
@AnyLogicInternalAPI public void fillFromTable(TableInput tableInput, java.util.function.BiConsumer<TableInput,E> agentSetupCode, java.util.function.Function<TableInput,java.lang.Integer> numberOfAgents, boolean callCreate, boolean startAgents)
tableInput
- table input (contains information about table source and columns-to-parameters mapping)agentSetupCode
- code to set agent parameters from tablenumberOfAgents
- code to obtain number of agents (to be created with the same parameters) from tablecallCreate
- true
to call Agent.create()
for newly added agents (this will
create internal structure of agent)startAgents
- true
to call Agent.start()
for newly added agents (this will
schedule events, start statecharts etc.) - callCreate
argument is ignored in this case
and assumed to be true
@AnyLogicInternalCodegenAPI public <T> T getValueFromTable(java.lang.String columnLabel, java.lang.Class<T> returnType)
@AnyLogicInternalCodegenAPI public double getPresentationScaleOnOwnerSpace()
1.0
if space isn't defined
or agent list is empty@AnyLogicInternalCodegenAPI public boolean isPresentationEnabled()
Copyright © AnyLogic North America, LLC. All Rights Reserved.