mesa
mesa copied to clipboard
Frequently-needed functions
Are there recurring functions which come up frequently enough in agent-based modeling that we should include them in Mesa? The first one that comes to mind is proportional selection, i.e. picking one of a set of options based on weights. This post made me think that it might be worthwhile to have a somewhat-optimized implementation of that somewhere. Are there any other important functions?
If we want to add those, do they go in the root mesa package, or under mesa.utils or something?
ie weight randomization
Will create, add weighted selection.
As to the question of commonly used functions, there are a lot of these kinds of conveniences built into NetLogo. See http://ccl.northwestern.edu/netlogo/docs/dictionary.html (especially the 'Agentset' and 'Mathematical' sections).
Some of those are probably best provided by other Python packages. Not sure which of them are worth providing directly.
Sent email to Simsoc to see if anyone had thoughts on this.
just got the email from Simsoc, and let me say it's a blast getting to know about Mesa!
about functions often used:
- one-of / n-of: the ability to pick an element (or n-elements) uniformly at random from a collection
- picking based on attribute (would be optimal to have a prob of picking proportional to the attribute value as well as a probability of picking inversely related to the attribute)
I'll go check Mesa to see what it offers out of the box! Again great project!
Also coming from SIMSOC. I can't find a dictionary anywhere of functions that are already available. I would be happy to go through my (NetLogo) teaching materials and identify the functions that I make sure I teach as a shortcut to identifying commonly used functions. But I don't know which would be suggestions as I don't have Mesa installed so can't access any help system.
Functions to help parallel processing
@digitaldust, @jbadham, @prochlorothrix -- ty for your responses!!
@jbadham -- Your suggestion is amazing! I love that. Here are our docs -- https://mesa.readthedocs.io/en/master/apis/api_main.html. The API section is auto-generated based on the doc strings (aka help text) in the code. Since it is auto-generated, they might not be great. If you notice something, feel free to say -- hey, this isn't working or more is needed here by filing a new ticket. :-)
@prochlorothrix -- Can you provide more of a description on this -- maybe in a new ticket? There are a few discussions around this, but we need a solid use case to build around.
Okay, here's some useful NetLogo commands that I am not sure are already in Mesa. Mesa obviously relies on standard Python for concepts like agentsets (for example, selecting agents that satisfy some condition), mathematical operators and networks (perhaps igraph or NetworkX), so I didn't really look at those. In this list, I have used the NetLogo primitive name - full descriptions are available at the dictionary.
Agent movement:
- uphill/downhill: move in the direction of an increasing/decreasing value of a characteristic owned by the space
- face: change heading so that a forward movement will go toward a specified agent
- turtles-on: create a set of all the agents at a particular grid reference
- patch-ahead: where an agent would move in the next time step (eg to check for obstacles)
Agent selection:
- max-n-of, min-n-of: select the n agents with the largest/smallest values of a specified attribute
- weighted-n-of: select randomly in proportion to the value of a specified attribute (part of the rnd extension)
There's also 'self' and 'myself'. These are terrible names, but the concept is essential to agent-centric thinking. One agent needs to be able to ask another agent to do something (such as change an attribute value) and there needs to be an easy way to distinguish between the agent doing the asking and the agent being asked.
Functions to help parallel processing
There is BatchRunnerMP
for this. But another direction would be to parallelize across independent sensitivity analysis sessions, which doesn't require pickling and hence doesn't require external library. For a project to resort to parallel processing it would mean that the model is too slow to run on a laptop. In that case, the same speed up benefit can be done by this parallelize-across-sessions alternative.
@tpike3 For discussion at the next dev session -- let's break this apart and close this monster ticket.
Will do...I will set up the next dec session discussion this weekend and do the notes form last time (apologies I got sidetracked by NUMFOCUS and other newsletter)