operations_research/OR_HTML_04/bruecke.html

813 lines
96 KiB
HTML
Raw Normal View History

Version 04 als eigenes Repository Erster Commit des Strangs "Optimierte Entscheidungsfindung mit Python" (Version 04). Die Historie der 71 Commits bis zur Trennung bleibt im uebergeordneten Repository OR_mit_Python liegen, das ab jetzt nur noch Version_03 (eingefroren) verwaltet und Version_04/ ignoriert. Bewusst kein "git subtree split": Der Pfad Version_04/ existiert erst seit der Verzeichnistrennung, ein Split braechte daher nur 7 der 41 einschlaegigen Commits - eine Teilhistorie, die vollstaendig aussieht und es nicht ist. Stand: 5 Teile, 23 Kapitel, 5 Anhaenge, 292 Abschnitte, 703 Querverweise, 325 Indexmarken, 73 Beispielprogramme, 32 SVGs, 4 Plotly-Figuren, 25 Notebooks, PDF mit 715 Seiten. Zusaetzlich in diesem Commit: * pyproject.toml mit Abhaengigkeitsgruppen finance, large-scale, api, figures, dev, empfehlungen. Die abgedruckte requirements.txt bleibt unveraendert daneben bestehen. ortools steht in der Grundausstattung, highspy erst in [large-scale] - so kann der HiGHS-Symbolkonflikt bei der schlanken Installation gar nicht erst auftreten. * Dabei zwei Funde: graphviz wird von erzeuge_architektur_diagramme.py importiert, fehlt aber in requirements.txt (jetzt in [figures]); pymoo steht in requirements.txt, wird aber von keinem Programm importiert, sondern nur im Kapitel Metaheuristiken empfohlen (jetzt in [empfehlungen]). * NEUER_TITEL.md nach Kritik_und_Verbesserungsvorschlaege/ verschoben - es ist die Vorlage des Titelblatts, kein Bestandteil des Werks. Die beiden Fundstellen in PROGRESS.md und erzeuge_titelseite.py nachgezogen. * PROGRESS.md nannte noch den Untertitel der ersten Fassung; auf den tatsaechlichen aus erzeuge_titelseite.py korrigiert. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 01:20:09 +02:00
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Kapitel 16: Die Strukturbrücke — dieselbe Mathematik, zwei Welten · Optimierte Entscheidungsfindung mit Python</title>
<script>
(function () {
try {
var t = localStorage.getItem("or-theme");
if (t) document.documentElement.setAttribute("data-theme", t);
} catch (e) {}
})();
</script>
<link rel="stylesheet" href="assets/highlight.css" />
<link rel="stylesheet" href="katex/katex.min.css" />
<script defer="" src="katex/katex.min.js"></script>
<script>document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}}
// Der Browser springt zu einem #anker in der URL schon beim ersten Rendern
// an, BEVOR die KaTeX-Formeln oben im Text ihre finale Hoehe bekommen -
// durch den Reflow landet der Anker danach zu weit unten. Nach dem
// Formel-Rendering hier erneut zum Anker springen, das behebt es.
if (location.hash) {
var ziel = document.getElementById(decodeURIComponent(location.hash.slice(1)));
if (ziel) ziel.scrollIntoView({behavior: "instant", block: "start"});
}
});
</script>
<link rel="stylesheet" href="assets/site.css" />
</head>
<body>
<svg style="display:none" aria-hidden="true"><symbol id="icon-menu" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/>
</symbol>
<symbol id="icon-search" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.2" y2="16.2"/>
</symbol>
<symbol id="icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<circle cx="12" cy="12" r="4.5"/>
<line x1="12" y1="1.5" x2="12" y2="4"/><line x1="12" y1="20" x2="12" y2="22.5"/>
<line x1="1.5" y1="12" x2="4" y2="12"/><line x1="20" y1="12" x2="22.5" y2="12"/>
<line x1="4.5" y1="4.5" x2="6.2" y2="6.2"/><line x1="17.8" y1="17.8" x2="19.5" y2="19.5"/>
<line x1="19.5" y1="4.5" x2="17.8" y2="6.2"/><line x1="6.2" y1="17.8" x2="4.5" y2="19.5"/>
</symbol>
<symbol id="icon-moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M20 14.5A8.5 8.5 0 1 1 9.5 4a6.8 6.8 0 0 0 10.5 10.5z"/>
</symbol>
<symbol id="icon-chevron-left" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="15 4 7 12 15 20"/>
</symbol>
<symbol id="icon-chevron-right" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="9 4 17 12 9 20"/>
</symbol>
<symbol id="icon-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="4 13 9.5 18.5 20 6"/>
</symbol>
<symbol id="icon-external-link" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M18 13.5V19a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 19V7A1.5 1.5 0 0 1 5 5.5h5.5"/>
<polyline points="14.5 3.5 20.5 3.5 20.5 9.5"/><line x1="11" y1="13" x2="20" y2="4"/>
</symbol>
<symbol id="icon-book" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 5.5A2 2 0 0 1 6 4h6v16H6a2 2 0 0 0-2 1.5z"/>
<path d="M20 5.5A2 2 0 0 0 18 4h-6v16h6a2 2 0 0 1 2 1.5z"/>
</symbol>
<symbol id="icon-copy" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
</symbol>
<symbol id="icon-download" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><path d="M4 19.5h16"/>
</symbol></svg>
<header class="site-header">
<button type="button" class="icon-btn" id="sidebar-toggle" aria-label="Menü öffnen"><svg class="icon" aria-hidden="true"><use href="#icon-menu"></use></svg></button>
<a class="brand" href="index.html"><svg class="icon" aria-hidden="true"><use href="#icon-book"></use></svg> <span>Optimierte Entscheidungsfindung mit Python</span></a>
<div class="site-search">
<input id="suche-eingabe" type="search" placeholder="Suchen …" aria-label="Suche" autocomplete="off" />
<svg class="icon such-icon" aria-hidden="true"><use href="#icon-search"></use></svg>
<div id="suche-ergebnisse" class="suche-ergebnisse" hidden></div>
</div>
<button type="button" class="icon-btn" id="theme-toggle" aria-label="Darstellung umschalten">
<svg class="icon icon-sun" aria-hidden="true"><use href="#icon-sun"></use></svg><svg class="icon icon-moon" aria-hidden="true"><use href="#icon-moon"></use></svg>
</button>
</header>
<div class="site-body">
<div class="sidebar-overlay" id="sidebar-overlay" hidden></div>
<nav class="sidebar" id="sidebar" aria-label="Kapitelnavigation"><div class="sidebar-inhalt"><details class="sidebar-gruppe"><summary>Einstieg</summary><ul><li data-kapitel="vorwort.html"><a href="vorwort.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Vorwort & Lesehilfe</span></a></li><li data-kapitel="notation.html"><a href="notation.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Notation & Abkürzungen</span></a></li></ul></details><details class="sidebar-gruppe"><summary>Teil I: Grundlagen des Operations Research</summary><ul><li data-kapitel="einfuehrung.html"><a href="einfuehrung.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 1: Einführung in Operations Research — Vom Ursprung zur mathematischen Entscheidungsfindung</span></a></li><li data-kapitel="fundament.html"><a href="fundament.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 2: Das mathematische Fundament — Vektoren, Matrizen, Konvexität</span></a></li><li data-kapitel="oekosystem.html"><a href="oekosystem.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 3: Das Python-Ökosystem für OR — Solver, Bindings und Modellierungsschichten</span></a></li><li data-kapitel="modellierung.html"><a href="modellierung.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 4: Vom Management-Wunsch zum Modell</span></a></li></ul></details><details class="sidebar-gruppe"><summary>Teil II: Die Kernverfahren der deterministischen Optimierung</summary><ul><li data-kapitel="lp.html"><a href="lp.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 5: Lineare Programmierung — Simplex, Dualität und Schattenpreise</span></a></li><li data-kapitel="milp.html"><a href="milp.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 6: Gemischt-ganzzahlige Optimierung — Diskrete Entscheidungen und Branch-and-Bound</span></a></li><li data-kapitel="cpsat.html"><a href="cpsat.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 7: Constraint Programming mit CP-SAT — Logik, Scheduling und Zuweisung</span></a></li><li data-kapitel="graphen.html"><a href="graphen.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 8: Graphen, Flüsse und Touren — Min-Cost-Flow, Matching und VRP</span></a></li><li data-kapitel="metaheuristiken.html"><a href="metaheuristiken.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 9: Metaheuristiken — wenn der exakte Solver aussteigt</span></a></li><li data-kapitel="dekomposition.html"><a href="dekomposition.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 10: Spaltengenerierung — das Modell umbauen statt die Lösung raten</span></a></li></ul></details><details class="sidebar-gruppe"><summary>Teil III: Nichtlinearität, Unsicherheit und mehrperiodige Dynamik</summary><ul><li data-kapitel="qp-nlp.html"><a href="qp-nlp.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></span><span>Kapitel 11: Quadratische und nichtlineare Optimierung — KKT, Lagrange, Konvexität</span></a></li><li data-kapitel="unsicherheit.html"><a href="unsicherheit.html"><span class="fortschritt-haken"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg></
<main class="content">
<nav class="breadcrumb" aria-label="Breadcrumb"><a href="index.html">Start</a> <span>Teil IV</span> <span>Kapitel 16: Die Strukturbrücke — dieselbe Mathematik, zwei Welten</span></nav>
<nav class="prev-next"><a class="prev-next-knopf prev-next-prev" href="prognose.html"><svg class="icon" aria-hidden="true"><use href="#icon-chevron-left"></use></svg><span><small>Zurück</small>Kapitel 15: Predict-then-Optimize — die bessere Prognose, die schlechtere Entscheidung</span></a><a class="prev-next-knopf prev-next-next" href="supplychain.html"><span><small>Weiter</small>Kapitel 17: Supply-Chain und Energieeinsatz unter Unsicherheit</span><svg class="icon" aria-hidden="true"><use href="#icon-chevron-right"></use></svg></a></nav>
<article>
<h1 id="teil-anwendungen">Teil IV: Anwendungen — Energiewirtschaft und Finanzmärkte</h1>
<p>Dieser Teil wechselt die Domäne — aber <strong>nicht</strong> die Methoden. Was hier folgt, ist die konsequente Anwendung dessen, was Sie in den Teilen II und III gelernt haben, auf zwei Gebiete, in denen viel Unsicherheit auf ein unmittelbar messbares Ergebnis trifft: die Energiewirtschaft und die Finanzmärkte.</p>
<p>Er hat drei Abschnitte, und Sie können nach jedem aufhören:</p>
<ol type="1">
<li><strong>Die Brücke</strong> (<a href="#kap-bruecke">Kapitel 16</a>) macht die Behauptung nachprüfbar, dass es dieselben Methoden sind. Sie lässt denselben Code einmal über eine Werkstatt und einmal über ein Depot laufen — und benennt die drei Stellen, an denen die Analogie endet.</li>
<li><strong>Die Industrieanwendung</strong> (<a href="supplychain.html#kap-supplychain">Kapitel 17</a>) führt die Werkzeuge an einem zusammenhängenden Fall aus der Energiewirtschaft zusammen: Kraftwerkseinsatzplanung unter Windunsicherheit. Wer mit Produktion, Logistik oder Energie zu tun hat, findet hier die Vertiefung, die für die Finanzkapitel keinen Ersatz braucht.</li>
<li><strong>Die Finanzanwendung</strong> (ab <a href="finanzdaten.html#kap-finanzdaten">Kapitel 18</a>) ist die spezialisierte Vertiefungsdomäne.</li>
</ol>
<div class="card card-blick">
<blockquote>
<p><strong>📌 Für wen dieser Teil gedacht ist</strong></p>
<p>Die Finanzkapitel ab <a href="finanzdaten.html#kap-finanzdaten">Kapitel 18</a> sind eine <strong>Vertiefungsdomäne</strong>, kein Pflichtstoff. Wer beruflich mit Logistik, Produktion oder Energie zu tun hat, liest die ersten beiden Kapitel dieses Teils und kann den Rest überspringen, ohne dass etwas fehlt — die Methoden sind dieselben.</p>
<p><strong>Lesen Sie ihn trotzdem, wenn Sie eines der folgenden Themen brauchen:</strong> Schätzfehler in Kovarianzmatrizen (das Problem tritt bei jeder Korrelationsschätzung auf, auch bei Lieferzeiten), Risikomaße jenseits der Standardabweichung, oder rollierende Auswertung mit sauberer Trennung von Trainings- und Testzeitraum.</p>
</blockquote>
</div>
<p><strong>Ein Hinweis vorweg:</strong> Die Kapitel ab <a href="finanzdaten.html#kap-finanzdaten">Kapitel 18</a> laden aktuelle Kursdaten über <code>yfinance</code> und brauchen dafür einen <strong>Internetzugang</strong>. Weil die Daten sich täglich ändern, sind die abgedruckten Zahlen dort <em>Beispielläufe</em>, keine reproduzierbaren Werte — anders als im übrigen Buch. Das Brückenkapitel kommt ohne Internet aus.</p>
<hr />
<h1 id="kap-bruecke">Kapitel 16: Die Strukturbrücke — dieselbe Mathematik, zwei Welten</h1>
<div class="card card-blick">
<blockquote>
<p><strong>📌 Kapitel auf einen Blick</strong></p>
<p><strong>Worum geht es?</strong> Um den Nachweis, dass die Verfahren aus Teil II und III unverändert in der Finanzwelt funktionieren — und um die drei Stellen, an denen die Analogie endet.</p>
<p><strong>Voraussetzungen:</strong> <a href="einfuehrung.html#kap-einfuehrung">Kapitel 1</a> (Allokation als LP), <a href="unsicherheit.html#kap-unsicherheit">Kapitel 12</a> (Szenarien) und <a href="praxisfallen.html#sec:praxisfallen-or-kern">Abschnitt 22.5</a> (<code>or_kern.py</code>).</p>
<p><strong>Danach können Sie:</strong> ein betriebswirtschaftliches Modell in die andere Domäne übersetzen, ohne den Modellcode anzufassen; Schattenpreise in beiden Welten lesen; und benennen, welche Annahmen dabei <strong>nicht</strong> mitwandern.</p>
<p><strong>Zeitbedarf:</strong> ca. 2,5 Stunden.</p>
<p><strong>Programme:</strong><br />
<code>Strukturbruecke.py</code></p>
<p><strong>Notebook:</strong> <a href="Notebooks_04/bruecke.ipynb">bruecke.ipynb</a><br />
<a href="https://colab.research.google.com/github/dschlueter/or-mit-python/blob/main/Notebooks_04/bruecke.ipynb">In Google Colab öffnen</a></p>
</blockquote>
</div>
<hr />
<h2 id="sec:bruecke-schnellstart">16.1 In 5 Minuten gelöst</h2>
<div class="card card-schnellstart">
<blockquote>
<p><strong>🚀 In 5 Minuten gelöst: Was ist ein Risikobudget?</strong></p>
<p>Ein Anleger hat 150 000 € und will sie auf drei Anlageklassen verteilen. Neben dem Kapital gibt es eine zweite knappe Größe: das <strong>Risikobudget</strong> — eine Kennzahl, die die Bankaufsicht oder das eigene Regelwerk vorgibt und die jede Anlage unterschiedlich stark beansprucht.</p>
<table>
<thead>
<tr class="header">
<th>Anlage</th>
<th style="text-align: right;">Ertrag je 1 000 €</th>
<th style="text-align: right;">Kapital</th>
<th style="text-align: right;">Risikobudget</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Aktien Welt</td>
<td style="text-align: right;">75 €</td>
<td style="text-align: right;">1,0</td>
<td style="text-align: right;">1,00</td>
</tr>
<tr class="even">
<td>Anleihen</td>
<td style="text-align: right;">28 €</td>
<td style="text-align: right;">1,0</td>
<td style="text-align: right;">0,22</td>
</tr>
<tr class="odd">
<td>Immobilienfonds</td>
<td style="text-align: right;">46 €</td>
<td style="text-align: right;">1,0</td>
<td style="text-align: right;">0,55</td>
</tr>
<tr class="even">
<td><strong>verfügbar</strong></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"><strong>150</strong></td>
<td style="text-align: right;"><strong>90</strong></td>
</tr>
</tbody>
</table>
<p>Lesen Sie die Tabelle noch einmal — und ersetzen Sie „Kapital” durch „Montagestunden” und „Risikobudget” durch „Plattenmaterial”. Es ist die Schreinerei aus <a href="einfuehrung.html#kap-einfuehrung">Kapitel 1</a>, Wort für Wort.</p>
<p>Deshalb genügt der vorhandene Code:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> or_kern <span class="im">import</span> Produkt, Produktionsproblem, loese_mit_scipy</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>depot <span class="op">=</span> Produktionsproblem(</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> produkte<span class="op">=</span>[</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Aktien Welt&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">75.0</span>,</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Kapital (Tsd. EUR)&quot;</span>: <span class="fl">1.0</span>, <span class="st">&quot;Risikobudget&quot;</span>: <span class="fl">1.00</span>}),</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Anleihen&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">28.0</span>,</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Kapital (Tsd. EUR)&quot;</span>: <span class="fl">1.0</span>, <span class="st">&quot;Risikobudget&quot;</span>: <span class="fl">0.22</span>}),</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Immobilienfonds&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">46.0</span>,</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Kapital (Tsd. EUR)&quot;</span>: <span class="fl">1.0</span>, <span class="st">&quot;Risikobudget&quot;</span>: <span class="fl">0.55</span>}),</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a> ],</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> kapazitaeten<span class="op">=</span>{<span class="st">&quot;Kapital (Tsd. EUR)&quot;</span>: <span class="fl">150.0</span>, <span class="st">&quot;Risikobudget&quot;</span>: <span class="fl">90.0</span>})</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a>loesung <span class="op">=</span> loese_mit_scipy(depot)</span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(loesung.als_bericht())</span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(loesung.schattenpreise)</span></code></pre></div>
<p><strong>Ausgabe:</strong></p>
<pre><code>Status: optimal | Zielwert: 7,634.62 | Gap: 0.00% | Zeit: 0.00s
{&#39;Kapital (Tsd. EUR)&#39;: 14.74, &#39;Risikobudget&#39;: 60.26}</code></pre>
</blockquote>
</div>
<p><strong>Und jetzt der Punkt.</strong> Die Klasse heißt <code>Produktionsproblem</code>, und das Depot passt hinein, ohne dass eine Zeile geändert wurde. Kein Adapter, keine Unterklasse, keine Fallunterscheidung — die Struktur ist dieselbe, weil das Problem dasselbe ist: <em>knappe Größen auf konkurrierende Verwendungen verteilen.</em></p>
<p>Der interessanteste Teil steht in der zweiten Zeile der Ausgabe. <strong>60,26 € je Einheit Risikobudget</strong> — das ist der Dualwert derselben Nebenbedingung, die in der Werkstatt sagt, was eine zusätzliche Montagestunde wert wäre. In der Finanzwelt hat diese Zahl einen eigenen Namen: der <strong>Preis des Risikos</strong>. Es ist nicht bloß eine Analogie, es ist derselbe Schattenpreis aus <a href="lp.html#kap-lp">Kapitel 5</a>.</p>
<blockquote>
<p><strong>🎯 Merksatz</strong> Wenn zwei Probleme dieselbe Struktur haben, brauchen sie nicht zwei Modelle, sondern zwei Datensätze. Ob das der Fall ist, erkennt man daran, dass derselbe Code ohne Änderung läuft — nicht daran, dass eine Tabelle es behauptet.</p>
</blockquote>
<p><strong>Warum funktioniert das?</strong> Weil ein LP nichts über die Bedeutung seiner Zahlen weiß. Es sieht eine Matrix, einen Kapazitätsvektor und einen Zielvektor. Ob in der Matrix Stunden, Kilogramm oder Risikobeiträge stehen, kommt darin nicht vor.</p>
<hr />
<h2 id="sec:bruecke-lernziele">16.2 Lernziele</h2>
<p>Nach diesem Kapitel können Sie …</p>
<ol type="1">
<li>… ein Allokationsproblem aus der einen Domäne in die andere übersetzen, indem Sie die Daten austauschen statt des Codes.</li>
<li>… den Schattenpreis in beiden Welten deuten — als Wert einer Ressource und als Preis des Risikos.</li>
<li>… erklären, warum die CVaR-Formulierung aus <a href="cvar.html#kap-cvar">Kapitel 20</a> auf Lieferverzüge genauso passt wie auf Kursverluste.</li>
<li>… die drei Stellen benennen, an denen die Analogie <strong>nicht</strong> trägt — und begründen, warum das Übertragen von Methoden dort gefährlich wird.</li>
</ol>
<hr />
<h2 id="sec:bruecke-programm">16.3 Das Programm</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co">#!/usr/bin/env python3</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Strukturbruecke.py</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co">&quot;&quot;&quot;</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="co">Kapitel Bruecke: Derselbe Code, zwei Welten - der Beweis statt der Behauptung.</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="co">Der Teil-Auftakt stellt eine Tabelle auf: &quot;Ressourcen auf Produkte verteilen&quot;</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="co">entspreche &quot;Kapital auf Anlagen verteilen&quot;, &quot;gegen den Worst Case absichern&quot;</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="co">entspreche &quot;Absicherung gegen Kursabstuerze&quot;. Solche Tabellen stehen in vielen</span></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a><span class="co">Buechern. Sie sind billig - und man kann sie pruefen.</span></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a><span class="co">Dieses Programm prueft sie. Es fuettert zweimal DENSELBEN Code mit Daten aus</span></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a><span class="co">zwei Welten und zeigt die Ergebnisse nebeneinander:</span></span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a><span class="co"> 1. Die Allokation als LP. Das Domaenenmodell aus or_kern.py, einmal mit einer</span></span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a><span class="co"> Schreinerei (Montagestunden, Plattenmaterial) und einmal mit einem Depot</span></span>
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a><span class="co"> (Kapital, Risikobudget). Gleiche Klasse, gleicher Modellbauer, gleiche</span></span>
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a><span class="co"> Abnahmepruefung - und der Schattenpreis heisst in der einen Welt</span></span>
<span id="cb3-19"><a href="#cb3-19" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;Wert einer zusaetzlichen Montagestunde&quot; und in der anderen &quot;Preis des</span></span>
<span id="cb3-20"><a href="#cb3-20" aria-hidden="true" tabindex="-1"></a><span class="co"> Risikos&quot;.</span></span>
<span id="cb3-21"><a href="#cb3-21" aria-hidden="true" tabindex="-1"></a><span class="co"> 2. Die Absicherung gegen den schlechtesten Fall als CVaR. EINE Funktion,</span></span>
<span id="cb3-22"><a href="#cb3-22" aria-hidden="true" tabindex="-1"></a><span class="co"> einmal mit Kursrenditen und einmal mit Lieferverzuegen.</span></span>
<span id="cb3-23"><a href="#cb3-23" aria-hidden="true" tabindex="-1"></a><span class="co"> 3. Was NICHT hinueberreicht. Der ehrliche Teil: Drei Unterschiede, die die</span></span>
<span id="cb3-24"><a href="#cb3-24" aria-hidden="true" tabindex="-1"></a><span class="co"> Analogie begrenzen - und die man kennen muss, bevor man Methoden aus</span></span>
<span id="cb3-25"><a href="#cb3-25" aria-hidden="true" tabindex="-1"></a><span class="co"> der einen Welt in die andere traegt.</span></span>
<span id="cb3-26"><a href="#cb3-26" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-27"><a href="#cb3-27" aria-hidden="true" tabindex="-1"></a><span class="co">ZUR SOLVERWAHL: Teil 1 benutzt &#39;loese_mit_scipy&#39; und nicht &#39;loese_mit_glop&#39;.</span></span>
<span id="cb3-28"><a href="#cb3-28" aria-hidden="true" tabindex="-1"></a><span class="co">Das ist kein Zufall - CVXPY laedt fuer Teil 2 highspy, und ortools vertraegt</span></span>
<span id="cb3-29"><a href="#cb3-29" aria-hidden="true" tabindex="-1"></a><span class="co">sich damit nicht im selben Prozess (Kapitel Oekosystem). Wer hier GLOP nimmt,</span></span>
<span id="cb3-30"><a href="#cb3-30" aria-hidden="true" tabindex="-1"></a><span class="co">bekommt beim cvxpy-Import eine Fehlermeldung ueber ein &#39;undefined symbol&#39;.</span></span>
<span id="cb3-31"><a href="#cb3-31" aria-hidden="true" tabindex="-1"></a><span class="co">Genau deshalb laedt or_kern.py seine Solver erst beim Aufruf.</span></span>
<span id="cb3-32"><a href="#cb3-32" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-33"><a href="#cb3-33" aria-hidden="true" tabindex="-1"></a><span class="co">Benoetigt: numpy, cvxpy, scipy und pydantic (ueber or_kern)</span></span>
<span id="cb3-34"><a href="#cb3-34" aria-hidden="true" tabindex="-1"></a><span class="co">&quot;&quot;&quot;</span></span>
<span id="cb3-35"><a href="#cb3-35" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-36"><a href="#cb3-36" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> __future__ <span class="im">import</span> annotations</span>
<span id="cb3-37"><a href="#cb3-37" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-38"><a href="#cb3-38" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np</span>
<span id="cb3-39"><a href="#cb3-39" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-40"><a href="#cb3-40" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> or_kern <span class="im">import</span> (Produkt, Produktionsproblem, loese_mit_scipy,</span>
<span id="cb3-41"><a href="#cb3-41" aria-hidden="true" tabindex="-1"></a> pruefe_loesung)</span>
<span id="cb3-42"><a href="#cb3-42" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-43"><a href="#cb3-43" aria-hidden="true" tabindex="-1"></a>SAAT <span class="op">=</span> <span class="dv">7</span></span>
<span id="cb3-44"><a href="#cb3-44" aria-hidden="true" tabindex="-1"></a>SZENARIEN <span class="op">=</span> <span class="dv">500</span></span>
<span id="cb3-45"><a href="#cb3-45" aria-hidden="true" tabindex="-1"></a>ALPHA <span class="op">=</span> <span class="fl">0.95</span> <span class="co"># die schlechtesten 5 % der Faelle</span></span>
<span id="cb3-46"><a href="#cb3-46" aria-hidden="true" tabindex="-1"></a>MAX_ANTEIL <span class="op">=</span> <span class="fl">0.40</span> <span class="co"># Streuungsgebot in beiden Welten</span></span>
<span id="cb3-47"><a href="#cb3-47" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-48"><a href="#cb3-48" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-49"><a href="#cb3-49" aria-hidden="true" tabindex="-1"></a><span class="co"># --- Teil 1: Dieselbe Klasse, zwei Welten ----------------------------------</span></span>
<span id="cb3-50"><a href="#cb3-50" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-51"><a href="#cb3-51" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> schreinerei() <span class="op">-&gt;</span> Produktionsproblem:</span>
<span id="cb3-52"><a href="#cb3-52" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;Montagestunden und Plattenmaterial auf Tische und Stuehle verteilen.&quot;&quot;&quot;</span></span>
<span id="cb3-53"><a href="#cb3-53" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> Produktionsproblem(</span>
<span id="cb3-54"><a href="#cb3-54" aria-hidden="true" tabindex="-1"></a> produkte<span class="op">=</span>[</span>
<span id="cb3-55"><a href="#cb3-55" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Tisch&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">240.0</span>,</span>
<span id="cb3-56"><a href="#cb3-56" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Montagestunden&quot;</span>: <span class="fl">3.0</span>, <span class="st">&quot;Plattenmaterial&quot;</span>: <span class="fl">6.0</span>}),</span>
<span id="cb3-57"><a href="#cb3-57" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Stuhl&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">60.0</span>,</span>
<span id="cb3-58"><a href="#cb3-58" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Montagestunden&quot;</span>: <span class="fl">1.0</span>, <span class="st">&quot;Plattenmaterial&quot;</span>: <span class="fl">1.0</span>}),</span>
<span id="cb3-59"><a href="#cb3-59" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Regal&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">130.0</span>,</span>
<span id="cb3-60"><a href="#cb3-60" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Montagestunden&quot;</span>: <span class="fl">2.0</span>, <span class="st">&quot;Plattenmaterial&quot;</span>: <span class="fl">4.0</span>}),</span>
<span id="cb3-61"><a href="#cb3-61" aria-hidden="true" tabindex="-1"></a> ],</span>
<span id="cb3-62"><a href="#cb3-62" aria-hidden="true" tabindex="-1"></a> kapazitaeten<span class="op">=</span>{<span class="st">&quot;Montagestunden&quot;</span>: <span class="fl">150.0</span>, <span class="st">&quot;Plattenmaterial&quot;</span>: <span class="fl">240.0</span>})</span>
<span id="cb3-63"><a href="#cb3-63" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-64"><a href="#cb3-64" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-65"><a href="#cb3-65" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> depot() <span class="op">-&gt;</span> Produktionsproblem:</span>
<span id="cb3-66"><a href="#cb3-66" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;Kapital und Risikobudget auf Anlageklassen verteilen.</span></span>
<span id="cb3-67"><a href="#cb3-67" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-68"><a href="#cb3-68" aria-hidden="true" tabindex="-1"></a><span class="co"> Eine &quot;Einheit&quot; ist hier 1.000 EUR Anlagesumme. Der Deckungsbeitrag ist der</span></span>
<span id="cb3-69"><a href="#cb3-69" aria-hidden="true" tabindex="-1"></a><span class="co"> erwartete Jahresertrag dieser Einheit, der Verbrauch die beanspruchte</span></span>
<span id="cb3-70"><a href="#cb3-70" aria-hidden="true" tabindex="-1"></a><span class="co"> Kapital- und Risikomenge. Das ist keine Analogie, sondern buchstaeblich</span></span>
<span id="cb3-71"><a href="#cb3-71" aria-hidden="true" tabindex="-1"></a><span class="co"> dasselbe Modell - deshalb passt es in dieselbe Klasse.</span></span>
<span id="cb3-72"><a href="#cb3-72" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb3-73"><a href="#cb3-73" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> Produktionsproblem(</span>
<span id="cb3-74"><a href="#cb3-74" aria-hidden="true" tabindex="-1"></a> produkte<span class="op">=</span>[</span>
<span id="cb3-75"><a href="#cb3-75" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Aktien Welt&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">75.0</span>,</span>
<span id="cb3-76"><a href="#cb3-76" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Kapital (Tsd. EUR)&quot;</span>: <span class="fl">1.0</span>, <span class="st">&quot;Risikobudget&quot;</span>: <span class="fl">1.00</span>}),</span>
<span id="cb3-77"><a href="#cb3-77" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Anleihen&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">28.0</span>,</span>
<span id="cb3-78"><a href="#cb3-78" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Kapital (Tsd. EUR)&quot;</span>: <span class="fl">1.0</span>, <span class="st">&quot;Risikobudget&quot;</span>: <span class="fl">0.22</span>}),</span>
<span id="cb3-79"><a href="#cb3-79" aria-hidden="true" tabindex="-1"></a> Produkt(name<span class="op">=</span><span class="st">&quot;Immobilienfonds&quot;</span>, deckungsbeitrag<span class="op">=</span><span class="fl">46.0</span>,</span>
<span id="cb3-80"><a href="#cb3-80" aria-hidden="true" tabindex="-1"></a> verbrauch<span class="op">=</span>{<span class="st">&quot;Kapital (Tsd. EUR)&quot;</span>: <span class="fl">1.0</span>, <span class="st">&quot;Risikobudget&quot;</span>: <span class="fl">0.55</span>}),</span>
<span id="cb3-81"><a href="#cb3-81" aria-hidden="true" tabindex="-1"></a> ],</span>
<span id="cb3-82"><a href="#cb3-82" aria-hidden="true" tabindex="-1"></a> kapazitaeten<span class="op">=</span>{<span class="st">&quot;Kapital (Tsd. EUR)&quot;</span>: <span class="fl">150.0</span>, <span class="st">&quot;Risikobudget&quot;</span>: <span class="fl">90.0</span>})</span>
<span id="cb3-83"><a href="#cb3-83" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-84"><a href="#cb3-84" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-85"><a href="#cb3-85" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> berichte_allokation(titel: <span class="bu">str</span>, problem: Produktionsproblem,</span>
<span id="cb3-86"><a href="#cb3-86" aria-hidden="true" tabindex="-1"></a> einheit: <span class="bu">str</span>, ertragsname: <span class="bu">str</span>) <span class="op">-&gt;</span> <span class="va">None</span>:</span>
<span id="cb3-87"><a href="#cb3-87" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;Ein Bericht fuer beide Welten - nur die Beschriftung wechselt.&quot;&quot;&quot;</span></span>
<span id="cb3-88"><a href="#cb3-88" aria-hidden="true" tabindex="-1"></a> loesung <span class="op">=</span> loese_mit_scipy(problem)</span>
<span id="cb3-89"><a href="#cb3-89" aria-hidden="true" tabindex="-1"></a> beanstandungen <span class="op">=</span> pruefe_loesung(problem, loesung)</span>
<span id="cb3-90"><a href="#cb3-90" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-91"><a href="#cb3-91" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; </span><span class="sc">{</span>titel<span class="sc">}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-92"><a href="#cb3-92" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; </span><span class="sc">{</span>loesung<span class="sc">.</span>als_bericht()<span class="sc">}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-93"><a href="#cb3-93" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> produkt <span class="kw">in</span> problem.produkte:</span>
<span id="cb3-94"><a href="#cb3-94" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; </span><span class="sc">{</span>produkt<span class="sc">.</span>name<span class="sc">:&lt;18}</span><span class="ss"> </span><span class="sc">{</span>loesung<span class="sc">.</span>werte[produkt.name]<span class="sc">:8.2f}</span><span class="ss"> </span><span class="sc">{</span>einheit<span class="sc">}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-95"><a href="#cb3-95" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; </span><span class="sc">{</span>ertragsname<span class="sc">:&lt;18}</span><span class="ss"> </span><span class="sc">{</span>loesung<span class="sc">.</span>zielwert<span class="sc">:8.2f}</span><span class="ss"> EUR&quot;</span>)</span>
<span id="cb3-96"><a href="#cb3-96" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> ressource, preis <span class="kw">in</span> loesung.schattenpreise.items():</span>
<span id="cb3-97"><a href="#cb3-97" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; Schattenpreis </span><span class="sc">{</span>ressource<span class="sc">:&lt;24}</span><span class="ss"> </span><span class="sc">{</span>preis<span class="sc">:7.2f}</span><span class="ss"> EUR&quot;</span>)</span>
<span id="cb3-98"><a href="#cb3-98" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; Abnahmepruefung: &quot;</span></span>
<span id="cb3-99"><a href="#cb3-99" aria-hidden="true" tabindex="-1"></a> <span class="ss">f&quot;</span><span class="sc">{</span><span class="st">&#39;bestanden&#39;</span> <span class="cf">if</span> <span class="kw">not</span> beanstandungen <span class="cf">else</span> beanstandungen<span class="sc">}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-100"><a href="#cb3-100" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-101"><a href="#cb3-101" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-102"><a href="#cb3-102" aria-hidden="true" tabindex="-1"></a><span class="co"># --- Teil 2: Eine CVaR-Funktion, zwei Welten -------------------------------</span></span>
<span id="cb3-103"><a href="#cb3-103" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-104"><a href="#cb3-104" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> optimiere_cvar(verluste: np.ndarray, ertrag: np.ndarray,</span>
<span id="cb3-105"><a href="#cb3-105" aria-hidden="true" tabindex="-1"></a> mindestertrag: <span class="bu">float</span>, alpha: <span class="bu">float</span> <span class="op">=</span> ALPHA,</span>
<span id="cb3-106"><a href="#cb3-106" aria-hidden="true" tabindex="-1"></a> max_anteil: <span class="bu">float</span> <span class="op">=</span> MAX_ANTEIL):</span>
<span id="cb3-107"><a href="#cb3-107" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;Minimiert den CVaR der Verluste unter einer Mindestertragsbedingung.</span></span>
<span id="cb3-108"><a href="#cb3-108" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-109"><a href="#cb3-109" aria-hidden="true" tabindex="-1"></a><span class="co"> &#39;verluste&#39; hat die Form (Szenarien x Optionen) und enthaelt, was in</span></span>
<span id="cb3-110"><a href="#cb3-110" aria-hidden="true" tabindex="-1"></a><span class="co"> Szenario s passiert, wenn eine Einheit in Option j steckt. Was ein</span></span>
<span id="cb3-111"><a href="#cb3-111" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;Verlust&quot; ist, entscheidet allein die Einheit der Matrix: Prozentpunkte</span></span>
<span id="cb3-112"><a href="#cb3-112" aria-hidden="true" tabindex="-1"></a><span class="co"> Kursverlust oder Tage Lieferverzug - die Formel sieht keinen Unterschied.</span></span>
<span id="cb3-113"><a href="#cb3-113" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-114"><a href="#cb3-114" aria-hidden="true" tabindex="-1"></a><span class="co"> Das ist die Rockafellar-Uryasev-Formulierung aus dem Kapitel CVaR, hier</span></span>
<span id="cb3-115"><a href="#cb3-115" aria-hidden="true" tabindex="-1"></a><span class="co"> ohne jede Aenderung wiederverwendet.</span></span>
<span id="cb3-116"><a href="#cb3-116" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb3-117"><a href="#cb3-117" aria-hidden="true" tabindex="-1"></a> <span class="im">import</span> cvxpy <span class="im">as</span> cp</span>
<span id="cb3-118"><a href="#cb3-118" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-119"><a href="#cb3-119" aria-hidden="true" tabindex="-1"></a> anzahl_szenarien, anzahl_optionen <span class="op">=</span> verluste.shape</span>
<span id="cb3-120"><a href="#cb3-120" aria-hidden="true" tabindex="-1"></a> anteil <span class="op">=</span> cp.Variable(anzahl_optionen, nonneg<span class="op">=</span><span class="va">True</span>)</span>
<span id="cb3-121"><a href="#cb3-121" aria-hidden="true" tabindex="-1"></a> schwelle <span class="op">=</span> cp.Variable() <span class="co"># wird im Optimum zum VaR</span></span>
<span id="cb3-122"><a href="#cb3-122" aria-hidden="true" tabindex="-1"></a> ueberschuss <span class="op">=</span> cp.Variable(anzahl_szenarien, nonneg<span class="op">=</span><span class="va">True</span>)</span>
<span id="cb3-123"><a href="#cb3-123" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-124"><a href="#cb3-124" aria-hidden="true" tabindex="-1"></a> cvar <span class="op">=</span> schwelle <span class="op">+</span> (<span class="fl">1.0</span> <span class="op">/</span> (anzahl_szenarien <span class="op">*</span> (<span class="dv">1</span> <span class="op">-</span> alpha))) <span class="op">*</span> cp.<span class="bu">sum</span>(ueberschuss)</span>
<span id="cb3-125"><a href="#cb3-125" aria-hidden="true" tabindex="-1"></a> problem <span class="op">=</span> cp.Problem(</span>
<span id="cb3-126"><a href="#cb3-126" aria-hidden="true" tabindex="-1"></a> cp.Minimize(cvar),</span>
<span id="cb3-127"><a href="#cb3-127" aria-hidden="true" tabindex="-1"></a> [ueberschuss <span class="op">&gt;=</span> verluste <span class="op">@</span> anteil <span class="op">-</span> schwelle,</span>
<span id="cb3-128"><a href="#cb3-128" aria-hidden="true" tabindex="-1"></a> cp.<span class="bu">sum</span>(anteil) <span class="op">==</span> <span class="dv">1</span>,</span>
<span id="cb3-129"><a href="#cb3-129" aria-hidden="true" tabindex="-1"></a> anteil <span class="op">&lt;=</span> max_anteil,</span>
<span id="cb3-130"><a href="#cb3-130" aria-hidden="true" tabindex="-1"></a> ertrag <span class="op">@</span> anteil <span class="op">&gt;=</span> mindestertrag])</span>
<span id="cb3-131"><a href="#cb3-131" aria-hidden="true" tabindex="-1"></a> problem.solve()</span>
<span id="cb3-132"><a href="#cb3-132" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> problem.status <span class="kw">not</span> <span class="kw">in</span> (<span class="st">&quot;optimal&quot;</span>, <span class="st">&quot;optimal_inaccurate&quot;</span>):</span>
<span id="cb3-133"><a href="#cb3-133" aria-hidden="true" tabindex="-1"></a> <span class="cf">raise</span> <span class="pp">SystemExit</span>(<span class="ss">f&quot;CVaR-Problem nicht loesbar: </span><span class="sc">{</span>problem<span class="sc">.</span>status<span class="sc">}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-134"><a href="#cb3-134" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> anteil.value, <span class="bu">float</span>(cvar.value), <span class="bu">float</span>(schwelle.value)</span>
<span id="cb3-135"><a href="#cb3-135" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-136"><a href="#cb3-136" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-137"><a href="#cb3-137" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> kursszenarien(rng) <span class="op">-&gt;</span> <span class="bu">tuple</span>[np.ndarray, np.ndarray, <span class="bu">list</span>[<span class="bu">str</span>]]:</span>
<span id="cb3-138"><a href="#cb3-138" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;Taegliche Verluste (negative Renditen) von sechs Anlageklassen.&quot;&quot;&quot;</span></span>
<span id="cb3-139"><a href="#cb3-139" aria-hidden="true" tabindex="-1"></a> namen <span class="op">=</span> [<span class="st">&quot;Aktien Welt&quot;</span>, <span class="st">&quot;Aktien EU&quot;</span>, <span class="st">&quot;Schwellenlaender&quot;</span>,</span>
<span id="cb3-140"><a href="#cb3-140" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Staatsanleihen&quot;</span>, <span class="st">&quot;Unternehmensanl.&quot;</span>, <span class="st">&quot;Rohstoffe&quot;</span>]</span>
<span id="cb3-141"><a href="#cb3-141" aria-hidden="true" tabindex="-1"></a> rendite_pa <span class="op">=</span> np.array([<span class="fl">0.080</span>, <span class="fl">0.065</span>, <span class="fl">0.110</span>, <span class="fl">0.025</span>, <span class="fl">0.045</span>, <span class="fl">0.070</span>])</span>
<span id="cb3-142"><a href="#cb3-142" aria-hidden="true" tabindex="-1"></a> schwankung <span class="op">=</span> np.array([<span class="fl">0.180</span>, <span class="fl">0.160</span>, <span class="fl">0.260</span>, <span class="fl">0.040</span>, <span class="fl">0.075</span>, <span class="fl">0.210</span>])</span>
<span id="cb3-143"><a href="#cb3-143" aria-hidden="true" tabindex="-1"></a> taeglich <span class="op">=</span> rng.normal(rendite_pa <span class="op">/</span> <span class="dv">252</span>, schwankung <span class="op">/</span> np.sqrt(<span class="dv">252</span>),</span>
<span id="cb3-144"><a href="#cb3-144" aria-hidden="true" tabindex="-1"></a> (SZENARIEN, <span class="bu">len</span>(namen)))</span>
<span id="cb3-145"><a href="#cb3-145" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="op">-</span>taeglich <span class="op">*</span> <span class="fl">100.0</span>, rendite_pa <span class="op">*</span> <span class="fl">100.0</span>, namen</span>
<span id="cb3-146"><a href="#cb3-146" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-147"><a href="#cb3-147" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-148"><a href="#cb3-148" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> lieferszenarien(rng) <span class="op">-&gt;</span> <span class="bu">tuple</span>[np.ndarray, np.ndarray, <span class="bu">list</span>[<span class="bu">str</span>]]:</span>
<span id="cb3-149"><a href="#cb3-149" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;Lieferverzug in Tagen bei sechs Lieferanten.</span></span>
<span id="cb3-150"><a href="#cb3-150" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-151"><a href="#cb3-151" aria-hidden="true" tabindex="-1"></a><span class="co"> Der Aufbau ist bewusst anders als bei den Kursen: Hier gibt es einen</span></span>
<span id="cb3-152"><a href="#cb3-152" aria-hidden="true" tabindex="-1"></a><span class="co"> normalen Verzug UND seltene Totalausfaelle, die 14 Tage kosten. Das ist</span></span>
<span id="cb3-153"><a href="#cb3-153" aria-hidden="true" tabindex="-1"></a><span class="co"> genau die Art fetter Raender, wegen der man in beiden Welten CVaR statt</span></span>
<span id="cb3-154"><a href="#cb3-154" aria-hidden="true" tabindex="-1"></a><span class="co"> Standardabweichung benutzt.</span></span>
<span id="cb3-155"><a href="#cb3-155" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb3-156"><a href="#cb3-156" aria-hidden="true" tabindex="-1"></a> namen <span class="op">=</span> [<span class="st">&quot;Nordwerk&quot;</span>, <span class="st">&quot;Sued-Metall&quot;</span>, <span class="st">&quot;Fernost A&quot;</span>, <span class="st">&quot;Lokalzulieferer&quot;</span>,</span>
<span id="cb3-157"><a href="#cb3-157" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Fernost B&quot;</span>, <span class="st">&quot;Osteuropa&quot;</span>]</span>
<span id="cb3-158"><a href="#cb3-158" aria-hidden="true" tabindex="-1"></a> zuverlaessigkeit <span class="op">=</span> np.array([<span class="fl">0.94</span>, <span class="fl">0.97</span>, <span class="fl">0.90</span>, <span class="fl">0.99</span>, <span class="fl">0.92</span>, <span class="fl">0.95</span>])</span>
<span id="cb3-159"><a href="#cb3-159" aria-hidden="true" tabindex="-1"></a> verzugsstreuung <span class="op">=</span> np.array([<span class="fl">3.5</span>, <span class="fl">1.8</span>, <span class="fl">5.0</span>, <span class="fl">0.9</span>, <span class="fl">4.2</span>, <span class="fl">2.8</span>])</span>
<span id="cb3-160"><a href="#cb3-160" aria-hidden="true" tabindex="-1"></a> normaler_verzug <span class="op">=</span> np.maximum(<span class="fl">0.0</span>, rng.normal(<span class="fl">0.5</span>, <span class="fl">1.0</span>, (SZENARIEN, <span class="bu">len</span>(namen)))</span>
<span id="cb3-161"><a href="#cb3-161" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span> verzugsstreuung)</span>
<span id="cb3-162"><a href="#cb3-162" aria-hidden="true" tabindex="-1"></a> totalausfall <span class="op">=</span> (rng.random((SZENARIEN, <span class="bu">len</span>(namen))) <span class="op">&gt;</span> zuverlaessigkeit) <span class="op">*</span> <span class="fl">14.0</span></span>
<span id="cb3-163"><a href="#cb3-163" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> normaler_verzug <span class="op">+</span> totalausfall, zuverlaessigkeit, namen</span>
<span id="cb3-164"><a href="#cb3-164" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-165"><a href="#cb3-165" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-166"><a href="#cb3-166" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> berichte_cvar(titel: <span class="bu">str</span>, verluste, ertrag, namen, mindestertrag,</span>
<span id="cb3-167"><a href="#cb3-167" aria-hidden="true" tabindex="-1"></a> einheit: <span class="bu">str</span>, ertragsname: <span class="bu">str</span>):</span>
<span id="cb3-168"><a href="#cb3-168" aria-hidden="true" tabindex="-1"></a> anteile, cvar, var <span class="op">=</span> optimiere_cvar(verluste, ertrag, mindestertrag)</span>
<span id="cb3-169"><a href="#cb3-169" aria-hidden="true" tabindex="-1"></a> mittel <span class="op">=</span> <span class="bu">float</span>((verluste <span class="op">@</span> anteile).mean())</span>
<span id="cb3-170"><a href="#cb3-170" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; </span><span class="sc">{</span>titel<span class="sc">}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-171"><a href="#cb3-171" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; VaR </span><span class="sc">{</span>ALPHA<span class="sc">:.0%}</span><span class="ss">: </span><span class="sc">{</span>var<span class="sc">:8.3f}</span><span class="ss"> </span><span class="sc">{</span>einheit<span class="sc">}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-172"><a href="#cb3-172" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; CVaR </span><span class="sc">{</span>ALPHA<span class="sc">:.0%}</span><span class="ss">: </span><span class="sc">{</span>cvar<span class="sc">:8.3f}</span><span class="ss"> </span><span class="sc">{</span>einheit<span class="sc">}</span><span class="ss"> &quot;</span></span>
<span id="cb3-173"><a href="#cb3-173" aria-hidden="true" tabindex="-1"></a> <span class="ss">f&quot;(Mittelwert ueber alle Szenarien: </span><span class="sc">{</span>mittel<span class="sc">:.3f}</span><span class="ss">)&quot;</span>)</span>
<span id="cb3-174"><a href="#cb3-174" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; </span><span class="sc">{</span>ertragsname<span class="sc">}</span><span class="ss">: </span><span class="sc">{</span><span class="bu">float</span>(ertrag <span class="op">@</span> anteile)<span class="sc">:.3f}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-175"><a href="#cb3-175" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Aufteilung:&quot;</span>)</span>
<span id="cb3-176"><a href="#cb3-176" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> name, anteil <span class="kw">in</span> <span class="bu">zip</span>(namen, anteile):</span>
<span id="cb3-177"><a href="#cb3-177" aria-hidden="true" tabindex="-1"></a> balken <span class="op">=</span> <span class="st">&quot;#&quot;</span> <span class="op">*</span> <span class="bu">int</span>(<span class="bu">round</span>(anteil <span class="op">*</span> <span class="dv">40</span>))</span>
<span id="cb3-178"><a href="#cb3-178" aria-hidden="true" tabindex="-1"></a> grenze <span class="op">=</span> <span class="st">&quot; &lt;- an der Streuungsgrenze&quot;</span> <span class="cf">if</span> anteil <span class="op">&gt;</span> MAX_ANTEIL <span class="op">-</span> <span class="fl">1e-4</span> <span class="cf">else</span> <span class="st">&quot;&quot;</span></span>
<span id="cb3-179"><a href="#cb3-179" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; </span><span class="sc">{</span>name<span class="sc">:&lt;18}</span><span class="ss"> </span><span class="sc">{</span>anteil<span class="sc">:6.1%}</span><span class="ss"> </span><span class="sc">{</span>balken<span class="sc">}{</span>grenze<span class="sc">}</span><span class="ss">&quot;</span>)</span>
<span id="cb3-180"><a href="#cb3-180" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> anteile</span>
<span id="cb3-181"><a href="#cb3-181" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-182"><a href="#cb3-182" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-183"><a href="#cb3-183" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="va">__name__</span> <span class="op">==</span> <span class="st">&quot;__main__&quot;</span>:</span>
<span id="cb3-184"><a href="#cb3-184" aria-hidden="true" tabindex="-1"></a> rng <span class="op">=</span> np.random.default_rng(SAAT)</span>
<span id="cb3-185"><a href="#cb3-185" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-186"><a href="#cb3-186" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;=&quot;</span> <span class="op">*</span> <span class="dv">80</span>)</span>
<span id="cb3-187"><a href="#cb3-187" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; DIESELBE STRUKTUR, ZWEI WELTEN&quot;</span>)</span>
<span id="cb3-188"><a href="#cb3-188" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;=&quot;</span> <span class="op">*</span> <span class="dv">80</span>)</span>
<span id="cb3-189"><a href="#cb3-189" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-190"><a href="#cb3-190" aria-hidden="true" tabindex="-1"></a> <span class="co"># --- Teil 1 ----------------------------------------------------------</span></span>
<span id="cb3-191"><a href="#cb3-191" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;</span><span class="ch">\n</span><span class="st">1. Allokation als LP - EINE Klasse, EIN Modellbauer</span><span class="ch">\n</span><span class="st">&quot;</span>)</span>
<span id="cb3-192"><a href="#cb3-192" aria-hidden="true" tabindex="-1"></a> berichte_allokation(<span class="st">&quot;Werkstatt: Produktionsprogramm&quot;</span>, schreinerei(),</span>
<span id="cb3-193"><a href="#cb3-193" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Stueck&quot;</span>, <span class="st">&quot;Deckungsbeitrag&quot;</span>)</span>
<span id="cb3-194"><a href="#cb3-194" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-195"><a href="#cb3-195" aria-hidden="true" tabindex="-1"></a> berichte_allokation(<span class="st">&quot;Depot: Anlageaufteilung&quot;</span>, depot(),</span>
<span id="cb3-196"><a href="#cb3-196" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Tsd. &quot;</span>, <span class="st">&quot;Erwarteter Ertrag&quot;</span>)</span>
<span id="cb3-197"><a href="#cb3-197" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-198"><a href="#cb3-198" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;</span><span class="ch">\n</span><span class="st"> Beide Ausgaben stammen aus derselben Funktion &quot;</span></span>
<span id="cb3-199"><a href="#cb3-199" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;&#39;berichte_allokation&#39;.&quot;</span>)</span>
<span id="cb3-200"><a href="#cb3-200" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Ausgetauscht wurden nur die Daten und die Beschriftungen -&quot;</span>)</span>
<span id="cb3-201"><a href="#cb3-201" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; keine Zeile Modellcode.&quot;</span>)</span>
<span id="cb3-202"><a href="#cb3-202" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-203"><a href="#cb3-203" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Lesen Sie die Schattenpreise nebeneinander: In der Werkstatt sagt&quot;</span>)</span>
<span id="cb3-204"><a href="#cb3-204" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; er, was eine zusaetzliche Montagestunde wert waere. Im Depot sagt&quot;</span>)</span>
<span id="cb3-205"><a href="#cb3-205" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; dieselbe Zahl, was eine zusaetzliche Einheit Risikobudget wert&quot;</span>)</span>
<span id="cb3-206"><a href="#cb3-206" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; waere - der PREIS DES RISIKOS. Das ist kein Sprachbild, sondern&quot;</span>)</span>
<span id="cb3-207"><a href="#cb3-207" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; derselbe Dualwert derselben Nebenbedingung.&quot;</span>)</span>
<span id="cb3-208"><a href="#cb3-208" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-209"><a href="#cb3-209" aria-hidden="true" tabindex="-1"></a> <span class="co"># --- Teil 2 ----------------------------------------------------------</span></span>
<span id="cb3-210"><a href="#cb3-210" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;</span><span class="ch">\n</span><span class="st">&quot;</span> <span class="op">+</span> <span class="st">&quot;-&quot;</span> <span class="op">*</span> <span class="dv">80</span>)</span>
<span id="cb3-211"><a href="#cb3-211" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;2. Absicherung gegen den schlechtesten Fall - EINE CVaR-Funktion</span><span class="ch">\n</span><span class="st">&quot;</span>)</span>
<span id="cb3-212"><a href="#cb3-212" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-213"><a href="#cb3-213" aria-hidden="true" tabindex="-1"></a> kurse, rendite, anlagen <span class="op">=</span> kursszenarien(rng)</span>
<span id="cb3-214"><a href="#cb3-214" aria-hidden="true" tabindex="-1"></a> anteile_depot <span class="op">=</span> berichte_cvar(</span>
<span id="cb3-215"><a href="#cb3-215" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Depot: die schlechtesten 5 </span><span class="sc">% d</span><span class="st">er Handelstage&quot;</span>,</span>
<span id="cb3-216"><a href="#cb3-216" aria-hidden="true" tabindex="-1"></a> kurse, rendite, anlagen, <span class="fl">5.5</span>,</span>
<span id="cb3-217"><a href="#cb3-217" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;% je Tag &quot;</span>, <span class="st">&quot;Erwartete Jahresrendite (%)&quot;</span>)</span>
<span id="cb3-218"><a href="#cb3-218" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-219"><a href="#cb3-219" aria-hidden="true" tabindex="-1"></a> lieferung, zuverlaessig, lieferanten <span class="op">=</span> lieferszenarien(rng)</span>
<span id="cb3-220"><a href="#cb3-220" aria-hidden="true" tabindex="-1"></a> anteile_einkauf <span class="op">=</span> berichte_cvar(<span class="st">&quot;Einkauf: die schlechtesten 5 </span><span class="sc">% d</span><span class="st">er Bestellungen&quot;</span>,</span>
<span id="cb3-221"><a href="#cb3-221" aria-hidden="true" tabindex="-1"></a> lieferung, zuverlaessig, lieferanten, <span class="fl">0.945</span>,</span>
<span id="cb3-222"><a href="#cb3-222" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Tage Verzug &quot;</span>, <span class="st">&quot;Mittlere Zuverlaessigkeit&quot;</span>)</span>
<span id="cb3-223"><a href="#cb3-223" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-224"><a href="#cb3-224" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;</span><span class="ch">\n</span><span class="st"> Auch hier: eine Funktion, zwei Aufrufe. Die Zielfunktion&quot;</span>)</span>
<span id="cb3-225"><a href="#cb3-225" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; interessiert sich nicht dafuer, ob in der Matrix Prozentpunkte&quot;</span>)</span>
<span id="cb3-226"><a href="#cb3-226" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; oder Tage stehen.&quot;</span>)</span>
<span id="cb3-227"><a href="#cb3-227" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-228"><a href="#cb3-228" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; Interessant ist, WO die Streuungsgrenze von </span><span class="sc">{</span>MAX_ANTEIL<span class="sc">:.0%}</span><span class="ss"> bindet:&quot;</span>)</span>
<span id="cb3-229"><a href="#cb3-229" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; Depot : </span><span class="sc">{</span>(anteile_depot <span class="op">&gt;</span> MAX_ANTEIL <span class="op">-</span> <span class="fl">1e-4</span>)<span class="sc">.</span><span class="bu">sum</span>()<span class="sc">}</span><span class="ss"> von &quot;</span></span>
<span id="cb3-230"><a href="#cb3-230" aria-hidden="true" tabindex="-1"></a> <span class="ss">f&quot;</span><span class="sc">{</span><span class="bu">len</span>(anteile_depot)<span class="sc">}</span><span class="ss"> Posten am Anschlag&quot;</span>)</span>
<span id="cb3-231"><a href="#cb3-231" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f&quot; Einkauf : </span><span class="sc">{</span>(anteile_einkauf <span class="op">&gt;</span> MAX_ANTEIL <span class="op">-</span> <span class="fl">1e-4</span>)<span class="sc">.</span><span class="bu">sum</span>()<span class="sc">}</span><span class="ss"> von &quot;</span></span>
<span id="cb3-232"><a href="#cb3-232" aria-hidden="true" tabindex="-1"></a> <span class="ss">f&quot;</span><span class="sc">{</span><span class="bu">len</span>(anteile_einkauf)<span class="sc">}</span><span class="ss"> Posten am Anschlag&quot;</span>)</span>
<span id="cb3-233"><a href="#cb3-233" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-234"><a href="#cb3-234" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Im Einkauf zieht es die Loesung an den sicheren Lokalzulieferer,&quot;</span>)</span>
<span id="cb3-235"><a href="#cb3-235" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; bis die Grenze sie stoppt. Im Depot nicht - dort verhindert die&quot;</span>)</span>
<span id="cb3-236"><a href="#cb3-236" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Mindestrendite, dass alles in Anleihen wandert. Zwei verschiedene&quot;</span>)</span>
<span id="cb3-237"><a href="#cb3-237" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Bremsen also, und sie stehen an verschiedenen Stellen des Modells:&quot;</span>)</span>
<span id="cb3-238"><a href="#cb3-238" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; einmal in einer Nebenbedingung ueber die Anteile, einmal in einer&quot;</span>)</span>
<span id="cb3-239"><a href="#cb3-239" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; ueber den Ertrag. Wer eine Struktur uebertraegt, uebertraegt eben&quot;</span>)</span>
<span id="cb3-240"><a href="#cb3-240" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; nicht automatisch mit, WELCHE Bedingung am Ende bindet.&quot;</span>)</span>
<span id="cb3-241"><a href="#cb3-241" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-242"><a href="#cb3-242" aria-hidden="true" tabindex="-1"></a> <span class="co"># --- Teil 3: Der ehrliche Teil ---------------------------------------</span></span>
<span id="cb3-243"><a href="#cb3-243" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;</span><span class="ch">\n</span><span class="st">&quot;</span> <span class="op">+</span> <span class="st">&quot;=&quot;</span> <span class="op">*</span> <span class="dv">80</span>)</span>
<span id="cb3-244"><a href="#cb3-244" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; WAS NICHT HINUEBERREICHT&quot;</span>)</span>
<span id="cb3-245"><a href="#cb3-245" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;=&quot;</span> <span class="op">*</span> <span class="dv">80</span>)</span>
<span id="cb3-246"><a href="#cb3-246" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;Die Struktur traegt. Drei Unterschiede tragen NICHT mit, und wer sie&quot;</span>)</span>
<span id="cb3-247"><a href="#cb3-247" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;uebersieht, macht aus einer nuetzlichen Analogie einen Fehler:&quot;</span>)</span>
<span id="cb3-248"><a href="#cb3-248" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-249"><a href="#cb3-249" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;1. WOHER DIE ZAHLEN KOMMEN.&quot;</span>)</span>
<span id="cb3-250"><a href="#cb3-250" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; In der Werkstatt ist der Verbrauch je Tisch gemessen - drei&quot;</span>)</span>
<span id="cb3-251"><a href="#cb3-251" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Montagestunden sind drei Montagestunden. Im Depot ist die&quot;</span>)</span>
<span id="cb3-252"><a href="#cb3-252" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; erwartete Rendite GESCHAETZT, und zwar mit einem Fehler, der&quot;</span>)</span>
<span id="cb3-253"><a href="#cb3-253" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; groesser sein kann als die Unterschiede zwischen den Anlagen&quot;</span>)</span>
<span id="cb3-254"><a href="#cb3-254" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; (Kapitel Markowitz, Renditeschaetzung_Falle.py). Dieselbe&quot;</span>)</span>
<span id="cb3-255"><a href="#cb3-255" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Optimierung ist im einen Fall Planung und im anderen&quot;</span>)</span>
<span id="cb3-256"><a href="#cb3-256" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Fehlerverstaerkung.&quot;</span>)</span>
<span id="cb3-257"><a href="#cb3-257" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-258"><a href="#cb3-258" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;2. OB DIE VERGANGENHEIT ETWAS UEBER DIE ZUKUNFT SAGT.&quot;</span>)</span>
<span id="cb3-259"><a href="#cb3-259" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Lieferzeiten haben physikalische Ursachen: Entfernung, Zoll,&quot;</span>)</span>
<span id="cb3-260"><a href="#cb3-260" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Kapazitaet. Sie aendern sich langsam und nachvollziehbar.&quot;</span>)</span>
<span id="cb3-261"><a href="#cb3-261" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Kursrenditen entstehen aus dem Verhalten von Marktteilnehmern,&quot;</span>)</span>
<span id="cb3-262"><a href="#cb3-262" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; die selbst auf Modelle reagieren - dort verschwindet ein&quot;</span>)</span>
<span id="cb3-263"><a href="#cb3-263" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; erkanntes Muster oft genau deshalb, weil es erkannt wurde&quot;</span>)</span>
<span id="cb3-264"><a href="#cb3-264" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; (Kapitel Handelsmaschine, Data_Snooping.py).&quot;</span>)</span>
<span id="cb3-265"><a href="#cb3-265" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-266"><a href="#cb3-266" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;3. OB TEILBARKEIT ERLAUBT IST.&quot;</span>)</span>
<span id="cb3-267"><a href="#cb3-267" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; 37,4 </span><span class="sc">% e</span><span class="st">ines Aktienfonds sind ein normaler Auftrag. 37,4 </span><span class="sc">% e</span><span class="st">ines&quot;</span>)</span>
<span id="cb3-268"><a href="#cb3-268" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Lieferanten sind es nicht - Vertraege, Mindestabnahmen und&quot;</span>)</span>
<span id="cb3-269"><a href="#cb3-269" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; Ruestzeiten machen Einkaufsentscheidungen ganzzahlig. Genau&quot;</span>)</span>
<span id="cb3-270"><a href="#cb3-270" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot; deshalb ist Teil II voller MILP und Teil V fast frei davon.&quot;</span>)</span>
<span id="cb3-271"><a href="#cb3-271" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>()</span>
<span id="cb3-272"><a href="#cb3-272" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;Die Bruecke traegt also die MODELLE, nicht die Annahmen. Wer sie&quot;</span>)</span>
<span id="cb3-273"><a href="#cb3-273" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;benutzt, spart sich das Lernen der Methoden - nicht das Nachdenken&quot;</span>)</span>
<span id="cb3-274"><a href="#cb3-274" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;ueber die Daten.&quot;</span>)</span>
<span id="cb3-275"><a href="#cb3-275" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">&quot;=&quot;</span> <span class="op">*</span> <span class="dv">80</span>)</span></code></pre></div>
<p><strong>Erwartete Ausgabe:</strong></p>
<pre><code>================================================================================
DIESELBE STRUKTUR, ZWEI WELTEN
================================================================================
1. Allokation als LP - EINE Klasse, EIN Modellbauer
Werkstatt: Produktionsprogramm
Status: optimal | Zielwert: 10,800.00 | Gap: 0.00% | Zeit: 0.00s
Tisch 30.00 Stueck
Stuhl 60.00 Stueck
Regal 0.00 Stueck
Deckungsbeitrag 10800.00 EUR
Schattenpreis Montagestunden 40.00 EUR
Schattenpreis Plattenmaterial 20.00 EUR
Abnahmepruefung: bestanden
Depot: Anlageaufteilung
Status: optimal | Zielwert: 7,634.62 | Gap: 0.00% | Zeit: 0.00s
Aktien Welt 73.08 Tsd.
Anleihen 76.92 Tsd.
Immobilienfonds 0.00 Tsd.
Erwarteter Ertrag 7634.62 EUR
Schattenpreis Kapital (Tsd. EUR) 14.74 EUR
Schattenpreis Risikobudget 60.26 EUR
Abnahmepruefung: bestanden
Beide Ausgaben stammen aus derselben Funktion &#39;berichte_allokation&#39;.
Ausgetauscht wurden nur die Daten und die Beschriftungen -
keine Zeile Modellcode.
Lesen Sie die Schattenpreise nebeneinander: In der Werkstatt sagt
er, was eine zusaetzliche Montagestunde wert waere. Im Depot sagt
dieselbe Zahl, was eine zusaetzliche Einheit Risikobudget wert
waere - der PREIS DES RISIKOS. Das ist kein Sprachbild, sondern
derselbe Dualwert derselben Nebenbedingung.
--------------------------------------------------------------------------------
2. Absicherung gegen den schlechtesten Fall - EINE CVaR-Funktion
Depot: die schlechtesten 5 % der Handelstage
VaR 95%: 0.521 % je Tag
CVaR 95%: 0.644 % je Tag (Mittelwert ueber alle Szenarien: -0.011)
Erwartete Jahresrendite (%): 5.500
Aufteilung:
Aktien Welt 14.9% ######
Aktien EU 12.2% #####
Schwellenlaender 9.6% ####
Staatsanleihen 26.8% ###########
Unternehmensanl. 30.7% ############
Rohstoffe 5.7% ##
Einkauf: die schlechtesten 5 % der Bestellungen
VaR 95%: 4.351 Tage Verzug
CVaR 95%: 5.716 Tage Verzug (Mittelwert ueber alle Szenarien: 2.072)
Mittlere Zuverlaessigkeit: 0.963
Aufteilung:
Nordwerk 12.6% #####
Sued-Metall 22.1% #########
Fernost A 6.2% ##
Lokalzulieferer 40.0% ################ &lt;- an der Streuungsgrenze
Fernost B 8.7% ###
Osteuropa 10.4% ####
Auch hier: eine Funktion, zwei Aufrufe. Die Zielfunktion
interessiert sich nicht dafuer, ob in der Matrix Prozentpunkte
oder Tage stehen.
Interessant ist, WO die Streuungsgrenze von 40% bindet:
Depot : 0 von 6 Posten am Anschlag
Einkauf : 1 von 6 Posten am Anschlag
Im Einkauf zieht es die Loesung an den sicheren Lokalzulieferer,
bis die Grenze sie stoppt. Im Depot nicht - dort verhindert die
Mindestrendite, dass alles in Anleihen wandert. Zwei verschiedene
Bremsen also, und sie stehen an verschiedenen Stellen des Modells:
einmal in einer Nebenbedingung ueber die Anteile, einmal in einer
ueber den Ertrag. Wer eine Struktur uebertraegt, uebertraegt eben
nicht automatisch mit, WELCHE Bedingung am Ende bindet.
================================================================================
WAS NICHT HINUEBERREICHT
================================================================================
Die Struktur traegt. Drei Unterschiede tragen NICHT mit, und wer sie
uebersieht, macht aus einer nuetzlichen Analogie einen Fehler:
1. WOHER DIE ZAHLEN KOMMEN.
In der Werkstatt ist der Verbrauch je Tisch gemessen - drei
Montagestunden sind drei Montagestunden. Im Depot ist die
erwartete Rendite GESCHAETZT, und zwar mit einem Fehler, der
groesser sein kann als die Unterschiede zwischen den Anlagen
(Kapitel Markowitz, Renditeschaetzung_Falle.py). Dieselbe
Optimierung ist im einen Fall Planung und im anderen
Fehlerverstaerkung.
2. OB DIE VERGANGENHEIT ETWAS UEBER DIE ZUKUNFT SAGT.
Lieferzeiten haben physikalische Ursachen: Entfernung, Zoll,
Kapazitaet. Sie aendern sich langsam und nachvollziehbar.
Kursrenditen entstehen aus dem Verhalten von Marktteilnehmern,
die selbst auf Modelle reagieren - dort verschwindet ein
erkanntes Muster oft genau deshalb, weil es erkannt wurde
(Kapitel Handelsmaschine, Data_Snooping.py).
3. OB TEILBARKEIT ERLAUBT IST.
37,4 % eines Aktienfonds sind ein normaler Auftrag. 37,4 % eines
Lieferanten sind es nicht - Vertraege, Mindestabnahmen und
Ruestzeiten machen Einkaufsentscheidungen ganzzahlig. Genau
deshalb ist Teil II voller MILP und Teil V fast frei davon.
Die Bruecke traegt also die MODELLE, nicht die Annahmen. Wer sie
benutzt, spart sich das Lernen der Methoden - nicht das Nachdenken
ueber die Daten.
================================================================================</code></pre>
<hr />
<h2 id="sec:bruecke-einzelnen">16.4 Die zwei Brücken im Einzelnen</h2>
<h3 id="erste-brücke-allokation">Erste Brücke: Allokation</h3>
<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="header">
<th>Werkstatt</th>
<th>Depot</th>
<th>im Modell</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Montagestunden, Plattenmaterial</td>
<td>Kapital, Risikobudget</td>
<td><code>kapazitaeten</code></td>
</tr>
<tr class="even">
<td>Tisch, Stuhl, Regal</td>
<td>Aktien, Anleihen, Immobilien</td>
<td><code>produkte</code></td>
</tr>
<tr class="odd">
<td>Verbrauch je Stück</td>
<td>Beanspruchung je 1 000 €</td>
<td><code>verbrauch</code></td>
</tr>
<tr class="even">
<td>Deckungsbeitrag je Stück</td>
<td>Erwarteter Ertrag je 1 000 €</td>
<td><code>deckungsbeitrag</code></td>
</tr>
<tr class="odd">
<td>Wert einer Montagestunde</td>
<td><strong>Preis des Risikos</strong></td>
<td><code>schattenpreise</code></td>
</tr>
</tbody>
</table>
<p>Die letzte Zeile ist die, die sich zu merken lohnt. Ein Portfoliomanager, der sagt „unser Risikobudget ist zu knapp bemessen”, trifft dieselbe Aussage wie ein Fertigungsleiter, der eine zweite Schicht fordert — und beide können sie mit derselben Zahl belegen.</p>
<h3 id="zweite-brücke-absicherung-gegen-den-schlechtesten-fall">Zweite Brücke: Absicherung gegen den schlechtesten Fall</h3>
<p>Hier ist die Übereinstimmung noch enger, weil sie nicht nur die Struktur betrifft, sondern die <em>Formel</em>. Die Rockafellar-Uryasev-Formulierung aus <a href="cvar.html#kap-cvar">Kapitel 20</a></p>
<p><span class="math display">
\min_{w,\;\gamma} \;\; \gamma + \frac{1}{S(1-\alpha)} \sum_{s=1}^{S} u_s
\qquad \text{mit} \qquad
u_s \ge \ell_s^\top w - \gamma, \quad u_s \ge 0
</span></p>
<p>steht im Programm genau einmal und wird zweimal aufgerufen.</p>
<div class="card card-formel">
<blockquote>
<p><strong>🔤 Formel-Übersetzer</strong></p>
<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="header">
<th>Mathematik</th>
<th>im Depot</th>
<th>im Einkauf</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><span class="math inline">w</span></td>
<td>Anteil je Anlageklasse</td>
<td>Bestellanteil je Lieferant</td>
</tr>
<tr class="even">
<td><span class="math inline">\ell_s</span></td>
<td>Verlust in Szenario <span class="math inline">s</span>, in Prozentpunkten</td>
<td>Verzug in Szenario <span class="math inline">s</span>, in Tagen</td>
</tr>
<tr class="odd">
<td><span class="math inline">\gamma</span></td>
<td>der VaR: „so schlimm wird es an 95 % der Tage höchstens”</td>
<td>„so viele Tage Verzug höchstens bei 95 % der Bestellungen”</td>
</tr>
<tr class="even">
<td><span class="math inline">u_s</span></td>
<td>Überschuss über diese Schwelle</td>
<td>dasselbe</td>
</tr>
<tr class="odd">
<td>Zielwert</td>
<td>CVaR: Mittelwert der schlechtesten 5 %</td>
<td>dasselbe</td>
</tr>
</tbody>
</table>
<p><strong>Ohne Formel gesagt:</strong> „Sorge dafür, dass die schlimmsten fünf Prozent der Fälle im Mittel so glimpflich wie möglich ausgehen.” Dieser Satz enthält kein Wort, das nur an der Börse Sinn ergibt.</p>
</blockquote>
</div>
<p>Beide Anwendungen haben denselben Grund, warum sie CVaR und nicht die Standardabweichung benutzen: <strong>fette Ränder.</strong> Ein Lieferant fällt selten aus, aber wenn, dann kostet es vierzehn Tage — genau die Verteilungsform, bei der die Standardabweichung in die Irre führt (<a href="cvar.html#kap-cvar">Kapitel 20</a>).</p>
<h3 id="wo-die-lösungen-sich-unterscheiden">Wo die Lösungen sich unterscheiden</h3>
<p>Der Vergleich fördert nebenbei einen Unterschied zutage, den man nicht erwartet: Die Streuungsgrenze von 40 % <strong>bindet nur im Einkauf</strong>, nicht im Depot.</p>
<p>Im Einkauf zieht es die Lösung an den sicheren Lokalzulieferer, bis die Grenze sie stoppt. Im Depot verhindert stattdessen die Mindestrendite, dass alles in Anleihen wandert. Zwei verschiedene Bremsen also — und sie sitzen an verschiedenen Stellen des Modells.</p>
<p>Das ist die feine, wichtige Lehre dieses Abschnitts: <strong>Wer eine Struktur überträgt, überträgt nicht automatisch mit, welche Nebenbedingung am Ende bindet.</strong> Und das ist die Information, die im Gespräch mit dem Fachbereich zählt.</p>
<hr />
<h2 id="sec:bruecke-grenzen">16.5 Wo die Brücke endet</h2>
<p>Eine Analogie ist nur so nützlich wie die Grenzen, die man ihr zieht. Drei Dinge wandern <strong>nicht</strong> mit:</p>
<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="header">
<th></th>
<th>Werkstatt / Einkauf</th>
<th>Depot</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><strong>Woher die Zahlen kommen</strong></td>
<td>gemessen: drei Montagestunden sind drei Montagestunden</td>
<td>geschätzt: die erwartete Rendite hat einen Fehler, der größer sein kann als die Unterschiede zwischen den Anlagen (<a href="markowitz.html#kap-markowitz">Kapitel 19</a>)</td>
</tr>
<tr class="even">
<td><strong>Ob die Vergangenheit trägt</strong></td>
<td>Lieferzeiten haben physikalische Ursachen und ändern sich langsam</td>
<td>Kurse entstehen aus dem Verhalten von Marktteilnehmern, die auf Modelle reagieren — ein erkanntes Muster verschwindet oft deshalb, weil es erkannt wurde (<a href="handelsmaschine.html#kap-handelsmaschine">Kapitel 21</a>)</td>
</tr>
<tr class="odd">
<td><strong>Ob Teilbarkeit erlaubt ist</strong></td>
<td>37,4 % eines Lieferanten gibt es nicht: Verträge, Mindestabnahmen, Rüstzeiten → MILP</td>
<td>37,4 % eines Fonds sind ein normaler Auftrag → LP/QP genügt</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>⚠️ Der Fehler, vor dem diese Tabelle schützt</strong></p>
<p>Dieselbe Optimierung ist in der Werkstatt <strong>Planung</strong> und im Depot <strong>Fehlerverstärkung</strong>. Ein LP sucht die Ecke des zulässigen Bereichs mit dem besten Zielwert — und wenn die Zielkoeffizienten Schätzungen mit großem Fehler sind, sucht es genau die Ecke, an der der Schätzfehler am günstigsten aussieht.</p>
<p>In der Werkstatt gibt es dieses Problem nicht, weil der Deckungsbeitrag je Tisch aus der Kalkulation kommt und nicht aus einer Zeitreihe. Deshalb ist Shrinkage (<a href="finanzdaten.html#kap-finanzdaten">Kapitel 18</a>) im Depot Pflicht und in der Fertigung unbekannt.</p>
<p>Die dritte Zeile erklärt außerdem eine Beobachtung, die aufmerksamen Lesern längst aufgefallen ist: <strong>Teil II ist voller MILP, Teil IV fast frei davon.</strong> Das liegt nicht an der Methode, sondern daran, was in der jeweiligen Welt teilbar ist.</p>
</blockquote>
<hr />
<h2 id="sec:bruecke-uebungsaufgaben">16.6 Übungsaufgaben</h2>
<blockquote>
<p>Lösungen: <a href="anhang-loesungen.html#sec:loesungen-bruecke">Abschnitt A.16</a>.</p>
</blockquote>
<p><strong>Aufgabe 16.1 ⭐ — Die dritte Ressource.</strong> Ergänzen Sie im Depot eine dritte knappe Größe: „Liquidität” (wie schnell sich eine Anlage verkaufen lässt). Was entspricht ihr in der Werkstatt?</p>
<p><strong>Aufgabe 16.2 ⭐ — Den Schattenpreis lesen.</strong> Das Risikobudget hat einen Schattenpreis von 60,26 €. Die Aufsicht bietet an, es gegen eine Gebühr um 10 Einheiten zu erhöhen. Bis zu welcher Gebühr lohnt sich das — und welche Einschränkung dieser Aussage kennen Sie aus <a href="lp.html#sec:lp-entartung">Abschnitt 5.9</a>?</p>
<p><strong>Aufgabe 16.3 ⭐⭐ — Die Brücke rückwärts.</strong> Übertragen Sie die Ledoit-Wolf-Shrinkage aus <a href="finanzdaten.html#kap-finanzdaten">Kapitel 18</a> auf Lieferzeiten: Wo genau träte dort dasselbe Problem auf, und welche Daten bräuchten Sie?</p>
<p><strong>Aufgabe 16.4 ⭐⭐ — CVaR mit Ganzzahligkeit.</strong> Der Einkauf darf höchstens <strong>drei</strong> Lieferanten beauftragen. Ergänzen Sie die entsprechende Kardinalitätsbedingung (<a href="milp.html#kap-milp">Kapitel 6</a>, Muster 5) und vergleichen Sie den CVaR mit dem teilbaren Fall. Was kostet die Ganzzahligkeit?</p>
<p><strong>Aufgabe 16.5 ⭐⭐⭐ — Die eigene Brücke.</strong> Nehmen Sie ein Modell aus Ihrem Arbeitsumfeld und suchen Sie die Entsprechung in der jeweils anderen Welt. Prüfen Sie mit der Tabelle aus <a href="#sec:bruecke-grenzen">Abschnitt 16.5</a>, ob die Übertragung trägt — und schreiben Sie auf, welche der drei Zeilen im Weg steht.</p>
<hr />
<h2 id="sec:bruecke-denkfehler">16.7 Finde den Denkfehler</h2>
<div class="card card-denkfehler">
<blockquote>
<p><strong>🐛 „Das ist doch dasselbe Problem”</strong></p>
<p>Eine Logistikerin liest dieses Kapitel und überträgt es zurück. Ihre Aufgabe: Aus 40 möglichen Lieferanten sollen die besten ausgewählt und Bestellmengen zugeteilt werden. Sie geht vor wie im Portfoliomanagement:</p>
<blockquote>
<p><em>„Ich habe für jeden Lieferanten aus den letzten drei Jahren die mittlere Lieferzeit und &gt; die Kovarianzmatrix der Lieferzeiten geschätzt. Dann habe ich das Markowitz-Modell &gt; angewendet: minimiere die Varianz der Gesamtlieferzeit bei vorgegebener mittlerer &gt; Lieferzeit. Das Ergebnis ist ein sauber diversifiziertes Lieferantenportfolio.”</em></p>
</blockquote>
<p>Das Vorgehen ist methodisch sauber, die Rechnung stimmt, und das Ergebnis sieht plausibel aus.</p>
<p><strong>Zwei Dinge daran sind falsch — und das eine ist genau der Fehler, vor dem dieses Kapitel warnt, das andere ein zusätzlicher, den es nicht behandelt. Welche?</strong></p>
</blockquote>
</div>
<hr />
<h2 id="sec:bruecke-quiz">16.8 Micro-Quiz</h2>
<div class="card card-quiz">
<blockquote>
<p><strong>❓ Drei Fragen</strong></p>
<p><strong>1. Warum passt das Depot in die Klasse <code>Produktionsproblem</code>, ohne dass etwas geändert werden muss?</strong> a) Weil <code>Produktionsproblem</code> mit <code>Any</code>-Typen arbeitet und alles akzeptiert. b) Weil beide Probleme dieselbe Struktur haben: knappe Größen auf konkurrierende Verwendungen verteilen. c) Weil Pydantic die Feldnamen automatisch übersetzt.</p>
<p><strong>2. Der Schattenpreis des Risikobudgets beträgt 60,26 €. Was bedeutet das?</strong> a) Das Risikobudget ist zu 60,26 % ausgelastet. b) Eine zusätzliche Einheit Risikobudget würde den erwarteten Ertrag um rund 60,26 € erhöhen — solange die Basis sich nicht ändert. c) Jede Einheit Risikobudget kostet die Bank 60,26 €.</p>
<p><strong>3. Welche der drei Grenzen der Analogie ist der Grund dafür, dass Teil II voller MILP ist und Teil IV fast frei davon?</strong> a) Woher die Zahlen kommen. b) Ob die Vergangenheit etwas über die Zukunft sagt. c) Ob Teilbarkeit erlaubt ist.</p>
</blockquote>
</div>
<hr />
<h2 id="sec:bruecke-selbsttest">16.9 Selbsttest</h2>
<ol type="1">
<li>Nennen Sie drei Größenpaare, die in Werkstatt und Depot einander entsprechen.</li>
<li>Warum weiß ein LP nichts über die Bedeutung seiner Zahlen — und warum ist das hier ein Vorteil?</li>
<li>Erklären Sie den „Preis des Risikos” jemandem, der nur Fertigungsplanung kennt.</li>
<li>Warum benutzen beide Welten CVaR statt der Standardabweichung? Nennen Sie die Verteilungseigenschaft, um die es geht.</li>
<li>Sie wollen ein Verfahren aus der Finanzwelt in die Produktion übertragen. Welche drei Fragen stellen Sie vorher?</li>
</ol>
<hr />
<h2 id="sec:bruecke-zusammenfassung">16.10 Zusammenfassung</h2>
<ul>
<li>Die Behauptung „dieselben Methoden, andere Domäne” ist prüfbar — und hier geprüft: Ein Depot passt unverändert in die Klasse <code>Produktionsproblem</code>, und <strong>eine</strong> CVaR-Funktion bearbeitet Kursverluste wie Lieferverzüge.</li>
<li>Der <strong>Schattenpreis</strong> einer Ressource heißt in der Finanzwelt <em>Preis des Risikos</em>. Es ist derselbe Dualwert derselben Nebenbedingung.</li>
<li>Die <strong>CVaR-Formulierung</strong> enthält kein Wort, das nur an der Börse Sinn ergibt. Beide Welten benutzen sie aus demselben Grund: fette Ränder, bei denen die Standardabweichung in die Irre führt.</li>
<li>Übertragen wird die <strong>Struktur</strong>, nicht die <strong>Annahmen</strong>. Drei Dinge wandern nicht mit: woher die Zahlen kommen (gemessen gegen geschätzt), ob die Vergangenheit trägt (Physik gegen reagierende Marktteilnehmer) und ob Teilbarkeit erlaubt ist (MILP gegen LP).</li>
<li>Die erste dieser Grenzen ist die gefährlichste: Dieselbe Optimierung ist in der Werkstatt Planung und im Depot Fehlerverstärkung.</li>
</ul>
</article>
<button type="button" class="fortschritt-knopf" data-kapitel="bruecke.html"><svg class="icon" aria-hidden="true"><use href="#icon-check"></use></svg> <span>Als gelesen markieren</span></button>
<nav class="prev-next"><a class="prev-next-knopf prev-next-prev" href="prognose.html"><svg class="icon" aria-hidden="true"><use href="#icon-chevron-left"></use></svg><span><small>Zurück</small>Kapitel 15: Predict-then-Optimize — die bessere Prognose, die schlechtere Entscheidung</span></a><a class="prev-next-knopf prev-next-next" href="supplychain.html"><span><small>Weiter</small>Kapitel 17: Supply-Chain und Energieeinsatz unter Unsicherheit</span><svg class="icon" aria-hidden="true"><use href="#icon-chevron-right"></use></svg></a></nav>
</main>
</div>
<footer class="site-footer">
<p>© Dieter Schlüter · <a href="gesamtdokument.html">Gesamtdokument</a> ·
<a href="programme.html">Beispielprogramme</a></p>
</footer>
<script defer src="assets/search-index.js"></script>
<script defer src="assets/programme.js"></script>
<script defer src="assets/site.js"></script>
</body>
</html>