# Product Model Derivation from Feature Model and Formal Specification
## 3 Product Derivation Based on Feature Model and Specification Approach
### Product Model Derivation Approach
#### 3.3.2 Behavior Preserving Integration
The process input and output variables \(iv_{ij}\), \(ov_{ij}\) can help to filter the functional scenarios of a process and obtain the relevant scenario paths. We implement the above process, as follows in Algorithm 2. Here, we take the feature _ReserveforBus_ and _ReserveforFlight_ of TMS as an example. Figure 6 is the CDFD diagram of the formal specification of the feature. It can be observed from the figure that there are four processes in the module _ReserveforBus: Check_Bus, Check_Pass, Confirm_Bus_, and \(Confirm\_invoice\) and four processes in the module _ReserveforFlight_. Each module has one or more functional scenario paths, as shown in Table 2. For example, there are four functional scenario paths for the feature _ReserveforBus_, of which the first scenario path [_reserve_for_bus_request_, _user_id]Check_Bus1[wrong_id_] is a functional scenario based on the process _Check_Bus_. The number 11 behind _Check_Bus_ represents the port number, respectively; _reserve_for_bus_request_, _user_id_ is from the first input port to enter the process _Check_Bus_, and the output is from the first port of the output after passing through the post-condition. The last three scenario paths are also similar. ```
Input: module \(m_{f}\) Output: Path /* the set of functional scenario paths */ \(postP_{m_{f}}\gets P_{1}\lor P_{2}\cdots\lor Pn\;\;P_{i}(i\in\{1\cdots n\})\); foreach\(P_{t}\gets R_{1}\wedge R_{2}\cdots\wedge R_{m}(m\geq 1)\)do \(\{\text{IO}_{1},\text{IO}_{2}\}\leftarrow\text{iv}_{ij}\subseteq\text{IO}_{1}\), \(\text{ov}_{ij}\subseteq\text{IO}_{2}\)

end foreach IO\({}_{k},k\in\{1,2\}\)do \(C_{1}^{t}\leftarrow\wedge_{i\in s}R_{i},s\in\{i\in[1\cdots m]|R_{i\in}\text{IO}_ {1}\}\); \(D_{2}^{t}\leftarrow\wedge_{i\in s}R_{i},s\in\{i\in[1\cdots m]|R_{i\in}\text{IO}_ {2}\}\);

end foreach f\({}_{i}\leftarrow C_{1}^{t}\wedge D_{2}^{t}\); Path \(\leftarrow\cup f{}_{i}\); returnPath;
```  
**Algorithm 2** Feature Scenario Paths Generation  
**Definition 7**. : _Given two features \(f_{1}\), \(f_{2}\), let \(S_{f_{1},f_{2}}=(M_{1},M_{2},\cdots,M_{n})\) denote a integrated feature specification, where each \(M=(T_{M},V_{M},I_{M},\text{FS}_{M})(i\in\{1,2,\cdots n\})\) is a module defined in the specification, \(T_{M}\), \(V_{M}\), \(I_{M}\) and \(\text{FS}_{M}\) are the set of all type declarations, state variable declarations, invariants, and functional scenarios, respectively. \(f_{1}\cdot f_{2}\) is said to be a behavior preserving integration, if_  
\[\text{FS}_{f_{1}\cdot f_{2}}=\bigcup_{i=1}^{n}M_{i}\cdot\text{FS}_{M} \tag{7}\]  
\[T_{f_{1}\cdot f_{2}}=\bigcup_{i=1}^{n}M_{i}\cdot T_{M} \tag{8}\]  
\[V_{f_{1}\cdot f_{2}}=\bigcup_{i=1}^{n}M_{i}\cdot V_{M} \tag{9}\]  
\[\exists_{p_{i},\cdots,p_{j}\in P_{m}}\cdot(\exists_{m\in[i,j-1]}\cdot \
exists_{IPort(p_{m})\cup T\times L\to O\mathit{Port}(p_{j})\cup T}) \tag{2}\]0  
\[\exists_{p_{i},\cdots,p_{j}\in P_{m}}\cdot(\exists_{m\in[i,j-1]}\cdot \
exists_{IPort(p_{m})\cup T\times L\to O\mathit{Port}(p_{j})\cup T}) \tag{2}\]1  
\[\exists_{p_{i},\cdots,p_{j}\in P_{m}}\cdot(\exists_{m\in[i,j-1]}\cdot \
exists_{IPort(p_{m})\cup T\times L\to O\mathit{Port}(p_{j})\cup T}) \tag{2}\]2  
_where \(\text{FS}_{f_{1}\cdot f_{2}}\) are the set of all functional scenarios defined in the entire formal specification; \(T_{f_{1}\cdot f_{2}}\) and \(V_{f_{1}\cdot f_{2}}\) are the sets of all types and state variable declarations, respectively; and \(I_{f_{1}\cdot f_{2}}\) are the set of all invariants._  
The functional scenario is the basic unit in the formal specification for presenting the desired functions, and the process can be transformed into the conjunction or disjunction of functional scenarios. The module contains the set of all functional scenarios derived from the processes of f1 and f2. For each feature pair, feature integration can be conducted if its functional scenario path matches another feature. Function integration based on path matching aims to connect fragmented process paths into functional paths that can express independent operations.