Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

50 строки
1.3KB

  1. package pipeline
  2. import "sort"
  3. type ScheduledCandidate struct {
  4. Candidate Candidate `json:"candidate"`
  5. Priority float64 `json:"priority"`
  6. }
  7. // ScheduleCandidates picks the most valuable candidates for costly local refinement.
  8. // Current heuristic is intentionally simple and deterministic; later phases can add
  9. // richer scoring (novelty, persistence, profile-aware band priorities, decoder value).
  10. func ScheduleCandidates(candidates []Candidate, policy Policy) []ScheduledCandidate {
  11. if len(candidates) == 0 {
  12. return nil
  13. }
  14. out := make([]ScheduledCandidate, 0, len(candidates))
  15. for _, c := range candidates {
  16. if c.SNRDb < policy.MinCandidateSNRDb {
  17. continue
  18. }
  19. priority := c.SNRDb
  20. if c.BandwidthHz > 0 {
  21. priority += minFloat64(c.BandwidthHz/25000.0, 6)
  22. }
  23. if c.PeakDb > 0 {
  24. priority += c.PeakDb / 20.0
  25. }
  26. out = append(out, ScheduledCandidate{Candidate: c, Priority: priority})
  27. }
  28. sort.Slice(out, func(i, j int) bool {
  29. if out[i].Priority == out[j].Priority {
  30. return out[i].Candidate.CenterHz < out[j].Candidate.CenterHz
  31. }
  32. return out[i].Priority > out[j].Priority
  33. })
  34. limit := policy.MaxRefinementJobs
  35. if limit <= 0 || limit > len(out) {
  36. limit = len(out)
  37. }
  38. return out[:limit]
  39. }
  40. func minFloat64(a, b float64) float64 {
  41. if a < b {
  42. return a
  43. }
  44. return b
  45. }