Skip to main content

large population models

Reason this release was yanked:

Not required anymore

Project description

Differentiable agent-based learning for million-scale populations - inside the body, around us and beyond.

1. Installation

Download

The simplest way to install AgentTorch is from PyPi at:

pip install agent-torch

To get the latest version of AgentTorch, you can install it directly from git at:

pip install git+https://github.com/AgentTorch/AgentTorch

2. Setup

Hardware

The code has been tested for macOS Catalina 10.1.7 and Ubuntu 22.04.2 LTS. Large-scale experiments are run using NVIDIA TITANX GPU and V100 GPU.

Dependencies

Step 1: Create a virtual environment agent_torch_env. We recommend using python 3.8 and pip as the install.

python3.8 -m venv agent_torch_env
source agent_torch_env/bin/activate

To install python3.8, follow these tutorials for Mac and Ubuntu respectively. To install pip, follow these tutorials for Mac and Ubuntu respectively.

Step 2: Install pytorch and pytorch geometric. We recommend using Pytorch 2.0 and corresponding Pytorch geometric bindings. We recommend following the guides for offical pytorch install and official pytorch-geometric install. We summarize the commands below:

Mac:

# CUDA is not available on MacOS, please use default package
pip install torch torchvision torchaudio
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv

Ubuntu:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/${CUDA}
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.0.0+${CUDA}.html

where ${CUDA} is the CUDA version. We have tested our code on cu118.

Step 3: Install AgentTorch specific dependencies as below:

cd AgentTorch
pip3 install -r requirements.txt

3. AgentTorch overview

Creating a new simulator using AgentTorch involves the following steps:

  1. Defining the configuration: Here we define the variables and functions to be used in the simulator. In this module a Configurator object is to be created to which the variables and functions to be used in the simulator are added as properties. These are then used to instantiate a Runner object. An example for this can be found in nca_simulator.py.
  2. Defining the trainer: This module loads the configuration, the various variables and functions that form the substeps and executes the main simulation and learning loop. Any learning related loss and optimization function need to be defined here. An example for this can be found in "models/nca/trainer.py"
  3. Defining substeps: As described in the figure above, each simulation comprises of multiple substeps. Each substep comprises of the following four functions: observation, action, transition and reward. Each of these need to be defined in a separate module, using the base classes for SubstepObservation, SubstepTransition, SubstepPolicy provided in substep.py. Since these functions need to be differentiable, we provide several differentiable utilities in helpers_soft.py. These can be used to create differentiable variants of operations such as maximum, logical comparison etc. An example for substep definition can be found in nca_evolve.py, covid_quarantine.py
  4. Using helpers: AgentTorch has several useful functions defined in helpers that can be used in defining the various functions. These include library of utilities to support differentiability of substeps, loading public data sources such as from US census and, initialization of state properties and environment networks. For instance, helpers_soft.py include differentiable utilities and helpers_general.py includes uitilies for data reading and writing.

A detailed code specific documentation is provided in create model docs

4. Running examples

You can run a sample experiment with the following command:

cd models/nca
python trainer.py --c config.yaml
cd models/opinion
python trainer.py --c config.yaml

5. Starter Guide

Generate and Interpret config.yaml file

An interactive notebook with step-by-step guide to define and understand a config.yaml is given in config_example_docs.

Build your own AgentTorch model

A step-by-step guide to start a new AgentTorch project is given in starter documentation

6. Issues

The AgentTorch project is under active development and are continually fixing issues. Please feel free to leave a comment at Troubleshooting issues

Citation

If you use this project or code in your work, please cite it using the following BibTeX entry:

@inproceedings{chopra2024framework, title = {A Framework for Learning in Agent-Based Models}, author = {Chopra, Ayush and Subramanian, Jayakumar and Krishnamurthy, Balaji and Raskar, Ramesh}, booktitle = {Proceedings of the 23rd International Conference on Autonomous Agents and Multi-agent Systems}, year = {2024}, organization = {International Foundation for Autonomous Agents and Multiagent Systems}, }

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

agent_torch-0.2.1.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_torch-0.2.1-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file agent_torch-0.2.1.tar.gz.

File metadata

  • Download URL: agent_torch-0.2.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.2

File hashes

Hashes for agent_torch-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7daf2794ccd1ad24597ea441b700e593f6785b70da2fd3c4e609b89de36aa916
MD5 49440a64077c8c3a3e4429b13763f09c
BLAKE2b-256 1e173535ee59be7575653cdb2d6091c88a1f01d99f61f5108ed1efd81c17e5d4

See more details on using hashes here.

File details

Details for the file agent_torch-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: agent_torch-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.2

File hashes

Hashes for agent_torch-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 66478f72f48cf177905f5ccee919545810ed970c07c2537ccd4885b6559fafe8
MD5 d38d60ab55a309a391fd5a2683daf21c
BLAKE2b-256 7ad77db728c154be90a59db5d04f291592481fa5ac7af67f44f396ef9857cc73

See more details on using hashes here.

Supported by

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