## 3 Proposed Method for Representing and Searching Physical Models
### Search Algorithm  
To carry out the retrieval process, an algorithm was designed and implemented based on pattern matching algorithms [31], vector representation techniques [32], and cosine similarity functions [33,34]. This algorithm calculates the similarity of the results from an input query to enable the retrieval of relevant physical models. In this section, a detailed explanation of the algorithm and its components is provided, along with a description of how the semantic reuse of physical models is achieved through pattern matching, vector representations, and cosine similarity.  
1. **Pattern Matching:** in this step, the algorithm searches for the semantic pattern of the input query to be matched in the models. The model text and the query text are processed using NLP techniques, such as tokenisation and normalisation, to calculate the cosine similarity \(d\) between the resulting terms of the query \(t_{q}\) and model \(t_{m}\). If the cosine similarity of \(t_{q}\) in \(t_{m}\) is consecutively higher than the value of 0.7 set in the algorithm, then the model is assigned a weight \(w=1000\). In this way, the models that match the pattern return a higher similarity than the others (see Figure 6).  
The threshold value of 0.7 was selected after an empirical experimentation process in which we tested different values ranging from 0.4 to 0.9. The selected threshold  
Figure 4: Example of transformation of information from graph representation to a pattern.  
Figure 5: Example of the verbalisation process of an electrical model.  
consistently yielded the most accurate and relevant results while effectively balancing precision and recall. When setting the threshold at 0.7, the algorithm assigns a significant weight to highly relevant models that closely match the query's semantic pattern, thereby optimising the trade-off between capturing meaningful matches and avoiding excessive false positives. Similarly, the assigned weight \(w=1000\) for matching models was determined through experimentation, where it was found to provide a desirable emphasis on pattern matches while boosting the similarity scores. This weighted approach prioritises models that closely align with the query pattern, thereby refining the retrieval process. The combination of the threshold and weight parameters ensures that the algorithm generates meaningful and relevant results, facilitating the semantic reuse of physical models with improved precision and effectiveness.
2. **Term Similarity:** The last step of the algorithm consists of calculating the similarity between \(t_{q}\) and \(t_{m}\). The cosine distance \(d\) is calculated for each element \(t_{qi}\) and \(t_{mj}\), then multiplied by a weight function \(h(x,y)\) provided by Equation 1, where \(x\) is the number of distance calculations with a value larger than \(a\) and less or equal to \(b\) and \(y\) is the number of distance calculations with a value smaller or equal to \(a\). After conducting different tests and evaluations, the values of \(a=0.6\) and \(b=0.85\) were determined to offer the best precision in the algorithm. This weight function was implemented to take into account the relevance of terms in a query within a model. \[h(x,y)=\begin{cases}\frac{1}{y},&\text{for }a\geq d\\ \frac{1}{\sqrt{x}},&\text{for }a<d\leq b\\ 1,&\text{for }b<d\leq 1\end{cases}\] (1)  
Finally, the function to calculate the similarity of a model based on a query is presented in Equation (2). This function takes into account the cosine similarity between the query term (\(t_{q}\)) and model term (\(t_{m}\)) for each element in the query and model. The similarity score is then multiplied by a weight function \(h(x,y)\) that considers the relevance of terms in the query within the model.  
\[S_{model}=\sum_{i=0}^{n}\sum_{j=0}^{p}d(t_{qi},t_{mj})\cdot h(x,y)+w \tag{2}\]