Glossar: Sprungleiste, Abkürzungen ausschreiben, CLAUDE.md-Regel

Sprungleiste (A B C ... Z) im Glossar — wie im Stichwortverzeichnis:
ein Klick je Buchstabe springt zur '## <Buchstabe>'-Überschrift.
Eingebaut in erzeuge_glossar_04.py als {=html}-Rohblock (nur HTML,
im PDF bedeutungslos).

Abkürzungen beim ersten Mal ausschreiben: 'VaR' → 'VaR (Value at Risk)',
'EVPI' → 'EVPI (Expected Value of Perfect Information)' als Link-Text
bei der ersten Nennung je Datei; danach nur die Abkürzung. 19 Abkürzungen
erfasst (VaR, CVaR, KKT, NLP, MILP, EVPI, LP, QP, ...).

CLAUDE.md: Regel 'Glossar-Links: Fachbegriffe im Fließtext automatisch
verlinkt' dokumentiert — resolve_glossar(), LINK_TEXTE,
ABBREV_ERSTE_NENNUNG, _NICHT_AUTO_LINKEN, _ZU_KURZ_ABK, .glossar-link,
{gl:}-Marke, Sprungleiste, {#gloss:<slug>}-Anchor.
This commit is contained in:
dschlueter 2026-09-10 17:52:49 +02:00
commit 0e2c011732
47 changed files with 545 additions and 561 deletions

View file

@ -197,7 +197,7 @@
<blockquote>
<p>Nimm eine Bedingung versuchsweise heraus. Bleibt der Rest unlösbar, wurde sie nicht gebraucht: weg damit, endgültig. Wird der Rest lösbar, war sie beteiligt: sie bleibt.</p>
</blockquote>
<p>Nach genau einem Durchlauf über alle <span class="math inline">n</span> Bedingungen ist die übrig gebliebene Menge <strong>unreduzierbar</strong> — entfernt man aus ihr irgendeine Bedingung, ist der Rest lösbar. Das ist ein <em>Irreducible Infeasible Subset</em>, kurz <a href="anhang-glossar.md#gloss:iis-irreducible-infeasible-subset" class="glossar-link">IIS</a>. Kommerzielle Solver bieten das als fertige Funktion an (<code>computeIIS</code> bei <a href="anhang-glossar.md#gloss:gurobi" class="glossar-link">Gurobi</a>, der Conflict Refiner bei CPLEX); im Open-Source-Werkzeugkasten dieses Buchs gibt es sie nicht — sie ist aber in zwanzig Zeilen selbst geschrieben, und sie kostet <span class="math inline">n</span> Aufrufe des Solvers statt <span class="math inline">2^n</span> durchprobierter Teilmengen.</p>
<p>Nach genau einem Durchlauf über alle <span class="math inline">n</span> Bedingungen ist die übrig gebliebene Menge <strong>unreduzierbar</strong> — entfernt man aus ihr irgendeine Bedingung, ist der Rest lösbar. Das ist ein <em>Irreducible Infeasible Subset</em>, kurz <a href="anhang-glossar.md#gloss:iis-irreducible-infeasible-subset" class="glossar-link">IIS (Irreducible Infeasible Subset)</a>. Kommerzielle Solver bieten das als fertige Funktion an (<code>computeIIS</code> bei <a href="anhang-glossar.md#gloss:gurobi" class="glossar-link">Gurobi</a>, der Conflict Refiner bei CPLEX); im Open-Source-Werkzeugkasten dieses Buchs gibt es sie nicht — sie ist aber in zwanzig Zeilen selbst geschrieben, und sie kostet <span class="math inline">n</span> Aufrufe des Solvers statt <span class="math inline">2^n</span> durchprobierter Teilmengen.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co">#!/usr/bin/env python3</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Konfliktsuche.py</span></span>
@ -567,9 +567,9 @@ Insgesamt 2874 Solveraufrufe fuer die gesamte Diagnose.
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a>loesen()<span class="op">;</span> t2 <span class="op">=</span> time.perf_counter()</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f&quot;Aufbau </span><span class="sc">{</span>t1<span class="op">-</span>t0<span class="sc">:.2f}</span><span class="ss">s | Loesen </span><span class="sc">{</span>t2<span class="op">-</span>t1<span class="sc">:.2f}</span><span class="ss">s&quot;</span>)</span></code></pre></div>
<p>Bei CVXPY und bei Schleifen über Szenarien ist oft der <strong>Aufbau</strong> der Engpass, nicht der Solver (siehe <a href="cvar.html#sec:cvar-implementierung-cvar-portfolio-mit-reibung">Abschnitt 20.6</a>).</p>
<p><strong>2. Big-M zu groß?</strong> Der häufigste Grund für explodierende <a href="anhang-glossar.md#gloss:gemischt-ganzzahlige-optimierung-milp" class="glossar-link">MILP</a>-Laufzeiten. Setzen Sie <span class="math inline">M</span> auf die kleinste gültige Schranke (<a href="milp.html#sec:milp-modellierungstricks-big-m-und-logische-bedingungen">Abschnitt 6.5</a>).</p>
<p><strong>2. Big-M zu groß?</strong> Der häufigste Grund für explodierende <a href="anhang-glossar.md#gloss:gemischt-ganzzahlige-optimierung-milp" class="glossar-link">MILP (Gemischt-ganzzahlige Optimierung)</a>-Laufzeiten. Setzen Sie <span class="math inline">M</span> auf die kleinste gültige Schranke (<a href="milp.html#sec:milp-modellierungstricks-big-m-und-logische-bedingungen">Abschnitt 6.5</a>).</p>
<p><strong>3. Symmetrie im Modell?</strong> Identische Maschinen, austauschbare Mitarbeitende, gleichwertige Fahrzeuge — der Solver durchsucht alle Vertauschungen. Abhilfe: Ordnungsbedingungen (Muster B20).</p>
<p><strong>4. Falsche Solverfamilie?</strong> Zuordnungsprobleme mit MILP, Routing mit <a href="anhang-glossar.md#gloss:constraint-programming-cp" class="glossar-link">CP</a>-<a href="anhang-glossar.md#gloss:sat-boolean-satisfiability" class="glossar-link">SAT</a> von Hand nachgebaut, konvexe Probleme mit <code>scipy.optimize.minimize</code> — jeweils Größenordnungen langsamer als das passende Werkzeug (<a href="oekosystem.html#sec:oekosystem-wann-lohnt-sich-welche-ebene">Abschnitt 3.6</a>).</p>
<p><strong>4. Falsche Solverfamilie?</strong> Zuordnungsprobleme mit MILP, Routing mit <a href="anhang-glossar.md#gloss:constraint-programming-cp" class="glossar-link">CP (Constraint Programming)</a>-<a href="anhang-glossar.md#gloss:sat-boolean-satisfiability" class="glossar-link">SAT (Boolean Satisfiability)</a> von Hand nachgebaut, konvexe Probleme mit <code>scipy.optimize.minimize</code> — jeweils Größenordnungen langsamer als das passende Werkzeug (<a href="oekosystem.html#sec:oekosystem-wann-lohnt-sich-welche-ebene">Abschnitt 3.6</a>).</p>
<p><strong>5. Wird vektorisiert?</strong></p>
<div class="sourceCode" id="cb8"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="co"># langsam: # schnell:</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> s <span class="kw">in</span> <span class="bu">range</span>(S): constraints.append(u <span class="op">&gt;=</span> <span class="op">-</span>(R <span class="op">@</span> w) <span class="op">-</span> gamma)</span>
@ -694,7 +694,7 @@ Insgesamt 2874 Solveraufrufe fuer die gesamte Diagnose.
<tr class="odd">
<td><code>x * y</code> (beide Variablen)</td>
<td>bilinear</td>
<td>umformulieren oder MILP/<a href="anhang-glossar.md#gloss:nichtlineare-programmierung-nlp" class="glossar-link">NLP</a></td>
<td>umformulieren oder MILP/<a href="anhang-glossar.md#gloss:nichtlineare-programmierung-nlp" class="glossar-link">NLP (Nichtlineare Programmierung)</a></td>
</tr>
<tr class="even">
<td><code>a / x</code></td>
@ -703,7 +703,7 @@ Insgesamt 2874 Solveraufrufe fuer die gesamte Diagnose.
</tr>
<tr class="odd">
<td><code>cp.sqrt(cp.quad_form(w, S))</code></td>
<td><code>cp.sqrt</code> ist <strong>konkav</strong> und verlangt ein konkaves Argument — <code>quad_form</code> ist konvex. Der Ausdruck ist nie <a href="anhang-glossar.md#gloss:dcp-disciplined-convex-programming" class="glossar-link">DCP</a>, egal wie sauber <span class="math inline">S</span> ist</td>
<td><code>cp.sqrt</code> ist <strong>konkav</strong> und verlangt ein konkaves Argument — <code>quad_form</code> ist konvex. Der Ausdruck ist nie <a href="anhang-glossar.md#gloss:dcp-disciplined-convex-programming" class="glossar-link">DCP (Disciplined Convex Programming)</a>, egal wie sauber <span class="math inline">S</span> ist</td>
<td>Cholesky <span class="math inline">S = LL^\top</span>, dann <code>cp.norm2(L.T @ w)</code>: die 2-Norm eines <strong>affinen</strong> Ausdrucks (siehe <code>CVaR_Portfolio.py</code>)</td>
</tr>
<tr class="even">