superneuroabm.core package¶
Submodules¶
superneuroabm.core.agent module¶
- class superneuroabm.core.agent.AgentFactory¶
Bases:
object- property breeds: List[Breed]¶
Returns the breeds registered in the model
- Returns:
A list of currently registered breeds.
- create_agent(breed: Breed, **kwargs) int¶
- Creates and agent of the given breed initialized with the properties given in
**kwargs.
- Parameters:
breed – Breed definition of agent
**kwargs –
named arguments of agent properties. Names much match properties already registered in breed.
- Returns:
Agent ID
- generate_agent_data_tensors(use_cuda=True) List[List[Any]] | Dict[str, List[Any]]¶
- get_agent_property_value(property_name: str, agent_id: int) Any¶
- Returns the value of the specified property_name of the agent with
agent_id
- Parameters:
property_name – str name of property as registered in the breed.
agent_id – Agent’s id as returned by create_agent
- Returns:
value of property_name property for agent of agent_id
- get_agents_with(query: Callable) Dict[int, List[Any]]¶
- Returns an Dict, key: agent_id value: List of properties, of the agents that satisfy
the query. Query must be a callable that returns a boolean and accepts **kwargs where arguments may with breed property names may be accepted and used to form query logic.
- Parameters:
query – Callable that takes agent data as dict and returns List of agent data
- Returns:
Dict of agent_id: List of properties
- property num_agents: int¶
- Returns number of agents. Agents are not removed if they are killed at the
moment.
- register_breed(breed: Breed) None¶
- Registered agent breed in the model so that agents can be created under
this definition.
- Parameters:
breed – Breed definition of agent
- set_agent_property_value(property_name: str, agent_id: int, value: Any, dims: List[int] | None = None) None¶
- Sets the property of property_name for the agent with agent_id with
value.
- Parameters:
property_name – str name of property as registered in the breed.
agent_id – Agent’s id as returned by create_agent
value – New value for property
dims – Optional dimensions of property_value as List of ints. Not required, but improves performance if provied. E.g. [0] if value is a single number like 0, [4, 2] if it is a multi-dimensional list/array with dimensions 4 and 2.
- update_agents_properties(equal_side_agent_data_tensors=typing.List[typing.List[typing.Any]], use_cuda=True) None¶
- class superneuroabm.core.agent.Breed(name: str)¶
Bases:
object- property name: str¶
- property properties: Dict[str, Any]¶
- register_property(name: str, default: int | float | List = nan, max_dims: List[int] | None = None) None¶
- register_step_func(step_func: Callable, priority: int = 0)¶
What the agent is supposed to do during a simulation step.
- property step_funcs: Dict[int, Callable]¶
superneuroabm.core.model module¶
SuperNeuroABM basic Model class
- class superneuroabm.core.model.Model¶
Bases:
object- THREADSPERBLOCK = 32¶
- get_agent_property_value(id: int, property_name: str) Any¶
- get_agents_with(query: Callable) Set[List[Any]]¶
- get_synapse_weight(presynaptic_neuron_id: int, post_synaptic_neuron_id: int) float¶
Return synaptic weight. This function is useful if STDP is turned on as weights will be updated during simulation.
- Parameters:
presynaptic_neuron_id – int
presynaptic_neuron_id – int
- Returns:
float, final weight of synapse
- save(app: Model, fpath: str) None¶
Saves model. Must be overridden if additional data pertaining to application must be saved.
- Parameters:
fpath – file path to save pickle file at
app_data – additional application data to be saved.
- set_agent_property_value(id: int, property_name: str, value: Any, dims: List[int] | None = None) None¶
- setup(use_cuda: bool = True) None¶
Must be called before first simulate call. Initializes model and resets ticks. Readies step functions and for breeds.
- Parameters:
use_cuda – runs model in GPU mode.
- simulate(ticks: int, update_data_ticks: int = 1, num_cpu_proc: int = 4) None¶
- superneuroabm.core.model.generate_gpu_func(n_properties, breed_idx_2_step_func_by_priority, ticks)¶
- superneuroabm.core.model.smap(func_args)¶
superneuroabm.core.util module¶
- superneuroabm.core.util.compress_tensor(arr: Iterable, level: int = 0)¶
- superneuroabm.core.util.convert_to_equal_side_tensor(tensor: List[Any], max_dims: Tuple[int] | None = None) array¶