Solving Constrained Mean-Variance Portfolio Optimization Problems Using Spiral Optimization Algorithm
Chen Kai BOSS

The classic mean – variance portfolio model is elegant, but real trading constraints (buy-in thresholds, cardinality limits, min/max position sizes) quickly turn it into a hard mixed-integer nonlinear problem. This paper tackles that constrained setting with a modified Spiral Optimization Algorithm (SOA)— a metaheuristic designed to search complex feasible regions where convex solvers or gradient methods are not directly applicable. This note focuses on the formulation (what constraints are added and how), how SOA explores the search space, and what the reported results say about solution quality under practical constraints.

Background

A portfolio is a combination of assets (stocks, bonds, real estate, cash, etc.) designed to meet an investment objective. Investors typically want higher return under controlled risk, but return and risk trade off against each other. Markowitz ’ s (1959) mean – variance framework is the classical foundation: expected return captures reward, and variance (or covariance) captures risk.

In practice, additional trading constraints are common (minimum buy-in, upper bounds, and “ choose onlyassets ”). Adding these turns the problem into a mixed-integer nonlinear program (MINLP). This post follows the paper ’ s formulation and the SOA-based solver used to search for feasible low-risk portfolios under such constraints.

Mean – variance portfolio optimization as an MINLP

Base mean – variance problem

Letbe the capital fraction allocated to asset (). Letbe the vector of expected returns andthe positive semidefinite covariance matrix.

Assume future asset returns can be estimated statistically, and risk is measured by the variance of returns. Letdenote the capital fraction invested in asset (), and letbe the weight vector. Forassets, let the mean return vector be, and letbe thepositive semidefinite covariance matrix.

The optimization objective is to minimize total risk, i.e., minimize the portfolio variance:Typical constraints include a target return and full investment:whereis the target portfolio return, and the weights sum to 1:where.

If short selling is disallowed, enforce. The resulting quadratic program is:

Buy-in threshold constraint

A buy-in threshold sets a minimum allocationfor any selected asset. Introduce a binary variableto indicate whether assetis included. Then enforce: - if, then- if, thencan be written as.Extra close brace or missing open brace\begin{aligned} \min \quad & V(y) = \mathbf{y}^T Q \mathbf{y} \ \text{subject to:} \quad & \overline{\mathbf{r }}^T \mathbf{y} = R_p \ & \mathbf{e}^T \mathbf{y} = 1 \ & l_i z_i \leq y_i \leq u_i z_i, \quad i = 1, 2, \dots, n \ & 0 < l_i < u_i \leq 1 \ & z_i \in \{0, 1} \end{aligned}Hereis a binary “ selection ” variable.

Cardinality constraint

The cardinality constraint restricts the portfolio to exactly (or at most)assets. In the paper ’ s formulation it is enforced by:Extra close brace or missing open brace\begin{aligned} \min \quad & V(y) = \mathbf{y}^T Q \mathbf{y} \ \text{subject to:} \quad & \overline{\mathbf{r }}^T \mathbf{y} = R_p \ & \mathbf{e}^T \mathbf{y} = 1 \ & \sum_{i=1}^{n} z_i = K \ & l_i z_i \leq y_i \leq u_i z_i, \quad i = 1, 2, \dots, n \ & 0 < l_i < u_i \leq 1 \ & z_i \in \{0, 1} \end{aligned}whereis the number of selected assets.

Mixed-integer nonlinear programming (MINLP)

Following standard MINLP notation (e.g., Kania & Sidarto, 2016), an MINLP can be written as:with equality and inequality constraints: where the firstvariables are integer-valued.

Numerical example

The paper reports experiments on a five-asset dataset from Bartholomew-Biggs & Kane (2009). The mean return vector is:and the covariance matrix is:The target return isy_{}=0.05^8$. After 50 iterations, the reported best risk is 0.6969, the weights sum to 1, and all 5 assets are active.

Conclusion

The paper proposes a modified spiral optimization method (SOA-MINLP) to handle mean – variance portfolio optimization with buy-in and cardinality constraints. The numerical study suggests SOA-MINLP can find competitive solutions under these nonconvex, discrete constraints, and the paper compares it against baselines such as Quasi-Newton and DIRECT-type methods.

Spiral Optimization Algorithm (SOA) Basics

Core idea

SOA is a metaheuristic inspired by spiral trajectories in nature (e.g., spiral phyllotaxis in plants, spiral galaxies). The algorithm iteratively updates candidate solutions by moving them toward a center point along a spiral path.

Update rule (simplified):where:

-is the current best solution -is a rotation matrix with angle -decreases over iterations (tightening spiral)

Key property: The spiral path allows exploration (early iterations, large) and exploitation (late iterations, small).

Why SOA for constrained MINLP?

Traditional gradient-based methods struggle with:

  • Integer constraints: Gradient is undefined for binary variables
  • Non-convexity: Multiple local optima
  • Feasibility: Hard to maintain constraints during optimization

SOA handles these naturally:

  • Metaheuristic: Does not require gradients
  • Global search: Spiral trajectory explores diverse regions
  • Constraint handling: Penalty method or repair operators

Modified SOA for Portfolio Optimization

Constraint handling via penalty

The paper uses a penalty method to convert constrained optimization into unconstrained:where:

-is portfolio variance (objective) -is penalty for constraint violations:-is a large penalty weight (e.g.,)

Intuition: Infeasible solutions get heavily penalized, pushing the search toward the feasible region.

Algorithm steps

  1. Initialize: Generate random candidate solutions

  2. Evaluate: Compute penalized objectivefor each candidate

  3. Find best:

  4. Update: For each candidate, apply spiral update toward

  5. Repair: Project back to bounds (e.g.,)

  6. Repeat: Until convergence or max iterations


Performance Comparison

The paper compares SOA against baseline solvers:

Solver Risk (variance) Feasibility Runtime
SOA-MINLP 0.6969 ✅ Feasible Fast
Quasi-Newton 0.7123 ⚠️ Sometimes infeasible Medium
DIRECT 0.7458 ✅ Feasible Slow

Key takeaway: SOA achieves lower risk while maintaining feasibility and reasonable runtime.


Practical Considerations

When to use SOA?

Good fit:

  • Non-convex, constrained optimization
  • Mixed-integer problems (binary + continuous variables)
  • Small to medium scale (n < 100 assets)

Not ideal:

  • Very large scale (n > 1000 assets) → use specialized solvers (e.g., Gurobi, CPLEX)
  • Convex problems → use gradient-based methods (faster and more reliable)

Tuning SOA hyperparameters

Key knobs:

  • Population size N: Larger N → better exploration, slower
  • Max iterations: Depends on problem difficulty
  • Spiral angle decay: Faster decay → quicker convergence, risk of local optima
  • Penalty weight: Too small → infeasible solutions; too large → numerical issues

Rule of thumb: Start with N=50, max_iter=100,, then tune based on convergence plots.


Limitations and Extensions

Limitations

  1. Stochastic: SOA can return different solutions on different runs (need multiple runs + ensemble)
  2. No optimality guarantee: Metaheuristics do not prove global optimality
  3. Scalability: Struggles with very large portfolios (n > 100)

Possible extensions

  1. Hybrid SOA + local search: Use SOA for global exploration, then refine with gradient-based local search
  2. Multi-objective SOA: Optimize return and risk simultaneously (Pareto front)
  3. Robust portfolio: Extend to worst-case optimization under uncertainty

Conclusion

The paper demonstrates that modified SOA is a viable solver for mean – variance portfolio optimization with realistic trading constraints (buy-in thresholds, cardinality limits). The key innovation is adapting the spiral trajectory to handle mixed-integer nonlinear constraints via penalty methods. While not guaranteed to find the global optimum, SOA provides high-quality feasible solutions in reasonable time, making it suitable for practical portfolio construction where exact optimality is less critical than tractability and interpretability.

For practitioners: if your portfolio model includes integer constraints (e.g., "select exactly K stocks"), SOA-type metaheuristics are worth exploring before resorting to expensive commercial solvers.

The constrained mean variance portfolio optimization problem represents a significant challenge in quantitative finance because it combines the theoretical elegance of Markowitz's framework with the practical realities of real-world trading. Traditional quadratic programming solvers work well for the unconstrained or simply-bounded case, but as soon as practitioners introduce cardinality constraints (select exactly K assets), minimum buy-in thresholds (if you hold an asset at all, hold at least L percent), and transaction costs, the problem becomes a mixed-integer nonlinear program that defeats standard convex optimization tools.

Metaheuristic approaches like Spiral Optimization Algorithm gain traction in this space precisely because they do not require convexity or differentiability assumptions. The spiral trajectory provides a natural balance between exploration (when the spiral is wide) and exploitation (when the spiral tightens around promising regions). This contrasts with simpler metaheuristics like genetic algorithms or particle swarm optimization, which often struggle with the delicate balance between global search and local refinement, especially in high-dimensional mixed-integer spaces.

From a practitioner's perspective, the choice of solver depends on several factors beyond just solution quality. Computational budget matters: if you need to rebalance a portfolio daily or intraday, spending hours on optimization is not viable. Interpretability matters: some institutional investors prefer methods that provide intuition about why certain assets were selected, rather than black-box solutions. Robustness matters: financial data is noisy and non-stationary, so a solver that is slightly suboptimal but robust to parameter misspecification may outperform a theoretically optimal but brittle solver in live trading.

The numerical experiments in the paper use a small five-asset dataset to demonstrate feasibility, but real portfolios often contain hundreds or thousands of assets. Scaling metaheuristics to this regime requires careful algorithmic engineering: sampling strategies to reduce the effective search space, hierarchical clustering to group similar assets, and warm-starting with solutions from simpler models. Furthermore, the penalty parameter rho plays a critical role in balancing feasibility and optimality: too small and the solver wanders into infeasible regions, too large and numerical precision issues arise because the objective becomes dominated by penalty terms with vastly different magnitudes.

Conclusion: while Spiral Optimization Algorithm is not a silver bullet for all portfolio optimization problems, it represents a valuable tool in the quantitative analyst's toolkit, especially when dealing with discrete constraints that render classical methods inapplicable. Key: understanding when to use it (non-convex, mixed-integer, moderate scale) and when to switch to specialized commercial solvers (very large scale, need for optimality certificates) or simpler heuristics (low-latency requirements, noisy data). By combining domain knowledge with algorithmic pragmatism, practitioners can build portfolio construction systems that are both theoretically sound and practically deployable.

  • Post title:Solving Constrained Mean-Variance Portfolio Optimization Problems Using Spiral Optimization Algorithm
  • Post author:Chen Kai
  • Create time:2024-10-01 00:00:00
  • Post link:https://www.chenk.top/en/Solving%20Constrained%20Mean-Variance%20Portfolio%20Optimization%20Problems%20Using%20Spiral%20Optimization%20Algorithm/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments