Problem codes: Agents¶
Agent types, populations and their messages. The list is generated from the codes' own table; the meaning is the table's sentence for the code.
| Code | Severity | Meaning | About |
|---|---|---|---|
E_AGENT_ACTION |
error | An action is not exactly one of set {target, expr}, send {send, to, payload?}, enter {enter, e_type?}, transfer {transfer, amount, mode?}, signal {signal}, move_to {move_to}, spawn {spawn, count?, state?, init?}, remove {remove}, step {step: [dx, dy]}, move_random {move_random: "any"|"free"}, forward {forward: <distance>}, turn {turn: <degrees>}, face {face: <target>}, random_walk {random_walk: {step, turn_sd?}} or python {python: <function>}; a set target is neither self.<declared attribute> nor a declared variable, an enter names no block an entity can enter, move_to needs a space the type does not declare, a grid move_to/step is not in whole cells, or forward/turn/face/random_walk is used on a type without a continuous space. On screen: "Agent type {agent}: {where}: action is not valid" | -- |
E_AGENT_ATTRIBUTE |
error | An attribute or parameter name is invalid or duplicate, an attribute is named "heading" (a read-only built-in on a continuous space), a parameter is not a number, or an expression reads an undeclared self.<attribute> -- self.heading included, on a type with no continuous space. On screen: "{who}: the recipient has no attribute {attr}" / "{who}: the sender has no attribute {attr}" / "Population {population}: attribute {attr} needs a table with one row per agent" / "Population {population}: attribute {attr} has an unknown column" / "Population {population}: cannot colour by {attr}, it is not a category" / "Agent type {agent}: parameters must be names with numbers" / "Agent type {agent}: parameter {parameter} must be a name with a number" / "Agent type {agent}: attribute {attr} has a reserved or repeated name" / "Agent type {agent}: attribute {attr} must be a number or category" / "Agent type {agent}: attribute {attr} needs at least 2 distinct categories" / "Agent type {agent}: attribute {attr} has an invalid start value" / "Agent type {agent}: attribute {attr}: start value is not a category" / "Agent type {agent}: {where}: {attr} is not an attribute" / "Agent type {agent}: {where}: {population} agents have no attribute {attr}" / "Agent type {agent}: {where}: spawned agent has no attribute {attr}" | -- |
E_AGENT_EXPRESSION |
error | An agent type's expression (attribute init, timeout, rate, condition, guard, action, speed, a send's where) does not compile, or reads payload outside a message transition's guard and actions. On screen: "{who}: the recipient condition cannot be read" / "{who}: a recipient condition cannot draw or use entities" / "Agent type {agent}: {where}: expression cannot be read" / "Agent type {agent}: {where}: agents have no entity" / "Agent type {agent}: {where}: a condition cannot draw random numbers" |
-- |
E_AGENT_GRID |
error | PATCH/NEIGHBOURS/NEIGHBOUR_SUM/NEIGHBOUR_MEAN/CELL_COUNT, a step or move_random action, or a patch.<name> set is used in an agent type without a grid space. On screen: "Agent type {agent}: {where}: needs a grid space" | -- |
E_AGENT_NETWORK |
error | A population's network is not {kind: none|random|small_world|scale_free|table, directed?, link_on_spawn?} with its kind's own keys: random exactly one of p in [0, 1] or mean_degree in [0, count - 1]; small_world an even k >= 2 below count and beta in [0, 1]; scale_free an integer m >= 1 below count; table a model table with numeric "from"/"to" columns; small_world/scale_free undirected. On screen: "Population {population}: network is not valid" | network |
E_AGENT_PATCH |
error | A grid patch is not {name, init?, diffuse?, evaporate?, grow?} with a unique identifier name, diffuse/evaporate is not in [0, 1], grow is not {rate >= 0, max?}, its init is not a number or an agent-free expression of cx, cy, patch_tick is not > 0 or missing while a patch diffuses, evaporates or grows, or PATCH("name") / patch.<name> names an undeclared patch. On screen: "Agent type {agent}: patch setting is not valid" / "Agent type {agent}: {where}: no patch named {patch}" | -- |
E_AGENT_PLACEMENT |
error | A population's placement.kind is not "random"/"table", or a table placement's points/nodes list is missing, empty or malformed (on a grid: cells [cx, cy] inside it, and no bounds). On screen: "Population {population}: placement must be random or a table" / "Population {population}: on a grid, placement is random or cells" / "Population {population}: a table placement needs a {key} list" / "Population {population}: bounds must be four numbers" | -- |
E_AGENT_PYTHON |
error | An agent type's python is not a string of top-level def statements that parses, uses a refused construct (import, global, class, yield, with, a _-prefixed name, an attribute outside the agent/api views, math and plain list/dict/str methods), or a {python: <function>} action names no top-level def taking exactly (agent, api). Checked without running anything; running it needs the caller's consent (NAGASIM_ALLOW_AGENT_PYTHON=1). On screen: "Agent type {agent}: python code is not valid" / "Agent type {agent}: {where}: python function {function} is not usable" | -- |
E_AGENT_RATE_FORM |
error | A rate is not shared (no self), own (self, parameters, constants) or a product of the two (a factor mixes self with shared state), or it varies continuously with time (a bare TNOW, RAMP, a linear TS). On screen: "Agent type {agent}: {where}: rate changes continuously with time" / "Agent type {agent}: {where}: rate has an unsupported form" | -- |
E_AGENT_SPACE |
error | An agent type's space.kind is not "continuous"/"network"/"grid", a continuous space has no valid bounds or its edge is not "none"/"clamp"/"wrap"/"bounce", a network space's model declares no network nodes, or a grid's size/cell/torus/neighbourhood is invalid. On screen: "Agent type {agent}: space kind is not valid" / "Agent type {agent}: grid space settings are not valid" / "Agent type {agent}: continuous space bounds are not valid" / "Agent type {agent}: space edge setting is not valid" / "Agent type {agent}: a network space needs network nodes" | -- |
E_AGENT_STATE |
error | An agent type has no states or a duplicate state, or an initial state, a transition end or a population's initial state is not declared. On screen: "Population {population}: unknown state {state}" / "Agent type {agent}: state {state} has unknown parent {parent}" / "Agent type {agent}: state {state} is its own ancestor" / "Agent type {agent}: state {state}: initial is not one of its children" / "Agent type {agent}: a state name is empty or repeated" / "Agent type {agent}: no states" / "Agent type {agent}: initial state {state} is not declared" / "Agent type {agent}: {where}: unknown state {state}" / "Agent type {agent}: {where}: spawned agent has no state {state}" | -- |
E_AGENT_TICK |
error | A tick is not {dt, activation?, phase?}, its dt is not a number > 0, its activation is not synchronous/random/sequential, its phase is not in [0, dt), or a population whose type has on_tick actions or "tick" transitions has no tick dt (on the type or the population), or a let is not {name: expression} with new identifier names. On screen: "{who}: the tick setting is malformed" / "{who}: tick step must be above 0" / "{who}: tick activation order is not valid" / "{who}: tick phase must be 0 or more" / "Population {population}: a tick step is missing" / "Population {population}: tick phase must be below the step" / "Agent type {agent}: local values must map names to expressions" / "Agent type {agent}: local value {name} is not valid" | -- |
E_AGENT_TRANSITION |
error | A transition does not have exactly one trigger among timeout, rate, condition, message and tick, its message is not a name, its tick is not a condition string, or its scan is not a number > 0. On screen: "Agent type {agent}: {where}: re-check interval must be above 0" / "Agent type {agent}: {where}: history is invalid or has no composite target" / "Agent type {agent}: {where}: needs exactly one trigger" / "Agent type {agent}: {where}: tick needs a condition" / "Agent type {agent}: {where}: message must be a name" | -- |
E_AGENT_TYPE_NAME |
error | An agent type has an empty or duplicate name. On screen: "An agent type name is empty or repeated" | agent_types |
E_AGGREGATE_AGENTS |
error | A two- or three-argument SUM/MEAN (the agent aggregate over a population's attribute, optionally in one state) does not name its population, attribute and state as string literals. On screen: "{block}: {name}() needs literal population and attribute names" | -- |
E_POPULATION_COUNT |
error | A population's count is not an integer >= 0, its initial states place more agents than it has, or its max_count is not an integer >= count. On screen: "Population {population}: count is not valid" / "Population {population}: count must be 0 or more, or a table" / "Population {population}: initial states must be a list" / "Population {population}: an initial count must be 0 or more" / "Population {population}: initial states place {placed} agents, not {resolved}" / "Population {population}: max count must be at least the count" | populations |
E_POPULATION_FULL |
error | At run time: a spawn found its population at max_count; the run stops with an ExpressionError whose message starts with this code. | populations |
E_POPULATION_NAME |
error | A population has an empty or duplicate name. On screen: "A population name is empty or repeated" | populations |
E_POPULATION_TYPE |
error | A population names an undeclared agent type. On screen: "Population {population}: unknown agent type {agent}" | populations |
E_POPULATION_UNKNOWN |
error | COUNT/SUM/MEAN/AGENT, a send's to, a spawn or a remove target names an undeclared population. On screen: "{who}: unknown population {population}" / "Agent type {agent}: {where}: unknown population {population}" / "Block {block}: unknown population {population}" / "{block}: no population named {name}" |
populations |
E_SEND_TARGET |
error | A send action's or SEND block's to (or a remove action's target) is malformed: not "self" (agents only), an index, an agent expression or {population, where?, random?}; or a SEND block in a model without populations. On screen: "{who}: links only works inside an agent type" / "{who}: the send target is malformed" / "{who}: self only works inside an agent type" / "{who}: a block cannot send to an agent number" / "Block {block}: the model has no populations" |
SEND |
W_AGENT_MESSAGE_UNUSED |
warning | A message transition waits for a name that no send action or SEND block sends. On screen: "{who}: nothing sends message {message}" | SEND |
W_AGENT_SCAN |
warning | A rate or condition reads model state that moves outside the agents (LEVEL, AUX, NQ, a bare TNOW, ...) and has no "scan": it is re-evaluated only at agent events. On screen: "Agent type {agent}: {where}: re-checked only at agent events" | -- |
W_AGENT_STATE_COMPOSITE |
warning | An expression compares self.state with a composite state's name: self.state is the leaf, so the comparison is never true. On screen: "Agent type {agent}: {where}: {state} is composite, never the current state" | -- |
How to fix¶
Each code with the usual remedy:
E_AGENT_ACTION: Rewrite the action in the agent type with exactly one action key and its own fields, as the message names. Asettarget must beself.plus a declared attribute or a declared variable, and movement actions need the matchingspace.E_AGENT_ATTRIBUTE: Give each agent attribute and parameter a unique valid name, make every parameter a number, and declare anyself.<name>an expression reads. Do not name an attributeheading.E_AGENT_EXPRESSION: Rewrite the agent type's expression so it compiles, reading onlyself.attributes, the type's parameters, model variables,TNOWand built-in functions. Readpayloadonly in a message transition, neverentity, and draw no random numbers in acondition.E_AGENT_GRID: Give the agent type a grid space, such as"space": {"kind": "grid", "size": [50, 50]}, or remove the grid functions,stepormove_randomactions andpatch.writes.E_AGENT_NETWORK: Fix the population'snetworkto the keys itskindtakes:pormean_degreeforrandom, an evenkandbetaforsmall_world,mforscale_free, a table with numericfromandtocolumns fortable.E_AGENT_PATCH: Fix the patch under the grid space: a unique identifiername,diffuseandevaporatein [0, 1],growas{rate, max}, andpatch_tickabove 0 when it changes. Read only declared patches withPATCH.E_AGENT_PLACEMENT: Set the population'splacement.kindtorandomortable. A table placement needs a non-empty list of points or nodes; on a grid, cells[cx, cy]inside it and nobounds.E_AGENT_PYTHON: Make the agent type'spythontop-leveldefstatements without imports, globals, classes,yield,withor underscore names. Each{python: ...}action must name a defined function taking(agent, api).E_AGENT_RATE_FORM: Write the rate as an own part (self, parameters, constants) times a shared part, with no factor mixing both. Express time dependence withSTEP,PULSEor a step time series, not a bareTNOW.E_AGENT_SPACE: Fix the agent type'sspace:kindiscontinuous,networkorgrid. A continuous space needsbounds[x0, y0, x1, y1]; a grid needs a validsize; a network space needs nodes in the model'snetworksection.E_AGENT_STATE: Declare the agent type's states, and make the initial state and every transition end one of them. A population's initial states must also be declared.E_AGENT_TICK: Writetickas{"dt": 1, "activation": "synchronous"}withdtabove 0 andphasebelowdt. Give a tick to any population whose type hason_tickactions orticktransitions, and giveletnew identifier names.E_AGENT_TRANSITION: Give the transition exactly one trigger amongtimeout,rate,condition,messageandtick. Amessagemust be a name, aticka condition string, andscana number above 0.E_AGENT_TYPE_NAME: Give every entry inagent_typesa non-emptynamethat no other agent type uses.E_AGGREGATE_AGENTS: Write the agent aggregate with quoted literal names, for exampleSUM("People", "age")orMEAN("People", "age", "Sick"). For the system-dynamics form useSUM(LEVEL("x[*]")).E_POPULATION_COUNT: Set the population'scountto an integer of 0 or more (or a table count), keep theinitialstate counts within it, and makemax_countan integer at leastcount.E_POPULATION_FULL: Raise the population'smax_count, or make the agent type'sspawnactions create fewer agents. The run stops when a spawn finds the population already atmax_count.E_POPULATION_NAME: Give every entry inpopulationsa non-emptynamethat no other population uses.E_POPULATION_TYPE: Set the population'stypeto the name of an agent type declared underagent_types, or declare that type. The hint lists the declared types.E_POPULATION_UNKNOWN: Correct the population name in theCOUNT,SUM,MEANorAGENTcall, or in the send, spawn or remove action, or declare that population underpopulations.E_SEND_TARGET: Writetoasentity.agent, anAGENT("Pop", i)expression, or an object with apopulation. A SEND block needs a model that declares at least one population.W_AGENT_MESSAGE_UNUSED: Add asendaction or a SEND block that sends this message, or remove the transition that waits for it. Check the spelling: message names must match exactly.W_AGENT_SCAN: Add"scan": 0.5(any interval above 0) to the transition so it is re-checked on that grid. If re-evaluating only at agent events is intended, the warning can stay.W_AGENT_STATE_COMPOSITE: Compareself.statewith one of the composite state's leaf states, or count the group withCOUNT("Population", "Composite").self.statealways holds the leaf.