Application of Genetic Optimization Algorithm in F
Application of Genetic Optimization Algorithm in F
Research Article
Application of Genetic Optimization Algorithm in Financial
Portfolio Problem
Received 21 April 2022; Revised 9 June 2022; Accepted 15 June 2022; Published 15 July 2022
Copyright © 2022 He Li and Naiyu Shi. This is an open access article distributed under the Creative Commons Attribution
License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is
properly cited.
In order to address the application of genetic optimization algorithms to financial investment portfolio issues, the optimal
allocation rate must be high and the risk is low. This paper uses quadratic programming algorithms and genetic algorithms as well
as quadratic programming algorithms, Matlab planning solutions for genetic algorithms, and genetic algorithm toolboxes to solve
Markowitz’s mean variance model. The mathematical model for introducing sparse portfolio strategies uses the decomposition
method of penalty functions as an algorithm for solving nonconvex sparse optimization strategies to solve financial portfolio
problems. The merging speed of the quadratic programming algorithm is fast, and the merging speed depends on the selection of
the initial value. The genetic algorithm performs very well in global searches, but local search capabilities are insufficient and the
pace of integration into the next stage is slow. To solve this, using a genetic algorithm toolbox is quick and easy. The results of the
experiments show that the final solution of the decomposition method of the fine function is consistent with the solution of the
integrity of the genetic algorithm. 67% of the total funds will be spent on local car reserves and 33% on wine reserves. When data
scales are small, quadratic programming algorithms and genetic algorithms can provide effective portfolio feedback, and the
method of breaking down penalty functions to ensure the reliability and effectiveness of algorithm combinations is widely used in
sparse financial portfolio issues.
mathematics. Mathematically, this means finding the min- describing securities returns, it greatly simplifies the model
imum or maximum value of the objective function under of Markowitz theory and provides convenience for the
certain conditions [3]. A typical optimization problem is to successful application of Markowitz theory in the actual
achieve the goal optimization by allocating different pro- investment process. However, the theory is not perfect. Then
portions of resources, such as cost minimization, profit Wang et al. proposed a multifactor model, which we call
maximization, and so on. Optimization method is a arbitrage pricing model [8]. Setiawan and Rosadi made an
mathematical method to solve optimization problems. in-depth study on the securities price in the capital market
Traditional optimization methods mainly include branch by using statistical methods from both theoretical and
definition method, background segmentation method, dy- empirical aspects in 1965 and put forward the efficient
namic programming method, and other accurate algo- market theory [9]. The subsequent portfolio development is
rithms. The absolute optimal solution can be obtained by based on some of the above theories. In China, the research
accurate algorithm, but because of its large calculation scale, on portfolio can be traced back to the 1990s [10]. Of course,
it is only suitable for solving small-scale problems and is not many valuable documents have emerged. Jiang et al. pro-
suitable for application in complex engineering problems posed a portfolio selection theory that strictly stated the
with high-dimensional, multiobjective, and multi- operability under uncertain conditions: mean variance
constraints. On the contrary, heuristic algorithm refers to method, and conducted systematic, in-depth, and fruitful
the method of searching according to empirical rules when research. This theory led to the revolution of stock invest-
solving problems, rather than solving according to deter- ment theory. Since Markowitz put forward the mean vari-
mined steps. After the 1950s, scholars applied heuristic ance model, most portfolio models are based on the two
algorithms to practical complex engineering problems and parameters of mean and variance. With the development of
obtained good feedback, which opened the research wave of portfolio theory, new risk measurement methods continue
heuristic algorithms [4]. to emerge. Takahashi and Takahashi proposed the concept of
The purpose of this article is to understand the effects of semiabsolute deviation (Semia. D) and improved the mean
various methods of optimization in theory and practice. variance model on this basis [11]. By analyzing the com-
Therefore, we have chosen the M-V model, which is the pound price of 50 representative stocks in Shanghai, it is
simplest square error model. concluded that the portfolio based on M-Semiad model is
M-V model, as shown in the following formulas: better than that in M-V model at each expected rate of
1 return, and the effective portfolio satisfies the separation
min σ 2 � xT Vx, (1) theorem of two funds. Finding the optimal solution of
x 2
portfolio problem actually belongs to a kind of portfolio
optimization problem, which usually comes down to qua-
⎪
⎧
⎪ rT x ≥ μ,
⎨ T dratic programming model. The solving process is very
s⎪ e x � 1, (2) cumbersome and requires high mathematical foundation, so
⎪
⎩
L ≤ x ≤ U, many scholars use intelligent algorithms to solve it. Nahvi
et al. applied binary coded genetic algorithm (GA) to solve
where V represents the covariance matrix of each financial this problem, which has the advantages of simplicity and
asset (in this case, stock), (r1 , r2 , . . . , rn )T represents the rate intuition, but the efficiency is not high enough (Figure 2)
of return of each stock, and μ � (μ1 , μ2 , . . . , μn )T represents [12]. Bakar and Rosbi applied integer coded adaptive genetic
the investment return expected by investors. algorithm (AGA) to solve the problem, which improved the
In the portfolio theory, the average value of the return on solution efficiency [13]. In 1964, Cheng and Zhong estab-
assets is used as the measurement index of the expected lished the capital asset pricing model (CAPM) based on
return on assets, and the variance of the return on assets is Markowitz. CAPM “accurately described the return and risk
used as the risk measurement index of the portfolio [5]. of assets” and studied the relationship between the expected
return of assets and risky assets in the securities market and
2. Related Works the formation of equilibrium price [14]. Pakistan proposed
to solve the problem of portfolio optimization through
At present, domestic and foreign scholars have more and symbiotic multiswarm PSO [15]. Mu and Xiong proposed
more research on portfolio optimization. It can be seen from portfolio analysis under background risk based on mean
the Citation Report retrieved from the relevant database that variance model [16]. Lin et al. put forward an adaptive
there is more and more literature research on portfolio portfolio model under new assets [17].
optimization. The publication and citation of portfolio Based on the basic idea of ABC algorithm, this paper
optimization literature are shown in Figure 1. solves the cardinality constrained mean variance model
After Kumar et al. put forward the portfolio theory, there (CCMV model) in portfolio problem. In the process of
have been many new portfolio developments: multiperiod solving, a FABC algorithm which can always get the feasible
portfolio, portfolio under different risk measures, portfolio solution is designed for CCMV model. Then the renewal
based on transaction cost and liquidity, portfolio theory equation of FABC is improved, and the IFABC algorithm
based on nonutility maximization, etc. [6, 7]. In the de- with faster convergence speed is obtained. Finally, the
velopment history of portfolio theory, Ahn’s work is the IFABC algorithm is further improved based on quadratic
most prominent. By introducing a single factor model programming, and a better QFABC algorithm is proposed.
Computational Intelligence and Neuroscience 3
2000
300
1800
250 1600
Document number
1400
Reference number
200
1200
150 1000
100 800
600
50
400
0 200
0
2010 2012 2014 2016 2018 2020
2010 2012 2014 2016 2018 2020
Year
Year
(a) (b)
Figure 1: Publication and citation of portfolio optimization literature. (a) Number of documents published per year. (b) Number of
citations per year.
constraint, the model is transformed into solving the sparse objective function to obtain the individual fitness value.
portfolio problem, which remedies the high instability of the Individuals with higher adaptability to living environment
traditional portfolio model. In particular, the Markowitz often have higher survival probability. At the beginning,
model is modified by adding constraints to control the some individuals are always randomly generated, that is,
number of assets [18]. This kind of problem is called the candidate solutions. These individuals are cross combined by
portfolio problem with cardinality constraints, as shown in genetic algorithm according to the principle of “survival of
the following equation: the fittest” to produce offspring. The offspring inherit some
1 excellent shapes of the parent generation, so they are ob-
σ 2 � xT Qx, viously better than the previous generation. In this way, the
2
minn population of “chromosome” will gradually evolve towards a
x∈R better solution. Combined with genetic operations such as
μT x � β, gene mutation in the process of species evolution, offspring
(8) more adapted to the environment may be produced [19].
‖x‖0 ≤ K, Genetic algorithm is mainly composed of chromosome
coding, initial population setting, fitness function setting,
s.t. eT x � 1, genetic operation (crossover, mutation) design, and so on.
Coding refers to transforming the solution structure of
x ≥ 0, practical problems into chromosome structure. Selection
where ‖x‖0 is the zero norm of x and represents the number refers to selecting several individuals with higher fitness
of nonzero elements in vector x; parameter K is the upper from the current population according to the selection
limit of the number of investment projects. In short, the probability and the fitness value of each chromosome.
modern portfolio problem mainly includes the following Fitness determines the individual’s viability, usually roulette
three objective functions: selection or tournament selection. Crossover refers to the
mating recombination of some genes of two chromosomes
(1) Minimize investment risk xT Qx, min xT Qx according to the crossover probability and crossover strategy
(2) Maximize expected return on investment μT x, to produce new individuals. Crossover strategies generally
max μT x include single point crossover and multipoint crossover.
(3) Minimize the number of selected investment proj- Mutation refers to the mutation of some genes in the
ects ‖x‖0 , min ‖x‖0 chromosome according to the mutation probability and
mutation strategy, which is another method for genetic
The restriction on the number of investment projects in algorithm to generate new individuals. For example, under
the above cardinal constrained portfolio can be transformed the binary coding mode, the traditional mutation operation
into controlling the parameter K to a sufficiently small value; simply reverses the binary of the gene; that is, “0” becomes
that is, the mathematical model of the financial portfolio “1” and “1” becomes “0” [20].
problem mainly studied in this paper is obtained, as shown The common parameters of genetic algorithm in China
in the following equation: are shown in Table 1.
minn ‖x‖0 , Genetic algorithms for solving optimization problems
x∈R usually involve three basic operations: selection, crossover,
μT x � β, and mutation. Selection is a key function of genetic algo-
rithms. Different selection actions affect the speed of the
s.t.xT Qx ≤ a, (9) genetic algorithm. Excessive selection pressure can improve
the integration speed of the algorithm but can lead to early
eT x � 1,
mergers. Therefore, it is necessary to choose the appropriate
x ≥ 0, selection measure. Selection means selecting the most
physically fit people and passing them on to the next gen-
where μ is the rate of return of each asset, Q is the variance eration with a higher probability and selecting the less
covariance matrix of each asset, α is the upper limit of physically fit people to pass on to the next generation. The
acceptable risk of investors, and β is the expected rate of selection process can bring the fitness value of individuals in
return of investors. the population closer to the optimal solution. Crossover
operation is the process of replacing and reuniting parts of a
parent’s two personal structures to create a new individual.
3.2. Genetic Algorithm. Genetic algorithm (GA) is a global Crossover activity can create new people in next-generation
optimization algorithm formed by simulating the evolution populations and increase the efficiency of genetic algorithm
mechanism of natural selection and population “survival of search. Relying solely on the crossover operator is likely to
the fittest” and “survival of the fittest.” Each possible bring you closer to local optimization. Mutation refers to the
problem solution is expressed as a “chromosome,” so as to act of mutating an individual with a certain probability, and
obtain a “group” composed of chromosomes. This group is the value of the vector changes randomly among individuals
limited to the specific environment of the problem. Each with a low probability. Mutational activity creates a structure
individual is evaluated according to the predetermined that is unprecedented in a population and increases the
Computational Intelligence and Neuroscience 5
Exclude choosing
Start choose
(5) The “best survival” process is implemented through a
selection process to select better independent groups.
Code and generate the
(6) crossover operation on better chromosomes selected
cross
initial population according to probability PC (single point crossover).
(7) Participate in a mutation process with a PM prob-
The fitness of each individual in the
population was calculated and evaluated
variation ability for a gene on the chromosome.
(8) The performance of the group determines whether it
The end of the
Yes Whether termination No meets the predetermined termination criteria.
conditions are met
Otherwise, return to 4.
Figure 4: Flowchart of genetic algorithm.
Because l0 is the only nonconvex term, the convergence 4. Experimental Results and Discussion
point is the local minimum of the penalty function
subproblem. In this paper, we use a penalized decomposition method to
Sparse problems are now widely used. For example, with solve this problem, i.e., a block cooperative method to solve
a compressed sensor, it is possible to encode a large sparse the subproblem of the penalty function. According to some
signal with a relatively small number of linear dimensions, reasonable assumptions, the first point of the sequence
which converts the problem into a solution of a linear formed by the penalized decomposition method provides a
equation or a set of linear inequalities. Similar methods have first-order optimization of the problem. Furthermore, when
been widely used in the field of linear regression. In recent h is an affine function and f and g are convex functions, the
years, the choice of sparse reverse covariance has become an join point is a local minimum of the problem. At the same
important tool for finding conditional independent terms in time, the boundary points of the sequence formed by the
image design. The current basic approach is to increase the joint collapse of the blocks are saddle points for the children
log-probability function while finding a sparsely inverse of the penalty function. In addition, h is an affine function, f
covariance matrix. Similarly, the choice of characteristics for and g are convex functions, and the combination is a local
cluster problems suggests a promising approach to sparse minimum of the penalty function subproblem.
logistic regression that seeks to reduce sparse logistics losses
min f(x): g(x) ≤ 0, h(x) � 0, xJ − y � 0, (14)
while seeking sparse solutions [22]. All the above applica- x∈X,y∈Y
tions can be expressed as the following l0 minimization
problem, as shown in the following formulas: where Y � y ∈ RJ : ‖y‖0 ≤ r.
�� �� The related quadratic penalty function is defined as
minf(x): g(x) ≤ 0, h(x) � 0, ��xJ ��0 ≤ r, (10) follows, as shown in the following equation:
x∈x
ρ �� ��2 �� ��2
�� �� qp (x, y) � f(x) + ��g(x)+ �� +‖h(x)‖2 + ��xJ − y�� ,
minf(x) + ]��xJ ��0: g(x) ≤ 0, h(x) � 0, (11) 2
x∈X
where r > 0, υ > 0R > 0, υ > 0, and the sparsity of the problem ∀x ∈ X, y ∈ Y,
is controlled by adjusting the size of R and υ. X is the closed (15)
convex set of n-dimensional Euclidean space Rn .
g : Rn ⟶ R, g : Rn ⟶ Rm , h : Rn ⟶ Rp are continuously where penalty function ρ > 0.
differentiable functions. ‖xJ ‖0 refers to the cardinality of the Now a penalty function decomposition method is
subvector marked by the index set J in x. Aiming at the proposed to solve the problem, which can be treated
special situation of this kind of problem, some algorithms equivalently.
are proposed. For example, iterative threshold method and Let εk be a decreasing sequence of positive terms. For
matching pursuit method are developed to solve the the given ρ0 > 0, σ > 1, choose any y00 ∈ Y, constant
l0 -regularized least squares problem in compressed sensing, c ≥ maxf(xfeas ), min qpo (x, y00 ), makek � 0° .
x∈X
but they can not be used to deal with the general l0 -mini-
mization problem. A popular way to deal with the problem is (1) Let l � 0; apply the block cooperative descent
to replace ‖•‖0 with l1 − norm‖•‖1 and then solve the re- method to solve the approximate solution of the
laxation problem. In applications such as compression penalty function subproblem through steps (a), (b),
sensing, problems can be solved under some reasonable (c), and (d).
assumptions. In recent years, some other relaxation methods minqpk (x, y): x ∈ X, y ∈ Y. (16)
have been proposed, that is, replacing l0 with lp . In general,
the properties of the solutions of these methods are not very
(a) Solve
clear. The l0 regularization problem with upper and lower
bound constraints is shown in the following equation: xkl+1 ∈ arg min qρk x, ykl . (17)
x∈X
minf(x) + λ‖x‖0 : l ≤ x ≤ u. (12)
x
(b) Solve
The hard threshold algorithm is proposed as follows, as
ykl+1 ∈ arg min qρk xkl+1 , y. (18)
shown in the following equation: y∈Y
T
xk+1 ∈ arg minfxk + ∇fxk x − xk (c) Let (xk , yk ) � (xkl+1 , ykl+1 ), if (xk , yk ) meets
x∈B �� �
(13) ��P xk − ∇ q xk , yk − xk ��� ≤ ε . (19)
L�� ��2 � x x ρk � k
+ ���x − xk ��� + λ‖x‖0 ,
2 2
(d) Makel←l + 1, Turn to(a).
where λ > 0, L > Lf , Lf is the Lipschitz constant of ∇f(x), After analysis, the problem can be expressed
n
B � {x ∈ Rn : l ≤ x ≤ u}, l ∈ R− , u ∈ Rn+ . equivalently, as shown in the following equation:
Computational Intelligence and Neuroscience 7
0.012
min f(x) + ]‖y‖0 : g(x) ≤ 0, h(x) � 0, xJ − y � 0.
x∈X,y∈R|J|
0.010
(20)
0.008
The related quadratic penalty function is defined as
The yield
follows, as shown in the following equation: 0.006
qρ (x, y) ≔ f(x) + ]‖y‖0
0.004
ρ �� ��2 �� ��2
+ ��g(x)+ �� +‖h(x)‖2 + ��xJ − y�� , (21) 0.002
2
0.000
∀x ∈ X, y ∈ R|J| .
stock
Return on investment
6.0
⎨
⎧ ⎬
⎫
c ≥ max⎩ f(xfeas ) + ]‖xfeas ‖0 , min pρ0 (x, y00 )⎭ ; let 5.5
x∈X
k � 0. 5.0
1.013
Conflicts of Interest
1.012
The authors declare that there are no conflicts of interest.
1.011
1.010 Acknowledgments
1.009 This paper was supported by Research on Financial Science
and Technology Serving Agricultural and Rural Moderni-
-100 0 100 200 300 400 500 600 700 zation (YN21047).
The number of iterations
of Financial Risk Management, vol. 10, no. 03, pp. 317–341, [25] F. Ghani, “Editorial fallow time and managing aerosol gen-
2021. eration in dental clinics-current evidence and financial in-
[9] E. P. Setiawan and D. Rosadi, “Portfolio optimisation with vestment implications,” Journal of Rawalpindi Medical
cardinality constraint based on expected shortfall,” Interna- College, vol. 24, no. 4, pp. 290-291, 2020.
tional Journal of Computing Science and Mathematics, vol. 12,
no. 3, p. 262, 2020.
[10] M. Jiang, W. Liu, W. Xu, and W. Chen, “Improved multi-
objective bat algorithm for the credibilistic multiperiod mean-
var portfolio optimization problem,” Soft Computing, vol. 25,
no. 8, pp. 6445–6467, 2021.
[11] A. Takahashi and S. Takahashi, “A new interval type-2 fuzzy
logic system under dynamic environment: application to fi-
nancial investment,” Engineering Applications of Artificial
Intelligence, vol. 100, no. 1, Article ID 104154, 2021.
[12] A. Nahvi, M. Ghorbani, M. Sabouhi SabouniSabouhi Sabouni,
and A. Dourandish, “Portfolio optimization of bank credits
with interval returns: empirical evidence from Iran,” Banks
and Bank Systems, vol. 15, no. 4, pp. 49–68, 2020.
[13] N. A. Bakar and S. Rosbi, “Robust hybrid optimization
method to reduce investment portfolio risk using fusion of
modern portfolio theory and genetic algorithm,” Interna-
tional Journal of Engineering and Advanced Technology, vol. 8,
no. 6S3, pp. 136–148, 2019.
[14] T. Cheng and J. Zhong, “An efficient memetic genetic pro-
gramming framework for symbolic regression,” Memetic
Computing, vol. 12, no. 4, pp. 299–315, 2020.
[15] F. Abbas and P. Lahore, “Impact of investment, financial and
trade freedom on bank’s risk-taking,” Studies in Business and
Economics, vol. 16, no. 3, pp. 5–23, 2021.
[16] S. Mu and Z. Xiong, “Internet financial interest rate risk
measure based on genetic rough set reduction,” Service
Oriented Computing and Applications, vol. 13, no. 4,
pp. 309–321, 2019.
[17] W. Lin, S. Wandelt, and X. Sun, “Efficient network dis-
mantling through genetic algorithms,” Soft Computing,
vol. 26, no. 6, pp. 3107–3125, 2021.
[18] X. P. Mao, “Research on residents’ consumption and financial
investment behavior in internet economy,” E3S Web of
Conferences, vol. 253, no. 7, Article ID 03081, 2021.
[19] C. Tang and H. Wu, “Joint optimization of task caching and
computation offloading in vehicular edge computing,” Peer-
to-Peer Networking and Applications, vol. 15, no. 2, pp. 854–
869, 2021.
[20] L. H. Hung, C. H. Wu, C. H. Tsai, and H. C. Huang, Mi-
gration-based Load Balance of Virtual Machine Servers in
Cloud Computing by Load Prediction Using Genetic-Based
Methods, IEEE Access, vol. 99, p. 1, Piscataway, NJ, USA, 2021.
[21] M. P. Cuéllar, J. Gómez-Torrecillas, F. J. Lobillo, and
G. Navarro, “Genetic algorithms with permutation-based
representation for computing the distance of linear codes,”
Swarm and Evolutionary Computation, vol. 60, no. 6, Article
ID 100797, 2021.
[22] J. Ni, “Evaluation of financial investment risk of enterprises,”
E3S Web of Conferences, vol. 253, no. 6, Article ID 03077,
2021.
[23] R. Mehdi and M. Nachouki, “Cost optimization of procuring
cloud computing resources using genetic algorithms,” Journal
of Theoretical and Applied Information Technology, vol. 98,
no. 8, p. 1201, 2020.
[24] H. Zhang, H. Liao, X. Wu, E. K. Zavadskas, and A. Al-Bar-
akati, “Internet financial investment product selection with
pythagorean fuzzy dnma method,” Engineering Economics,
vol. 31, no. 1, pp. 61–71, 2020.