## 6 The Proposed Simulation Optimization Algorithm
### Adding Discrete Event Simulation Principles to BR
The parameters within the algorithm should be interpreted as follows: _requests_ denotes the list containing both input and output orders to be processed; _racks_ signifies the list of warehouse racks; and _beta_ represents the vector of parameters utilized for the geometric distributions employed in the various BR processes. ```
input: requests, racks, beta \(solution\leftarrow NULL\)\(\triangleright\) init final solution whilelength(requests) \(>\) 0 do \(next\leftarrow getNextRequest(requests)\) \(reqSol\gets NULL\)\(\triangleright\) init solution to current request iftype(\(nextr\)) == Input then \(sol\gets processInput(nextr,solution,racks,beta)\) elseiftype(\(nextr\)) == Output then \(sol\gets processOutput(nextr,solution,racks,beta)\) endif ifisFeasible(\(sol\)) then \(postponentProc(nextr,requests)\)\(\triangleright\) request postponed else \(solution\leftarrow add(solution,sol)\) endif endwhile return\(solution\)
```  
**Algorithm 1** Pseudo-code of the proposed BR-DES algorithm. For an input operation, the objective is to identify an available space within the warehouse to accommodate the incoming bundle. The space must be sufficiently long, aligning with the bundle's type (code). To determine a viable solution, all racks are taken into consideration. During each iteration, racks are prioritized based on the availability of their respective cranes, with one of these racks chosen through a BR procedure. This phase is crucial for ensuring an equitable distribution of workload among all cranes. Specifically, the BR procedure incorporates a geometric probability distribution, as proposed in [PERSON] et al. (2018). If \(x\) denotes the position occupied by a candidate in the previously sorted list and \(\beta\) represents the parameter of the geometric probability distribution, then the probability \(f(x)\) of selecting candidate \(x\) is calculated as follows:  
\[f(x)=(1-\beta)^{x} \tag{6}\]  
When the chosen rack contains feasible storage locations, one of them is randomly selected using a uniform distribution. The decision is recorded in the emerging solution, and a new operation is scheduled to update the system's state. However, if the selected rack lacks feasible space, it is eliminated from the list of potential racks, and the BR rack-selection process is reiterated. If the list of potential racks becomes empty without finding a solution, a non-feasible solution is returned. In such cases, the BR-DES procedure postpones the input request. The pseudo-code for processing input operations is presented in Algorithm 2. ```
input:\(nextr\), \(solution\), \(racks\), \(beta\) \(pRacks\leftarrow\mathbf{copy}(racks)\)\(\triangleright\) list of racks to consider \(sol\gets NULL\)\(\triangleright\) solution to the current request while\(sol==NULL\)and\(length(pRacks)>0\)do \(pRacks\leftarrow\mathbf{sort}(pRacks,key:craneAvailability)\)\(\triangleright\) sort racks prioritizing the busiest ones \(rack\leftarrow\mathbf{findBR}(pRacks,beta)\)\(\triangleright\) select a rack by using BR \(pPlaces\leftarrow\mathbf{feasiblePlaces}(rack)\)\(\triangleright\) feasible storage locations if\(length(pPlaces)>0\)then \(place\leftarrow\mathbf{randomOnChoice}(pPlaces)\)\(\triangleright\) pick a random storage location \(sol\leftarrow\mathbf{newInput}Operation(nextr,rack,place)\) schedule\(\mathbf{Operation}(solution,sol)\)\(\triangleright\) schedule the new operation to carry out else \(pRacks\leftarrow\mathbf{remove}(pRacks,rack)\) endif endwhile return\(sol\)
```  
**Algorithm 2** Pseudo-code for input processing  
For output operations, constructing a solution involves selecting multiple bundles. Upon choosing a bundle, the system's state must be updated to accurately select the subsequent bundle. However, the solution cannot be deemed feasible until all required bundles have been retrieved. Therefore, before initiating solution construction, the system's state is saved to enable restoration to a previous state if the solution is found to be non-feasible. The construction process operates iteratively.