• No results found

The Inflation Risk Model

3.3 Solution to the Problem

3.3.6 Parallel Computation in Mathematica

As we said earlier, the problem (3.26)–(3.34) is converted into a form suitable for solving it on the computer. Actually, we solve the problem on eight computers and use the technique of parallel computations. It means that we transform the problem into a form suitable for distributing similar tasks to many processors, in our case 14 processors, where each processor solves one set of tasks and returns the results. Each processor works on the computer where Mathematica 5.2 is installed. In these circumstances, one computer is the master and others are slaves. The master computer runs Mathematica front–end and one kernel, while the others use Mathematica kernels only. The slave computers have two processors and one kernel runs on each of them, thus running two kernels at the same time on each slave computer.

All programming and storage of data is done on the master computer. We develop the programs using standard Mathematica 5.2 as the main programming language, supported with Parallel Toolkit 2.0 and Global Optimisation 5.2 package.

Parallel Toolkit 2.0 is an addition to Mathematica 5.2, which provides the tool for distributing tasks to many processors, which are run on the computers where Mathematica 5.2 and Parallel Toolkit 2.0 are installed. We also need to connect the computers in the appropriate way such that each processor recognises the master computer. Once we have this setup, we write the programs on the master computer which sets up the model and all the variables, procedures and functions. We use the standard Mathematica 5.2 as the front–end on the master computer. Parallel Toolkit 2.0 provides us with the tool to send tasks to other processors such that they receive the task, solve it and return the results to the master computer. The results are then collected to the master computer and regrouped such that they give us one full solution. The solution is stored on the master computer and available for further analysis. Parallel Toolkit 2.0 runs Mathematica kernel on the remote computers only, and we actually do not see these calculations, we only send tasks and get results.

Using this technique, we have parallel computations which means that by running the problem on 14 processors we obtain the solution 14 times faster compared to running the same problem on just one computer.

The Global Optimisation 5.2 package provides a suite of tools for solving nonlinear optimization problems, as well as a variety of other applications such as finding the roots or zeros of a non–analytic function. As the authors say, the package is easier, simpler, and more robust than most optimisation tools, and we find it works quite efficiently. The range of functions for solving nonlinear optimisation problems uses different techniques. In order to find the best solution in the shortest time, we combined two main functions, GlobalSearch and MultiStartMin. Generally, both functions find the minimum of a nonlinear function of n variables with equality and inequality constraints. Both functions use a multiple–start generalised hill–climbing algorithm designed to work with or without constraints. The function itself starts the calculation from the random point in the domain of the solution and then finds the optimal solution and multiple–start algorithm means that the function starts from a predefined number of randomly chosen starting points. Then the function chooses the best solution obtained amongst solutions for each starting point. MultiStartMin handles highly nonlinear problems better and in order to solve this subset of problems, it handles constraints differently and is thus slower than GlobalSearch, particularly as problems get larger. Both functions are robust to noisy functions and local minima.

Let us now give some more details of the solution of our problem. On the computer we solve equation (3.43) for the values on the wealth grid

( )

wt i, ni=w1, where nw =51.

Nominal income coefficient dtNA takes values from the set

(

dt jNA,

)

njd=1, where nd = . 8

The inflation grid

( )

It k, nkI=1 takes nI =15 values, and transitional matrix for inflation is

(

; ,

)

(( ,,) ( ))1,1

I I

n n t k m k m

I = . Grids, states and transitional matrix for inflation are presented in 3.4.1.

We calculate and store in the file the set of solutions (3.42) of equation (3.43). This is the point where we use parallel computing. We need to calculate the solution of equation (3.43) nw×nd×nI times.

One calculation is measured in seconds depending on the complexity of the calculation. We firstly apply the GlobalSearch algorithm for two random starting points. If we get two same solutions, we assume that this solution is correct and practice has shown that it is the correct assumption. If we get two different solutions, or only one solution, or no solution then we apply the MultiStartMin algorithm for three random starting points. Now, if we get one solution using the GlobalSearch algorithm then we compare the expected value functions obtained using different algorithms and take as the solution the one providing the highest expected value function. If no solution is obtained using the GlobalSearch algorithm then we take as

the solution the one providing the highest value function using the MultiStartMin algorithm. This approach has proved to lead to good solutions in each instance.

Rarely it is possible that two random starting points for the GlobalSearch algorithm and three random starting points for the MultiStartMin algorithm are not enough because we get unsatisfactory solutions in some instances. Then we increase the number of starting points. It means that we solve the problem a bit more slowly but we increase the quality of the solution. In some cases, useful criteria for finding the good solution are the precisions of the required solution in terms of number of decimal places up to which we compare resulting expected value function. Usually, we use 108 for ages 90 99− , 107 for ages 80 89− , 106 for ages 70 79− , and 105 for ages 65 69− . We determine these precision limits from experience such that we get smooth curves of the expected value functions, asset allocation functions, and annuitisation functions. If we do not get satisfactory solutions in terms of smooth curves, then we can try to improve the solutions by decreasing the powers mentioned earlier and we get solutions that are more precise. Thus, we have two main assumptions that can be changed in order to improve the quality of the solutions and these are the number of random starting points and the required precisions of the value functions.

Depending on the complexity of the instance, the time needed for obtaining one solution varies from 1 to 20 seconds. Rarely it can take more time but never more than 100 seconds. One calculation takes 10 seconds on average. If we work with deterministic inflation and if we work with 51 points of wealth grid and 8 points of

NA

dt grid then the calculation for one year of age takes 10 51 8⋅ ⋅ =4000 seconds or approximately one hour. However, we use parallel computation and the set of calculation tasks is distributed to 14 processors. As a result, it takes us just a few minutes to obtain the solution for one year of age. The time needed for the cubic splines, and storing results on the hard drive is not significant. If we work with stochastic inflation and if we take the inflation grid to have 15 points then our calculation is 15 times longer.

With the appropriate programs in Mathematica, we can make the full set of solutions for one setup of assumptions in one run of the program. In practice, we start the program, leave it for a couple of hours, and get solutions stored on the computer.

Solutions are stored in excel files. As we will see later, stochastic inflation is not always necessary and in that case we store on the computer one excel file for each age and for five functions, optimal consumption, optimal asset allocation, optimal nominal annuitisation, optimal real annuitisation and derived optimal value function.

Altogether, it is 35 5 175⋅ = files. If we work with stochastic inflation then we have 15 times more, or 2625 files as the solution for one assumption of parameters. We save and name these files in a predetermined way and then they are easily manageable.

Transformation of the solutions from the form (3.44) into the form (3.50) is done afterwards when we have the set of the solution (3.44) stored on the master computer.

This transformation is not time consuming once when we have the set of solutions (3.44) stored in files.

Solutions can be easily used for the analysis afterwards. Producing tables and graphs in excel is not time consuming once the appropriate excel files together with macros are made. We do not need parallel computing for this part of obtaining the results.