## Figures

## Abstract

The typical behavior of optimal solutions to portfolio optimization problems with absolute deviation and expected shortfall models using replica analysis was pioneeringly estimated by S. Ciliberti et al. [Eur. Phys. B. **57**, 175 (2007)]; however, they have not yet developed an approximate derivation method for finding the optimal portfolio with respect to a given return set. In this study, an approximation algorithm based on belief propagation for the portfolio optimization problem is presented using the Bethe free energy formalism, and the consistency of the numerical experimental results of the proposed algorithm with those of replica analysis is confirmed. Furthermore, the conjecture of H. Konno and H. Yamazaki, that the optimal solutions with the absolute deviation model and with the mean-variance model have the same typical behavior, is verified using replica analysis and the belief propagation algorithm.

**Citation: **Shinzato T, Yasuda M (2015) Belief Propagation Algorithm for Portfolio Optimization Problems. PLoS ONE 10(8):
e0134968.
https://doi.org/10.1371/journal.pone.0134968

**Editor: **Yong Deng,
Southwest University, CHINA

**Received: **April 17, 2015; **Accepted: **July 15, 2015; **Published: ** August 25, 2015

**Copyright: ** © 2015 Shinzato, Yasuda. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited

**Data Availability: **All relevant data are within the paper and its Supporting Information files.

**Funding: **This study was supported by Grant-in-Aid for Young Scientists (B) Research Project Number: 24710169, https://kaken.nii.ac.jp/d/p/24710169.en.html 2. Akita prefectural university, (2014). President project for young scientists 3. Grant-in-Aid for Young Scientists (B) Research Project Number: 15K20999, https://kaken.nii.ac.jp/d/p/15K20999.en.html 4. The National Institute of Informatics, Japan, (2014). Research Project Number: 50, http://www.nii.ac.jp/kenkyou/files/b/1234/kyoudoukenkyu_ichiran/h26_ichiran.pdf 5. Japan Institute of Life Insurance, (2015). Research Project Number: 5, http://www.jili.or.jp/pdf/150604.pdf 6. Kyoto university institute of economic research foundation, (2015). http://www.fd.kier.kyoto-u.ac.jp/grant/grant.html 7. Zengin Foundation for Studies on Economics and Finance, (2015). Research Project Number: 1414, http://www.jade.dti.ne.jp/bankfund/table2014.pdf 8. The institute of statistical mathematics, (2015). Research Project Number: 2068, http://kyodo.ism.ac.jp/public_system/member/saitaku-kadai.php?n=H27 9. Kampo foundation, (2015). Research Project Number: 2, http://www.kampozaidan.or.jp/CL01_02/185_S1.pdf.

**Competing interests: ** The authors have declared that no competing interests exist.

## Introduction

Portfolio optimization is one of the most fundamental frameworks of risk diversification management. Its theory was introduced by Markowitz in 1959 and is one of the most important areas being actively investigated in financial engineering [1–3]. In their theoretical research, Ciliberti and Mézard assessed the typical behavior of optimal solutions to portfolio optimization problems, in particular those described by the absolute deviation and expected shortfall models, using replica analysis, one of the most powerful approaches in disordered systems. With this approach, they showed that the phase transitions of these optimal solutions were nontrivial [1]. However, they did not develop an effective algorithm for finding the optimal portfolio with respect to a fixed return set. This requires a rapid algorithm for resolving the optimal portfolio problem with respect to a large enough in-sample set.

As a first step in such a research direction, we propose an algorithm based on belief propagation, which is well-known as one of the most prominent algorithms in probabilistic inference, to resolve the microscopic averages of the optimal solution in a feasible amount of time for a fixed return set. We also confirm whether the numerical experimental results of our novel algorithm are consistent with the ones of replica analysis. Furthermore, the conjecture of Konno and Yamazaki, that if the return at each period is independently and identically drawn from the normal probability distribution [2], the optimal portfolio of the mean-variance model is consistent with that of the absolute deviation model, is supported using replica analysis and belief propagation.

## Model Setting and Proposed Algorithm

Let us define the model setting for our discussion. A portfolio of *N* assets and the return at period *μ* are represented by **w** = {*w*_{1},*w*_{2}, ⋯, *w*_{N}}^{T} ∈ **R**^{N} and **x**_{μ} = {*x*_{1μ},*x*_{2μ}, ⋯, *x*_{Nμ}}^{T} ∈ **R**^{N}, respectively, where *w*_{k} is the position of asset *k*, and we assume for simplicity that the mean of the return of asset *k* in period *μ*, *x*_{kμ}, is zero. The notation T indicates matrix transposition. Given a return set for *p* periods as reference, the problem is to minimize the following cost function (i.e., Hamiltonian) for the portfolio:
(1)
where *R*(*u*) represents a cost function, such as in the mean-variance model and ∣*u*∣ in the absolute deviation model, respectively. Furthermore, since the budget is assumed to be finite, the following global constraint is set:
(2)

One of our aims is to develop an effective general algorithm for solving this problem; in particular, our aim is an algorithm that works for all cost functions *R*(*u*) and all probability distributions of the returns.

As a basis for the proposed algorithm, following examples in statistical mechanics, we set the joint probability of portfolio **w** used in Eq (1) using finite inverse absolute temperature *β* as follows:
(3)
where *g*(*u*) = *e*^{−βR(u)} is the likelihood function and prior probability for sufficiently large *N* [4, 5]. Notice that the partition function of this posterior probability
(4)
is implicitly ignored in this analysis because intuitively it is possible to evaluate the first- and second-order moments of portfolio *w*_{k} approximately without the partition function by the following procedure. An arbitrary test probability of portfolio is defined as follows:
(5)
where the reducibility condition on beliefs *b*_{k}(*w*_{k}) and *b*_{μ}(**w**),
(6)
must hold and **w**\*w*_{k} denotes a subset of **w** from which *w*_{k} is excluded. The Kullback-Liebler divergence (KLD)
(7)
provides a useful guideline for deriving the belief propagation algorithm. However, since it is too complicated to directly assess KLD except in specific graphical models, we here approximate the Bethe free energy denoted as follows:
(8)
where is used. The purpose of this step is to derive the optimal portfolio using the beliefs *b*_{k}(*w*_{k}) and *b*_{μ}(**w**) that minimize the Bethe free energy under the reducibility condition of Eq (6). By adding the term to the right-hand side of Eq (8), it is possible to minimize the Bethe free energy with respect to the beliefs to obtain
(9) (10)

Furthermore, for simplicity, we set
(11)
as novel auxiliary functions, and then *b*_{k}(*w*_{k}) and *b*_{μ}(**w**) can be rewritten using and as
(12) (13)

Moreover, applying the cumulant generating functions
(14) (15)
the first and second moments of *w*_{k} have the compact forms and at *θ* = {*θ*_{1}, ⋯, *θ*_{N}}^{T} → 0. This allows us to disregard the calculation of the partition function. Then, our proposed algorithm for sufficiently large *N* comprises the following:
(16) (17) (18) (19) (20) (21) (22) (23)
where is used. Note that if is redefined as , then and [4–7]. In addition, and describe the Onsager reaction terms in the literature of spin glass theory (respectively [8, 9]).

Four points should be noticed here. First, the calculation of this procedure is reduced from *O*(*N*^{3}) to *O*(*N*^{2}). For instance, in the case of the mean-variance model, although we are required to calculate the inverse matrix of the correlation matrix of return set *XX*^{T} ∈ ℳ_{N×N}, where return matrix *X* = {**x**_{1}, ⋯, **x**_{p}} ∈ ℳ_{N×p}, in order to assess the optimal solution rigorously, it is well-known that this calculation is *O*(*N*^{3}). Moreover, fortunately it is found that in the case of the mean-variance model, this algorithm derives the exact optimal solution (see appendix A for details). Second, only Eqs (20) and (23) are dependent on the likelihood function *g*(*u*) = *e*^{−βR(u)}, and the variables of index *u* are the only model dependent ones. Furthermore, is determined by Eqs (2) and (16). Third, the randomness of return is not assumed to be sampled from specific distributions. Because it is plausible that the assumption on the Bethe free energy approximation works correctly if the return at each period is asymptotically not correlated with other returns. Lastly, we expect that in the limit as *β* → ∞, the estimate of the portfolio of asset *k*, *m*_{wk}, asymptotically corresponds to the optimal portfolio with respect to the given return set.

## Numerical Experimental Results

In order to confirm the effectiveness of our method, the numerical experimental results of the proposed algorithm and those of the replica analysis for the case of the Markowitz model are shown in Figs 1 and 2, where *x*_{kμ} are independently and identically drawn from the normal distribution with mean and variance 0 and 1, respectively. The numerical experimental result of belief propagation is assessed from 10^{2} samples of the number of assets *N* = 500 and is denoted by error bars and the result of replica analysis is denoted by a solid line. Both findings indicate that the two approaches are consistent with each other.

The numerical experimental results from the proposed algorithm (error bars) are assessed from 10^{2} experiments using *N* = 500 assets. Comparing with the results of replica analysis (solid line), the effectiveness of proposed algorithm is verified.

This result also indicates that the approximation approach based on probabilistic inference works correctly.

With regard to the conjecture of Konno and Yamazaki, the variables in Eqs (20) and (23), in the case of the mean-variance model
(24) (25)
and the absolute deviation model
(26) (27)
are assessed exactly using . Because in the case of *u* ≫ 1, and are estimated; that is, this finding indicates that the conjecture of Konno and Yamazaki is valid in part in the sense of the belief propagation approach. See appendices for details.

## Summary

In conclusion, we have discussed an effective algorithm for finding the optimal solution of the portfolio optimization problem with respect to an arbitrary cost function according to Ciliberti and Mézard [1]. With loss of generality, applying the likelihood function *g*(*u*) defined by the cost function *R*(*u*) dependent on the risk diversification problem, we proposed a novel approximation derivation method based on one of the most powerful estimation methods in probabilistic inference. In addition, since two types of Onsager reaction terms are derived in Eqs (17) and (21), our algorithm provides the Thouless, Anderson, and Palmer approach rather than the mean-field approximation in the literature of spin glass theory. One advantage of our algorithm is that it rapidly converges by excluding the effect of self-response. In order to confirm the effectiveness of the proposed approach, we have described the case of the mean-variance model. Furthermore, we have shown that the conjecture of Konno and Yamazaki is supported by employing both approaches developed in cross-disciplinary research involving statistical mechanics and information sciences. In future work, we will assess the properties of *R*(*u*) and the randomness of return that make solving the portfolio optimization problem using belief propagation possible.

## Appendix

### A. Proof of Exactness

We here confirm the exactness of the proposed belief propagation algorithm for the case of the Markowitz model. Our discussion is restricted to *α* > 1 for simplicity. From Eqs (21), (24), and (25), we obtain , where **m**_{u} = {*m*_{u1}, ⋯, *m*_{up}}^{T} ∈ **R**^{p} and **m**_{w} = {*m*_{w1}, ⋯, *m*_{wN}}^{T} ∈ **R**^{N}. Furthermore, follows immediately from Eqs (16), (17), and (19), where **e** = {1, ⋯, 1}^{T} ∈ **R**^{N}. Thus, substituting into the constraint *N* = **e**^{T} **m**_{w} gives the exact optimal solution .

### B. Replica Analysis

According to Ciliberti and Mézard, replica symmetry solution of the portfolio optimization problem, where *x*_{kμ} is independently and identically distributed with *N*(0,1), is derived as the following extremum:
(28)
where is the partition function and the notation [⋯]_{q} denotes the quenched average over the return set. Moreover, the quenched overlap parameters become if *a* = *b* and *q* otherwise by employing replica indices *a*,*b* = 1, 2, ⋯, *n* and the assumption of replica symmetry. Furthermore, for large *N* and *p*, *α* = *p*/*N* ∼ *O*(1) remains finite and plays an important role as a control parameter with respect to phase transition phenomena. If , then and *χ* = (*β*(*α* − 1))^{−1} can be exactly calculated in the case *α* > 1 and *q* → ∞, and *χ* → ∞ otherwise. This analytical finding is also verified in by the following. It is well known that the eigenvalue distribution of the correlation matrix in the limit of *N* → ∞ is asymptotically close to the Marčhenko-Pastur law with and [*u*]^{+} = max{*u*, 0} [10]. Therefore, and one degree of the cost function are obtained straightforwardly using . Applying Marčhencko-Pastur law, that and if *α* > 1 and approach infinity otherwise follows directly. This is consistent with the findings of replica analysis [5].

In general, the order parameters are derived as follows: (29) (30) (31) (32)

From Eqs (29) and (30),
(33)
is obtained. In the limit of sufficiently large *β* of *g*(*u*) = *e*^{−β∣u∣}, if we assess and asymptotically, then the conjecture of Konno and Yamazaki is confirmed as correct in the sense of replica analysis.

### C. The Conjecture of Konno and Yamazaki

This conjecture is related to the assessment of an annealed system in the context of spin glass theory. If the return at period *μ*, **x**_{μ}, is independently and identically drawn from *N* (0, Σ), where Σ ∈ ℳ_{N×N} is variance-covariance matrix and **w** is fixed, the novel variable is distributed as *N* (0, *s*^{2}(**w**)) with . With respect to fixed **w**, employing one degree of the cost function of the annealed optimization problem , which becomes in the case of the mean-variance model and in the absolute deviation model. This implies that the optimal portfolios of the annealed situations of the two models are consistent with each other. Note that one degree of the cost function in the case of the annealed portfolio problem with the expected shortfall model, with *γ* > 0 can also be assessed. If , then this optimal solution is identical to those of the previous mentioned models. This finding, that is, , is one part of the contributions reported by Konno and Yamazaki.

However, they optimistically assumed **w**_{MV} = **w**_{AD} with respect to a given return set *X* without any mathematical proof, using
(34) (35)

As explained above, with respect to the annealed optimization problem strictly holds; however, **w**_{MV} = **w**_{AD} is not always satisfied. For example, in the simple case of *N* = *p* = 2 for the two returns **x**_{1} = {*a*, *c*}^{T} and **x**_{2} = {*b*, *d*}^{T}, their assumption **w**_{MV} = **w**_{AD} does not hold, except under specific special situations.

Although this is apparently contradictory to these obtained findings from both approaches, it is necessary to recognize that the relation **w**_{MV} = **w**_{AD} with a fixed return set is equivalent to the sufficient condition *q*_{MV} = *q*_{AD}, where and are quenched averages of overlap parameters. Moreover, although **w**_{MV} = **w**_{AD} does not hold in general, it is expected that the inner product is approximately 1 because in the case of sufficiently large *N*.

## Supporting Information

### S1 Data. Figure 1 and figure 2 from S1 Data.

S1 Data is the result from numerical experiment of S1 File and S2 File.

https://doi.org/10.1371/journal.pone.0134968.s001

(TXT)

### S1 File. S1 File is main program of C language.

https://doi.org/10.1371/journal.pone.0134968.s002

(TXT)

### S2 File. S2 File is sub program of C language.

https://doi.org/10.1371/journal.pone.0134968.s003

(TXT)

## Author Contributions

Conceived and designed the experiments: TS. Performed the experiments: TS. Analyzed the data: TS. Contributed reagents/materials/analysis tools: TS MY. Wrote the paper: TS MY.

## References

- 1. Ciliberti S., Mézard M., 2007. Risk minimization through portfolio replication, The European Physical Journal B., 57(2), 175–180.
- 2. Konno H., Yamazaki H., 1991. Mean-absolute deviation portfolio optimization model and its applications to Tokyo stock, Management Science, 37(5), 519–531.
- 3.
Markowitz H., 1959. Portfolio selection: Efficient diversification of investments, J. Wiley and Sons, New York.
- 4. Kabashima Y., 2005. Replicated Bethe free energy: A variational principle behind survey propagation, Journal of the Physical Society of Japan, 74(8), 2133–2136.
- 5. Shinzato T., 2015. Self-Averaging Property of Minimal Investment Risk of Mean-Variance Model, PLOS ONE.
- 6.
Çakmak B., Winther O., Fleury H. B., 2014. S-AMP: Approximate message passing for general matrix ensembles, IEEE, Information Theory Worksop, 192–196.
- 7.
Minka, T. P., 2001. Expectation propagation for approximate Bayesian inference, Proceedings of the Seventeenth conference on Uncertainty in artificial intelligence, 362–369.
- 8. Opper M., Winther O., 2001. Tractable approximations for probabilistic models: The adaptive Thouless-Anderson-Palmer mean field approach, Physical Review Letters, 86(17), 3695. pmid:11329302
- 9. Opper M., Winther O., 2001. Adaptive and self-averaging Thouless-Anderson-Palmer mean-field theory for probabilistic modeling, Physical Review E, 64(5), 056131.
- 10. Shinzato T., Kabashima Y., 2008. Perceptron capacity revisited: Classification ability for correlated patterns, Journal of Physics A, 41(32), 324013.