read_agent_file¶
Syntax¶
Parameters¶
filename- The name of the input file containing agent IDs and any additional properties, surrounded by quotes.
Returns¶
Optionally returns a list of agents that were updated.
Description¶
Read and internally store a list of agents and their properties from a file.
This is an action enables reading and assigning agent properties to individual agents based off of the contents of an input csv file.
The syntax of the input file is expected to have column headers matching existing agent variables so that the values in subsequent rows can be assigned. A column with an "ID" column header can be used to specify which specific agents these properties are to be applied.
If the "ID" header is omitted, the ID field will be generated. There are no guarantees that the generated ID will not collide with an existing ID.
An error occurs if the file is not found.
Examples¶
agents.txt
main.fred
simulation {
locations = none
default_model = none
start_date = 2020-Jan-01
end_date = 2020-Jan-01
}
variables {
agent numeric sex
}
condition TEST {
start_state = Agent_Start
meta_start_state = Meta_Start
state Meta_Start {
read_agent_file("agents.txt")
wait()
default()
}
state Agent_Start {
print("ID: ", id(), "; SEX: ", sex)
wait()
default()
}
}
Running the above will can produce the following output: