# Meshfree Variational-Physics-Informed Neural Networks (MF-VPINN): An Adaptive Training Strategy
## 2 Problem Formulation
### The Choice of \(\mathcal{M}\) and \(\mathcal{P}\)  
In this section, the procedure adopted to generate the set of test functions used to train the MF-VPINN is described. We propose an iterative approach, in which the MF-VPINN is initially trained with very few test functions, and then other test functions are added in the regions of the domain in which the \(H_{1}\) norm of the error is larger. We anticipate that, as shown in Section 3.3, generating test functions in regions where \(r_{h,i}^{2}\) is large may not lead to accurate solutions because \(r_{h,i}^{2}\) is not proportional to the \(H_{1}\) error. Therefore, such a choice may increase the density of test functions where they are not required while maintaining only a few test functions in regions in which the error is large. Instead, we use the error indicator \(\eta_{i}\) defined in (25). Let us initially consider a cover \(\mathcal{P}_{0}=\left\{P_{i}\right\}_{i=1}^{n_{\text{patches}}}\) of \(\Omega\) comprising a few patches (i.e., \(n_{\text{patches}}\) is a small integer) and the corresponding set of mappings \(\mathcal{M}_{0}=\left\{M_{i}\right\}_{i=1}^{n_{\text{patches}}}\) and test functions \(\left\{\varphi_{i}\right\}_{i=1}^{n_{\text{patches}}}\). These sets induce a loss function \(R_{h}^{2}(w;\mathcal{P}_{0})\) as defined in (14), which is used to train an MF-VPINN. After this initial training, one computes \(\eta_{i}^{\gamma}=\gamma_{i}\eta_{i}\) for each patch \(P_{i}\in\mathcal{P}_{0}\) and stores the result in the array \(\mathbf{\eta}=\left[\eta_{1}^{\gamma},\ldots,\eta_{n_{\text{patches}}}^{\gamma}\right]\). Note that \(\eta_{i}^{\gamma}\) is a suitable rescaling of \(\eta_{i}\) to get rid of dependence from the size of \(P_{i}\). Let us choose a threshold \(1\leq\tau_{0}\leq n_{\text{patches}}\), sort \(\mathbf{\eta}\) in descending order obtaining \(\mathbf{\eta}_{\text{sort}}=\left[\eta_{s_{1}}^{\gamma},\ldots,\eta_{s_{\text{ patches}}}^{\gamma}\right]\) (where we denote by \([s_{1},\ldots,s_{n_{\text{patches}}}]\) the index set corresponding to a suitable permutation of \([1,\ldots,n_{\text{patches}}]\)) and consider the vector \(\overline{\mathbf{\eta}}_{0}=\left[\eta_{s_{1}}^{\gamma},\ldots,\eta_{s_{0}}^{ \gamma}\right]\). It is possible to note that \(\overline{\mathbf{\eta}}_{0}\) contains only the \(\tau_{0}\) worst values of the indicator; it thus allows us to understand where the error is higher and where additional test functions are required to increase the model accuracy. It is then possible to move forward with the second iteration of the iterative training. For each patch \(P_{i}\) such that \(\eta_{i}^{\gamma}\in\overline{\mathbf{\eta}}_{0}\), we generate \(k_{\text{new}}\) new patches \(P_{i}^{k}\), \(k=1,\ldots,k_{\text{new}}\) with centers inside \(P_{i}\) and areas such that \(\operatorname{area}(P_{i}^{k})<\cup_{k=1}^{k_{\text{new}}}\operatorname{area}(P _{i}^{k})<c\cdot\operatorname{area}(P_{i})\), where \(c>1\) is a tunable parameter. In the numerical experiments, we use \(c=1.25\). There exist different strategies to choose the number, the dimension, and the position of the centers of the new patches. Such strategies are described in Section 3 with particular attention to the effects of these choices on the MF-VPINN accuracy. Let us denote by \(\mathcal{P}_{1}\) the set \(\mathcal{P}_{1}=\mathcal{P}_{0}\cup\{P_{s_{1}}^{k}\}_{k=1}^{k_{\text{new}}} \cup\cdots\cup\{P_{s_{0}}^{k}\}_{k=1}^{k_{\text{new}}}\) and by \(\mathcal{M}_{1}\) the corresponding set of mappings. Then, it is possible to define the loss function \(R_{h}^{2}(w;\mathcal{P}_{1})\), continue the training of the previously trained MF-VPINN, compute the error indicator \(\eta_{i}^{\gamma}\) for each patch \(P_{i}\in\mathcal{P}_{1}\), and obtain the vector \(\overline{\mathbf{\eta}}_{1}\) used to decide where to insert the new patches to generate \(\mathcal{P}_{2}\).