Prediction of IDR-USD Exchange Rate using the Cheng Fuzzy Time Series Method with Particle Swarm Optimization

Currently, much research on machine learning about prediction has been carried out. For example, to predict the exchange rate of the rupiah against the United States currency, namely the United States Dollar (USD). The continuing trend of USD depreciation has attracted many researchers to explore currency trading, especially in establishing an efficient method for predicting fluctuating exchange rates. The rapid development of time series prediction methods has resulted in many methods that can predict data according to needs. In this study, we apply the Fuzzy Time Series Cheng method with Particle Swarm Optimization (PSO) to predict the IDR exchange rate against USD. The data used in this research is sourced from Bank Indonesia in the form of time series data on the selling and buying exchange rate. The FTS Cheng method forecasts the IDR exchange rate against USD. In contrast, the PSO algorithm optimizes the interval parameter to increase the forecasting accuracy. Based on the implementation and the results of the tests, the results show that using the PSO algorithm can produce the best optimization interval parameters and increase the accuracy value. From the results of 10 trials with training data, testing data, and different iterations, it was obtained that the MAPE test for predicting the rupiah exchange rate against the US dollar using FTS Cheng with 60% training data and 40% testing data resulted in the lowest MAPE of 0.610145%. Furthermore, 70% of the training and 30% of the testing data resulted in the lowest MAPE of 0.313388%. Then the FTS Cheng and PSO testing with 60% training data and 40% testing data, and an iteration value of 200 resulted in the lowest MAPE of 0.394707%. Furthermore, 70% of training data and 30% of testing data and an iteration value of 90 resulted in the lowest MAPE of 0.263666%.


I. INTRODUCTION
The need to make predictions is vital in stock predictions, sales of goods, as well as weather forecasting, and currency rates. In predicting the rupiah exchange rate, the United States Dollar (USD) is the international reference currency. The trend of USD fluctuations attracts many researchers to know the pattern, especially in establishing an efficient method for exchange rate prediction. The rapid development of time series prediction methods has resulted in many methods that can predict data according to needs. Many methods have been proposed ranging from linear and non-linear regression to artificial intelligence algorithms [1].
Research related to currency exchange rate prediction using the Arima Box-Jenkins method produces the best model, ARIMA (13,1,13). Still, the ARIMA method has a complicated process to identify the appropriate model. [2]. The data will be transformed into stationery data, not original data that can be directly processed. The Fuzzy Mamdani method used to predict the exchange rate produces a MAPE value of 9.35% [3]. Machine learning with the Support Vector Regression (SVR) method with training modeling as much as 415 data with an R 2 value of 0.9223 and an RMSE of 54.3156. The 30 data testing also shows quite good results with an R 2 value of 0.5397 and an RMSE of 66.8015 [4]. Predicting the Malaysian Ringgit (MYR) exchange rate against the Singapore Dollar (SGD) using the Fuzzy Time Series Markov Chain and Fuzzy Time Series Chen & Hsu methods produces a MAPE for Fuzzy Time Series (FTS) Markov Chain of 0.9895%. While the MAPE value for FTS Chen & Hsu is 3,4306% [5].
The fuzzy time series algorithm is one of the computational intelligence methods that is attracting much attention today. Fuzzy Time Series (FTS) modeling through fuzzy relational equations and approaching reasoning [6]. One of the advantages of the fuzzy time series approach is that theoretical assumptions do not need to be checked compared to conventional time series methods, where various theoretical assumptions have to be considered. The fuzzy time series approach can handle minimal data sets, and the assumption of linearity does not need to be considered [7]. Many FTS methods have been developed, for example, the Chen FTS method and the Cheng FTS method. The research by [8] compared both methods and found that the Cheng method had a lower error rate. However, there are still weaknesses in FTS, namely the lack of consideration in determining the universe of speech and the optimal length of the interval [8]. An optimization algorithm is needed to find the optimal value of the FTS interval, and the optimization algorithm used is Particle Swarm Optimization (PSO) to overcome these weaknesses [9].
Particle Swarm Optimization (PSO) is a PSO optimization strategy that performs well in many function and parameter optimization problems [10]. Many studies using PSO have been shown to increase the performance percentage in research [11], [12]. The advantage of the PSO algorithm is that it has high decentralization with a simple implementation to solve optimization problems efficiently [13]. Another advantage of PSO is that the PSO algorithm can quickly achieve convergence values and is not sensitive to population size [10], [14], [15]. In this study, PSO will be applied to solve problems that occur in FTS Cheng by changing the pattern of the parameter intervals of the universe of speech to maximize the performance of the resulting model by achieving more accurate accuracy values.
Based on the problems and research references described, this study proposes the Fuzzy Time Series Cheng method with Particle Swarm Optimization (PSO) to predict the IDR exchange rate against USD. The data used in this study is sourced from Bank Indonesia in the form of time series data on the selling and buying rates. The FTS Cheng method forecasts the IDR exchange rate against USD, while the PSO algorithm is used to optimize the interval parameter so that the prediction accuracy level increases. This study is expected to determine the accuracy performance of the Cheng FTS method by optimizing the PSO interval parameter in predicting the rupiah exchange rate against the US dollar.

II. METHOD
The research methodology used for data collection in this study is quantitative. The quantitative research method is used if the data collected is quantitative or other data types that can be quantified and processed using statistical techniques. The research method in Fig. 1 contains the stages of planning that will be carried out while conducting this research. There are four stages to be carried out: data collection, particle swarm optimization algorithm, fuzzy time series Cheng algorithm, and error calculation.

A. Data Collection
The data collection process is carried out by taking data from the Bank Indonesia website at the address http://www.bi.go.id/id/statistik/information-kurs/transaksi-bi/default.aspx. The data used is data on the exchange rate of the rupiah (IDR) against the US dollar (USD) in the form of selling and buying rates from 2 January 2018 to 9 July 2021

B. Particle Swarm Optimization
Particle Swarm Optimization (PSO) is a population-based optimization technique. There are three basic principles in PSO as an algorithm based on cognitive and social behavior: evaluation, comparison, and imitation. [10]. PSO is a population-based evolutionary computing technique inspired by the social behavior of animals, such as flocks of birds, fish flocks, and swarming theory. PSO can solve many problems, such as Genetic Algorithms [16].
This kind of swarm intelligence-based optimization method is called a behaviorally inspired algorithm, which has a different approach from genetic algorithms. Genetic algorithms are usually considered by the method of evolution-based producers. It is assumed that the swarm on each particle has a specific or fixed size, and its initial position is random in multidimensional space. Each particle is assumed to have two characteristics: position and velocity. Each particle moves in a particular space and remembers the best position ever traversed or found concerning the food source or the value of the objective function. The particle conveys each particle's best position, adjusting the position and speed according to the information received regarding the best position. There are several steps or stages of learning in Particle Swarm Optimization (PSO), which are as follows: [17]: • Initialization of the velocity and initial position of the particle. The initial particle velocity is symbolized by vi, while the particle's initial position is symbolized by xi, for 1 ≤ i ≤ N, N is the number of particles. • Calculate the fitness value for each particle. The fitness value calculation is carried out for each particle i as well as the best position Pbest of each particle and its fitness value. The best position Pbest with the best fitness value is stored as Gbest. • Update particle speed. Particle velocity updates are carried out to determine the direction of displacement of particles in the population [10]. Equation (1) calculates the new particle velocity based on the previous velocity, the distance between the current position and Pbest, and between the current position and the best position Gbest.
Where the j variable is 1 , 2, … ,n represents the number of particles; the vj(i) variable is a particle velocity j in the iteration i; the c1,c2 variable the cognitive and social particle coefficient; the r1,r2 variable is the random numbers in the range [1,10]; the Pbest,j variable is the Pbest value represents the personal best of the particle j; and the Gbest,j variable is the the Gbest value represents the global best of the entire population. • Update particle position. Particle position updates are carried out to find the latest position on each particle i based on Equation (2).
Equation (2) is simulated in a space with a particular dimension with many iterations. In each iteration, the particle's position will increasingly lead to the intended target (minimizing or maximizing the value of the function). The iteration is done until the maximum iteration is reached or other stopping criteria are met.

C. Fuzzy time series Cheng
The Cheng method has a slightly different way of determining intervals, using a Fuzzy Logical Relationship (FLR) by including all relationships and assigning weights based on the same FLR sequence and iteration. [18]. The stages in making predictions using Cheng fuzzy time series are: • Determining the Universe of Discourse using Equation (3). Where dmin and dmax are the smallest and largest data from data, and d1 and d2 are positive numbers.
• Determining the interval width using the frequency distribution based on Equation (4).

= (
• Determine the number of class intervals using the Sturges based on Equation (5).
Specify the width of the interval using Equation (6).
Finding the middle value using Equation (7). Where, the variable is the number of fuzzy sets.
• Define fuzzy sets and form fuzzification, fuzzy sets 1 , 2 , ... can be formed based on pre-formed intervals. • Create a Fuzzy Logical Relationship (FLR) table based on actual data. FLR can be denoted by → where Ai is called the current state and Aj is called the next state.
• Determine the weight of the FLR relationship into a Fuzzy Logical Relationship Group (FLRG) by including all relationships (all relationships) and assigning weights based on the same sequence and iteration. FLRs that have the same current state ( ) are combined into one group in the form of a weighting matrix. Suppose there is a sequence of the same FLR. ( = 1) 1 → 1, given weight 1 ( = 2) 2 → 1, given weight 1 ( = 3) 1 → 1, given weight 2 ( = 4) 1 → 1, given weight 3 Where denotes time, the weights obtained in the FLR relation are entered as a weighting matrix using the matrix in Equation (8). Where is the weight of the matrix in the i-th row and j-th column with = 1, 2,…, ; = 1, 2,…, .
• Transforming the FLRG weights into a normalized weighting matrix ( * ) using a matrix on Equation (9). where * is a weighted matrix that has been normalized with Equation (10).
• Determine the Defuzzification of the predicted value. The normalized weighting matrix ( *) is multiplied by , the median value on the fuzzy set interval, and the prediction calculation using Equation (11) where is the result of weight prediction calculated using Equation (12).
If the result of the fuzzification i-th period is , and do not have FLR on FLRG with condition → ∅, where the maximum value of the degree of membership is at , then the predicted value ( ) is the median value of , defined by i [19].

D. Error Calculation
Error calculation is performed to compare the predicted results with the actual data. In this study, the method used to calculate the error is the Mean Absolute Percentage Error (MAPE). Mean Absolute Percentage Error (MAPE) is a method used to measure and evaluate the predicted value generated [17]. MAPE values are displayed as a percentage using Equation (13). Where, the Ai variable is actual data i, the Fi variable is the prediction result value for data i, and the N variable is the amount of data. Table I shows the quality of a prediction value calculated using the MAPE value can be determined based on the MAPE value criteria.

A. Data Collection
The data used is data on the exchange rate of the rupiah against the US Dollar in the form of selling rates and buying rates from 2 January 2018 to 9 July 2021, with a total of 872 data. The data is copied to Microsoft Excel with file format .csv and then imported into a MySQL database. However, for the exchange rate data sample based on the values in Table II Table III, which is an example of exchange rate data for testing.

B. Particle Swarm Optimization
Parameter interval optimization aims to find the best FTS interval parameters that can provide better results. The Particle Swarm Optimization (PSO) algorithm has several stages: initializing the initial particle velocity and particle position, calculating the fitness value, updating the speed and position of the particle, updating for the personal best value Pbest, and the global best Gbest. After the number of iterations is reached. The slightest error value and the best interval will be obtained, where the interval will then be used in calculating the exchange rate prediction with FTS Cheng.
• Initialization of Particle Position and Initial Velocity. Initialization of the particle's initial position based on in the value in Table IV is done to generate a solution in the problem space of a predetermined number of particles. The initialization process for the initial position in this problem is carried out randomly. • • Calculate Fitness Value. After the initial position and velocity of the particles are formed, the next step is to calculate the fitness value for each particle. The fitness value is obtained from MAPE (Mean Absolute Percentage Error), which is the result of calculating the level of forecasting error generated by FTS Cheng using interval optimization results with actual data related to the results in Table V. • Update Pbest. Personal best Pbest is the best position of the particle during iteration. The Pbest value is obtained from the comparison of the current position of the particle with the previous. At the time of the first iteration, the particle does not have a position that can be compared with the current position. In this case, the particle's current position will be used as Pbest based on the value in Table VI.

18
• Update Gbest. Global best Gbest is the best position of the particle. The Gbest value is the Pbest value which has the lowest fitness value. Gbest value constantly changes in each iteration. In this example problem, the Pbest with the lowest fitness value is owned by the 4-th particle. Gbest = 18. • Update Particle Speed. After obtaining Pbest and Gbest from the four particles. The particle velocity will be updated based on the value of both based on Equation (1). Next, to initialize the initial velocity, because new particles are generated, the initial velocity value for each particle position is 0. • Update Particle Position. After getting the latest velocity, the particle position is updated according to Equation (2), and we get the latest particle position, as seen in the results of Table VII. The second iteration with the same steps as the previous iteration until the results are obtained, as seen in the results of Table VIII. The initial speed of a particle Random 2 Learning factor 1 (c1) 1 8 Number of iterations 4 3 Learning factor 2 (c2) 1 9 Result Interval 16 4 The initial position of a particle Random 5 r1 0,921823 6 r2 0,986884

C. Fuzzy time series
The Fuzzy Time Series Cheng method with Particle Swarm Optimization (PSO) was applied to predict the rupiah exchange rate against the USD based on the values in Table III.  The weakness of FTS Cheng is that the determination of intervals is less than optimal. So that the interval needs to be optimized, with the PSO playing a role in optimizing the interval so that it will affect the following calculation process. Because optimization will be carried out with PSO. The interval above will be replaced with the results carried out by PSO, which produces Knew=16.
3) Calculate the width of the interval using Equation (6  • Fuzzification and Fuzzy Logical Relationship (FLR). The fuzzification stage is based on the number of intervals formed, and there are 13 fuzzy sets, namely A1, A2, A3,…,A13. In the fuzzification process, data will be checked at a particular time, whether the data is included in a specific interval. If data is contained in an interval, then the data is included in the set associated with that interval. Suppose the exchange rate data is 13712; then the data is included in the fuzzy set A7 because the data is between 13701.25 and 13718.13, which is the limit of interval 7 based on Table X. The FLR is arranged by first-order rule, where the fuzzy logical relationship is based on two consecutive fuzzy sets. The FLR can be arranged as follows: ( ) = ( − 1) → ( ). For example, the results of the fuzzification of exchange rate data on 13, 14, 15, and 19 February 2018 are A7, A8, A3, and A1, respectively. The FLR compiled from the fuzzification results are A7 → A8, A8 → A3, dan A3 → A1 based on Table XI. • Fuzzy Logical Relationship Group (FLRG). After the FLR is formed, the next step is to form the FLR by grouping the FLRs with the same current state (left side) based on Table XII.   TABLE XII  THE FUZZY LOGICAL RELATIONSHIP GROUP  Group  FLRG  G1  A1→A3  G3  A3→A1, A3→A3, A3→A4  G7  A7→A8, A7→A11  G8  A8→A3, A8→A7, A8→A9  G9  A9→A8, A9→A11  G11  A11→A16  G13  A13→A13, A13→A14  G14  A14→A15  G15  A15→A14, A15→A16  G16 A16→A13, A16→A15 Then the weights obtained in the FLR relation are entered as a weighting matrix (W). The following is based on Equation (8) and Equation (14).   • Defuzzification Process. The defuzzification process calculates the predicted value based on Equation (11). If the result of fuzzification period i is Ai and Ai does not have FLR on FLRG with condition Ai → ∅, then the predicted value is the mean value of Ai. The results of the Defuzzification of FLRG are obtained in Table XIII. The predicted value obtained is based on the fuzzy set in the period i for each F(i).

E. Error Calculation
In this study, predictions of the IDR exchange rate against the US dollar have been made using the Fuzzy Time Series Cheng with Particle Swarm Optimization. The dataset is obtained from the official website of Bank Indonesia, namely daily data on selling rates and buying rates. Then the dataset is entered into the database to be used in the prediction process. The process starts from the PSO algorithm initializing the particles obtained from the FTS Cheng process until the output is obtained, namely the interval parameter, which will be the interval in the FTS Cheng prediction process. After obtaining the optimization interval, the FTS Cheng algorithm will conduct the prediction process and find the prediction error rate using MAPE.
Based on the implementation and the results of the tests, the results show that using the PSO algorithm can produce the best optimization interval parameters and increase the accuracy value. From the results of 10 trials with training data, testing data, and different iterations, it was obtained that the MAPE test for predicting the rupiah exchange rate against the US dollar using FTS Cheng with 60% training data and 40% testing data resulted in the lowest MAPE of 0.610145%. Furthermore, 70% of the training and 30% of the testing data resulted in the lowest MAPE of 0.313388%. Then the FTS Cheng and PSO testing with 60% training data and 40% testing data, and an iteration value of 200 resulted in the lowest MAPE of 0.394707%. Furthermore, 70% of training data and 30% of testing data and an iteration value of 90 resulted in the lowest MAPE of 0.263666%.
Based on the MAPE value criteria, the Fuzzy Time Series Cheng algorithm with Particle Swarm Optimization can predict the rupiah exchange rate against the US dollar with excellent prediction results. The test results also showed that the weighting value affects the level of accuracy with the result in Table XV. In this case, the FTS Cheng algorithm with PSO gives a better partition than the partition obtained from the FTS Cheng only. Thus, PSO performance increases with a small MAPE. The impact of these results is that iterations are also getting smaller MAPE because convergence will be achieved more quickly.

IV. CONCLUSION
Optimizing the PSO interval parameter on predicting the rupiah exchange rate against the US dollar using the FTS Cheng method affects the results, namely reducing the MAPE results. From the results of 10 trials with training data, testing data, and different iterations, it was obtained that the MAPE test predicts the rupiah exchange rate against the US dollar. The most optimal accuracy obtained by the FTS Cheng algorithm produces a MAPE value of 0.313388%, while the FTS Cheng and PSO algorithms obtain a MAPE of 0.263666%. In the FTS Cheng algorithm, many intervals affect the fuzzy set, subsequent stages, and the obtained MAPE value. The more intervals, the smaller the MAPE value obtained. The PSO algorithm's number of iterations affects the interval value obtained. Thus, the interval obtained by PSO improves the FTS Cheng interval and reduces the MAPE value. From various experiments on several FTS Cheng and PSO parameters, the MAPE produced by the FTS Cheng and PSO algorithms is relatively smaller than FTS Cheng alone, proving that PSO can optimize the FTS Cheng algorithm well. In future research, it would be better if the Fuzzy Cheng could be tested with other metaheuristic algorithms, such as Evolutionary algorithms, physics-based algorithms, or bio-inspired algorithms.