Backend
- pythonabm.backend.get_neighbors_gpu(locations, bin_locations, bins, bins_help, distance, edges, if_edge, edge_count, max_neighbors)
See get_neighbors_gpu for parameter descriptions.
- pythonabm.backend.cuda_magnitude(vector_1, vector_2)
Returns magnitude of vector between inputted vectors.
- class pythonabm.backend.Graph(*args, **kwargs)
Bases:
GraphThis class extends the Graph class from iGraph adding instance variables for the bin/bucket sort algorithm.
- pythonabm.backend.assign_bins_jit(number_agents, bin_locations, bins, bins_help, max_agents)
This just-in-time compiled method performs the actual calculations for the assign_bins() method.
- Parameters:
number_agents (int) – The current number of agents in the simulation.
locations (numpy.ndarray) – The locations of the agents.
bin_locations (numpy.ndarray) – Discretized agent locations for bin sorting.
bins (numpy.ndarray) – Holds the agent based on discretized locations.
bins_help (numpy.ndarray) – Stores the number of agents in each bin.
max_agents (int) – The maximum number of agents that can be stored in bin.
- pythonabm.backend.check_direct(path)
Makes sure directory exists, if not make that directory
- Parameters:
path (str) – The path to a directory.
- pythonabm.backend.check_existing(name, output_path, new_simulation=True)
Based on the mode, checks to see if an existing simulation in the output path has the same name.
- pythonabm.backend.check_output_dir(output_dir)
Checks that the output directory exists.
- Parameters:
output_dir (str) – Path to ABM output directory.
- Returns:
A correct output path
- pythonabm.backend.commandline_param(flag, dtype)
Returns the value for option passed at the command line.
- pythonabm.backend.empty_array(shape, dtype)
Create empty array based on data type.
- pythonabm.backend.get_end_step()
If using the continuation mode, get the last step number for the simulation.
- Returns:
The simulation end step number
- pythonabm.backend.get_neighbors_cpu(number_agents, locations, bin_locations, bins, bins_help, distance, edges, if_edge, edge_count, max_neighbors)
This just-in-time compiled method performs the actual calculations for the get_neighbors() method.
- Parameters:
number_agents (int) – The current number of agents in the simulation.
locations (numpy.ndarray) – The locations of the agents.
bin_locations (numpy.ndarray) – Discretized agent locations for bin sorting.
bins (numpy.ndarray) – Holds the agent based on discretized locations.
bins_help (numpy.ndarray) – Stores the number of agents in each bin.
distance (float) – The radius of each agent’s neighborhood.
edges (numpy.ndarray) – Stores the graph edge connections between neighboring agents.
if_edge (numpy.ndarray) – Whether edges are a non-zero values.
edge_count (numpy.ndarray) – The number of neighbors per agent.
max_neighbors (int) – The maximum number of agents that can be stored with these arrays.
- Returns:
The edge values and the number of edges (neighbors) per agent.
- pythonabm.backend.normal_vector(vector)
Normalizes the vector.
- Parameters:
vector (numpy.ndarray) – Vector to be normalized.
- Returns:
A normalized vector
- pythonabm.backend.progress_bar(progress, maximum)
Makes a progress bar to show progress of output.
- pythonabm.backend.record_time(function)
This is a decorator used to time individual methods.
- Parameters:
function (func) – A function to be decorated.
- Returns:
A wrapped function
- pythonabm.backend.starting_params()
Returns the name and mode for the simulation either from the commandline or a text-based UI.
- Returns:
The simulation name and mode
- pythonabm.backend.template_params(path)
Return parameters as dict from a YAML template file.