# Dictionarys on the GPU for Agents.jl

Hello!

I am working on an Agent Based Model with the Agents.jl framework and I am having performance problems.

I am working with dictonarys to save positions and values. Is there a way to work with dictonaries on the GPU to speed thing up?

Thank you so much!

Perhaps itâ€™s better to describe what you are doing with the dictionaries so that we can advise whether there is a more performance data structure all together. Dictionaries are one of the least performance data structures

CU!

George Datseris (he/him)

I am simulating the spread of an invasive tree species. I have several dispersal functions for different dispersal mechanisms of the tree species (e.g. the spread along a river by water transporting the seeds).

This functions take the location of a tree and return a dictonary with possible locations where the tree could spread to next as keys and the probability for the locations as values (e.g. in dependence of distance along the river).

Thank you!
Karl

Right.

Well the most obvious thing I can thinnk of is: I am not sure whether you need to store this dictionary. Why do you not make a decision imediatelly about where the seed should be planted based on these probabilities? Where do you pass this dictionary, and why does it need to be passed? Why donâ€™t you pass instead the decided location? If you pass the decided locaiton you donâ€™t need to make a dictionary at all. A vector of positions and avector of probabilities. sample one posiition with a weighted sam[pling based on the probabilities.

Furthermore, can you be more descriptive about the performance problems you are having? What is the problem exactly and what would you expected to have happened instead of the problem?

1 Like

Sometimes itâ€™s the simple question!

Your question about my performance issue actually triggered a search that already helped me find part of the solution.
I had much more agents than I expected; this was simply because a keyword in the initialization was missing that would allow only one agent per position!

Therefore, it now runs already much better!

The passing of the dicts was more for modularity and readability so itâ€™s all ordered in terms of â€śhere I look for possible locations,â€ť â€śhere I combine the locations,â€ť â€śhere I plant my trees.â€ť
But maybe it is possible to â€śplant the treesâ€ť right away without storing the locations at all; I might try this!