## 3 Concept of an Adaptive Algorithm of Proportional Gain Change  
The proposed adaptive P-type gain change algorithm for the soft sensor generates all object signals, including those for which no measurements can be made due to the difficulties of online measurement. The concept of the algorithm consists of applying a filtration equation with a structure used that is similar to the Kalman filter. However, the value of the gain will be determined adaptively. In particular, modification of the gain coefficient is made in each step of the calculation based on the current adaptation error \(\varepsilon_{i}\) (7), defined for the needs of this algorithm.  
The equation generating the signals of the object in the monitoring system takes the form  
\[\frac{d}{dt}\hat{x}_{i}=A\hat{x}_{i}+K_{i}[y_{i}-C\hat{x}_{i}] \tag{6}\]  
where:  
\(\hat{x}\)--signal generated by soft sensor adaptive algorithm;  
Figure 1: Idea scheme of a biochemical oxygen demand (BOD) soft sensor for a water quality monitoring system.  
\(y\)--measurements from Equation (5);  
\(A\)--matrix from the model (3);  
\(K\)--adaptively determined values of the gain coefficient;  
\(C\)--measurement matrix;  
\(i\)--index of the current calculation step.  
The adaptation error is a real, measurable signal, expressed by the equation  
\[\varepsilon_{i}=y_{i}-C\hat{x}_{i} \tag{7}\]  
where \(\varepsilon_{i}\) is the adaptation error in the \(i\)th step.  
Based on the adaptation error defined in this way, the algorithm determines the proportional correction value of the gain coefficient dependent on the adaptation error value according to the equation  
\[\Delta K_{i}=k_{p}\varepsilon_{i}, \tag{8}\]  
in which:  
\(\Delta K\)--correction of the gain coefficient;  
\(k_{p}\)--proportionality parameter of changes in the gain coefficient.  
At the present stage of research, expert knowledge is required to determine the value of parameter \(k_{p}\) contained in Equation (8).  
After determining the correction, the current value of the \(K\) gain coefficient is determined incrementally in each calculation step according to the dependence:  
\[K_{i+1}=K_{i}+\Delta K_{i},\;\;K_{0}=0. \tag{9}\]  
Assumption of the initial value of the gain coefficient is zero. This causes greater universality of applications of the proposed adaptive algorithm.  
The gain thus obtained is used in Equation (6) to generate all the approximated signals of the object, even signals for which no measurements are made. In Equation (8), the error value \(\varepsilon_{i}\) represents the current information about the discrepancy between the signals of the \(x_{i}\) object and the value generated in the soft sensor \(\hat{x}_{i}\) (see Figure 1). Thus, the current value of the gain correction \(\Delta K_{i}\) results from the value of the adaptive error, which indicates the need to change the gain \(K_{i}\) to reduce the error \(\varepsilon_{i}\). The general concept of the algorithm used in the soft sensor is shown in the block diagram in Figure 2.  
The algorithm generates \(\hat{x}_{i}\) signals representing all signals of the object based on measurements \(y_{i}\) made only in online mode. The left part of the algorithm diagram determines the current values of gain coefficient \(K_{i}\) affecting the quality of the generated signals.  
The proposed algorithm requires knowledge of the mathematical model, but parameters of the object do not need to be determined precisely. An important advantage of the presented algorithm is the stability of operation for any values of interference generated on the basis of their intensity (lack of information about statistics characteristics for these signals). The soft sensor based on the proposed algorithm works in online mode and can generate signals with satisfactory accuracy, even for such signals for which no measurements are made.