Skip to content

Commit d8c9bf1

Browse files
committed
Update notebook outputs
1 parent 4544d7f commit d8c9bf1

File tree

4 files changed

+1670
-610
lines changed

4 files changed

+1670
-610
lines changed

notebooks/02/mad-portfolio-optimization.ipynb

Lines changed: 121 additions & 121 deletions
Large diffs are not rendered by default.

notebooks/06/optimal-growth-portfolios.ipynb

Lines changed: 1482 additions & 450 deletions
Large diffs are not rendered by default.

notebooks/09/economicdispatch.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"id": "kq1oXGHPbfFP"
77
},
88
"source": [
9-
"```{index} single: solver; cbc\n",
9+
"```{index} single: solver; highs\n",
1010
"```\n",
1111
"```{index} pandas dataframe\n",
1212
"```\n",

notebooks/09/markowitz_portfolio_with_chance_constraint.ipynb

Lines changed: 66 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
"cell_type": "markdown",
55
"id": "6b0b3c2f-3aaa-43fe-a8d0-2b696df5c1a6",
66
"metadata": {
7-
"tags": []
7+
"tags": [],
8+
"id": "6b0b3c2f-3aaa-43fe-a8d0-2b696df5c1a6"
89
},
910
"source": [
1011
"```{index} single: application; portfolio\n",
1112
"```\n",
1213
"```{index} single: application; investment\n",
1314
"```\n",
14-
"```{index} single: solver; highs\n",
15+
"```{index} single: solver; scip\n",
1516
"```\n",
1617
"```{index} chance constraints\n",
1718
"```\n",
@@ -23,9 +24,24 @@
2324
"execution_count": 1,
2425
"id": "5da22c67-5c34-4c3a-90a4-61222899e855",
2526
"metadata": {
26-
"tags": []
27+
"tags": [],
28+
"colab": {
29+
"base_uri": "https://localhost:8080/"
30+
},
31+
"id": "5da22c67-5c34-4c3a-90a4-61222899e855",
32+
"outputId": "22e416af-9eb0-4091-c467-7707e4465c8b"
2733
},
28-
"outputs": [],
34+
"outputs": [
35+
{
36+
"output_type": "stream",
37+
"name": "stdout",
38+
"text": [
39+
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/5.7 MB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91m━━━━\u001b[0m\u001b[90m╺\u001b[0m\u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.6/5.7 MB\u001b[0m \u001b[31m17.4 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[90m╺\u001b[0m\u001b[90m━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/5.7 MB\u001b[0m \u001b[31m49.4 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m \u001b[32m5.7/5.7 MB\u001b[0m \u001b[31m64.2 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.7/5.7 MB\u001b[0m \u001b[31m47.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
40+
"\u001b[?25hUsing default Community Edition License for Colab. Get yours at: https://ampl.com/ce\n",
41+
"Licensed to AMPL Community Edition License for the AMPL Model Colaboratory (https://ampl.com/colab).\n"
42+
]
43+
}
44+
],
2945
"source": [
3046
"# Install AMPL and solvers\n",
3147
"%pip install -q amplpy pandas numpy scipy\n",
@@ -45,7 +61,8 @@
4561
"execution_count": 2,
4662
"id": "b13edf26",
4763
"metadata": {
48-
"tags": []
64+
"tags": [],
65+
"id": "b13edf26"
4966
},
5067
"outputs": [],
5168
"source": [
@@ -59,18 +76,19 @@
5976
"id": "a82bd88d-7b16-4c82-b0b7-5dbd0d81b71c",
6077
"metadata": {
6178
"jp-MarkdownHeadingCollapsed": true,
62-
"tags": []
79+
"tags": [],
80+
"id": "a82bd88d-7b16-4c82-b0b7-5dbd0d81b71c"
6381
},
6482
"source": [
6583
"We consider here another variant of the Markowitz portfolio optimization problem, which we already encountered in the context of convex optimization [here](../05/markowitz_portfolio.ipynb) and in the context of conic optimization [here](../06/markowitz_portfolio_revisited.ipynb).\n",
6684
"\n",
6785
"Assuming there is an initial unit capital $C$ that needs to be invested in a selection of $n$ possible assets, each of them with a unknown return rate $r_i$, $i=1,\\dots,n$. Let $x$ be the vector whose $i$-th component $x_i$ describes the fraction of the capital invested in asset $i$. The return rate vector $r$ can be modelled by a multivariate Gaussian distribution with mean $\\mu$ and covariance $\\Sigma$. Assume there is also a risk-free asset with guaranteed return rate $R$ and let $\\tilde{x}$ the amount invested in that asset. We want to determine the portfolio that maximizes the _expected_ return $\\mathbb{E} ( R \\tilde{x} + r^\\top x )$, which in view of our assumptions rewrites as $ \\mathbb{E} ( R \\tilde{x} + r^\\top x ) = R \\tilde{x} + \\mu^\\top x$.\n",
6886
"\n",
69-
"Additionally, we includ a _loss risk chance constraint_ of the form \n",
87+
"Additionally, we includ a _loss risk chance constraint_ of the form\n",
7088
"\n",
7189
"$$\n",
7290
"\\mathbb{P} ( r^\\top x \\leq \\alpha) \\leq \\beta.\n",
73-
"$$ \n",
91+
"$$\n",
7492
"\n",
7593
"Thanks to the assumption that $r$ is multivariate Gaussian, this chance constraint can be equivalently rewritten as\n",
7694
"\n",
@@ -97,7 +115,9 @@
97115
"cell_type": "code",
98116
"execution_count": 3,
99117
"id": "1e9ef269",
100-
"metadata": {},
118+
"metadata": {
119+
"id": "1e9ef269"
120+
},
101121
"outputs": [],
102122
"source": [
103123
"# we import the inverse CDF or quantile function for the standard normal norm.ppf() from scipy.stats\n",
@@ -130,13 +150,19 @@
130150
"cell_type": "code",
131151
"execution_count": 4,
132152
"id": "3936f9b5",
133-
"metadata": {},
153+
"metadata": {
154+
"colab": {
155+
"base_uri": "https://localhost:8080/"
156+
},
157+
"id": "3936f9b5",
158+
"outputId": "d61cab63-9231-455b-9d02-5f66ea445ea0"
159+
},
134160
"outputs": [
135161
{
136-
"name": "stdout",
137162
"output_type": "stream",
163+
"name": "stdout",
138164
"text": [
139-
"Overwriting markowitz_chanceconstraints.mod\n"
165+
"Writing markowitz_chanceconstraints.mod\n"
140166
]
141167
}
142168
],
@@ -159,7 +185,7 @@
159185
"\n",
160186
"maximize expected_return:\n",
161187
" sum{i in N} mu[i] * x[i];\n",
162-
" \n",
188+
"\n",
163189
"subject to bounded_variance:\n",
164190
" phi_val * (sum{i in N, j in N} x[i] * Sigma[i, j] * x[j]) <= sum{i in N} mu[i] * x[i] - alpha;\n",
165191
"\n",
@@ -172,54 +198,53 @@
172198
"execution_count": 5,
173199
"id": "0e194e8d",
174200
"metadata": {
175-
"tags": []
201+
"tags": [],
202+
"colab": {
203+
"base_uri": "https://localhost:8080/",
204+
"height": 135
205+
},
206+
"id": "0e194e8d",
207+
"outputId": "02d0cc76-b727-484a-f973-c9fc2e406235"
176208
},
177209
"outputs": [
178210
{
179-
"name": "stdout",
180211
"output_type": "stream",
212+
"name": "stdout",
181213
"text": [
182-
"HiGHS 1.5.1: HiGHS 1.5.1: optimal solution; objective 1.229721418\n",
183-
"860 simplex iterations\n",
184-
"5 branching nodes\n",
185-
"absmipgap=8.14792e-06, relmipgap=6.62583e-06\n"
214+
"SCIP 9.0.1: WARNING: No dual information available when presolving was performed.\n",
215+
"\b\b\b\b\b\b\b\b\b\b\b\bSCIP 9.0.1: optimal solution; objective 1.232266138\n",
216+
"685 simplex iterations\n"
186217
]
187218
},
188219
{
220+
"output_type": "display_data",
189221
"data": {
190-
"text/markdown": [
191-
"**Solver result:** *solved*"
192-
],
193222
"text/plain": [
194223
"<IPython.core.display.Markdown object>"
195-
]
224+
],
225+
"text/markdown": "**Solver result:** *solved*"
196226
},
197-
"metadata": {},
198-
"output_type": "display_data"
227+
"metadata": {}
199228
},
200229
{
230+
"output_type": "display_data",
201231
"data": {
202-
"text/markdown": [
203-
"**Solution:** $\\tilde x = 0.000$, $x_1 = 0.797$, $x_2 = 0.203$, $x_3 = 0.000$"
204-
],
205232
"text/plain": [
206233
"<IPython.core.display.Markdown object>"
207-
]
234+
],
235+
"text/markdown": "**Solution:** $\\tilde x = 0.000$, $x_1 = 0.666$, $x_2 = 0.256$, $x_3 = 0.078$"
208236
},
209-
"metadata": {},
210-
"output_type": "display_data"
237+
"metadata": {}
211238
},
212239
{
240+
"output_type": "display_data",
213241
"data": {
214-
"text/markdown": [
215-
"**Maximizes objective value to:** $1.23$"
216-
],
217242
"text/plain": [
218243
"<IPython.core.display.Markdown object>"
219-
]
244+
],
245+
"text/markdown": "**Maximizes objective value to:** $1.23$"
220246
},
221-
"metadata": {},
222-
"output_type": "display_data"
247+
"metadata": {}
223248
}
224249
],
225250
"source": [
@@ -309,8 +334,11 @@
309334
"_Feature"
310335
],
311336
"window_display": false
337+
},
338+
"colab": {
339+
"provenance": []
312340
}
313341
},
314342
"nbformat": 4,
315343
"nbformat_minor": 5
316-
}
344+
}

0 commit comments

Comments
 (0)