Skip to content

Commit ff4c67b

Browse files
committed
docs(portfolio-optimization): reframe constraint solver value proposition
- Replace misleading "greedy vs solver" narrative with honest assessment - Explain real value: declarative rules, extensibility, complexity scaling - Remove comparison script references from article - Acknowledge this simplified quickstart works well with greedy
1 parent 1b47658 commit ff4c67b

File tree

1 file changed

+9
-30
lines changed

1 file changed

+9
-30
lines changed

content/en/docs/getting-started/portfolio-optimization.md

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -146,41 +146,20 @@ You have **$100,000** to invest and must select **20 stocks** from a pool of can
146146
**Soft constraints** (preferences to optimize):
147147
- Maximize total expected return (pick stocks with highest predictions)
148148

149-
### Why This is Hard
149+
### Why Use a Constraint Solver?
150150

151-
A naive **greedy algorithm** would sort stocks by predicted return and pick the top 20. But what happens when the top 8 stocks are all Technology?
151+
For this simplified quickstart (Boolean selection with sector limits), a well-implemented greedy algorithm can find near-optimal solutions. So why use a constraint solver?
152152

153-
**Example scenario:**
154-
| Rank | Stock | Sector | Predicted Return |
155-
|------|-------|--------|------------------|
156-
| 1 | NVDA | Technology | 20% |
157-
| 2 | TSLA | Technology | 18% |
158-
| 3 | GOOGL | Technology | 15% |
159-
| 4 | AMD | Technology | 14% |
160-
| 5 | AAPL | Technology | 12% |
161-
| 6 | CRM | Technology | 11% |
162-
| 7 | MSFT | Technology | 10% |
163-
| 8 | ADBE | Technology | 9% |
164-
| ... | ... | ... | ... |
153+
**1. Declarative vs Imperative:** With constraints, you describe *what* you want, not *how* to achieve it. Adding a new rule is one function, not a rewrite of your algorithm.
165154

166-
Greedy picks the top 8 Tech stocks = 40% in Technology. **Constraint violated!**
155+
**2. Constraint Interactions:** As constraints multiply, greedy logic becomes brittle. Consider adding:
156+
- Minimum 2 stocks per sector (diversification floor)
157+
- No more than 3 correlated stocks together
158+
- ESG score requirements
167159

168-
The greedy algorithm must skip high-return Tech stocks to stay within the 25% sector limit. But which ones to skip? And which lower-return stocks from other sectors to include?
160+
Each new constraint in greedy code means more `if/else` branches and edge cases. In a constraint solver, you just add another constraint function.
169161

170-
With 50 stocks across 5 sectors, there are **millions of valid combinations**. The constraint solver explores this space systematically to find the globally optimal portfolio.
171-
172-
### See It For Yourself
173-
174-
Run the comparison script to see how constraint solving beats greedy:
175-
176-
```bash
177-
python scripts/comparison.py
178-
```
179-
180-
Output shows:
181-
- Expected return difference (solver typically beats greedy by 1-3%)
182-
- Sector allocations (both respect limits)
183-
- Different stock selections (solver finds better combinations)
162+
**3. Real-World Complexity:** Production portfolios have weight optimization (not just in/out), correlation matrices, risk budgets, and regulatory requirements. These create solution spaces where greedy approaches fail.
184163

185164
---
186165

0 commit comments

Comments
 (0)