This commit is contained in:
parent
2f1636a33c
commit
5f5c236213
|
@ -2,9 +2,12 @@ package algo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"lukechampine.com/frand"
|
"lukechampine.com/frand"
|
||||||
|
"tuxpa.in/a/gambit"
|
||||||
"tuxpa.in/a/gambit/helper"
|
"tuxpa.in/a/gambit/helper"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ gambit.Bandit = (*EpsilonGreedy)(nil)
|
||||||
|
|
||||||
type EpsilonGreedy struct {
|
type EpsilonGreedy struct {
|
||||||
Epsilon float64
|
Epsilon float64
|
||||||
cr helper.CountReward
|
cr helper.CountReward
|
||||||
|
|
|
@ -17,13 +17,12 @@ func main() {
|
||||||
|
|
||||||
n := 100
|
n := 100
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
b.Update(
|
g.Observe(
|
||||||
// select a random arm
|
// select a random arm
|
||||||
b.Select(frand.Float64()),
|
frand.Float64(),
|
||||||
// and supply a random score
|
// and supply a random score
|
||||||
float64(frand.Intn(4)),
|
float64(frand.Intn(4)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(g.AllocateSolution())
|
log.Println(g.AllocateSolution())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue