# Fuzzy Logic-Based Performance Enhancement of FSO Systems Under Adverse Weather Conditions
## 3 Fuzzy Modeling for Enhancing Receiver Performance in FSO System
### Selection of Input and Output Membership Functions  
The FLC system operates according to the established rules that link environmental inputs to the variable BER threshold. For example, if the system identifies elevated levels of rain and fog along with an extended distance, the FLC will generate a high threshold BER value. Conversely, in optimal conditions marked by minimal rain and fog, as well as a short distance, a lower threshold BER value will be generated, which allows an increased error tolerance. This method enhances the reliability of the communication link while also optimizing resource utilization. By continuously observing the actual BER and comparing it with the dynamically computed threshold value, the system can initiate necessary adjustments when the BER surpasses acceptable limits. These modifications involve adjusting the transmission power. Therefore, for the implementation of a dynamic BER threshold, the designed fuzzy logic controller evaluates the following key environmental factors (inputs):  
* Rain (R): Intensity of rainfall (0 to precipitation rate \(>\) 50 mm).
* Fog (F): Density of fog (0 to 1.5 ).
* Distance (D): Distance between the FSO transceivers (0 to 3 km).  
These inputs undergo the first stage of the fuzzy inference process, known as the fuzzification interface, where precise inputs are converted into fuzzy values using membership functions. Each crisp input belongs to a universe of discourse, meaning it exists within a range of possible values that the crisp variable can take. The membership functions selected for the fuzzy sets of rainy weather conditions inputs, \(Z(\Delta R)=\text{clearair}(CA)\), low rain (LR), medium rain (MR), heavy rain (HR) and distances with four terms, \(Z(\Delta L)\) = very low distance (VLD), low distance (LD), medium distance (MD), and high distance (HD), within the universe of discourse between 0 and 3 km, are shown in Figure 5.  
Figure 4: Block diagram of FLC structure.  
Figure 5: Membership functions for rainfall \(Z(\Delta R)\) and distances \(Z(\Delta L)\).  
Likewise, the fuzzy sets of fog weather conditions inputs, \(Z(\Delta F)=\) clear air (CA), low fog (LF), medium fog (MF), and heavy fog (HF), follow a similar structure to the rainy weather conditions. Using these inputs, along with the properties of OCDMA codes, we adopt 2D-SSM codes with \(w=8\) to analyze the FSO system. The fuzzy logic controller generates a dynamic BER threshold (T-BER), which is classified into a set of thresholds (T-BER\({}_{i}\)), where \(i\) ranges from 1 to \(w\). Furthermore, due to its ability to represent the signal propagation model, the Gaussian membership function is adopted in this study, which involves setting the mean (\(\mu\)) and the standard deviation (\(\sigma\)) and is expressed as follows [26].  
\[f(x,\mu,\sigma)=e^{-\left(\frac{x-\mu}{2\sigma}\right)^{2}} \tag{9}\]  
Let \(\beta CA(Z(\Delta R))\), \(\beta LR(Z(\Delta R))\), \(\beta MR(Z(\Delta R))\), and \(\beta HR(Z(\Delta R))\) denote the membership functions of rain variation for CA, LR, MR, and HR in \(Z(\Delta R)\), respectively, having width \(\sigma=2\) and \(\mu\) ranging from 0 to 3, as shown in Figure 5. Likewise, assume \(\beta CA(Z(\Delta F))\), \(\beta LF(Z(\Delta F))\), \(\beta MF(Z(\Delta F))\), and \(\beta HF(Z(\Delta F))\) denote the membership functions of fog variation for CA, LF, MF, and HF in \(Z(\Delta F)\), respectively, having width \(\sigma=2\) and \(\mu\) ranging from 0 to 3. In the meantime, the membership function of distance variation is given by \(\beta VLD(Z(\Delta L))\), \(\beta LD(Z(\Delta L))\), \(\beta MD(Z(\Delta L))\), and \(\beta HD(Z(\Delta L))\). Finally, the membership functions of threshold output is given by \(\beta dthi(Z(\Delta T-BER)),\forall i\in{1,2,\cdots,8}\), having width \(\sigma=0.2\) and \(\mu\) ranging from 1 to 8, as shown in Figure 6.