23 lines
360 B
Go
23 lines
360 B
Go
package gambit
|
|
|
|
type Gang struct {
|
|
b Bandit
|
|
}
|
|
|
|
func (g *Gang) WithBandit(b Bandit) {
|
|
g.b = b
|
|
}
|
|
|
|
func (g *Gang) AllocateSolution() ([]int, []float64) {
|
|
a := make([]int, g.b.Size())
|
|
b := make([]float64, g.b.Size())
|
|
g.b.Count(a)
|
|
g.b.Reward(b)
|
|
return a, b
|
|
}
|
|
|
|
func (g *Gang) Observe(score float64, reward float64) {
|
|
g.b.Update(g.b.Select(score), reward)
|
|
|
|
}
|