No.2, Vol.1, Wnter 2012 2012 Publshed by JSES. A NEW GENETIC ALGORITHM TO SOLVE KNAPSACK PROBLEMS * Derya TURFAN a, Cagdas Hakan ALADAG b, Ozgur YENIAY c Abstract Knapsack problem s a well-known class of optmzaton problems, whch seeks to maxmze the beneft of objects n a knapsack wthout exceedng ts capacty. Varous knapsack problems have been tred to be solved by decson makers a wde range of felds, the most mportant one of these s portfolo optmzaton. In recent few decades, heurstc methods have been wdely used to solve hard optmzaton problems snce they have proved ther success n many real lfe applcatons. Genetc algorthm s one of these heurstc algorthms whch have been successfully employed n a varety of contnuous, dscrete and combnatoral optmzaton problems. In ths study, a new genetc algorthm s mproved to solve a portfolo optmzaton problem effcently. Keywords: Genetc algorthms, Mean-varance optmzaton, Portfolo analyss, knapsack problem JEL Classfcaton: C44, C61, G11 Authors Afflaton a - Hacettepe Unversty, Faculty of Scence, Department of Statstcs, Ankara, Turkey, e-mal: deryaturfan@hacettepe.edu.tr b - Hacettepe Unversty, Faculty of Scence, Department of Statstcs, Ankara, Turkey, e-mal: aladag@hacettepe.edu.tr (correspondng author) c - Hacettepe Unversty, Faculty of Scence, Department of Statstcs, Ankara, Turkey, e-mal: yenay@hacettepe.edu.tr *An earler verson of ths paper was presented at The 6th Internatonal Conference on Appled Statstcs, November 2012, Bucharest. 40
1. Introducton Knapsack problem has a central role n nteger and nonlnear optmzaton, whch has been ntensvely studed due to ts mmedate applcatons n many felds and theoretcal reasons. In many applcatons, practcal problems are often formulated as or approxmated by contnuous or nteger KP. Examples of successful applcatons n last decades cover resource allocaton (Btran et al 1981; Bretthauer et al. 1997; Bretthauer et al. 2006), demand forecastng (Hua et al. 2006), portfolo selecton (L et al. 2006), network flows (Helgason et al. 1980; Ventura 1991), etc. (Zhang et al. 2012) Gll and Kéllez (2000) has revewed portfolo analyss problem as follows: The fundamental goal of an nvestor s to optmally allocate hs nvestments among dfferent assets. The poneerng work of (Markowtz 1952) ntroduced mean-varance optmzaton as a quanttatve tool whch carres out ths allocaton by consderng the tradeoff between rsk (measured by the varance of the future asset returns) and return. Assumng the normalty of the returns and quadratc nvestor s preferences allow the smplfcaton of the problem n a relatvely easy to solve quadratc program. Notwthstandng ts popularty, ths approach has also been subject to a lot of crtcsm. Alternatve approaches attempt to conform the fundamental assumptons to realty by dsmssng the normalty hypothess n order to account for the fat-taledness and the asymmetry of the asset returns. Consequently, other measures of rsk, such as Value at Rsk (VaR), expected shortfall, mean absolute devaton, sem-varance and so on are used, leadng to problems that cannot always be reduced to standard lnear or quadratc programs. The resultng optmzaton problem often becomes qute complex as t exhbts multple local extreme and dscontnutes, n partcular f we ntroduce constrants restrctng the tradng varables to ntegers, constrants on the holdng sze of assets, on the maxmum number of dfferent assets n the portfolo, etc. In such stuatons, classcal optmzaton methods do not work effcently and heurstc optmzaton technques can be the only way out. They are relatvely easy to mplement and computatonally attractve. The use of heurstc optmzaton technques to portfolo selecton has already been suggested by (Mansn et al. 1999), (Chang et al. 2000) and (Speranza 1996). Ths paper bulds on work by (Dueck et al. 1992) who frst appled a heurstc optmzaton technque, called Threshold Acceptng, to portfolo choce problems. We show how ths technque can be successfully employed to solve complex portfolo choce problems where rsk s characterzed by Value at Rsk and Expected Shortfall. In ths study, the most actve 10 stocks traded n Istanbul Stock Exchange 30 Index (ISE 30) was chosen and ther proporton was calculated to obtan optmal portfolo wth the proposed genetc algorthm. Ths paper gves n Secton 2 formulaton of standard Markowtz s mean-varance model and n secton 3 bref nformaton about the usage of 41
genetc algorthms n portfolo optmzaton. The proposed genetc algorthm s ntroduced n Secton 4. Secton 5 presents the mplementaton. Fnally, Secton 6 provdes the concludng remarks. 2. The portfolo selecton problem Portfolo optmzaton problem s a well-known problem n the lterature. Varous methods have been used to make decsons about assets (Egroglu et al. 2012). There are dfferent formulatons for ths problem. The general formulaton of standard Markowtz s mean-varance model for the portfolo selecton problem: N: the number of assets avalable : the expected return of asset (=1,,N) j : the covarance between assets and j (=1,,N; j=1,,n) * R : the desred expected return w : the proporton (0 w 1) held of asset (=1,,N) Mnmze ww (1) subject to N N 1 j 1 j j N 1 w R * (2) N 1 w 1 (3) 0 w 1, =1,, N (4) (1) mnmzes the total varance (rsk) assocated wth the portfolo whlst (2) ensures that the portfolo has an expected return of R *. (3) ensures that the proportons add to one. Ths formulaton ((1)-(4)) s a smple quadratc programmng problem for whch computatonally effectve algorthms exst so there s (n practce) lttle dffculty n calculatng the optmal soluton for any partcular data set. (Chang et al. 2000) The Markowtz s mean-varance model to portfolo selecton nvolves tracng out an effcent fronter. (Markowtz1959; Markowtz 1987) 42
A combnaton of assets,.e. a portfolo, s referred to as "effcent" f t has the best possble expected level of return for ts level of rsk (usually proxes by the standard devaton of the portfolo's return) (Elton et al. 2011). 3. Genetc Algorthms A genetc algorthm (GA) can be descrbed as an ntellgent probablstc search algorthm. The theoretcal foundatons of Gas were orgnally developed by Holland (Holland 1975). In genetc algorthms, an ntal populaton contanng constant number of chromosomes s generated randomly (regardng portfolo optmzaton, each chromosome represents the weght of an ndvdual securty) and an evaluaton functon s formed to evaluate the ftness of each chromosome, whch defnes f the chromosome represents a good soluton. Usng crossover, mutaton and natural selecton, the populaton wll evolve towards a populaton that contans only the chromosomes wth good ftness. The larger the ftness value s the better objectve functon the soluton has. (Stancu et al 2010) The basc steps n genetc algorthms are: (Chang et al. 2009) Step 1: Intalze a randomly generated populaton. Step 2: Evaluate ftness of ndvdual n the populaton. Step 3: Apply eltst selecton: carry on the best ndvduals to the next generaton from reproducton, crossover and mutaton. Step 4: Replace the current populaton by the new populaton. Step 5: If the termnaton condton s satsfed then stop, else go to Step 2. 4. The proposed genetc algorthm A new genetc algorthm s proposed to solve the problem defned n secton 2. Ths secton ncludes the basc elements and parameters of the proposed genetc algorthm. Soluton Solutons are represented by chromosomes. The number of genes ncluded n a chromosome equals to the number of shares. Each gene ndcates the proporton (0 w 1) held of share. (=1,,N) There s an example of one soluton n Fgure 1. 43
Fgure 1. An example of one soluton Gene (share) ( 0,12 0,20 0,05 0,36 0,27 Chromosome (portfolo) Soluton spaces The solutons satsfy constrants gven at (2)-(5) compose of soluton space of the portfolo optmzaton problem. The ntal populaton To generate an ntal populaton, a functon coded n Matlab computer package was employed. Ths ntal soluton was generated dependng on the desred expected return(r * ). All solutons ncluded n ntal populatons satsfy the constrants of the related problem. The proposed genetc algorthm started from an ntal soluton. Ftness functon Objectve functon of the portfolo optmzaton problem gven n (1) was used as ftness functon. Neghborhood structure To generate a new populaton, crossover operaton was used n the proposed algorthm. A pont was defned randomly and for two parents, the genes after ths pont changed places wth each other. Mutaton Mutaton operaton was used n the proposed algorthm n order to generate a dversfcaton effect. The nverson method was used to perform mutaton. The parameters of the proposed algorthm are populaton sze, crossover fracton, mutaton fracton, teraton bound. Consequently, the am of ths study s to mnmze the rsk by usng the proposed genetc algorthm. 5. The mplementaton and the obtaned results The most actve 10 stocks traded n Istanbul Stock Exchange 30 Index (ISE 30) was chosen. Therefore, each chromosome has 10 genes. The used stocks are Akbank 44
(AKBNK), Emlak Konut Gayrmenkul Yatırım Ortaklığı A.Ş. (EKGYO), Garant Bankası (GARAN), Halk Bankası (HALKB), İpek Doğal Enerj Kaynakları Araştırma ve Üretm A.Ş. (IPEKE), İş Bankası C (ISCTR), Koza Anadolu Metal Madenclk İşletmeler A.Ş. (KOZAA), Türkye Petrol Rafnerler A.Ş (TUPRS), Türkye Vakıflar Bankası T.A.O. (VAKBN), Yapı Ve Kred Bankası A.Ş. (YAKBNK). The seres for each stocks contan weekly data between the dates 1 November 2011 and 31 October 2012. Totally 52 observatons were taken as closure prce for every week. The parameters of the proposed algorthm used n the mplementaton are gven n Table 1. Table 1. The parameters of the proposed genetc algorthm Parameter Values Populaton sze 20 Crossover fracton 1 Mutaton fracton 1 Iteraton bound 100 As a result of the mplementaton, the obtaned alternatve solutons are presented n Table 2. In ths table, the last two columns gve correspondng expected return and rsk values. After the proposed genetc algorthm s utlzed, alternatve solutons are obtaned. Decson maker can choose the best soluton based on hs/her further personal crtera of assessment. Table 2. The obtaned alternatve solutons AKBNK EKGYO GARAN HALKB IPEKE ISCTR KOZAA TUPRS VAKBN YKBNK Expected Return Rsk 0.081 0.580 0.075 0.003 0.029 0.030 0.029 0.003 0.081 0.090 5 0.149 0.158 0.328 0.045 0.011 0.038 0.040 0.038 0.006 0.179 0.157 6 0.236 0.143 0.536 0.019 0.000 0.006 0.006 0.006 0.000 0.141 0.141 7 0.132 0.145 0.398 0.048 0.001 0.038 0.043 0.041 0.001 0.142 0.142 8 0.198 0.153 0.259 0.121 0.004 0.034 0.033 0.035 0.004 0.178 0.179 9 0.257 0.168 0.336 0.066 0.011 0.019 0.018 0.019 0.010 0.183 0.170 10 0.228 0.196 0.250 0.038 0.013 0.038 0.038 0.037 0.001 0.194 0.196 11 0.254 0.014 0.919 0.009 0.007 0.008 0.008 0.009 0.008 0.010 0.009 12 0.070 0.113 0.581 0.017 0.004 0.016 0.013 0.014 0.003 0.117 0.122 13 0.132 0.147 0.287 0.015 0.001 0.015 0.016 0.015 0.001 0.248 0.255 14 0.206 0.009 0.870 0.011 0.008 0.007 0.010 0.007 0.006 0.007 0.066 15 0.077 0.002 0.985 0.002 0.001 0.001 0.002 0.002 0.001 0.002 0.002 16 0.049 0.035 0.884 0.009 0.002 0.009 0.009 0.009 0.001 0.009 0.033 17 0.067 45
0.094 0.691 0.004 0.003 0.003 0.004 0.003 0.002 0.099 0.099 18 0.099 0.004 0.963 0.004 0.004 0.004 0.004 0.004 0.004 0.004 0.005 19 0.057 0.002 0.980 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 20 0.051 6. Concluson Portfolo optmzaton s a knd of knapsack problem that s a well-known optmzaton problem. Many researchers from dfferent felds have been nterested n solvng ths problem. The decson-maker's desre s to avod the hgher rsks assocated wth larger monetary values when the decson maker has some nvestment opportuntes. In ths study, to provde support to the decson makers n the process of makng a choce among dfferent optons, we propose an alternatve soluton approach whch s based on genetc algorthms. The proposed genetc algorthm s ntroduced and t s appled to a real lfe problem. As a result of the mplementaton, sxteen dfferent solutons wth dfferent rsk levels and return values are obtaned and presented. References Chang, T., J. et al. (2000) Heurstcs for cardnalty constraned portfolo optmsaton. Computers & Operatons Research, 27, 1271-1302. Chang, T., J., Yang, S., C. and Chang, K., J. (2009) Portfolo optmzaton problems n dfferent rsk measures usng genetc algorthm, Expert Systems wth Applcatons, 36, 10529-10537. Egroglu, E., Aladag, C., H. and Yolcu, U. (2012) Comparson of feed forward and Elman neural networks forecastng ablty: case study for IMKB, Advances n Tme Seres Forecastng, Bentham Scence Publshers Ltd., 11-17. Elton, J., E. and Gruber, J., M. (2011) Investments and portfolo performance, World Scentfc, 382 383. Gll, M. and Këllez, E. (2000) Heurstc approaches for portfolo optmzaton, In: Sxth Internatonal Conference on Computng n Economcs and Fnance of the Socety for Computatonal Economcs, Barcelona, July 6-8 2000. J.,H., Holland (1975) Adaptaton n natural and artfcal systems: An ntroductory analyss wth applcatons to bology,control and artfcal ntellgence, Mchgan: Unversty of Mchgan Press. 46
Markowtz, H.(1959) Portfolo selecton: effcent dversfcaton of ınvestments, New York: Wley. Markowtz, H.(1987), Analyss n portfolo choce and captal markets, Oxford: Basl Blackwell. Stancu, S. and Predescu, M.,O. (2010)/ Genetc algorthm for the portfolo selecton problem on the Romanan captal market, Proceedngs of Internatonal Conference on Engneerng an Meta-Engneerng, Orlando, USA, 57-60. Zhang, B. and Hua, Z., S. (2012) Smple soluton methods for separable mxed lnear and quadratc knapsack problem, Appled Mathematcal Modellng, 36, 3239-3250. 47