File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ import (
8
8
9
9
// --- Definitions -----------------------
10
10
11
+ // Structs implementing this interface are used to convert the average response time for a host
12
+ // into a score that can be used to weight hosts in the epsilon greedy hostpool. Lower response
13
+ // times should yield higher scores (we want to select the faster hosts more often) The default
14
+ // LinearEpsilonValueCalculator just uses the reciprocal of the response time. In practice, any
15
+ // decreasing function from the positive reals to the positive reals should work.
11
16
type EpsilonValueCalculator interface {
12
17
CalcValueFromAvgResponseTime (float64 ) float64
13
18
}
@@ -26,9 +31,10 @@ func (c *LinearEpsilonValueCalculator) CalcValueFromAvgResponseTime(v float64) f
26
31
}
27
32
28
33
func (c * LogEpsilonValueCalculator ) CalcValueFromAvgResponseTime (v float64 ) float64 {
29
- return math .Log (c .LinearEpsilonValueCalculator .CalcValueFromAvgResponseTime (v ))
34
+ // we need to add 1 to v so that this will be defined on all positive floats
35
+ return c .LinearEpsilonValueCalculator .CalcValueFromAvgResponseTime (math .Log (v + 1.0 ))
30
36
}
31
37
32
38
func (c * PolynomialEpsilonValueCalculator ) CalcValueFromAvgResponseTime (v float64 ) float64 {
33
- return math . Pow ( c .LinearEpsilonValueCalculator .CalcValueFromAvgResponseTime (v ) , c .Exp )
39
+ return c .LinearEpsilonValueCalculator .CalcValueFromAvgResponseTime (math . Pow ( v , c .Exp ) )
34
40
}
You can’t perform that action at this time.
0 commit comments