469 lines
13 KiB
Plaintext
469 lines
13 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 18,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"import numpy as np\n",
|
|
"from datetime import datetime, timedelta"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 19,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#campaigns\n",
|
|
"init_date = datetime.now()\n",
|
|
"\n",
|
|
"campaigns = {1:{'name': 'ABC field test',\n",
|
|
" 'multiplier': 2.5,\n",
|
|
" 'min_raise': 984.0, \n",
|
|
" 'max_raise': 1260.0, \n",
|
|
" 'cutoff_date': init_date+timedelta(days=365*2/12.0),\n",
|
|
" 'expected_time': timedelta(days=365*8/12.0)},\n",
|
|
" 2:{'name': 'Giveth field test',\n",
|
|
" 'multiplier': 2.0,\n",
|
|
" 'min_raise': 726.0, \n",
|
|
" 'max_raise': 940.0, \n",
|
|
" 'cutoff_date': init_date+timedelta(days=365*4/12),\n",
|
|
" 'expected_time': timedelta(days=365*6/12.0)},\n",
|
|
" 3:{'name': 'CV field test',\n",
|
|
" 'multiplier': 1.5,\n",
|
|
" 'min_raise': 1140.0, \n",
|
|
" 'max_raise': 1460.0, \n",
|
|
" 'cutoff_date': init_date+timedelta(days=365*6/12),\n",
|
|
" 'expected_time': timedelta(days=365*12/12)},\n",
|
|
" 4:{'name': 'Analytics',\n",
|
|
" 'multiplier': 1.25,\n",
|
|
" 'min_raise': 780.0, \n",
|
|
" 'max_raise': 975.0, \n",
|
|
" 'cutoff_date': init_date+timedelta(days=365*4/12.0),\n",
|
|
" 'expected_time': timedelta(days=365*16/12.0)},\n",
|
|
" 5:{'name': 'Mobile first',\n",
|
|
" 'multiplier': 1.125,\n",
|
|
" 'min_raise': 1610.0, \n",
|
|
" 'max_raise': 2010.0, \n",
|
|
" 'cutoff_date': init_date+timedelta(days=365*8/12.0),\n",
|
|
" 'expected_time': timedelta(days=365*24/12.0)},\n",
|
|
" 6:{'name': 'Easy Deploy',\n",
|
|
" 'multiplier': 1.0,\n",
|
|
" 'min_raise': 1500.0, \n",
|
|
" 'max_raise': 1875.0, \n",
|
|
" 'cutoff_date': init_date+timedelta(days=365*6/12.0),\n",
|
|
" 'expected_time': timedelta(days=365*30/12.0)},\n",
|
|
" \n",
|
|
"}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 20,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"1875.0"
|
|
]
|
|
},
|
|
"execution_count": 20,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"1500*1.25"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 28,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"total_min = sum([campaigns[i]['min_raise'] for i in campaigns.keys()])\n",
|
|
"total_max = sum([campaigns[i]['max_raise'] for i in campaigns.keys()])\n",
|
|
"\n",
|
|
"total_first3_at_max = sum([campaigns[i]['max_raise'] for i in campaigns.keys()if i<4] )\n",
|
|
"total_first3_at_min = sum([campaigns[i]['min_raise'] for i in campaigns.keys()if i<4] )\n",
|
|
"total_first4_at_min = sum([campaigns[i]['min_raise'] for i in campaigns.keys()if i<5] )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 22,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"smallest outcome: 6740.0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"smallest outcome: \"+str(total_min))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 23,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"largest outcome: 8520.0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"largest outcome: \"+str(total_max))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 24,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"outcome at first 3 full amount: 3660.0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"outcome at first 3 full amount: \"+str(total_first3_at_max))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 29,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"buffer for first 3 given first 3 full amount: 1.2842105263157895\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"buffer for first 3 given first 3 full amount: \"+str(total_first3_at_max/total_first3_at_min))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 25,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"share of total budget covered by capping first 3: 0.543026706231454\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"share of total budget covered by capping first 3: \"+str(total_first3_at_max/total_min))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 26,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"share of 4 iteration budget covered by capping first 3: 1.0082644628099173\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"share of 4 iteration budget covered by capping first 3: \"+str(total_first3_at_max/total_first4_at_min))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 30,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"multi_mins = [campaigns[i]['multiplier']*campaigns[i]['min_raise'] for i in campaigns.keys()]\n",
|
|
"multi_maxs = [campaigns[i]['multiplier']*campaigns[i]['max_raise'] for i in campaigns.keys()]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 36,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"[2460.0, 1452.0, 1710.0, 975.0, 1811.25, 1500.0]"
|
|
]
|
|
},
|
|
"execution_count": 36,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"multi_mins"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 38,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"hatch allocations after first 3 at min:4286.25\n",
|
|
"hatch allocations after first 6 at min:9908.25\n",
|
|
"hatch allocations after first 3 at max:5355.0\n",
|
|
"hatch allocations after first 6 at max:12575.0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"#hatch allocations after first 3 at min\n",
|
|
"print(\"hatch allocations after first 3 at min:\"+str(sum(multi_mins[3:])) )\n",
|
|
"\n",
|
|
"#hatch allocations after all 6 at min\n",
|
|
"print(\"hatch allocations after first 6 at min:\"+str(sum(multi_mins)) )\n",
|
|
"\n",
|
|
"#hatch allocations after first 3 at max\n",
|
|
"print(\"hatch allocations after first 3 at max:\"+str(sum(multi_maxs[3:])) )\n",
|
|
"\n",
|
|
"#hatch allocations after all 6 at max\n",
|
|
"print(\"hatch allocations after first 6 at max:\"+str(sum(multi_maxs)) )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{1: {'cutoff_date': datetime.datetime(2019, 9, 24, 7, 21, 10, 221483),\n",
|
|
" 'expected_time': datetime.timedelta(243, 28800),\n",
|
|
" 'max_raise': 1500.0,\n",
|
|
" 'min_raise': 984.0,\n",
|
|
" 'multiplier': 2.5,\n",
|
|
" 'name': 'ABC field test'},\n",
|
|
" 2: {'cutoff_date': datetime.datetime(2019, 11, 24, 3, 21, 10, 221483),\n",
|
|
" 'expected_time': datetime.timedelta(182, 43200),\n",
|
|
" 'max_raise': 1500.0,\n",
|
|
" 'min_raise': 726.0,\n",
|
|
" 'multiplier': 2.0,\n",
|
|
" 'name': 'Giveth field test'},\n",
|
|
" 3: {'cutoff_date': datetime.datetime(2020, 1, 23, 23, 21, 10, 221483),\n",
|
|
" 'expected_time': datetime.timedelta(365),\n",
|
|
" 'max_raise': 2000.0,\n",
|
|
" 'min_raise': 1140.0,\n",
|
|
" 'multiplier': 1.5,\n",
|
|
" 'name': 'CV field test'},\n",
|
|
" 4: {'cutoff_date': datetime.datetime(2019, 11, 24, 3, 21, 10, 221483),\n",
|
|
" 'expected_time': datetime.timedelta(486, 57600),\n",
|
|
" 'max_raise': 1500.0,\n",
|
|
" 'min_raise': 780.0,\n",
|
|
" 'multiplier': 1.25,\n",
|
|
" 'name': 'Analytics'},\n",
|
|
" 5: {'cutoff_date': datetime.datetime(2020, 3, 24, 19, 21, 10, 221483),\n",
|
|
" 'expected_time': datetime.timedelta(730),\n",
|
|
" 'max_raise': 2500.0,\n",
|
|
" 'min_raise': 1610.0,\n",
|
|
" 'multiplier': 1.125,\n",
|
|
" 'name': 'Mobile first'},\n",
|
|
" 6: {'cutoff_date': datetime.datetime(2020, 1, 23, 23, 21, 10, 221483),\n",
|
|
" 'expected_time': datetime.timedelta(912, 43200),\n",
|
|
" 'max_raise': 3000.0,\n",
|
|
" 'min_raise': 1500.0,\n",
|
|
" 'multiplier': 1.0,\n",
|
|
" 'name': 'Easy Deploy'}}"
|
|
]
|
|
},
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"campaigns"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"tranches = { tr:{'raised':0, 'status':'not_started'} for tr in range(2,7)}\n",
|
|
"tranches[1] = {'raised':0, 'status':'active'}\n",
|
|
"state = {'new_raised':0,'total_raised': 0, 'active_tranche':1,'tranches': tranches}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'active_tranche': 1,\n",
|
|
" 'new_raised': 0,\n",
|
|
" 'total_raised': 0,\n",
|
|
" 'tranches': {1: {'raised': 0, 'status': 'active'},\n",
|
|
" 2: {'raised': 0, 'status': 'not_started'},\n",
|
|
" 3: {'raised': 0, 'status': 'not_started'},\n",
|
|
" 4: {'raised': 0, 'status': 'not_started'},\n",
|
|
" 5: {'raised': 0, 'status': 'not_started'},\n",
|
|
" 6: {'raised': 0, 'status': 'not_started'}}}"
|
|
]
|
|
},
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"state"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"T = 52*3\n",
|
|
"dt = timedelta(weeks =1)\n",
|
|
"\n",
|
|
"def gen_raise(thresh = .3, scale = 10):\n",
|
|
" rv = np.random.rand()\n",
|
|
" if rv < thresh:\n",
|
|
" return 0\n",
|
|
" else :\n",
|
|
" return rv*scale"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<img src=\"camp_logics.png\">"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "IndentationError",
|
|
"evalue": "expected an indented block (<ipython-input-12-88028d8e562f>, line 12)",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-12-88028d8e562f>\"\u001b[0;36m, line \u001b[0;32m12\u001b[0m\n\u001b[0;31m elif week > campaigns[ct]['cutoff_date']:\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m expected an indented block\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"#to be written to match the logic in the image above \n",
|
|
"def tranche_iter_logic(week, state):\n",
|
|
" \n",
|
|
" ct = state['active_tranche']\n",
|
|
" \n",
|
|
" ct_data = state['tranches'][ct]\n",
|
|
" \n",
|
|
" #is the deadline passed:\n",
|
|
" if ct_data['raised'] > ct_data['max_raise']:\n",
|
|
" \n",
|
|
" \n",
|
|
" elif week > campaigns[ct]['cutoff_date']:\n",
|
|
" \n",
|
|
" #is the cap reached\n",
|
|
" elif :\n",
|
|
" \n",
|
|
" \n",
|
|
" \n",
|
|
" return "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"tranch_status"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# generate a simulation so what happens!\n",
|
|
"states = [state]\n",
|
|
"for t in range(T):\n",
|
|
" new_raise = gen_raise()\n",
|
|
" state['new_raised'] = new_raise\n",
|
|
" state['total_raised'] = state['total_raised'] + new_raise\n",
|
|
" \n",
|
|
" #\n",
|
|
" "
|
|
]
|
|
},
|
|
{
|
|
"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.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|