Package: ai-economist
Foundation: An Economic Simulation FrameworkThis repo contains an implementation of Foundation, a framework for flexible, modular, and composable environments thatmodel socio-economic behaviors and dynamics in a society with both agents and governments.Foundation provides aGym-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 LearningStephan Zheng, Alexander Trott, Sunil Srinivasa, David C. Parkes, Richard Socher.Building a Foundation for Data-Driven, Interpretable, and Robust Policy Design using the AI EconomistAlexander 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:The AI Economist websiteBlog: The AI Economist: Improving Equality and Productivity with AI-Driven Tax PoliciesBlog: The AI Economist moonshotBlog: The AI Economist web demo of the COVID-19 case studyWeb demo: The AI Economist ethical review of AI policy design and COVID-19 case studySimulation Cards: Ethics Review and Intended UsePlease see ourSimulation Cardfor a review of the intended use and ethical review of our framework.Please see ourCOVID-19 Simulation Cardfor a review of the ethical aspects of the pandemic simulation (and as fitted for COVID-19).Join us on SlackIf you're interested in extending this framework, discussing machine learning for economics, and collaborating on research project:join our Slack channelaieconomist.slack.comusing thisinvite link, oremail us @ai.economist@salesforce.com.Installation InstructionsTo get started, you'll need to have Python 3.7+ installed.Using pipSimply use the Python package manager:pipinstallai-economistInstalling from SourceClone this repository to your local machine:git clone www.github.com/salesforce/ai-economistCreate a new conda environment (named "ai-economist" below - replace with anything else) and activate itconda create --name ai-economist python=3.7 --yes
 conda activate ai-economistEithera) Edit the PYTHONPATH to include the ai-economist directoryexport PYTHONPATH=<local path to ai-economist>:$PYTHONPATHORb) Install as an editable Python packagecd 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 runaiecononce to activate the conda environment.Testing your InstallTo test your installation, try running:conda activate ai-economist
python -c "import ai_economist"Getting StartedTo familiarize yourself with Foundation, check out the tutorials in thetutorialsfolder. You can run these notebooks interactively in your browser on Google Colab.Multi-Agent Simulationseconomic_simulation_basic(Try this on Colab!): Shows how to interact with and visualize the simulation.economic_simulation_advanced(Try this on Colab!): Explains how Foundation is built up using composable and flexible building blocks.optimal_taxation_theory_and_simulation(Try this on Colab!): Demonstrates how economic simulations can be used to study the problem of optimal taxation.covid19_and_economic_simulation(Try this on Colab!): Introduces a simulation on the COVID-19 pandemic and economy that can be used to study different health and economic policies .Multi-Agent Trainingmulti_agent_gpu_training_with_warp_drive(Try this on Colab!): Introduces our multi-agent reinforcement learning frameworkWarpDrive, which we then use to train the COVID-19 and economic simulation.multi_agent_training_with_rllib(Try this on Colab!): Shows how to perform distributed multi-agent reinforcement learning withRLlib.two_level_curriculum_training_with_rllib: Describes how to implement two-level curriculum training withRLlib.To run these notebookslocally, you needJupyter. Seehttps://jupyter.readthedocs.io/en/latest/install.htmlfor installation instructions and(https://jupyter-notebook.readthedocs.io/en/stable/for examples of how to work with Jupyter.Structure of the CodeThe simulation is located in theai_economist/foundationfolder.The code repository is organized into the following components:ComponentDescriptionbaseContains base classes to can be extended to define Agents, Components and Scenarios.agentsAgents represent economic actors in the environment. Currently, we have mobile Agents (representing workers) and a social planner (representing a government).entitiesEndogenous 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).componentsComponents 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.scenariosScenarios 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 theai_economist/datasetsfolder.Releases and ContributingPlease 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 ourcontribution guidelines.ChangelogFor the complete release history, seeCHANGELOG.md.LicenseFoundation and the AI Economist are released under theBSD-3 License.