Optimization Interactive
Convex Optimization
When the problem is convex, local optima are global optima. Efficient algorithms guarantee finding the best solution.
๐ What is Convex?
Convex Set
Line between any two points in the set stays inside the set.
โ Convex
โ Non-convex
Convex Function
"Bowl-shaped" โ line between any two points lies above the curve.
f(ฮปx + (1-ฮป)y) โค ฮปf(x) + (1-ฮป)f(y)
Gradient Descent
-8 8
0.01 0.5
10 100
๐ Optimization Result
Optimum x* -1
Found x -0.9999
f(x) 0.0000
Error |x - x*| 1.28e-4
โ Converged to optimum
Gradient Descent Path
Start Path End f(x) = xยฒ + 2x + 1
Why Convexity Matters
Global Minimum
Local minimum = global minimum
โ No "traps"
Guaranteed Convergence
Gradient descent converges
โ Smooth landscape
Efficient Algorithms
Polynomial time solutions
โ Well-studied theory
Duality
Strong duality often holds
โ Bounds on optimum
๐ฐ Betting Applications
Portfolio Optimization
Obj: Minimize variance
s.t. Target return
Liability Hedging
Obj: Minimize cost
s.t. Risk limits
Odds Calibration
Obj: Minimize Brier score
s.t. Probs sum to 1
Resource Allocation
Obj: Maximize profit
s.t. Budget limits
Python Code
# Convex optimization with CVXPY
import cvxpy as cp
import numpy as np
# Portfolio optimization (minimize variance)
n_assets = 5
expected_returns = np.array([0.12, 0.10, 0.08, 0.15, 0.11])
cov_matrix = np.random.randn(n_assets, n_assets)
cov_matrix = cov_matrix @ cov_matrix.T # Make positive semidefinite
# Decision variables
weights = cp.Variable(n_assets)
# Objective: minimize portfolio variance
objective = cp.Minimize(cp.quad_form(weights, cov_matrix))
# Constraints
constraints = [
cp.sum(weights) == 1, # Weights sum to 1
weights >= 0, # No short selling
weights @ expected_returns >= 0.10 # Target return
]
# Solve
problem = cp.Problem(objective, constraints)
problem.solve()
print(f"Optimal weights: {weights.value}")
print(f"Portfolio variance: {problem.value}")โ Key Takeaways
- โข Convex = no local minima traps
- โข Gradient descent guaranteed to converge
- โข Many betting problems are convex
- โข Use CVXPY (Python) or cvx (MATLAB)
- โข Check if problem is convex before solving
- โข Non-convex: use multiple restarts