You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Copy file name to clipboardExpand all lines: content/en/docs/getting-started/portfolio-optimization.md
+9-30Lines changed: 9 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,41 +146,20 @@ You have **$100,000** to invest and must select **20 stocks** from a pool of can
146
146
**Soft constraints** (preferences to optimize):
147
147
- Maximize total expected return (pick stocks with highest predictions)
148
148
149
-
### Why This is Hard
149
+
### Why Use a Constraint Solver?
150
150
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?
152
152
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.
165
154
166
-
Greedy picks the top 8 Tech stocks = 40% in Technology. **Constraint violated!**
- Minimum 2 stocks per sector (diversification floor)
157
+
- No more than 3 correlated stocks together
158
+
- ESG score requirements
167
159
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.
169
161
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.
0 commit comments