Skip to main content

Foundation: An Economics Simulation Framework

Project description

Foundation: An Economic Simulation Framework

This repo contains an implementation of Foundation, a framework for flexible, modular, and composable environments that model socio-economic behaviors and dynamics in a society with both agents and governments.

Foundation provides a Gym-style API:

  • reset: resets the environment's state and returns the observation.
  • step: advances the environment by one timestep, and returns the tuple (observation, reward, done, info).

This simulation can be used in conjunction with reinforcement learning to learn optimal economic policies, as detailed in the following papers:

The AI Economist: Improving Equality and Productivity with AI-Driven Tax Policies, Stephan Zheng, Alexander Trott, Sunil Srinivasa, Nikhil Naik, Melvin Gruesbeck, David C. Parkes, Richard Socher.

The AI Economist: Optimal Economic Policy Design via Two-level Deep Reinforcement Learning Stephan Zheng, Alexander Trott, Sunil Srinivasa, David C. Parkes, Richard Socher.

Building a Foundation for Data-Driven, Interpretable, and Robust Policy Design using the AI Economist Alexander Trott, Sunil Srinivasa, Douwe van der Wal, Sebastien Haneuse, Stephan Zheng.

If you use this code in your research, please cite us using this BibTeX entry:

@misc{2004.13332,
 Author = {Stephan Zheng, Alexander Trott, Sunil Srinivasa, Nikhil Naik, Melvin Gruesbeck, David C. Parkes, Richard Socher},
 Title = {The AI Economist: Improving Equality and Productivity with AI-Driven Tax Policies},
 Year = {2020},
 Eprint = {arXiv:2004.13332},
}

For more information and context, check out:

Simulation Cards: Ethics Review and Intended Use

Please see our Simulation Card for a review of the intended use and ethical review of our framework.

Please see our COVID-19 Simulation Card for a review of the ethical aspects of the pandemic simulation (and as fitted for COVID-19).

Join us on Slack

If you're interested in extending this framework, discussing machine learning for economics, and collaborating on research project:

Installation Instructions

To get started, you'll need to have Python 3.7+ installed.

Using pip

Simply use the Python package manager:

pip install ai-economist

Installing from Source

  1. Clone this repository to your local machine:
 git clone www.github.com/salesforce/ai-economist
  1. Create a new conda environment (named "ai-economist" below - replace with anything else) and activate it
 conda create --name ai-economist python=3.7 --yes
 conda activate ai-economist
  1. Either

    a) Edit the PYTHONPATH to include the ai-economist directory

 export PYTHONPATH=<local path to ai-economist>:$PYTHONPATH

OR

b) Install as an editable Python package

 cd ai-economist
 pip install -e .

Useful tip: for quick access, add the following to your ~/.bashrc or ~/.bash_profile:

alias aiecon="conda activate ai-economist; cd <local path to ai-economist>"

You can then simply run aiecon once to activate the conda environment.

Testing your Install

To test your installation, try running:

conda activate ai-economist
python -c "import ai_economist"

Getting Started

To familiarize yourself with Foundation, check out the tutorials in the tutorials folder. You can run these notebooks interactively in your browser on Google Colab.

Multi-Agent Simulations

Multi-Agent Training

To run these notebooks locally, you need Jupyter. See https://jupyter.readthedocs.io/en/latest/install.html for installation instructions and (https://jupyter-notebook.readthedocs.io/en/stable/ for examples of how to work with Jupyter.

Structure of the Code

  • The simulation is located in the ai_economist/foundation folder.

The code repository is organized into the following components:

Component Description
base Contains base classes to can be extended to define Agents, Components and Scenarios.
agents Agents represent economic actors in the environment. Currently, we have mobile Agents (representing workers) and a social planner (representing a government).
entities Endogenous and exogenous components of the environment. Endogenous entities include labor, while exogenous entity includes landmarks (such as Water and Grass) and collectible Resources (such as Wood and Stone).
components Components are used to add some particular dynamics to an environment. They also add action spaces that define how Agents can interact with the environment via the Component.
scenarios Scenarios compose Components to define the dynamics of the world. It also computes rewards and exposes states for visualization.
  • The datasets (including the real-world data on COVID-19) are located in the ai_economist/datasets folder.

Releases and Contributing

  • Please let us know if you encounter any bugs by filing a GitHub issue.
  • We appreciate all your contributions. If you plan to contribute new Components, Scenarios Entities, or anything else, please see our contribution guidelines.

Changelog

For the complete release history, see CHANGELOG.md.

License

Foundation and the AI Economist are released under the BSD-3 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai-economist-1.7.1.tar.gz (111.3 kB view details)

Uploaded Source

Built Distribution

ai_economist-1.7.1-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file ai-economist-1.7.1.tar.gz.

File metadata

  • Download URL: ai-economist-1.7.1.tar.gz
  • Upload date:
  • Size: 111.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ai-economist-1.7.1.tar.gz
Algorithm Hash digest
SHA256 52366732f43da20691daa3f355a70257288933d1537a2bc3b0f40209f55882ec
MD5 2a504375d5fac451f17f4f2d7f4f425e
BLAKE2b-256 c23a22a6ffdb74d0ef952d3015653d486752f819254a1dfc303d5ea13ecbedc1

See more details on using hashes here.

File details

Details for the file ai_economist-1.7.1-py3-none-any.whl.

File metadata

  • Download URL: ai_economist-1.7.1-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ai_economist-1.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3329ed74da48f0466a3688ffd3a3f4885493cd16144a5bc2ede81519bb17db8
MD5 f641fd04070708d2a86724227ba9403b
BLAKE2b-256 82258c7ec8d9733c9e52cbdab73e2489d4a44970eae41c0343ef188d71da855f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page