{ "metadata": { "name": "", "signature": "sha256:f7b03ec7886048228b0b44ea21c5dd129f4247bb917223359e0e716b20d271f3" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "\n", "import numpy as np\n", "import pandas as pd\n", "\n", "from matplotlib import pyplot as plt\n", "import prettyplotlib as pplt\n", "import seaborn as sns\n", "\n", "from statsmodels.formula.api import glm\n", "import statsmodels.api as sm\n", "\n", "np.set_printoptions(precision=2)\n", "\n", "# local imports from the http://github.com/pjbull/civil_conflict\n", "# repository\n", "from ConflictMap import ConflictMap\n", "\n", "import ConflictModel\n", "reload(ConflictModel)\n", "#from ConflictModel import ConflictModel\n", "\n", "from graphics import plot_locations\n", "from graphics import plot_route_with_colors\n", "\n", "from models import Configuration\n", "from models import Route\n", "from models import HqLocator\n", "from models import HqLocatorUganda\n", "\n", "from optimization import sim_anneal\n", "\n", "from SliceSampler import SliceSampler" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 69 }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Modeling and Simulating Political Violence and Optimizing Aid Distribution in Uganda\n", "\n", "## Peter J. Bull & Isaac M. Slavitt\n", "\n", "Institute for Applied Computational Science \n", "Harvard University \n", "52 Oxford Street \n", "Cambridge, MA 02139 \n", "\n", "Using MCMC techniques, we model civil conflict in Uganda and optimize the limited relief aid that can be provided in these scenarios. We describe a method to simulate civil conflict events in space and time given historical data about these events. We also optimize the distribution of limited aid resources to refugees from these crises. Modeling aid delivery as a combination of the traveling salesman problem and the knapsack algorithm \u2014 two NP-hard problems \u2014 we find acceptable solutions using stochastic metaheuristics.\n", "\n", "Additional code can be found in our [civil_conflict GitHub repository](http://www.github.com/pjbull/civil_conflict).\n", "\n", "Additional details can be found in our [technical writeup](https://github.com/pjbull/civil_conflict/blob/master/write-up/am207_project_paper_bull_slavitt.pdf).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading in The Data\n", "The data comes from ACLED (Armed Conflict Location and Event Data Project), which is a dataset with locations, dates, fatalities, motivation, actors involved, and other information about civil conflicts in Africa. Their collection of data on Uganda covers 1997-2013, and they have a real-time tracker of events reported in 2014." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Load in the data\n", "with open(\"data/ACLED-Uganda_19970101-to-20131231_final.xlsx\") as f:\n", " uganda_file = pd.ExcelFile(f)\n", " \n", "uganda_data = uganda_file.parse('Sheet1')\n", "uganda_data.head()" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "
\n", " | GWNO | \n", "EVENT_ID_CNTY | \n", "EVENT_ID_NO_CNTY | \n", "EVENT_DATE | \n", "YEAR | \n", "TIME_PRECISION | \n", "EVENT_TYPE | \n", "ACTOR1 | \n", "ALLY_ACTOR_1 | \n", "INTER1 | \n", "ACTOR2 | \n", "ALLY_ACTOR_2 | \n", "INTER2 | \n", "INTERACTION | \n", "COUNTRY | \n", "ADMIN1 | \n", "ADMIN2 | \n", "ADMIN3 | \n", "LOCATION | \n", "LATITUDE | \n", "\n", " |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "500 | \n", "1UGA\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0... | \n", "12 | \n", "1997-01-01 | \n", "1997 | \n", "3 | \n", "Battle-No change of territory | \n", "Military Forces of Uganda (1986-) | \n", "NaN | \n", "1 | \n", "UFDF: Uganda Federal Democratic Front | \n", "NaN | \n", "2 | \n", "12 | \n", "Uganda | \n", "Mubende | \n", "Mityana | \n", "Bulera | \n", "Buganda | \n", "0.50000 | \n", "... | \n", "
1 | \n", "500 | \n", "2UGA\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0... | \n", "13 | \n", "1997-01-01 | \n", "1997 | \n", "3 | \n", "Battle-No change of territory | \n", "Military Forces of Uganda (1986-) | \n", "NaN | \n", "1 | \n", "LRA: Lord's Resistance Army | \n", "NaN | \n", "2 | \n", "12 | \n", "Uganda | \n", "Gulu | \n", "Gulu | \n", "Pece | \n", "Gulu | \n", "2.76667 | \n", "... | \n", "
2 | \n", "500 | \n", "3UGA\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0... | \n", "42 | \n", "1997-01-07 | \n", "1997 | \n", "1 | \n", "Battle-No change of territory | \n", "Military Forces of Uganda (1986-) | \n", "NaN | \n", "1 | \n", "ADF-NALU: Allied Democratic Forces-National Ar... | \n", "NaN | \n", "2 | \n", "12 | \n", "Uganda | \n", "Kamwenge | \n", "Kitagwenda | \n", "Nyabbani | \n", "Nyabani | \n", "0.13580 | \n", "... | \n", "
3 | \n", "500 | \n", "4UGA\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0... | \n", "49 | \n", "1997-01-08 | \n", "1997 | \n", "1 | \n", "Battle-No change of territory | \n", "Military Forces of Uganda (1986-) | \n", "NaN | \n", "1 | \n", "ADF-NALU: Allied Democratic Forces-National Ar... | \n", "NaN | \n", "2 | \n", "12 | \n", "Uganda | \n", "Kasese | \n", "Busongora | \n", "Kasese Tc | \n", "Kasese | \n", "0.18333 | \n", "... | \n", "
4 | \n", "500 | \n", "5UGA\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0... | \n", "65 | \n", "1997-01-11 | \n", "1997 | \n", "1 | \n", "Violence against civilians | \n", "LRA: Lord's Resistance Army | \n", "NaN | \n", "2 | \n", "Civilians (Uganda) | \n", "NaN | \n", "7 | \n", "27 | \n", "Uganda | \n", "Pader | \n", "Aruu | \n", "Acholibur | \n", "Acholi-Bur | \n", "3.12583 | \n", "... | \n", "
5 rows \u00d7 25 columns
\n", "\n", " | \n", " | FATALITIES | \n", "sum | \n", "prev1fat | \n", "prev2fat | \n", "prev3fat | \n", "prev4fat | \n", "prev5fat | \n", "
---|---|---|---|---|---|---|---|---|
1997 | \n", "6 | \n", "12 | \n", "245 | \n", "2 | \n", "5 | \n", "4 | \n", "5 | \n", "5 | \n", "
7 | \n", "24 | \n", "130 | \n", "12 | \n", "2 | \n", "5 | \n", "4 | \n", "5 | \n", "|
8 | \n", "9 | \n", "28 | \n", "24 | \n", "12 | \n", "2 | \n", "5 | \n", "4 | \n", "|
9 | \n", "14 | \n", "78 | \n", "9 | \n", "24 | \n", "12 | \n", "2 | \n", "5 | \n", "|
10 | \n", "5 | \n", "42 | \n", "14 | \n", "9 | \n", "24 | \n", "12 | \n", "2 | \n", "
5 rows \u00d7 7 columns
\n", "