PyDynamica is a freely available agent-based economy simulation

Overview

PyDynamica

PyDynamica is a pure python implementation of Sociodynamica, a virtual environment to simulate a simple economy with minimal dependencies.

PyDynamica is loosely based on ideas presented by Axtell and Epstein in Growing Artificial Societies (https://wtf.tw/ref/epstein_axtell.pdf) and Klaus Jaffe's work in developing Agent based models to visualize ideas in classical economics. (https://arxiv.org/abs/1509.04264)

Installation

pip3 install -r requirements.txt

python3 visualizer.py or python3 run_cli.py After the installation is complete and the server is running, open a web browser and navigate to http://localhost:8050 to see the visualizer.

Visualizer

How good of a model is this?

Not very. But even so, we can still learn a lot from this simple model, testing different economic hypotheses. A full economic analysis is coming soon.

It's easy to think of each agent as a "person" but really, it's more accurate to think of them as corporations. Here's why...

How does it work?

Sociodynamica is a freely available agent-based simulation model.

Resources

The grid world is filled with resources of three kinds: food, minerals, and empty. Each grid also keeps track of resource abundance.

Resources are generated by first creating three individual grids representing the abundance of each resource using perlin noise. At each grid, we choose the resource with highest abundance since each cell can only have one resource.

Minerals are a limited resource and therefore cannot regenerate. However, food regenerates at a constant rate.

Agent

There are four types of agents: omnipotent, trader, farmer, and miner. A miner can only mine minerals and trade with the trader. A farmer can only gather food and trade with the trader. A trader can trade with anybody. An omnipotent agent can, as the name implies, perform every action.

At the start of each turn, the agents move according to brownian motion except when they encounter an edge. After they move, they are given a chance to look for someone to trade with under the max trade per step contraint. An agent may choose who to trade with randomly as long as they are within the "contact horizon." Contact horizon represents how integrated an economy is.

The agents then collect resources if they are standing on a tile with resources they can collect. They then consume resources at a constant rate and adjust the internal value of each commodity.

The internal value represents how much an agent is willing to sell/buy a product for. The average sum of the internal value of all agents represents the "true market value" of products.

If the agent run out of food the agent dies. There is also a random chance that an agent may die (to simulate natural disasters, accidents, disease, etc). An agent can decrease the chance of this random death by accumulating minerals. Sudden death is determined through mineral_wealth < random[0,1] * danger.

Bartering / Trading mechanism

Each agent has a risk property which determines how much of their stockpile they want to sell off at each timestep. The amount to purchase is determined by the minimum of either the maximum amount the trading partner wants to sell or the amount of money the agent currently has.

If the agent values a resource more than its tradnig partner, a purchase will be made accordingly.

After each trading period comes a value adjustment period. If the resources sold in the previous trading round is less than the minerals the agent wanted to sell, the agent will decrease it's internal perceived value of that resource by a certain percentage. Otherwise, it will increase its internal perceived value.

Environment

An environment is defined by its terrestrial dimensions as well as the number of agents. Unlike other simulators which imbue agents with genetics and heredity, PyDynamica chooses to randomly generate agents at each step to replace dead agents.

This is more like how corporations work in free market capitalism. New companies don't inherit properties of the fallen ones (for the most part). In fact, people don't even try to replicate behaviors of successful companies (for the most part).

Statistics

The provided visualizer can show a couple interesting statistics about the economy:

  • GDP per capita: the sum of wealth of all agents divided by the number of agents.
  • Avg internal values: Price of food and price of minerals
  • Resources: the wealth of the richest agent and the wealth of the poorest agent and the wealth disparity

Todo

  • Mineral efficiency increase (innovation in capitalism)
  • More statistics about wealth disparities and the top 10% (See if bernie is right)
  • Implement "innovation" (increase extraction efficienties and extraction difficulties)
  • Implement replenishing resources
  • How do we get the price to determine the innovation level?
  • Make visualizer pretty
  • Implement Stalin
  • Implement income tax & wealth tax at different rates

Bugs & Qs

Feel free to report bugs and issues on github. Also feel free to email me at [email protected]

PyDynamica is a freely available agent-based economy simulation

PyDynamica PyDynamica is a pure python implementation of Sociodynamica, a virtual environment to simulate a simple economy with minimal dependencies.

4 Sep 10, 2022
A fast and easy python virtual environment creator for linux with some pre-installed libraries.

python-venv-creator A fast and easy python virtual environment created for linux with some optional pre-installed libraries. Dependencies: The followi

2 Apr 19, 2022
a pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)

pyenv-virtualenv pyenv-virtualenv is a pyenv plugin that provides features to manage virtualenvs and conda environments for Python on UNIX-like system

pyenv 5.3k Jan 08, 2023
A pythonic interface to high-throughput virtual screening software

pyscreener A pythonic interface to high-throughput virtual screening software Overview This repository contains the source of pyscreener, both a libra

56 Dec 15, 2022
Python virtualenvs in Debian packages

dh-virtualenv Contents Overview Presentations, Blogs & Other Resources Using dh-virtualenv How does it work? Running tests Building the package in a D

Spotify 1.5k Jan 02, 2023
A simple but powerful Python packer to run any project with any virtualenv dependencies anywhwere.

PyEmpaq A simple but powerful Python packer to run any project with any virtualenv dependencies anywhwere. With PyEmpaq you can convert any Python pro

Facundo Batista 23 Sep 22, 2022
Simple Python version management

Simple Python Version Management: pyenv pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UN

pyenv 30.1k Jan 04, 2023
Ready-to-run Docker images containing Jupyter applications

Jupyter Docker Stacks are a set of ready-to-run Docker images containing Jupyter applications and interactive computing tools.

Project Jupyter 7k Jan 03, 2023
Fish shell tool for managing Python virtual environments

VirtualFish VirtualFish is a Python virtual environment manager for the Fish shell. You can get started by reading the documentation. (It’s quite shor

Justin Mayer 968 Dec 24, 2022
Define requirements inside your python code and scriptenv makes them ready to import.

scriptenv Define requirements inside your python code and scriptenv makes them ready to import. Getting Started Install scriptenv $ pip install script

Stefan Hoelzl 6 Nov 04, 2022
An experimental technique for efficiently exploring neural architectures.

SMASH: One-Shot Model Architecture Search through HyperNetworks An experimental technique for efficiently exploring neural architectures. This reposit

Andy Brock 478 Aug 04, 2022
Manage python virtual environments on the working notebook server

notebook-environments Manage python virtual environments on the working notebook server. Installation It is recommended to use this package together w

Vladislav Punko 44 Nov 02, 2022
Python Development Workflow for Humans.

Pipenv: Python Development Workflow for Humans [ ~ Dependency Scanning by PyUp.io ~ ] Pipenv is a tool that aims to bring the best of all packaging wo

Python Packaging Authority 23.5k Jan 01, 2023
The GNS3 server manages emulators such as Dynamips, VirtualBox or Qemu/KVM

GNS3-server This is the GNS3 server repository. The GNS3 server manages emulators such as Dynamips, VirtualBox or Qemu/KVM. Clients like the GNS3 GUI

GNS3 644 Dec 30, 2022
Run a command in the named virtualenv.

Vex Run a command in the named virtualenv. vex is an alternative to virtualenv's source wherever/bin/activate and deactivate, and virtualenvwrapper's

Sasha Hart 374 Dec 21, 2022
Virtual Python Environment builder

virtualenv A tool for creating isolated virtual python environments. Installation Documentation Changelog Issues PyPI Github Code of Conduct Everyone

Python Packaging Authority 4.3k Dec 30, 2022
A PipEnv Environment Switcher

Pipes Pipenv Environment Switcher ⚡ Overview Pipes is a Pipenv companion CLI tool that provides a quick way to jump between your pipenv powered projec

Gui Talarico 131 Sep 04, 2022
This tool is used to install `pyenv` and friends.

pyenv installer This tool installs pyenv and friends. It is inspired by rbenv-installer. Prerequisites In general, compiling your own Python interpret

pyenv 3.5k Jan 03, 2023
macOS development environment setup: Setting up a new developer machine can be an ad-hoc, manual, and time-consuming process.

dev-setup Motivation Setting up a new developer machine can be an ad-hoc, manual, and time-consuming process. dev-setup aims to simplify the process w

Donne Martin 5.9k Jan 02, 2023
to-requirements.txt allows to automatically add and delete modules to requirements.txt installing them using pip.

to-requirements.txt | Automatically update requirements.txt to-requirements.txt allows to automatically add and delete modules to requirements.txt ins

Ilya 16 Dec 29, 2022