|
@@ -8,6 +8,11 @@ import (
|
|
|
|
|
|
|
|
// --- Definitions -----------------------
|
|
// --- Definitions -----------------------
|
|
|
|
|
|
|
|
|
|
+// Structs implementing this interface are used to convert the average response time for a host
|
|
|
|
|
+// into a score that can be used to weight hosts in the epsilon greedy hostpool. Lower response
|
|
|
|
|
+// times should yield higher scores (we want to select the faster hosts more often) The default
|
|
|
|
|
+// LinearEpsilonValueCalculator just uses the reciprocal of the response time. In practice, any
|
|
|
|
|
+// decreasing function from the positive reals to the positive reals should work.
|
|
|
type EpsilonValueCalculator interface {
|
|
type EpsilonValueCalculator interface {
|
|
|
CalcValueFromAvgResponseTime(float64) float64
|
|
CalcValueFromAvgResponseTime(float64) float64
|
|
|
}
|
|
}
|
|
@@ -26,9 +31,10 @@ func (c *LinearEpsilonValueCalculator) CalcValueFromAvgResponseTime(v float64) f
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (c *LogEpsilonValueCalculator) CalcValueFromAvgResponseTime(v float64) float64 {
|
|
func (c *LogEpsilonValueCalculator) CalcValueFromAvgResponseTime(v float64) float64 {
|
|
|
- return math.Log(c.LinearEpsilonValueCalculator.CalcValueFromAvgResponseTime(v))
|
|
|
|
|
|
|
+ // we need to add 1 to v so that this will be defined on all positive floats
|
|
|
|
|
+ return c.LinearEpsilonValueCalculator.CalcValueFromAvgResponseTime(math.Log(v + 1.0))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (c *PolynomialEpsilonValueCalculator) CalcValueFromAvgResponseTime(v float64) float64 {
|
|
func (c *PolynomialEpsilonValueCalculator) CalcValueFromAvgResponseTime(v float64) float64 {
|
|
|
- return math.Pow(c.LinearEpsilonValueCalculator.CalcValueFromAvgResponseTime(v), c.Exp)
|
|
|
|
|
|
|
+ return c.LinearEpsilonValueCalculator.CalcValueFromAvgResponseTime(math.Pow(v, c.Exp))
|
|
|
}
|
|
}
|