File tree 1 file changed +13
-1
lines changed
RecoLocalCalo/EcalRecAlgos/src
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,7 @@ bool PulseChiSqSNNLS::NNLS() {
302
302
int iter = 0 ;
303
303
Index idxwmax = 0 ;
304
304
double wmax = 0.0 ;
305
+ double threshold = 1e-11 ;
305
306
// work = PulseVector::zeros();
306
307
while (true ) {
307
308
// can only perform this step if solution is guaranteed viable
@@ -316,7 +317,12 @@ bool PulseChiSqSNNLS::NNLS() {
316
317
wmax = updatework.tail (nActive).maxCoeff (&idxwmax);
317
318
318
319
// convergence
319
- if (wmax<1e-11 || (idxwmax==idxwmaxprev && wmax==wmaxprev)) break ;
320
+ if (wmax<threshold || (idxwmax==idxwmaxprev && wmax==wmaxprev)) break ;
321
+
322
+ // worst case protection
323
+ if (iter>=500 ) {
324
+ edm::LogWarning (" PulseChiSqSNNLS::NNLS()" ) << " Max Iterations reached at iter " << iter << std::endl;
325
+ }
320
326
321
327
// unconstrain parameter
322
328
Index idxp = _nP + idxwmax;
@@ -384,6 +390,12 @@ bool PulseChiSqSNNLS::NNLS() {
384
390
--_nP;
385
391
}
386
392
++iter;
393
+
394
+ // adaptive convergence threshold to avoid infinite loops but still
395
+ // ensure best value is used
396
+ if (iter%50 ==0 ) {
397
+ threshold *= 10 .;
398
+ }
387
399
}
388
400
389
401
return true ;
You can’t perform that action at this time.
0 commit comments