Package: pram2mesa
pram2mesaTools for translatingPyPRAM's Probabilistic Relational Agent-Based Models toMesa's Agent-Based Modelspram2mesa is a tool allowing a Probabilistic Relational Agent-Based Model (PRAM) to be translated into an Agent-Based Model (ABM). There are a few tradeoffs here:PRAMs work at a group level, while ABMs work at an individual agent levelPRAMs have a more formal grammar, while ABMs are open-endedPRAMs are often much faster than ABMs, especially on very large populationsCore to this project, however, is a more theoretical purpose - demonstrating the interconnectedness of the two frameworks. While they are not the same, they are similar in many ways, allowing a tool like pram2mesa to exist. For more on comparing these frameworks, see theMediasection.InstallationDependencies (For Translation)Python 3.8PyPRAM(must be installed separately; see below)astorautopep8dilliteroundDependencies (For Running Translated ABMs)Mesanetworkx(also a dependency of Mesa)dillSetupTo install pram2mesa and its dependencies (except PyPRAM) simply use pip:pip install pram2mesaPyPRAM must be installed separately. See PyPRAM'sSetupfor details or just use:pip install git+https://github.com/momacs/pram.gitBear in mind that any computer running a translated ABM will (of course) need Mesa, but also dill.Also, note that many of the samples require further dependencies to run, although most should be covered by installing PyPRAM.UsageTranslating the PRAMTo translate a PRAM, first create the PRAM in a Python file or interpreter. Make sure that youdo not runthe PRAM. If you do, your new ABM will be setup with the ending configuration of the PRAM, not the beginning.my_pram=(Simulation().add(...))Ensure you have imported pram2mesa:frompram2mesaimportpram2mesaThen simply supply your PRAM simulation and a nice file-safe name for your new files:pram2mesa(my_pram,'MyNewABM')By default, pram2mesa will automatically clean the outputted Python files in an attempt to make them PEP8-compliant. To disable this, simply setautopeptoFalse:pram2mesa(my_pram,'MyNewABM',autopep=False)This will create a new directory calledMyNewABM(orMyNewABM_1ifMyNewABMalready exists; orMyNewABM_2etc...) containing three Python files and three JSON files:MyNewABM
+-- MyNewABMAgent.py
+-- MyNewABMGroups.json
+-- MyNewABMModel.py
+-- MyNewABMRules.json
+-- MyNewABMSites.json
+-- make_python_identifier.pyRunning the ABMOnce you've created the files, you can instantiate your new model and run it as you normally would in Mesa. Make sure to keep all the files together; the Agent and Model classes need the JSON files during their initialization and usemake_python_identifier.pyas well.fromMyNewABMModelimportMyNewABMModelmodel=MyNewABMModel()You will want to be sure to add a datacollector to the model to measure and graph outputs.model.datacollector=DataCollector(...)The Models that pram2mesa generates do not overriderun_model(). If you want, you can override it yourself in the Model class, or just usestep():foriinrange(num_runs):model.step()Then, you can extract graphs or other data from your datacollector. If you are unfamiliar with Mesa, you can look at theirdocumentationwhich includes some well-written tutorials. The files namedrun_abm.pyin each folder of this project'sSamplesdirectory may also be useful.AcknowledgementsThank you to my research mentors, Drs.Paul CohenandTomek Loboda, for their support on this project.This project is supported by the Brackenridge Fellowship at theUniversity of Pittsburgh Honors College.LicenseThis project is licensed under theMIT License.