func (m *Miner) takeOne(queue []lattice.Node) ([]lattice.Node, lattice.Node) { s := stats.Sample(10, len(queue)) k := m.Scorer.Kernel(queue, s) var i int var ms float64 if len(k) > 0 { i, ms = stats.Max(stats.Srange(len(k)), func(i int) float64 { return k.Mean(i) }) i = s[i] } else { i, ms = stats.Max(s, func(i int) float64 { return m.Scorer.Score(queue[i], queue) }) } errors.Logf("DEBUG", "max score %v, queue len %v, taking %v", ms, len(queue), queue[i]) return pop(queue, i) }
func (m *Miner) dropOne(queue []lattice.Node) []lattice.Node { s := stats.Sample(10, len(queue)) k := m.Scorer.Kernel(queue, s) var i int var ms float64 if len(k) > 0 { i, ms = stats.Min(stats.Srange(len(k)), func(i int) float64 { return k.Mean(i) }) i = s[i] } else { i, ms = stats.Min(s, func(i int) float64 { return m.Scorer.Score(queue[i], queue) }) } errors.Logf("DEBUG", "min score %v, queue len %v, dropping %v", ms, len(queue), queue[i]) queue, _ = pop(queue, i) return queue }
func (k Kernel) Mean(i int) float64 { mean, _ := stats.Mean(stats.Srange(len(k)), func(j int) float64 { return k[i][j] }) return mean }