@@ -95,6 +95,8 @@ def fit(
9595 dlens_updated = norm_calc_max_n_const_sensors (self .constrainedIndices ,dlens ,p ,j , self .nConstrainedSensors ,self .all_sensorloc ,self .nSensors )
9696 elif self .constraint_option == "exact_n_const_sensors" :
9797 dlens_updated = norm_calc_exact_n_const_sensors (self .constrainedIndices ,dlens ,p ,j ,self .nConstrainedSensors )
98+ elif self .constraint_option == "predetermined_end" :
99+ dlens_updated = predetermined_norm_calc (self .constrainedIndices , dlens , p , j , self .nConstrainedSensors , self .nSensors )
98100
99101 # Choose pivot
100102 i_piv = np .argmax (dlens_updated )
@@ -202,6 +204,38 @@ def norm_calc_max_n_const_sensors(lin_idx, dlens, piv, j, const_sensors,all_sens
202204 dlens [didx ] = 0
203205 return dlens
204206
207+ def predetermined_norm_calc (lin_idx , dlens , piv , j , n_const_sensors , n_sensors ):
208+ """
209+ Function for mapping constrained sensor locations with the QR procedure.
210+
211+ Parameters
212+ ----------
213+ lin_idx: np.ndarray, shape [No. of constrained locations]
214+ Array which contains the constrained locationsof the grid in terms of column indices of basis_matrix.
215+ dlens: np.ndarray, shape [Variable based on j]
216+ Array which contains the norm of columns of basis matrix.
217+ piv: np.ndarray, shape [n_features]
218+ Ranked list of sensor locations.
219+ n_const_sensors: int,
220+ Number of sensors to be placed in the constrained area.
221+ j: int,
222+ Iterative variable in the QR algorithm.
223+
224+ Returns
225+ -------
226+ dlens : np.darray, shape [Variable based on j] with constraints mapped into it.
227+ """
228+ if (n_sensors - n_const_sensors ) <= j <= n_sensors : # force sensors into constraint region
229+ #idx = np.arange(dlens.shape[0])
230+ #dlens[np.delete(idx, lin_idx)] = 0
231+
232+ didx = np .isin (piv [j :],lin_idx ,invert = True )
233+ dlens [didx ] = 0
234+ else :
235+ didx = np .isin (piv [j :],lin_idx ,invert = False )
236+ dlens [didx ] = 0
237+ return dlens
238+
205239
206240
207241if __name__ == '__main__' :
0 commit comments