# Smart Low-Cost Control System for Fish Farm Facilities
## 5 Smart Control Algorithm for Aquaculture
### Example 2: Control Algorithm Operation in RAS  
As mentioned in previous subsections, the isolation of tanks due to malfunctioning of the water reconditioning system or stopping them due to maintenance is one of the possibilities in RAS facilities. Concerning the isolated tank operation, the algorithm is triggered when the water quality monitoring subsystem detects an abnormal situation and sends an alarm. First of all, the algorithm checks the values of the water quality parameters at the end of filtration and the threshold values for the tanks (based on fish species and development stage). Then, it identifies the affected tanks and calculates the maximum and minimum values of the aeration system to keep the DO in range. Immediately, it closes the water pumps and turns on the aeration at the minimum value. From that moment, the systems continuously check the DO values in each tank and readjust the aeration level to ensure that the DO does not decrease from the recommended values. Moreover, it checks if the condition at the end of the filtration tank has improved, allowing the water circulation to be reestablished. Once the water condition improves, the system turns on the water pumping, closes the aeration, and sends a message to the rest of the system stating that no tanks are isolated. This algorithm is integrated with AI, as illustrated in Figure 19. The deep learning components of the system will adjust the models, thresholds, and coefficients used, as well as the water quality parameters to be considered. In Figure 20a,b, we can see the example of the operation of RAS with connectivity with the DB and AI engine during a failure in the solid filter and the example when there is no connectivity in Figure 21a,b. Figure 19: Smart algorithm for isolated tank subsystem. This algorithm represents the initial algorithm provided to the deep learning system, which will evolve based on sensed data and the output values of other decision-making algorithms. In the first case, the solid filter starts to operate abnormally, and then the AI predicts its imminent failure based on the change in the trend of the data. This triggers three different decisions; the first is to isolate the tanks and the rest of the water reconditioning system to prevent the excess turbidity from reaching the biofilter and tanks. The second is to activate the aeration of tanks at a 15% ratio and start to increase it slowly as time passes, given an exponential model that is calculated to keep the DO at the maximum DO value. The last action is to activate the alarm in the solid filter to ensure that a worker fixes the problem in the filter. This alarm ensures that the problem is solved after a few minutes, and the complete failure of the solid filter is prevented while the fish welfare is assured. The maximum turbidity in the tank is 2.5 NTUs, the minimum DO is 8.49 mg/L, and the aeration system operates for 19 min at an average ratio of 24%. When no connection with the smart algorithm is available, the IA cannot detect the trend of the solid filter change, and no action is taken. The turbidity increases in the tank until it reaches a threshold that activates the predefined control algorithm that closes the water entrance of the tank. Then, the DO starts to decrease since the aeration is not automatically triggered. Once the DO drops below the limit, the aeration is turned on based on the predefined control algorithm. The aeration starts operating at 100% until the DO reaches the upper limit of the DO. Then, it is deactivated, and the DO decays again, producing a future activation of the aeration. The maximum turbidity in the tank is  
Figure 20: Scenario 2 with connected Smart Control System. (**a**) Depicts the conditions of turbidity and dissolved oxygen in the tanks. (**b**) Illustrates the operation of the water flow pump and aeration system. The automatic isolation of the tank and activation of the aeration system ensures that fish welfare is preserved.