cadCAD/simulations/validation/robot-marbles-agents-advanc...

1618 lines
86 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# cadCAD Tutorials: The Robot and the Marbles, Networks Addition\n",
"In [Part 2](https://github.com/BlockScience/SimCAD-Tutorials/blob/master/demos/robot-marbles-part-2/robot-marbles-part-2.ipynb) we introduced the 'language' in which a system must be described in order for it to be interpretable by cadCAD and some of the basic concepts of the library:\n",
"* State Variables\n",
"* Timestep\n",
"* Policies\n",
"* State Update Functions\n",
"* Partial State Update Blocks\n",
"* Simulation Configuration Parameters\n",
"\n",
"In the previous example, we observed how two robotic arms acting in parallel could result in counterintuitive system level behavior despite the simplicity of the individual robotic arm policies. \n",
"In this notebook we'll introduce the concept of networks. This done by extending from two boxes of marbles to *n* boxes which are the nodes in our network. Furthermore, there are are going to be arms between some of the boxes but not others forming a network where the arms are the edges.\n",
"\n",
"__The robot and the marbles__ \n",
"* Picture a set of n boxes (`balls`) with an integer number of marbles in each; a network of robotic arms is capable of taking a marble from their one of their boxes and dropping it into the other one.\n",
"* Each robotic arm in the network only controls 2 boxes and they act by moving a marble from one box to the other.\n",
"* Each robotic arm is programmed to take one marble at a time from the box containing the largest number of marbles and drop it in the other box. It repeats that process until the boxes contain an equal number of marbles.\n",
"* For the purposes of our analysis of this system, suppose we are only interested in monitoring the number of marbles in only their two boxes."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from cadCAD.engine import ExecutionMode, ExecutionContext, Executor\n",
"from cadCAD.configuration import Configuration\n",
"from cadCAD.configuration.utils.userDefinedObject import udoPipe, UDO\n",
"import networkx as nx\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"%matplotlib inline\n",
"\n",
"T = 50 #iterations in our simulation\n",
"n=3 #number of boxes in our network\n",
"m= 2 #for barabasi graph type number of edges is (n-2)*m\n",
"\n",
"G = nx.barabasi_albert_graph(n, m)\n",
"k = len(G.edges)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"balls = np.zeros(n,)\n",
"\n",
"for node in G.nodes:\n",
" rv = np.random.randint(1,25)\n",
" G.nodes[node]['initial_balls'] = rv\n",
" balls[node] = rv"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAcUAAAE1CAYAAACWU/udAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XlcVXX+P/DXOefeyyKbuAAuCEoqcAFlE3cpremr2TJWptZUI8oFNUvbm+93WiZtcilTriZT09hM5UxaaVOZSy4FgQvCBXXKNc0VBNnvdn5/RP6mmZILnHvPvZfX8/Hojwg+59Uf9/Hi/eGczxFkWZZBREREENUOQERE5C5YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC1YikRERC00agew22VUnLuCstM12HuyCvtPVePClSZY7DIgA1pJQGgXHZL6hiA9KhT63sFI6B0MrcQ+JyIiZQmyLMtqXPhyvRnv7f0Of9pzHA1mK+wy0GixXfNnfLUiNKIIUQDuzeiHezOiEB7s66LERETk7VxeilX1Zjy3uQKfmM5CEIAmi71d6/hoRMgARg7ohhduS0DvED9lgxIRUafj0lL8tPwcHv3HQTRZbLDYlLmsJArQSSKemRiLaemREARBkXWJiKjzcUkp1jVb8fB7Jdjz7aVWt0jby08rIS4iCKtnpKBHoI9TrkFERN7N6aV4ud6Mu14vwMmqBpit7dsqdZRGFNCtiw7vG0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IkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJqwVIkIiJq8f8AvXS47PErPO4AAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"scale=100\n",
"nx.draw_kamada_kawai(G, node_size=balls*scale,labels=nx.get_node_attributes(G,'initial_balls'))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"initial_conditions = {'balls':balls, 'network':G}"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"#input the deltas along the edges and update the boxes\n",
"#mechanism: edge by node dimensional operator\n",
"# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \n",
"# We make the state update functions less \"intelligent\",\n",
"# ie. they simply add the number of marbles specified in _input \n",
"# (which, per the policy function definition, may be negative)\n",
"\n",
"\n",
"def update_balls(params, step, sL, s, _input):\n",
" \n",
" delta_balls = _input['delta']\n",
" new_balls = s['balls']\n",
" for e in G.edges:\n",
" move_ball = delta_balls[e]\n",
" src = e[0]\n",
" dst = e[1]\n",
" if (new_balls[src] >= move_ball) and (new_balls[dst] >= -move_ball):\n",
" new_balls[src] = new_balls[src]-move_ball\n",
" new_balls[dst] = new_balls[dst]+move_ball\n",
" \n",
" \n",
" key = 'balls'\n",
" value = new_balls\n",
" \n",
" return (key, value)\n",
"\n",
"def update_network(params, step, sL, s, _input):\n",
" \n",
" new_nodes = _input['nodes']\n",
" new_edges = _input['edges']\n",
" new_balls = _input['quantity']\n",
" \n",
" graph = s['network']\n",
" \n",
" for node in new_nodes:\n",
" graph.add_node(node)\n",
" graph.nodes[node]['initial_balls'] = new_balls[node]\n",
" graph.nodes[node]['strat'] = _input['node_strats'][node]\n",
" \n",
" for edge in new_edges:\n",
" graph.add_edge(edge[0], edge[1])\n",
" graph.edges[edge]['strat'] = _input['edge_strats'][edge]\n",
" \n",
" \n",
" key = 'network'\n",
" value = graph\n",
" return (key, value)\n",
"\n",
"def update_network_balls(params, step, sL, s, _input):\n",
" \n",
" new_nodes = _input['nodes']\n",
" new_balls = _input['quantity']\n",
" balls = np.zeros(len(s['balls'])+len(new_nodes))\n",
" \n",
" for node in s['network'].nodes:\n",
" balls[node] = s['balls'][node]\n",
" \n",
" for node in new_nodes:\n",
" balls[node] = new_balls[node]\n",
" \n",
" key = 'balls'\n",
" value = balls\n",
" \n",
" return (key, value)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# this time lets make three kinds of robots\n",
"\n",
"def greedy_robot(src_balls, dst_balls):\n",
" \n",
" #robot wishes to accumlate balls at its source\n",
" #takes half of its neighbors balls\n",
" if src_balls < dst_balls:\n",
" delta = -np.floor(dst_balls/2)\n",
" else:\n",
" delta = 0\n",
" \n",
" return delta\n",
"\n",
"def fair_robot(src_balls, dst_balls):\n",
" \n",
" #robot follows the simple balancing rule\n",
" delta = np.sign(src_balls-dst_balls)\n",
" \n",
" return delta\n",
"\n",
"\n",
"def giving_robot(src_balls, dst_balls):\n",
" \n",
" #robot wishes to gice away balls one at a time\n",
" if src_balls > 0:\n",
" delta = 1\n",
" else:\n",
" delta = 0\n",
" \n",
" return delta"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"#in the previous version the robots were assigned to the edges\n",
"#moving towards an agent based model formulation we assign the stratgies\n",
"#instead to the nodes\n",
"robot_strategies = [greedy_robot,fair_robot, giving_robot]\n",
"\n",
"for node in G.nodes:\n",
" nstrats = len(robot_strategies)\n",
" rv = np.random.randint(0,nstrats)\n",
" G.nodes[node]['strat'] = robot_strategies[rv]\n",
"\n",
"for e in G.edges:\n",
" owner_node = e[0]\n",
" G.edges[e]['strat'] = G.nodes[owner_node]['strat']"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"#Policy: node by edge dimensional operator\n",
"#input the states of the boxes output the deltas along the edges\n",
"# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \n",
"# We specify the robotic networks logic in a Policy Function\n",
"# unlike previous examples our policy controls a vector valued action, defined over the edges of our network\n",
"def robotic_network(params, step, sL, s):\n",
" \n",
" graph = s['network']\n",
" \n",
" \n",
" delta_balls = {}\n",
" for e in graph.edges:\n",
" src = e[0]\n",
" src_balls = s['balls'][src]\n",
" dst = e[1]\n",
" dst_balls = s['balls'][dst]\n",
" \n",
" #transfer balls according to specific robot strat\n",
" strat = graph.edges[e]['strat']\n",
" delta_balls[e] = strat(src_balls,dst_balls)\n",
" \n",
" return_dict = {'nodes': [],'edges': {}, 'quantity': {}, 'node_strats':{},'edge_strats':{},'delta': delta_balls}\n",
"\n",
" return(return_dict)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"def agent_arrival(params, step, sL, s):\n",
" \n",
" node= len(s['network'].nodes)\n",
" edge_list = s['network'].edges\n",
" \n",
" #choose a m random edges without replacement\n",
" #new = np.random.choose(edgelist,m) \n",
" new = [0, 1]#tester\n",
" \n",
" nodes = [node]\n",
" edges = [(node,new_node) for new_node in new]\n",
" \n",
" initial_balls = {node:np.random.randint(1,25) }\n",
" \n",
" rv = np.random.randint(0,nstrats)\n",
" node_strat = {node: robot_strategies[rv]}\n",
" \n",
" edge_strats = {e: robot_strategies[rv] for e in edges}\n",
"\n",
" return_dict = {'nodes': nodes,\n",
" 'edges': edges, \n",
" 'quantity':initial_balls, \n",
" 'node_strats':node_strat,\n",
" 'edge_strats':edge_strats,\n",
" 'delta': np.zeros(node+1)\n",
" } \n",
" return(return_dict)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \n",
"# In the Partial State Update Blocks, the user specifies if state update functions will be run in series or in parallel\n",
"partial_state_update_blocks = [\n",
" { \n",
" 'policies': { # The following policy functions will be evaluated and their returns will be passed to the state update functions\n",
" 'p1': robotic_network\n",
" },\n",
" 'variables': { # The following state variables will be updated simultaneously\n",
" 'balls': update_balls\n",
" \n",
" }\n",
" },\n",
" {\n",
" 'policies': { # The following policy functions will be evaluated and their returns will be passed to the state update functions\n",
" 'p1': agent_arrival\n",
" },\n",
" 'variables': { # The following state variables will be updated simultaneously\n",
" 'network': update_network,\n",
" 'balls': update_network_balls\n",
" }\n",
" }\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \n",
"# Settings of general simulation parameters, unrelated to the system itself\n",
"# `T` is a range with the number of discrete units of time the simulation will run for;\n",
"# `N` is the number of times the simulation will be run (Monte Carlo runs)\n",
"# In this example, we'll run the simulation once (N=1) and its duration will be of 10 timesteps\n",
"# We'll cover the `M` key in a future article. For now, let's leave it empty\n",
"simulation_parameters = {\n",
" 'T': range(T),\n",
" 'N': 1,\n",
" 'M': {}\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \n",
"# The configurations above are then packaged into a `Configuration` object\n",
"config = Configuration(initial_state=initial_conditions, #dict containing variable names and initial values\n",
" partial_state_update_blocks=partial_state_update_blocks, #dict containing state update functions\n",
" sim_config=simulation_parameters #dict containing simulation parameters\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"single_proc: [<cadCAD.configuration.Configuration object at 0x1017d5edd8>]\n"
]
}
],
"source": [
"exec_mode = ExecutionMode()\n",
"exec_context = ExecutionContext(exec_mode.single_proc)\n",
"executor = Executor(exec_context, [config]) # Pass the configuration object inside an array\n",
"raw_result, tensor = executor.main() # The `main()` method returns a tuple; its first elements contains the raw results"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(raw_result)\n",
"balls_list = [b for b in df.balls]"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>balls</th>\n",
" <th>network</th>\n",
" <th>run</th>\n",
" <th>substep</th>\n",
" <th>timestep</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>[13.0, 16.0, 24.0]</td>\n",
" <td>(0, 1, 2)</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>[25.0, 15.0, 13.0]</td>\n",
" <td>(0, 1, 2, 3)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>[25.0, 15.0, 13.0, 10.0]</td>\n",
" <td>(0, 1, 2, 3)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>[25.0, 14.0, 14.0, 10.0]</td>\n",
" <td>(0, 1, 2, 3, 4)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>[25.0, 14.0, 14.0, 10.0, 9.0]</td>\n",
" <td>(0, 1, 2, 3, 4)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>[25.0, 13.0, 15.0, 10.0, 9.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>[25.0, 13.0, 15.0, 10.0, 9.0, 24.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>[25.0, 12.0, 16.0, 10.0, 9.0, 24.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>[25.0, 12.0, 16.0, 10.0, 9.0, 24.0, 14.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>[25.0, 11.0, 17.0, 10.0, 9.0, 24.0, 14.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>[25.0, 11.0, 17.0, 10.0, 9.0, 24.0, 14.0, 5.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>[25.0, 10.0, 18.0, 10.0, 9.0, 24.0, 14.0, 5.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>[25.0, 10.0, 18.0, 10.0, 9.0, 24.0, 14.0, 5.0,...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>[25.0, 9.0, 19.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>[25.0, 9.0, 19.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>[25.0, 8.0, 20.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>[25.0, 8.0, 20.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>[25.0, 7.0, 21.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>[25.0, 7.0, 21.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>[25.0, 6.0, 22.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>[25.0, 6.0, 22.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>[25.0, 5.0, 23.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>[25.0, 5.0, 23.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>[25.0, 4.0, 24.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>[25.0, 4.0, 24.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>[25.0, 3.0, 25.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>[25.0, 3.0, 25.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>[25.0, 2.0, 26.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>[25.0, 2.0, 26.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>[38.0, 1.0, 14.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>71</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>36</td>\n",
" </tr>\n",
" <tr>\n",
" <th>72</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>36</td>\n",
" </tr>\n",
" <tr>\n",
" <th>73</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>37</td>\n",
" </tr>\n",
" <tr>\n",
" <th>74</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>37</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>76</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>77</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>39</td>\n",
" </tr>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>39</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>41</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>41</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>43</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>43</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>89</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>45</td>\n",
" </tr>\n",
" <tr>\n",
" <th>90</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>45</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>92</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>93</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>47</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>47</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>96</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>97</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>49</td>\n",
" </tr>\n",
" <tr>\n",
" <th>98</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>49</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>50</td>\n",
" </tr>\n",
" <tr>\n",
" <th>100</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>50</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>101 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>balls</th>\n",
" <th>network</th>\n",
" <th>run</th>\n",
" <th>substep</th>\n",
" <th>timestep</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>[13.0, 16.0, 24.0]</td>\n",
" <td>(0, 1, 2)</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>[25.0, 15.0, 13.0]</td>\n",
" <td>(0, 1, 2, 3)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>[25.0, 15.0, 13.0, 10.0]</td>\n",
" <td>(0, 1, 2, 3)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>[25.0, 14.0, 14.0, 10.0]</td>\n",
" <td>(0, 1, 2, 3, 4)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>[25.0, 14.0, 14.0, 10.0, 9.0]</td>\n",
" <td>(0, 1, 2, 3, 4)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>[25.0, 13.0, 15.0, 10.0, 9.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>[25.0, 13.0, 15.0, 10.0, 9.0, 24.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>[25.0, 12.0, 16.0, 10.0, 9.0, 24.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>[25.0, 12.0, 16.0, 10.0, 9.0, 24.0, 14.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>[25.0, 11.0, 17.0, 10.0, 9.0, 24.0, 14.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>[25.0, 11.0, 17.0, 10.0, 9.0, 24.0, 14.0, 5.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>[25.0, 10.0, 18.0, 10.0, 9.0, 24.0, 14.0, 5.0]</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>[25.0, 10.0, 18.0, 10.0, 9.0, 24.0, 14.0, 5.0,...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>[25.0, 9.0, 19.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>[25.0, 9.0, 19.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>[25.0, 8.0, 20.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>[25.0, 8.0, 20.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>[25.0, 7.0, 21.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>[25.0, 7.0, 21.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>[25.0, 6.0, 22.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>[25.0, 6.0, 22.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>[25.0, 5.0, 23.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>[25.0, 5.0, 23.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>[25.0, 4.0, 24.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>[25.0, 4.0, 24.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>[25.0, 3.0, 25.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>[25.0, 3.0, 25.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>[25.0, 2.0, 26.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>[25.0, 2.0, 26.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>[38.0, 1.0, 14.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>71</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>36</td>\n",
" </tr>\n",
" <tr>\n",
" <th>72</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>36</td>\n",
" </tr>\n",
" <tr>\n",
" <th>73</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>37</td>\n",
" </tr>\n",
" <tr>\n",
" <th>74</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>37</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>76</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>77</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>39</td>\n",
" </tr>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>39</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>41</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>41</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>43</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>43</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>89</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>45</td>\n",
" </tr>\n",
" <tr>\n",
" <th>90</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>45</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>92</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>93</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>47</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>47</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>96</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>97</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>49</td>\n",
" </tr>\n",
" <tr>\n",
" <th>98</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>49</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>50</td>\n",
" </tr>\n",
" <tr>\n",
" <th>100</th>\n",
" <td>[38.0, 0.0, 15.0, 10.0, 9.0, 24.0, 14.0, 5.0, ...</td>\n",
" <td>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>50</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>101 rows × 5 columns</p>\n",
"</div>"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"ename": "ValueError",
"evalue": "setting an array element with a sequence.",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-17-14985419ff14>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtimestep\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mballs_list\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mxlabel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'iteration'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mylabel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'number of balls'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtitle\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'balls in each box'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlegend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Box #'\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnode\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mnode\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mncol\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/pyplot.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 3356\u001b[0m mplDeprecation)\n\u001b[1;32m 3357\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3358\u001b[0;31m \u001b[0mret\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0max\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3359\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3360\u001b[0m \u001b[0max\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_hold\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mwashold\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/__init__.py\u001b[0m in \u001b[0;36minner\u001b[0;34m(ax, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1853\u001b[0m \u001b[0;34m\"the Matplotlib list!)\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mlabel_namer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1854\u001b[0m RuntimeWarning, stacklevel=2)\n\u001b[0;32m-> 1855\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0max\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1856\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1857\u001b[0m inner.__doc__ = _add_data_doc(inner.__doc__,\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_axes.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1526\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1527\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mline\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_lines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1528\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd_line\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1529\u001b[0m \u001b[0mlines\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1530\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_base.py\u001b[0m in \u001b[0;36madd_line\u001b[0;34m(self, line)\u001b[0m\n\u001b[1;32m 1930\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_clip_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpatch\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1931\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1932\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_update_line_limits\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1933\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_label\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1934\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_label\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'_line%d'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlines\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_base.py\u001b[0m in \u001b[0;36m_update_line_limits\u001b[0;34m(self, line)\u001b[0m\n\u001b[1;32m 1952\u001b[0m \u001b[0mFigures\u001b[0m \u001b[0mout\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mdata\u001b[0m \u001b[0mlimit\u001b[0m \u001b[0mof\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mgiven\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mupdating\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataLim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1953\u001b[0m \"\"\"\n\u001b[0;32m-> 1954\u001b[0;31m \u001b[0mpath\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1955\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvertices\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1956\u001b[0m \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/lines.py\u001b[0m in \u001b[0;36mget_path\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 949\u001b[0m \"\"\"\n\u001b[1;32m 950\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_invalidy\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_invalidx\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 951\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecache\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 952\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_path\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 953\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/lines.py\u001b[0m in \u001b[0;36mrecache\u001b[0;34m(self, always)\u001b[0m\n\u001b[1;32m 655\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0malways\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_invalidy\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 656\u001b[0m \u001b[0myconv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconvert_yunits\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_yorig\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 657\u001b[0;31m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_to_unmasked_float_array\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0myconv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mravel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 658\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 659\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_y\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/cbook/__init__.py\u001b[0m in \u001b[0;36m_to_unmasked_float_array\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 2048\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfilled\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnan\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2049\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2050\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2051\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2052\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/numeric.py\u001b[0m in \u001b[0;36masarray\u001b[0;34m(a, dtype, order)\u001b[0m\n\u001b[1;32m 490\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 491\u001b[0m \"\"\"\n\u001b[0;32m--> 492\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0morder\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 493\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 494\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mValueError\u001b[0m: setting an array element with a sequence."
],
"output_type": "error"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAADU9JREFUeJzt3GGI5Hd9x/H3xztTaYym9FaQu9Ok9NJ42ELSJU0Raoq2XPLg7oFF7iBYJXhgGylVhBRLlPjIhloQrtWTilXQGH0gC57cA40ExAu3ITV4FyLb03oXhawxzZOgMe23D2bSna53mX92Z3cv+32/4GD+//ntzJcfe++dndmZVBWSpO3vFVs9gCRpcxh8SWrC4EtSEwZfkpow+JLUhMGXpCamBj/JZ5M8meT7l7g+ST6ZZCnJo0lunP2YkqT1GvII/3PAgRe5/lZg3/jfUeBf1j+WJGnWpga/qh4Efv4iSw4Bn6+RU8DVSV4/qwElSbOxcwa3sRs4P3F8YXzup6sXJjnK6LcArrzyyj+8/vrrZ3D3ktTHww8//LOqmlvL184i+INV1XHgOMD8/HwtLi5u5t1L0stekv9c69fO4q90ngD2ThzvGZ+TJF1GZhH8BeBd47/WuRl4pqp+7ekcSdLWmvqUTpIvAbcAu5JcAD4Cv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k+B3xxffl/nvRivuwp4EDgFzG/13Fv4fbEPeAT4rfHx67Z67i3ci+PA+8aX9wM/2uq5N2gv/gS4Efj+Ja6/DfgGEOBm4KEht7vRj/D9WIYVU/eiqh6oqmfHh6cYvedhOxryfQHwMUafy/SLzRxukw3Zi/cCx6rqaYCqenKTZ9wsQ/aigNeML78W+MkmzrdpqupBRn/xeCmHgM/XyCng6iSvn3a7Gx38i30sw+5Lramq54EXPpZhuxmyF5PuYPQTfDuauhfjX1H3VtXXN3OwLTDk++I64Lok30lyKsmBTZtucw3Zi48Ctye5AJwA3r85o112XmpPgE3+aAUNk+R2YB5461bPshWSvAL4BPDuLR7lcrGT0dM6tzD6re/BJL9fVf+1pVNtjSPA56rqH5P8MaP3/7y5qv5nqwd7OdjoR/h+LMOKIXtBkrcDHwYOVtUvN2m2zTZtL64C3gx8O8mPGD1HubBNX7gd8n1xAVioql9V1Q+BHzD6AbDdDNmLO4D7Aarqu8CrGH2wWjeDerLaRgffj2VYMXUvktwAfJpR7Lfr87QwZS+q6pmq2lVV11TVNYxezzhYVWv+0KjL2JD/I19j9OieJLsYPcVzbjOH3CRD9uLHwNsAkryJUfCXN3XKy8MC8K7xX+vcDDxTVT+d9kUb+pRObdzHMrzsDNyLe4FXA18Zv27946o6uGVDb5CBe9HCwL04Cfx5krPAfwMfqqpt91vwwL34IPCZJH/L6AXcd2/HB4hJvsToh/yu8esVHwFeCVBVn2L0+sVtwBLwLPCeQbe7DfdKknQRvtNWkpow+JLUhMGXpCYMviQ1YfAlqQmDL0lNGHxJauJ/Acz2XLpusNoKAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(df.timestep.values, balls_list)\n",
"plt.xlabel('iteration')\n",
"plt.ylabel('number of balls')\n",
"plt.title('balls in each box')\n",
"plt.legend(['Box #'+str(node) for node in range(n)], ncol = 2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"end_state_balls = np.array([b for b in balls_list[-1]])\n",
"avg_balls = np.array([np.mean(b) for b in balls_list])\n",
"\n",
"for node in G.nodes:\n",
" G.nodes[node]['final_balls'] = end_state_balls[node]\n",
" G.nodes[node]['avg_balls'] = avg_balls[node]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cmap = plt.cm.jet\n",
"Nc = cmap.N\n",
"Ns = len(robot_strategies)\n",
"d = int(Nc/Ns)\n",
"\n",
"k = len(G.edges)\n",
"strat_color = []\n",
"for e in G.edges:\n",
" \n",
" for i in range(Ns):\n",
" if G.edges[e]['strat']==robot_strategies[i]:\n",
" color = cmap(i*d)\n",
" G.edges[e]['color'] = color\n",
" strat_color = strat_color+[color]\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"nx.draw_kamada_kawai(G, node_size=end_state_balls*scale, labels=nx.get_node_attributes(G,'final_balls'), edge_color=strat_color)\n",
"print(end_state_balls)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rolling_avg_balls = np.zeros((T+1, n))\n",
"for t in range(T+1):\n",
" for node in G.nodes:\n",
" for tau in range(t):\n",
" rolling_avg_balls[t,node] = (tau)/(tau+1)*rolling_avg_balls[t, node]+ 1/(tau+1)*balls_list[tau][node]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.plot(range(len(rolling_avg_balls)),rolling_avg_balls)\n",
"plt.xlabel('iteration')\n",
"plt.ylabel('number of balls')\n",
"plt.title('time average balls in each box')\n",
"plt.legend(['Box #'+str(node) for node in range(n)], ncol = 2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for node in G.nodes:\n",
" G.nodes[node]['avg_balls'] = int(10*(rolling_avg_balls[node][-1]))/10\n",
"\n",
"nx.draw_kamada_kawai(G, node_size=avg_balls*scale, labels=nx.get_node_attributes(G,'avg_balls'))\n",
"print(end_state_balls)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cmap = plt.cm.jet\n",
"Nc = cmap.N\n",
"Nt = len(simulation_parameters['T'])\n",
"dN = int(Nc/Nt)\n",
"cmaplist = [cmap(i*dN) for i in range(Nt)]\n",
"\n",
"for t in simulation_parameters['T']:\n",
" state = np.array([b for b in balls_list[t]])\n",
" nx.draw_kamada_kawai(G, node_size=state*scale, alpha = .4/(t+1), node_color = cmaplist[t])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}