comparison pkg/controllers/fwa.go @ 5252:aebe1a12e8b9 new-fwa

If looking at sections/stretches the bottleneck with the lowest class determines the class of the whole construct.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 13 May 2020 09:29:55 +0200
parents 1fce0fd81f46
children 878d52d95e37
comparison
equal deleted inserted replaced
5251:1fce0fd81f46 5252:aebe1a12e8b9
345 345
346 next = current.AddDate(0, 0, 1) 346 next = current.AddDate(0, 0, 1)
347 347
348 // Assume that a bottleneck is over LDC. 348 // Assume that a bottleneck is over LDC.
349 overLDC := true 349 overLDC := true
350 highest := -1 350 lowest := len(counters) - 1
351 351
352 var hasValid bool 352 var hasValid bool
353 353
354 // check all bottlenecks 354 // check all bottlenecks
355 for i, validity := range validities { 355 for i, validity := range validities {
383 if min := minClass(bns[i].measurements.classify( 383 if min := minClass(bns[i].measurements.classify(
384 current, next, 384 current, next,
385 chooseBreaks[vs.limiting], 385 chooseBreaks[vs.limiting],
386 limitingAccess[vs.limiting]), 386 limitingAccess[vs.limiting]),
387 12*time.Hour, 387 12*time.Hour,
388 ); min > highest { 388 ); min < lowest {
389 highest = min 389 lowest = min
390 } 390 }
391 } 391 }
392 392
393 if hasValid { 393 if hasValid {
394 if overLDC { 394 if overLDC {
395 overLDCDays++ 395 overLDCDays++
396 } 396 }
397 if highest > -1 { 397 counters[lowest]++
398 counters[highest]++
399 }
400 } else { // assume that all is in best conditions 398 } else { // assume that all is in best conditions
401 overLDCDays++ 399 overLDCDays++
402 counters[len(counters)-1]++ 400 counters[len(counters)-1]++
403 } 401 }
404 402
444 for i, v := range classes { 442 for i, v := range classes {
445 if sum += v; sum >= threshold { 443 if sum += v; sum >= threshold {
446 return i 444 return i
447 } 445 }
448 } 446 }
449 return -1 447 return len(classes) - 1
450 } 448 }
451 449
452 func dusk(t time.Time) time.Time { 450 func dusk(t time.Time) time.Time {
453 return time.Date( 451 return time.Date(
454 t.Year(), 452 t.Year(),