## 4 Further Analysis and Discussion
### Code Optimization: The Recursive Implementation of the Permanent Value Determination Algorithm
```
Input: Temp_Mat Output: >0 for the Permanent Value of Temp_Mat; = \(-1\) for Dimensional Inconsistency (Non-square Matrix Input) or Dimensional Conflict (the Degree is not 3)
1: Initialize the sum value: TheSum = 0;
2: Accumulate the sum according to mathematical formulae of permanent value:
2-1: #Row = count # rows for Temp_Mat;
2-2: #Col = count # columns for Temp_Mat;
2-3: if#Row equals to #Col do// Check if Temp_Mat is a square matrix
2-4: if#Row equals to 3 do// Check if Temp_Mat has the 3x3 dimension
2-5: TheSum = TheSum + Temp_Mat [1,1] \(\times\) Temp_Mat [2,2] \(\times\) Temp_Mat [3,3];
2-6: TheSum = TheSum + Temp_Mat [1,2] \(\times\) Temp_Mat [2,3] \(\times\) Temp_Mat [3,1];
2-7: TheSum = TheSum + Temp_Mat [1,3] \(\times\) Temp_Mat [2,1] \(\times\) Temp_Mat [3,2];
2-8: TheSum = TheSum + Temp_Mat [1,3] \(\times\) Temp_Mat [2,2] \(\times\) Temp_Mat [3,1];
2-9: TheSum = TheSum + Temp_Mat [1,2] \(\times\) Temp_Mat [2,1] \(\times\) Temp_Mat [3,3];
2-10: TheSum = TheSum + Temp_Mat [1,1] \(\times\) Temp_Mat [3,2] \(\times\) Temp_Mat [2,3];
2-11: elsedo
2-12: TheSum = (\(-1\));
2-13: endif
2-14: elsedo
2-15: TheSum = (\(-1\));
2-16: endif
3: Return the TheSum value to the calling algorithm: return TheSum;
```  
**Algorithm 4** PermRecur  
```
Input: A Square Matrix Temp_Mat of Degree > 3 Output: The Permanent Value of Temp_Mat Algorithm 3 has been implemented
1: Initialize TheSum and measure the degree of Temp_Mat:
1: TheSum = 0;
2: #Row = count # rows for Temp_Mat;
3: #Col = count # columns for Temp_Mat;
3: Perform suitable operations based on the dimension of Temp_Mat:
2: **if#Row equals to #Col do//Check if Temp_Mat is a square matrix
2: **if**#Row equals to 3 do//Check if the degree of Temp_Mat has reached 3x3
3: TheSum = Per3\(\times\)3(Temp_Mat);
4: else
5: for\(i\) in [1... DimMat] do
6: Reduced_Mat = remove row \(i\) from Temp_Mat;
7: Reduced_Mat = remove column 1 from Reduced_Mat; //Obtained the reduced matrix of Temp_Mat by removing the \(i\)-th row and the \(j\)-th column
8: TheSum = TheSum + Temp_Mat[i,1] \(\times\) PermRecur(Reduced_Mat);
9: // Accumulate TheSum
10: endif
11: else
12: TheSum \(\gets\) 0;
13: endif
14: Return TheSum value to the calling algorithm: return TheSum;
```  
**Algorithm 5** PermRecur  
``` Input: Temp_Mat
1: TheSum = 0;
2: #Row = count # rows for Temp_Mat;
3: #Col = count # columns for Temp_Mat;
4: Perform suitable operations based on the dimension of Temp_Mat:
5: #Row = count # columns for Temp_Mat;
6: #Row = count # rows for Temp_Mat;
7: #Row = count # columns for Tem

+++ ==WARNING: Truncated because of repetitions==
p_Mat;



++

### The Performance of the Recursive Implementation

The performance of the new GTMA implementation should be an interesting issue. However, limitations of space mean that the overall performance of only the recursive algorithm that is improved, instead of the entire R program, is measured, because computations to determine the permanent values create a bottleneck during GTMA computations. To benchmark this, the program is revised and a timing mechanism is inserted at the outside calling layer, which is at the ComputePermanentValuesForASAMs() function that calls PermRecur() (i.e., Function-2 that calls Function-4). For the problem size (_Nalt_ = 8 and _Ncrit_ = 7) and data of the used decision case, the following outputs, which are the timestamps in units of (seconds.milliseconds), are listed in Table 6.

The start time and stop time for each call to the PermRecur() function in R is shown in the second and third columns. The last column and the last row are also obtained as the auxiliary information of the benchmarking process. The result show that, on the testing platform (a portable PC with Intel i7 CPU 2.6 GHz, 16 G RAM, HDD, Windows 10 64-bits as the OS, R Studio v1.0.143 and R x64 v3.3.1 installed, with two SSD hard drives), it requires about 0.253 s to complete calling PermRecur() function each time for any one 7 \(\times\) 7 ASAM matrix.