2023-07-06 09:10:29 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"lukechampine.com/frand"
|
|
|
|
"tuxpa.in/a/gambit"
|
|
|
|
"tuxpa.in/a/gambit/algo"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
g := &gambit.Gang{}
|
|
|
|
b := &algo.EpsilonGreedy{Epsilon: 0.1}
|
|
|
|
b.Reset(4)
|
|
|
|
g.WithBandit(b)
|
|
|
|
|
|
|
|
n := 100
|
|
|
|
for i := 0; i < n; i++ {
|
2023-07-06 09:48:20 +00:00
|
|
|
g.Observe(
|
2023-07-06 09:10:29 +00:00
|
|
|
// select a random arm
|
2023-07-06 09:48:20 +00:00
|
|
|
frand.Float64(),
|
2023-07-06 09:10:29 +00:00
|
|
|
// and supply a random score
|
|
|
|
float64(frand.Intn(4)),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
log.Println(g.AllocateSolution())
|
|
|
|
}
|