Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frequently-needed functions #132

Open
dmasad opened this issue Jun 25, 2015 · 11 comments
Open

Frequently-needed functions #132

dmasad opened this issue Jun 25, 2015 · 11 comments
Assignees
Labels

Comments

@dmasad
Copy link
Member

dmasad commented Jun 25, 2015

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

@dmasad dmasad added discuss feature Release notes label labels Jun 25, 2015
@dmasad dmasad self-assigned this Aug 18, 2015
@dmasad
Copy link
Member Author

dmasad commented Aug 18, 2015

Will create, add weighted selection.

@max-orhai
Copy link

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.

@jackiekazil
Copy link
Member

Sent email to Simsoc to see if anyone had thoughts on this.

@digitaldust
Copy link

digitaldust commented May 16, 2018

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!

@jbadham
Copy link

jbadham commented May 17, 2018

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.

@prochlorothrix
Copy link

Functions to help parallel processing

@jackiekazil
Copy link
Member

@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.

@jackiekazil jackiekazil self-assigned this May 24, 2018
@jbadham
Copy link

jbadham commented Jun 9, 2018

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.

@rht
Copy link
Contributor

rht commented May 22, 2019

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.

@jackiekazil
Copy link
Member

@tpike3 For discussion at the next dev session -- let's break this apart and close this monster ticket.

@tpike3
Copy link
Contributor

tpike3 commented Feb 15, 2023

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)

@jackiekazil jackiekazil added the Sprints! A task that might be good to tackle during sprints! label Apr 20, 2023
@jackiekazil jackiekazil removed the Sprints! A task that might be good to tackle during sprints! label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8 participants